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

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