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

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