Browse Source

回復pricereview Alpine js

main
10994015 1 year ago
parent
commit
8e81a112f0
  1. 296
      wms/mkt/assets/js/pricereviewAlpine.js

296
wms/mkt/assets/js/pricereviewAlpine.js

@ -1,6 +1,6 @@
const pricereviewCreate = () => { const pricereviewCreate = ()=>{
return { return {
init() { init(){
this.elevators = elevators; this.elevators = elevators;
this.is_renovation = is_renovation this.is_renovation = is_renovation
this.selectedOptions = selectedOptions; this.selectedOptions = selectedOptions;
@ -15,21 +15,20 @@ const pricereviewCreate = () => {
9:"CO" 9:"CO"
}, },
optionalArr: { optionalArr: {
1: '標配', 1:'標配',
2: '選配', 2:'選配',
3: '選配', 3:'選配',
}, },
total_spec: total_spec, total_spec: total_spec,
options: options, options: options,
// orioptions: options,
searchtext: '', searchtext: '',
kind: 1, kind: 1,
subkind: 1, subkind: 1,
buttons: [], buttons: [],
modalSelectedOptions: {}, modalSelectedOptions: {},
selectedOptions: [], selectedOptions:[],
elevators: [], elevators: [],
toElevators: [], toElevators:[],
toElevatorNo: '', toElevatorNo: '',
currentOptionKey: '', currentOptionKey: '',
currentOtherOptionKey: '', currentOtherOptionKey: '',
@ -46,23 +45,23 @@ const pricereviewCreate = () => {
speed:'', speed:'',
open:'CO', open:'CO',
num: 1, num: 1,
price: '', price:'',
sale_price: '', sale_price:'',
facility_id: '', facility_id: '',
model:'', model:'',
}, },
otherOptions: [], otherOptions: [],
modalOtherOptionInfo: { modalOtherOptionInfo:{
pr_no: "", pr_no:"",
name: "", name:"",
price: 0, price: 0,
num: "", num:"",
}, },
maintainOptions: [], maintainOptions:[],
modalMaintainInfo: { modalMaintainInfo:{
price: 0, price:0,
num: "", num:"",
memo: "", memo:"",
}, },
demolishOptions: demolishOptions, demolishOptions: demolishOptions,
modalDemolishOptionsInfo:{ modalDemolishOptionsInfo:{
@ -89,8 +88,6 @@ const pricereviewCreate = () => {
uscc: uscc, uscc: uscc,
person: salesman, person: salesman,
}, },
attatch1:"",
attatch2:"",
weightArr: { weightArr: {
6: 450, 6: 450,
8: 550, 8: 550,
@ -105,6 +102,8 @@ const pricereviewCreate = () => {
24:1600, 24:1600,
}, },
is_renovation: is_renovation, is_renovation: is_renovation,
attatch1:"",
attatch2:"",
async getElevatorPrice(idx){ async getElevatorPrice(idx){
const spec = this.elevators[idx].specifications const spec = this.elevators[idx].specifications
const person = this.elevators[idx].person const person = this.elevators[idx].person
@ -124,11 +123,12 @@ const pricereviewCreate = () => {
try{ try{
const res = await axios.get("./api/getElevatorPrice.php", {params: {model: model, kind: spec}}) const res = await axios.get("./api/getElevatorPrice.php", {params: {model: model, kind: spec}})
console.log(res.data); console.log(res.data);
if (res.data == null || res.data == "") { if(res.data.id == null || res.data.id == ""){
console.log("公司並無提供此規格!!"); console.log("公司並無提供此規格!!");
} }
this.elevators[idx].price = res.data this.elevators[idx].price = res.data.price
} catch (error) { this.elevators[idx].facility_id = res.data.id
}catch (error) {
console.error("Error fetching elevator price:", error); console.error("Error fetching elevator price:", error);
} }
@ -143,16 +143,15 @@ const pricereviewCreate = () => {
model = this.modalElevatorInfo.spec + '-' + this.modalElevatorInfo.person + '*' + this.modalElevatorInfo.stop + '-' + this.modalElevatorInfo.open + this.modalElevatorInfo.speed; model = this.modalElevatorInfo.spec + '-' + this.modalElevatorInfo.person + '*' + this.modalElevatorInfo.stop + '-' + this.modalElevatorInfo.open + this.modalElevatorInfo.speed;
this.modalElevatorInfo.model = this.modalElevatorInfo.spec + '-' + this.modalElevatorInfo.person + '*' + this.modalElevatorInfo.stop + '-' + this.modalElevatorInfo.open + this.modalElevatorInfo.speed; this.modalElevatorInfo.model = this.modalElevatorInfo.spec + '-' + this.modalElevatorInfo.person + '*' + this.modalElevatorInfo.stop + '-' + this.modalElevatorInfo.open + this.modalElevatorInfo.speed;
} }
console.log(model);
try{ try{
const res = await axios.get("./api/getElevatorPrice.php", {params: {model: model, kind:kind}}) const res = await axios.get("./api/getElevatorPrice.php", {params: {model: model, kind:kind}})
console.log(res.data); console.log(res.data);
if (res.data == null || res.data == "") { if(res.data.id == null || res.data.id == ""){
console.log("公司並無提供此規格!!"); console.log("公司並無提供此規格!!");
} }
this.modalElevatorInfo.price = res.data.price this.modalElevatorInfo.price = res.data.price
this.modalElevatorInfo.id = res.data.id this.modalElevatorInfo.facility_id = res.data.id
} catch (error) { }catch (error) {
console.error("Error fetching elevator price:", error); console.error("Error fetching elevator price:", error);
} }
}, },
@ -230,65 +229,65 @@ const pricereviewCreate = () => {
} }
}, },
optionSubCategory: 1, optionSubCategory: 1,
initOptinos() { initOptinos(){
this.options.forEach(option => { this.options.forEach(option=>{
option.isShow = 1; option.isShow = 1;
}) })
}, },
searchOptions(kind = this.kind, subkind = this.subkind) { searchOptions(kind=this.kind, subkind=this.subkind){
if (kind != null) this.kind = kind; if(kind!=null) this.kind = kind;
if (subkind != null) this.subkind = subkind; if(subkind!=null) this.subkind = subkind;
this.initOptinos(); this.initOptinos();
this.initButtons(kind); this.initButtons(kind);
this.options.forEach(option => { this.options.forEach(option=>{
if (option.kind != this.kind && this.kind != 1) { if(option.kind != this.kind && this.kind != 1){
option.isShow = 0; option.isShow = 0;
} else { }else{
if (option.subkind != this.subkind && this.subkind != 1) { if(option.subkind != this.subkind && this.subkind != 1){
option.isShow = 0; option.isShow = 0;
} }
} }
if (option.isShow == 1) { if(option.isShow == 1){
if (option.group_name == null) option.group_name = '' if(option.group_name == null) option.group_name = ''
if (option.spec == null) option.spec = '' if(option.spec == null) option.spec = ''
if (option.memo == null) option.memo = '' if(option.memo == null) option.memo = ''
if (option.price == null) option.price = 0 if(option.price == null) option.price = 0
if (option.unit == null) option.unit = '' if(option.unit == null) option.unit = ''
if (String(option.id).includes(this.searchtext) || option.group_name.includes(this.searchtext) || option.memo.toLowerCase().includes(this.searchtext) || option.spec.toLowerCase().includes(this.searchtext) || option.unit.includes(this.searchtext) || String(option.price).includes(this.searchtext)) { if(String(option.id).includes(this.searchtext) || option.group_name.includes(this.searchtext) || option.memo.toLowerCase().includes(this.searchtext) || option.spec.toLowerCase().includes(this.searchtext) || option.unit.includes(this.searchtext) || String(option.price).includes(this.searchtext)){
option.isShow = 1 option.isShow = 1
} else { }else{
option.isShow = 0 option.isShow = 0
} }
} }
}) })
}, },
selectOption(idx, id, name, price, memo) { selectOption(idx, id, name, price, memo){
this.options[idx].selected = this.options[idx].selected == 1 ? 0 : 1; this.options[idx].selected = this.options[idx].selected==1 ? 0 : 1;
if (this.modalSelectedOptions.hasOwnProperty(idx)) { if(this.modalSelectedOptions.hasOwnProperty(idx)){
delete this.modalSelectedOptions[idx]; delete this.modalSelectedOptions[idx];
} else { }else{
//this.optionKey => 已選option 流水號, idx:option表內的流水號, id:option 資料庫的ID //this.optionKey => 已選option 流水號, idx:option表內的流水號, id:option 資料庫的ID
this.modalSelectedOptions[idx] = { key: this.optionKey, 'idx': idx, 'id': id, 'name': name, 'price': price, qty: 1, 'memo': memo, 'toElevator': [] } this.modalSelectedOptions[idx] = {key:this.optionKey, 'idx':idx, 'id': id, 'name': name, 'price': price, qty:1, 'memo': memo, 'toElevator':[] }
} }
this.optionKey++; this.optionKey ++;
}, },
initModalSelectedOptions() { initModalSelectedOptions(){
this.modalSelectedOptions = {} this.modalSelectedOptions = {}
this.options.forEach(option => { this.options.forEach(option=>{
option.selected = 0 option.selected = 0
}) })
this.$refs.optionsModal.style.display = "block" this.$refs.optionsModal.style.display = "block"
body.style.overflow = 'hidden' body.style.overflow = 'hidden'
}, },
chkOptions() { chkOptions(){
Object.keys(this.modalSelectedOptions).forEach(option => { Object.keys(this.modalSelectedOptions).forEach(option=>{
this.selectedOptions.push(this.modalSelectedOptions[option]) this.selectedOptions.push(this.modalSelectedOptions[option])
}) })
console.log(this.selectedOptions); console.log(this.selectedOptions);
this.hideOptionsModal(); this.hideOptionsModal();
}, },
hideOptionsModal() { hideOptionsModal(){
this.$refs.optionsModal.style.display = 'none'; this.$refs.optionsModal.style.display = 'none';
body.style.overflow = 'auto' body.style.overflow = 'auto'
}, },
@ -356,33 +355,33 @@ const pricereviewCreate = () => {
return total + (elevator.spec_num * elevator.price); return total + (elevator.spec_num * elevator.price);
}, 0); }, 0);
}, },
totalElevatorsNum() { totalElevatorsNum(){
return this.elevators.reduce((total, elevator) => { return this.elevators.reduce((total, elevator) => {
return total + Number(elevator.spec_num); return total + Number(elevator.spec_num);
}, 0) }, 0)
}, },
totalElevatorsSalePrice() { totalElevatorsSalePrice(){
return this.elevators.reduce((total, elevator) => { return this.elevators.reduce((total, elevator) => {
return total + (elevator.spec_num * elevator.spec_price); return total + (elevator.spec_num * elevator.spec_price);
}, 0); }, 0);
}, },
totalOptionsPrice() { totalOptionsPrice(){
return this.selectedOptions.reduce((total, option) => { return this.selectedOptions.reduce((total, option) => {
return total + (option.qty * option.price); return total + (option.qty * option.price);
}, 0); }, 0);
}, },
openAddElevatorFn() { openAddElevatorFn(){
}, },
createElevatorFn() { createElevatorFn(){
if (this.modalElevatorInfo.spec == '') return alert("請選擇電梯規格"); if(this.modalElevatorInfo.spec == '') return alert("請選擇電梯規格");
if (this.modalElevatorInfo.stop == '') return alert("請填入停數"); if(this.modalElevatorInfo.stop == '') return alert("請填入停數");
if (this.modalElevatorInfo.speed == '') return alert("請選擇速度"); if(this.modalElevatorInfo.speed == '') return alert("請選擇速度");
if (this.modalElevatorInfo.open == '') return alert("請選擇開梯方式"); if(this.modalElevatorInfo.open == '') return alert("請選擇開梯方式");
if (this.modalElevatorInfo.person == '') return alert("請填入人乘/載重"); if(this.modalElevatorInfo.person == '') return alert("請填入人乘/載重");
if (this.modalElevatorInfo.num == '') return alert("請填入數量"); if(this.modalElevatorInfo.num == '') return alert("請填入數量");
if (this.modalElevatorInfo.sale_price == '') return alert("請填入售價"); if(this.modalElevatorInfo.sale_price == '') return alert("請填入售價");
this.total_spec++; this.total_spec ++;
this.elevators.push({ this.elevators.push({
id: this.total_spec, id: this.total_spec,
specifications: this.modalElevatorInfo.spec, specifications: this.modalElevatorInfo.spec,
@ -392,7 +391,7 @@ const pricereviewCreate = () => {
open_converted: this.modalElevatorInfo.open, open_converted: this.modalElevatorInfo.open,
spec_price: this.modalElevatorInfo.sale_price, spec_price: this.modalElevatorInfo.sale_price,
price: this.modalElevatorInfo.price, price: this.modalElevatorInfo.price,
open: '', open:'',
spec_num: this.modalElevatorInfo.num, spec_num: this.modalElevatorInfo.num,
facility_id: this.modalElevatorInfo.facility_id, facility_id: this.modalElevatorInfo.facility_id,
model: this.modalElevatorInfo.model, model: this.modalElevatorInfo.model,
@ -400,7 +399,7 @@ const pricereviewCreate = () => {
console.log(this.elevators); console.log(this.elevators);
this.hideCreateElevatorModal(); this.hideCreateElevatorModal();
}, },
copyElevator(idx) { copyElevator(idx){
const spec = this.elevators[idx].specifications const spec = this.elevators[idx].specifications
const person = this.elevators[idx].person const person = this.elevators[idx].person
const stop = this.elevators[idx].stop const stop = this.elevators[idx].stop
@ -413,7 +412,7 @@ const pricereviewCreate = () => {
const facility_id = this.elevators[idx].facility_id const facility_id = this.elevators[idx].facility_id
const model = this.elevators[idx].model const model = this.elevators[idx].model
this.total_spec++; this.total_spec ++;
this.elevators.push({ this.elevators.push({
id: this.total_spec, id: this.total_spec,
specifications: spec, specifications: spec,
@ -486,11 +485,11 @@ const pricereviewCreate = () => {
this.$refs.toElevatorModal.style.display = 'block'; this.$refs.toElevatorModal.style.display = 'block';
body.style.overflow = 'hidden' body.style.overflow = 'hidden'
}, },
addOtherOptionToElevator(id) { addOtherOptionToElevator(id){
this.currentOtherOptionKey = id; this.currentOtherOptionKey = id;
this.toElevators = []; this.toElevators = [];
this.toElevatorNo = ""; this.toElevatorNo = "";
const matchElevators = this.otherOptions.filter(option => option.id == id)[0].toElevator.map(elevator => elevator.id) const matchElevators = this.otherOptions.filter(option=> option.id == id)[0].toElevator.map(elevator=> elevator.id)
this.toElevatorNo = matchElevators[0] this.toElevatorNo = matchElevators[0]
this.elevators.forEach(elevator=>{ this.elevators.forEach(elevator=>{
if(elevator.price > 0){ if(elevator.price > 0){
@ -512,7 +511,7 @@ const pricereviewCreate = () => {
this.$refs.toOtherOptionElevatorModal.style.display = 'block'; this.$refs.toOtherOptionElevatorModal.style.display = 'block';
body.style.overflow = 'hidden' body.style.overflow = 'hidden'
}, },
chkOptionToElevators() { chkOptionToElevators(){
const checkedOptions = []; const checkedOptions = [];
const matchElevators = this.elevators.filter(elevator=> elevator.id == this.toElevatorNo)[0] const matchElevators = this.elevators.filter(elevator=> elevator.id == this.toElevatorNo)[0]
@ -520,8 +519,8 @@ const pricereviewCreate = () => {
id: this.toElevatorNo, id: this.toElevatorNo,
model: matchElevators['model'] , model: matchElevators['model'] ,
}) })
this.selectedOptions.forEach(option => { this.selectedOptions.forEach(option=>{
if (option.key == this.currentOptionKey) { if(option.key == this.currentOptionKey){
option.toElevator = []; option.toElevator = [];
option.toElevator.push(...checkedOptions) option.toElevator.push(...checkedOptions)
} }
@ -529,7 +528,7 @@ const pricereviewCreate = () => {
this.currentOptionKey = '' this.currentOptionKey = ''
this.hideToElevatorModal(); this.hideToElevatorModal();
}, },
chkOtherOptionToElevators() { chkOtherOptionToElevators(){
const checkedOptions = []; const checkedOptions = [];
const matchElevators = this.elevators.filter(elevator=> elevator.id == this.toElevatorNo)[0] const matchElevators = this.elevators.filter(elevator=> elevator.id == this.toElevatorNo)[0]
@ -537,8 +536,8 @@ const pricereviewCreate = () => {
id: this.toElevatorNo, id: this.toElevatorNo,
model: matchElevators['model'], model: matchElevators['model'],
}) })
this.otherOptions.forEach(option => { this.otherOptions.forEach(option=>{
if (option.id == this.currentOtherOptionKey) { if(option.id == this.currentOtherOptionKey){
option.toElevator = []; option.toElevator = [];
option.toElevator.push(...checkedOptions) option.toElevator.push(...checkedOptions)
} }
@ -548,36 +547,36 @@ const pricereviewCreate = () => {
this.hideToOtherOptionElevatorModal(); this.hideToOtherOptionElevatorModal();
}, },
removeElevator(id) { removeElevator(id){
if (!confirm("確定刪除嗎?")) return; if(!confirm("確定刪除嗎?")) return;
this.elevators = this.elevators.filter(elevator => elevator.id != id) this.elevators = this.elevators.filter(elevator=> elevator.id != id)
const issetElevators = []; const issetElevators = [];
this.elevators.forEach(elevator => { this.elevators.forEach(elevator=>{
issetElevators.push(elevator.id); issetElevators.push(elevator.id);
}) })
this.selectedOptions.forEach(option => { this.selectedOptions.forEach(option=>{
option.toElevator = option.toElevator.filter(el => { option.toElevator = option.toElevator.filter(el=>{
return issetElevators.includes(el.id) return issetElevators.includes(el.id)
}) })
}) })
console.log(this.selectedOptions); console.log(this.selectedOptions);
}, },
removeOption(key) { removeOption(key){
console.log(this.selectedOptions); console.log(this.selectedOptions);
this.selectedOptions = this.selectedOptions.filter(option => option.key != key) this.selectedOptions = this.selectedOptions.filter(option=> option.key != key)
}, },
removeOtherOption(id) { removeOtherOption(id){
this.otherOptions = this.otherOptions.filter(option => option.id != id) this.otherOptions = this.otherOptions.filter(option=> option.id != id)
}, },
createOtherOptionFn() { createOtherOptionFn(){
this.otherOptions.push({ this.otherOptions.push({
id: this.otherOptionKey, id: this.otherOptionKey,
pr_no: this.modalOtherOptionInfo.pr_no, pr_no: this.modalOtherOptionInfo.pr_no,
name: this.modalOtherOptionInfo.name, name: this.modalOtherOptionInfo.name,
price: this.modalOtherOptionInfo.price, price: this.modalOtherOptionInfo.price,
num: this.modalOtherOptionInfo.num, num: this.modalOtherOptionInfo.num,
toElevator: [], toElevator:[],
}) })
this.modalOtherOptionInfo = { this.modalOtherOptionInfo = {
pr_no: '', pr_no: '',
@ -585,35 +584,34 @@ const pricereviewCreate = () => {
price: 0, price: 0,
num: '', num: '',
} }
this.otherOptionKey++; this.otherOptionKey ++;
console.log(this.otherOptions); this.hideCreateOtherOptionModal();
this.$refs.closeCreateOtherOptionModalBtn.click();
}, },
totalOtherOptionsPrice() { totalOtherOptionsPrice(){
return this.otherOptions.reduce((total, option) => { return this.otherOptions.reduce((total, option) => {
return total + (Number(option.num) * Number(option.price)); return total + (Number(option.num) * Number(option.price));
}, 0); }, 0);
}, },
totalOtherOptionsNum() { totalOtherOptionsNum(){
return this.otherOptions.reduce((total, option) => { return this.otherOptions.reduce((total, option) => {
return total + Number(option.num); return total + Number(option.num);
}, 0); }, 0);
}, },
createMaintainOptionFn() { createMaintainOptionFn(){
this.maintainOptions.push({ this.maintainOptions.push({
id: this.maintainOptionKey, id: this.maintainOptionKey,
price: this.modalMaintainInfo.price, price: this.modalMaintainInfo.price,
num: this.modalMaintainInfo.num, num: this.modalMaintainInfo.num,
memo: this.modalMaintainInfo.memo, memo: this.modalMaintainInfo.memo,
toElevator: [], toElevator:[],
}) })
this.modalMaintainInfo = { this.modalMaintainInfo = {
price: 0, price:0,
num: "", num:"",
memo: "", memo:"",
} }
this.maintainOptionKey++; this.maintainOptionKey ++;
this.$refs.closeCreateMaintainOptionModalBtn.click(); this.hideCreateMaintainModal();
}, },
createDemolishOptionFn(){ createDemolishOptionFn(){
this.demolishOptions.push({ this.demolishOptions.push({
@ -639,7 +637,7 @@ const pricereviewCreate = () => {
return total + (Number(option.num) * Number(option.price)); return total + (Number(option.num) * Number(option.price));
}, 0); }, 0);
}, },
totalMaintainOptionsNum() { totalMaintainOptionsNum(){
return this.maintainOptions.reduce((total, option) => { return this.maintainOptions.reduce((total, option) => {
return total + Number(option.num); return total + Number(option.num);
}, 0); }, 0);
@ -662,8 +660,8 @@ const pricereviewCreate = () => {
id: this.toElevatorNo, id: this.toElevatorNo,
model: matchElevators['model'], model: matchElevators['model'],
}) })
this.maintainOptions.forEach(option => { this.maintainOptions.forEach(option=>{
if (option.id == this.currentMaintainOptionKey) { if(option.id == this.currentMaintainOptionKey){
option.toElevator = []; option.toElevator = [];
option.toElevator.push(...checkedOptions) option.toElevator.push(...checkedOptions)
} }
@ -691,7 +689,7 @@ const pricereviewCreate = () => {
this.currentMaintainOptionKey = id; this.currentMaintainOptionKey = id;
this.toElevators = []; this.toElevators = [];
this.toElevatorNo = ""; this.toElevatorNo = "";
const matchElevators = this.maintainOptions.filter(option => option.id == id)[0].toElevator.map(elevator => elevator.id) const matchElevators = this.maintainOptions.filter(option=> option.id == id)[0].toElevator.map(elevator=> elevator.id)
this.toElevatorNo = matchElevators[0] this.toElevatorNo = matchElevators[0]
this.elevators.forEach(elevator=>{ this.elevators.forEach(elevator=>{
if(elevator.price > 0){ if(elevator.price > 0){
@ -748,19 +746,19 @@ const pricereviewCreate = () => {
totalPrice(){ totalPrice(){
return this.totalElevatorsPrice() + this.totalOptionsPrice() + this.totalOtherOptionsPrice() + this.totalMaintainOptionsPrice(); return this.totalElevatorsPrice() + this.totalOptionsPrice() + this.totalOtherOptionsPrice() + this.totalMaintainOptionsPrice();
}, },
totalSalePrice() { totalSalePrice(){
return this.elevators.reduce((total, elevator) => { return this.elevators.reduce((total, elevator) => {
return total + (elevator.spec_num * elevator.spec_price); return total + (elevator.spec_num * elevator.spec_price);
}, 0); }, 0);
}, },
scalePrice(scale) { scalePrice(scale){
if (scale === '') return 0; if(scale === '') return 0;
return this.totalSalePrice() * scale / 100; return this.totalSalePrice() * scale / 100;
}, },
totalScale() { totalScale(){
let total = 0; let total = 0;
Object.keys(this.paymentRatio).forEach(pay => { Object.keys(this.paymentRatio).forEach(pay=>{
if (this.paymentRatio[pay].scale != '' && this.paymentRatio[pay].scale > 0) { if(this.paymentRatio[pay].scale != '' && this.paymentRatio[pay].scale > 0){
total += Number(this.paymentRatio[pay].scale) total += Number(this.paymentRatio[pay].scale)
} }
}) })
@ -806,12 +804,12 @@ const pricereviewCreate = () => {
errortext += err+'\n'; errortext += err+'\n';
}) })
alert(errortext) alert(errortext)
return; return false;
} }
}, },
submit(){ submit(){
this.validation(); const validation = this.validation();
if(!validation) return
const form = new FormData(); const form = new FormData();
form.append('contractno', contractno); form.append('contractno', contractno);
form.append('ekind', (is_renovation=="Y") ? "汰改" : "新梯"); form.append('ekind', (is_renovation=="Y") ? "汰改" : "新梯");
@ -821,7 +819,7 @@ const pricereviewCreate = () => {
form.append('address', this.customerInfo.address); form.append('address', this.customerInfo.address);
form.append('price_lowest', this.totalPrice()); form.append('price_lowest', this.totalPrice());
form.append('price_total', this.totalSalePrice()); form.append('price_total', this.totalSalePrice());
form.append('price_rate', Math.round(this.totalSalePrice() / this.totalPrice() * 100 * 10) / 10); form.append('price_rate', Math.round(this.totalSalePrice() / this.totalPrice() * 100 *10) / 10);
form.append('special_fee', this.serviceFee); form.append('special_fee', this.serviceFee);
form.append('predeal_date', this.transactionDate); form.append('predeal_date', this.transactionDate);
form.append('facilitok_date', this.shippingDate); form.append('facilitok_date', this.shippingDate);
@ -844,20 +842,19 @@ const pricereviewCreate = () => {
form.append('paymentRatio', JSON.stringify(this.paymentRatio)); form.append('paymentRatio', JSON.stringify(this.paymentRatio));
axios.post('./api/postNewElevatorPricereview.php', form).then(res => { axios.post('./api/postNewElevatorPricereview.php', form).then(res=>{
console.log(res.data); console.log(res.data);
if (res.data == "success") { if(res.data == "success"){
alert("送審成功!"); alert("送審成功!");
window.location.href = './pricereview-index.php?' + token_link; window.location.href = './pricereview-index.php?' + token_link;
} }
}).catch(err => { }).catch(err=>{
console.error(err); console.error(err);
}) })
}, },
save(){ save(){
console.log(this.attatch1); const validation = this.validation();
return; if(!validation) return
this.validation();
const form = new FormData(); const form = new FormData();
form.append('contractno', contractno); form.append('contractno', contractno);
form.append('ekind', (is_renovation=="Y") ? "汰改" : "新梯"); form.append('ekind', (is_renovation=="Y") ? "汰改" : "新梯");
@ -903,7 +900,9 @@ const pricereviewCreate = () => {
}, },
} }
} }
const pricereviewCheck = () => {
const pricereviewCheck = ()=>{
return { return {
init(){ init(){
this.elevators = elevators this.elevators = elevators
@ -927,8 +926,8 @@ const pricereviewCheck = () => {
if(option.option_relate_spec == elevator.item_no){ if(option.option_relate_spec == elevator.item_no){
elevator.optionsTotalPrice += option.option_mi * option.item_qty elevator.optionsTotalPrice += option.option_mi * option.item_qty
this.elevators[idx].options.push({ this.elevators[idx].options.push({
'id': option.id, 'id': option.id, //<br>()
'item_spec': option.item_spec.trim(), 'item_spec': option.item_spec.trim().replaceAll('&', '').replaceAll('lt;', '').replaceAll('br', '').replaceAll('gt;', '').replaceAll('()', ''),
'item_unit_price': option.item_unit_price, 'item_unit_price': option.item_unit_price,
'item_qty': option.item_qty, 'item_qty': option.item_qty,
'mi': Math.round(option.option_mi), 'mi': Math.round(option.option_mi),
@ -937,8 +936,8 @@ const pricereviewCheck = () => {
} }
}) })
this.otherOptions.forEach(option => { this.otherOptions.forEach(option=>{
if (option.option_relate_spec == elevator.item_no) { if(option.option_relate_spec == elevator.item_no){
elevator.otherOptionsTotalPrice += option.item_unit_price * option.item_qty elevator.otherOptionsTotalPrice += option.item_unit_price * option.item_qty
this.elevators[idx].otherOptions.push({ this.elevators[idx].otherOptions.push({
'id': option.id, 'id': option.id,
@ -950,8 +949,8 @@ const pricereviewCheck = () => {
} }
}) })
this.maintainOptions.forEach(option => { this.maintainOptions.forEach(option=>{
if (option.option_relate_spec == elevator.item_no) { if(option.option_relate_spec == elevator.item_no){
elevator.maintainOptionsTotalPrice += option.item_unit_price * option.item_qty elevator.maintainOptionsTotalPrice += option.item_unit_price * option.item_qty
this.elevators[idx].maintainOptions.push({ this.elevators[idx].maintainOptions.push({
'id': option.id, 'id': option.id,
@ -983,8 +982,8 @@ const pricereviewCheck = () => {
let stop = model.split('-')[1].split('*')[1].split('-')[0]; let stop = model.split('-')[1].split('*')[1].split('-')[0];
let open = model.split('-')[2]; let open = model.split('-')[2];
let speed = ''; let speed = '';
for (let i = 0; i < this.openFn.length; i++) { for(let i=0;i<this.openFn.length;i++){
if (open.includes(this.openFn[i])) { if(open.includes(this.openFn[i])){
speed = open.replace(this.openFn[i], '') speed = open.replace(this.openFn[i], '')
open = this.openFn[i]; open = this.openFn[i];
break; break;
@ -1033,18 +1032,18 @@ const pricereviewCheck = () => {
console.log(this.elevators[idx]); console.log(this.elevators[idx]);
} catch (error) { }catch (error) {
console.error("Error fetching elevator price:", error); console.error("Error fetching elevator price:", error);
} }
}, },
isNotfoundMi: false, isNotfoundMi:false,
openFn: [ openFn:[
'CO', '2S', '2U', '4PCO', '6PCO' 'CO', '2S', '2U', '4PCO', '6PCO'
], ],
sign1: '', sign1:'',
sign2: '', sign2:'',
sign3: '', sign3:'',
sign4: '', sign4:'',
is_renovate: false, is_renovate: false,
elevators_total_price: 0, elevators_total_price: 0,
contractno: contractno, contractno: contractno,
@ -1064,24 +1063,25 @@ const pricereviewCheck = () => {
memo: memo, memo: memo,
qty: 0, qty: 0,
pays: pays, pays: pays,
elevators: [], elevators:[],
options: [], options: [],
otherOptions: [], otherOptions: [],
maintainOptions: [], maintainOptions: [],
demolishOptions:[], demolishOptions:[],
mid: mid, mid: mid,
user_id: user_id, user_id: user_id,
optionsTotalPrice() { reviewcomment:'',
optionsTotalPrice(){
return this.options.reduce((total, option) => { return this.options.reduce((total, option) => {
return total + (option.item_qty * option.item_unit_price); return total + (option.item_qty * option.item_unit_price);
}, 0); }, 0);
}, },
otherOptionsTotalPrice() { otherOptionsTotalPrice(){
return this.otherOptions.reduce((total, option) => { return this.otherOptions.reduce((total, option) => {
return total + (option.item_qty * option.item_unit_price); return total + (option.item_qty * option.item_unit_price);
}, 0); }, 0);
}, },
maintainOptionsTotalPrice() { maintainOptionsTotalPrice(){
return this.maintainOptions.reduce((total, option) => { return this.maintainOptions.reduce((total, option) => {
return total + (option.item_qty * option.item_unit_price); return total + (option.item_qty * option.item_unit_price);
}, 0); }, 0);
@ -1093,7 +1093,7 @@ const pricereviewCheck = () => {
}, },
totalScale(){ totalScale(){
return this.pays.reduce((total, option) => { return this.pays.reduce((total, option) => {
return total + Number(option.pay_scale); return total + Number(option.pay_scale );
}, 0); }, 0);
}, },
totalElevatorsPrice(){ totalElevatorsPrice(){
@ -1111,9 +1111,10 @@ const pricereviewCheck = () => {
form.append('mid', this.mid); form.append('mid', this.mid);
form.append('result', status); form.append('result', status);
form.append('user_id', this.user_id); form.append('user_id', this.user_id);
axios.post('./api/postPricereviewSign.php', form).then(res => { form.append('reviewcomment', this.reviewcomment);
axios.post('./api/postPricereviewSign.php', form).then(res=>{
console.log(res.data); console.log(res.data);
if (res.data == 1) { if(res.data == 1){
alert("簽核成功!"); alert("簽核成功!");
window.location.reload() window.location.reload()
} }
@ -1125,6 +1126,5 @@ const pricereviewCheck = () => {
const res = await axios.get('./api/getUsername.php', {params: {user_id: user_id}}) const res = await axios.get('./api/getUsername.php', {params: {user_id: user_id}})
return res.data ; return res.data ;
}, },
} }
} }
Loading…
Cancel
Save