自主产品,供应链食堂系统。将两个端拆开了。
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.

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