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

587 lines
16 KiB

5 years ago
  1. <template>
  2. <view>
  3. <view class="box">
  4. <view class="title">报价清单</view>
  5. <view class="lf-font-24 lf-color-gray lf-m-t-5">请在以下物资信息表内填写报价</view>
  6. </view>
  7. <!-- 修饰条 -->
  8. <self-line></self-line>
  9. <view class="box lf-row-between relation">
  10. <view>
  11. <text class="title">关联食堂</text>
  12. <text class="lf-font-24 lf-color-555 lf-m-l-10">(多选)</text>
  13. </view>
  14. <view class="lf-font-24 lf-color-gray lf-text-right lf-row-center" style="width: 370rpx; justify-content: flex-end;" @click="switchRelation">
  15. <view class="lf-line-1">{{ selectName }}</view>
  16. <u-icon name="arrow-right" class="lf-text-vertical"></u-icon>
  17. </view>
  18. <view class="mask" :style="{top: node_top +'px'}" v-if="is_show" @click="is_show = false">
  19. <view class="list">
  20. <view class="lf-row-between item" v-for="(item, index) in relation_list" :key="index" @click.stop="selectItem(index)">
  21. <view>{{ item.canteen_name }}</view>
  22. <u-icon name="checkmark-circle" color="#1833F2" size="40" v-if="item.checked"></u-icon>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. <self-line></self-line>
  28. <!-- 报价时间 -->
  29. <view class="lf-row-between lf-p-30 lf-p-l-32 lf-p-r-32 lf-font-28">
  30. <view class="lf-color-black">报价生效时间</view>
  31. <picker mode="date" :value="deadline_start" @change="pickerChange($event, 'deadline_start')">
  32. <view class="lf-color-555 lf-text-right" style="width: 400rpx;">{{ deadline_start || '请选择...' }}</view>
  33. </picker>
  34. </view>
  35. <view class="lf-row-between lf-p-30 lf-p-l-32 lf-p-r-32 lf-font-28">
  36. <view class="lf-color-black">报价失效时间</view>
  37. <picker mode="date" :value="deadline_end" @change="pickerChange($event, 'deadline_end')">
  38. <view class="lf-color-555 lf-text-right" style="width: 400rpx;">{{ deadline_end || '请选择...' }}</view>
  39. </picker>
  40. </view>
  41. <self-line></self-line>
  42. <!-- 物料table -->
  43. <view class="box">
  44. <view class="lf-m-b-20 lf-row-between">
  45. <view class="lf-font-32 lf-color-black lf-font-bold">报价明细</view>
  46. <view class="lf-flex search-self">
  47. <u-icon name="search" class="search-icon"></u-icon>
  48. <input placeholder="搜索物资" confirm-type="search" @focus="hideIcon()" class="lf-m-l-10 lf-font-28" :value="searchValue" @input="inputChange" @confirm="inputConfirm" />
  49. </view>
  50. </view>
  51. <wyb-table :first-line-fixed="true"
  52. contentBgColor="#eef6fe"
  53. :headers="headers"
  54. :contents="contents"
  55. :scrollToInput="true"
  56. :loading="table_loading"
  57. :searchKey="searchValue"
  58. @onInputChange="onInputChange"
  59. @onButtonClick="onButtonClick"
  60. width="100%" height="80vh"></wyb-table>
  61. </view>
  62. <view style="height: 140rpx;"></view>
  63. <!-- 操作按钮 -->
  64. <view class="fixed-bottom">
  65. <button class="btn btn1" :class="{'lf-btn-disabled': button_click}" @click="save(0)">临时保存</button>
  66. <button class="btn btn2" :class="{'lf-btn-disabled': button_click}" @click="save(1)">直接报价</button>
  67. </view>
  68. </view>
  69. </template>
  70. <script>
  71. import wybTable from '@/components/wyb-table/wyb-table';
  72. let app = getApp();
  73. let timer = null;
  74. export default {
  75. components: {
  76. wybTable
  77. },
  78. data(){
  79. return {
  80. show_icon: true,
  81. headers: [{
  82. label: '物资名称',
  83. key: 'name',
  84. search: true
  85. },{
  86. label: '规格',
  87. key: 'spec'
  88. },{
  89. label: '单位',
  90. key: 'unit'
  91. },{
  92. label: '分类',
  93. key: 'category'
  94. },{
  95. label: '品牌',
  96. key: 'brand'
  97. },{
  98. label: '品级',
  99. key: 'quality_level'
  100. },{
  101. label: '编号',
  102. key: 'number'
  103. },{
  104. label: '起购数',
  105. key: 'purchase_limit'
  106. },{
  107. label: '含税价',
  108. key: 'tax_price'
  109. },{
  110. label: '不含税价',
  111. key: 'non_tax_price'
  112. },{
  113. label: '操作',
  114. key: 'operation'
  115. }],
  116. contents: [],
  117. is_show: false,
  118. relation_list: [], // 关联食堂列表
  119. node_top: 0,
  120. code: '', // 订单号,批次号,如果有
  121. type: 0,
  122. deadline_start: '',
  123. deadline_end: '',
  124. table_loading: true,
  125. searchValue: '', // 搜索内容
  126. button_click: false
  127. }
  128. },
  129. computed: {
  130. selectName(){
  131. let arr = [];
  132. this.relation_list.map(item => {
  133. if(item.checked){
  134. arr.push(item.canteen_name);
  135. }
  136. });
  137. let str = '请选择...';
  138. if(arr.length > 0){
  139. str = arr.join(',');
  140. }
  141. return str;
  142. }
  143. },
  144. onLoad(options){
  145. this.code = options.code || '';
  146. this.type = options.type || 0;
  147. if(options.type == 1){
  148. // 编辑,不可更换食堂
  149. this.materialListByOrder();
  150. }else if(options.type == 2){
  151. // 复用订单号
  152. this.materialListByOrder();
  153. }else if(options.type == 3){
  154. // 复用批次号
  155. this.materialListByBatch();
  156. }else{
  157. // 单纯发起报价
  158. this.getMaterialList();
  159. }
  160. },
  161. onReady(){
  162. let that = this;
  163. let info = uni.createSelectorQuery().select(".relation");
  164.     info.boundingClientRect(function(data) {
  165. let num = app.globalData.customBarH;
  166. // #ifdef MP-WEIXIN
  167. num -= 60;
  168. // #endif
  169. num += data.height;
  170. num += data.top;
  171. that.node_top = num;
  172.    }).exec()
  173. },
  174. onPageScroll(){
  175. if(this.is_show){
  176. this.is_show = false;
  177. }
  178. },
  179. methods: {
  180. hideIcon() {
  181. if(this.searchValue != '') {
  182. this.show_icon = false;
  183. }
  184. },
  185. // 搜索input值被改变
  186. inputChange(event){
  187. if(timer){
  188. clearTimeout(timer);
  189. timer = null;
  190. }
  191. timer = setTimeout(() => {
  192. this.searchValue = event.detail.value;
  193. }, 1000);
  194. if(event.detail.value == '') {
  195. this.show_icon = true;
  196. }else {
  197. this.show_icon = false;
  198. }
  199. },
  200. // 搜索按下回车
  201. inputConfirm(event){
  202. this.searchValue = event.detail.value;
  203. },
  204. // 日期选择器值被改变
  205. pickerChange(event, current_name){
  206. if(current_name == 'deadline_start') {
  207. // PS 获取30天后日期
  208. var date1 = new Date(event.detail.value);
  209. var date2 = new Date(date1);
  210. date2.setDate(date1.getDate() + 30);
  211. var nowTime = new Date()
  212. var today = this.$shared.recordTime(nowTime, '-', 'date')
  213. if(today>event.detail.value) {
  214. this.$msg('请选择今天或未来的时间')
  215. return
  216. }else {
  217. this[current_name] = event.detail.value;
  218. this.deadline_end = this.$shared.recordTime(date2, '-', 'date')
  219. }
  220. }else {
  221. var nowTime = new Date()
  222. var today = this.$shared.recordTime(nowTime, '-', 'date')
  223. if(today>event.detail.value) {
  224. this.$msg('请选择今天之后的时间')
  225. return
  226. }else {
  227. this[current_name] = event.detail.value;
  228. }
  229. }
  230. },
  231. // 获取物资列表
  232. getMaterialList(){
  233. this.$http(this.API.API_SUPPLIER_MATERIALLIST).then(res => {
  234. let list = res.data.spec || [];
  235. let contents = list.map(item => {
  236. return {
  237. name: item?.material?.m_name || '',
  238. material_id: item?.material?.id || 0,
  239. spec: item.name || '',
  240. spec_id: item.id,
  241. brand: item?.material?.brand || '',
  242. quality_level: item?.material?.quality_level || '',
  243. number: item?.material?.m_sn || '',
  244. purchase_limit: {edit: true, value: 1},
  245. tax_price: {edit: true, value: ''},
  246. non_tax_price: {edit: true, value: ''},
  247. operation: {button: true, key: 'delete', value: '删除'},
  248. unit: item?.material?.unit?.unit_name || '',
  249. category: item?.material?.category?.m_cate_name || ''
  250. }
  251. })
  252. this.contents = contents;
  253. this.table_loading = false;
  254. this.getCanteenList();
  255. })
  256. },
  257. // 复用报价订单号 & 编辑共用
  258. materialListByOrder(){
  259. this.$http(this.API.API_SUPPLIER_QUOTATIONREUSEBYORDER, {
  260. q_sn: this.code
  261. }).then(res => {
  262. let list = res.data.order || [];
  263. let canteen = res.data.canteen || [];
  264. // 处理表格显示
  265. let contents = list.map(item => {
  266. let obj = {
  267. name: item?.material?.m_name || '',
  268. material_id: item?.material?.id || 0,
  269. spec: item.name || '',
  270. spec_id: item.id,
  271. brand: item?.material?.brand || '',
  272. quality_level: item?.material?.quality_level || '',
  273. number: item?.material?.m_sn || '',
  274. purchase_limit: {edit: true, value: item?.quotation_item?.purchase_limit || ''},
  275. tax_price: {edit: true, value: item?.quotation_item?.tax_price || ''},
  276. non_tax_price: {edit: true, value: item?.quotation_item?.non_tax_price || ''},
  277. quotation_id: item?.quotation_item?.id || 0,
  278. operation: {button: true, key: 'delete', value: '删除'},
  279. unit: item?.material?.unit?.unit_name || '',
  280. category: item?.material?.category?.m_cate_name || ''
  281. }
  282. if(item?.material?.state && item?.material?.state != '启用'){
  283. obj.disabled = true;
  284. }
  285. return obj;
  286. })
  287. this.contents = contents;
  288. this.table_loading = false;
  289. // 处理报价生效、失效时间
  290. let deadline_start = '';
  291. let deadline_end = '';
  292. if(list[0] && list[0]?.quotation_item?.quotation){
  293. let quotation = list[0]?.quotation_item?.quotation || {};
  294. if(quotation.deadline_start){
  295. deadline_start = quotation.deadline_start.split(' ')[0];
  296. }
  297. if(quotation.deadline){
  298. deadline_end = quotation.deadline.split(' ')[0];
  299. }
  300. }
  301. this.deadline_start = deadline_start;
  302. this.deadline_end = deadline_end;
  303. this.getCanteenList(canteen);
  304. })
  305. },
  306. // 复用批次号
  307. materialListByBatch(){
  308. this.$http(this.API.API_SUPPLIER_QUOTATIONREUSEBYBATCH, {
  309. batch_sn: this.code
  310. }).then(res => {
  311. console.log("materialListByBatch", res);
  312. let list = res.data.order || [];
  313. let canteen = res.data.canteen || [];
  314. // 处理表格显示
  315. let contents = list.map(item => {
  316. return {
  317. name: item?.material?.m_name || '',
  318. material_id: item?.material?.id || 0,
  319. spec: item.name || '',
  320. spec_id: item.id,
  321. brand: item?.material?.brand || '',
  322. quality_level: item?.material?.quality_level || '',
  323. number: item?.material?.m_sn || '',
  324. purchase_limit: {edit: true, value: item?.quotation?.purchase_limit || ''},
  325. tax_price: {edit: true, value: item?.quotation?.tax_price || ''},
  326. non_tax_price: {edit: true, value: item?.quotation?.non_tax_price || ''}
  327. }
  328. })
  329. this.contents = contents;
  330. this.table_loading = false;
  331. // 处理报价生效、失效时间
  332. let deadline_start = '';
  333. let deadline_end = '';
  334. if(list[0] && list[0]?.quotation_item?.quotation){
  335. let quotation = list[0]?.quotation_item?.quotation || {};
  336. if(quotation.deadline_start){
  337. deadline_start = quotation.deadline_start.split(' ')[0];
  338. }
  339. if(quotation.deadline){
  340. deadline_end = quotation.deadline.split(' ')[0];
  341. }
  342. }
  343. this.deadline_start = deadline_start;
  344. this.deadline_end = deadline_end;
  345. this.getCanteenList(canteen);
  346. })
  347. },
  348. // 关联食堂列表
  349. getCanteenList(canteen = []){
  350. this.$http(this.API.API_SUPPLIER_CANTEENLIST).then(res => {
  351. let list = res.data.list.map(item => {
  352. item.checked = false;
  353. canteen.map(ct => {
  354. if(ct == item.id){
  355. item.checked = true;
  356. }
  357. })
  358. return item;
  359. })
  360. this.relation_list = list;
  361. })
  362. },
  363. // 监听表格被输入
  364. onInputChange(event){
  365. this.contents[event.contentIndex][event.key].value = event.detailValue;
  366. },
  367. // table操作按钮被点击
  368. onButtonClick(event){
  369. if(event.content.key == 'delete'){
  370. let contentIndex = event.contentIndex;
  371. let name = event?.lineData?.name || '';
  372. let spec = event?.lineData?.spec || '';
  373. uni.showModal({
  374. title: '温馨提示',
  375. content: `确定删除 ${name}-${spec} 吗?`,
  376. confirmColor: '#1833F2',
  377. success: result => {
  378. if(result.confirm){
  379. this.contents.splice(contentIndex, 1);
  380. }
  381. }
  382. })
  383. }
  384. },
  385. // 切换显示关联食堂modal
  386. switchRelation(){
  387. if(this.type == 1) return this.$msg('编辑不可更换关联食堂哦');
  388. this.is_show = !this.is_show;
  389. },
  390. // 选择食堂
  391. selectItem(index){
  392. this.relation_list[index].checked = !this.relation_list[index].checked;
  393. },
  394. // 报价订单编辑时保存
  395. editMaterial(_t){
  396. // 物资列表
  397. let list = [];
  398. this.contents.map(item => {
  399. list.push({
  400. id: item.quotation_id,
  401. tax_price: item.tax_price.value,
  402. non_tax_price: item.non_tax_price.value,
  403. purchase_limit: Number(item.purchase_limit.value) || 1
  404. })
  405. });
  406. // 操作状态,是保存还是直接发起
  407. let state = ['待发起', '待审核'][_t];
  408. this.$http(this.API.API_SUPPLIER_QUOTATIONSAVE, {
  409. data: list,
  410. state: state,
  411. q_sn: this.code,
  412. start: this.deadline_start,
  413. end: this.deadline_end
  414. }).then(res => {
  415. this.$msg('操作成功').then(result => {
  416. this.$toBack();
  417. })
  418. }).catch(err => this.button_click = false)
  419. },
  420. // 保存
  421. save(_t){
  422. // 拦截按钮重复点击
  423. if(this.button_click){
  424. return;
  425. }
  426. this.button_click = true;
  427. // 拦截是编辑的情况
  428. if(this.type == 1){
  429. this.editMaterial(_t);
  430. return;
  431. }
  432. // 物资列表
  433. let list = [];
  434. this.contents.map(item => {
  435. if(item.tax_price.value && item.non_tax_price.value){
  436. list.push({
  437. m_id: item.material_id,
  438. m_spec_id: item.spec_id,
  439. tax_price: item.tax_price.value,
  440. non_tax_price: item.non_tax_price.value,
  441. purchase_limit: Number(item.purchase_limit.value) || 1
  442. })
  443. }
  444. });
  445. // 关联食堂
  446. let canteen_ids = [];
  447. this.relation_list.map(item => {
  448. if(item.checked){
  449. canteen_ids.push(item.id);
  450. }
  451. })
  452. if(canteen_ids.length <= 0){
  453. this.button_click = false;
  454. return this.$msg('您未选择关联食堂哦')
  455. }
  456. if(!this.deadline_start){
  457. this.button_click = false;
  458. return this.$msg('您未选择报价生效时间哦')
  459. }
  460. if(!this.deadline_end){
  461. this.button_click = false;
  462. return this.$msg('您未选择报价失效时间哦')
  463. }
  464. if(list.length <= 0){
  465. this.button_click = false;
  466. return this.$msg('请补充完整物资报价信息')
  467. }
  468. // 操作状态,是保存还是直接发起
  469. let state = ['待发起', '待审核'][_t];
  470. this.$http(this.API.API_SUPPLIER_QUOTATIONAPPLY, {
  471. data: list,
  472. state: state,
  473. canteen_ids: canteen_ids,
  474. start: this.deadline_start,
  475. end: this.deadline_end
  476. }).then(res => {
  477. this.$msg(res.data).then(result => {
  478. this.$toBack();
  479. })
  480. }).catch(err => this.button_click = false)
  481. }
  482. }
  483. }
  484. </script>
  485. <style>
  486. page{
  487. overflow-x: hidden;
  488. }
  489. </style>
  490. <style lang="scss" scoped="scoped">
  491. .search-icon {
  492. color: #777;
  493. }
  494. .search-self {
  495. background: #f2f2f2;
  496. padding: 10rpx 0 10rpx 20rpx;
  497. border-radius: 40rpx;
  498. font-size: 28rpx;
  499. }
  500. .search-self .uni-input-placeholder {
  501. margin-right: 500px;
  502. color: #777;
  503. font-size: 28rpx;
  504. }
  505. .lf-m-t-5{
  506. margin-top: 5rpx;
  507. }
  508. .box{
  509. padding: 30rpx 32rpx;
  510. width: 100%;
  511. height: max-content;
  512. box-sizing: border-box;
  513. }
  514. .title{
  515. color: #222222;
  516. font-size: 28rpx;
  517. font-weight: bold;
  518. }
  519. .fixed-bottom{
  520. position: fixed;
  521. bottom: 0rpx;
  522. left: 0rpx;
  523. z-index: 99;
  524. width: 750rpx;
  525. height: 98rpx;
  526. display: flex;
  527. justify-content: center;
  528. align-items: center;
  529. border-top: 1rpx solid #E5E5E5;
  530. background-color: #fff;
  531. .btn{
  532. width: 320rpx;
  533. height: 82rpx;
  534. border-radius: 41rpx;
  535. margin: 0;
  536. padding: 0;
  537. font-size: 32rpx;
  538. display: flex;
  539. justify-content: center;
  540. align-items: center;
  541. }
  542. .btn1{
  543. border: 2rpx solid #555555;
  544. opacity: .5;
  545. }
  546. .btn2{
  547. background: #1833F2;
  548. color: #FFFFFF;
  549. margin-left: 50rpx;
  550. }
  551. }
  552. .relation{
  553. position: relative;
  554. border-bottom: 1rpx solid #E5E5E5;
  555. }
  556. .mask{
  557. position: fixed;
  558. background-color: rgba(0,0,0,0.4);
  559. width: 100%;
  560. // top: 149px;
  561. bottom: 0;
  562. left: 0;
  563. z-index: 100;
  564. .list{
  565. min-height: max-content;
  566. max-height: 500rpx;
  567. overflow: scroll;
  568. background-color: #FFFFFF;
  569. width: 100%;
  570. .item{
  571. height: 92rpx;
  572. padding: 0 32rpx;
  573. border-bottom: 1rpx solid #E5E5E5;
  574. color: #222222;
  575. font-size: 28rpx;
  576. }
  577. }
  578. }
  579. </style>