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

488 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
  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 || order.voucher.length || voucher_list.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="order.voucher.length">
  44. <view>证明材料-供应端</view>
  45. <view class="lf-flex-wrap lf-m-t-10">
  46. <image :src="item.voucher_pic" @click="lookImage(index)" class="ms-img" v-for="(item, index) in order.voucher" :key="item.id"></image>
  47. </view>
  48. </view>
  49. <view class="list" v-if="voucher_list.length">
  50. <view>证明材料-食堂端</view>
  51. <view class="lf-flex-wrap lf-m-t-10">
  52. <image :src="item" @click="lookPopupImage(index)" class="ms-img" v-for="(item, index) in voucher_list" :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="lookPopupImage(index)">
  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. }
  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. lookPopupImage(current){
  179. if(this.voucher_list.length <= 0) return;
  180. this.$u.throttle(() => {
  181. uni.previewImage({
  182. urls: this.voucher_list,
  183. current: current
  184. })
  185. }, 500);
  186. },
  187. // 移除图片
  188. removeInage(current){
  189. this.voucher_list.splice(current, 1);
  190. },
  191. // 上传凭证图片
  192. uploadImage(){
  193. let current_count = this.voucher_count - this.voucher_list.length;
  194. if(current_count == 0) return;
  195. uni.chooseImage({
  196. count: current_count,
  197. complete: result => {
  198. this.voucher_list.push(...result.tempFilePaths);
  199. console.log(this.voucher_list)
  200. }
  201. })
  202. },
  203. // 用户点击确定,将图片上传至oss,并将url发送给后端
  204. submitImage(){
  205. let that = this;
  206. let voucher_list = that.voucher_list;
  207. if(voucher_list.length <= 0){
  208. return that.$msg('您未上传图片哦');
  209. };
  210. that.is_show_voucher = false;
  211. uni.showLoading({
  212. title: '正在上传中...'
  213. })
  214. let http_list = [];
  215. voucher_list.map(item => {
  216. let itemP = new Promise((resolve, reject) => {
  217. uploadFile(item, (res) => {
  218. resolve(res);
  219. }, (err) => {
  220. reject(err);
  221. }, this);
  222. })
  223. http_list.push(itemP);
  224. })
  225. Promise.all(http_list).then(res => {
  226. let images = res.map(item => item.path);
  227. that.$http(that.API.API_SUPPLIER_PURCHASEUPLOADVOUCHER, {
  228. p_sn: that.p_sn,
  229. images: images,
  230. }).then(result => {
  231. uni.hideLoading();
  232. that.voucher_list = [];
  233. that.$msg('凭证已上传成功!')
  234. }).catch(err => uni.hideLoading());
  235. }).catch(err => {
  236. console.log(err)
  237. uni.hideLoading();
  238. uni.showModal({
  239. title: '',
  240. content: JSON.stringify(err),
  241. showCancel: false,
  242. confirmColor: '#1833F2'
  243. })
  244. })
  245. },
  246. getData(){
  247. this.$http(this.API.API_CANTEEN_PURCHASEDETAIL, {
  248. p_sn: this.p_sn
  249. }).then(res => {
  250. let order = res.data.order;
  251. order.state_log.forEach((item, index) => {
  252. item.isFinished = false;
  253. if(index == order.state_log.length - 1){
  254. let actionState = [
  255. '订单已完成',
  256. '订单已退款',
  257. '订单已撤销',
  258. '订单已确认,物资入库'
  259. ];
  260. if(actionState.includes(item.action)){
  261. item.isFinished = true;
  262. }
  263. }
  264. })
  265. this.order = order;
  266. let list = order.items || [];
  267. let contents = list.map(item => {
  268. return {
  269. name: item.material.m_name,
  270. spec: item.spec.name,
  271. brand: item.material.brand,
  272. quality_level: item.material.quality_level,
  273. m_sn: item.material.m_sn,
  274. supplier_name: order.supplier.supplier_name,
  275. pre_tax_price: item.total_tax_amount,
  276. after_tax_price: item.total_non_tax_amount,
  277. purchase_limit: item.p_order_item.purchase_limit,
  278. purchase_number: item.purchase_number
  279. }
  280. })
  281. this.contents = contents;
  282. this.type = order.state;
  283. }).catch(err => this.$toBack());
  284. },
  285. // 预览图片
  286. lookImage(index){
  287. this.$u.throttle(() => {
  288. let images = this.order.voucher.map(item => item.voucher_pic);
  289. uni.previewImage({
  290. urls: images,
  291. current: index
  292. })
  293. }, 200);
  294. },
  295. // 改变订单状态
  296. orderStateChange(state){
  297. uni.showModal({
  298. title: '温馨提示',
  299. content: '确定继续退单吗?',
  300. confirmColor: '#FF0000',
  301. cancelColor: '#11D189',
  302. success: result => {
  303. if(result.confirm){
  304. this.$http(this.API.API_CANTEEN_PURCHASEUPDATE, {
  305. p_sn: this.p_sn,
  306. state: state
  307. }).then(res => {
  308. console.log("orderStateChange", res);
  309. this.$msg('操作成功').then(()=> this.getData());
  310. })
  311. }
  312. }
  313. })
  314. }
  315. }
  316. }
  317. </script>
  318. <style lang="scss" scoped="scoped">
  319. .head{
  320. padding: 0 32rpx;
  321. width: 750rpx;
  322. box-sizing: border-box;
  323. height: auto;
  324. .list{
  325. padding: 30rpx 0;
  326. border-bottom: 1rpx solid #e5e5e5;
  327. font-size: 28rpx;
  328. color: #555555;
  329. &:last-child{
  330. border-bottom: none;
  331. }
  332. .image{
  333. width: 140rpx;
  334. height: 140rpx;
  335. border-radius: 10rpx;
  336. background-color: #EEEEEE;
  337. }
  338. .info{
  339. display: flex;
  340. flex-direction: column;
  341. justify-content: space-around;
  342. width: 530rpx;
  343. height: 140rpx;
  344. }
  345. }
  346. }
  347. .fixed-bottom{
  348. position: fixed;
  349. bottom: 0rpx;
  350. left: 0rpx;
  351. z-index: 99;
  352. width: 750rpx;
  353. height: 98rpx;
  354. display: flex;
  355. // justify-content: flex-end;
  356. align-items: center;
  357. border-top: 1rpx solid #E5E5E5;
  358. background-color: #FFFFFF;
  359. box-sizing: border-box;
  360. padding: 0 32rpx;
  361. .btn{
  362. width: 212rpx;
  363. height: 82rpx;
  364. border-radius: 41rpx;
  365. margin: 0;
  366. padding: 0;
  367. font-size: 32rpx;
  368. display: flex;
  369. justify-content: center;
  370. align-items: center;
  371. }
  372. .btn1{
  373. border: 2rpx solid #555555;
  374. opacity: .5;
  375. }
  376. .btn2{
  377. background: #11D189;
  378. color: #FFFFFF;
  379. margin-left: 20rpx;
  380. }
  381. }
  382. .fixed-bottom>view{
  383. width: 100%;
  384. }
  385. .ms-img{
  386. width: 160rpx;
  387. height: 160rpx;
  388. margin-right: 15rpx;
  389. margin-top: 15rpx;
  390. background-color: #EEEEEE;
  391. &:nth-of-type(4n){
  392. margin-right: 0rpx;
  393. }
  394. }
  395. .popup-box{
  396. width: 686rpx;
  397. height: max-content;
  398. display: flex;
  399. justify-content: space-between;
  400. flex-direction: column;
  401. .content{
  402. .popup-title{
  403. font-size: 32rpx;
  404. font-weight: bold;
  405. color: #222222;
  406. text-align: center;
  407. margin-top: 40rpx;
  408. }
  409. .popup-desc{
  410. font-size: 28rpx;
  411. color: #555555;
  412. text-align: center;
  413. margin-top: 20rpx;
  414. margin-bottom: 18rpx;
  415. }
  416. .popup-images{
  417. display: flex;
  418. flex-wrap: wrap;
  419. padding: 22rpx;
  420. margin-bottom: 18rpx;
  421. .popup-image-item{
  422. width: 198rpx;
  423. height: 198rpx;
  424. margin: 8rpx;
  425. background: #F5F5F5;
  426. border-radius: 10rpx;
  427. position: relative;
  428. image{
  429. width: 100%;
  430. height: 100%;
  431. }
  432. .remove-image{
  433. position: absolute;
  434. right: -8rpx;
  435. top: -16rpx;
  436. color: #e74c3c;
  437. font-size: 40rpx;
  438. padding: 8rpx;
  439. }
  440. }
  441. .popup-image-item-after::after{
  442. content: '+';
  443. position: absolute;
  444. left: 30%;
  445. top: 14%;
  446. font-size: 100rpx;
  447. color: #777777;
  448. }
  449. }
  450. .popup-input{
  451. padding: 0 60rpx;
  452. box-sizing: border-box;
  453. height: 90rpx;
  454. font-size: 28rpx;
  455. color: #555555;
  456. input{
  457. text-align: right;
  458. }
  459. }
  460. }
  461. .foot-btn{
  462. height: 90rpx;
  463. width: 100%;
  464. border-top: 1rpx solid #E5E5E5;
  465. display: flex;
  466. box-sizing: border-box;
  467. .popup-btn{
  468. width: 50%;
  469. height: 100%;
  470. border: none;
  471. border-radius: initial;
  472. &:last-child{
  473. border-left: 1rpx solid #E5E5E5;
  474. color: #1833F2;
  475. }
  476. }
  477. }
  478. }
  479. </style>