Browse Source

[添加] 供应商发起报价校验拦截已发起审核中的相同订单

[添加] 数组对象去重方法
master
邓平艺 5 years ago
parent
commit
eff5b10331
  1. 12
      supplier/common/shared.js
  2. 122
      supplier/pages/offer/index.vue
  3. 78
      supplier/pages/order/detail.vue

12
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;
};
};
// 数组对象去重
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;
}

122
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)
}
}
}
}

78
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)
}
}
}
}

Loading…
Cancel
Save