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

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