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

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