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

490 lines
13 KiB

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