Browse Source

回復pricereview Alpine js

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

40
wms/mkt/assets/js/pricereviewAlpine.js

@ -21,7 +21,6 @@ const pricereviewCreate = () => {
}, },
total_spec: total_spec, total_spec: total_spec,
options: options, options: options,
// orioptions: options,
searchtext: '', searchtext: '',
kind: 1, kind: 1,
subkind: 1, subkind: 1,
@ -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,10 +123,11 @@ 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
this.elevators[idx].facility_id = res.data.id
}catch (error) { }catch (error) {
console.error("Error fetching elevator price:", error); console.error("Error fetching elevator price:", error);
} }
@ -143,15 +143,14 @@ 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);
} }
@ -586,8 +585,7 @@ const pricereviewCreate = () => {
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) => {
@ -613,7 +611,7 @@ const pricereviewCreate = () => {
memo:"", memo:"",
} }
this.maintainOptionKey ++; this.maintainOptionKey ++;
this.$refs.closeCreateMaintainOptionModalBtn.click(); this.hideCreateMaintainModal();
}, },
createDemolishOptionFn(){ createDemolishOptionFn(){
this.demolishOptions.push({ this.demolishOptions.push({
@ -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") ? "汰改" : "新梯");
@ -855,9 +853,8 @@ const pricereviewCreate = () => {
}) })
}, },
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,6 +900,8 @@ const pricereviewCreate = () => {
}, },
} }
} }
const pricereviewCheck = ()=>{ const pricereviewCheck = ()=>{
return { return {
init(){ init(){
@ -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),
@ -1071,6 +1070,7 @@ const pricereviewCheck = () => {
demolishOptions:[], demolishOptions:[],
mid: mid, mid: mid,
user_id: user_id, user_id: user_id,
reviewcomment:'',
optionsTotalPrice(){ 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);
@ -1111,6 +1111,7 @@ 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);
form.append('reviewcomment', this.reviewcomment);
axios.post('./api/postPricereviewSign.php', form).then(res=>{ axios.post('./api/postPricereviewSign.php', form).then(res=>{
console.log(res.data); console.log(res.data);
if(res.data == 1){ if(res.data == 1){
@ -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