Browse Source

7公噸折扣需求完成,展覽名稱必選權限待優化

Dev
parent
commit
ed443d3ede
  1. 11
      FrontEnd/components/service/content/selectExhibitionBooth.vue
  2. 148
      FrontEnd/pages/service/_id.vue

11
FrontEnd/components/service/content/selectExhibitionBooth.vue

@ -46,10 +46,13 @@ export default {
watch: { watch: {
value: { value: {
handler: function () { handler: function () {
if (this.value) {
console.log(this.value);
this.$emit('booth-select', this.value);
}
// if (this.value) {
// console.log(this.value);
// this.$emit('booth-select', this.value);
// }
this.$emit('booth-select', this.value);
}, },
}, },
}, },

148
FrontEnd/pages/service/_id.vue

@ -441,8 +441,10 @@ export default {
previewFile: '', previewFile: '',
countdown: 15, countdown: 15,
rulesShow: false, rulesShow: false,
boothSelect: 0,
boothSelect: 0,
serviceID: false, serviceID: false,
stackerDiscountQuota: 0,
stackerDiscountQuotaUsed: 0,
}; };
}, },
async created() { async created() {
@ -484,6 +486,8 @@ export default {
this.$nextTick(()=>{ this.$nextTick(()=>{
this.isLoading = false; this.isLoading = false;
}); });
// this.discount();
}, },
mounted() { mounted() {
let vm = this; let vm = this;
@ -671,6 +675,9 @@ export default {
.then((response) => { .then((response) => {
if(response && response.data && response.data.DATA && response.data.DATA.rel){ if(response && response.data && response.data.DATA && response.data.DATA.rel){
let data = response.data.DATA.rel let data = response.data.DATA.rel
console.log('getExhibitions: ', data)
if(data.length>0){ if(data.length>0){
this.selectExhibitionList = data.map((item) => { this.selectExhibitionList = data.map((item) => {
return { return {
@ -690,6 +697,9 @@ export default {
.then((response) => { .then((response) => {
if(response && response.data && response.data.DATA && response.data.DATA.rel){ if(response && response.data && response.data.DATA && response.data.DATA.rel){
let data = response.data.DATA.rel let data = response.data.DATA.rel
console.log('getServiceItems: ', data)
if(data.length>0){ if(data.length>0){
this.typeGroupList = data.map((item) => { this.typeGroupList = data.map((item) => {
if(item.ItemType=="02"){ if(item.ItemType=="02"){
@ -722,6 +732,9 @@ export default {
.then((response) => { .then((response) => {
if(response && response.data && response.data.DATA && response.data.DATA.rel){ if(response && response.data && response.data.DATA && response.data.DATA.rel){
let data = response.data.DATA.rel let data = response.data.DATA.rel
console.log('getPackages: ', data)
if(data.length>0){ if(data.length>0){
this.selectPackageList = data.map((item) => { this.selectPackageList = data.map((item) => {
return { return {
@ -740,6 +753,9 @@ export default {
.then((response) => { .then((response) => {
if(response && response.data && response.data.DATA && response.data.DATA.rel){ if(response && response.data && response.data.DATA && response.data.DATA.rel){
let data = response.data.DATA.rel let data = response.data.DATA.rel
console.log('getQuantitySelects: ', data)
if(data.length>0){ if(data.length>0){
this.quantitySelectList = data; this.quantitySelectList = data;
} }
@ -772,7 +788,7 @@ export default {
if(response && response.data && response.data.DATA && response.data.DATA.rel){ if(response && response.data && response.data.DATA && response.data.DATA.rel){
let data = response.data.DATA.rel let data = response.data.DATA.rel
console.log(data)
console.log('getServiceData: ', data)
if(data){ if(data){
this.content.name = data.ServiceName; this.content.name = data.ServiceName;
@ -819,6 +835,11 @@ export default {
// //
getBoothSelect(value){ getBoothSelect(value){
this.boothSelect = value; this.boothSelect = value;
this.setStackerDiscountQuota();
this.ChangeCosts(null);
}, },
// //
async getInfoItem() { async getInfoItem() {
@ -828,7 +849,7 @@ export default {
if(response && response.data && response.data.DATA && response.data.DATA.rel){ if(response && response.data && response.data.DATA && response.data.DATA.rel){
let data = response.data.DATA.rel let data = response.data.DATA.rel
console.log(data);
console.log('getInfoItem: ', data);
if(data.length>0){ if(data.length>0){
this.expenseRules = data; this.expenseRules = data;
@ -914,7 +935,7 @@ export default {
} }
} }
} }
// let pickupServiceData = this.$refs.ref_pickupService.formData;
// let pickupServiceData = this.$refs. ref_pickupService.formData;
if(this.rulesShow){ if(this.rulesShow){
this.ChangeCosts(null); this.ChangeCosts(null);
return false; return false;
@ -964,11 +985,14 @@ export default {
this.$refs.ref_quantitySelectGroup.clearAll(); this.$refs.ref_quantitySelectGroup.clearAll();
} }
}, },
//()
//() //
ChangeCosts(data){ ChangeCosts(data){
let totalPrice = 0; let totalPrice = 0;
this.totalPrice = 0; this.totalPrice = 0;
this.rulesShow = false; this.rulesShow = false;
this.stackerDiscountQuotaUsed = 0;
// let selectExhibitionData = this.$refs.ref_selectExhibition.formData; // let selectExhibitionData = this.$refs.ref_selectExhibition.formData;
let selectExhibitionServiceData = []; let selectExhibitionServiceData = [];
if(this.selectExhibitionServiceList.length>0){ if(this.selectExhibitionServiceList.length>0){
@ -981,22 +1005,37 @@ export default {
} }
} }
if(selectExhibitionServiceData.length>0){ if(selectExhibitionServiceData.length>0){
// sort by serviceData weight
selectExhibitionServiceData = selectExhibitionServiceData.sort(function(serviceDataA, serviceDataB) {
return serviceDataB.weight - serviceDataA.weight;
});
console.table(selectExhibitionServiceData)
for(let i=0;i<selectExhibitionServiceData.length;i++){ for(let i=0;i<selectExhibitionServiceData.length;i++){
let arr = selectExhibitionServiceData[i].selectServiceItems;
if(arr.length>0){
for(let j=0;j<arr.length;j++){
if(arr[j].itemType == "01"){
totalPrice += this.stackerCostRules(selectExhibitionServiceData[i],arr[j]);
let serviceTypeArr = selectExhibitionServiceData[i].selectServiceItems;
// let arr = selectExhibitionServiceData[i].selectServiceItems;
if(serviceTypeArr.length>0){
for(let j=0;j<serviceTypeArr.length;j++){
if(serviceTypeArr[j].itemType == "01"){
totalPrice += this.stackerCostRules(selectExhibitionServiceData[i],serviceTypeArr[j]);
// totalPrice += this.discount(selectExhibitionServiceData[i],serviceTypeArr[j]);
if(totalPrice==-1){ if(totalPrice==-1){
this.totalPrice = 0; this.totalPrice = 0;
this.finalPrice = "0"; this.finalPrice = "0";
this.rulesShow = true; this.rulesShow = true;
return false; return false;
} }
}else if(arr[j].itemType == "02"){
}else if(serviceTypeArr[j].itemType == "02"){
}else if(arr[j].itemType == "03" || arr[j].itemType == "04" || arr[j].itemType == "05" || arr[j].itemType == "06"){
totalPrice += this.OtherCostRules(selectExhibitionServiceData[i],arr[j]);
}else if(serviceTypeArr[j].itemType == "03" || serviceTypeArr[j].itemType == "04" || serviceTypeArr[j].itemType == "05" || arr[j].itemType == "06"){
totalPrice += this.OtherCostRules(selectExhibitionServiceData[i],serviceTypeArr[j]);
if(totalPrice==-1){ if(totalPrice==-1){
this.totalPrice = 0; this.totalPrice = 0;
this.finalPrice = "0"; this.finalPrice = "0";
@ -1015,11 +1054,74 @@ export default {
this.totalPrice = Math.ceil(totalPrice); this.totalPrice = Math.ceil(totalPrice);
this.finalPrice = Math.ceil(Number(totalPrice)).toLocaleString(); this.finalPrice = Math.ceil(Number(totalPrice)).toLocaleString();
}, },
setStackerDiscountQuota() {
this.stackerDiscountQuota = 0;
if (this.expenseRules) {
this.expenseRules.forEach(rule => {
if(rule.ItemType === "01" && rule.BoothNo > 0) {
this.stackerDiscountQuota = this.boothSelect / rule.BoothNo * rule.ItemNo;
}
});
}
},
// 7
stackerDiscount(quantity, formData, serviceType) {
this.expenseRules.forEach( rule => {
if(rule.PreferentialScheme === "1") {
// check if serviceType is null
if (serviceType && serviceType.itemType) {
if (serviceType.itemType == rule.ItemType) {
if(formData.weight <= rule.TonNo) {
// if stacker discount still has quota
let quotaLeft = this.stackerDiscountQuota - this.stackerDiscountQuotaUsed;
for (let i = 0; i < quotaLeft; i++) {
if (quantity > 0) {
quantity -= 1;
this.stackerDiscountQuotaUsed += 1;
}
}
}
}
}
}
})
return quantity;
},
// //
stackerCostRules(data1,data2){ stackerCostRules(data1,data2){
//
console.log('expenseRules', this.expenseRules);
console.log('堆高機func: ', data1);
console.log('堆高機func: ', data2);
console.log('expenseRules: ', this.expenseRules);
let price = 0; let price = 0;
let tmpWeight = 0;//Number(data1.weight)/1000; let tmpWeight = 0;//Number(data1.weight)/1000;
@ -1059,7 +1161,7 @@ export default {
for(let i=0;i<this.expenseRules.length;i++){ for(let i=0;i<this.expenseRules.length;i++){
let subArr = this.expenseRules[i].StackerCostRules; let subArr = this.expenseRules[i].StackerCostRules;
console.log('subArr', subArr)
console.log('subArr: ', subArr)
if(this.expenseRules[i].Guid == data2.package_id && subArr.length>0){ if(this.expenseRules[i].Guid == data2.package_id && subArr.length>0){
for(let j=0;j<subArr.length;j++){ for(let j=0;j<subArr.length;j++){
@ -1080,7 +1182,19 @@ export default {
} }
} }
let num = (data1.quantity =="" || data1.quantity =="0") ? 0 : Number(data1.quantity); let num = (data1.quantity =="" || data1.quantity =="0") ? 0 : Number(data1.quantity);
price = price*num;
// price = price*num;
// apply stacker discount
let quantityLeft = this.stackerDiscount(num, data1, data2);
console.log("stackerDiscountQuota: ", this.stackerDiscountQuota)
console.log("stackerDiscountQuotaUsed: ", this.stackerDiscountQuotaUsed)
console.log("quantityLeft: ", quantityLeft)
price = price * quantityLeft;
return price; return price;
}, },
TruckCostRules(){ TruckCostRules(){

Loading…
Cancel
Save