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

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