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

534 lines
15 KiB

  1. <template>
  2. <view class="content">
  3. <view class="card" v-for="(item, index) in list" :key="index">
  4. <view class="lf-row-between">
  5. <view class="flex lf-row-center justify-center text-center">
  6. <view class="lf-color-black lf-font-bold" v-if="item.material && item.material.m_name">{{ item.material.m_name }}</view>
  7. <view class="lf-m-l-10">{{item.spec.name}}</view>
  8. </view>
  9. <view>单位: {{item.material.unit.unit_name}}</view>
  10. <!-- 修改功能先隐藏 -->
  11. <!-- <view style="color: #11D189;" @click="showEdit">修改</view> -->
  12. </view>
  13. <view class="lf-row-between lf-m-t-30">
  14. <view>订购数</view>
  15. <view class="lf-flex">
  16. <input class="input" placeholder="0" type="number" :disabled="true" v-if="item.material && item.purchase_number" v-model="item.purchase_number"/>
  17. <text class="lf-color-black" v-if="item.material && item.material.unit">{{item.material.unit.unit_name}}</text>
  18. </view>
  19. </view>
  20. <view class="lf-row-between lf-m-t-30">
  21. <view>实到数</view>
  22. <view class="lf-flex">
  23. <input class="input" placeholder="0" type="number" v-model="item.reachNum" @blur="inputBlur(index, 'real_reach_number', $event)" />
  24. <text class="lf-color-black" v-if="item.material && item.material.unit">{{item.material.unit.unit_name}}</text>
  25. </view>
  26. </view>
  27. <view class="lf-row-between lf-m-t-30">
  28. <view>实收数</view>
  29. <view class="lf-flex">
  30. <input class="input" placeholder="0" type="number" v-model="item.receiveNum" @blur="inputBlur(index, 'real_receive_number', $event)" />
  31. <text class="lf-color-black" v-if="item.material && item.material.unit">{{item.material.unit.unit_name}}</text>
  32. </view>
  33. </view>
  34. </view>
  35. <!-- 修饰底部 -->
  36. <view :style="upload_list.length ? 'height: 260rpx' : 'height: 140rpx'"></view>
  37. <!-- 凭证图 -->
  38. <view class="fixed-images" v-if="upload_list.length">
  39. <image class="ms-img" :src="item" @click="lookImage(index)" v-for="(item, index) in upload_list" :key="index" v-if="index < 6"></image>
  40. </view>
  41. <view class="fixed-bottom" v-if="list.length">
  42. <button class="btn btn1 lf-m-l-20" @click="is_show_voucher = true">上传凭证</button>
  43. <button class="btn" @click="comfirm">确认收货</button>
  44. </view>
  45. <!-- 弹出层-确认收货修改 TODO每个都应该是动态 -->
  46. <u-popup v-model="is_show_edit" mode="bottom" border-radius="20">
  47. <view class="edit-popup-box">
  48. <view class="popup-content">
  49. <view>
  50. <view class="popup-item" hover-class="lf-opacity" :style="currentObj(1)?'border-bottom:none':''" @click="switchItem(1)">
  51. <text class="lf-font-bold">选择供应商</text>
  52. <u-icon name="arrow-up" color="#777777" v-if="currentObj(1)"></u-icon>
  53. <u-icon name="arrow-down" color="#777777" v-else></u-icon>
  54. </view>
  55. <scroll-view :scroll-y="true" class="scroll-box" :style="currentObj(1)?'max-height:360rpx':'max-height:0rpx'">
  56. <view class="lf-row-between scroll-item" v-for="(item, index) in supplier_list" :key="index" @click="checkItem(index, 'supplier_list')">
  57. <view>{{ item.name }}</view>
  58. <u-icon name="checkmark-circle" color="#11D189" v-if="item.checked"></u-icon>
  59. </view>
  60. </scroll-view>
  61. </view>
  62. <view>
  63. <view class="popup-item" hover-class="lf-opacity" :style="currentObj(2)?'border-bottom:none':''" @click="switchItem(2)">
  64. <text class="lf-font-bold">选择物资</text>
  65. <u-icon name="arrow-up" color="#777777" v-if="currentObj(2)"></u-icon>
  66. <u-icon name="arrow-down" color="#777777" v-else></u-icon>
  67. </view>
  68. <scroll-view :scroll-y="true" class="scroll-box" :style="currentObj(2)?'max-height:360rpx':'max-height:0rpx'">
  69. <view class="lf-row-between scroll-item" v-for="(item, index) in material_list" :key="index" @click="checkItem(index, 'material_list')">
  70. <view>{{ item.name }}</view>
  71. <u-icon name="checkmark-circle" color="#11D189" v-if="item.checked"></u-icon>
  72. </view>
  73. </scroll-view>
  74. </view>
  75. </view>
  76. <u-button class="popup-btn" @click="comfirmEdit">确认修改</u-button>
  77. </view>
  78. </u-popup>
  79. <!-- 弹出层-上传凭证 -->
  80. <u-popup v-model="is_show_voucher" mode="center" border-radius="20">
  81. <view class="voucher-popup-box">
  82. <view class="popup-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="lookImage(index, 'voucher_list')">
  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. <!-- 预览图片组件 --> <lf-previewimage ref="previewimage" />
  102. </view>
  103. </template>
  104. <script>
  105. import { uploadFile } from '@/common/uploadFile.js'
  106. export default {
  107. data(){
  108. return {
  109. list: [],
  110. is_show_edit: false,
  111. current_show: {
  112. type: 1,
  113. open: false
  114. },
  115. supplier_list: [{
  116. name: '南开大学',
  117. checked: false
  118. },{
  119. name: '华侨大学',
  120. checked: false
  121. }],
  122. material_list: [{
  123. name: '哈哈哈哈',
  124. checked: false
  125. },{
  126. name: '嘿嘿嘿',
  127. checked: false
  128. }],
  129. p_sn: '',
  130. contents: [],
  131. order: {},
  132. type: 4,
  133. reachNum: 0,
  134. receiveNum: 0,
  135. is_show_voucher: false,
  136. voucher_count: 6,
  137. voucher_list: [],
  138. is_upload: false, // 是否上传了凭证
  139. upload_list: []
  140. }
  141. },
  142. computed: {
  143. currentObj(){
  144. let current_show = this.current_show;
  145. return function(num){
  146. return current_show.type == num && current_show.open
  147. }
  148. }
  149. },
  150. onLoad(options){
  151. // http://localhost:8081/pages/purchase/receipt?p_sn=P16281395178122
  152. this.p_sn = options.p_sn || '';
  153. this.getData();
  154. },
  155. methods: {
  156. // 预览图片
  157. lookImage(current){
  158. this.$u.throttle(() => {
  159. this.$refs.previewimage.show({
  160. images: this.upload_list,
  161. current: current
  162. });
  163. }, 500);
  164. },
  165. // 移除图片
  166. removeInage(current){
  167. this.voucher_list.splice(current, 1);
  168. },
  169. // 上传凭证图片
  170. uploadImage(){
  171. let current_count = this.voucher_count - this.voucher_list.length;
  172. if(current_count == 0) return;
  173. uni.chooseImage({
  174. count: current_count,
  175. complete: result => {
  176. this.voucher_list.push(...result.tempFilePaths);
  177. console.log(this.voucher_list)
  178. }
  179. })
  180. },
  181. // 用户点击确定,将图片上传至oss,并将url发送给后端
  182. submitImage(){
  183. let that = this;
  184. let voucher_list = that.voucher_list;
  185. if(voucher_list.length <= 0){
  186. return that.$msg('您未上传图片哦');
  187. };
  188. that.is_show_voucher = false;
  189. uni.showLoading({
  190. title: '正在上传中...'
  191. })
  192. let http_list = [];
  193. voucher_list.map(item => {
  194. let itemP = new Promise((resolve, reject) => {
  195. uploadFile(item, (res) => {
  196. resolve(res);
  197. }, (err) => {
  198. reject(err);
  199. }, this);
  200. })
  201. http_list.push(itemP);
  202. })
  203. Promise.all(http_list).then(res => {
  204. let images = [];
  205. let show_images = [];
  206. res.map(item => {
  207. if(item.path){
  208. images.push(item.path);
  209. }
  210. if(item.url){
  211. show_images.push(item.url);
  212. }
  213. });
  214. that.$http(that.API.API_SUPPLIER_PURCHASEUPLOADVOUCHER, {
  215. p_sn: that.p_sn,
  216. images: images,
  217. }).then(result => {
  218. uni.hideLoading();
  219. that.voucher_list = [];
  220. that.is_upload = true;
  221. that.upload_list.push(...show_images);
  222. that.$msg('凭证已上传成功!')
  223. }).catch(err => uni.hideLoading());
  224. }).catch(err => {
  225. uni.hideLoading();
  226. uni.showModal({
  227. title: '',
  228. content: JSON.stringify(err),
  229. showCancel: false,
  230. confirmColor: '#1833F2'
  231. })
  232. })
  233. },
  234. getData(){
  235. this.$http(this.API.API_CANTEEN_PURCHASEDETAIL, {
  236. p_sn: this.p_sn
  237. }).then(res => {
  238. this.order = res.data.order;
  239. this.list = res.data.order.items || [];
  240. this.list.forEach(item => {
  241. item.reachNum = item.purchase_number
  242. item.receiveNum = item.purchase_number
  243. })
  244. let voucher = res.data?.order?.voucher || [];
  245. voucher = voucher.filter(item => item.client_type == '食堂');
  246. this.is_upload = voucher.length > 0;
  247. this.upload_list = voucher.map(item => item.voucher_pic);
  248. })
  249. },
  250. inputBlur(current, key, event){
  251. this.list[current][key] = event.detail.value;
  252. },
  253. comfirm(){
  254. let is_empty = false;
  255. let real_count_item = []
  256. this.list.forEach(item => {
  257. if(!item.receiveNum || !item.reachNum){
  258. is_empty = true;
  259. }
  260. real_count_item.push({
  261. id:item.id,
  262. real_receive_number: item.receiveNum,
  263. real_reach_number: item.reachNum
  264. })
  265. })
  266. if(is_empty){
  267. return this.$msg('请将收货数量填写完整');
  268. }
  269. if(!this.is_upload){
  270. return this.$msg('请上传凭证后再确认收货');
  271. }
  272. this.$http(this.API.API_CONFIRM, {
  273. p_sn: this.p_sn,
  274. state: '已入库',
  275. real_count_item
  276. }).then(res => {
  277. this.$msg('确认收货成功').then(()=>{this.$toBack()});
  278. })
  279. },
  280. switchItem(current){
  281. let current_show = this.current_show;
  282. if(current_show.type != current){
  283. current_show.open = false;
  284. }
  285. current_show.type = current;
  286. current_show.open = !current_show.open;
  287. this.current_show = current_show;
  288. },
  289. checkItem(index, name){
  290. this[name].forEach(item => item.checked = false);
  291. this[name][index].checked = true;
  292. },
  293. // 确认修改
  294. comfirmEdit(){
  295. this.$msg('修改成功!');
  296. this.is_show_edit = false;
  297. },
  298. // 显示修改弹出层
  299. showEdit(){
  300. this.current_show = {
  301. type: 1,
  302. open: false
  303. };
  304. this.is_show_edit = true;
  305. }
  306. }
  307. }
  308. </script>
  309. <style>
  310. page{
  311. background-color: #F6F6F6;
  312. overflow-x: hidden;
  313. }
  314. </style>
  315. <style lang="scss" scoped="scoped">
  316. .content{
  317. display: flex;
  318. align-items: center;
  319. flex-wrap: wrap;
  320. flex-direction: column;
  321. }
  322. .card{
  323. width: 686rpx;
  324. height: auto;
  325. background-color: #FFFFFF;
  326. border-radius: 20rpx;
  327. margin-top: 30rpx;
  328. font-size: 28rpx;
  329. box-sizing: border-box;
  330. padding: 30rpx;
  331. color: #777777;
  332. .input{
  333. width: 112rpx;
  334. border-bottom: 1rpx solid #e5e5e5;
  335. margin-right: 14rpx;
  336. text-align: center;
  337. color: #222222;
  338. }
  339. }
  340. .fixed-images{
  341. position: fixed;
  342. bottom: 98rpx;
  343. left: 0rpx;
  344. z-index: 99;
  345. width: 750rpx;
  346. height: 126rpx;
  347. background-color: #FFFFFF;
  348. display: flex;
  349. align-items: center;
  350. justify-content: center;
  351. .ms-img{
  352. // 六张一行
  353. width: 102rpx;
  354. height: 102rpx;
  355. // width: 146rpx;
  356. // height: 146rpx;
  357. margin-right: 14rpx;
  358. background-color: #EEEEEE;
  359. &:nth-of-type(6n){
  360. margin-right: 0rpx;
  361. }
  362. }
  363. }
  364. .fixed-bottom{
  365. position: fixed;
  366. bottom: 0rpx;
  367. left: 0rpx;
  368. z-index: 99;
  369. width: 750rpx;
  370. height: 98rpx;
  371. display: flex;
  372. justify-content: flex-end;
  373. align-items: center;
  374. border-top: 1rpx solid #E5E5E5;
  375. background-color: #FFFFFF;
  376. box-sizing: border-box;
  377. padding: 0 32rpx;
  378. .btn{
  379. width: 212rpx;
  380. background-color: #11D189;
  381. font-size: 32rpx;
  382. line-height: 82rpx;
  383. margin: 0;
  384. height: 82rpx;
  385. border-radius: 40rpx;
  386. color: #FFFFFF;
  387. }
  388. .btn1{
  389. border: 2rpx solid #555555;
  390. background-color: #FFFFFF;
  391. color: #555555;
  392. line-height: 80rpx;
  393. margin-right: 20rpx;
  394. }
  395. }
  396. /deep/.placeholder-class{
  397. color: #777777;
  398. }
  399. // 去掉u-button 外边框线
  400. /deep/.u-hairline-border::after{
  401. border: none;
  402. }
  403. // 修改收货信息弹出层
  404. .edit-popup-box{
  405. width: 100%;
  406. min-height: 484rpx;
  407. max-height: 64vh;
  408. padding: 10rpx 32rpx;
  409. display: flex;
  410. flex-direction: column;
  411. justify-content: space-between;
  412. .popup-content{
  413. min-height: 332rpx;
  414. // max-height: 54vh;
  415. margin-bottom: 40rpx;
  416. .popup-item{
  417. padding: 30rpx 0;
  418. box-sizing: border-box;
  419. border-bottom: 1rpx solid #E5E5E5;
  420. display: flex;
  421. justify-content: space-between;
  422. font-size: 28rpx;
  423. color: #222222;
  424. }
  425. .scroll-box{
  426. transition: all .5s;
  427. .scroll-item{
  428. padding: 30rpx 0;
  429. }
  430. }
  431. }
  432. .popup-btn{
  433. width: 100%;
  434. height: 82rpx;
  435. background: #11D189;
  436. border-radius: 10rpx;
  437. font-size: 32rpx;
  438. color: #FFFFFF;
  439. margin-bottom: 30rpx;
  440. }
  441. }
  442. // 上传凭证弹出层
  443. .voucher-popup-box{
  444. width: 686rpx;
  445. height: max-content;
  446. display: flex;
  447. justify-content: space-between;
  448. flex-direction: column;
  449. .popup-content{
  450. .popup-title{
  451. font-size: 32rpx;
  452. font-weight: bold;
  453. color: #222222;
  454. text-align: center;
  455. margin-top: 40rpx;
  456. }
  457. .popup-desc{
  458. font-size: 28rpx;
  459. color: #555555;
  460. text-align: center;
  461. margin-top: 20rpx;
  462. margin-bottom: 18rpx;
  463. }
  464. .popup-images{
  465. display: flex;
  466. flex-wrap: wrap;
  467. padding: 22rpx;
  468. margin-bottom: 18rpx;
  469. .popup-image-item{
  470. width: 198rpx;
  471. height: 198rpx;
  472. margin: 8rpx;
  473. background: #F5F5F5;
  474. border-radius: 10rpx;
  475. position: relative;
  476. image{
  477. width: 100%;
  478. height: 100%;
  479. }
  480. .remove-image{
  481. position: absolute;
  482. right: -8rpx;
  483. top: -16rpx;
  484. color: #e74c3c;
  485. font-size: 40rpx;
  486. padding: 8rpx;
  487. }
  488. }
  489. .popup-image-item-after::after{
  490. content: '+';
  491. position: absolute;
  492. left: 30%;
  493. top: 14%;
  494. font-size: 100rpx;
  495. color: #777777;
  496. }
  497. }
  498. .popup-input{
  499. padding: 0 60rpx;
  500. box-sizing: border-box;
  501. height: 90rpx;
  502. font-size: 28rpx;
  503. color: #555555;
  504. input{
  505. text-align: right;
  506. }
  507. }
  508. }
  509. .foot-btn{
  510. height: 90rpx;
  511. width: 100%;
  512. border-top: 1rpx solid #E5E5E5;
  513. display: flex;
  514. box-sizing: border-box;
  515. .popup-btn{
  516. width: 50%;
  517. height: 100%;
  518. border: none;
  519. border-radius: initial;
  520. &:last-child{
  521. border-left: 1rpx solid #E5E5E5;
  522. color: #1833F2;
  523. }
  524. }
  525. }
  526. }
  527. </style>