|
@@ -933,13 +933,13 @@
|
|
|
getKeyWatch(keyWatch) {
|
|
|
this.keyWatch = keyWatch
|
|
|
},
|
|
|
- init(method, id) {
|
|
|
- this.bj1 = ''
|
|
|
- this.importVisible = false
|
|
|
- this.method = method
|
|
|
+ async init(method, id) {
|
|
|
+ this.bj1 = '';
|
|
|
+ this.importVisible = false;
|
|
|
+ this.method = method;
|
|
|
this.inputForm = {
|
|
|
checkType: '',
|
|
|
- accountTotal: '',//发票汇总金额
|
|
|
+ accountTotal: '', // 发票汇总金额
|
|
|
id: '',
|
|
|
financeInvoiceBaseDTOList: [],
|
|
|
programName: '',
|
|
@@ -987,122 +987,108 @@
|
|
|
reportType: '',
|
|
|
tenantId: '',
|
|
|
actualDrawerEmailAddress: ''
|
|
|
- }
|
|
|
- // if (method === 'add') {
|
|
|
- // this.title = `新建发票`
|
|
|
- // } else if (method === 'edit') {
|
|
|
- // this.title = '修改发票'
|
|
|
- // } else if (method === 'view') {
|
|
|
- // this.title = '查看发票信息'
|
|
|
- // }
|
|
|
- this.inputForm.id = id
|
|
|
- this.visible = true
|
|
|
- this.loading = false
|
|
|
- this.$nextTick(() => {
|
|
|
- var user = this.$TOOL.data.get("USER_INFO")
|
|
|
- this.inputForm.tenantId = user.tenantDTO.id
|
|
|
- userService.queryById(user.id).then((data) => {
|
|
|
- this.userPhone = data.mobile
|
|
|
- this.userEmail = data.email
|
|
|
+ };
|
|
|
+
|
|
|
+ this.inputForm.id = id;
|
|
|
+ this.visible = true;
|
|
|
+ this.loading = false;
|
|
|
+
|
|
|
+ this.$nextTick(async () => {
|
|
|
+ try {
|
|
|
+ const user = this.$TOOL.data.get("USER_INFO");
|
|
|
+ this.inputForm.tenantId = user.tenantDTO.id;
|
|
|
+
|
|
|
+ // 确保userService.queryById完成后再执行后续代码
|
|
|
+ const userData = await userService.queryById(user.id);
|
|
|
+ this.userPhone = userData.mobile;
|
|
|
+ this.userEmail = userData.email;
|
|
|
+
|
|
|
+ // 重置表单字段
|
|
|
+ this.$refs.inputForm.resetFields();
|
|
|
+
|
|
|
+ // 获取发票数据并处理
|
|
|
+ this.loading = true;
|
|
|
+ const invoiceData = await financeInvoiceService.queryById(this.inputForm.id);
|
|
|
+
|
|
|
+ this.$refs.uploadComponent.clearUpload();
|
|
|
+ this.inputForm = this.recover(this.inputForm, invoiceData);
|
|
|
|
|
|
- });
|
|
|
- this.$refs.inputForm.resetFields()
|
|
|
- this.loading = true
|
|
|
- financeInvoiceService.queryById(this.inputForm.id).then((data) => {
|
|
|
- this.$refs.uploadComponent.clearUpload()
|
|
|
- this.inputForm = this.recover(this.inputForm, data)
|
|
|
if (this.commonJS.isEmpty(this.inputForm.actualDrawerEmailAddress)) {
|
|
|
- this.inputForm.actualDrawerEmailAddress = this.userEmail
|
|
|
+ this.inputForm.actualDrawerEmailAddress = this.userEmail;
|
|
|
}
|
|
|
- this.inputForm = JSON.parse(JSON.stringify(this.inputForm))
|
|
|
+
|
|
|
+ // 确保对象深拷贝
|
|
|
+ this.inputForm = JSON.parse(JSON.stringify(this.inputForm));
|
|
|
+
|
|
|
+ // 加载银行账户信息
|
|
|
if (!this.commonJS.isEmpty(this.inputForm.billingWorkplaceRealId)) {
|
|
|
- this.bankList = []
|
|
|
- workClientService.queryById(this.inputForm.billingWorkplaceRealId).then((data) => {
|
|
|
- if (this.commonJS.isNotEmpty(data.cwWorkClientBillingDTOList)) {
|
|
|
- data.cwWorkClientBillingDTOList.forEach(i => {
|
|
|
- i.ourBank = i.accountHolder
|
|
|
- this.bankList.push(i)
|
|
|
- this.inputForm.openBank = i.ourBank
|
|
|
- })
|
|
|
- } else {
|
|
|
- this.bankList = []
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
+ this.bankList = [];
|
|
|
+ const workClientData = await workClientService.queryById(this.inputForm.billingWorkplaceRealId);
|
|
|
|
|
|
- if (this.commonJS.isEmpty(this.inputForm.type)) {
|
|
|
- this.inputForm.type = '1'
|
|
|
- }
|
|
|
- if (this.commonJS.isEmpty(this.inputForm.billingType)) {
|
|
|
- this.inputForm.billingType = '1'
|
|
|
- }
|
|
|
- if (this.commonJS.isEmpty(this.inputForm.receivablesType)) {
|
|
|
- this.inputForm.receivablesType = '2'
|
|
|
+ if (this.commonJS.isNotEmpty(workClientData.cwWorkClientBillingDTOList)) {
|
|
|
+ workClientData.cwWorkClientBillingDTOList.forEach(i => {
|
|
|
+ i.ourBank = i.accountHolder;
|
|
|
+ this.bankList.push(i);
|
|
|
+ this.inputForm.openBank = i.ourBank;
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.bankList = [];
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ // 设置默认值
|
|
|
+ this.inputForm.type = this.commonJS.isEmpty(this.inputForm.type) ? '1' : this.inputForm.type;
|
|
|
+ this.inputForm.billingType = this.commonJS.isEmpty(this.inputForm.billingType) ? '1' : this.inputForm.billingType;
|
|
|
+ this.inputForm.receivablesType = this.commonJS.isEmpty(this.inputForm.receivablesType) ? '2' : this.inputForm.receivablesType;
|
|
|
if (this.status === 'audit') {
|
|
|
- this.inputForm.billingPeople = this.$store.state.user.name
|
|
|
- }
|
|
|
- if (this.commonJS.isEmpty(this.inputForm.billingPeopleId)) {
|
|
|
- this.inputForm.billingPeopleId = this.$store.state.user.id
|
|
|
- }
|
|
|
- console.log('billingPeopleReal', this.inputForm.billingPeopleReal)
|
|
|
- if (this.commonJS.isEmpty(this.inputForm.billingPeopleReal)) {
|
|
|
- this.inputForm.billingPeopleReal = this.$store.state.user.id
|
|
|
- }
|
|
|
- // console.log('reconciliationPeople', this.inputForm.reconciliationPeople)
|
|
|
- // if (this.commonJS.isEmpty(this.inputForm.reconciliationPeople)) {
|
|
|
- // this.inputForm.reconciliationPeople = this.$store.state.user.id
|
|
|
- // }
|
|
|
- if (this.commonJS.isEmpty(this.inputForm.financeInvoiceBaseDTOList)) {
|
|
|
- this.inputForm.financeInvoiceBaseDTOList = []
|
|
|
- }
|
|
|
- if (this.commonJS.isEmpty(this.inputForm.workAttachmentDtoList) || this.inputForm.workAttachmentDtoList.length === 0) {
|
|
|
- this.inputForm.workAttachmentDtoList = []
|
|
|
- }
|
|
|
- if (this.commonJS.isEmpty(this.inputForm.financeInvoiceReceivablesDTOList) || this.inputForm.financeInvoiceReceivablesDTOList.length === 0) {
|
|
|
- this.inputForm.financeInvoiceReceivablesDTOList = []
|
|
|
+ this.inputForm.billingPeople = this.$store.state.user.name;
|
|
|
}
|
|
|
+ this.inputForm.billingPeopleId = this.commonJS.isEmpty(this.inputForm.billingPeopleId) ? this.$store.state.user.id : this.inputForm.billingPeopleId;
|
|
|
+
|
|
|
+ // 初始化数据
|
|
|
+ this.inputForm.billingPeopleReal = this.commonJS.isEmpty(this.inputForm.billingPeopleReal) ? this.$store.state.user.id : this.inputForm.billingPeopleReal;
|
|
|
+ this.inputForm.financeInvoiceBaseDTOList = this.commonJS.isEmpty(this.inputForm.financeInvoiceBaseDTOList) ? [] : this.inputForm.financeInvoiceBaseDTOList;
|
|
|
+ this.inputForm.workAttachmentDtoList = this.commonJS.isEmpty(this.inputForm.workAttachmentDtoList) ? [] : this.inputForm.workAttachmentDtoList;
|
|
|
+ this.inputForm.financeInvoiceReceivablesDTOList = this.commonJS.isEmpty(this.inputForm.financeInvoiceReceivablesDTOList) ? [] : this.inputForm.financeInvoiceReceivablesDTOList;
|
|
|
+
|
|
|
if (this.commonJS.isEmpty(this.inputForm.checkType) || this.inputForm.checkType === '0') {
|
|
|
- // 是否多张开票 默认为 0 否
|
|
|
- this.bj1 = 'bj1'
|
|
|
+ this.bj1 = 'bj1';
|
|
|
}
|
|
|
if (this.commonJS.isEmpty(this.inputForm.isMultiple) && this.status !== 'taskFormDetail') {
|
|
|
- // 是否多张开票 默认为 0 否
|
|
|
- this.inputForm.isMultiple = '0'
|
|
|
+ this.inputForm.isMultiple = '0';
|
|
|
}
|
|
|
+
|
|
|
if (this.status === 'audit' || this.status === 'taskFormDetail') {
|
|
|
- method = 'view'
|
|
|
- if (this.status === 'audit'){
|
|
|
- this.inputForm.billingDate = this.moment(new Date()).format('YYYY-MM-DD')
|
|
|
+ method = 'view';
|
|
|
+ if (this.status === 'audit') {
|
|
|
+ this.inputForm.billingDate = this.moment(new Date()).format('YYYY-MM-DD');
|
|
|
}
|
|
|
}
|
|
|
- /*if (this.commonJS.isEmpty(this.inputForm.billingDate)) {
|
|
|
- this.inputForm.billingDate = this.moment(new Date()).format('YYYY-MM-DD')
|
|
|
- }*/
|
|
|
- if (!this.commonJS.isEmpty(this.status) && this.status === 'audit' && (this.commonJS.isEmpty(this.inputForm.financeInvoiceDetailDTOList) || this.inputForm.financeInvoiceDetailDTOList.length === 0)) {
|
|
|
- this.inputForm.financeInvoiceDetailDTOList = []
|
|
|
- let i = this.inputForm.financeInvoiceBaseDTOList.length
|
|
|
- let sun = this.inputForm.account
|
|
|
- // let sun = 0
|
|
|
- // for (let j = 0; j < i; j++) {
|
|
|
- // sun = (100*sun + 100* this.inputForm.financeInvoiceBaseDTOList[j].account)/100
|
|
|
- // }
|
|
|
- console.log(sun)
|
|
|
+
|
|
|
+ if (!this.commonJS.isEmpty(this.status) && this.status === 'audit' && this.commonJS.isEmpty(this.inputForm.financeInvoiceDetailDTOList)) {
|
|
|
+ this.inputForm.financeInvoiceDetailDTOList = [];
|
|
|
+ const totalAccount = this.inputForm.account;
|
|
|
this.inputForm.financeInvoiceDetailDTOList.push({
|
|
|
code: '',
|
|
|
number: '',
|
|
|
- account: sun,
|
|
|
+ account: totalAccount,
|
|
|
rate: '',
|
|
|
amount: '',
|
|
|
tax: '',
|
|
|
allAmount: ''
|
|
|
- })
|
|
|
+ });
|
|
|
}
|
|
|
- this.$refs.uploadComponent.newUpload(method, this.inputForm.workAttachmentDtoList, 'invoice')
|
|
|
- this.loading = false
|
|
|
- })
|
|
|
- })
|
|
|
- },
|
|
|
+
|
|
|
+ this.$refs.uploadComponent.newUpload(method, this.inputForm.workAttachmentDtoList, 'invoice');
|
|
|
+ this.loading = false;
|
|
|
+
|
|
|
+ } catch (error) {
|
|
|
+ console.error("Error occurred:", error);
|
|
|
+ this.loading = false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ ,
|
|
|
saveForm(callback) {
|
|
|
this.doSubmit('save', callback)
|
|
|
},
|