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.
 
 
 
 
 
 

875 lines
34 KiB

const contractDownload = () => {
return {
init() {
this.standarDate = this.deepClone(this.data);
this.onstandarViewData = this.deepClone(this.data);
this.buystandarData = this.deepClone(this.buydata);
this.buyonstandardViewData = this.deepClone(this.buydata);
},
buyfill1: buyfill1,
css: `table { background - color: #fff; border: none; margin - top: 30px; font - family: '標楷體'; width: 600px; } table tr: nth - child(even), table tr: nth - child(odd) { background - color: #fff; } table tr { font - size: 12pt; width: 100 %; } table tr h2 { font - size: 18pt; } table tr td { width: 100 %; height: 100 %; line - height: 2; display: flex; } table tr td.center { display: flex; justify - content: center; align - items: center; } table tr td.list { width: 100 %; height: 100 %; white - space: nowrap; display: flex; } table tr td.list span { width: 60px; min - height: 100 %; display: block; } table tr td.list > p { display: block; text - align: justify; } table tr td.list div { max - width: calc(100 % - 60px); white - space: normal; } table tr td.list div.text - justify { display: flex; width: 100 %; justify - content: space - between; } table tr.date td > div { width: 100 %; text - align: right; } table tr.date td > div.text - justify { display: flex; justify - content: space - between; } table td, table th { padding: 8px; }`,
data: {
illustrate: {
editshow: false,
plaintext: '茲因甲乙雙方就電梯設備保養.檢修事宜,同意訂定本契約,議定條款如后,並相互遵守條款約定。',
},
partyA: {
editshow: false,
plaintext: partyAcompany,
},
partyAcontractno: {
editshow: false,
plaintext: partyAcontractno,
},
list: {
plaintext: [
{
editshow: false,
origin: true,
text: ``,
deleted: false,
id: 0,
input_id: null
},
{
editshow: false,
origin: true,
text: `規格`,
type: 'title',
deleted: false,
id: 1,
input_id: null
},
{
editshow: false
}
]
}
},
deepClone: function (obj) {
let clone = Array.isArray(obj) ? [] : {};
for (let key in obj) {
if (obj.hasOwnProperty(key)) {
if (typeof obj[key] === 'object' && obj[key] !== null) {
clone[key] = this.deepClone(obj[key]);
if (clone[key].text != undefined) {
} else {
clone[key] = obj[key];
}
}
}
}
return clone;
},
buydata: {
},
exportFn(type) {
const form = this.$refs.form;
const prviewType = this.$refs.form.querySelector('#prview-type');
const list = this.$refs.form.querySelector('#privew-list');
const standardList = this.$refs.form.querySelector('#standard-prview-list');
const illustrate = this.$refs.form.querySelector('illustrate');
const standardIllustrate = this.$refs.form.querySelector('#standard-illustrate');
const partyA = this.$refs.form.querySelector('#partyA');
const partyAcontractno = this.$refs.form.querySelector('#partyAcontractno');
const total_price = this.$refs.form.querySelector('#total_price');
prviewType.value = type;
if (type === 1) {
const standarJsonText = this.buystandarDate.list.plaintext.map((item, idx) => {
let text = '';
text = item.text.replace(/\s+/g, "");
this.buydata.list.plaintext[idx].text = this.buydata.list.plaintext[idx].text.replace(/\s+/g, "");
return {
text: text,
id: item.id
}
});
const jsonText = this.buydata.list.plaintext.map(item => {
let text = '';
text = item.text;
return {
text: text,
origin: item.origin ? 1 : 0,
deleted: item.deleted ? 1 : 0,
id: item.id,
updated: item.updated ? 1 : 0
}
});
list.value = JSON.stringify(jsonText);
standardList.value = JSON.stringify(standarJsonText);
illustrate.value = this.buydata.illustrate.plaintext;
standardIllustrate.value = this.buyonstandardViewData.illustrate.plaintext;
partyA.value = this.buydata.partyA.plaintext;
partyAcontractno.value = this.buydata.partyAcontractno.plaintext;
total_price.value = totalBuyPrice;
form.submit();
return;
}
if (type === 2) {
const standardJsonText = this.standarData.list.plaintext.map((item, idx) => {
let text = '';
text = item.text.replace(/\s+/g, "");
if (this.data.list.plaintext[idx] !== undefined) {
this.data.list.plaintext[idx].text = this.data.list.plaintext[idx].text.replace(/\s+/g, "");
}
return {
text: text,
id: item.id
}
})
const jsonText = this.data.list.plaintext.map(item => {
let text = '';
item.text;
text = item.text;
return {
text: text,
origin: item.origin ? 1 : 0,
deleted: item.deleted ? 1 : 0,
id: item.id,
updated: item.updated ? 1 : 0
}
})
list.value = JSON.stringify(jsonText);
standardList.value = JSON.stringify(standarJsonText);
illustrate.value = this.data.illustrate.plaintext;
standardIllustrate.value = this.standardData.illustrate.plaintext;
partyA.value = this.data.partyA.plaintext;
partyAcontractno.value = this.data.partyAcontractno.plaintext;
total_price.value = totalInstallPrice;
form.submit();
return;
}
},
isBuyShow: true,
sendBuyInputFn() {
if (this.buyfilt1 == '') {
alert('請輸入交貨期限');
return;
}
if (this.buyfilt1 < 1) {
alert('交貨日期不得低於1日');
return;
}
if (buyArr[1].installment == 2) {
}
},
isBuyInputIng: true,
}
};
const contractNewInput = () => {
return {
init() { },
data: {
contractno: '',
customer: '',
manager: '',
vat: '',
case_name: '',
linkman: '',
lm_tel: '',
address: '',
salesman: '',
qc: '',
qc: '',
// files:[],
},
step: 1,
isLoading: false,
customize: false,
nextStepFn() {
if (this.data.contractno == '') return alert('合約號為必填')
this.isLoading = true
if (this.step == 1) {
this.getContractDate();
}
},
nextStepKeyupFn(e) {
if (e.keyCode != 13) return
if (this.step == 1) {
this.getContractDate();
console.log(this.step);
}
},
preStepFn() {
if (this.step == 2) {
this.step = 1
}
},
getContractDate() {
axios.get('./api/getContractData.php?contracttype=m&contractno=' + this.data.contractno).then(res => {
if (!res.data) {
this.step = 2
this.isLoading = false
return
}
if (!this.customize) {
console.log(res.data);
this.data.customer = res.data.customer
this.data.manager = res.data.manager
this.data.vat = res.data.uscc
this.data.case_name = res.data.case_name
this.data.linkman = res.data.linkman
this.data.lm_tel = res.data.lm_tel
this.data.address = res.data.address
this.data.salesman = res.data.salesman
this.data.qc = res.data.qc
}
this.step = 2
this.isLoading = false
}).catch(err => {
console.error(err)
this.isLoading = false
})
},
save() {
this.isLoading = true
const form = new FormData();
form.append('contractno', this.data.contractno);
form.append('customer', this.data.customer);
form.append('manager', this.data.manager);
form.append('vat', this.data.vat);
form.append('case_name', this.data.case_name);
form.append('linkman', this.data.linkman);
form.append('lm_tel', this.data.lm_tel);
form.append('address', this.data.address);
form.append('salesman', this.data.salesman);
form.append('qc', this.data.qc);
form.append('contracttype', 'm');
form.append('user_id', user_id);
for (var i = 0; i < this.data.files.length; i++) {
form.append('files[]', this.data.files[i]);
}
axios.post('./api/postNewContractData.php', form).then(res => {
console.log(res);
if (res.status === 201) {
alert('儲存成功');
this.step = 1
this.data.contractno = ''
this.data.customer = ''
this.data.manager = ''
this.data.vat = ''
this.data.case_name = ''
this.data.linkman = ''
this.data.lm_tel = ''
this.data.address = ''
this.data.salesman = ''
this.data.qc = ''
this.data.files = []
this.customize = false
} else {
alert('儲存失敗!可能為以下錯誤:\n' + res.data)
}
this.isLoading = false
}).catch(error => {
let code = error.response.status;
if (code == 422) {
this.fail_arr = error.response.data
this.errorFn();
}
if (code == 500) {
alert('儲存失敗!可能為以下錯誤:\n' + error.response.data)
}
this.isLoading = false
})
},
errorFn() {
let msg = ''
for (let i = 0; i < this.fail_arr.length; i++) {
msg += this.fail_arr[i] + '、'
}
alert(msg)
},
uploadFiles(e) {
this.data.files = e.target.files
},
}
};
//////////////////////////////
//// 合約簽回(修理)
////
//// 製作人:梓誠
/// 時間 :
//////////////////////////////
const contractRepair = () => {
return {
init() { },
data: {
contractno: '',
company: '',
repairer: '',
repaireid: '',
facilityno: '',
taxid: '',
invoice: '', //發票抬頭
type: '', //工程類別需新增,用 post
address: '',
repair_no: '',
total_price: '',
sign_date: '',
contract_status: ''
},
step: 1,
isLoading: false,
customize: false,
nextStepFn() {
if (this.data.repair_no == '') return alert('合約號為必填')
this.isLoading = true
if (this.step == 1) {
this.getContractDate();
}
},
nextStepKeyupFn(e) {
if (e.keyCode != 13) return
if (this.step == 1) {
this.getContractDate();
console.log(this.step);
}
},
// 抓資料
getContractDate() {
axios.get('./api/getContractData.php?contracttype=r&repair_no=' + this.data.repair_no).then(res => {
if (!res.data) {
this.step = 2;
this.isLoading = false;
// console.log(123);
return
}
if (!this.customize) {
// console.log(res.data);
this.data.contractno = res.data.contractno;
this.data.company = res.data.company;
this.data.repairer = res.data.name;
this.data.facilityno = res.data.facilityno;
this.data.taxid = res.data.taxid;
this.data.invoice = res.data.invoice;
this.data.address = res.data.address;
this.data.repair_no = res.data.repair_no;
this.data.total_price = res.data.total_price;
this.data.repaireid = res.data.repairerid;
this.data.sign_date = res.data.sign_date;
this.data.contract_status = res.data.contract_status;
}
this.step = 2;
this.isLoading = false;
// console.log(user_name);
// console.log(this.data.sign_date);
}).catch(err => {
console.log(err);
alert(err.response.data);
this.isLoading = false
})
},
preStepFn() {
if (this.step == 2) {
if (confirm('回到上一頁會初始化資料,確定要返回嗎?')) {
this.step = 1;
this.data.contractno = '';
this.data.company = '';
this.data.repairer = '';
this.data.facilityno = '';
this.data.taxid = '';
this.data.invoice = '';
this.data.address = '';
this.data.repair_no = '';
this.data.total_price = '';
this.data.repaireid = '';
this.data.sign_date = '';
this.data.contract_status = '';
return;
}
}
},
save() {
this.isLoading = true;
const form = new FormData();
form.append('contractno', this.data.contractno);
form.append('company', this.data.company);
form.append('repairid', this.data.repaireid);
form.append('facilityno', this.data.facilityno);
form.append('taxid', this.data.taxid);
form.append('invoice', this.data.invoice);
form.append('address', this.data.address);
form.append('repair_no', this.data.repair_no);
form.append('total_price', this.data.total_price);
form.append('sign_date', this.data.sign_date);
form.append('contract_status', this.data.contract_status);
form.append('contracttype', 'r');
form.append('user_id', user_id);
form.append('type', this.data.type);
axios.post('./api/postContractData.php', form).then(res => {
console.log(res.status);
if (res.status === 200) {
alert('儲存成功');
this.step = 1;
this.data.contractno = '';
this.data.company = '';
this.data.repaireid = '';
this.data.facilityno = '';
this.data.repairer = '';
this.data.taxid = '';
this.data.invoice = '';
this.data.address = '';
this.data.repair_no = '';
this.data.total_price = '';
this.data.user_id = '';
this.data.type = '';
this.data.sign_date = '';
this.data.contract_status = '';
}
this.isLoading = false;
}).catch(error => {
let code = error.response.status;
if (code == 422) {
this.fail_arr = error.response.data;
this.errorFn();
console.log(error.response.data);
}
if (code == 500) {
alert('儲存失敗!可能為以下錯誤:\n' + error.response.data);
}
this.isLoading = false;
})
},
errorFn() {
let msg = '';
for (let i = 0; i < this.fail_arr.length; i++) {
msg += this.fail_arr[i] + '、';
}
alert(msg);
},
uploadFiles(e) {
this.data.files = e.target.files;
}
}
};
const contractInput = () => {
return {
init() {
$('.contract-input-component .form .dropdown').dropdown();
axios.get('./twzip.json').then(res => {
this.cities = res.data.cities
})
},
cities: [],
data: {
contractno: 'B23100060',
total_price: '', //合約總價
vat: '', //統一編號
mtype: 'A', //維修型態
phone: '', //客戶電話
email: '', //Email
mworker: '', //保養員
mcycle: '', //保養頻率
salesman: '', //營業員
contract_begin_date: '', //合約開始時間
contract_end_date: '', //合約終止時間
area: '', //區域
zip: '', //郵遞區號
address: '', //地址
customer: '', //立約人
partyA: '', //業務聯繫人
partyAaddress: '', //業務聯繫人地址
partyAphone: '', //業務聯繫人電話
partyAemail: '', //業務聯繫人email
files: [], //附件檔案
num: '', //電梯數量
disabled: false, //資料庫是否有電梯數量資料
elevators: [], //機種、載重、人乘、樓停、樓層、速度、緯度、經度、開門方式、保養別、廠牌、竣檢日、許可證日期
},
customize: false,
step: 1,
isLoading: false,
fail_arr: [],
nextStepFn() {
if (this.step == 1) {
if (this.data.contractno == '') return alert('請輸入合約號');
this.isLoading = true
this.getContractDate();
} else if (this.step == 2) {
if (this.data.num <= 0) return alert('請填寫電梯數量!')
if (!this.data.disabled) {
this.createElevator();
}
this.step = 3
}
},
nextStepKeyupFn(e) {
if (e.keyCode !== 13) return
if (this.step == 1) {
if (this.data.repair_no == '') return alert('請輸入合約號');
this.isLoading = true
this.getContractDate();
} else if (this.step == 2) {
this.step = 3
}
},
createElevator() {
for (let i = 0; i < this.data.num; i++) {
this.data.elevators.push({
spec: '', //規格
weight: '', //載重
speed: '', //速度
persons: '', //人乘
stop: '', //樓停
floors: '', //樓層
latitude: '', //緯度
longitude: '', //經度
elevator_brand: '', //廠牌
opendoor: '', //開門方式
maintainance: '', //保養別
takecertificatedate: '', //竣檢日
useful_date: '', //許可證有效日期
})
}
},
getContractDate() {
axios.get('./api/getContractData.php?contracttype=b&contractno=' + this.data.contractno).then(res => {
if (!res.data) {
this.step = 2
this.isLoading = false
return
}
if (!this.customize) {
console.log(res.data);
this.data.total_price = res.data.sold_price
this.data.salesman = res.data.salesman
this.data.contract_begin_date = res.data.contract_begin_date
this.data.contract_end_date = res.data.contract_end_date
this.data.address = res.data.address
this.data.customer = res.data.customer
this.data.partyA = res.data.customer
this.data.partyAaddress = res.data.address
this.data.num = res.data.num
this.data.disabled = (res.data.num > 0) ? true : false;
this.data.elevators = res.data.elevators
let cityIndex = this.data.address.indexOf('市');
console.log(cityIndex);
if (cityIndex == -1) {
cityIndex = this.data.address.indexOf('縣');
}
if (cityIndex > 1) {
// 獲取''市''前面的兩個字
let city = this.data.address.substring(cityIndex - 2, cityIndex + 1);
this.data.area = city;
} else {
this.data.area = ''
}
}
this.step = 2
this.isLoading = false
}).catch(err => {
console.error(err)
this.isLoading = false
})
},
preStepFn() {
if (this.step == 2) {
if (confirm('回到上一頁會將會初始化資料,確定返回嗎?')) {
this.step = 1
this.data.total_price = ''
this.data.salesman = ''
this.data.contract_begin_date = ''
this.data.contract_end_date = ''
this.data.address = ''
this.data.customer = ''
this.data.partyA = ''
this.data.partyAaddress = ''
this.step = 1
this.data.num = ''
this.data.disabled = false
this.data.elevators = []
this.data.files = []
this.data.vat = ''
this.data.mtype = ''
this.data.phone = ''
this.data.email = ''
this.data.mworker = ''
this.data.mcycle = ''
this.data.area = ''
this.data.zip = ''
this.data.partyAphone = ''
this.data.partyAemail = ''
return;
}
} else if (this.step == 3) {
this.step = 2
}
},
save() {
this.isLoading = true
const form = new FormData();
form.append('contractno', this.data.contractno);
form.append('total_price', this.data.total_price);
form.append('vat', this.data.vat);
form.append('mtype', this.data.mtype);
form.append('phone', this.data.phone);
form.append('email', this.data.email);
form.append('mworker', this.data.mworker);
form.append('mcycle', this.data.mcycle);
form.append('salesman', this.data.salesman);
form.append('contract_begin_date', this.data.contract_begin_date);
form.append('contract_end_date', this.data.contract_end_date);
form.append('address', this.data.address);
form.append('area', this.data.area);
form.append('customer', this.data.customer);
form.append('partyA', this.data.partyA);
form.append('partyAaddress', this.data.partyAaddress);
form.append('partyAphone', this.data.partyAphone);
form.append('partyAemail', this.data.partyAemail);
form.append('user_id', user_id);
form.append('user_name', user_name);
form.append('num', this.data.num);
form.append('elevators', JSON.stringify(this.data.elevators));
form.append('contracttype', 'b');
// 如果有附件檔案,可以逐一加入
for (var i = 0; i < this.data.files.length; i++) {
form.append('files[]', this.data.files[i]);
}
axios.post('./api/postContractData.php', form).then(res => {
console.log(res.status);
if (res.status === 200) {
alert('儲存成功');
this.step = 1
this.data.total_price = ''
this.data.salesman = ''
this.data.contract_begin_date = ''
this.data.contract_end_date = ''
this.data.address = ''
this.data.customer = ''
this.data.partyA = ''
this.data.partyAaddress = ''
this.step = 1
this.data.num = ''
this.data.disabled = false
this.data.elevators = []
this.data.files = []
this.data.vat = ''
this.data.mtype = ''
this.data.phone = ''
this.data.email = ''
this.data.mworker = ''
this.data.mcycle = ''
this.data.area = ''
this.data.zip = ''
this.data.partyAphone = ''
this.data.partyAemail = ''
}
this.isLoading = false
}).catch(error => {
let code = error.response.status;
if (code == 422) {
this.fail_arr = error.response.data
this.errorFn();
}
if (code == 500) {
alert('儲存失敗!可能為以下錯誤:\n' + error.response.data)
}
this.isLoading = false
})
},
errorFn() {
let msg = ''
for (let i = 0; i < this.fail_arr.length; i++) {
msg += this.fail_arr[i] + '、'
}
alert(msg)
},
uploadFiles(e) {
this.data.files = e.target.files
},
}
};
const contractNewApply = () => {
return {
step: 1,
isLoading: false,
data: {
mid: mid,
vol_no: contractno,
salesman: salesman,
salesmanname: salesmanname,
apply_date: apply_date,
apply_type: 'A',
case_name: case_name,
company: company,
manager: manager,
vat: vat,
total_price: price_total,
price_a: price_a,
price_b: price_b,
address: address,
workdeadline_a: 30, //完工期限: 幾天內安裝完成,預設30
workdeadline_b: 7, //完工期限: 幾天內整理完善,預設7
regulations: 10, //附則
freedeadline: 18, //免保期限(月)
tradeaddress: '', //交貨地點
tradedeadline: 90, //交貨期限
items: items,
},
pays: {
1: 0,
2: 0,
3: 0,
4: 0,
5: 0,
6: 0,
7: 0,
},
tickets: {
1: 0,
2: 0,
3: 0,
4: 0,
5: 0,
6: 0,
7: 0,
},
localnumber(num) {
return num.toLocaleString();
},
storageFn() {
this.isLoading = true
const isFirst = 1;
const form = new FormData();
form.append('mid', this.data.mid);
form.append('vol_no', this.data.vol_no);
form.append('salesman', this.data.salesman);
form.append('apply_date', this.data.apply_date);
form.append('apply_type', this.data.apply_type);
form.append('case_name', this.data.case_name);
form.append('company', this.data.company);
form.append('manager', this.data.manager);
form.append('vat', this.data.vat);
form.append('total_price', this.data.total_price);
form.append('price_a', this.data.price_a);
form.append('price_b', this.data.price_b);
form.append('address', this.data.address);
form.append('workdeadline_a', this.data.workdeadline_a);
form.append('workdeadline_b', this.data.workdeadline_b);
form.append('regulations', this.data.regulations);
form.append('freedeadline', this.data.freedeadline);
form.append('tradeaddress', this.data.tradeaddress);
form.append('tradedeadline', this.data.tradedeadline);
form.append('isFirst', isFirst);
form.append('user_id', user_id);
axios.post('./api/postContractNewApplyData.php', form).then(res => {
if (res.status === 200) {
alert('暫存成功');
console.log(res.data);
}
this.isLoading = false
}).catch(error => {
alert('儲存失敗!可能為以下錯誤:\n' + error.response.data)
this.isLoading = false
})
}
}
}
const contract_edit = () => {
console.log(contract_status);
return {
isLoading: false,
data: {
id: id,
repair_no: repair_no,
contractno: contractno,
company: company,
taxid: taxid,
facilityno: facilityno,
address: address,
type: type,
invoice: invoice,
repaireid: repaireid,
total_price: total_price,
sign_date: sign_date,
user_id: user_id,
contract_status: contract_status
},
fail_arr: [],
deleteFileFn(id) {
if (!confirm("確定要刪除嗎?")) return
this.data.files = this.data.files.filter(file => id != file.id)
this.data.deletefiles.push(id)
console.log(this.data.deletefiles);
},
save() {
this.isLoading = true
const form = new FormData();
form.append("id", this.data.id);
form.append("repair_no", this.data.repair_no);
form.append("contractno", this.data.contractno);
form.append("company", this.data.company);
form.append("taxid", this.data.taxid);
form.append("facilityno", this.data.facilityno);
form.append("address", this.data.address);
form.append("type", this.data.type);
form.append("invoice", this.data.invoice);
form.append("repaireid", this.data.repaireid);
form.append("total_price", this.data.total_price);
form.append("sign_date", this.data.sign_date);
form.append("user_id", user_id);
form.append("contract_status", this.data.contract_status);
form.append('contracttype', 'r');
axios.post("./api/putContractData.php", form).then(res => {
console.log(res);
if (res.status === 200) {
alert("更新成功");
window.location.reload();
}
this.isLoading = false
}).catch(error => {
console.log(this.data);
console.log(error);
let code = error.response.status;
if (code == 422) {
this.fail_arr = error.response.data
this.errorFn()
}
if (code == 500) {
alert("更新失敗!可能為以下錯誤:\n" + error.response.data)
}
this.isLoading = false
})
},
uploadFiles(e) {
this.data.newfiles = e.target.files
},
errorFn() {
let msg = ""
for (let i = 0; i < this.fail_arr.length; i++) {
msg += this.fail_arr[i] + "、"
}
alert(msg)
}
}
}