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

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