<template>
	<div>
		<el-card :body-style="cardBodyStyle">
			<el-form :inline="true">
				<el-form-item label="对账单单号" style="margin-bottom: 5px;" prop="billNo">
					<el-input v-model="query.billNo" placeholder="请输入对账单单号" clearable></el-input>
				</el-form-item>
				<el-form-item label="供应商名称" style="margin-bottom: 5px;" prop="tradePartnerName">
					<el-input v-model="query.tradePartnerName" placeholder="请输入供应商名称" clearable></el-input>
				</el-form-item>
				<el-form-item label="合同号" style="margin-bottom: 5px;" prop="contrNo">
					<el-input v-model="query.contrNo" placeholder="请输入合同号" clearable></el-input>
				</el-form-item>
				<el-form-item label="对方合同号" style="margin-bottom: 5px;" prop="khContrNo">
					<el-input v-model="query.khContrNo" placeholder="请输入对方合同号" clearable></el-input>
				</el-form-item>
			</el-form>
		</el-card>

		<ButtonBar @search="handleSearch" @export="handleExport" @addAct="handleAddAct"></ButtonBar>

		<el-card :body-style="cardBodyStyle">
			<el-tabs v-model="activeNameTop" type="border-card">
				<el-tab-pane label="对账单头" name="master">
					<el-table :data="tableData" border highlight-current-row @selection-change="handleSelectionChange"
						@row-click="DoubleClick">
						<el-table-column type="selection" fixed></el-table-column>
						<el-table-column type="index" label="序号" align="center" width="60" fixed>
							<template #default="scope">
								<span>{{ scope.$index + (currentPage - 1) * pageSize + 1 }}</span>
							</template>
						</el-table-column>
						<el-table-column v-if="true" prop="billNo" label="对账单单号" min-width="200" header-align="center"
							align="center" show-overflow-tooltip fixed>
						</el-table-column>
						<el-table-column v-if="true" prop="tradePartnerCode" label="供应商编码" min-width="150"
							header-align="center" align="center" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="tradePartnerName" label="供应商名称" min-width="250"
							header-align="center" align="center" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="contrNo" label="合同号" min-width="180" header-align="center"
							align="center" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="khContrNo" label="对方合同号" min-width="200"
							header-align="center" align="center" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="accountQty" label="结算重量和" min-width="120"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="accountAmount" label="结算金额和" min-width="120"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="accountTaxAmount" label="结算含税金额和" min-width="150"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="accountFlag" label="是否结算" min-width="120"
							header-align="center" align="center" show-overflow-tooltip :formatter="formatter">
						</el-table-column>
						<el-table-column v-if="true" prop="workModel.flowStatusName" label="流程状态" width="120"
							header-align="center" align="center" show-overflow-tooltip>
							<template #default="{ row }">
								<div>
									<el-tag v-if="row.workId !== undefined && row.workModel.flowStatus === '110'">{{
										row.workModel.flowStatusName }}</el-tag>
									<el-tag type="success"
										v-else-if="row.workId !== undefined && row.workModel.flowStatus === '170'">{{
											row.workModel.flowStatusName }}</el-tag>
									<el-tag type="danger"
										v-else-if="row.workId !== undefined && (row.workModel.flowStatus === '130' || row.workModel.flowStatus === '180' || row.workModel.flowStatus === '190')">{{
											row.workModel.flowStatusName }}</el-tag>
									<el-tag type="warning" v-else>'---'</el-tag>
								</div>
							</template>
						</el-table-column>
						<el-table-column label="操作" header-align="center" align="center" width="200px" fixed="right">
							<template #default="{ row }">
								<el-button plain type="danger" @click="handleDelete(row)"
									v-if="row.workId === '' || row.workModel.opType === '1'">删除
								</el-button>
								<el-button plain type="danger" @click="handleCancelBill(row)"
									v-if="row.workId !== '' && row.workModel.flowStatus === '170' && row.accountFlag != '1'">取消对账
								</el-button>
								<el-button plain type="success" @click="handleSubmit(row)"
									v-if="row.workId === '' || row.workModel.opType === '1'">发起
								</el-button>
								<el-button plain type="primary" @click="handleDetail(row)"
									v-if="row.workId !== ''">详情</el-button>
								<el-button plain type="info" @click="handleCancel(row)"
									v-if="row.workId !== '' && row.workModel.opType !== '1' && row.workModel.flowStatus !== '170'">撤回</el-button>
							</template>
						</el-table-column>
					</el-table>
				</el-tab-pane>
			</el-tabs>
		</el-card>

		<el-card :body-style="cardBodyStyle">
			<el-pagination :current-page="currentPage" :page-size="pageSize" :page-sizes="pageSizes" :total="totalRows"
				background="background" layout="total, sizes, prev, pager, next, jumper" @size-change="handleSizeChange"
				@current-change="handleCurrentChange">
			</el-pagination>
		</el-card>

		<el-card :body-style="cardBodyStyle">
			<el-tabs v-model="activeNameBottom" type="border-card">
				<el-tab-pane label="对账单行" name="first">
					<el-table :data="tableDataLine" border highlight-current-row :load="loadingLine">
						<!-- <el-table-column type="selection" fixed></el-table-column> -->
						<el-table-column type="index" label="序号" align="center" width="60" fixed>
							<template #default="scope">
								<span>{{ scope.$index + (currentPageLine - 1) * pageSizeLine + 1 }}</span>
							</template>
						</el-table-column>
						<el-table-column v-if="true" prop="billNo" label="对账单单号" min-width="200" header-align="center"
							align="center" show-overflow-tooltip fixed>
						</el-table-column>
						<el-table-column v-if="true" prop="billLine" label="对账单行号" min-width="100" header-align="center"
							align="center" show-overflow-tooltip fixed>
						</el-table-column>
						<el-table-column v-if="true" prop="stoInDt" label="收货日期" width="110" header-align="center"
							align="center" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="qty" label="收货重量" width="90" header-align="center"
							align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="false" prop="moistureContent" label="水分" width="100" header-align="center"
							align="center" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="qtyDry" label="干基量" width="90" header-align="center"
							align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="false" prop="uom" label="单位" width="60" header-align="center"
							align="center" show-overflow-tooltip :formatter="formatter">
						</el-table-column>
						<!-- <el-table-column v-if="true" prop="mtlExistTfe" label="TFe是否为结算项" width="140"
							header-align="center" align="right" show-overflow-tooltip :formatter="formatter">
						</el-table-column>
						<el-table-column v-if="true" prop="mtlResultTfe" label="TFe检化验结果" width="130"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlStandardTfe" label="TFe结算标准" width="110"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlPriceChangeTfe" label="TFe加减价" width="100"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlExistH2o" label="H₂O是否为结算项" width="150"
							header-align="center" align="right" show-overflow-tooltip :formatter="formatter">
						</el-table-column>
						<el-table-column v-if="true" prop="mtlResultH2o" label="H₂O检化验结果" width="130"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlStandardH2o" label="H₂O结算标准" width="120"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlPriceChangeH2o" label="H₂O加减价" width="100"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlExistFeo" label="FeO是否为结算项" width="140"
							header-align="center" align="right" show-overflow-tooltip :formatter="formatter">
						</el-table-column>
						<el-table-column v-if="true" prop="mtlResultFeo" label="FeO检化验结果" width="130"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlStandardFeo" label="FeO结算标准" width="120"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlPriceChangeFeo" label="FeO加减价" width="100"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlExistS" label="S是否为结算项" width="130" header-align="center"
							align="right" show-overflow-tooltip :formatter="formatter">
						</el-table-column>
						<el-table-column v-if="true" prop="mtlResultS" label="S检化验结果" width="110" header-align="center"
							align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlStandardS" label="S结算标准" width="100" header-align="center"
							align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlPriceChangeS" label="S加减价" width="80"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlExistP" label="P是否为结算项" width="130" header-align="center"
							align="right" show-overflow-tooltip :formatter="formatter">
						</el-table-column>
						<el-table-column v-if="true" prop="mtlResultP" label="P检化验结果" width="110" header-align="center"
							align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlStandardP" label="P结算标准" width="100" header-align="center"
							align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlPriceChangeP" label="P加减价" width="80"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlExistSio2" label="SiO₂是否为结算项" width="150"
							header-align="center" align="right" show-overflow-tooltip :formatter="formatter">
						</el-table-column>
						<el-table-column v-if="true" prop="mtlResultSio2" label="SiO₂检化验结果" width="130"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlStandardSio2" label="SiO₂结算标准" width="120"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlPriceChangeSio2" label="SiO₂加减价" width="100"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlExistAl3o2" label="Al₃O₂是否为结算项" width="160"
							header-align="center" align="right" show-overflow-tooltip :formatter="formatter">
						</el-table-column>
						<el-table-column v-if="true" prop="mtlResultAl3o2" label="Al₃O₂检化验结果" width="140"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlStandardAl3o2" label="Al₃O₂结算标准" width="130"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlPriceChangeAl3o2" label="Al₃O₂加减价" width="110"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlExistTio2" label="TiO₂是否为结算项" width="150"
							header-align="center" align="right" show-overflow-tooltip :formatter="formatter">
						</el-table-column>
						<el-table-column v-if="true" prop="mtlResultTio2" label="TiO₂检化验结果" width="130"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlStandardTio2" label="TiO₂结算标准" width="120"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlPriceChangeTio2" label="TiO₂加减价" width="100"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlExistZno" label="ZnO是否为结算项" width="150"
							header-align="center" align="right" show-overflow-tooltip :formatter="formatter">
						</el-table-column>
						<el-table-column v-if="true" prop="mtlResultZno" label="ZnO检化验结果" width="130"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlStandardZno" label="ZnO结算标准" width="120"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlPriceChangeZno" label="ZnO加减价" width="100"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlExistPbo" label="PbO是否为结算项" width="150"
							header-align="center" align="right" show-overflow-tooltip :formatter="formatter">
						</el-table-column>
						<el-table-column v-if="true" prop="mtlResultPbo" label="PbO检化验结果" width="130"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlStandardPbo" label="PbO结算标准" width="120"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlPriceChangePbo" label="PbO加减价" width="100"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlExistAs" label="As是否为结算项" width="150"
							header-align="center" align="right" show-overflow-tooltip :formatter="formatter">
						</el-table-column>
						<el-table-column v-if="true" prop="mtlResultAs" label="As检化验结果" width="130"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlStandardAs" label="As结算标准" width="120"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlPriceChangeAs" label="As加减价" width="100"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlExistMn" label="Mn是否为结算项" width="150"
							header-align="center" align="right" show-overflow-tooltip :formatter="formatter">
						</el-table-column>
						<el-table-column v-if="true" prop="mtlResultMn" label="Mn检化验结果" width="130"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlStandardMn" label="Mn结算标准" width="120"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlPriceChangeMn" label="Mn加减价" width="100"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlExistCu" label="Cu是否为结算项" width="150"
							header-align="center" align="right" show-overflow-tooltip :formatter="formatter">
						</el-table-column>
						<el-table-column v-if="true" prop="mtlResultCu" label="Cu检化验结果" width="130"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlStandardCu" label="Cu结算标准" width="120"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlPriceChangeCu" label="Cu加减价" width="100"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlExistMgo" label="MgO是否为结算项" width="150"
							header-align="center" align="right" show-overflow-tooltip :formatter="formatter">
						</el-table-column>
						<el-table-column v-if="true" prop="mtlResultMgo" label="MgO检化验结果" width="140"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlStandardMgo" label="MgO结算标准" width="120"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlPriceChangeMgo" label="MgO加减价" width="110"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlExistCao" label="CaO是否为结算项" width="150"
							header-align="center" align="right" show-overflow-tooltip :formatter="formatter">
						</el-table-column>
						<el-table-column v-if="true" prop="mtlResultCao" label="CaO检化验结果" width="130"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlStandardCao" label="CaO结算标准" width="120"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlPriceChangeCao" label="CaO加减价" width="100"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlExistK2ona2o" label="‌K₂O+Na₂O是否为结算项" width="190"
							header-align="center" align="right" show-overflow-tooltip :formatter="formatter">
						</el-table-column>
						<el-table-column v-if="true" prop="mtlResultK2ona2o" label="‌K₂O+Na₂O检化验结果" width="190"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlStandardK2ona2o" label="‌K₂O+Na₂O结算标准" width="170"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlPriceChangeK2ona2o" label="‌K₂O+Na₂O加减价" width="160"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlExistGrain" label="‌‌粒度是否为结算项" width="150"
							header-align="center" align="right" show-overflow-tooltip :formatter="formatter">
						</el-table-column>
						<el-table-column v-if="true" prop="mtlResultGrain" label="‌‌粒度检化验结果" width="130"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlStandardGrain" label="‌粒度结算标准" width="120"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="mtlPriceChangeGrain" label="‌粒度加减价" width="100"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="miscellaneousWeight" label="杂重" width="100"
							header-align="center" align="right" show-overflow-tooltip>
						</el-table-column> -->
						<el-table-column label="TFe" align="center" v-if="mtlResultTfe">
							<el-table-column v-if="true" prop="mtlExistTfe" label="是否为结算项" width="120" header-align="center"
								align="right" show-overflow-tooltip :formatter="formatter">
							</el-table-column>
							<el-table-column v-if="true" prop="mtlResultTfe" label="检化验结果" width="120" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlStandardTfe" label="结算标准" width="180" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlPriceChangeTfe" label="加减价" width="100" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
						</el-table-column>
						<el-table-column label="H₂O" align="center" v-if="mtlResultH2o">
							<el-table-column v-if="true" prop="mtlExistH2o" label="是否为结算项" width="120" header-align="center"
								align="right" show-overflow-tooltip :formatter="formatter">
							</el-table-column>
							<el-table-column v-if="true" prop="mtlResultH2o" label="检化验结果" width="120" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlStandardH2o" label="结算标准" width="180" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlPriceChangeH2o" label="加减价" width="100" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
						</el-table-column>
						<el-table-column label="FeO" align="center" v-if="mtlResultFeo">
							<el-table-column v-if="true" prop="mtlExistFeo" label="是否为结算项" width="120" header-align="center"
								align="right" show-overflow-tooltip :formatter="formatter">
							</el-table-column>
							<el-table-column v-if="true" prop="mtlResultFeo" label="检化验结果" width="120" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlStandardFeo" label="结算标准" width="180" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlPriceChangeFeo" label="加减价" width="100" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
						</el-table-column>
						<el-table-column label="S" align="center" v-if="mtlResultS">
							<el-table-column v-if="true" prop="mtlExistS" label="是否为结算项" width="120" header-align="center"
								align="right" show-overflow-tooltip :formatter="formatter">
							</el-table-column>
							<el-table-column v-if="true" prop="mtlResultS" label="检化验结果" width="120" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlStandardS" label="结算标准" width="180" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlPriceChangeS" label="加减价" width="100" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
						</el-table-column>
						<el-table-column label="P" align="center" v-if="mtlResultP">
							<el-table-column v-if="true" prop="mtlExistP" label="是否为结算项" width="120" header-align="center"
								align="right" show-overflow-tooltip :formatter="formatter">
							</el-table-column>
							<el-table-column v-if="true" prop="mtlResultP" label="检化验结果" width="120" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlStandardP" label="结算标准" width="180" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlPriceChangeP" label="加减价" width="100" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
						</el-table-column>
						<el-table-column label="SiO₂" align="center" v-if="mtlResultSio2">
							<el-table-column v-if="true" prop="mtlExistSio2" label="是否为结算项" width="120" header-align="center"
								align="right" show-overflow-tooltip :formatter="formatter">
							</el-table-column>
							<el-table-column v-if="true" prop="mtlResultSio2" label="检化验结果" width="120" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlStandardSio2" label="结算标准" width="180" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlPriceChangeSio2" label="加减价" width="100" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
						</el-table-column>
						<el-table-column label="Al₃O₂" align="center" v-if="mtlResultAl3o2">
							<el-table-column v-if="true" prop="mtlExistAl3o2" label="是否为结算项" width="120" header-align="center"
								align="right" show-overflow-tooltip :formatter="formatter">
							</el-table-column>
							<el-table-column v-if="true" prop="mtlResultAl3o2" label="检化验结果" width="120" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlStandardAl3o2" label="结算标准" width="180" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlPriceChangeAl3o2" label="加减价" width="100"
								header-align="center" align="right" show-overflow-tooltip>
							</el-table-column>
						</el-table-column>
						<el-table-column label="TiO₂" align="center" v-if="mtlResultTio2">
							<el-table-column v-if="true" prop="mtlExistTio2" label="是否为结算项" width="120" header-align="center"
								align="right" show-overflow-tooltip :formatter="formatter">
							</el-table-column>
							<el-table-column v-if="true" prop="mtlResultTio2" label="检化验结果" width="120" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlStandardTio2" label="结算标准" width="180" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlPriceChangeTio2" label="加减价" width="100" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
						</el-table-column>
						<el-table-column label="ZnO" align="center" v-if="mtlResultZno">
							<el-table-column v-if="true" prop="mtlExistZno" label="是否为结算项" width="120" header-align="center"
								align="right" show-overflow-tooltip :formatter="formatter">
							</el-table-column>
							<el-table-column v-if="true" prop="mtlResultZno" label="检化验结果" width="120" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlStandardZno" label="结算标准" width="180" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlPriceChangeZno" label="加减价" width="100" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
						</el-table-column>
						<el-table-column label="PbO" align="center" v-if="mtlResultPbo">
							<el-table-column v-if="true" prop="mtlExistPbo" label="是否为结算项" width="120" header-align="center"
								align="right" show-overflow-tooltip :formatter="formatter">
							</el-table-column>
							<el-table-column v-if="true" prop="mtlResultPbo" label="检化验结果" width="120" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlStandardPbo" label="结算标准" width="180" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlPriceChangePbo" label="加减价" width="100" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
						</el-table-column>
						<el-table-column label="As" align="center" v-if="mtlResultAs">
							<el-table-column v-if="true" prop="mtlExistAs" label="是否为结算项" width="120" header-align="center"
								align="right" show-overflow-tooltip :formatter="formatter">
							</el-table-column>
							<el-table-column v-if="true" prop="mtlResultAs" label="检化验结果" width="120" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlStandardAs" label="结算标准" width="180" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlPriceChangeAs" label="加减价" width="100" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
						</el-table-column>
						<el-table-column label="Mn" align="center" v-if="mtlResultMn">
							<el-table-column v-if="true" prop="mtlExistMn" label="是否为结算项" width="120" header-align="center"
								align="right" show-overflow-tooltip :formatter="formatter">
							</el-table-column>
							<el-table-column v-if="true" prop="mtlResultMn" label="检化验结果" width="120" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlStandardMn" label="结算标准" width="180" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlPriceChangeMn" label="加减价" width="100" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
						</el-table-column>
						<el-table-column label="Cu" align="center" v-if="mtlResultCu">
							<el-table-column v-if="true" prop="mtlExistCu" label="是否为结算项" width="120" header-align="center"
								align="right" show-overflow-tooltip :formatter="formatter">
							</el-table-column>
							<el-table-column v-if="true" prop="mtlResultCu" label="检化验结果" width="120" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlStandardCu" label="结算标准" width="180" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlPriceChangeCu" label="加减价" width="100" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
						</el-table-column>
						<el-table-column label="MgO" align="center" v-if="mtlResultMgo">
							<el-table-column v-if="true" prop="mtlExistMgo" label="是否为结算项" width="120" header-align="center"
								align="right" show-overflow-tooltip :formatter="formatter">
							</el-table-column>
							<el-table-column v-if="true" prop="mtlResultMgo" label="检化验结果" width="120" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlStandardMgo" label="结算标准" width="180" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlPriceChangeMgo" label="加减价" width="100" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
						</el-table-column>
						<el-table-column label="CaO" align="center" v-if="mtlResultCao">
							<el-table-column v-if="true" prop="mtlExistCao" label="是否为结算项" width="120" header-align="center"
								align="right" show-overflow-tooltip :formatter="formatter">
							</el-table-column>
							<el-table-column v-if="true" prop="mtlResultCao" label="检化验结果" width="120" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlStandardCao" label="结算标准" width="180" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlPriceChangeCao" label="加减价" width="100" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
						</el-table-column>
						<el-table-column label="K₂O+Na₂O" align="center" v-if="mtlResultK2ona2o">
							<el-table-column v-if="true" prop="mtlExistK2ona2o" label="‌是否为结算项" width="120"
								header-align="center" align="right" show-overflow-tooltip :formatter="formatter">
							</el-table-column>
							<el-table-column v-if="true" prop="mtlResultK2ona2o" label="检化验结果" width="120"
								header-align="center" align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlStandardK2ona2o" label="‌结算标准" width="180"
								header-align="center" align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlPriceChangeK2ona2o" label="加减价" width="100"
								header-align="center" align="right" show-overflow-tooltip>
							</el-table-column>
						</el-table-column>
						<el-table-column label="‌粒度" align="center" v-if="mtlResultGrain">
							<el-table-column v-if="true" prop="mtlExistGrain" label="‌是否为结算项" width="120" header-align="center"
							align="right" show-overflow-tooltip :formatter="formatter">
							</el-table-column>
							<el-table-column v-if="true" prop="mtlResultGrain" label="‌检化验结果" width="120" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlStandardGrain" label="结算标准" width="180" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
							<el-table-column v-if="true" prop="mtlPriceChangeGrain" label="加减价" width="100" header-align="center"
								align="right" show-overflow-tooltip>
							</el-table-column>
						</el-table-column>	
						<el-table-column v-if="miscellaneousWeight" prop="miscellaneousWeight" label="杂重" width="100" header-align="center"
							align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="accountQty" label="结算重量" width="90" header-align="center"
							align="right" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="taxPrice" label="合同含税单价" width="120" header-align="center"
								align="center" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="accountUnitTaxPrice" label="结算含税单价" width="120" header-align="center"
							align="center" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="accountTaxAmount" label="结算含税金额" width="120" header-align="center"
							align="center" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="price" label="合同单价" width="120" header-align="center"
							align="center" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="accountUnitPrice" label="结算单价" width="120" header-align="center"
							align="center" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="accountAmount" label="结算金额" width="120" header-align="center"
							align="center" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="itemCd" label="物料编码" width="150" header-align="center" align="center"
							show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="itemNm" label="物料名称" width="120" header-align="center" align="center"
							show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="tradePartnerCode" label="供应商编码" width="150" header-align="center"
							align="center" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="tradePartnerName" label="供应商名称" width="200" header-align="center"
							align="center" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="purOrdNo" label="采购订单号" width="200" header-align="center"
							align="center" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="purOrdLn" label="采购订单行号" width="120" header-align="center"
							align="center" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="contrNo" label="合同编号" width="120" header-align="center" align="center"
							show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="contrNoLine" label="合同行号" width="90" header-align="center"
							align="center" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="khContrNo" label="对方合同编号" width="120" header-align="center"
							align="center" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="true" prop="syiNo" label="检化验组批号" width="150" header-align="center"
							align="center" show-overflow-tooltip>
						</el-table-column>
						<el-table-column v-if="false" prop="carNo" label="车号" width="120" header-align="center"
							align="center" show-overflow-tooltip>
						</el-table-column>

						<!--     <el-table-column label="操作" header-align="center" align="center" width="200px">
							<template #default="scope">
								<el-button plain type="warning" @click="handleEdit(scope.row)">编辑</el-button>
								<el-button plain type="danger" @click="handleDelete(scope.row )">删除</el-button>
							</template>
						</el-table-column> -->
					</el-table>
				</el-tab-pane>
			</el-tabs>
		</el-card>

		<el-card :body-style="cardBodyStyle">
			<el-pagination :current-page="currentPageLine" :page-size="pageSizeLine" :page-sizes="pageSizesLine"
				:total="totalRowsLine" background="background" layout="total, sizes, prev, pager, next, jumper"
				@size-change="handleSizeChangeLine" @current-change="handleCurrentChangeLine">
			</el-pagination>
		</el-card>

		<el-dialog fullscreen class="diaClass" :close-on-click-modal="false" draggable title="新增"
			v-model="dialogVisibleAct" @open="openDialogAct" @close="closeDialogAct">
			<el-card class="box-card">
				<el-form :model="formAct" label-width="110px" label-position="right" inline ref="ruleFormRefAct"
					:rules="rulesAct">
					<el-row>
						<el-col :span="6">
							<el-form-item label="结算单号">
								<el-input v-model="formAct.accountNo" clearable style="width: 220px"
									disabled></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="6">
							<el-form-item label="合同号" prop="contrNo">
								<el-input v-model="formAct.contrNo" clearable style="width: 220px" disabled></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="6">
							<el-form-item label="对方合同号">
								<el-input v-model="formAct.khContrNo" clearable style="width: 220px"
									disabled></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="6">
							<el-form-item label="供应商名称" prop="tradePartnerName">
								<el-input v-model="formAct.tradePartnerName" clearable style="width: 220px"
									disabled></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="6">
							<el-form-item label="供应商编号">
								<el-input v-model="formAct.tradePartnerCode" clearable style="width: 220px"
									disabled></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="6">
							<el-form-item label="发票编号">
								<el-input v-model="formAct.invoiceNo" clearable style="width: 220px"
									disabled></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="6">
							<el-form-item label="发票号码" prop="invoiceNum">
								<el-input v-model="formAct.invoiceNum" clearable style="width: 220px"></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="6">
							<el-form-item label="发票张数" prop="invoiceCnt">
								<el-input v-model="formAct.invoiceCnt" clearable style="width: 220px"></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="6">
							<el-form-item label="发票日期" prop="invoiceDate">
								<el-date-picker v-model="formAct.invoiceDate" type="date" style="width: 220px;"
									value-format="YYYY-MM-DD" format="YYYY-MM-DD"></el-date-picker>
							</el-form-item>
						</el-col>
						<el-col :span="6">
							<el-form-item label="发票金额" prop="invoiceAmount">
								<el-input-number v-model="formAct.invoiceAmount" :precision="2" :step="0.1"
									controls-position="right" clearable style="width: 220px"></el-input-number>
							</el-form-item>
						</el-col>
						<el-col :span="6">
							<el-form-item label="合同单价">
								<el-input v-model="formAct.contrPrice" clearable style="width: 220px"></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="6">
							<el-form-item label="合同含税单价">
								<el-input v-model="formAct.contrTaxPrice" clearable style="width: 220px"></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="6">
							<el-form-item label="运输方式">
								<el-select v-model="formAct.transportMth" placeholder="请选择" clearable
									style="width: 220px">
									<el-option key="汽运自提" label="汽运自提" value="汽运自提" />
									<el-option key="送货到厂" label="送货到厂" value="送货到厂" />
								</el-select>
							</el-form-item>
						</el-col>
						<el-col :span="6">
							<el-form-item label="付款方式">
								<el-select v-model="formAct.payMth" placeholder="请选择" clearable style="width: 220px">
									<el-option v-for="item in dicList.COM_PAY_MTH" :key="item.dicCode"
										:label="item.dicName" :value="item.dicCode" />
								</el-select>
							</el-form-item>
						</el-col>
						<el-col :span="6">
							<el-form-item label="结算依据">
								<el-select v-model="formAct.actBasis" placeholder="请选择" clearable style="width: 220px">
									<el-option key="手动输入" label="手动输入" value="手动输入" />
								</el-select>
							</el-form-item>
						</el-col>
						<el-col :span="6">
							<el-form-item label="结算方式">
								<el-select v-model="formAct.actMth" placeholder="请选择" clearable style="width: 220px">
									<el-option key="分批办理" label="分批办理" value="分批办理" />
								</el-select>
							</el-form-item>
						</el-col>
						<el-col :span="6">
							<el-form-item label="结算数量">
								<el-input-number v-model="formAct.actQty" :precision="2" :step="0.1"
									controls-position="right" clearable style="width: 220px" disabled></el-input-number>
							</el-form-item>
						</el-col>
						<el-col :span="6">
							<el-form-item label="不含税金额合计">
								<el-input-number v-model="formAct.totalAmountExcludeTax" :precision="2" :step="0.1"
									controls-position="right" clearable style="width: 220px" disabled></el-input-number>
							</el-form-item>
						</el-col>
						<el-col :span="6">
							<el-form-item label="税率" prop="taxRate">
								<el-select v-model="formAct.taxRate" placeholder="请选择" clearable style="width: 220px">
									<el-option v-for="item in dicList.TAX_RATE" :key="item.dicCode"
										:label="item.dicName" :value="item.dicCode" />
								</el-select>
							</el-form-item>
						</el-col>
						<el-col :span="6">
							<el-form-item label="计算税率">
								<el-input-number v-model="formAct.taxRateCal" style="width: 220px" :precision="2"
									:step="0.1" controls-position="right" disabled></el-input-number>
							</el-form-item>
						</el-col>
						<el-col :span="6">
							<el-form-item label="税额">
								<el-input-number v-model="formAct.tax" :precision="2" :step="0.1"
									controls-position="right" clearable style="width: 220px" disabled></el-input-number>
							</el-form-item>
						</el-col>
						<el-col :span="6">
							<el-form-item label="起止日期">
								<el-date-picker v-model="glDate" type="daterange" value-format="YYYY-MM-DD"
									format="YYYY-MM-DD" clearable style="max-width: 200px"></el-date-picker>
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="备注">
								<el-input type="textarea" v-model="formAct.description" clearable
									style="width: 585px"></el-input>
							</el-form-item>
						</el-col>
					</el-row>
				</el-form>
			</el-card>

			<el-card class="box-card" v-if="true" style="margin-top: 10px;">
				<el-table :data="tableDataActLine" border highlight-current-row>
					<!-- <el-table-column type="selection" fixed></el-table-column> -->
					<el-table-column type="index" label="序号" align="center" width="60" fixed>
						<template #default="scope">
							<span>{{ scope.$index + (currentPageActLine - 1) * pageSizeActLine + 1 }}</span>
						</template>
					</el-table-column>
					<el-table-column v-if="true" prop="accountNo" label="结算单号" width="200" header-align="center"
						align="center" show-overflow-tooltip fixed>
					</el-table-column>
					<el-table-column v-if="true" prop="accountLine" label="结算单行号" width="100" header-align="center"
						align="right" show-overflow-tooltip fixed>
					</el-table-column>
					<el-table-column v-if="true" prop="itemCd" label="物料编码" width="150" header-align="center"
						align="center" show-overflow-tooltip>
					</el-table-column>
					<el-table-column v-if="true" prop="itemNm" label="物料名称" width="100" header-align="center"
						align="center" show-overflow-tooltip>
					</el-table-column>
					<el-table-column v-if="true" prop="quantityInvoiced" label="发票匹配接收数量(对应入库量)" width="250"
						header-align="center" align="right" show-overflow-tooltip>
					</el-table-column>
					<el-table-column v-if="true" prop="quantityAccount" label="结算量" width="100" header-align="center"
						align="right" show-overflow-tooltip>
					</el-table-column>
					<el-table-column v-if="true" prop="unit" label="计量单位" width="100" header-align="center"
						align="center" show-overflow-tooltip :formatter="formatter">
					</el-table-column>
					<el-table-column v-if="true" prop="unitPrice" label="单价" width="150" header-align="center"
						align="right" show-overflow-tooltip>
					</el-table-column>
					<el-table-column v-if="true" prop="amount" label="行金额" width="150" header-align="center"
						align="right" show-overflow-tooltip>
					</el-table-column>
					<el-table-column v-if="true" prop="unitTaxPrice" label="含税单价" width="150" header-align="center"
						align="right" show-overflow-tooltip>
					</el-table-column>
					<el-table-column v-if="true" prop="taxAmount" label="行含税金额" width="150" header-align="center"
						align="right" show-overflow-tooltip>
					</el-table-column>
					<el-table-column v-if="true" prop="purOrdNo" label="订单号" width="200" header-align="center"
						align="center" show-true-tooltip>
					</el-table-column>
					<el-table-column v-if="true" prop="purOrdLn" label="订单行号" width="100" header-align="center"
						align="right" show-overflow-tooltip>
					</el-table-column>
					<el-table-column v-if="true" prop="billNo" label="对账单号" width="100" header-align="center"
						align="center" show-overflow-tooltip>
					</el-table-column>
					<el-table-column v-if="true" prop="billLine" label="对账单行号" width="150" header-align="center"
						align="center" show-overflow-tooltip>
					</el-table-column>
					<el-table-column v-if="true" prop="contractNo" label="合同号" width="200" header-align="center"
						align="center" show-overflow-tooltip>
					</el-table-column>
					<el-table-column v-if="false" prop="taxRate" label="税率" width="100" header-align="center"
						align="right" show-overflow-tooltip :formatter="formatter">
					</el-table-column>
					<el-table-column v-if="true" prop="description" label="备注" width="120" header-align="center"
						align="center" show-overflow-tooltip>
					</el-table-column>
				</el-table>
			</el-card>
			<template #footer>
				<div class="dialog-footer">
					<el-button type="success" @click="handleSaveAct(ruleFormRefAct)">保存</el-button>
					<el-button type="danger" @click="handleCancelSaveAct">取消</el-button>
					<!-- <el-button type="info" @click="handleCancelSaveAct">关闭</el-button> -->
				</div>
			</template>
		</el-dialog>
	</div>
</template>

<script setup>
import ButtonBar from '@/components/ButtonBar.vue'

import {
	ref,
	reactive,
	onMounted,
	getCurrentInstance
} from 'vue'

const {
	proxy
} = getCurrentInstance()

import tools from '@/tools'
import { workflowSubmit, workflowCancel } from "@/tools/workflow.js"

const cardBodyStyle = ref(tools.style.card)
const inputStyle = ref(tools.style.input)

onMounted(() => {
	getDictList()
	handleSearch()
})

/**
 * 查询公司代码
 */
const userId = window.localStorage.getItem('userId')
const userCode = window.localStorage.getItem('userCode')
const userName = window.localStorage.getItem('userDesc')
const dept = JSON.parse(window.localStorage.getItem('dept'))
const deptTree = JSON.parse(window.localStorage.getItem('deptTree'))
/**
 * 查询公司代码
 */


/**
 *  查询字典
 */
const dicList = ref({
	COM_PAY_MTH: [],
	TAX_RATE: [],
	MEASURING_UNIT: []
})
const getDictList = () => {
	var url = 'framework/Common/querySelectorList'
	var param = {
		type: JSON.stringify(['COM_PAY_MTH', 'TAX_RATE', 'MEASURING_UNIT'])
	}
	proxy.$axios.get(url, param).then(response => {
		if (response.data.code == '0') {
			dicList.value = response.data.data
		} else {
			ElMessage.error('操作失败！' + response.data.msg)
		}
	})
}
/**
 *  查询字典
 */

const formatter = (row, column, cellValue, index) => {
	if (!cellValue || cellValue == null || cellValue == '') {
		return cellValue
	}
	switch (column.property) {
		case 'stoInDt':
			cellValue = cellValue ? cellValue.split(' ')[0] : ''
			break
		case 'mtlExistTfe':
			cellValue = cellValue != '' && cellValue === '1' ? '是' : '否'
			break
		case 'mtlExistH2o':
			cellValue = cellValue != '' && cellValue === '1' ? '是' : '否'
			break
		case 'mtlExistFeo':
			cellValue = cellValue != '' && cellValue === '1' ? '是' : '否'
			break
		case 'mtlExistS':
			cellValue = cellValue != '' && cellValue === '1' ? '是' : '否'
		case 'mtlExistP':
			cellValue = cellValue != '' && cellValue === '1' ? '是' : '否'
			break
		case 'mtlExistSio2':
			cellValue = cellValue != '' && cellValue === '1' ? '是' : '否'
			break
		case 'mtlExistAl3o2':
			cellValue = cellValue != '' && cellValue === '1' ? '是' : '否'
			break
		case 'mtlExistTio2':
			cellValue = cellValue != '' && cellValue === '1' ? '是' : '否'
			break
		case 'mtlExistZno':
			cellValue = cellValue != '' && cellValue === '1' ? '是' : '否'
			break
		case 'mtlExistPbo':
			cellValue = cellValue != '' && cellValue === '1' ? '是' : '否'
			break
		case 'mtlExistAs':
			cellValue = cellValue != '' && cellValue === '1' ? '是' : '否'
			break
		case 'mtlExistMn':
			cellValue = cellValue != '' && cellValue === '1' ? '是' : '否'
			break
		case 'mtlExistCu':
			cellValue = cellValue != '' && cellValue === '1' ? '是' : '否'
			break
		case 'mtlExistMgo':
			cellValue = cellValue != '' && cellValue === '1' ? '是' : '否'
			break
		case 'mtlExistCao':
			cellValue = cellValue != '' && cellValue === '1' ? '是' : '否'
			break
		case 'mtlExistK2ona2o':
			cellValue = cellValue != '' && cellValue === '1' ? '是' : '否'
			break
		case 'mtlExistGrain':
			cellValue = cellValue != '' && cellValue === '1' ? '是' : '否'
			break
		case 'uom':
			cellValue = dicList.value.MEASURING_UNIT.find(item => item.dicCode == cellValue)?.dicName
			break
		case 'unit':
			cellValue = dicList.value.MEASURING_UNIT.find(item => item.dicCode == cellValue)?.dicName
			break
		case 'taxRate':
			cellValue = dicList.value.TAX_RATE.find(item => item.dicCode == cellValue)?.dicName
			break
		case 'accountFlag':
			cellValue = cellValue === '1' ? '是' : '否'
			break
	}

	return cellValue
}


/**
 *   查询
 */
const query = ref({
	billNo: '',
	tradePartnerName: '',
	contrNo: '',
	khContrNo: ''
})
const activeNameTop = ref('master')
const tableData = ref([])
const handleSearch = () => {
	tableDataLine.value = []
	currentPage.value = 1
	getTableData()
}
const getTableData = () => {
	// tableData.value = []

	var url = 'pur/BillHead/query'
	var param = {
		page: currentPage.value,
		rows: pageSize.value,
		params: JSON.stringify(query.value)
	}
	proxy.$axios.get(url, param).then(response => {
		if (response.data.code == '0') {
			tableData.value = response.data.data.records
			totalRows.value = response.data.data.total
		} else {
			ElMessage.error('操作失败！' + response.data.msg)
		}
	})
}
/**
 *   查询
 */

/**
 * 分页
 */
const currentPage = ref(1)
const totalRows = ref(0)
const pageSizes = ref([5, 10, 20, 30, 40])
const pageSize = ref(5)
const handleSizeChange = (val) => {
	pageSize.value = val
	getTableData()
}
const handleCurrentChange = (val) => {
	currentPage.value = val
	getTableData()
}
/**
 * 分页
 */


/**
 * 取消对账单
 */
const handleDelete = (row) => {
	ElMessageBox.confirm(
		'确定取消本条对账单?',
		'提示', {
		confirmButtonText: '确认',
		cancelButtonText: '取消',
		type: 'warning',
		draggable: true,
	}).then(() => {
		var url = 'pur/BillHead/remove'
		var param = {
			id: row.id
		}
		proxy.$axios.post(url, param).then(response => {
			if (response.data.code == 0) {
				ElMessage({
					type: 'success',
					message: '取消成功',
				})
				tableDataLine.value = []
				getTableData()
			} else {
				ElMessage({
					type: 'error',
					message: '取消失败' + response.data.msg
				});
			}
		});
	}).catch(() => {
		ElMessage({
			type: 'info',
			message: '已取消',
		})
	})
}

const handleCancelBill = (row) => {


	ElMessageBox.confirm(
		'确定取消本条对账单?',
		'提示', {
		confirmButtonText: '确认',
		cancelButtonText: '取消',
		type: 'warning',
		draggable: true,
	}).then(() => {
		var url = 'pur/BillHead/cancel'
		var param = {
			id: row.id
		}
		proxy.$axios.post(url, param).then(response => {
			if (response.data.code == 0) {
				ElMessage({
					type: 'success',
					message: '取消成功',
				})
				tableDataLine.value = []
				getTableData()
			} else {
				ElMessage({
					type: 'error',
					message: '取消失败' + response.data.msg
				});
			}
		});
	}).catch(() => {
		ElMessage({
			type: 'info',
			message: '已取消',
		})
	})
}

/**
 * 导出
 */
const multipleSelection = ref([])
const handleSelectionChange = (val) => {
	multipleSelection.value = val
}
const handleExport = () => {
	if (multipleSelection.value.length !== 1) {
		ElMessage({
			type: 'warning',
			message: '请选择要一条导出的数据!'
		})
		return
	}

	location.href = import.meta.env.VITE_BASE_API +
		'/pur/BillLine/export?billNo=' + encodeURIComponent(multipleSelection.value[0].billNo)
}


/**
* 工作流相关
*/
const flowId = ref('purBillFinance')
const handleSubmit = (row) => {
	ElMessageBox.confirm(
		'确定提交审批?',
		'提示', {
		confirmButtonText: '确认',
		cancelButtonText: '取消',
		type: 'warning',
		draggable: true,
	}).then(() => {
		let variables = {
			id: row.id,
		}
		return workflowSubmit(
			flowId.value,
			'采购对账单流程',
			'初始化提交',
			JSON.stringify(variables),
			row.workId,
			row.trackId)
	}).then((result) => {
		if (result.status === 'success') {
			// 将结果返回的workId和trackId保存
			var url = 'pur/BillHead/saveProcessInfo'
			var process = {
				'id': row.id,
				'workId': result.workId,
				'trackId': result.trackId,
			}
			var param = {
				json: JSON.stringify(process),
			}
			proxy.$axios.post(url, param).then(response => {
				if (response.data.code === 0) {
					ElMessage({
						type: 'success',
						message: '提交审批成功',
					})
					getTableData()
				}
			})
		}
		else {
			ElMessage({
				type: 'error',
				message: '提交审批失败' + result.msg
			});
		}
	}).catch(() => {
		ElMessage({
			type: 'info',
			message: '已取消提交',
		})
	})
}

const handleCancel = (row) => {
	ElMessageBox.confirm(
		'确定撤回审批?',
		'提示', {
		confirmButtonText: '确认',
		cancelButtonText: '取消',
		type: 'warning',
		draggable: true,
	}).then(() => {
		return workflowCancel(row.workId, row.trackId);
	}).then((result) => {
		if (result.status === 'success') {
			ElMessage({
				type: 'success',
				message: '撤回审批成功',
			})
			getTableData()
		} else {
			ElMessage({
				type: 'error',
				message: '撤回审批失败' + result.msg
			})
		}
	}).catch(() => {
		ElMessage({
			type: 'info',
			message: '已取消撤回',
		})
	})
}

const handleDetail = (row) => {
	if (row.workId === null) {
		ElMessage({
			type: 'info',
			message: '无法查看',
		})
	} else {

		sessionStorage.setItem('workflowQuery', JSON.stringify({
			flowId: flowId.value,
			workId: row.workId,
			trackId: row.trackId,
			date: new Date().getTime()
		}))

		proxy.$router.push({
			path: '/workflow/detail',
		})
	}
}

/**
 *   查询 —— 对账单行
 */
const queryLine = ref({
	billNo: ''
})
const activeNameBottom = ref('first')
const loadingLine = ref(false)
const tableDataLine = ref([])
const DoubleClick = (row) => {
	queryLine.value.billNo = row.billNo
	getTableDataLine()
}

const mtlResultTfe = ref(true)
const mtlResultH2o = ref(true)
const mtlResultFeo = ref(true)
const mtlResultS = ref(true)
const mtlResultP = ref(true)
const mtlResultSio2 = ref(true)
const mtlResultAl3o2 = ref(true)
const mtlResultTio2 = ref(true)
const mtlResultZno = ref(true)
const mtlResultPbo = ref(true)
const mtlResultAs = ref(true)
const mtlResultMn = ref(true)
const mtlResultCu = ref(true)
const mtlResultMgo = ref(true)
const mtlResultCao = ref(true)
const mtlResultK2ona2o = ref(true)
const mtlResultGrain = ref(true)
const miscellaneousWeight = ref(true)
const getTableDataLine = () => {
	loadingLine.value = true
	//tableDataLine.value = []

	var url = 'pur/BillLine/query'
	var param = {
		page: currentPageLine.value,
		rows: pageSizeLine.value,
		params: JSON.stringify(queryLine.value)
	}
	proxy.$axios.get(url, param).then(response => {
		loadingLine.value = false
		tableDataLine.value = response.data.data.records
		totalRowsLine.value = response.data.data.total

		mtlResultTfe.value = false
		mtlResultH2o.value = false
		mtlResultFeo.value = false
		mtlResultS.value = false
		mtlResultP.value = false
		mtlResultSio2.value = false
		mtlResultAl3o2.value = false
		mtlResultTio2.value = false
		mtlResultZno.value = false
		mtlResultPbo.value = false
		mtlResultAs.value = false
		mtlResultMn.value = false
		mtlResultCu.value = false
		mtlResultMgo.value = false
		mtlResultCao.value = false
		mtlResultK2ona2o.value = false
		mtlResultGrain.value = false
		miscellaneousWeight.value = false
		tableData.value.forEach(item => {
			if(!mtlResultTfe.value && item.mtlResultTfe != '') {
				
				mtlResultTfe.value = true
				console.log(mtlResultTfe.value)
			}
			if(!mtlResultH2o.value && item.mtlResultH2o != '') {
				mtlResultH2o.value = true
			}
			if(!mtlResultFeo.value && item.mtlResultFeo != '') {
				mtlResultFeo.value = true
			}
			if(!mtlResultS.value && item.mtlResultS != '') {
				mtlResultS.value = true
			}
			if(!mtlResultP.value && item.mtlResultP != '') {
				mtlResultP.value = true
			}
			if(!mtlResultSio2.value && item.mtlResultSio2 != '') {
				mtlResultSio2.value = true
			}
			if(!mtlResultAl3o2.value && item.mtlResultAl3o2 != '') {
				mtlResultAl3o2.value = true
			}
			if(!mtlResultTio2.value && item.mtlResultTio2 != '') {
				mtlResultTio2.value = true
			}
			if(!mtlResultZno.value && item.mtlResultZno != '') {
				mtlResultZno.value = true
			}
			if(!mtlResultPbo.value && item.mtlResultPbo != '') {
				mtlResultPbo.value = true
			}
			if(!mtlResultAs.value && item.mtlResultAs != '') {
				mtlResultAs.value = true
			}
			if(!mtlResultMn.value && item.mtlResultMn != '') {
				mtlResultMn.value = true
			}
			if(!mtlResultCu.value && item.mtlResultCu != '') {
				mtlResultCu.value = true
			}
			if(!mtlResultMgo.value && item.mtlResultMgo != '') {
				mtlResultMgo.value = true
			}
			if(!mtlResultCao.value && item.mtlResultCao != '') {
				mtlResultCao.value = true
			}
			if(!mtlResultK2ona2o.value && item.mtlResultK2ona2o != '') {
				mtlResultK2ona2o.value = true
			}
			if(!mtlResultGrain.value && item.mtlResultGrain != '') {
				mtlResultGrain.value = true
			}
			if(!miscellaneousWeight.value && item.miscellaneousWeight != '') {
				miscellaneousWeight.value = true
			}
		})
	})
}
/**
 *   查询
 */


/**
  * 分页
  */
const currentPageLine = ref(1)
const totalRowsLine = ref(0)
const pageSizesLine = ref([5, 10, 20, 30, 40])
const pageSizeLine = ref(5)
const handleSizeChangeLine = (val) => {
	pageSizeLine.value = val
	getTableDataLine()
}
const handleCurrentChangeLine = (val) => {
	currentPageLine.value = val
	getTableDataLine()
}
/**
  * 分页
  */
const formAct = ref({
	compCd: '',
	compNm: '',
	accountNo: '',
	tradePartnerCode: '',
	tradePartnerName: '',
	tradePartnerId: '',
	invoiceNo: '',
	invoiceCnt: '',
	invoiceType: '',
	invoiceDate: '',
	invoiceAmount: null,
	invoiceCurrency: '',
	exchangeRate: '',
	exchangeDate: '',
	description: '',
	glDateBegin: '',
	glDateEnd: '',
	totalAmountExcludeTax: null,
	contrNo: '',
	khContrNo: '',
	invoiceNum: '',
	taxRateCode: '',
	taxRateCal: null,
	tax: null,
	taxRate: '',
	transportMth: '',
	payMth: '',
	actBasis: '',
	actMth: '',
	actQty: null,
	contrPrice: '',
	contrTaxPrice: '',
	addId: '',
	addCode: '',
	addName: '',
	addDeptId: '',
	addDeptCode: '',
	addDeptName: '',
	addTime: '',
	modifyCode: '',
	modifyName: '',
})
const ruleFormRefAct = ref()
const rulesAct = reactive({
	contrNo: [{
		required: true,
		message: '请输入合同号',
		trigger: 'change' | 'blur'
	}],
	tradePartnerName: [{
		required: true,
		message: '请输入供应商名称',
		trigger: 'change' | 'blur'
	}],
	invoiceNum: [{
		required: true,
		message: '请输入发票号码',
		trigger: 'change' | 'blur'
	}],
	invoiceCnt: [{
		required: true,
		message: '请输入发票张数',
		trigger: 'change' | 'blur'
	}],
	invoiceDate: [{
		required: true,
		message: '请输入发票日期',
		trigger: 'change' | 'blur'
	}],
	invoiceAmount: [{
		required: true,
		message: '请输入发票金额',
		trigger: 'change' | 'blur'
	}],
	taxRate: [{
        required: true,
        message: '请输入税率',
        trigger: 'change' | 'blur'
    }],
})
const handleAddAct = () => {
	if (window.localStorage.getItem('deptTree') == JSON.stringify(new Array())) {
		ElMessage({
			type: 'warning',
			message: '请添加登录人所在公司'
		})
		return
	}

	if (multipleSelection.value.length < 1) {
		ElMessage({
			type: 'warning',
			message: '请选择要生成结算单的数据!'
		})
		return
	}

	const flag1 = multipleSelection.value.find(item => item.accountFlag === '1')
	if (flag1) {
		ElMessage({
			type: 'warning',
			message: '未进行结算的对账单才能参与结算!'
		})
		return
	}

	const flag2 = multipleSelection.value.find(item => item.processInstanceStatus !== '170')
	if (flag2) {
		ElMessage({
			type: 'warning',
			message: '流程状态为生效的对账单才能参与结算!'
		})
		return
	}

	const first = multipleSelection.value[0]
	const isContrNo = multipleSelection.value.every(item => item.contrNo === first.contrNo)
	if (!isContrNo) {
		ElMessage({
			type: 'warning',
			message: '必须是同一份合同下的对账单'
		})
		return
	}

	const isTradePartnerCode = multipleSelection.value.every(item => item.tradePartnerCode === first.tradePartnerCode)
	if (!isTradePartnerCode) {
		ElMessage({
			type: 'warning',
			message: '必须是同一供应商的对账单'
		})
		return
	}

	formAct.value = {
		compCd: deptTree[0].deptCode,
		compNm: deptTree[0].deptName,
		accountNo: '',
		tradePartnerCode: '',
		tradePartnerName: '',
		tradePartnerId: '',
		invoiceNo: '',
		invoiceCnt: '',
		invoiceType: '',
		invoiceDate: '',
		invoiceAmount: null,
		invoiceCurrency: '',
		exchangeRate: '',
		exchangeDate: '',
		description: '',
		glDateBegin: '',
		glDateEnd: '',
		totalAmountExcludeTax: null,
		contrNo: '',
		khContrNo: '',
		invoiceNum: '',
		taxRateCode: '',
		taxRateCal: null,
		tax: null,
		taxRate: '',
		transportMth: '', // 汽运自提
		payMth: '',
		actBasis: '', // 手动输入
		actMth: '', // 分批办理
		actQty: null,
		contrPrice: '',
		addId: userId,
		addCode: userCode,
		addName: userName,
		addDeptId: dept[0].id,
		addDeptCode: dept[0].deptCode,
		addDeptName: dept[0].deptName,
		addTime: '',
		modifyCode: '',
		modifyName: '',
	}
	glDate.value = []

	if (ruleFormRefAct.value) {
		ruleFormRefAct.value.resetFields();
	}

	tableDataActLine.value = []
	billNos.value = []
	multipleSelection.value.forEach((item, index) => {
		billNos.value.push(item.billNo)
	})
	getBillLines()
}
const billNos = ref([])
const billLines = ref([])
const dialogVisibleAct = ref(false)
const getBillLines = () => {
	var url = 'pur/BillLine/queryByBillNos'
	var param = {
		billNos: JSON.stringify(billNos.value)
	}

	proxy.$axios.get(url, param).then(response => {
		if (response.data.code == '0') {
			billLines.value = response.data.data
			retuBill(billLines.value)
			dialogVisibleAct.value = true
		} else {
			ElMessage.error('操作失败！' + response.data.msg)
		}
	})
}
const retuBill = (val) => {
	if (val && val.length > 0) {
		formAct.value.contrNo = val[0].contrNo
		formAct.value.khContrNo = val[0].khContrNo
		formAct.value.tradePartnerId = val[0].tradePartnerId
		formAct.value.tradePartnerCode = val[0].tradePartnerCode
		formAct.value.tradePartnerName = val[0].tradePartnerName
		formAct.value.actQty = val.reduce((sum, current) => sum + current.accountQty, 0)
		formAct.value.contrPrice = val.map(item => item.price).join('、')
		formAct.value.contrTaxPrice = val.map(item => item.taxPrice).join('、')
		formAct.value.totalAmountExcludeTax = numberToFixed(val.reduce((sum, current) => sum + current.accountAmount, 0))
		formAct.value.invoiceAmount = numberToFixed(val.reduce((sum, current) => sum + current.accountTaxAmount, 0))
		formAct.value.taxRateCal = String(Math.round(parseFloat((formAct.value.invoiceAmount / formAct.value.totalAmountExcludeTax) - 1) * 10000) / 100)
		formAct.value.tax = numberToFixed(formAct.value.invoiceAmount - formAct.value.totalAmountExcludeTax)
		let minStoInDt = null;
		let maxStoInDt = null;

		// 遍历数组，找到最小和最大的 stoInDt
		val.forEach(item => {
			if (minStoInDt === null || item.stoInDt < minStoInDt) {
				minStoInDt = item.stoInDt
			}
			if (maxStoInDt === null || item.stoInDt > maxStoInDt) {
				maxStoInDt = item.stoInDt
			}
		})
		glDate.value.push(minStoInDt)
		glDate.value.push(maxStoInDt)
		billLines.value = val
	}
}
const numberToFixed = (data) => {
	var value = Math.round(parseFloat(data) * 100) / 100;
	var d = value.toString().split(".");
	if (d.length == 1) {
		value = value.toString() + ".00";
		return value;
	}
	if (d.length > 1) {
		if (d[1].length < 2) {
			console.log(d[1])
			value = value.toString() + "0";
		}
		return value;
	}
}

const glDate = ref([])
const handleSaveAct = (ruleFormRefAct) => {
	formAct.value.glDateEnd = glDate.value[1]
	formAct.value.glDateBegin = glDate.value[0]


	ruleFormRefAct.validate((valid, fields) => {
		if (valid) {
			var url = 'pur/ActHead/save'
			var param = {
				json: JSON.stringify(formAct.value),
				json1: JSON.stringify(billLines.value),
			}
			proxy.$axios.post(url, param).then(response => {
				if (response.data.code == 0) {
					ElMessage({
						message: '保存成功',
						type: 'success',
					})
					formAct.value = response.data.data
					queryActLine.value.accountNo = formAct.value.accountNo
					getTableDataActLine()
				} else {
					ElMessage({
						message: '操作失败' + response.data.msg,
						type: 'error'
					})
				}
			})

		} else {
			console.log('error submit!', fields)
		}
	})
}
const handleCancelSaveAct = () => {
	dialogVisibleAct.value = false
}

const queryActLine = ref({
	accountNo: ''
})
const tableDataActLine = ref([])
const getTableDataActLine = () => {
	var url = 'pur/ActLine/query'
	var param = {
		page: currentPageActLine.value,
		rows: pageSizeActLine.value,
		params: JSON.stringify(queryActLine.value)
	}
	proxy.$axios.get(url, param).then(response => {
		tableDataActLine.value = response.data.data.records
		totalRowsActLine.value = response.data.data.total
	})
}

/**
 * 分页
 */
const currentPageActLine = ref(1)
const totalRowsActLine = ref(0)
const pageSizesActLine = ref([5, 10, 20, 30, 40])
const pageSizeActLine = ref(5)
const handleSizeChangeActLine = (val) => {
	pageSizeActLine.value = val
	getTableDataActLine()
}
const handleCurrentChangeActLine = (val) => {
	currentPageActLine.value = val
	getTableDataActLine()
}
/**
 * 分页
 */
</script>

<style></style>