2 Commits

  1. 11
      FrontEnd/components/service/content/selectExhibitionBooth.vue
  2. 146
      FrontEnd/pages/service/_id.vue

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

@ -46,10 +46,13 @@ export default {
watch: {
value: {
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);
},
},
},

146
FrontEnd/pages/service/_id.vue

@ -443,6 +443,8 @@ export default {
rulesShow: false,
boothSelect: 0,
serviceID: false,
stackerDiscountQuota: 0,
stackerDiscountQuotaUsed: 0,
};
},
async created() {
@ -484,6 +486,8 @@ export default {
this.$nextTick(()=>{
this.isLoading = false;
});
// this.discount();
},
mounted() {
let vm = this;
@ -671,6 +675,9 @@ export default {
.then((response) => {
if(response && response.data && response.data.DATA && response.data.DATA.rel){
let data = response.data.DATA.rel
console.log('getExhibitions: ', data)
if(data.length>0){
this.selectExhibitionList = data.map((item) => {
return {
@ -690,6 +697,9 @@ export default {
.then((response) => {
if(response && response.data && response.data.DATA && response.data.DATA.rel){
let data = response.data.DATA.rel
console.log('getServiceItems: ', data)
if(data.length>0){
this.typeGroupList = data.map((item) => {
if(item.ItemType=="02"){
@ -722,6 +732,9 @@ export default {
.then((response) => {
if(response && response.data && response.data.DATA && response.data.DATA.rel){
let data = response.data.DATA.rel
console.log('getPackages: ', data)
if(data.length>0){
this.selectPackageList = data.map((item) => {
return {
@ -740,6 +753,9 @@ export default {
.then((response) => {
if(response && response.data && response.data.DATA && response.data.DATA.rel){
let data = response.data.DATA.rel
console.log('getQuantitySelects: ', data)
if(data.length>0){
this.quantitySelectList = data;
}
@ -772,7 +788,7 @@ export default {
if(response && response.data && response.data.DATA && response.data.DATA.rel){
let data = response.data.DATA.rel
console.log(data)
console.log('getServiceData: ', data)
if(data){
this.content.name = data.ServiceName;
@ -819,6 +835,11 @@ export default {
//
getBoothSelect(value){
this.boothSelect = value;
this.setStackerDiscountQuota();
this.ChangeCosts(null);
},
//
async getInfoItem() {
@ -828,7 +849,7 @@ export default {
if(response && response.data && response.data.DATA && response.data.DATA.rel){
let data = response.data.DATA.rel
console.log(data);
console.log('getInfoItem: ', data);
if(data.length>0){
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){
this.ChangeCosts(null);
return false;
@ -964,11 +985,14 @@ export default {
this.$refs.ref_quantitySelectGroup.clearAll();
}
},
//()
//() //
ChangeCosts(data){
let totalPrice = 0;
this.totalPrice = 0;
this.rulesShow = false;
this.stackerDiscountQuotaUsed = 0;
// let selectExhibitionData = this.$refs.ref_selectExhibition.formData;
let selectExhibitionServiceData = [];
if(this.selectExhibitionServiceList.length>0){
@ -981,22 +1005,37 @@ export default {
}
}
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++){
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){
this.totalPrice = 0;
this.finalPrice = "0";
this.rulesShow = true;
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){
this.totalPrice = 0;
this.finalPrice = "0";
@ -1015,11 +1054,74 @@ export default {
this.totalPrice = Math.ceil(totalPrice);
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){
//
console.log('expenseRules', this.expenseRules);
console.log('堆高機func: ', data1);
console.log('堆高機func: ', data2);
console.log('expenseRules: ', this.expenseRules);
let price = 0;
let tmpWeight = 0;//Number(data1.weight)/1000;
@ -1059,7 +1161,7 @@ export default {
for(let i=0;i<this.expenseRules.length;i++){
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){
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);
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;
},
TruckCostRules(){

Loading…
Cancel
Save