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

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