<template>
	<div>
		<SearchBox ref="SearchBoxRef" formName="search" :formData="query" @PopupNo="PopupNo" @reset="reset"></SearchBox>

		<el-card :body-style="cardBodyStyle">
			<el-button plain type="primary" @click="handleSearch">查询</el-button>
			<el-button plain type="warning" @click="confirm" :loading="loading">生成</el-button>
			<el-button plain type="success" @click="handleSave" :disabled="saveButton">保存</el-button>
		</el-card>

		<el-card :body-style="cardBodyStyle">
			<el-table :data="tableData" border highlight-current-row @selection-change="handleSelectionChange">
				<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="false" prop="" label="ID" width="120" header-align="center" align="center"
					show-overflow-tooltip>
				</el-table-column>
				<el-table-column v-if="true" prop="stoInDt" label="收货日期" width="110" header-align="center"
					align="center" show-overflow-tooltip :formatter="formatter" fixed>
				</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>
				</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>
		</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> -->

	</div>
</template>

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

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

const {
	proxy
} = getCurrentInstance()

import tools from '@/tools'
const cardBodyStyle = ref(tools.style.card)
const inputStyle = ref(tools.style.input)

onMounted(() => {

})
import Attachment from '@/components/Attachment.vue'


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' ? '是' : '否'
			break
		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 === '1' ? '是' : '否'
			break
	}
	return cellValue
}

/**
 * 查询公司代码
 */
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 query = ref({
	stoInDt: '',
	stoInDtBegin: '',
	stoInDtEnd: '',
	contrNo: '',
	khContrNo: '',
	purOrdNo: '',
	tradePartnerName: '',
	itemNm: '',
	syiNo: '',
	
})
const tableData = ref([])
const handleSearch = () => {
	if (query.value.contrNo === '' || query.value.stoInDt === '') {
		if(query.value.contrNo === '' ) {
			ElMessage({
				type: 'warning',
				message: '合同号不能为空'
			})
		}
		if (query.value.stoInDt === '') {
			ElMessage({
				type: 'warning',
				message: '收货日期不能为空'
			})
			
		}
		return
	}
	

	currentPage.value = 1
	getTableData()
}

const getTableData = () => {
	query.value.stoInDtBegin = query.value.stoInDt[0]
	query.value.stoInDtEnd = query.value.stoInDt[1]


	var url = 'pur/StoInRecord/queryBillConfirm'
	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
			// totalRows.value = response.data.data.total
			saveButton.value = true
		} 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 dialogVisible = ref(false)
const form = ref({
	billNo: '',
	tradePartnerId: '',
	tradePartnerCode: '',
	tradePartnerName: '',
	contrNo: '',
	khContrNo: '',
	accountQty: '',
	accountAmount: '',
	accountFlag: '',
	addId: '',
	addCode: '',
	addName: '',
	addDeptId: '',
	addDeptCode: '',
	addDeptName: '',
	addTime: '',
})
const ruleFormRef = ref()
const rules = reactive({
})

const handleAdd = () => {
	form.value = {
		billNo: '',
		tradePartnerId: '',
		tradePartnerCode: '',
		tradePartnerName: '',
		contrNo: '',
		khContrNo: '',
		accountQty: '',
		accountAmount: '',
		accountFlag: '',
		addId: '',
		addCode: '',
		addName: '',
		addDeptId: '',
		addDeptCode: '',
		addDeptName: '',
		addTime: '',
	}
	dialogVisible.value = true
}
/**
 * 新增
 */


/**
 * 保存、修改、删除
 */
const refUpload = ref()

const openDialog = () => {
}

const handleSave = () => {
	if (multipleSelection.value.length < 1) {
		ElMessage({
			type: 'warning',
			message: '请选择要保存的数据'
		})
		return
	}

	if (window.localStorage.getItem('dept') == JSON.stringify(new Array())) {
		ElMessage({
			type: 'warning',
			message: '请添加登录人所在公司'
		})
		return
	}

	const deptId = dept[0].addDeptId
	const deptCode = dept[0].deptCode
	const deptName = dept[0].deptName

	const billLine = multipleSelection.value[0]
	form.value = {
		billNo: '',
		tradePartnerId: billLine.tradePartnerId,
		tradePartnerCode: billLine.tradePartnerCode,
		tradePartnerName: billLine.tradePartnerName,
		contrNo: billLine.contrNo,
		khContrNo: billLine.khContrNo,
		accountQty: '',
		accountAmount: '',
		accountFlag: '0',
		addId: userId,
		addCode: userCode,
		addName: deptId,
		addDeptId: deptCode,
		addDeptCode: deptCode,
		addDeptName: deptName,
		addTime: '',
	}

	multipleSelection.value.forEach(item => {
		item.addId = userId,
			item.addCode = userCode,
			item.addName = userName,
			item.addDeptId = deptId,
			item.addDeptCode = deptCode,
			item.addDeptName = deptName,
			item.addTime = ''
		form.value.accountAmount = Number(form.value.accountAmount) + Number(item.accountAmount)
		if (item.uom === 'dry ton') {
			form.value.accountQty = Number(form.value.accountQty) + Number(item.qty)
		} else {
			form.value.accountQty = Number(form.value.accountQty) + Number(item.qtyWet)
		}
	})

	ElMessageBox.confirm(
		'确定保存对账单?',
		'提示', {
		confirmButtonText: '确认',
		cancelButtonText: '取消',
		type: 'warning',
		draggable: true,
	}).then(() => {
		var url = 'pur/BillHead/save'
		var param = {
			json: JSON.stringify(form.value),
			json1: JSON.stringify(multipleSelection.value),
		}
		proxy.$axios.post(url, param).then(response => {
			if (response.data.code == 0) {
				ElMessage({
					message: '保存成功',
					type: 'success',
				})
				saveButton.value = true
				getTableData()
			} else {
				ElMessage({
					message: '操作失败' + response.data.msg,
					type: 'error'
				})
			}
		})
	}).catch(() => {
		ElMessage({
			type: 'info',
			message: '已取消',
		})
	})
}
const handleCancelSave = () => {
	dialogVisible.value = false
}
const handleEdit = (row) => {
	dialogVisible.value = true
	form.value = row
}

/**
 * 保存、修改、删除
 */
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 multipleSelection = ref([])
const handleSelectionChange = (val) => {
	multipleSelection.value = val
}

const loading = ref(false)
const saveButton = ref(true)
const confirm = () => {

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

	const billLine = multipleSelection.value[0]
	const flag = multipleSelection.value.find(item => item.contrNo != billLine.contrNo)
	const flag1 = multipleSelection.value.find(item => item.price == null || item.price == '')
	const flag2 = multipleSelection.value.find(item => item.taxPrice == null || item.taxPrice == '')
	if (flag || flag1 || flag2) {
			if (flag) {
			ElMessage({
				type: 'warning',
				message: '同一合同才能生成对账单！'
			})
		}

		if (flag1) {
			ElMessage({
				type: 'warning',
				message: '合同价格不能为空！'
			})
		}

		if (flag2) {
				ElMessage({
				type: 'warning',
				message: '合同含税价格不能为空！'
			})
			
		}
		return
	}

	loading.value = true

	ElMessageBox.confirm(
		'确定生成对账单?',
		'提示', {
		confirmButtonText: '确认',
		cancelButtonText: '取消',
		type: 'warning',
		draggable: true,
	}).then(() => {
		var url = 'pur/BillLine/confirm'
		var param = {
			params: JSON.stringify(query.value),
			json: JSON.stringify(multipleSelection.value),
		}
		proxy.$axios.post(url, param).then(response => {
			if (response.data.code == 0) {
				ElMessage({
					message: '生成成功',
					type: 'success',
				})
				loading.value = false
				saveButton.value = false
				tableData.value = response.data.data
				
				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
					}
				})
			} else {
				loading.value = false
				ElMessage({
					message: '操作失败' + response.data.msg,
					type: 'error'
				})
			}
		})
	}).catch(() => {
		loading.value = false
		ElMessage({
			type: 'info',
			message: '已取消',
		})
	})
}

</script>

<style></style>