自主产品,供应链食堂系统。将两个端拆开了。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

586 lines
16 KiB

5 years ago
5 years ago
  1. <template>
  2. <view>
  3. <view class="head">
  4. <view class="lf-row-between list" v-if="order.canteen">
  5. <lf-image class="image" :src="order.canteen.logo" errSrc="../../static/images/canteen_avatar.png"></lf-image>
  6. <view class="info">
  7. <view class="lf-font-32 lf-color-black lf-font-bold">{{ order.canteen.canteen_name }}</view>
  8. <view class="lf-font-24 lf-color-555">{{ order.canteen.address }}</view>
  9. <view class="lf-font-24 lf-color-555" @click="call(order.canteen.ctl_phone)">{{order.canteen.ctl_man}} {{ order.canteen.ctl_phone }}</view>
  10. </view>
  11. </view>
  12. </view>
  13. <self-line></self-line>
  14. <view class="lf-border-box lf-bg-white">
  15. <lf-stepbar :list="stepList"></lf-stepbar>
  16. </view>
  17. <self-line v-if="order.car_license || supplier_voucher.length || canteen_voucher.length ||order.contact_name"></self-line>
  18. <view class="head">
  19. <view class="lf-row-between list">
  20. <view>采购人</view>
  21. <view class="lf-font-bold">{{order.contact_name}}</view>
  22. </view>
  23. <view class="lf-row-between list">
  24. <view>联系电话</view>
  25. <view class="lf-font-bold" @click="call(order.contact_phone)">{{order.contact_phone}}</view>
  26. </view>
  27. <view class="lf-row-between list">
  28. <view>采购单</view>
  29. <view class="lf-font-bold">{{order.p_sn}}</view>
  30. </view>
  31. <view class="lf-row-between list">
  32. <view>批次号</view>
  33. <view class="lf-font-bold">{{order.batch_sn}}</view>
  34. </view>
  35. <view class="lf-row-between list">
  36. <view>预计收货时间</view>
  37. <view class="lf-font-bold">{{order.deadline_text}}</view>
  38. </view>
  39. <view class="lf-row-between list" v-if="order.receive_time">
  40. <view>实际收货时间</view>
  41. <view class="lf-font-bold">{{order.receive_time}}</view>
  42. </view>
  43. <block v-if="order.car_license">
  44. <view class="lf-row-between list">
  45. <view>车辆</view>
  46. <view class="lf-font-bold">{{order.car_license}}</view>
  47. </view>
  48. <view class="lf-row-between list">
  49. <view>司机</view>
  50. <view class="lf-font-bold">{{order.deliver_man}}</view>
  51. </view>
  52. <view class="lf-row-between list">
  53. <view>联系电话</view>
  54. <view class="lf-font-bold">{{order.deliver_phone}}</view>
  55. </view>
  56. </block>
  57. <view class="list" v-if="supplier_voucher.length">
  58. <view>供应商证明材料</view>
  59. <view class="lf-flex-wrap lf-m-t-10">
  60. <lf-image :src="item" class="ms-img" @click="lookImage(index, 'supplier_voucher')" v-for="(item, index) in supplier_voucher" :key="index"></lf-image>
  61. </view>
  62. </view>
  63. <view class="list" v-if="canteen_voucher.length">
  64. <view>食堂证明材料</view>
  65. <view class="lf-flex-wrap lf-m-t-10">
  66. <lf-image :src="item" class="ms-img" @click="lookImage(index, 'canteen_voucher')" v-for="(item, index) in canteen_voucher" :key="index"></lf-image>
  67. </view>
  68. </view>
  69. </view>
  70. <self-line></self-line>
  71. <view class="lf-m-t-30 lf-m-l-32 lf-m-r-32">
  72. <view class="lf-font-32 lf-color-black lf-font-bold lf-m-b-20">物资明细</view>
  73. <wyb-table v-if="contents.length" :first-line-fixed="true" contentBgColor="#eef6fe" :headers="headers" :contents="contents" width="max-content" height="80vh"></wyb-table>
  74. </view>
  75. <view style="height: 140rpx;"></view>
  76. <!-- 操作按钮 -->
  77. <view class="fixed-bottom">
  78. <view v-if="type == '待接单'" class="lf-row-flex-end">
  79. <button class="btn btn2" :class="{'lf-btn-disabled': button_click}" style="background-color: #1833F2;" @click="orderTaking">立即接单</button>
  80. </view>
  81. <view v-else-if="type == '备货中'" class="lf-row-flex-end">
  82. <button class="btn btn1" @click="is_show_voucher = true">上传凭证</button>
  83. <button class="btn btn2" @click="is_show_receiving = true">确认发货</button>
  84. </view>
  85. <view v-else-if="type == '已发货'" class="lf-row-between">
  86. <button class="btn btn1" @click="is_show_voucher = true">上传凭证</button>
  87. <view class="lf-font-32" style="color: #11D189;">{{ type }}</view>
  88. </view>
  89. <view v-else class="lf-row-flex-end">
  90. <view class="lf-font-32">{{ type }}</view>
  91. </view>
  92. </view>
  93. <!-- 弹出层-上传凭证 -->
  94. <u-popup v-model="is_show_voucher" mode="center" border-radius="20">
  95. <view class="popup-box">
  96. <view class="content">
  97. <view class="popup-title">上传凭证信息</view>
  98. <view class="popup-desc">请在此处上传检验检疫凭证售卖资质等证书</view>
  99. <view class="popup-images">
  100. <view class="popup-image-item" v-for="(item, index) in voucher_list" :key="index" @click="lookImage(index, 'voucher_list')">
  101. <image :src="item" mode="aspectFill"></image>
  102. <view class="remove-image" @click.stop="removeInage(index)">
  103. <u-icon name="close-circle"></u-icon>
  104. </view>
  105. </view>
  106. <view class="popup-image-item popup-image-item-after" @click="uploadImage" v-if="voucher_list.length < 6"></view>
  107. </view>
  108. </view>
  109. <view class="foot-btn">
  110. <u-button class="popup-btn" @click="is_show_voucher = false">取消</u-button>
  111. <u-button class="popup-btn" @click="submitImage">确定</u-button>
  112. </view>
  113. </view>
  114. </u-popup>
  115. <!-- 弹出层-确认收货 -->
  116. <u-popup v-model="is_show_receiving" mode="center" border-radius="20">
  117. <view class="popup-box">
  118. <view class="content">
  119. <view class="popup-title">发货提醒</view>
  120. <view class="popup-desc">请填写车辆信息司机信息</view>
  121. <view class="lf-row-between popup-input">
  122. <view>车牌号</view>
  123. <input placeholder="请输入车牌号" v-model="l_p_num" />
  124. </view>
  125. <view class="lf-row-between popup-input">
  126. <view>司机姓名</view>
  127. <input placeholder="请输入司机姓名" v-model="driver_name" />
  128. </view>
  129. <view class="lf-row-between popup-input lf-m-b-30">
  130. <view>司机电话</view>
  131. <input placeholder="请输入司机电话" maxlength="11" v-model="driver_phone" />
  132. </view>
  133. </view>
  134. <view class="foot-btn">
  135. <u-button class="popup-btn" @click="is_show_receiving = false">取消</u-button>
  136. <u-button class="popup-btn" @click="confirmDeliver">确定</u-button>
  137. </view>
  138. </view>
  139. </u-popup>
  140. <!-- 预览图片组件 -->
  141. <lf-previewimage ref="previewimage" />
  142. </view>
  143. </template>
  144. <script>
  145. import { uploadFile } from '@/common/uploadFile.js'
  146. import wybTable from '@/components/wyb-table/wyb-table';
  147. export default {
  148. components: { wybTable },
  149. data(){
  150. return {
  151. stepList: [],
  152. headers: [{
  153. key: 'm_name',
  154. label: '物资名称'
  155. },{
  156. key: 'spec',
  157. label: '规格'
  158. },{
  159. label: '单位',
  160. key: 'unit'
  161. },{
  162. label: '分类',
  163. key: 'category'
  164. },{
  165. key: 'brand',
  166. label: '品牌'
  167. },{
  168. key: 'quality_level',
  169. label: '品级'
  170. },{
  171. label: '编号',
  172. key: 'm_sn'
  173. },{
  174. key: 'tax_price',
  175. label: '含税价'
  176. },{
  177. key: 'non_tax_price',
  178. label: '不含税价'
  179. },{
  180. key: 'purchase_limit',
  181. label: '起购数'
  182. },{
  183. key: 'purchase_number',
  184. label: '采购数量'
  185. }],
  186. contents: [],
  187. is_show_voucher: false, // 是否显示凭证上传弹出层
  188. is_show_receiving: false,
  189. voucher_list: [], // 已上传的凭证列表
  190. voucher_count: 6, // 最多可以上传多少张凭证
  191. type: '', // 订单状态
  192. p_sn: '',
  193. order: {},
  194. l_p_num: '',
  195. driver_name: '',
  196. driver_phone: '',
  197. canteen_voucher: [], // 食堂端凭证
  198. supplier_voucher: [], // 供应端凭证
  199. button_click: false
  200. }
  201. },
  202. onLoad(options){
  203. this.p_sn = options.p_sn;
  204. this.getData();
  205. },
  206. methods: {
  207. call(phone) {
  208. uni.makePhoneCall({
  209. phoneNumber: phone //仅为示例
  210. });
  211. },
  212. getData(){
  213. this.$http(this.API.API_SUPPLIER_PURCHASEDETAIL, {
  214. p_sn: this.p_sn
  215. }).then(res => {
  216. console.log("getData", res);
  217. let order = res.data.order || {};
  218. this.type = order.state;
  219. this.order = order;
  220. this.stepList = order.state_log.map((item, index) => {
  221. item.isFinished = false;
  222. if(index == order.state_log.length - 1){
  223. let actionState = [
  224. '订单已完成',
  225. '订单已退款',
  226. '订单已撤销',
  227. '订单已确认,物资入库'
  228. ]
  229. if(actionState.includes(item.action)){
  230. item.isFinished = true;
  231. }
  232. }
  233. return item;
  234. })
  235. let supplier_voucher = [];
  236. let canteen_voucher = [];
  237. order.voucher.map(item => {
  238. if(item.client_type == '供应商'){
  239. supplier_voucher.push(item.voucher_pic);
  240. }else if(item.client_type == '食堂'){
  241. canteen_voucher.push(item.voucher_pic);
  242. }
  243. })
  244. this.supplier_voucher = supplier_voucher;
  245. this.canteen_voucher = canteen_voucher;
  246. let list = order.items || [];
  247. let contents = list.map(item => {
  248. let obj = {
  249. m_name: item?.material?.m_name || '',
  250. material_id: item?.material?.id,
  251. spec: item?.spec?.name || '',
  252. spec_id: item?.spec?.id,
  253. brand: item?.material?.brand || '',
  254. quality_level: item?.material?.quality_level || '',
  255. m_sn: item?.material?.m_sn || '',
  256. tax_price: item.tax_price,
  257. non_tax_price: item.non_tax_price,
  258. purchase_limit: item?.p_order_item?.purchase_limit || '',
  259. purchase_number: item.purchase_number,
  260. unit: item?.material?.unit?.unit_name || '',
  261. category: item?.material?.category?.m_cate_name || ''
  262. }
  263. return obj;
  264. });
  265. this.contents = contents;
  266. });
  267. },
  268. // 上传凭证图片
  269. uploadImage(){
  270. let current_count = this.voucher_count - this.voucher_list.length;
  271. if(current_count == 0) return;
  272. uni.chooseImage({
  273. count: current_count,
  274. complete: result => {
  275. let tempFiles = result.tempFiles;
  276. let voucher_list = [];
  277. let overstep = false;
  278. tempFiles.map(item => {
  279. // 上传的图片需小于10MB
  280. if(item.size < 10464788){
  281. voucher_list.push(item.path);
  282. }else{
  283. overstep = true;
  284. }
  285. })
  286. if(overstep){
  287. uni.showModal({
  288. title: '温馨提示',
  289. content: '您上传的图片含有超出10M大小的限制,请优化大小后再上传!',
  290. showCancel: false
  291. })
  292. }
  293. this.voucher_list.push(...voucher_list);
  294. }
  295. })
  296. },
  297. // 预览图片
  298. lookImage(current, list){
  299. if(this[list].length <= 0) return;
  300. this.$u.throttle(() => {
  301. this.$refs.previewimage.show({
  302. images: this[list],
  303. current: current
  304. });
  305. }, 500);
  306. },
  307. // 移除图片
  308. removeInage(current){
  309. this.voucher_list.splice(current, 1);
  310. },
  311. // 用户点击确定,将图片上传至oss,并将url发送给后端
  312. submitImage(){
  313. let that = this;
  314. if(that.button_click){
  315. return;
  316. }
  317. that.button_click = true;
  318. let voucher_list = that.voucher_list;
  319. if(voucher_list.length <= 0){
  320. that.button_click = false;
  321. return that.$msg('您未上传图片哦');
  322. };
  323. that.is_show_voucher = false;
  324. uni.showLoading({
  325. title: '正在上传中...'
  326. })
  327. let http_list = [];
  328. voucher_list.map(item => {
  329. let itemP = new Promise((resolve, reject) => {
  330. uploadFile(item, (res) => {
  331. resolve(res);
  332. }, (err) => {
  333. reject(err);
  334. }, this);
  335. })
  336. http_list.push(itemP);
  337. })
  338. Promise.all(http_list).then(res => {
  339. console.log("上传完毕", res);
  340. let images = res.map(item => item.path);
  341. that.$http(that.API.API_SUPPLIER_PURCHASESAVEVOUCHER, {
  342. p_sn: that.p_sn,
  343. images: images,
  344. }).then(result => {
  345. uni.hideLoading();
  346. that.voucher_list = [];
  347. that.$msg('凭证已上传成功!');
  348. that.button_click = false;
  349. that.getData();
  350. }).catch(err => {
  351. uni.hideLoading();
  352. that.button_click = false;
  353. });
  354. }).catch(err => {
  355. uni.hideLoading();
  356. that.button_click = false;
  357. uni.showModal({
  358. title: '',
  359. content: JSON.stringify(err),
  360. showCancel: false,
  361. confirmColor: '#1833F2'
  362. })
  363. })
  364. },
  365. // 立即接单
  366. orderTaking(){
  367. if(this.button_click) return;
  368. this.button_click = true;
  369. this.$http(this.API.API_SUPPLIER_PURCHASEORDERACCEPT, {
  370. p_sn: this.p_sn
  371. }).then(res => {
  372. this.$msg('接单成功');
  373. this.button_click = false;
  374. this.getData();
  375. }).catch(err => this.button_click = false)
  376. },
  377. // 确认发货
  378. confirmDeliver(){
  379. if(this.buttom_click) return;
  380. this.buttom_click = true;
  381. let l_p_num = this.l_p_num;
  382. let driver_name = this.driver_name;
  383. let driver_phone = this.driver_phone;
  384. if(!l_p_num){
  385. this.buttom_click = false;
  386. return this.$msg('请输入车牌号')
  387. }else if(!driver_name){
  388. this.buttom_click = false;
  389. return this.$msg('请输入司机姓名')
  390. }else if(!driver_phone){
  391. this.buttom_click = false;
  392. return this.$msg('请输入司机电话')
  393. }
  394. this.is_show_receiving = false;
  395. this.$http(this.API.API_SUPPLIER_PURCHASEORDERSENDOUT, {
  396. p_sn: this.p_sn,
  397. deliver_phone: driver_phone,
  398. deliver_man: driver_name,
  399. car_license: l_p_num
  400. }).then(res => {
  401. this.$msg('确认发货成功');
  402. this.buttom_click = false;
  403. this.getData();
  404. }).catch(err => this.buttom_click = false)
  405. }
  406. }
  407. }
  408. </script>
  409. <style lang="scss" scoped="scoped">
  410. .head{
  411. padding: 0 32rpx;
  412. width: 750rpx;
  413. box-sizing: border-box;
  414. height: auto;
  415. .list{
  416. padding: 30rpx 0;
  417. // border-bottom: 1rpx solid #e5e5e5;
  418. font-size: 28rpx;
  419. color: #555555;
  420. &:last-child{
  421. border-bottom: none;
  422. }
  423. .image{
  424. width: 140rpx;
  425. height: 140rpx;
  426. border-radius: 10rpx;
  427. }
  428. .info{
  429. display: flex;
  430. flex-direction: column;
  431. // justify-content: space-around;
  432. justify-content: space-between;
  433. width: 530rpx;
  434. height: 140rpx;
  435. }
  436. }
  437. }
  438. .fixed-bottom{
  439. position: fixed;
  440. bottom: 0rpx;
  441. left: 0rpx;
  442. z-index: 99;
  443. width: 750rpx;
  444. height: 98rpx;
  445. display: flex;
  446. // justify-content: flex-end;
  447. align-items: center;
  448. border-top: 1rpx solid #E5E5E5;
  449. background-color: #FFFFFF;
  450. box-sizing: border-box;
  451. padding: 0 32rpx;
  452. .btn{
  453. width: 212rpx;
  454. height: 82rpx;
  455. border-radius: 41rpx;
  456. margin: 0;
  457. padding: 0;
  458. font-size: 32rpx;
  459. display: flex;
  460. justify-content: center;
  461. align-items: center;
  462. }
  463. .btn1{
  464. border: 2rpx solid #555555;
  465. opacity: .5;
  466. }
  467. .btn2{
  468. background: #1833F2;
  469. color: #FFFFFF;
  470. margin-left: 20rpx;
  471. }
  472. }
  473. .fixed-bottom>view{
  474. width: 100%;
  475. }
  476. .ms-img{
  477. width: 160rpx;
  478. height: 160rpx;
  479. margin-right: 15rpx;
  480. margin-top: 15rpx;
  481. background-color: #EEEEEE;
  482. &:nth-of-type(4n){
  483. margin-right: 0rpx;
  484. }
  485. }
  486. .popup-box{
  487. width: 686rpx;
  488. // height: 727rpx;
  489. height: max-content;
  490. display: flex;
  491. justify-content: space-between;
  492. flex-direction: column;
  493. .content{
  494. .popup-title{
  495. font-size: 32rpx;
  496. font-weight: bold;
  497. color: #222222;
  498. text-align: center;
  499. margin-top: 40rpx;
  500. }
  501. .popup-desc{
  502. font-size: 28rpx;
  503. color: #555555;
  504. text-align: center;
  505. margin-top: 20rpx;
  506. margin-bottom: 18rpx;
  507. }
  508. .popup-images{
  509. display: flex;
  510. flex-wrap: wrap;
  511. padding: 22rpx;
  512. margin-bottom: 18rpx;
  513. .popup-image-item{
  514. width: 198rpx;
  515. height: 198rpx;
  516. margin: 8rpx;
  517. background: #F5F5F5;
  518. border-radius: 10rpx;
  519. position: relative;
  520. image{
  521. width: 100%;
  522. height: 100%;
  523. }
  524. .remove-image{
  525. position: absolute;
  526. right: -8rpx;
  527. top: -16rpx;
  528. color: #e74c3c;
  529. font-size: 40rpx;
  530. padding: 8rpx;
  531. }
  532. }
  533. .popup-image-item-after::after{
  534. content: '+';
  535. position: absolute;
  536. left: 30%;
  537. top: 14%;
  538. font-size: 100rpx;
  539. color: #777777;
  540. }
  541. }
  542. .popup-input{
  543. padding: 0 60rpx;
  544. box-sizing: border-box;
  545. height: 90rpx;
  546. font-size: 28rpx;
  547. color: #555555;
  548. input{
  549. text-align: right;
  550. }
  551. }
  552. }
  553. .foot-btn{
  554. height: 90rpx;
  555. width: 100%;
  556. border-top: 1rpx solid #E5E5E5;
  557. display: flex;
  558. box-sizing: border-box;
  559. .popup-btn{
  560. width: 50%;
  561. height: 100%;
  562. border: none;
  563. border-radius: initial;
  564. &:last-child{
  565. border-left: 1rpx solid #E5E5E5;
  566. color: #1833F2;
  567. }
  568. }
  569. }
  570. }
  571. // 去掉u-button 外边框线
  572. /deep/.u-hairline-border::after{
  573. border: none;
  574. }
  575. // 弹出层样式
  576. /deep/.u-drawer{
  577. z-index: 999 !important;
  578. }
  579. </style>