offer.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. <template>
  2. <view class="content">
  3. <view v-if="pageData.tab !== 1 && pageData.statue != 3">
  4. <view class="box">
  5. <view class="title">报价记录</view>
  6. <view class="offer_detail" v-if="pageData.user_order.amount == '' || !pageData.user_order.amount">
  7. <view class="offer_money">未填写报价</view>
  8. </view>
  9. <block v-for="(item,index) in pageData.user_order.amounts" :key="index">
  10. <view class="offer_detail hflex acenter" v-if="item.user_id == userId">
  11. <view class="offer_left">第{{index + 1}}次报价</view>
  12. <view class="offer_money">{{item.amount?item.amount:'暂无报价'}}</view>
  13. </view>
  14. </block>
  15. </view>
  16. </view>
  17. <view v-else-if="pageData.tab == 1 && pageData.item[index].statue != 3">
  18. <view class="box">
  19. <view class="title">报价记录</view>
  20. <view class="offer_detail" v-if="pageData.items[index].user_order.amount == '' || !pageData.items[index].user_order.amount">
  21. <view class="offer_money">未填写报价</view>
  22. </view>
  23. <block v-for="(item,index1) in pageData.items[index].user_order.amounts" :key="index1">
  24. <view class="offer_detail hflex acenter" v-if="item.user_id == userId">
  25. <view class="offer_left">第{{index1 + 1}}次报价</view>
  26. <view class="offer_money">{{item.amount?item.amount:'暂无报价'}}</view>
  27. </view>
  28. </block>
  29. </view>
  30. </view>
  31. <view class="box" v-if="pageData.tab == 1 && pageData.items[index].status !=3">
  32. <view class="title">订单报价</view>
  33. <view class="input hflex acenter">
  34. <view>¥</view>
  35. <u-input v-model="money" border="none" placeholder="请填写你的报价"></u-input>
  36. </view>
  37. <view class="input_bg hflex acenter" v-if="tab == 3 || tab == 4">
  38. <view class="price">报价说明</view>
  39. <u-input v-model="description" placeholder="例如:税前/税后" border="none"></u-input>
  40. </view>
  41. <view class="input_bg hflex acenter" v-if="tab == 1 || tab == 2">
  42. <view class="price">货期</view>
  43. <u-input v-model="lead_time" placeholder="例如: 1个月" border="none"></u-input>
  44. </view>
  45. <view class="input_bg" v-if="tab == 2 || tab == 1">
  46. <view class="price">产品介绍以及报价说明</view>
  47. <u--textarea v-model="description" placeholder="例如:税前/税后" border="none"></u--textarea>
  48. </view>
  49. <view class="hflex acenter jbetween" v-if="tab == 1">
  50. <view class="price">是否现货</view>
  51. <u-switch v-model="is_stock" activeColor="#506dff" inactiveColor="rgb(230, 230, 230)" @change="change"></u-switch>
  52. </view>
  53. <view class="text_style1">上传图片及资质证明图片</view>
  54. <view class="upload">
  55. <u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" :maxCount="3" name="1" multiple :previewFullImage="true" width="200rpx" height="200rpx">
  56. </u-upload>
  57. </view>
  58. </view>
  59. <view class="box" v-if="pageData.status != 3 && pageData.tab !=1">
  60. <view class="title">订单报价</view>
  61. <view class="input hflex acenter">
  62. <view>¥</view>
  63. <u-input v-model="money" border="none" placeholder="请填写你的报价"></u-input>
  64. </view>
  65. <view class="input_bg hflex acenter" v-if="tab == 3 || tab == 4">
  66. <view class="price">报价说明</view>
  67. <u-input v-model="description" placeholder="例如:税前/税后" border="none"></u-input>
  68. </view>
  69. <view class="input_bg hflex acenter" v-if="tab == 1 || tab == 2">
  70. <view class="price">货期</view>
  71. <u-input v-model="lead_time" placeholder="例如: 1个月" border="none"></u-input>
  72. </view>
  73. <view class="input_bg" v-if="tab == 2 || tab == 1">
  74. <view class="price">产品介绍以及报价说明</view>
  75. <u--textarea v-model="description" placeholder="例如:税前/税后" border="none"></u--textarea>
  76. </view>
  77. <view class="hflex acenter jbetween" v-if="tab == 1">
  78. <view class="price">是否现货</view>
  79. <u-switch v-model="is_stock" activeColor="#506dff" inactiveColor="rgb(230, 230, 230)" @change="change"></u-switch>
  80. </view>
  81. <view class="text_style1">上传图片及资质证明图片</view>
  82. <view class="upload">
  83. <u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" :maxCount="3" name="1" multiple :previewFullImage="true" width="200rpx" height="200rpx">
  84. </u-upload>
  85. </view>
  86. </view>
  87. <view v-if="pageData.user_order">
  88. <view class="box" v-if="pageData.status == 3">
  89. <view class="title">报价信息</view>
  90. <view class="hflex acenter cell" >
  91. <view class="left">价格</view>
  92. <view class="right" style="font-size: 32rpx;color: #222222;">{{money2?money2:'暂无报价'}}</view>
  93. </view>
  94. <view class="hflex acenter cell" v-if="lead_time">
  95. <view class="left">货期</view>
  96. <view class="right">{{lead_time}}</view>
  97. </view>
  98. <view class="hflex acenter cell">
  99. <view class="left">说明</view>
  100. <view class="right">{{description}}</view>
  101. </view>
  102. <view class="hflex acenter cell" v-if="is_stock">
  103. <view class="left">是否现货</view>
  104. <view class="right">{{is_stock==0?'否':'是'}}</view>
  105. </view>
  106. <!-- <block v-if="pageData.status == 3 && pageData.file">
  107. <view class="text_style1 cell">图片及资质证明图片</view>
  108. <view class="hflex acenter fwrap">
  109. <block v-for="(item,index1) in pageData.user_order.file" :key="index1">
  110. <image :src="item" mode="aspectFill" class="imgs"></image>
  111. </block>
  112. </view>
  113. </block> -->
  114. <block v-if="pageData.status == 3 && pageData.user_order.images">
  115. <view class="text_style1 cell">图片及资质证明图片</view>
  116. <view class="hflex acenter fwrap">
  117. <block v-for="(item,index1) in pageData.user_order.images" :key="index1">
  118. <image :src="item" mode="aspectFill" class="imgs"></image>
  119. </block>
  120. </view>
  121. </block>
  122. </view>
  123. </view>
  124. <view class="" v-if="pageData.items[index].user_order">
  125. <view class="box" v-if="pageData.items[index].status == 3">
  126. <view class="title">报价信息</view>
  127. <view class="hflex acenter cell" >
  128. <view class="left">价格</view>
  129. <view class="right" style="font-size: 32rpx;color: #222222;">{{money2?money2:'暂无报价'}}</view>
  130. </view>
  131. <view class="hflex acenter cell" v-if="lead_time">
  132. <view class="left">货期</view>
  133. <view class="right">{{lead_time}}</view>
  134. </view>
  135. <view class="hflex acenter cell">
  136. <view class="left">说明</view>
  137. <view class="right">{{description}}</view>
  138. </view>
  139. <view class="hflex acenter cell" v-if="is_stock">
  140. <view class="left">是否现货</view>
  141. <view class="right">{{is_stock==0?'否':'是'}}</view>
  142. </view>
  143. <block v-if="pageData.items[index].status == 3 && pageData.images">
  144. <view class="text_style1 cell">图片及资质证明图片</view>
  145. <view class="hflex acenter fwrap">
  146. <block v-for="(item,index1) in pageData.items[index].user_order.images" :key="index1">
  147. <image :src="item" mode="aspectFill" class="imgs"></image>
  148. </block>
  149. </view>
  150. </block>
  151. </view>
  152. </view>
  153. <view v-if="pageData.tab == 1 && pageData.items[index].status !=3">
  154. <view class="btn" @click="create" v-if="pageData.items[index].user_order">{{pageData.items[index].user_order.amounts.length > 0 ? '重新报价' : '立即报价'}}</view>
  155. <view class="btn" @click="create" v-else>立即报价</view>
  156. <view class="text">友情提醒</view>
  157. <view class="text text2">请认真核算报价,报价后不可修改和删除,报价时间约需x天内报价,逾期影响信用等级。</view>
  158. </view>
  159. <view v-if="pageData.status != 3 && pageData.tab != 1">
  160. <view class="btn" @click="create" v-if="pageData.user_order">{{pageData.user_order.amounts.length > 0 ? '重新报价' : '立即报价'}}</view>
  161. <view class="btn" @click="create" v-else>立即报价</view>
  162. <view class="text">友情提醒</view>
  163. <view class="text text2">请认真核算报价,报价后不可修改和删除,报价时间约需x天内报价,逾期影响信用等级。</view>
  164. </view>
  165. </view>
  166. </template>
  167. <script>
  168. import $api from '@/static/js/api.js'
  169. var that = ''
  170. export default {
  171. data() {
  172. return {
  173. id: '',
  174. pageData: {},
  175. tab: '',
  176. fileList1: [],
  177. money: '',
  178. money2: '',
  179. index: '',
  180. is_stock: '',
  181. description: '',
  182. lead_time: '',
  183. userId: '',
  184. }
  185. },
  186. onLoad(options) {
  187. that = this
  188. that.userId = uni.getStorageSync('id')
  189. that.id = options.id
  190. that.tab = options.tab
  191. if(options.index) {
  192. that.index = options.index
  193. }
  194. that.getData()
  195. },
  196. methods: {
  197. getData() {
  198. var url = ""
  199. switch(that.tab) {
  200. case '1':
  201. url = '/data/api.auth.Purchase/show';
  202. break;
  203. case '2':
  204. url = '/data/api.auth.Purchase/production_show';
  205. break;
  206. case '3':
  207. url = '/data/api.auth.Purchase/coor_show';
  208. break;
  209. case '4':
  210. url = '/data/api.auth.Purchase/ocean_show';
  211. break;
  212. }
  213. $api.req({
  214. url: url,
  215. data: {
  216. id: that.id
  217. }
  218. }, function(res) {
  219. if(res.code == 1) {
  220. that.pageData = res.data
  221. if(that.tab == '1') {
  222. that.money2 = that.pageData.items[that.index].user_order.amount
  223. that.lead_time = that.pageData.items[that.index].user_order.date
  224. that.description = that.pageData.items[that.index].user_order.desc
  225. that.is_stock = that.pageData.items[that.index].user_order.is_have == 1 ? true : false
  226. if(JSON.stringify(that.pageData.items[that.index].user_order.images) !== '{}') {
  227. for(var i=0;i<that.pageData.items[that.index].user_order.images.length;i++) {
  228. var img = {
  229. url: that.pageData.items[that.index].user_order.images[i]
  230. }
  231. that.fileList1.push(img)
  232. }
  233. }
  234. // that.fileList1 = that.pageData.items[that.index].user_order.images
  235. } else {
  236. that.money2 = that.pageData.user_order.amount
  237. that.lead_time = that.pageData.user_order.date
  238. that.description = that.pageData.user_order.desc
  239. that.is_stock = that.pageData.user_order.is_have == 1 ? true : false
  240. for(var i=0;i<that.pageData.user_order.images.length;i++) {
  241. var img = {
  242. url: that.pageData.user_order.images[i]
  243. }
  244. that.fileList1.push(img)
  245. }
  246. }
  247. }
  248. })
  249. },
  250. // 是否现货
  251. change(e) {
  252. console.log(e);
  253. that.is_stock = e
  254. },
  255. // 删除图片
  256. deletePic(event) {
  257. // that.userInfo.imgList.splice(event.index, 1)
  258. console.log(event)
  259. this[`fileList${event.name}`].splice(event.index, 1)
  260. },
  261. // 新增图片
  262. async afterRead(event) {
  263. uni.showLoading({
  264. title: '上传中',
  265. mask: true
  266. })
  267. let lists = [].concat(event.file)
  268. let fileListLen = this[`fileList${event.name}`].length
  269. lists.map((item) => {
  270. this[`fileList${event.name}`].push({
  271. ...item,
  272. status: 'uploading',
  273. message: '上传中'
  274. })
  275. })
  276. for (let i = 0; i < lists.length; i++) {
  277. const result = await this.uploadFilePromise(lists[i].url)
  278. let item = this[`fileList${event.name}`][fileListLen]
  279. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  280. status: 'success',
  281. message: '',
  282. url: result.url
  283. }))
  284. fileListLen++
  285. if(lists.length - 1 == i) {
  286. uni.hideLoading()
  287. }
  288. }
  289. },
  290. uploadFilePromise(url) {
  291. return new Promise((resolve, reject) => {
  292. let a = uni.uploadFile({
  293. url: $api.config.baseUrl + '/data/api.auth.Center/upload',
  294. filePath: url,
  295. name: 'file',
  296. header: {
  297. 'content-type': 'application/x-www-form-urlencoded',
  298. 'api-token': uni.getStorageSync('token').token?uni.getStorageSync('token').token:'',
  299. 'api-name': 'wxapp'
  300. },
  301. formData: {
  302. user: 'test'
  303. },
  304. success: (res) => {
  305. setTimeout(() => {
  306. var data = JSON.parse(res.data)
  307. resolve(data.data)
  308. }, 1000)
  309. }
  310. });
  311. })
  312. },
  313. create() {
  314. var url = ""
  315. var images = []
  316. for(var i=0;i<that.fileList1.length;i++) {
  317. images.push(that.fileList1[i].url)
  318. }
  319. if(that.description == "") {
  320. $api.info('请填写报价说明')
  321. return
  322. }
  323. if(that.money == '') {
  324. $api.info('请填写报价')
  325. return
  326. }
  327. /* if(images.length == 0) {
  328. $api.info('请上传图片资质')
  329. return
  330. } */
  331. var data = {}
  332. switch(that.pageData.tab) {
  333. case 1:
  334. url = '/data/api.auth.Purchase/purchase_create';
  335. data = {
  336. id: that.pageData.items[that.index].id,
  337. amount: that.money,
  338. date: that.lead_time,
  339. desc: that.description,
  340. is_have: that.is_stock?1:0,
  341. images: images,
  342. is_edit: 1
  343. };
  344. break;
  345. case 2:
  346. url = '/data/api.auth.Purchase/production_create';
  347. data = {
  348. id: that.pageData.id,
  349. amount: that.money,
  350. date: that.lead_time,
  351. desc: that.description,
  352. images: images,
  353. is_edit: 1
  354. };
  355. break;
  356. case 3:
  357. url = '/data/api.auth.Purchase/coor_create';
  358. data = {
  359. id: that.pageData.id,
  360. amount: that.money,
  361. desc: that.description,
  362. images: images,
  363. is_edit: 1
  364. };
  365. break;
  366. case 4:
  367. url = '/data/api.auth.Purchase/ocean_create';
  368. data = {
  369. id: that.pageData.id,
  370. amount: that.money,
  371. desc: that.description,
  372. images: images,
  373. is_edit: 1
  374. };
  375. break;
  376. }
  377. $api.req({
  378. url: url,
  379. method: 'POST',
  380. data: data
  381. }, function(res) {
  382. if(res.code == 1) {
  383. /* that.getData()
  384. that.name = "",
  385. that.money = ""
  386. that.fileList1 = [] */
  387. $api.jump(-1)
  388. }
  389. })
  390. }
  391. },
  392. }
  393. </script>
  394. <style lang="scss" scoped>
  395. .content::v-deep {
  396. background: #F4F4F4;
  397. padding: 0 30rpx;
  398. .box {
  399. width: 100%;
  400. background: #FFFFFF;
  401. border-radius: 24rpx;
  402. box-sizing: border-box;
  403. padding: 24rpx 20rpx;
  404. margin-top: 20rpx;
  405. .title {
  406. font-size: 28rpx;
  407. font-weight: 500;
  408. color: #222222;
  409. }
  410. .cell {
  411. padding: 18rpx 0;
  412. }
  413. .left {
  414. font-size: 26rpx;
  415. font-weight: 400;
  416. color: #222222;
  417. line-height: 36rpx;
  418. padding-right: 20rpx;
  419. }
  420. .right {
  421. font-size: 26rpx;
  422. font-weight: 400;
  423. color: #222222;
  424. line-height: 36rpx;
  425. }
  426. .offer_detail {
  427. width: 100%;
  428. height: 68rpx;
  429. background: #F4F4F4;
  430. border-radius: 16rpx;
  431. box-sizing: border-box;
  432. padding: 20rpx;
  433. margin: 10rpx 0;
  434. .offer_left {
  435. font-size: 22rpx;
  436. font-weight: 400;
  437. color: #777777;
  438. margin-right: 40rpx;
  439. }
  440. .offer_money {
  441. font-size: 28rpx;
  442. font-weight: 400;
  443. color: #FF3636;
  444. }
  445. }
  446. .input {
  447. width: 100%;
  448. height: 88rpx;
  449. background: #F4F4F4;
  450. border-radius: 16rpx;
  451. font-size: 32rpx;
  452. font-weight: 500;
  453. color: #222222;
  454. box-sizing: border-box;
  455. padding: 0 20rpx;
  456. line-height: 88rpx;
  457. margin: 20rpx 0;
  458. }
  459. .input_bg {
  460. background: #F4F4F4;
  461. border-radius: 8px;
  462. box-sizing: border-box;
  463. padding: 16rpx 20rpx;
  464. margin: 20rpx 0;
  465. .price {
  466. font-size: 32rpx;
  467. font-weight: 500;
  468. color: #222222;
  469. padding-right: 20rpx;
  470. }
  471. .u-textarea {
  472. background-color: #F4F4F4 !important;
  473. }
  474. .red {
  475. font-size: 28rpx;
  476. font-weight: bold;
  477. color: #FF3636;
  478. }
  479. }
  480. .text_style1 {
  481. font-size: 28rpx;
  482. font-weight: 500;
  483. color: #444444;
  484. }
  485. .imgs {
  486. width: 200rpx;
  487. height: 200rpx;
  488. border-radius: 16rpx;
  489. margin: 0 15rpx 20rpx 0;
  490. }
  491. .upload {
  492. margin-top: 20rpx;
  493. }
  494. }
  495. .btn {
  496. margin: 56rpx 0 22rpx;
  497. width: 100%;
  498. height: 88rpx;
  499. background: #506DFF;
  500. border-radius: 44rpx;
  501. font-size: 36rpx;
  502. font-weight: 500;
  503. text-align: center;
  504. line-height: 88rpx;
  505. color: #FFFFFF;
  506. }
  507. .text {
  508. font-size: 24rpx;
  509. font-weight: 400;
  510. color: #222222;
  511. }
  512. .text2 {
  513. color: #999999;
  514. }
  515. }
  516. </style>