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

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