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

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