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

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