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

611 lines
16 KiB

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