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

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