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.
701 lines
30 KiB
701 lines
30 KiB
const pricereviewCreate = ()=>{
|
|
return {
|
|
init(){
|
|
},
|
|
modalShow:{
|
|
elevator: false,
|
|
other:false,
|
|
otherToElevator:false,
|
|
},
|
|
vol_no: vol_no,
|
|
apply_key: apply_key,
|
|
customer:customer,
|
|
manager:manager,
|
|
salesman:salesman,
|
|
salesman_name:salesman_name,
|
|
pre_order_date:pre_order_date,
|
|
address:address,
|
|
progress_status:progress_status,
|
|
total_spec:total_spec,
|
|
elevators: hope_elevators,
|
|
case_name:case_name, //案件名稱
|
|
contract_status:contract_kind, // 契約性質
|
|
pay_method:payment_kind, // 付款方式
|
|
startDate:contract_begin_date, //合約開始日期
|
|
endDate:contract_end_date, // 合約結束日期
|
|
brand:brand,
|
|
modalElevatorInfo:{
|
|
spec:'',
|
|
person:'',
|
|
weight:'',
|
|
stop:'',
|
|
speed:'',
|
|
permitNumber:'', //許可證號碼
|
|
brand:'', //品牌
|
|
m1:'N', //贈送M1
|
|
months:12, // 保養月數
|
|
cycle:'', // 保養週期
|
|
method:'', //保養方式
|
|
checkYear:'', //竣工檢查年度
|
|
lastDate:'', // 上次年檢日期
|
|
yearCheckFee:1260, //年檢費用
|
|
price:'', //公司發布價(月)
|
|
qty:1, //電梯數量
|
|
sale_price:'', //契約報價
|
|
inspectionFee:0, //檢驗費
|
|
},
|
|
otherOptions: otherOptions,
|
|
modalOtherOptionInfo:{
|
|
pr_no:"",
|
|
name:"",
|
|
price: 0,
|
|
num:"",
|
|
memo:"",
|
|
},
|
|
otherOptionKey: otherOptionKey,
|
|
currentOtherOptionKey:'',
|
|
toElevators:[],
|
|
toElevatorNo:'',
|
|
serviceFee: service_fee,
|
|
remark:memo,
|
|
penalty: penalty,
|
|
deposit_rate: deposit_rate,
|
|
keep_rate: keep_rate,
|
|
warranty_rate: warranty_rate,
|
|
attatch1:'',
|
|
attatch2:'',
|
|
error:[],
|
|
openCreateElevatorModal(){
|
|
this.modalShow.elevator = true;
|
|
body.style.overflow = 'hidden';
|
|
},
|
|
hideCreateElevatorModal(){
|
|
this.modalShow.elevator = false;
|
|
body.style.overflow = 'auto';
|
|
this.modalElevatorInfo = {
|
|
spec:'',
|
|
person:'',
|
|
weight:'',
|
|
stop:'',
|
|
speed:'',
|
|
permitNumber:'', //許可證號碼
|
|
brand:'', //品牌
|
|
m1:'N', //贈送M1
|
|
months:12, // 保養月數
|
|
cycle:'', // 保養週期
|
|
method:'', //保養方式
|
|
checkYear:'', //竣工檢查年度
|
|
lastDate:'', // 上次年檢日期
|
|
yearCheckFee:1260, //年檢費用
|
|
price:'', //公司發布價(月)
|
|
qty:1, //電梯數量
|
|
sale_price:'', //契約報價
|
|
inspectionFee:0,
|
|
};
|
|
},
|
|
createElevatorFn(){
|
|
// if(this.modalElevatorInfo.spec == '') return alert("請選擇電梯規格");
|
|
// if(this.modalElevatorInfo.person == '') return alert("請選擇人乘");
|
|
// if(this.modalElevatorInfo.weight == '') return alert("請輸入載重");
|
|
// if(this.modalElevatorInfo.stop == '') return alert("請輸入停數");
|
|
// if(this.modalElevatorInfo.speed == '') return alert("請選擇速度");
|
|
// if(this.modalElevatorInfo.brand == '') return alert("請選擇品牌");
|
|
// if(this.modalElevatorInfo.months == '') return alert("請輸入保養月數");
|
|
if(this.modalElevatorInfo.m1 == 'Y' && this.modalElevatorInfo.months < 60) return alert('贈送M1保養月數不得小於60!')
|
|
// if(this.modalElevatorInfo.method == '') return alert("請選擇保養方式");
|
|
// if(this.modalElevatorInfo.cycle == '') return alert("請選擇保養週期");
|
|
// if(this.modalElevatorInfo.checkYear == '') return alert("請輸入竣工檢查年度");
|
|
// if(this.modalElevatorInfo.price == '') return alert("請選擇正確規格");
|
|
// if(this.modalElevatorInfo.sale_price == '') return alert("請輸入契約報價");
|
|
this.total_spec ++;
|
|
this.elevators.push({
|
|
id: this.total_spec,
|
|
spec: this.modalElevatorInfo.spec,
|
|
person: this.modalElevatorInfo.person,
|
|
weight: this.modalElevatorInfo.weight,
|
|
stop: this.modalElevatorInfo.stop,
|
|
speed: this.modalElevatorInfo.speed,
|
|
permitNumber: this.modalElevatorInfo.permitNumber,
|
|
brand: this.modalElevatorInfo.brand,
|
|
m1: this.modalElevatorInfo.m1,
|
|
months:this.modalElevatorInfo.months, // 保養月數
|
|
cycle: this.modalElevatorInfo.cycle,
|
|
method:this.modalElevatorInfo.method, // 保養方法
|
|
checkYear: this.modalElevatorInfo.checkYear,
|
|
lastDate: this.modalElevatorInfo.lastDate,
|
|
yearCheckFee: this.modalElevatorInfo.yearCheckFee,
|
|
price: this.modalElevatorInfo.price,
|
|
qty: this.modalElevatorInfo.qty,
|
|
sale_price: this.modalElevatorInfo.sale_price,
|
|
inspectionFee: this.modalElevatorInfo.inspectionFee
|
|
})
|
|
this.hideCreateElevatorModal();
|
|
},
|
|
copyElevator(idx){
|
|
const spec = this.elevators[idx].spec;
|
|
const person = this.elevators[idx].person;
|
|
const stop = this.elevators[idx].stop;
|
|
const weight = this.elevators[idx].weight
|
|
const speed = this.elevators[idx].speed;
|
|
const brand = this.elevators[idx].brand;
|
|
const m1 = this.elevators[idx].m1;
|
|
const months = this.elevators[idx].months;
|
|
const method = this.elevators[idx].method;
|
|
const cycle = this.elevators[idx].cycle;
|
|
const checkYear = this.elevators[idx].checkYear;
|
|
const lastDate = this.elevators[idx].lastDate;
|
|
const yearCheckFee = this.elevators[idx].yearCheckFee;
|
|
const price = this.elevators[idx].price;
|
|
const qty = this.elevators[idx].qty;
|
|
const sale_price = this.elevators[idx].sale_price;
|
|
const inspectionFee = this.elevators[idx].inspectionFee;
|
|
this.total_spec ++;
|
|
this.elevators.push({
|
|
id: this.total_spec,
|
|
spec: spec,
|
|
person: person,
|
|
stop: stop,
|
|
weight:weight,
|
|
speed: speed,
|
|
permitNumber: '',
|
|
brand: brand,
|
|
m1: m1,
|
|
months: months,
|
|
method: method,
|
|
cycle: cycle,
|
|
checkYear: checkYear,
|
|
lastDate: lastDate,
|
|
yearCheckFee: yearCheckFee,
|
|
price: price,
|
|
qty: qty,
|
|
sale_price: sale_price,
|
|
inspectionFee: inspectionFee
|
|
})
|
|
},
|
|
removeElevator(id){
|
|
if(!confirm('確定刪除該電梯?')) return;
|
|
this.elevators = this.elevators.filter(elevator=> elevator.id != id)
|
|
const issetElevators = [];
|
|
this.elevators.forEach(elevator=>{
|
|
issetElevators.push(elevator.id);
|
|
})
|
|
this.otherOptions.forEach(option=>{
|
|
option.toElevator = option.toElevator.filter(el=>{
|
|
return issetElevators.includes(el.id)
|
|
})
|
|
})
|
|
},
|
|
openCreateOtherOptionFn(){
|
|
this.modalShow.other = true
|
|
body.style.overflow = 'hidden'
|
|
},
|
|
createOtherOptionFn(){
|
|
this.otherOptionKey ++;
|
|
this.otherOptions.push({
|
|
id: this.otherOptionKey,
|
|
pr_no: this.modalOtherOptionInfo.pr_no,
|
|
name: this.modalOtherOptionInfo.name,
|
|
price: this.modalOtherOptionInfo.price,
|
|
num: this.modalOtherOptionInfo.num,
|
|
memo: this.modalOtherOptionInfo.memo,
|
|
toElevator:[],
|
|
})
|
|
this.modalOtherOptionInfo = {
|
|
pr_no: '',
|
|
name: '',
|
|
price: 0,
|
|
num: '',
|
|
memo: '',
|
|
}
|
|
this.hideCreateOtherOptionModal();
|
|
},
|
|
hideCreateOtherOptionModal(){
|
|
this.modalShow.other = false
|
|
// this.$refs.createOtherOptionModal.style.display = 'none';
|
|
body.style.overflow = 'auto'
|
|
},
|
|
addOtherOptionToElevator(id){
|
|
this.currentOtherOptionKey = id;
|
|
this.toElevators = [];
|
|
this.toElevatorNo = "";
|
|
const matchElevators = this.otherOptions.filter(option=> option.id == id)[0].toElevator.map(elevator=> elevator.id)
|
|
this.toElevatorNo = matchElevators[0]
|
|
console.log(this.elevators);
|
|
this.elevators.forEach(elevator=>{
|
|
if(elevator.price > 0){
|
|
let model = ''
|
|
model = elevator.spec
|
|
this.toElevators.push({
|
|
id: elevator.id,
|
|
model: model,
|
|
checked: matchElevators.includes(elevator.id) ? 1: 0,
|
|
})
|
|
}
|
|
})
|
|
|
|
this.modalShow.otherToElevator = true
|
|
body.style.overflow = 'hidden'
|
|
},
|
|
hideToOtherOptionElevatorModal(){
|
|
this.modalShow.otherToElevator = false
|
|
body.style.overflow = 'auto'
|
|
},
|
|
copyOtherOption(id){
|
|
this.otherOptionKey++;
|
|
const copyOption = this.otherOptions.filter(option=> option.id === id)[0]
|
|
console.log(copyOption);
|
|
this.otherOptions.push({
|
|
id: this.otherOptionKey,
|
|
name: copyOption.name,
|
|
price: copyOption.price,
|
|
num: copyOption.num,
|
|
toElevator: [],
|
|
pr_no: copyOption.pr_no
|
|
})
|
|
console.log(this.otherOptions);
|
|
},
|
|
chkOtherOptionToElevators(){
|
|
const checkedOptions = [];
|
|
|
|
const matchElevators = this.elevators.filter(elevator=> elevator.id == this.toElevatorNo)[0]
|
|
console.log(matchElevators);
|
|
checkedOptions.push({
|
|
id: this.toElevatorNo,
|
|
model: matchElevators['spec'],
|
|
})
|
|
this.otherOptions.forEach(option=>{
|
|
if(option.id == this.currentOtherOptionKey){
|
|
option.toElevator = [];
|
|
option.toElevator.push(...checkedOptions)
|
|
}
|
|
})
|
|
console.log(this.otherOptions);
|
|
this.currentOtherOptionKey = ''
|
|
|
|
this.hideToOtherOptionElevatorModal();
|
|
},
|
|
removeOtherOption(id){
|
|
this.otherOptions = this.otherOptions.filter(option=> option.id != id)
|
|
},
|
|
checkMonths(idx=null){
|
|
if(this.elevators[idx].months < 60 && this.elevators[idx].m1 == 'Y'){
|
|
alert('贈送M1保養月數不得小於60!')
|
|
this.elevators[idx].months = 60
|
|
}
|
|
},
|
|
changeMonths(idx=null){
|
|
if(idx===null){
|
|
if(this.modalElevatorInfo.m1 == 'N') return;
|
|
if(this.modalElevatorInfo.months < 60){
|
|
this.modalElevatorInfo.months = 60
|
|
}
|
|
return;
|
|
}
|
|
if(this.elevators[idx].m1 == 'N') return;
|
|
if(this.elevators[idx].months < 60){
|
|
this.elevators[idx].months = 60
|
|
}
|
|
},
|
|
get totalPrice(){
|
|
let total_price = this.elevators.reduce((accumulator, el) => accumulator + Number(el.price*el.months), 0);
|
|
let total_other_price = this.otherOptions.reduce((accumulator, option) => accumulator + Number(option.price*option.num), 0);
|
|
return total_price + total_other_price;
|
|
},
|
|
get totalSalePrice(){
|
|
let total_sale_price = this.elevators.reduce((accumulator, el) => accumulator + Number(el.sale_price*el.months), 0);
|
|
return total_sale_price;
|
|
},
|
|
get totalElevatorsNum(){
|
|
let total_num = this.elevators.reduce((accumulator, el) => accumulator + Number(el.qty), 0);
|
|
return total_num;
|
|
},
|
|
get totalOtherOptionsNum(){
|
|
let total_other_num = this.otherOptions.reduce((accumulator, option) => accumulator + Number(option.num), 0);
|
|
return total_other_num;
|
|
},
|
|
get totalOtherOptionsPrice(){
|
|
let total_other_price = this.otherOptions.reduce((accumulator, option) => accumulator + Number(option.price*option.num), 0);
|
|
return total_other_price;
|
|
},
|
|
get discountRate(){
|
|
return Math.round((Number(this.totalSalePrice) - Number(this.serviceFee)) / Number(this.totalPrice) * 1000) / 1000
|
|
},
|
|
async getModalElevatorPrice(){
|
|
const spec = this.modalElevatorInfo.spec
|
|
const person = this.modalElevatorInfo.person
|
|
const stop = this.modalElevatorInfo.stop
|
|
const weight = this.modalElevatorInfo.weight
|
|
const speed = this.modalElevatorInfo.speed
|
|
const m1 = this.modalElevatorInfo.m1
|
|
const method = this.modalElevatorInfo.method
|
|
const cycle = this.modalElevatorInfo.cycle
|
|
try{
|
|
const res = await axios.get('./api/getElevatorPrice.php', {params: {spec: spec, person:person, weight: weight, stop: stop, speed: speed, m1: m1, method: method, cycle:cycle}})
|
|
this.modalElevatorInfo.price = res.data;
|
|
console.log(res.data);
|
|
}catch (error) {
|
|
console.error("Error message:", error);
|
|
}
|
|
},
|
|
async getElevatorPrice(idx){
|
|
const spec = this.elevators[idx].spec
|
|
const person = this.elevators[idx].person
|
|
const stop = this.elevators[idx].stop
|
|
const weight = this.elevators[idx].weight
|
|
const speed = this.elevators[idx].speed
|
|
const m1 = this.elevators[idx].m1
|
|
const method = this.elevators[idx].method
|
|
const cycle = this.elevators[idx].cycle
|
|
try{
|
|
const res = await axios.get('./api/getElevatorPrice.php', {params: {spec: spec, person:person, weight: weight, stop: stop, speed: speed, m1: m1, method: method, cycle:cycle}})
|
|
this.elevators[idx].price = res.data;
|
|
console.log(res.data);
|
|
}catch (error) {
|
|
console.error("Error message:", error);
|
|
}
|
|
},
|
|
save(){
|
|
const form = new FormData();
|
|
form.append('vol_no', this.vol_no);
|
|
form.append('apply_key', this.apply_key);
|
|
form.append('customer', this.customer);
|
|
form.append('brand', this.brand);
|
|
form.append('address', this.address);
|
|
form.append('case_name', this.case_name);
|
|
form.append('brand', this.brand);
|
|
form.append('num', this.totalElevatorsNum);
|
|
form.append('salesman', this.salesman);
|
|
form.append('contract_begin_date', this.startDate);
|
|
form.append('contract_end_date', this.endDate);
|
|
form.append('contract_kind', this.contract_status);
|
|
form.append('progress_status', this.progress_status);
|
|
form.append('serviceFee', this.serviceFee);
|
|
form.append('penalty', this.penalty);
|
|
form.append('deposit_rate', this.deposit_rate);
|
|
form.append('keep_rate', this.keep_rate);
|
|
form.append('warranty_rate', this.warranty_rate);
|
|
form.append('remark', this.remark);
|
|
form.append('creater', user_id);
|
|
form.append('attatch1', this.attatch1);
|
|
form.append('attatch2', this.attatch2);
|
|
|
|
form.append('pay_method', this.pay_method);
|
|
form.append('status', 'Y1');
|
|
form.append('total_price', this.totalPrice);
|
|
form.append('total_sale_price', this.totalSalePrice);
|
|
|
|
form.append('elevators', JSON.stringify(this.elevators));
|
|
form.append('otherOptions', JSON.stringify(this.otherOptions));
|
|
|
|
axios.post('./api/postElevatorPricereview.php', form).then(res=>{
|
|
console.log(res.data);
|
|
if(res.data == 'success'){
|
|
alert("保存成功!");
|
|
window.location.reload();
|
|
}
|
|
})
|
|
},
|
|
validation(){
|
|
this.error = [];
|
|
if(this.totalElevatorsNum == 0) this.error.push("請至少輸入一種電梯");
|
|
for(let i=0;i<this.elevators.length;i++){
|
|
if(this.elevators[i].spec =='') this.error.push("整機單價:規格不能為空");
|
|
if(this.elevators[i].person =='') this.error.push("整機單價:人數不能為空");
|
|
if(this.elevators[i].stop =='' || this.elevators[i].stop <= 0 || !Number.isInteger(Number(this.elevators[i].stop))) this.error.push("整機單價:停數需為正整數");
|
|
if(this.elevators[i].speed =='') this.error.push("整機單價:速度不能為空");
|
|
if(this.elevators[i].price =='') this.error.push("整機單價:公司發布價無此規格");
|
|
if(this.elevators[i].sale_price == '' || this.elevators[i].spec_price <= 0) this.error.push("整機單價:售價需大於0");
|
|
if(this.elevators[i].brand == '') this.error.push("整機單價:請選擇電梯品牌");
|
|
if(this.elevators[i].cycle == '') this.error.push("整機單價:請選擇保養週期");
|
|
if(this.elevators[i].checkYear == '') this.error.push("整機單價:請輸入竣檢年度");
|
|
if(this.elevators[i].yearCheckFee == '') this.error.push("整機單價:請輸入年檢日期");
|
|
if(this.elevators[i].lastDate == '' || this.elevators[i].lastDate == '0000-00-00') this.error.push("整機單價:請輸入最後年檢日期");
|
|
if(this.elevators[i].months == '' || this.elevators[i].months <= 0) this.error.push("整機單價:保養月數需大於0");
|
|
if(this.elevators[i].qty <= 0) this.error.push("整機單價:電梯數量需大於0");
|
|
if(this.elevators[i].weight ==='' || this.elevators[i].weight <= 0) this.error.push("整機單價:電梯載重需大於0");
|
|
if(this.elevators[i].inspectionFee ==='' || this.elevators[i].inspectionFee < 0) this.error.push("整機單價:檢測費用需大於0");
|
|
}
|
|
for(let i=0;i<this.otherOptions.length;i++){
|
|
if(this.otherOptions[i].name == '' ) this.error.push("附加項目:名稱不得為空");
|
|
if(this.otherOptions[i].price === '' ) this.error.push("附加項目:價錢需大於0");
|
|
if(this.otherOptions[i].num == '' ) this.error.push("附加項目:數量需大於0");
|
|
if(this.otherOptions[i].toElevator.length <= 0) this.error.push("附加項目:需配對至電梯")
|
|
}
|
|
if(this.contract_status == '') this.error.push("請選擇契約性質");
|
|
if(this.pay_method == '') this.error.push("請選擇付款方式");
|
|
if(this.case_name == '') this.error.push("請輸入案件名稱");
|
|
if(this.startDate == '' || this.startDate == '0000-00-00') this.error.push("請輸入合約開始日期");
|
|
if(this.endDate == '' ||this.endDate == '0000-00-00') this.error.push("請輸入合約結束日期");
|
|
|
|
if(this.error.length > 0){
|
|
let errortext = '';
|
|
this.error.forEach(err=>{
|
|
errortext += err+'\n';
|
|
})
|
|
alert(errortext)
|
|
console.log(this.error);
|
|
}
|
|
|
|
return this.error.length > 0 ? false : true
|
|
|
|
},
|
|
submit(){
|
|
const validation = this.validation();
|
|
if(!validation) return
|
|
const form = new FormData();
|
|
form.append('vol_no', this.vol_no);
|
|
form.append('apply_key', this.apply_key);
|
|
form.append('customer', this.customer);
|
|
form.append('brand', this.brand);
|
|
form.append('address', this.address);
|
|
form.append('case_name', this.case_name);
|
|
form.append('brand', this.brand);
|
|
form.append('num', this.totalElevatorsNum);
|
|
form.append('salesman', this.salesman);
|
|
form.append('contract_begin_date', this.startDate);
|
|
form.append('contract_end_date', this.endDate);
|
|
form.append('contract_kind', this.contract_status);
|
|
form.append('progress_status', this.progress_status);
|
|
form.append('serviceFee', this.serviceFee);
|
|
form.append('penalty', this.penalty);
|
|
form.append('deposit_rate', this.deposit_rate);
|
|
form.append('keep_rate', this.keep_rate);
|
|
form.append('warranty_rate', this.warranty_rate);
|
|
form.append('remark', this.remark);
|
|
form.append('creater', user_id);
|
|
form.append('attatch1', this.attatch1);
|
|
form.append('attatch2', this.attatch2);
|
|
|
|
form.append('pay_method', this.pay_method);
|
|
form.append('status', 'YS');
|
|
form.append('total_price', this.totalPrice);
|
|
form.append('total_sale_price', this.totalSalePrice);
|
|
|
|
form.append('elevators', JSON.stringify(this.elevators));
|
|
form.append('otherOptions', JSON.stringify(this.otherOptions));
|
|
|
|
axios.post('./api/postElevatorPricereview.php', form).then(res=>{
|
|
console.log(res.data);
|
|
if(res.data == 'success'){
|
|
alert("送審成功!");
|
|
// window.location.reload();
|
|
window.location.href = '../index.php?' + token;
|
|
}
|
|
})
|
|
},
|
|
async getUsername(user_id){
|
|
if(user_id == '') return '---'
|
|
const res = await axios.get('./api/getUsername.php', {params: {user_id: user_id}})
|
|
return res.data ;
|
|
},
|
|
uploadFiles(e, attatch){
|
|
if(attatch == 1){
|
|
this.attatch1 = e.target.files[0]
|
|
}
|
|
if(attatch == 2){
|
|
this.attatch2 = e.target.files[0]
|
|
}
|
|
},
|
|
async getBonus(idx){
|
|
let contract_type = '';
|
|
if(this.contract_status == 1){
|
|
contract_type = 'new'
|
|
}else if(this.contract_status == 2){
|
|
contract_type = 'free_to_charge'
|
|
}else if(this.contract_status == 3){
|
|
contract_type = 'renew_priceissue'
|
|
}
|
|
const contract_years = this.isDifferenceMoreThanAYear(this.startDate, this.endDate);
|
|
const receivable_date_due = this.getNext25thDate(this.startDate);
|
|
const res = await axios.get('./api/maintaenance_contract_bonus.php', {params:
|
|
{
|
|
'contract_type':contract_type,
|
|
'contract_years': contract_years,
|
|
'discount': this.discountRate,
|
|
'fee_per_st': this.elevators[idx].sale_price,
|
|
'receivable_date_due':receivable_date_due,
|
|
'sales_id': user_id,
|
|
'region_manger_id': 'M0174',
|
|
'regular_contract_manger_id': 'M0174',
|
|
}})
|
|
|
|
console.log(res.data);
|
|
|
|
},
|
|
isDifferenceMoreThanAYear(startDate, endDate) {
|
|
const oneYear = 1000 * 60 * 60 * 24 * 365; // 毫秒數
|
|
const difference = Math.abs(endDate - startDate);
|
|
return difference > oneYear ? 'above_two' : 'one';
|
|
},
|
|
getNext25thDate(dateString) {
|
|
// 將傳入的日期字串轉換為 Date 物件
|
|
let date = new Date(dateString);
|
|
|
|
// 如果日期大於 25,則將月份加一
|
|
if (date.getDate() > 25) {
|
|
// 增加一個月
|
|
date.setMonth(date.getMonth() + 1);
|
|
}
|
|
|
|
// 設定日期為 25 號
|
|
date.setDate(25);
|
|
|
|
// 將 Date 物件格式化為 YYYY-MM-DD 字串
|
|
let year = date.getFullYear();
|
|
let month = date.getMonth() + 1; // 月份是從 0 開始的,所以加 1
|
|
month = month < 10 ? '0' + month : month; // 確保月份是兩位數
|
|
|
|
return `${year}-${month}-25`;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
const pricereviewCheck = ()=>{
|
|
return {
|
|
init(){
|
|
console.log(123);
|
|
this.elevators = elevators;
|
|
this.otherOptions = otherOptions;
|
|
this.elevators.forEach(el=>{
|
|
el.otherOptions = []
|
|
el.otherOptionsTotalPrice = 0;
|
|
})
|
|
|
|
this.elevators.forEach((elevator, idx)=>{
|
|
if(elevator.maintain_method == 'A'){
|
|
elevator.maintain_method = '全包'
|
|
}else if(elevator.maintain_method == 'B'){
|
|
elevator.maintain_method = '半包'
|
|
}else if(elevator.maintain_method == 'C'){
|
|
elevator.maintain_method = '清包'
|
|
}
|
|
if(elevator.maintain_period == 1){
|
|
elevator.maintain_period = '月保'
|
|
}else if(elevator.maintain_period == 2){
|
|
elevator.maintain_period = '月保兩次'
|
|
}else if(elevator.maintain_period == 3){
|
|
elevator.maintain_period = '雙月保'
|
|
}else if(elevator.maintain_period == 4){
|
|
elevator.maintain_period = '季保'
|
|
}
|
|
this.elevators_total_price += elevator.stand_price*elevator.maintain_months
|
|
this.otherOptions.forEach(option=>{
|
|
if(option.option_relate_spec == elevator.item_no){
|
|
elevator.otherOptionsTotalPrice += option.item_unit_price * option.item_qty
|
|
this.elevators[idx].otherOptions.push({
|
|
'id': option.id,
|
|
'item_spec': option.item_spec,
|
|
'item_unit_price': option.item_unit_price,
|
|
'item_qty': option.item_qty,
|
|
'mi': Math.round(option.item_unit_price),
|
|
})
|
|
}
|
|
})
|
|
})
|
|
console.log(this.elevators);
|
|
if(payment_kind == "A40006"){
|
|
this.payment_kind = "年繳";
|
|
}else if(payment_kind == "A40007"){
|
|
this.payment_kind = "季繳";
|
|
}else if(payment_kind == "A40003"){
|
|
this.payment_kind = "月繳";
|
|
}else if(payment_kind == "A40004"){
|
|
this.payment_kind = "雙月繳";
|
|
}else if(payment_kind == "A40005"){
|
|
this.payment_kind = "半年繳";
|
|
}
|
|
|
|
this.sign1 = this.getUsername(sign1)
|
|
this.sign2 = this.getUsername(sign2)
|
|
this.sign3 = this.getUsername(sign3)
|
|
this.sign4 = this.getUsername(sign4)
|
|
},
|
|
user_id:user_id,
|
|
apply_key:apply_key,
|
|
contractno: vol_no,
|
|
salesman: salesman,
|
|
customer: customer,
|
|
total_price: total_price,
|
|
total_sale_price: Number(total_sale_price),
|
|
elevators: [],
|
|
otherOptions:[],
|
|
elevators_total_price:0,
|
|
payment_kind: payment_kind,
|
|
memo: memo,
|
|
address: address,
|
|
case_name: case_name,
|
|
maintain_months: maintain_months,
|
|
service_fee: service_fee,
|
|
penalty: penalty,
|
|
deposit_rate: deposit_rate,
|
|
keep_rate: keep_rate,
|
|
warranty_rate: warranty_rate,
|
|
contract_begin_date: contract_begin_date,
|
|
contract_end_date: contract_end_date,
|
|
sign1:'',
|
|
sign2:'',
|
|
sign3:'',
|
|
sign4:'',
|
|
reviewcomment:'',
|
|
get single_amount(){
|
|
console.log(this.payment_kind);
|
|
let month_amount = Number(this.total_sale_price) / Number(this.maintain_months);
|
|
let pay_times = 0;
|
|
let amount_times = 0;
|
|
if(payment_kind == "A40006"){
|
|
amount_times = Math.round(month_amount*12)
|
|
pay_times = this.maintain_months / 12
|
|
}
|
|
if(payment_kind == "A40007"){
|
|
amount_times = Math.round(month_amount*3)
|
|
pay_times = this.maintain_months / 3
|
|
}
|
|
if(payment_kind == "A40003"){
|
|
amount_times = Math.round(month_amount)
|
|
pay_times = this.maintain_months / 1
|
|
}
|
|
if(payment_kind == "A40004"){
|
|
amount_times = Math.round(month_amount*2)
|
|
pay_times = this.maintain_months / 2
|
|
}
|
|
if(payment_kind == "A40005"){
|
|
amount_times = Math.round(month_amount*6)
|
|
pay_times = this.maintain_months / 6
|
|
}
|
|
return {
|
|
'amount_times': amount_times,
|
|
'pay_times': pay_times
|
|
}
|
|
},
|
|
get otherOptionsTotalPrice(){
|
|
return this.otherOptions.reduce((total, option) => {
|
|
return total + (option.item_qty * option.item_unit_price);
|
|
}, 0);
|
|
},
|
|
async getUsername(user_id){
|
|
if(user_id == '') return '---'
|
|
const res = await axios.get('./api/getUsername.php', {params: {user_id: user_id}})
|
|
return res.data ;
|
|
},
|
|
check(sign, status, user_id = this.user_id ){
|
|
console.log(sign);
|
|
const form = new FormData();
|
|
form.append('sign', sign);
|
|
form.append('mid', this.apply_key);
|
|
form.append('result', status);
|
|
form.append('user_id', user_id);
|
|
form.append('reviewcomment', this.reviewcomment);
|
|
form.append('currentSignId', currentSignId);
|
|
form.append('token', token);
|
|
form.append('form_key', form_key);
|
|
axios.post('./api/postPricereviewSign.php', form).then(res=>{
|
|
console.log(res.data);
|
|
if(res.data == 1){
|
|
alert("簽核成功!");
|
|
window.location.reload()
|
|
}
|
|
})
|
|
},
|
|
}
|
|
}
|