<template xmlns:v-slot="http://www.w3.org/1999/XSL/Transform">
	<div>
		<el-form :model="jsonData" ref="inputForm" v-loading="loading"
				 label-width="160px" @submit.native.prevent>
			<el-divider content-position="left"><i class="el-icon-document"></i>
				基本信息
			</el-divider>
			<el-row  :gutter="15">
				<el-col :span="24">
					<vxe-table
						border
						show-overflow
						show-footer
						footer-method
						ref="baseTable"
						class="vxe-table-element"
						:data="jsonData.workInvoiceProjectRelationList"
						style="margin-left: 5em"
						@cell-click=""
						@edit-closed=""
						keep-source
						highlight-current-row
						:edit-config="{trigger: 'click', mode: 'cell', showStatus: true, autoClear: true, icon: '-'}"
					>
						<vxe-table-column field="projectName" align="center" title="项目名称" :edit-render="{}" show-overflow="title">
							<template v-slot:edit="scope">
								<el-input @focus="openProgramPageForm(scope.$rowIndex)" placeholder="请填写项目名称" :readonly="true" v-model="scope.row.projectName"/>
							</template>
						</vxe-table-column>
						<vxe-table-column field="workContractName" align="center" title="合同名称" :edit-render="{}">
							<template v-slot:edit="scope">
								<el-input @focus="openContractForm()" placeholder="请填写合同名称" :readonly="true" v-model="scope.row.workContractName"/>
							</template>
						</vxe-table-column>
						<vxe-table-column field="projectNum" align="center" title="项目编号" :edit-render="{}">
							<template v-slot:edit="scope">
								<el-input :readonly="true" placeholder="请填写项目编号" v-model="scope.row.projectNum"/>
							</template>
						</vxe-table-column>
						<vxe-table-column field="clientName" title="委托方" :edit-render="{}">
							<template v-slot:edit="scope">
								<el-input :readonly="true" placeholder="请填写委托方" v-model="scope.row.clientName"/>
							</template>
						</vxe-table-column>
						<vxe-table-column field="reportDataNum" align="center" title="报告号" :edit-render="{}">
							<template v-slot:edit="scope">
								<el-input :readonly="true" placeholder="请填写项目编号" v-model="scope.row.reportDataNum"/>
							</template>
						</vxe-table-column>
						<!--            <vxe-table-column field="reportNo" title="报告号" :edit-render="{}">-->
						<!--              <template v-slot:edit="scope">-->
						<!--                <el-input v-model="scope.row.reportNo" placeholder="请填写报告号"/>-->
						<!--              </template>-->
						<!--            </vxe-table-column>-->
					</vxe-table>
				</el-col>
			</el-row>
			<el-divider content-position="left"><i class="el-icon-document"></i> 发票详情</el-divider>
			<el-row  :gutter="15">
				<el-col :span="12">
					<el-form-item label="发票类型" prop="invoiceTypeName"
								  :rules="[

               ]">
						<el-input :disabled="true" placeholder="请填写发票类型" v-model="jsonData.invoiceTypeName" clearable></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="开票类型" prop="newDrawerName"
								  :rules="[
               ]">
						<el-input :disabled="true" placeholder="请填写开票类型" v-model="jsonData.newDrawerName" clearable></el-input>
					</el-form-item>
				</el-col>
			</el-row>
			<el-row>
				<el-col :span="12">
					<el-form-item label="实际开票单位" prop="clientName"
								  :rules="[
               ]">
						<el-input :disabled="true" :readonly="true" placeholder="请填写实际开票单位" v-model="jsonData.clientName" clearable></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="纳税人识别号" prop="taxpayerIdentificationNo"
								  :rules="[
             ]">
						<el-input :disabled="true" v-model="jsonData.taxpayerIdentificationNo" placeholder="请填写纳税人识别号" clearable></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="地址" prop="address"
								  :rules="[
             ]">
						<el-input :disabled="true" v-model="jsonData.address" placeholder="请填写地址" clearable></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="电话" prop="telephone"
								  :rules="[
             ]">
						<el-input :disabled="true" v-model="jsonData.telephone" placeholder="请填写电话"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="开户银行" prop="bank"
								  :rules="[
             ]">
						<el-input :disabled="true" v-model="jsonData.bank" placeholder="请填写开户银行"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="银行账号" prop="bankNumber"
								  :rules="[
             ]">
						<el-input :disabled="true" placeholder="请填写银行账号" v-model="jsonData.bankNumber" clearable></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="收款类型" prop="chargeType"
								  :rules="[
               ]">
						<el-input :disabled="true" placeholder="请填写收款类型" v-model="jsonData.chargeType" clearable></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="开票内容" prop="billingContent"
								  :rules="[
               ]">
						<el-input :disabled="true" placeholder="请填写开票内容" v-model="jsonData.billingContent" clearable></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="发票金额(元)" prop="money"
								  :rules="[
               ]">
						<el-input
							placeholder="请填写发票金额"
							maxlength="15"
							v-model="jsonData.money"
							:disabled="true"
						>
						</el-input>
					</el-form-item>
				</el-col >
				<el-col :span="12">
					<el-form-item label="开票内容要求" prop="content"
								  :rules="[
               ]">
						<el-input :disabled="true" type="input"  v-model="jsonData.content" placeholder="开票内容要求" show-word-limit></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="开票人" prop="drawerName"
								  :rules="[
               ]">
						<el-input :disabled="true" v-model="jsonData.drawerName" placeholder="请选择开票人" clearable></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12" >
					<el-form-item label="开票时间" prop="invoiceDate"
								  :rules="[
                         {required: true, message:'开票时间不能为空', trigger:'blur'}
                 ]">
						<el-date-picker
							v-model="jsonData.invoiceDate"
							type="date"
							value-format="YYYY-MM-DD"
							placeholder="选择开票时间"
							style="width:100%"
							placement="bottom-start"
							clearable>
						</el-date-picker>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="领票时间" prop="takeDate"
								  :rules="[
                 ]">
						<el-date-picker
							v-model="jsonData.takeDate"
							type="date"
							value-format="YYYY-MM-DD"
							placeholder="选择领票时间"
							style="width:100%"
							placement="bottom-start"
							clearable>
						</el-date-picker>
					</el-form-item>
				</el-col>

				<el-col :span="12">
					<el-form-item label="实际开票人" prop="actualDrawerName"
								  :rules="[
					   ]">
						<el-input :disabled="true" :readonly="true" v-model="jsonData.actualDrawerName" placeholder="请选择实际开票人">
						</el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="接收邮箱" prop="actualDrawerEmailAddress"
								  :rules="[
							/*{required: true, message:'邮箱不能为空', trigger:'blur'},
							{required: true, message:'邮箱不能为空', trigger:'change'}*/
               ]">
						<el-input :disabled="true" v-model="jsonData.actualDrawerEmailAddress" placeholder="请输入接收邮箱" show-word-limi maxlength="50"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-col>
						<el-form-item label="对账人" prop="accountCheckingUserName"
									  :rules="[
                        {required: true, message:'对账人不能为空', trigger:'blur'},
                        {required: true, message:'对账人不能为空', trigger:'change'}
               ]">
							<el-input :disabled="true" :readonly="true"  v-model="jsonData.accountCheckingUserName" placeholder="请选择对账人">
							</el-input>
						</el-form-item>
					</el-col>

				</el-col>
				<el-col :span="12">
					<el-form-item label="对账地区" prop="area"
								  :rules="[
               ]">
						<el-input :disabled="true" :readonly="true"  v-model="jsonData.area" placeholder="请选择对账地区">
						</el-input>
					</el-form-item>
				</el-col>

				<el-col :span="24">
					<el-form-item label="备注" prop="remarks"
								  :rules="[
               ]">
						<el-input :disabled="true" maxlength="500" type="textarea" placeholder="请填写备注" v-model="jsonData.remarks" show-word-limit></el-input>
					</el-form-item>
				</el-col>
			</el-row>


			<el-form>
				<el-divider content-position="left"><i class="el-icon-document"></i>
					发票明细
					<el-button style="margin-left: 20px" type="primary" @click="insertEvent('detail')" plain>
						新增
					</el-button>
					<el-popover
						placement="top"
						width="400"
						v-model="importVisible">
						<p>请先下载模板，然后再进行导入操作</p>
						<el-row :gutter="1">
							<el-col :span="6">
								<el-button type="success" @click="downloadTpl">下载模板</el-button>
							</el-col>
							<el-col :span="6">
								<el-upload
									action=""
									:auto-upload="false"
									:on-change="beforeUploadDetail"
									:show-file-list="false">
									<el-button type="primary">导入全部</el-button>
								</el-upload>
							</el-col>
							<el-col :span="6">
								<el-upload
									action=""
									:auto-upload="false"
									:on-change="beforeUploadDetailCode"
									:show-file-list="false">
									<el-button type="primary" >仅导入当前纳税人识别号</el-button>
								</el-upload>
							</el-col>
						</el-row>
						<div style="text-align: right; margin-top: 10px;margin-right: 10px;">
							<el-button  type="default" @click="importVisible = false" plain>取消</el-button>
							<!--            <el-button type="primary"  @click="importVisible = false">确定</el-button>-->
						</div>
						<template #reference>
							<el-button style="margin-left: 20px" type="warning" plain>导入</el-button>
						</template>
					</el-popover>
				</el-divider>
			</el-form>

			<el-form :model="jsonData" ref="inputForm" v-loading="loading"
					 label-width="160px" @submit.native.prevent>
				<el-row  :gutter="15">
					<el-col :span="24">
						<vxe-table
							border
							show-overflow
							show-footer
							footer-method
							keep-source
							ref="detailTable"
							:key="detailKey"
							class="vxe-table-element"
							:data="jsonData.workAccountList"
							style="margin-left: 5em"
							highlight-current-row
							:edit-config="{trigger: 'click', mode: 'cell', showStatus: true, autoClear: true}"
						>
							<vxe-table-column field="code" title="发票代码" :edit-render="{}">
								<template #edit="scope">
									<el-input  v-model="scope.row.code" placeholder="请填写发票代码"/>
								</template>
							</vxe-table-column>
							<vxe-table-column field="number" title="发票号" :edit-render="{}">
								<template #edit="scope">
									<el-input
										oninput ="value=value.replace(/\D|^/g,'')"
										placeholder="请填写发票号"
										maxlength="8"
										@blur="checkNumber(scope.row,scope.$rowIndex)"
										v-model="scope.row.number"
										clearable>
									</el-input>
								</template>
							</vxe-table-column>
							<vxe-table-column field="account" title="开票金额(元)" :edit-render="{}">
								<template #edit="scope">
									<el-input-number
										@blur="checkAccount(scope.row,scope.$rowIndex)"
										v-model="scope.row.account"
										controls-position="right"
										:controls="false"
										style="width:100%;"
										:max="999999999999999"
										:precision="2"
										placeholder="请填写开票金额"
										:step="0.01"
									>
									</el-input-number>
								</template>
							</vxe-table-column>
							<vxe-table-column field="rate" title="税率(%)" :edit-render="{}">
								<template #edit="scope">
									<el-input-number
										@blur="checkRate(scope.row, scope.$rowIndex)"
										v-model="scope.row.rate"
										controls-position="right"
										:controls="false"
										style="width:100%;"
										:precision="2"
										placeholder="请填写税率"
										:step="0.01"
										:min="0"
										clearable>
									</el-input-number>
								</template>
							</vxe-table-column>
							<vxe-table-column field="amount" title="金额" :edit-render="{}">
								<template #edit="scope">
									<el-input  :readonly="true" v-model="scope.row.amount" placeholder="请填写金额"/>
								</template>
							</vxe-table-column>
							<vxe-table-column field="tax" title="税额" :edit-render="{}">
								<template #edit="scope">
									<el-input  :readonly="true" v-model="scope.row.tax" placeholder="请填写税额"/>
								</template>
							</vxe-table-column>
							<vxe-table-column title="操作" width="100">
								<template v-slot="scope">
									<el-button type="danger" @click="removeEvent(scope.row,scope.$rowIndex,'detail')">删除</el-button>
								</template>
							</vxe-table-column>
						</vxe-table>
					</el-col>
				</el-row>
			</el-form>
		</el-form>
		<!--        附件-->
		<UpLoadComponent ref="uploadComponent"></UpLoadComponent>
		<!--审核意见-->
		<div v-if="type === 'audit'">
			<el-divider content-position="left"><span style="color: red">*</span> <i class="el-icon-document"></i> 审批意见</el-divider>
			<el-row><el-input type="textarea" :rows="5" maxlength="500" placeholder="请填写审核意见：" v-model="comments" show-word-limit></el-input></el-row>
		</div>
		<!--流程历史-->
		<FlowHisTableCcpm ref="flowHisTableCcpm"></FlowHisTableCcpm>
		<!--操作按钮-->
		<div class="FlowFormFooter" style="margin-top: 2em;margin-left: 45em">
			<el-button v-if="type === 'audit'" type="primary" :loading="loading" @click="agree" v-noMoreClick plain>同意</el-button>
			<el-button v-if="type === 'audit'" type="danger" :loading="loading" @click="reject" v-noMoreClick plain>驳回</el-button>
			<el-button :loading="loading" @click="close" v-noMoreClick plain>关闭</el-button>
		</div>
	</div>
</template>

<script>
	import UpLoadComponent from '@/views/common/UpLoadComponent'
	import XEUtils from 'xe-utils'
	import processService from '@/api/flowable/processService'
	import FlowHisTableCcpm from '@/views/flowable/task/FlowHisTableCcpm'
	import financeInvoiceService from '@/api/cw/invoice/CwFinanceInvoiceService'
	import CcpmService from '@/api/centerservice/ccpm/CcpmService'
	export default {
		props: {
		},
		data() {
			return {
				jsonData: {},
				title: '',
				businessId: '',
				loading: false,
				type: '',
				processDefKey: '',
				comments: '', // 审核意见
				importVisible: false,
				detailKey:''
			}
		},
		ccpmService: null,
		activated () {
			this.init()
		},
		created() {
			this.ccpmService = new CcpmService()
			this.init()
		},
		mounted() {
		},
		components: {
			UpLoadComponent,
			FlowHisTableCcpm
		},
		computed: {

		},
		watch: {
		},
		methods: {
			// 初始化
			init () {
				this.businessId = this.$route.query.id
				this.processDefKey = this.$route.query.processDefKey
				this.title = this.$route.query.title
				this.type = this.$route.query.type
				this.jsonData = []
				this.comments = ''
				this.$nextTick(async () => {
					this.loading = true
					this.$refs.uploadComponent.clearUpload()
					this.$refs.flowHisTableCcpm.clearFlowHis()
					await this.ccpmService.getByIdGenerate(this.businessId, this.processDefKey).then((data)=>{
						if (data) {
							console.log('data',data)
							this.loading = false
							this.jsonData = JSON.parse(JSON.stringify(data))
							if (this.commonJS.isEmpty(this.jsonData.files)) {
								this.jsonData.files = []
							}
							if (this.commonJS.isEmpty(this.jsonData.drawerName)) {
								this.jsonData.drawerName = this.$store.state.user.name
							}
							if (this.commonJS.isEmpty(this.jsonData.invoiceDate)){
								this.jsonData.invoiceDate = this.moment(new Date()).format('YYYY-MM-DD')
							}
							let filesLabel = '附件'
							if (this.commonJS.isNotEmpty(this.jsonData.filesLabel)) {
								filesLabel = this.jsonData.filesLabel
							}
							this.$refs.uploadComponent.newUpload('view', this.jsonData.files, null, null, filesLabel)
							this.$refs.flowHisTableCcpm.setFlowHis(this.jsonData.flowChart, this.jsonData.histoicFlow)
							this.getTotalAccount()
							// this.$nextTick(() => {
							//   this.$refs.generateForm.refresh()
							// })
						} else {
							this.loading = false
						}
					})

				})
			},
			// 关闭
			close () {
				this.$refs.uploadComponent.clearUpload()
				this.$refs.flowHisTableCcpm.clearFlowHis()
				this.jsonData = []
				this.comments = ''
				this.$store.dispatch('tagsView/delView', {fullPath: this.$route.fullPath})
				if (this.$route.query.backPath) {
					this.$router.push(this.$route.query.backPath)
				} else {
					this.$router.push('/dashboard/index')
				}
			},
			// 同意
			async agree () {
				let acc = 0
				this.jsonData.workAccountList.forEach((item, index) => {
					if (this.commonJS.isEmpty(item.number)) {
						this.loading = false
						this.$message.warning('发票明细中第 ' + (index + 1) + ' 条数据的 “发票号” 为空')
						throw new Error()
					}
					if (this.commonJS.isEmpty(item.account)) {
						this.loading = false
						this.$message.warning('发票明细中第 ' + (index + 1) + ' 条数据的 “开票金额” 为空')
						throw new Error()
					}
					acc = (acc + parseFloat(parseFloat(item.account).toFixed(2)))
				})
				if (parseFloat(acc).toFixed(2) !== parseFloat(this.jsonData.money).toFixed(2)) {
					this.loading = false
					this.$message.warning('发票明细中 “开票金额”总和 与发票详情中 “发票金额” 不等')
					throw new Error()
				}
				this.jsonData.workAccountList.forEach((item, index) => {
					this.jsonData.workAccountList.forEach((item2, index2) => {
						if (index !== index2) {
							if (item.number === item2.number) {
								this.loading = false
								this.$message.warning('发票明细中第 ' + (index + 1) + ' 条数据的 “发票号” 存在重复')
								throw new Error()
							}
						}
					})
				})
				for await (let [index, item] of this.jsonData.workAccountList.entries()) {
					if (this.commonJS.isEmpty(item.number)) {
						this.loading = false
						this.$message.warning('发票明细中第 ' + (index + 1) + ' 条数据的 “发票号” 为空')
						this.err = true
					}
				}
				if (this.err === true) {
					this.loading = false
					this.err = ''
					throw new Error()
				}

				if (this.commonJS.isEmpty(this.comments)) {
					this.$message.error('请填写审批意见')
				} else {
					this.loading = true
					let jsonData = JSON.stringify(this.jsonData)
					this.ccpmService.invoiceAudit(this.businessId, 'yes', this.comments, this.processDefKey,jsonData).then((data) => {
						this.loading = false
						if (data.success) {
							this.$message.success(data.message)
							this.close()
						} else {
							this.$message.error(data.message)
						}
					}).catch(() => {
						this.loading = false
					})
				}
			},
			// 驳回
			reject () {
				if (this.commonJS.isEmpty(this.comments)) {
					this.$message.error('请填写审批意见')
				} else {
					this.$confirm(`确定驳回此报销申请吗?`, '提示', {
						confirmButtonText: '确定',
						cancelButtonText: '取消',
						type: 'warning'
					}).then(async () => {
						this.loading = true
						let jsonData = JSON.stringify(this.jsonData)
						this.ccpmService.invoiceAudit(this.businessId, 'no', this.comments, this.processDefKey,jsonData).then((data) => {
							this.loading = false
							if (data.success) {
								this.$message.success(data.message)
								this.close()
							} else {
								this.$message.error(data.message)
							}
						}).catch(() => {
							this.loading = false
						})
					})
				}
			},
			//新增
			insertEvent(type) {
				if (type === 'detail') {
					this.$refs.detailTable.insert().then((data) => {
						this.jsonData.workAccountList.push(data)
						this.detailKey = Math.random()
					})
				}
			},
			// 下载模板
			downloadTpl() {
				this.loading = true
				financeInvoiceService.exportTemplate().then((res) => {
					// 将二进制流文件写入excel表，以下为重要步骤
					this.$utils.downloadExcel(res, '发票明细导入模板')
					this.loading = false
				}).catch(function (err) {
					this.loading = false
					if (err.response) {
						console.log(err.response)
					}
				})
			},
			beforeUploadDetail(file) {
				const formBody = new FormData()
				formBody.append('file', file.raw)
				this.loading = true
				financeInvoiceService.importDetail(formBody).then(async (result) => {
					if (this.commonJS.isEmpty(result)) {
						this.importVisible = false
						this.loading = false
						throw new Error()
					}
					for await (let item of result) {
						this.jsonData.workAccountList.forEach(detail => {
							if (item.number === detail.number) {
								this.$message.error('上传的文件中存在与页面重复的发票号，请重新填写后上传')
								this.importVisible = false
								this.loading = false
								throw new Error()
							}
						})
					}
					await this.detailPush(result)
					this.importVisible = false
					this.loading = false
				}).catch(() => {
					this.importVisible = false
					this.loading = false
				})
			},
			async detailPush(data) {
				if (this.commonJS.isNotEmpty(data)) {
					await data.forEach(item => {
						this.getAmount(item)
						this.getTax(item)
						this.jsonData.workAccountList.push(item)
						this.detailKey = Math.random()
					})
				}
				this.$message.success('导入完成')
			},
			checkNumber(row, rowIndex) {
				if (!this.commonJS.isEmpty(row.number)) {
					if (parseInt(row.number) > 99999999) {
						this.$message.warning('“发票号” 不可以大于 8 位，请重新输入')
						row.number = undefined
						return
					}
					this.jsonData.workAccountList.forEach((item, index) => {
						if (rowIndex !== index) {
							if (row.number === item.number) {
								row.number = ''
								this.$message.warning('“发票号” 已存在，请重新输入')
								throw new Error()
							}
						}
					})
					this.ccpmService.queryByNumber(row.number).then((data) => {
						if (data === true) {
							row.number = ''
							this.$message.warning('“发票号” 已存在，请重新输入')
						}
					})
				}
			},
			checkAccount(row, rowIndex) {
				if (this.commonJS.isEmpty(row.account)) {
					row.account = undefined
				}
				this.getAmount(row)
				this.getTax(row)
			},
			checkRate(row, rowIndex) {
				if (!this.commonJS.isEmpty(row.rate)) {
					if (parseFloat(row.rate) < 0 || parseFloat(row.rate) > 100) {
						this.$message.warning('“税率” 请填写 0 到 100 之间的数字，请重新输入')
						row.rate = undefined
					}
				}
				this.getAmount(row)
				this.getTax(row)
			},
			// 根据开票金额和税率计算出金额: 开票金额-税率*开票金额
			getAmount(row) {
				if (!this.commonJS.isEmpty(row.account) && !this.commonJS.isEmpty(row.rate)) {
					row.amount = parseFloat((parseFloat(row.account) - parseFloat((parseFloat(row.account) * parseFloat((parseFloat(row.rate) / 100).toFixed(4))).toFixed(4))).toFixed(2))
				} else {
					row.amount = undefined
				}
			},
			// 根据开票金额和税率计算出税额: 税率*开票金额
			getTax(row) {
				if (!this.commonJS.isEmpty(row.account) && !this.commonJS.isEmpty(row.rate)) {
					row.tax = parseFloat((parseFloat(row.account) * parseFloat((parseFloat(row.rate) / 100).toFixed(4))).toFixed(2))
				} else {
					row.tax = undefined
				}
			},
			// 获取发票金额，放到开票明细中第一条数据
			getTotalAccount() {
				if (!this.commonJS.isEmpty(this.jsonData.money)) {
					this.jsonData.workAccountList.push({account: this.jsonData.money})
				}
			},
			async beforeUploadDetailCode(file) {
				await this.checkIdentificationNo()
				const formBody = new FormData()
				formBody.append('file', file.raw)
				this.loading = true
				financeInvoiceService.importDetail(formBody).then(async result => {
					if (this.commonJS.isEmpty(result)) {
						this.importVisible = false
						this.loading = false
						throw new Error()
					}
					for await (let item of result) {
						await this.jsonData.workAccountList.forEach(detail => {
							if (item.number === detail.number) {
								this.$message.error('上传的文件中存在与页面重复的发票号，请重新填写后上传')
								this.importVisible = false
								this.loading = false
								throw new Error()
							}
						})
					}
					this.detailPushCode(result)
					this.importVisible = false
					this.loading = false
				}).catch(() => {
					this.importVisible = false
					this.loading = false
				})
			},
			checkIdentificationNo() {
				if (this.commonJS.isEmpty(this.jsonData.taxpayerIdentificationNo)) {
					this.$message.error('当前纳税人识别号为空，导入失败')
					throw new Error()
				}
			},
			detailPushCode(data) {
				if (this.commonJS.isNotEmpty(data)) {
					data.forEach(item => {
						if (this.commonJS.isNotEmpty(item.taxpayerIdentificationNo)) {
							if (item.taxpayerIdentificationNo === this.jsonData.taxpayerIdentificationNo) {
								this.getAmount(item)
								this.getTax(item)
								this.jsonData.workAccountList.push(item)
								this.detailKey = Math.random()
							}
						}
					})
				}
				this.$message.success('导入完成')
			},
			// 删除
			removeEvent(row, rowIndex, type) {
				if (type === 'base') {
					this.$refs.baseTable.remove(row)
					this.inputForm.financeInvoiceBaseDTOList.splice(rowIndex, 1)
				}
				if (type === 'detail') {
					this.$refs.detailTable.remove(row)
					this.jsonData.workAccountList.splice(rowIndex, 1)
				}
				if (type === 'receivables') {
					this.$refs.receivablesTable.remove(row)
					this.inputForm.financeInvoiceReceivablesDTOList.splice(rowIndex, 1)
				}
			},
		}
	}
</script>
<style scoped>
	/deep/ .el-input-number .el-input__inner {
		text-align: left;
	}
	/deep/ .vxe-footer--row .vxe-footer--column:nth-child(1) .vxe-cell--item {
		font-weight:700;
	}
</style>
