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

574 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. console.log(current_name)
  207. if(current_name == 'deadline_start') {
  208. // PS 获取30天后日期
  209. var date1 = new Date(event.detail.value);
  210. var date2 = new Date(date1);
  211. date2.setDate(date1.getDate() + 30);
  212. console.log(this.$shared.recordTime(date2, '-', 'date'))
  213. this[current_name] = event.detail.value;
  214. this.deadline_end = this.$shared.recordTime(date2, '-', 'date')
  215. }else {
  216. this[current_name] = event.detail.value;
  217. }
  218. },
  219. // 获取物资列表
  220. getMaterialList(){
  221. this.$http(this.API.API_SUPPLIER_MATERIALLIST).then(res => {
  222. let list = res.data.spec || [];
  223. let contents = list.map(item => {
  224. return {
  225. name: item?.material?.m_name || '',
  226. material_id: item?.material?.id || 0,
  227. spec: item.name || '',
  228. spec_id: item.id,
  229. brand: item?.material?.brand || '',
  230. quality_level: item?.material?.quality_level || '',
  231. number: item?.material?.m_sn || '',
  232. purchase_limit: {edit: true, value: 1},
  233. tax_price: {edit: true, value: ''},
  234. non_tax_price: {edit: true, value: ''},
  235. operation: {button: true, key: 'delete', value: '删除'},
  236. unit: item?.material?.unit?.unit_name || '',
  237. category: item?.material?.category?.m_cate_name || ''
  238. }
  239. })
  240. this.contents = contents;
  241. this.table_loading = false;
  242. this.getCanteenList();
  243. })
  244. },
  245. // 复用报价订单号 & 编辑共用
  246. materialListByOrder(){
  247. this.$http(this.API.API_SUPPLIER_QUOTATIONREUSEBYORDER, {
  248. q_sn: this.code
  249. }).then(res => {
  250. let list = res.data.order || [];
  251. let canteen = res.data.canteen || [];
  252. // 处理表格显示
  253. let contents = list.map(item => {
  254. let obj = {
  255. name: item?.material?.m_name || '',
  256. material_id: item?.material?.id || 0,
  257. spec: item.name || '',
  258. spec_id: item.id,
  259. brand: item?.material?.brand || '',
  260. quality_level: item?.material?.quality_level || '',
  261. number: item?.material?.m_sn || '',
  262. purchase_limit: {edit: true, value: item?.quotation_item?.purchase_limit || ''},
  263. tax_price: {edit: true, value: item?.quotation_item?.tax_price || ''},
  264. non_tax_price: {edit: true, value: item?.quotation_item?.non_tax_price || ''},
  265. quotation_id: item?.quotation_item?.id || 0,
  266. operation: {button: true, key: 'delete', value: '删除'},
  267. unit: item?.material?.unit?.unit_name || '',
  268. category: item?.material?.category?.m_cate_name || ''
  269. }
  270. if(item?.material?.state && item?.material?.state != '启用'){
  271. obj.disabled = true;
  272. }
  273. return obj;
  274. })
  275. this.contents = contents;
  276. this.table_loading = false;
  277. // 处理报价生效、失效时间
  278. let deadline_start = '';
  279. let deadline_end = '';
  280. if(list[0] && list[0]?.quotation_item?.quotation){
  281. let quotation = list[0]?.quotation_item?.quotation || {};
  282. if(quotation.deadline_start){
  283. deadline_start = quotation.deadline_start.split(' ')[0];
  284. }
  285. if(quotation.deadline){
  286. deadline_end = quotation.deadline.split(' ')[0];
  287. }
  288. }
  289. this.deadline_start = deadline_start;
  290. this.deadline_end = deadline_end;
  291. this.getCanteenList(canteen);
  292. })
  293. },
  294. // 复用批次号
  295. materialListByBatch(){
  296. this.$http(this.API.API_SUPPLIER_QUOTATIONREUSEBYBATCH, {
  297. batch_sn: this.code
  298. }).then(res => {
  299. console.log("materialListByBatch", res);
  300. let list = res.data.order || [];
  301. let canteen = res.data.canteen || [];
  302. // 处理表格显示
  303. let contents = list.map(item => {
  304. return {
  305. name: item?.material?.m_name || '',
  306. material_id: item?.material?.id || 0,
  307. spec: item.name || '',
  308. spec_id: item.id,
  309. brand: item?.material?.brand || '',
  310. quality_level: item?.material?.quality_level || '',
  311. number: item?.material?.m_sn || '',
  312. purchase_limit: {edit: true, value: item?.quotation?.purchase_limit || ''},
  313. tax_price: {edit: true, value: item?.quotation?.tax_price || ''},
  314. non_tax_price: {edit: true, value: item?.quotation?.non_tax_price || ''}
  315. }
  316. })
  317. this.contents = contents;
  318. this.table_loading = false;
  319. // 处理报价生效、失效时间
  320. let deadline_start = '';
  321. let deadline_end = '';
  322. if(list[0] && list[0]?.quotation_item?.quotation){
  323. let quotation = list[0]?.quotation_item?.quotation || {};
  324. if(quotation.deadline_start){
  325. deadline_start = quotation.deadline_start.split(' ')[0];
  326. }
  327. if(quotation.deadline){
  328. deadline_end = quotation.deadline.split(' ')[0];
  329. }
  330. }
  331. this.deadline_start = deadline_start;
  332. this.deadline_end = deadline_end;
  333. this.getCanteenList(canteen);
  334. })
  335. },
  336. // 关联食堂列表
  337. getCanteenList(canteen = []){
  338. this.$http(this.API.API_SUPPLIER_CANTEENLIST).then(res => {
  339. let list = res.data.list.map(item => {
  340. item.checked = false;
  341. canteen.map(ct => {
  342. if(ct == item.id){
  343. item.checked = true;
  344. }
  345. })
  346. return item;
  347. })
  348. this.relation_list = list;
  349. })
  350. },
  351. // 监听表格被输入
  352. onInputChange(event){
  353. this.contents[event.contentIndex][event.key].value = event.detailValue;
  354. },
  355. // table操作按钮被点击
  356. onButtonClick(event){
  357. if(event.content.key == 'delete'){
  358. let contentIndex = event.contentIndex;
  359. let name = event?.lineData?.name || '';
  360. let spec = event?.lineData?.spec || '';
  361. uni.showModal({
  362. title: '温馨提示',
  363. content: `确定删除 ${name}-${spec} 吗?`,
  364. confirmColor: '#1833F2',
  365. success: result => {
  366. if(result.confirm){
  367. this.contents.splice(contentIndex, 1);
  368. }
  369. }
  370. })
  371. }
  372. },
  373. // 切换显示关联食堂modal
  374. switchRelation(){
  375. if(this.type == 1) return this.$msg('编辑不可更换关联食堂哦');
  376. this.is_show = !this.is_show;
  377. },
  378. // 选择食堂
  379. selectItem(index){
  380. this.relation_list[index].checked = !this.relation_list[index].checked;
  381. },
  382. // 报价订单编辑时保存
  383. editMaterial(_t){
  384. // 物资列表
  385. let list = [];
  386. this.contents.map(item => {
  387. list.push({
  388. id: item.quotation_id,
  389. tax_price: item.tax_price.value,
  390. non_tax_price: item.non_tax_price.value,
  391. purchase_limit: Number(item.purchase_limit.value) || 1
  392. })
  393. });
  394. // 操作状态,是保存还是直接发起
  395. let state = ['待发起', '待审核'][_t];
  396. this.$http(this.API.API_SUPPLIER_QUOTATIONSAVE, {
  397. data: list,
  398. state: state,
  399. q_sn: this.code,
  400. start: this.deadline_start,
  401. end: this.deadline_end
  402. }).then(res => {
  403. this.$msg('操作成功').then(result => {
  404. this.$toBack();
  405. })
  406. }).catch(err => this.button_click = false)
  407. },
  408. // 保存
  409. save(_t){
  410. // 拦截按钮重复点击
  411. if(this.button_click){
  412. return;
  413. }
  414. this.button_click = true;
  415. // 拦截是编辑的情况
  416. if(this.type == 1){
  417. this.editMaterial(_t);
  418. return;
  419. }
  420. // 物资列表
  421. let list = [];
  422. this.contents.map(item => {
  423. if(item.tax_price.value && item.non_tax_price.value){
  424. list.push({
  425. m_id: item.material_id,
  426. m_spec_id: item.spec_id,
  427. tax_price: item.tax_price.value,
  428. non_tax_price: item.non_tax_price.value,
  429. purchase_limit: Number(item.purchase_limit.value) || 1
  430. })
  431. }
  432. });
  433. // 关联食堂
  434. let canteen_ids = [];
  435. this.relation_list.map(item => {
  436. if(item.checked){
  437. canteen_ids.push(item.id);
  438. }
  439. })
  440. if(canteen_ids.length <= 0){
  441. this.button_click = false;
  442. return this.$msg('您未选择关联食堂哦')
  443. }
  444. if(!this.deadline_start){
  445. this.button_click = false;
  446. return this.$msg('您未选择报价生效时间哦')
  447. }
  448. if(!this.deadline_end){
  449. this.button_click = false;
  450. return this.$msg('您未选择报价失效时间哦')
  451. }
  452. if(list.length <= 0){
  453. this.button_click = false;
  454. return this.$msg('请补充完整物资报价信息')
  455. }
  456. // 操作状态,是保存还是直接发起
  457. let state = ['待发起', '待审核'][_t];
  458. this.$http(this.API.API_SUPPLIER_QUOTATIONAPPLY, {
  459. data: list,
  460. state: state,
  461. canteen_ids: canteen_ids,
  462. start: this.deadline_start,
  463. end: this.deadline_end
  464. }).then(res => {
  465. this.$msg(res.data).then(result => {
  466. this.$toBack();
  467. })
  468. }).catch(err => this.button_click = false)
  469. }
  470. }
  471. }
  472. </script>
  473. <style>
  474. page{
  475. overflow-x: hidden;
  476. }
  477. </style>
  478. <style lang="scss" scoped="scoped">
  479. .search-icon {
  480. color: #777;
  481. }
  482. .search-self {
  483. background: #f2f2f2;
  484. padding: 10rpx 0 10rpx 20rpx;
  485. border-radius: 40rpx;
  486. font-size: 28rpx;
  487. }
  488. .search-self .uni-input-placeholder {
  489. margin-right: 500px;
  490. color: #777;
  491. font-size: 28rpx;
  492. }
  493. .lf-m-t-5{
  494. margin-top: 5rpx;
  495. }
  496. .box{
  497. padding: 30rpx 32rpx;
  498. width: 100%;
  499. height: max-content;
  500. box-sizing: border-box;
  501. }
  502. .title{
  503. color: #222222;
  504. font-size: 28rpx;
  505. font-weight: bold;
  506. }
  507. .fixed-bottom{
  508. position: fixed;
  509. bottom: 0rpx;
  510. left: 0rpx;
  511. z-index: 99;
  512. width: 750rpx;
  513. height: 98rpx;
  514. display: flex;
  515. justify-content: center;
  516. align-items: center;
  517. border-top: 1rpx solid #E5E5E5;
  518. background-color: #fff;
  519. .btn{
  520. width: 320rpx;
  521. height: 82rpx;
  522. border-radius: 41rpx;
  523. margin: 0;
  524. padding: 0;
  525. font-size: 32rpx;
  526. display: flex;
  527. justify-content: center;
  528. align-items: center;
  529. }
  530. .btn1{
  531. border: 2rpx solid #555555;
  532. opacity: .5;
  533. }
  534. .btn2{
  535. background: #1833F2;
  536. color: #FFFFFF;
  537. margin-left: 50rpx;
  538. }
  539. }
  540. .relation{
  541. position: relative;
  542. border-bottom: 1rpx solid #E5E5E5;
  543. }
  544. .mask{
  545. position: fixed;
  546. background-color: rgba(0,0,0,0.4);
  547. width: 100%;
  548. // top: 149px;
  549. bottom: 0;
  550. left: 0;
  551. z-index: 100;
  552. .list{
  553. min-height: max-content;
  554. max-height: 500rpx;
  555. overflow: scroll;
  556. background-color: #FFFFFF;
  557. width: 100%;
  558. .item{
  559. height: 92rpx;
  560. padding: 0 32rpx;
  561. border-bottom: 1rpx solid #E5E5E5;
  562. color: #222222;
  563. font-size: 28rpx;
  564. }
  565. }
  566. }
  567. </style>