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

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