From eff5b1033189e048f034b6f111077a1c1dc00626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=93=E5=B9=B3=E8=89=BA?= <52643018@qq.com> Date: Tue, 17 Aug 2021 15:41:59 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=B7=BB=E5=8A=A0]=20=E4=BE=9B=E5=BA=94?= =?UTF-8?q?=E5=95=86=E5=8F=91=E8=B5=B7=E6=8A=A5=E4=BB=B7=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E6=8B=A6=E6=88=AA=E5=B7=B2=E5=8F=91=E8=B5=B7=E5=AE=A1=E6=A0=B8?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E7=9B=B8=E5=90=8C=E8=AE=A2=E5=8D=95=20[?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0]=20=E6=95=B0=E7=BB=84=E5=AF=B9=E8=B1=A1?= =?UTF-8?q?=E5=8E=BB=E9=87=8D=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supplier/common/shared.js | 12 +++- supplier/pages/offer/index.vue | 122 +++++++++++++++++++++++++------- supplier/pages/order/detail.vue | 78 +++++++++++++++++--- 3 files changed, 176 insertions(+), 36 deletions(-) diff --git a/supplier/common/shared.js b/supplier/common/shared.js index 4dcfeff..f518133 100644 --- a/supplier/common/shared.js +++ b/supplier/common/shared.js @@ -48,4 +48,14 @@ export function recordTime(time = new Date(), separator = "-", swf = 'all'){ var cover = function(par) { par = par.toString()[1] ? par : "0" + par; return par; -}; \ No newline at end of file +}; + +// 数组对象去重 +export function deWeightFour(arr, key){ + let obj = {}; + arr = arr.reduce(function(a, b) { + obj[b[key]] ? '' : obj[b[key]] = true && a.push(b); + return a; + }, []); + return arr; +} \ No newline at end of file diff --git a/supplier/pages/offer/index.vue b/supplier/pages/offer/index.vue index 3fd3997..1550c37 100644 --- a/supplier/pages/offer/index.vue +++ b/supplier/pages/offer/index.vue @@ -128,7 +128,8 @@ deadline_end: '', table_loading: true, searchValue: '', // 搜索内容 - button_click: false + button_click: false, + selected_canteens: [] } }, computed: { @@ -149,6 +150,7 @@ onLoad(options){ this.code = options.code || ''; this.type = options.type || 0; + this.getOfferList(); if(options.type == 1){ // 编辑,不可更换食堂 this.materialListByOrder(); @@ -182,6 +184,28 @@ } }, methods: { + // 获取订单列表(取出食堂id) + getOfferList(){ + this.$http(this.API.API_SUPPLIER_QUOTATIONORDERLIST, { + state: 1, + page: 1, + page_size: 10 + }).then(res => { + let list = res.data?.list?.data || []; + // 数组对象去重 + list = this.$shared.deWeightFour(list, 'canteen_id'); + let selected_canteens = []; + list.map(item => { + if(item.state == '待审核'){ + selected_canteens.push({ + id: item.canteen_id, + q_sn: item.q_sn + }) + } + }) + this.selected_canteens = selected_canteens; + }) + }, hideIcon() { if(this.searchValue != '') { this.show_icon = false; @@ -406,6 +430,7 @@ // 报价订单编辑时保存 editMaterial(_t){ // 物资列表 + let that = this; let list = []; this.contents.map(item => { list.push({ @@ -415,22 +440,49 @@ purchase_limit: Number(item.purchase_limit.value) || 1 }) }); - // 操作状态,是保存还是直接发起 - let state = ['待发起', '待审核'][_t]; - this.$http(this.API.API_SUPPLIER_QUOTATIONSAVE, { - data: list, - state: state, - q_sn: this.code, - start: this.deadline_start, - end: this.deadline_end - }).then(res => { - this.$msg('操作成功').then(result => { - this.$toBack(); + + // 已报价的食堂 + let already_offer; + // 关联食堂 + this.relation_list.map(item => { + if(item.checked){ + already_offer = this.selected_canteens.find(s_item => s_item.id == item.id); + } + }) + if(_t == 1 && typeof(already_offer) != 'undefined'){ + uni.showModal({ + title: '您当前已有相同食堂报价单审核中', + content: `编号【${already_offer.q_sn}】,仍要发起,之前待审核报价单将会撤回`, + success: result => { + if(result.confirm){ + launchRequest(); + }else{ + this.button_click = false; + } + } }) - }).catch(err => this.button_click = false) + }else{ + launchRequest(); + } + function launchRequest(){ + // 操作状态,是保存还是直接发起 + let state = ['待发起', '待审核'][_t]; + that.$http(that.API.API_SUPPLIER_QUOTATIONSAVE, { + data: list, + state: state, + q_sn: that.code, + start: that.deadline_start, + end: that.deadline_end + }).then(res => { + that.$msg('操作成功').then(result => { + that.$toBack(); + }) + }).catch(err => that.button_click = false) + } }, // 保存 save(_t){ + let that = this; // 拦截按钮重复点击 if(this.button_click){ return; @@ -454,11 +506,14 @@ }) } }); + // 已报价的食堂 + let already_offer; // 关联食堂 let canteen_ids = []; this.relation_list.map(item => { if(item.checked){ canteen_ids.push(item.id); + already_offer = this.selected_canteens.find(s_item => s_item.id == item.id); } }) if(canteen_ids.length <= 0){ @@ -477,19 +532,36 @@ this.button_click = false; return this.$msg('请补充完整物资报价信息') } - // 操作状态,是保存还是直接发起 - let state = ['待发起', '待审核'][_t]; - this.$http(this.API.API_SUPPLIER_QUOTATIONAPPLY, { - data: list, - state: state, - canteen_ids: canteen_ids, - start: this.deadline_start, - end: this.deadline_end - }).then(res => { - this.$msg(res.data).then(result => { - this.$toBack(); + if(_t == 1 && typeof(already_offer) != 'undefined'){ + uni.showModal({ + title: '您当前已有相同食堂报价单审核中', + content: `编号【${already_offer.q_sn}】,仍要发起,之前待审核报价单将会撤回`, + success: result => { + if(result.confirm){ + launchRequest(); + }else{ + this.button_click = false; + } + } }) - }).catch(err => this.button_click = false) + }else{ + launchRequest(); + } + function launchRequest(){ + // 操作状态,是保存还是直接发起 + let state = ['待发起', '待审核'][_t]; + that.$http(that.API.API_SUPPLIER_QUOTATIONAPPLY, { + data: list, + state: state, + canteen_ids: canteen_ids, + start: that.deadline_start, + end: that.deadline_end + }).then(res => { + that.$msg(res.data).then(result => { + that.$toBack(); + }) + }).catch(err => that.button_click = false) + } } } } diff --git a/supplier/pages/order/detail.vue b/supplier/pages/order/detail.vue index 598c3de..4e1c6fe 100644 --- a/supplier/pages/order/detail.vue +++ b/supplier/pages/order/detail.vue @@ -97,7 +97,8 @@ contents: [], q_sn: '', // 订单号 show_count: 0, - button_click: false + button_click: false, + selected_canteens: [] } }, computed: { @@ -160,23 +161,80 @@ return obj; }); this.contents = contents; + + // 如果状态是待发起的,需要请求列表接口 + if(res.data.order.state == '待发起'){ + this.getOfferList(); + } }).catch(err => { this.$toBack(); }) }, + // 获取订单列表(取出食堂id) + getOfferList(){ + this.$http(this.API.API_SUPPLIER_QUOTATIONORDERLIST, { + state: 1, + page: 1, + page_size: 10 + }).then(res => { + let list = res.data?.list?.data || []; + // 数组对象去重 + list = this.$shared.deWeightFour(list, 'canteen_id'); + let selected_canteens = []; + list.map(item => { + if(item.state == '待审核'){ + selected_canteens.push({ + id: item.canteen_id, + q_sn: item.q_sn + }) + } + }) + this.selected_canteens = selected_canteens; + }) + }, // 改变订单状态 orderStateChange(state){ if(this.button_click) return; this.button_click = true; - this.$http(this.API.API_SUPPLIER_QUOTATIONUPDATE, { - q_sn: this.q_sn, - state: state - }).then(res => { - console.log("revokeOrder", res); - this.$msg('操作成功'); - this.button_click = false; - this.getDetail(); // 更新当前页面数据 - }).catch(err => this.button_click = false) + let that = this; + + if(state == '待审核'){ + let already_offer; + this.selected_canteens.map(item => { + if(item.id == this.order.canteen_id){ + already_offer = item; + } + }) + if(typeof(already_offer) != 'undefined'){ + uni.showModal({ + title: '您当前已有相同食堂报价单审核中', + content: `编号【${already_offer.q_sn}】,仍要发起,之前待审核报价单将会撤回`, + success: result => { + if(result.confirm){ + launchRequest(); + }else{ + this.button_click = false; + } + } + }) + }else{ + launchRequest(); + } + }else{ + launchRequest(); + } + + function launchRequest(){ + that.$http(that.API.API_SUPPLIER_QUOTATIONUPDATE, { + q_sn: that.q_sn, + state: state + }).then(res => { + console.log("revokeOrder", res); + that.$msg('操作成功'); + that.button_click = false; + that.getDetail(); // 更新当前页面数据 + }).catch(err => that.button_click = false) + } } } }