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

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