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

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