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

505 lines
14 KiB

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