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

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