<template>
	<div
		:style="{ height: heightNum + 'px!important' }"
		class="sale-details-container order-mc-bg main-container"
	>
		<div class="sale-details-btn-group">
			<!-- 顶部按钮 -->
			<toolBtn
				:btnType="btnType"
				:isDisable="isDisable"
				@actionhandel="actionhandel"
			></toolBtn>
		</div>
		<div class="sale-details-base-info">
			<img
				class="reviewIconImg"
				src="../../../assets/reviewed_ico.png"
				v-if="pagefromData.documentStatus === 'c'"
			/>
			<el-tabs style="margin-bottom: 8px" type="border-card">
				<!-- 基本信息 -->
				<el-tab-pane label="基本信息">
					<div class="base-info-form-box">
						<el-form
							:model="pagefromData"
							label-width="80px"
							ref="form"
						>
							<el-col :span="4">
								<el-form-item
									class="item-bt-s Iisshow"
									label="物料编码"
								>
									<el-input
										:disabled="isEdit"
										:maxlength="255"
										@blur="
											saleRexgu(
												pagefromData.number,
												'number'
											)
										"
										placeholder="保存时自动生成"
										v-model.trim="pagefromData.number"
									></el-input>
									<div
										:data-clipboard-text="
											pagefromData.number
										"
										@click="saleOrderCopy"
										class="copyBtn"
									>
										<i class="el-icon-document-copy" />
									</div>
								</el-form-item>
								<el-form-item
									:required="true"
									class="item-bt-s Iisshow"
									label="物料名称"
								>
									<el-input
										:disabled="isEdit"
										:maxlength="255"
										placeholder
										v-model.trim="pagefromData.name"
									></el-input>
									<div
										:data-clipboard-text="pagefromData.name"
										@click="saleOrderCopy"
										class="copyBtn"
									>
										<i class="el-icon-document-copy" />
									</div>
								</el-form-item>
								<el-form-item
									:required="true"
									class="item-bt-s Iisshow"
									label="规格型号"
								>
									<el-input
										:disabled="isEdit"
										:maxlength="255"
										placeholder
										type="textarea"
										v-model.trim="
											pagefromData.specifications
										"
									></el-input>
									<div
										:data-clipboard-text="
											pagefromData.specifications
										"
										@click="saleOrderCopy"
										class="copyBtn"
									>
										<i class="el-icon-document-copy" />
									</div>
								</el-form-item>
								<el-form-item
									:required="true"
									class="item-bt-s"
									label="单位"
								>
									<el-select
										:disabled="isUseCheck || isEdit"
										filterable
										placeholder="请选择"
										v-model="pagefromData.unitId"
									>
										<el-option
											:key="item.id"
											:label="item.name"
											:value="item.id"
											v-for="item in unitData"
											:style="{
												height: item.disable
													? '0px'
													: 'auto',
											}"
										></el-option>
									</el-select>
								</el-form-item>
							</el-col>
							<el-col :span="4">
								<el-form-item
									:required="true"
									class="item-bt-s"
									label="物料分类"
								>
									<el-cascader
										:disabled="isEdit"
										:options="mateOptions"
										:props="{
											expandTrigger: 'hover',
											value: 'id',
											label: 'name',
											children: 'chinds',
										}"
										@change="changeMaterial"
										@remove-tag="clearData"
										clearable
										ref="materialType"
										v-model="pagefromData.groupId"
									></el-cascader>
								</el-form-item>
								<el-form-item
									:required="true"
									class="item-bt-s Iisshow"
									label="成本"
								>
									<el-input
										placeholder
										v-model.trim="pagefromData.cost"
										@input="pageInputEnter($event, 'cost')"
										:disabled="isEdit"
									></el-input>
									<div
										:data-clipboard-text="pagefromData.cost"
										@click="saleOrderCopy"
										class="copyBtn"
									>
										<i class="el-icon-document-copy" />
									</div>
								</el-form-item>
								<el-form-item
									class="item-bt-s Iisshow"
									label=" &nbsp;采购价格"
								>
									<el-input
										:disabled="isEdit"
										placeholder
										v-model.trim="
											pagefromData.purchasePrice
										"
										@input="
											pageInputEnter(
												$event,
												'purchasePrice'
											)
										"
									></el-input>
									<div
										:data-clipboard-text="
											pagefromData.purchasePrice
										"
										@click="saleOrderCopy"
										class="copyBtn"
									>
										<i class="el-icon-document-copy" />
									</div>
								</el-form-item>
								<el-form-item
									:required="true"
									class="item-bt-s Iisshow"
									label="物料ID"
								>
									<el-input
										:maxlength="255"
										disabled
										placeholder="(保存时自动生成)"
										v-model.trim="pagefromData.code"
									></el-input>
									<div
										:data-clipboard-text="pagefromData.code"
										@click="saleOrderCopy"
										class="copyBtn"
									>
										<i class="el-icon-document-copy" />
									</div>
								</el-form-item>
								<el-form-item
									:required="true"
									class="item-bt-s"
									label="子单位"
								>
									<el-select
										:disabled="isUseCheck || isEdit"
										filterable
										placeholder="请选择"
										v-model="pagefromData.subUnitId"
									>
										<el-option
											:key="item.id"
											:label="item.name"
											:value="item.id"
											v-for="item in unitData"
											:style="{
												height: item.disable
													? '0px'
													: 'auto',
											}"
										></el-option>
									</el-select>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="图片(800x800)">
									<el-upload
										class="pictrueS"
										:action="upload_url"
										:before-upload="beforeUpload"
										:disabled="isEdit"
										:file-list="fileList"
										:headers="{ Authorization: reqToken }"
										:limit="1"
										:on-remove="handleRemove"
										:on-success="handleSuccess"
										:with-credentials="true"
										accept=".jpg, .png"
										list-type="picture-card"
										name="ImgByte"
									>
										<i class="el-icon-plus"></i>
									</el-upload>
								</el-form-item>
								<el-col style="margin-top: 10px">
									<el-col :span="20">
										<el-form-item
											:required="true"
											class="item-bt-s Iisshow"
											label="1单位="
										>
											<el-input
												:disabled="isUseCheck || isEdit"
												@blur="
													numberChage(
														pagefromData.subUnitMultiple
													)
												"
												:oninput="
													unitMultipleInput(
														pagefromData.subUnitMultiple
													)
												"
												placeholder
												v-model="
													pagefromData.subUnitMultiple
												"
											></el-input>
											<div
												:data-clipboard-text="
													pagefromData.subUnitMultiple
												"
												@click="saleOrderCopy"
												class="copyBtn"
											>
												<i
													class="el-icon-document-copy"
												/>
											</div>
										</el-form-item>
									</el-col>
									<el-col :span="4">
										<span
											style="
												height: 28px;
												line-height: 28px;
												padding-left: 5px;
											"
											>子单位</span
										>
									</el-col>
								</el-col>
							</el-col>
							<el-col :span="4">
								<el-form-item
									:required="true"
									class="item-bt-s"
									label="存货类别"
								>
									<el-select
										:disabled="isEdit"
										placeholder="请选择"
										v-model="pagefromData.materialType"
									>
										<el-option
											:key="index"
											:label="item.name"
											:value="item.id"
											class="f-12"
											:style="{
												height: item.disable
													? '0px'
													: 'auto',
											}"
											v-for="(
												item, index
											) in InventoryType"
										></el-option>
									</el-select>
								</el-form-item>
								<el-form-item
									class="item-bt-s"
									label="单据状态"
								>
									<el-select
										:disabled="true"
										placeholder="请选择单据状态"
										v-model="pagefromData.documentStatus"
									>
										<el-option
											:key="key + index"
											:label="value"
											:value="key"
											style="font-size: 12px"
											v-for="(
												value, key, index
											) in documentStatuslist"
										></el-option>
									</el-select>
								</el-form-item>
								<el-form-item
									class="item-bt-s"
									label="禁用状态"
								>
									<el-select
										placeholder="请选择"
										:disabled="isEdit"
										v-model="pagefromData.isDisable"
									>
										<el-option
											label="是"
											:value="true"
											class="f-12"
										></el-option>
										<el-option
											label="否"
											:value="false"
											class="f-12"
										></el-option>
									</el-select>
								</el-form-item>
							</el-col>
						</el-form>
					</div>
				</el-tab-pane>
				<!-- 操作记录 -->
				<el-tab-pane :disabled="!pagefromData.id" label="操作记录">
					<div
						:style="{ height: '185px!important' }"
						class="base-info-form-box"
					>
						<el-form
							:model="pagefromData"
							label-width="80px"
							ref="pagefromData"
						>
							<el-row :gutter="10">
								<el-col :span="4">
									<div class="div-col">
										<el-form-item
											class="item-bt-s"
											label="创建人"
										>
											<el-input
												disabled
												placeholder
												v-model.trim="
													pagefromData.createName
												"
											></el-input>
										</el-form-item>
										<el-form-item
											class="item-bt-s"
											label="创建时间"
										>
											<el-input
												disabled
												placeholder
												v-model="
													pagefromData.createDate
												"
											></el-input>
										</el-form-item>
									</div>
								</el-col>
								<el-col :span="4">
									<div class="div-col col-2">
										<el-form-item
											class="item-bt-s"
											label="最后修改人"
										>
											<el-input
												disabled
												placeholder
												v-model.trim="
													pagefromData.modifyName
												"
											></el-input>
										</el-form-item>
										<el-form-item
											class="item-bt-s"
											label="最后修改时间"
										>
											<el-input
												disabled
												placeholder
												v-model="
													pagefromData.modifyDate
												"
											></el-input>
										</el-form-item>
										<el-form-item
											class="item-bt-s"
											label="提交时间"
										>
											<el-input
												disabled
												placeholder
												v-model="
													pagefromData.commitDate
												"
											></el-input>
										</el-form-item>
									</div>
								</el-col>
								<el-col :span="4">
									<div class="div-col">
										<el-row :gutter="0">
											<el-col :span="24">
												<el-form-item
													:maxlength="50"
													class="item-bt-s"
													label="审核人"
												>
													<el-input
														disabled
														placeholder
														v-model.trim="
															pagefromData.checkName
														"
													></el-input>
												</el-form-item>
												<el-form-item
													class="item-bt-s"
													label="审核时间"
												>
													<el-input
														disabled
														placeholder
														v-model="
															pagefromData.checkDate
														"
													></el-input>
												</el-form-item>
											</el-col>
										</el-row>
									</div>
								</el-col>
								<el-col :span="4">
									<div class="div-col">
										<el-row :gutter="0">
											<el-col :span="24">
												<el-form-item
													:maxlength="50"
													class="item-bt-s"
													label="禁用人"
												>
													<el-input
														disabled
														placeholder
														v-model.trim="
															pagefromData.disableName
														"
													></el-input>
												</el-form-item>
												<el-form-item
													class="item-bt-s"
													label="禁用时间"
												>
													<el-input
														disabled
														placeholder
														v-model="
															pagefromData.disableDate
														"
													></el-input>
												</el-form-item>
											</el-col>
										</el-row>
									</div>
								</el-col>
								<el-col :span="4"></el-col>
								<el-col :span="4"></el-col>
							</el-row>
						</el-form>
					</div>
				</el-tab-pane>
			</el-tabs>
		</div>
		<div class="sale-details-base-info" style="400px;">
			<el-tabs
				@tab-click="handleClick(activeName)"
				style="margin-bottom: 8px"
				type="border-card"
				v-model="activeName"
			>
				<!-- 组织信息 -->
				<el-tab-pane label="组织信息" name="org">
					<div class="org-info-form-box">
						<!-- 明细工具栏 -->
						<div class="tell-info-button-group">
							<DetailsOperation
								:detailBtn="detailBtn"
								:deviationSelectArr="selectRowIndexArr"
								@copyCellcolumn="copyCellcolumn"
								@copyRow="bottomCopyRow"
								@deleteRow="selectDeleteRow"
								@insertObj="getInsertInfo"
							></DetailsOperation>
						</div>
					</div>
					<!-- 表格信息-->
					<div class="tell-info-table">
						<el-table
							:cell-class-name="tableCellClassName"
							:data="pagefromData.materialOrgs"
							:header-cell-class-name="mustAfter"
							@cell-click="getRowCol"
							@select="selectRow"
							@select-all="selectAll"
							border
							max-height="400"
							ref="multipleTable"
							style="width: 70%; font-size: 12px"
						>
							<el-table-column
								:disabled="isEdit"
								align="center"
								fixed
								type="selection"
								width="40"
							/>
							<el-table-column
								align="left"
								label="组织"
								prop="orgName"
							></el-table-column>
							<el-table-column
								align="left"
								prop="materialProperty"
								width="200"
							>
								<template #header>
									<span
										class="iconfont icon-bianji1 iconfont-mg"
									></span
									>物料属性
								</template>
								<template #default="scope">
									<el-select
										:disabled="isEdit"
										placeholder="请选择"
										v-if="scope.row.ismaterialPropertyshow"
										v-model="scope.row.materialProperty"
									>
										<el-option
											:key="index"
											:label="item.name"
											:value="item.id"
											@click="
												getRowCol(
													scope.row,
													scope.column,
													'materialProperty'
												)
											"
											class="f-12"
											:style="{
												height: item.disable
													? '0px'
													: 'auto',
											}"
											v-for="(
												item, index
											) in materialPropData"
										></el-option>
									</el-select>
									<span v-else>{{
										publicidbyname(
											materialPropData,
											scope.row.materialProperty
										)
									}}</span>
								</template>
							</el-table-column>
							<el-table-column
								align="left"
								prop="supplyOrgId"
								width="190"
							>
								<template #header>
									<span
										class="iconfont icon-bianji1 iconfont-mg"
									></span
									>供应组织
								</template>
								<template #default="scope">
									<el-select
										:disabled="isEdit"
										:id="'supplyOrgId' + scope.$index"
										@change="
											gyorgChange($event, scope.$index)
										"
										filterable
										placeholder="请输入关键词"
										remote
										reserve-keyword
										v-if="scope.row.issupplyOrgIdshow"
										v-model="scope.row.supplyOrgId"
									>
										<el-option
											:key="item.id"
											:label="item.name"
											:value="item.id"
											@click="
												getRowCol(
													scope.row,
													scope.column,
													'supplyOrgId'
												)
											"
											v-for="item in supplyOrglist"
											:style="{
												height: item.disable
													? '0px'
													: 'auto',
											}"
										></el-option>
									</el-select>
									<span v-else>{{
										publicidbyname(
											supplyOrglist,
											scope.row.supplyOrgId
										)
									}}</span>
								</template>
							</el-table-column>
							<el-table-column
								align="left"
								prop="supplierId"
								width="220"
							>
								<template #header>
									<span
										class="iconfont icon-bianji1 iconfont-mg"
									></span
									>默认供应商
								</template>
								<template #default="scope">
									<el-select
										:disabled="isEdit"
										:id="'supplierId' + scope.$index"
										:remote-method="
											(query) => {
												mrgysquery(query, scope.$index);
											}
										"
										@change="
											mrgysChange($event, scope.$index)
										"
										filterable
										placeholder="请输入关键词"
										remote
										reserve-keyword
										v-if="scope.row.issupplierIdshow"
										v-model="scope.row.supplierId"
									>
										<el-option
											:key="item.id + item.name"
											:label="item.name"
											:value="item.id"
											:style="{
												height: item.disable
													? '0px'
													: 'auto',
											}"
											@click="
												getRowCol(
													scope.row,
													scope.column,
													'supplierId'
												)
											"
											v-for="item in specificationlist[
												scope.$index
											]"
										></el-option>
									</el-select>
									<span v-else>{{
										publicidbyname(
											specificationlist[scope.$index],
											scope.row.supplierId
										)
									}}</span>
								</template>
							</el-table-column>
							<el-table-column
								align="left"
								prop="deliveryDay"
								width="190"
							>
								<template #header>
									<span
										class="iconfont icon-bianji1 iconfont-mg"
									></span
									>交付天数
								</template>
								<template #default="scope">
									<el-input
										:disabled="isEdit"
										:id="'deliveryDay' + scope.$index"
										:maxlength="3"
										@input="
											getRowCol(
												scope.row,
												scope.column,
												'deliveryDay'
											)
										"
										onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')"
										placeholder
										v-if="scope.row.isdeliveryDayshow"
										v-model.trim="scope.row.deliveryDay"
									></el-input>
									<span v-else>{{
										scope.row.deliveryDay
									}}</span>
								</template>
							</el-table-column>
						</el-table>
					</div>
				</el-tab-pane>
				<!-- 成品信息 -->
				<el-tab-pane label="成品信息" name="product">
					<div class="pro-info-form-box">
						<el-form
							:model="pagefromData.materialProduct"
							label-width="120px"
							ref="form"
						>
							<el-row :gutter="15">
								<el-col :span="5">
									<el-form-item
										class="item-bt-s"
										label="供应链"
									>
										<el-select
											:disabled="isEdit"
											placeholder="请选择"
											v-model="
												pagefromData.materialProduct
													.supplyChain
											"
										>
											<el-option
												:key="index"
												:label="item.name"
												:value="item.id"
												class="f-12"
												v-for="(
													item, index
												) in supplyChainType"
												:style="{
													height: item.disable
														? '0px'
														: 'auto',
												}"
											></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col :span="5">
									<el-form-item
										class="item-bt-s"
										label="是否211"
									>
										<el-select
											:disabled="isEdit"
											placeholder="请选择"
											v-model="
												pagefromData.materialProduct
													.is211
											"
										>
											<el-option
												:key="item.id"
												:label="item.name"
												:value="item.id"
												v-for="item in is211List"
											></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col :span="5">
									<el-form-item
										class="item-bt-s"
										label="是否参与211运算"
									>
										<el-select
											:disabled="isEdit"
											placeholder="请选择"
											v-model="
												pagefromData.materialProduct
													.is211Compute
											"
										>
											<el-option
												:key="item.id"
												:label="item.name"
												:value="item.id"
												v-for="item in is211List"
											></el-option>
										</el-select>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row :gutter="15">
								<el-col :span="5">
									<el-form-item
										class="item-bt-s"
										label="产品定位"
									>
										<el-select
											:disabled="isEdit"
											placeholder="请选择"
											v-model="
												pagefromData.materialProduct
													.productLocation
											"
										>
											<el-option
												:key="index"
												:label="item.name"
												:value="item.id"
												class="f-12"
												v-for="(
													item, index
												) in productLocationType"
											></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col :span="5">
									<el-form-item
										class="item-bt-s"
										label="生命周期"
									>
										<el-select
											:disabled="isEdit"
											placeholder="请选择"
											v-model="
												pagefromData.materialProduct
													.lifeCycle
											"
										>
											<el-option
												:key="index"
												:label="item.name"
												:value="item.id"
												class="f-12"
												v-for="(
													item, index
												) in lifeCycleType"
											></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col :span="5">
									<el-form-item
										class="item-bt-s"
										label="条码"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											placeholder
											v-model.trim="
												pagefromData.materialProduct
													.barCode
											"
										></el-input>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row :gutter="15">
								<el-col :span="5">
									<el-form-item
										class="item-bt-s Iisshow"
										label="品牌"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											placeholder
											v-model.trim="
												pagefromData.materialProduct
													.brand
											"
										></el-input>
										<div
											:data-clipboard-text="
												pagefromData.materialProduct
													.brand
											"
											@click="saleOrderCopy"
											class="copyBtn"
										>
											<i class="el-icon-document-copy" />
										</div>
									</el-form-item>
								</el-col>
								<el-col :span="5">
									<el-form-item
										class="item-bt-s"
										label="品牌类型"
									>
										<el-select
											:disabled="isEdit"
											placeholder="请选择"
											v-model="
												pagefromData.materialProduct
													.brandType
											"
										>
											<el-option
												:key="index"
												:label="item.name"
												:value="item.id"
												class="f-12"
												v-for="(
													item, index
												) in brandType"
											></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col :span="5">
									<el-form-item
										class="item-bt-s Iisshow"
										label="产品家族"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											placeholder
											v-model.trim="
												pagefromData.materialProduct
													.productFamily
											"
										></el-input>
										<div
											:data-clipboard-text="
												pagefromData.materialProduct
													.productFamily
											"
											@click="saleOrderCopy"
											class="copyBtn"
										>
											<i class="el-icon-document-copy" />
										</div>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row :gutter="15">
								<el-col :span="5">
									<el-form-item
										class="item-bt-s Iisshow"
										label="产品系列"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											placeholder
											v-model.trim="
												pagefromData.materialProduct
													.productSeries
											"
										></el-input>
										<div
											:data-clipboard-text="
												pagefromData.materialProduct
													.productSeries
											"
											@click="saleOrderCopy"
											class="copyBtn"
										>
											<i class="el-icon-document-copy" />
										</div>
									</el-form-item>
								</el-col>
								<el-col :span="5">
									<el-form-item
										class="item-bt-s Iisshow"
										label="产品（不含颜色）"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											placeholder
											v-model.trim="
												pagefromData.materialProduct
													.productNoColor
											"
										></el-input>
										<div
											:data-clipboard-text="
												pagefromData.materialProduct
													.productNoColor
											"
											@click="saleOrderCopy"
											class="copyBtn"
										>
											<i class="el-icon-document-copy" />
										</div>
									</el-form-item>
								</el-col>
								<el-col :span="5">
									<el-form-item
										class="item-bt-s Iisshow"
										label="产品SPU（含颜色）"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											placeholder
											v-model.trim="
												pagefromData.materialProduct
													.productSPU
											"
										></el-input>
										<div
											:data-clipboard-text="
												pagefromData.materialProduct
													.productSPU
											"
											@click="saleOrderCopy"
											class="copyBtn"
										>
											<i class="el-icon-document-copy" />
										</div>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row :gutter="15">
								<el-col :span="5">
									<el-form-item
										class="item-bt-s Iisshow"
										label="功能版本"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											placeholder
											v-model.trim="
												pagefromData.materialProduct
													.version
											"
										></el-input>
										<div
											:data-clipboard-text="
												pagefromData.materialProduct
													.version
											"
											@click="saleOrderCopy"
											class="copyBtn"
										>
											<i class="el-icon-document-copy" />
										</div>
									</el-form-item>
								</el-col>
								<el-col :span="5">
									<el-form-item
										class="item-bt-s Iisshow"
										label="性能"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											placeholder
											v-model.trim="
												pagefromData.materialProduct
													.performance
											"
										></el-input>
										<div
											:data-clipboard-text="
												pagefromData.materialProduct
													.performance
											"
											@click="saleOrderCopy"
											class="copyBtn"
										>
											<i class="el-icon-document-copy" />
										</div>
									</el-form-item>
								</el-col>
								<el-col :span="5">
									<el-form-item
										class="item-bt-s Iisshow"
										label="尺码/数量"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											@input="inputSize"
											placeholder
											v-model.trim="
												pagefromData.materialProduct
													.sizeNumber
											"
										></el-input>
										<div
											:data-clipboard-text="
												pagefromData.materialProduct
													.sizeNumber
											"
											@click="saleOrderCopy"
											class="copyBtn"
										>
											<i class="el-icon-document-copy" />
										</div>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row :gutter="15">
								<el-col :span="5">
									<el-form-item
										class="item-bt-s Iisshow"
										label="颜色"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											placeholder
											v-model.trim="
												pagefromData.materialProduct
													.color
											"
										></el-input>
										<div
											:data-clipboard-text="
												pagefromData.materialProduct
													.color
											"
											@click="saleOrderCopy"
											class="copyBtn"
										>
											<i class="el-icon-document-copy" />
										</div>
									</el-form-item>
								</el-col>
								<el-col :span="5">
									<el-form-item
										class="item-bt-s"
										label="安规"
									>
										<el-select
											:disabled="isEdit"
											placeholder="请选择"
											v-model="
												pagefromData.materialProduct
													.safety
											"
										>
											<el-option
												:key="index"
												:label="item.name"
												:value="item.id"
												class="f-12"
												v-for="(
													item, index
												) in safetyType"
											></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col :span="5">
									<el-form-item
										class="item-bt-s Iisshow"
										label="包装"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											placeholder
											v-model.trim="
												pagefromData.materialProduct
													.package
											"
										></el-input>
										<div
											:data-clipboard-text="
												pagefromData.materialProduct
													.package
											"
											@click="saleOrderCopy"
											class="copyBtn"
										>
											<i class="el-icon-document-copy" />
										</div>
									</el-form-item>
								</el-col>
							</el-row>
							<!-- 11.15-->
							<el-row :gutter="15">
								<el-col :span="5">
									<el-form-item
										class="item-bt-s"
										label="是否价格战产品"
									>
										<el-select
											:disabled="isEdit"
											placeholder="请选择"
											v-model="
												pagefromData.materialProduct
													.isPriceWar
											"
										>
											<el-option
												label="是"
												:value="true"
												class="f-12"
											></el-option>
											<el-option
												label="否"
												:value="false"
												class="f-12"
											></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col :span="5">
									<el-form-item
										class="item-bt-s"
										label="促销类型"
									>
										<el-select
											:disabled="isEdit"
											placeholder="请选择"
											v-model="
												pagefromData.materialProduct
													.salesPromotionType
											"
										>
											<el-option
												:key="index"
												:label="item.name"
												:value="item.id"
												class="f-12"
												v-for="(
													item, index
												) in salesPromotionTypelist"
											></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col :span="5">
									<el-form-item
										class="item-bt-s item-date"
										label="促销日期"
									>
										<el-date-picker
											:disabled="isEdit"
											placeholder
											v-model.trim="
												pagefromData.materialProduct
													.salesPromotionDate
											"
											format="YYYY-MM-DD"
											type="date"
											value-format="YYYY-MM-DD"
										></el-date-picker>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row :gutter="15">
								<el-col :span="5">
									<el-form-item
										class="item-bt-s"
										label="是否新品"
									>
										<el-select
											:disabled="isEdit"
											placeholder="请选择"
											v-model="
												pagefromData.materialProduct
													.isNew
											"
										>
											<el-option
												label="是"
												:value="true"
												class="f-12"
											></el-option>
											<el-option
												label="否"
												:value="false"
												class="f-12"
											></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col :span="5">
									<el-form-item
										class="item-bt-s"
										label="出厂价"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											placeholder
											@input="
												pageInputEnter(
													$event,
													'outFactoryPrice'
												)
											"
											v-model.trim="
												pagefromData.materialProduct
													.outFactoryPrice
											"
										></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="5">
									<el-form-item
										class="item-bt-s"
										label="代理价"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											placeholder
											@input="
												pageInputEnter(
													$event,
													'agentPrice'
												)
											"
											v-model.trim="
												pagefromData.materialProduct
													.agentPrice
											"
										></el-input>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row :gutter="15">
								<el-col :span="5">
									<el-form-item
										class="item-bt-s"
										label="零售指导价"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											placeholder
											@input="
												pageInputEnter(
													$event,
													'retailPrice'
												)
											"
											v-model.trim="
												pagefromData.materialProduct
													.retailPrice
											"
										></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="5">
									<el-form-item
										class="item-bt-s"
										label="最低活动价"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											placeholder
											@input="
												pageInputEnter(
													$event,
													'minPrice'
												)
											"
											v-model.trim="
												pagefromData.materialProduct
													.minPrice
											"
										></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="5">
									<el-form-item
										class="item-bt-s"
										label="海外零售指导价"
									>
										<el-input
											:disabled="isEdit"
											placeholder
											@input="
												pageInputEnter(
													$event,
													'foreignRetailPrice'
												)
											"
											v-model.trim="
												pagefromData.materialProduct
													.foreignRetailPrice
											"
										></el-input>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row :gutter="15">
								<el-col :span="5">
									<el-form-item
										class="item-bt-s"
										label="海外零售最低活动价"
									>
										<el-input
											:disabled="isEdit"
											placeholder
											@input="
												pageInputEnter(
													$event,
													'foreignRetailMinPrice'
												)
											"
											v-model.trim="
												pagefromData.materialProduct
													.foreignRetailMinPrice
											"
										></el-input>
									</el-form-item>
								</el-col>
							</el-row>
						</el-form>
					</div>
				</el-tab-pane>
				<!-- 尺寸/质量信息 -->
				<el-tab-pane label="尺寸/质量信息" name="size">
					<div class="size-info-form-box">
						<el-form
							:model="pagefromData.materialSize"
							label-width="60px"
							ref="form"
						>
							<el-row :gutter="10">
								<el-col :span="4">
									<el-form-item
										class="item-bt-s Iisshow"
										label="产品长"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											:oninput="
												(pagefromData.materialSize.productLength =
													pagefromData.materialSize
														.productLength == 0 ||
													pagefromData.materialSize
														.productLength == null
														? ''
														: pagefromData.materialSize.productLength
																.toString()
																.replace(/^0/)
																.replace(
																	/[^\d.]/g,
																	''
																)
																.replace(
																	/\.{2,}/g,
																	'.'
																)
																.replace(
																	/^\./g,
																	''
																)
																.replace(
																	'.',
																	'$#$'
																)
																.replace(
																	/\./g,
																	''
																)
																.replace(
																	'$#$',
																	'.'
																)
																.replace(
																	/^(-)*(\d+)\.(\d\d\d\d).*$/,
																	'$1$2.$3'
																))
											"
											placeholder
											v-model.trim="
												pagefromData.materialSize
													.productLength
											"
										></el-input>
										<div
											:data-clipboard-text="
												pagefromData.materialSize
													.productLength
											"
											@click="saleOrderCopy"
											class="copyBtn"
										>
											<i class="el-icon-document-copy" />
										</div>
									</el-form-item>
								</el-col>
								<el-col :span="1">
									<span class="line-28">mm</span>
								</el-col>
								<el-col :span="4">
									<el-form-item
										class="item-bt-s Iisshow"
										label="包装长"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											:oninput="
												(pagefromData.materialSize.packageLength =
													pagefromData.materialSize
														.packageLength == 0 ||
													pagefromData.materialSize
														.packageLength == null
														? ''
														: pagefromData.materialSize.packageLength
																.toString()
																.replace(/^0/)
																.replace(
																	/[^\d.]/g,
																	''
																)
																.replace(
																	/\.{2,}/g,
																	'.'
																)
																.replace(
																	/^\./g,
																	''
																)
																.replace(
																	'.',
																	'$#$'
																)
																.replace(
																	/\./g,
																	''
																)
																.replace(
																	'$#$',
																	'.'
																)
																.replace(
																	/^(-)*(\d+)\.(\d\d\d\d).*$/,
																	'$1$2.$3'
																))
											"
											placeholder
											v-model.trim="
												pagefromData.materialSize
													.packageLength
											"
										></el-input>
										<div
											:data-clipboard-text="
												pagefromData.materialSize
													.packageLength
											"
											@click="saleOrderCopy"
											class="copyBtn"
										>
											<i class="el-icon-document-copy" />
										</div>
									</el-form-item>
								</el-col>
								<el-col :span="1">
									<span class="line-28">mm</span>
								</el-col>
								<el-col :span="4">
									<el-form-item
										class="item-bt-s Iisshow"
										label="外箱长"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											:oninput="
												(pagefromData.materialSize.outerBoxLength =
													pagefromData.materialSize
														.outerBoxLength == 0 ||
													pagefromData.materialSize
														.outerBoxLength == null
														? ''
														: pagefromData.materialSize.outerBoxLength
																.toString()
																.replace(/^0/)
																.replace(
																	/[^\d.]/g,
																	''
																)
																.replace(
																	/\.{2,}/g,
																	'.'
																)
																.replace(
																	/^\./g,
																	''
																)
																.replace(
																	'.',
																	'$#$'
																)
																.replace(
																	/\./g,
																	''
																)
																.replace(
																	'$#$',
																	'.'
																)
																.replace(
																	/^(-)*(\d+)\.(\d\d\d\d).*$/,
																	'$1$2.$3'
																))
											"
											placeholder
											v-model.trim="
												pagefromData.materialSize
													.outerBoxLength
											"
										></el-input>
										<div
											:data-clipboard-text="
												pagefromData.materialSize
													.outerBoxLength
											"
											@click="saleOrderCopy"
											class="copyBtn"
										>
											<i class="el-icon-document-copy" />
										</div>
									</el-form-item>
								</el-col>
								<el-col :span="1">
									<span class="line-28">mm</span>
								</el-col>
								<el-col :span="4">
									<el-form-item
										class="item-bt-s Iisshow"
										label="装箱毛重"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											:oninput="
												(pagefromData.materialSize.boxingWeight =
													pagefromData.materialSize
														.boxingWeight == 0 ||
													pagefromData.materialSize
														.boxingWeight == null
														? ''
														: pagefromData.materialSize.boxingWeight
																.toString()
																.replace(/^0/)
																.replace(
																	/[^\d.]/g,
																	''
																)
																.replace(
																	/\.{2,}/g,
																	'.'
																)
																.replace(
																	/^\./g,
																	''
																)
																.replace(
																	'.',
																	'$#$'
																)
																.replace(
																	/\./g,
																	''
																)
																.replace(
																	'$#$',
																	'.'
																)
																.replace(
																	/^(-)*(\d+)\.(\d\d\d\d).*$/,
																	'$1$2.$3'
																))
											"
											placeholder
											v-model.trim="
												pagefromData.materialSize
													.boxingWeight
											"
										></el-input>
										<div
											:data-clipboard-text="
												pagefromData.materialSize
													.boxingWeight
											"
											@click="saleOrderCopy"
											class="copyBtn"
										>
											<i class="el-icon-document-copy" />
										</div>
									</el-form-item>
								</el-col>
								<el-col :span="1">
									<span class="line-28">kg</span>
								</el-col>
							</el-row>
							<el-row :gutter="10">
								<el-col :span="4">
									<el-form-item
										class="item-bt-s Iisshow"
										label="产品宽"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											:oninput="
												(pagefromData.materialSize.productWidth =
													pagefromData.materialSize
														.productWidth == 0 ||
													pagefromData.materialSize
														.productWidth == null
														? ''
														: pagefromData.materialSize.productWidth
																.toString()
																.replace(/^0/)
																.replace(
																	/[^\d.]/g,
																	''
																)
																.replace(
																	/\.{2,}/g,
																	'.'
																)
																.replace(
																	/^\./g,
																	''
																)
																.replace(
																	'.',
																	'$#$'
																)
																.replace(
																	/\./g,
																	''
																)
																.replace(
																	'$#$',
																	'.'
																)
																.replace(
																	/^(-)*(\d+)\.(\d\d\d\d).*$/,
																	'$1$2.$3'
																))
											"
											placeholder
											v-model.trim="
												pagefromData.materialSize
													.productWidth
											"
										></el-input>
										<div
											:data-clipboard-text="
												pagefromData.materialSize
													.productWidth
											"
											@click="saleOrderCopy"
											class="copyBtn"
										>
											<i class="el-icon-document-copy" />
										</div>
									</el-form-item>
								</el-col>
								<el-col :span="1">
									<span class="line-28">mm</span>
								</el-col>
								<el-col :span="4">
									<el-form-item
										class="item-bt-s Iisshow"
										label="包装宽"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											:oninput="
												(pagefromData.materialSize.packageWidth =
													pagefromData.materialSize
														.packageWidth == 0 ||
													pagefromData.materialSize
														.packageWidth == null
														? ''
														: pagefromData.materialSize.packageWidth
																.toString()
																.replace(/^0/)
																.replace(
																	/[^\d.]/g,
																	''
																)
																.replace(
																	/\.{2,}/g,
																	'.'
																)
																.replace(
																	/^\./g,
																	''
																)
																.replace(
																	'.',
																	'$#$'
																)
																.replace(
																	/\./g,
																	''
																)
																.replace(
																	'$#$',
																	'.'
																)
																.replace(
																	/^(-)*(\d+)\.(\d\d\d\d).*$/,
																	'$1$2.$3'
																))
											"
											placeholder
											v-model.trim="
												pagefromData.materialSize
													.packageWidth
											"
										></el-input>
										<div
											:data-clipboard-text="
												pagefromData.materialSize
													.packageWidth
											"
											@click="saleOrderCopy"
											class="copyBtn"
										>
											<i class="el-icon-document-copy" />
										</div>
									</el-form-item>
								</el-col>
								<el-col :span="1">
									<span class="line-28">mm</span>
								</el-col>
								<el-col :span="4">
									<el-form-item
										class="item-bt-s Iisshow"
										label="外箱宽"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											:oninput="
												(pagefromData.materialSize.outerBoxWidth =
													pagefromData.materialSize
														.outerBoxWidth == 0 ||
													pagefromData.materialSize
														.outerBoxWidth == null
														? ''
														: pagefromData.materialSize.outerBoxWidth
																.toString()
																.replace(/^0/)
																.replace(
																	/[^\d.]/g,
																	''
																)
																.replace(
																	/\.{2,}/g,
																	'.'
																)
																.replace(
																	/^\./g,
																	''
																)
																.replace(
																	'.',
																	'$#$'
																)
																.replace(
																	/\./g,
																	''
																)
																.replace(
																	'$#$',
																	'.'
																)
																.replace(
																	/^(-)*(\d+)\.(\d\d\d\d).*$/,
																	'$1$2.$3'
																))
											"
											placeholder
											v-model.trim="
												pagefromData.materialSize
													.outerBoxWidth
											"
										></el-input>
										<div
											:data-clipboard-text="
												pagefromData.materialSize
													.outerBoxWidth
											"
											@click="saleOrderCopy"
											class="copyBtn"
										>
											<i class="el-icon-document-copy" />
										</div>
									</el-form-item>
								</el-col>
								<el-col :span="1">
									<span class="line-28">mm</span>
								</el-col>
								<el-col :span="4">
									<el-form-item
										class="item-bt-s Iisshow"
										label="装箱数量"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											:oninput="
												(pagefromData.materialSize.boxingNumber =
													pagefromData.materialSize
														.boxingNumber == 0 ||
													pagefromData.materialSize
														.boxingNumber == null
														? ''
														: pagefromData.materialSize.boxingNumber
																.toString()
																.replace(/^0/)
																.replace(
																	/[^\d.]/g,
																	''
																)
																.replace(
																	/\.{2,}/g,
																	'.'
																)
																.replace(
																	/^\./g,
																	''
																)
																.replace(
																	'.',
																	'$#$'
																)
																.replace(
																	/\./g,
																	''
																)
																.replace(
																	'$#$',
																	'.'
																)
																.replace(
																	/^(-)*(\d+)\.(\d\d\d\d).*$/,
																	'$1$2.$3'
																))
											"
											placeholder
											v-model.trim="
												pagefromData.materialSize
													.boxingNumber
											"
										></el-input>
										<div
											:data-clipboard-text="
												pagefromData.materialSize
													.boxingNumber
											"
											@click="saleOrderCopy"
											class="copyBtn"
										>
											<i class="el-icon-document-copy" />
										</div>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row :gutter="10">
								<el-col :span="4">
									<el-form-item
										class="item-bt-s Iisshow"
										label="产品高"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											:oninput="
												(pagefromData.materialSize.productHeight =
													pagefromData.materialSize
														.productHeight == 0 ||
													pagefromData.materialSize
														.productHeight == null
														? ''
														: pagefromData.materialSize.productHeight
																.toString()
																.replace(/^0/)
																.replace(
																	/[^\d.]/g,
																	''
																)
																.replace(
																	/\.{2,}/g,
																	'.'
																)
																.replace(
																	/^\./g,
																	''
																)
																.replace(
																	'.',
																	'$#$'
																)
																.replace(
																	/\./g,
																	''
																)
																.replace(
																	'$#$',
																	'.'
																)
																.replace(
																	/^(-)*(\d+)\.(\d\d\d\d).*$/,
																	'$1$2.$3'
																))
											"
											placeholder
											v-model.trim="
												pagefromData.materialSize
													.productHeight
											"
										></el-input>
										<div
											:data-clipboard-text="
												pagefromData.materialSize
													.productHeight
											"
											@click="saleOrderCopy"
											class="copyBtn"
										>
											<i class="el-icon-document-copy" />
										</div>
									</el-form-item>
								</el-col>
								<el-col :span="1">
									<span class="line-28">mm</span>
								</el-col>
								<el-col :span="4">
									<el-form-item
										class="item-bt-s Iisshow"
										label="包装高"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											:oninput="
												(pagefromData.materialSize.packageHeight =
													pagefromData.materialSize
														.packageHeight == 0 ||
													pagefromData.materialSize
														.packageHeight == null
														? ''
														: pagefromData.materialSize.packageHeight
																.toString()
																.replace(/^0/)
																.replace(
																	/[^\d.]/g,
																	''
																)
																.replace(
																	/\.{2,}/g,
																	'.'
																)
																.replace(
																	/^\./g,
																	''
																)
																.replace(
																	'.',
																	'$#$'
																)
																.replace(
																	/\./g,
																	''
																)
																.replace(
																	'$#$',
																	'.'
																)
																.replace(
																	/^(-)*(\d+)\.(\d\d\d\d).*$/,
																	'$1$2.$3'
																))
											"
											placeholder
											v-model.trim="
												pagefromData.materialSize
													.packageHeight
											"
										></el-input>
										<div
											:data-clipboard-text="
												pagefromData.materialSize
													.packageHeight
											"
											@click="saleOrderCopy"
											class="copyBtn"
										>
											<i class="el-icon-document-copy" />
										</div>
									</el-form-item>
								</el-col>
								<el-col :span="1">
									<span class="line-28">mm</span>
								</el-col>
								<el-col :span="4">
									<el-form-item
										class="item-bt-s Iisshow"
										label="外箱高"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											:oninput="
												(pagefromData.materialSize.outerBoxHeight =
													pagefromData.materialSize
														.outerBoxHeight == 0 ||
													pagefromData.materialSize
														.outerBoxHeight == null
														? ''
														: pagefromData.materialSize.outerBoxHeight
																.toString()
																.replace(/^0/)
																.replace(
																	/[^\d.]/g,
																	''
																)
																.replace(
																	/\.{2,}/g,
																	'.'
																)
																.replace(
																	/^\./g,
																	''
																)
																.replace(
																	'.',
																	'$#$'
																)
																.replace(
																	/\./g,
																	''
																)
																.replace(
																	'$#$',
																	'.'
																)
																.replace(
																	/^(-)*(\d+)\.(\d\d\d\d).*$/,
																	'$1$2.$3'
																))
											"
											placeholder
											v-model.trim="
												pagefromData.materialSize
													.outerBoxHeight
											"
										></el-input>
										<div
											:data-clipboard-text="
												pagefromData.materialSize
													.outerBoxHeight
											"
											@click="saleOrderCopy"
											class="copyBtn"
										>
											<i class="el-icon-document-copy" />
										</div>
									</el-form-item>
								</el-col>
								<el-col :span="1">
									<span class="line-28">mm</span>
								</el-col>
								<el-col :span="4">
									<el-form-item
										class="item-bt-s Iisshow"
										label="最小包装量（物料）"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											:oninput="
												(pagefromData.materialSize.minNumber =
													pagefromData.materialSize
														.minNumber == 0 ||
													pagefromData.materialSize
														.minNumber == null
														? ''
														: pagefromData.materialSize.minNumber
																.toString()
																.replace(/^0/)
																.replace(
																	/[^\d.]/g,
																	''
																)
																.replace(
																	/\.{2,}/g,
																	'.'
																)
																.replace(
																	/^\./g,
																	''
																)
																.replace(
																	'.',
																	'$#$'
																)
																.replace(
																	/\./g,
																	''
																)
																.replace(
																	'$#$',
																	'.'
																)
																.replace(
																	/^(-)*(\d+)\.(\d\d\d\d).*$/,
																	'$1$2.$3'
																))
											"
											placeholder
											v-model.trim="
												pagefromData.materialSize
													.minNumber
											"
										></el-input>
										<div
											:data-clipboard-text="
												pagefromData.materialSize
													.minNumber
											"
											@click="saleOrderCopy"
											class="copyBtn"
										>
											<i class="el-icon-document-copy" />
										</div>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row :gutter="10">
								<el-col :span="4">
									<el-form-item
										class="item-bt-s Iisshow"
										label="产品重"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											:oninput="
												(pagefromData.materialSize.productWeight =
													pagefromData.materialSize
														.productWeight == 0 ||
													pagefromData.materialSize
														.productWeight == null
														? ''
														: pagefromData.materialSize.productWeight
																.toString()
																.replace(/^0/)
																.replace(
																	/[^\d.]/g,
																	''
																)
																.replace(
																	/\.{2,}/g,
																	'.'
																)
																.replace(
																	/^\./g,
																	''
																)
																.replace(
																	'.',
																	'$#$'
																)
																.replace(
																	/\./g,
																	''
																)
																.replace(
																	'$#$',
																	'.'
																)
																.replace(
																	/^(-)*(\d+)\.(\d\d\d\d).*$/,
																	'$1$2.$3'
																))
											"
											placeholder
											v-model.trim="
												pagefromData.materialSize
													.productWeight
											"
										></el-input>
										<div
											:data-clipboard-text="
												pagefromData.materialSize
													.productWeight
											"
											@click="saleOrderCopy"
											class="copyBtn"
										>
											<i class="el-icon-document-copy" />
										</div>
									</el-form-item>
								</el-col>
								<el-col :span="1">
									<span class="line-28">kg</span>
								</el-col>
								<el-col :span="4">
									<el-form-item
										class="item-bt-s Iisshow"
										label="包装重"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											:oninput="
												(pagefromData.materialSize.packageWeight =
													pagefromData.materialSize
														.packageWeight == 0 ||
													pagefromData.materialSize
														.packageWeight == null
														? ''
														: pagefromData.materialSize.packageWeight
																.toString()
																.replace(/^0/)
																.replace(
																	/[^\d.]/g,
																	''
																)
																.replace(
																	/\.{2,}/g,
																	'.'
																)
																.replace(
																	/^\./g,
																	''
																)
																.replace(
																	'.',
																	'$#$'
																)
																.replace(
																	/\./g,
																	''
																)
																.replace(
																	'$#$',
																	'.'
																)
																.replace(
																	/^(-)*(\d+)\.(\d\d\d\d).*$/,
																	'$1$2.$3'
																))
											"
											placeholder
											v-model.trim="
												pagefromData.materialSize
													.packageWeight
											"
										></el-input>
										<div
											:data-clipboard-text="
												pagefromData.materialSize
													.packageWeight
											"
											@click="saleOrderCopy"
											class="copyBtn"
										>
											<i class="el-icon-document-copy" />
										</div>
									</el-form-item>
								</el-col>
								<el-col :span="1">
									<span class="line-28">kg</span>
								</el-col>
								<el-col :span="4">
									<el-form-item
										class="item-bt-s Iisshow"
										label="装箱净重"
									>
										<el-input
											:disabled="isEdit"
											:maxlength="255"
											:oninput="
												(pagefromData.materialSize.outerBoxWeight =
													pagefromData.materialSize
														.productLength == 0 ||
													pagefromData.materialSize
														.outerBoxWeight == null
														? ''
														: pagefromData.materialSize.outerBoxWeight
																.toString()
																.replace(/^0/)
																.replace(
																	/[^\d.]/g,
																	''
																)
																.replace(
																	/\.{2,}/g,
																	'.'
																)
																.replace(
																	/^\./g,
																	''
																)
																.replace(
																	'.',
																	'$#$'
																)
																.replace(
																	/\./g,
																	''
																)
																.replace(
																	'$#$',
																	'.'
																)
																.replace(
																	/^(-)*(\d+)\.(\d\d\d\d).*$/,
																	'$1$2.$3'
																))
											"
											placeholder
											v-model.trim="
												pagefromData.materialSize
													.outerBoxWeight
											"
										></el-input>
										<div
											:data-clipboard-text="
												pagefromData.materialSize
													.outerBoxWeight
											"
											@click="saleOrderCopy"
											class="copyBtn"
										>
											<i class="el-icon-document-copy" />
										</div>
									</el-form-item>
								</el-col>
								<el-col :span="1">
									<span class="line-28">kg</span>
								</el-col>
							</el-row>
						</el-form>
					</div>
				</el-tab-pane>
				<!-- 客户信息 -->
				<el-tab-pane label="客户信息" name="custom">
					<div class="org-info-form-box">
						<!-- 明细工具栏 -->
						<div class="tell-info-button-group">
							<DetailsOperation
								:deviationSelectArr="selectRowIndexArr"
								@copyCellcolumn="copyCellcolumn"
								@copyRow="bottomCopyRow"
								@deleteRow="selectDeleteRow"
								@insertObj="getInsertInfo"
							></DetailsOperation>
						</div>
					</div>
					<!-- 表格信息-->
					<div class="tell-info-table">
						<el-table
							:cell-class-name="tableCellClassName"
							:data="pagefromData.materialCustomers"
							:header-cell-class-name="mustAfter1"
							@cell-click="getRowCol1"
							@select="selectRow"
							@select-all="selectAll"
							border
							max-height="400"
							ref="multipleTable1"
							style="font-size: 12px"
						>
							<el-table-column
								align="center"
								fixed
								type="selection"
								width="40"
							/>
							<el-table-column align="left" prop="customer">
								<template #header>
									<span
										class="iconfont icon-bianji1 iconfont-mg"
									></span
									>客户名称
								</template>
								<template #default="scope">
									<el-input
										:disabled="isEdit"
										:id="'customer' + scope.$index"
										:maxlength="255"
										@input="
											getRowCol1(
												scope.row,
												scope.column,
												'customer'
											)
										"
										placeholder="请输入客户名称"
										v-if="scope.row.iscustomershow"
										v-model.trim="scope.row.customer"
									></el-input>
									<span v-else>{{ scope.row.customer }}</span>
								</template>
							</el-table-column>
							<el-table-column align="left" prop="specifications">
								<template #header>
									<span
										class="iconfont icon-bianji1 iconfont-mg"
									></span
									>客户商品型号
								</template>
								<template #default="scope">
									<el-input
										:disabled="isEdit"
										:id="'specifications' + scope.$index"
										:maxlength="255"
										@input="
											getRowCol1(
												scope.row,
												scope.column,
												'specifications'
											)
										"
										placeholder="请输入客户商品型号"
										v-if="scope.row.isspecificationsshow"
										v-model.trim="scope.row.specifications"
									></el-input>
									<span v-else>{{
										scope.row.specifications
									}}</span>
								</template>
							</el-table-column>
							<el-table-column align="left" prop="name">
								<template #header>
									<span
										class="iconfont icon-bianji1 iconfont-mg"
									></span
									>客户商品名称
								</template>
								<template #default="scope">
									<el-input
										:disabled="isEdit"
										:id="'name' + scope.$index"
										:maxlength="255"
										@input="
											getRowCol1(
												scope.row,
												scope.column,
												'name'
											)
										"
										placeholder="请输入客户商品名称"
										v-if="scope.row.isnameshow"
										v-model.trim="scope.row.name"
									></el-input>
									<span v-else>{{ scope.row.name }}</span>
								</template>
							</el-table-column>
							<el-table-column align="left" prop="number">
								<template #header>
									<span
										class="iconfont icon-bianji1 iconfont-mg"
									></span
									>客户商品编码
								</template>
								<template #default="scope">
									<el-input
										:disabled="isEdit"
										:id="'number' + scope.$index"
										:maxlength="255"
										@input="
											getRowCol1(
												scope.row,
												scope.column,
												'number'
											)
										"
										placeholder="请输入客户商品编码"
										v-if="scope.row.isnumbershow"
										v-model.trim="scope.row.number"
									></el-input>
									<span v-else>{{ scope.row.number }}</span>
								</template>
							</el-table-column>
							<el-table-column align="left" prop="code">
								<template #header>
									<span
										class="iconfont icon-bianji1 iconfont-mg"
									></span
									>客户商品条码
								</template>
								<template #default="scope">
									<el-input
										:disabled="isEdit"
										:id="'code' + scope.$index"
										:maxlength="255"
										@input="
											getRowCol1(
												scope.row,
												scope.column,
												'code'
											)
										"
										placeholder="请输入客户商品条码"
										v-if="scope.row.iscodeshow"
										v-model.trim="scope.row.code"
									></el-input>
									<span v-else>{{ scope.row.code }}</span>
								</template>
							</el-table-column>
							<el-table-column align="left" prop="level">
								<template #header>
									<span
										class="iconfont icon-bianji1 iconfont-mg"
									></span
									>客户商品等级
								</template>
								<template #default="scope">
									<el-input
										:disabled="isEdit"
										:id="'level' + scope.$index"
										@change="changeLevel(scope.row)"
										@input="
											getRowCol1(
												scope.row,
												scope.column,
												'level'
											)
										"
										placeholder="请输入1-10的整数"
										v-if="scope.row.islevelshow"
										v-model.trim="scope.row.level"
									></el-input>
									<span v-else>{{ scope.row.level }}</span>
								</template>
							</el-table-column>
						</el-table>
					</div>
				</el-tab-pane>
				<!-- 其他信息 -->
				<el-tab-pane label="其他信息" name="other">
					<div class="other-info-form-box">
						<el-form
							:model="pagefromData"
							label-width="60px"
							ref="form"
						>
							<el-row :gutter="10">
								<el-col :span="4">
									<el-form-item
										class="item-bt-s"
										label="税率"
									>
										<el-select
											:disabled="isEdit"
											placeholder="请选择"
											v-model="pagefromData.tariff"
										>
											<el-option
												:key="item.id"
												:label="item.name"
												:value="item.id"
												:style="{
													height: item.disable
														? '0px'
														: 'auto',
												}"
												v-for="item in statusForm.getTaxRateList"
											></el-option>
										</el-select>
									</el-form-item>
								</el-col>
							</el-row>
						</el-form>
					</div>
				</el-tab-pane>
			</el-tabs>
		</div>
	</div>
</template>
<script setup></script>
<script>
import { mapState, mapActions } from 'vuex';
import { reactive } from 'vue';
import { orderCopy, orderRexgu, bottomAddRow } from '@/utils/takeMethods';
import { theUnitSet, inputEnter } from '@/utils/pubulic.js';
import examineTop from '@/components/examineTop/index.vue';
export default {
	name: 'materialSet',
	components: {
		examineTop,
	},
	data() {
		return {
			isUseCheck: false,
			isDisableTop: false,
			isEdit: false, //是否可编辑
			documentStatuslist: [], // 单据状态
			isDisableY: false,
			heightNum: 0,
			statusForm: {
				getTaxRateList: [],
			},
			pagefromData: {
				isDisable: false, //是否禁用
				id: '',
				name: '',
				number: '',
				documentStatus: 'a',
				specifications: '',
				unitId: '',
				subUnitId: '',
				subUnitMultiple: '',
				groupId: '',
				cost: 0,
				purchasePrice: 0,
				materialType: '',
				picture: '',
				tariff: '',
				code: '',
				materialOrgs: [
					{
						id: 0,
						seq: 1,
						orgId: '',
						orgName: '',
						materialProperty: null,
						supplyOrgId: '',
						supplierId: '',
						deliveryDay: 0,
					},
				],
				materialProduct: {
					id: 0,
					materialId: 0,
					supplyChain: '',
					is211: '',
					is211Compute: '',
					productLocation: '',
					lifeCycle: '',
					barCode: '',
					brand: '',
					brandType: '',
					productFamily: '',
					productSeries: '',
					productNoColor: '',
					productSPU: '',
					version: '',
					performance: '',
					sizeNumber: '',
					color: '',
					safety: '',
					package: '',
				},
				materialSize: {
					id: 0,
					productLength: '',
					productWidth: '',
					productHeight: '',
					productWeight: '',
					packageLength: '',
					packageWidth: '',
					packageHeight: '',
					packageWeight: '',
					outerBoxLength: '',
					outerBoxWidth: '',
					outerBoxHeight: '',
					outerBoxWeight: '',
					boxingWeight: '',
					boxingNumber: '',
					minNumber: '',
				},
				materialCustomers: [
					{
						id: 0,
						seq: 1,
						customer: '',
						specifications: '',
						name: '',
						number: '',
						code: '',
						level: 0,
					},
				],
			},
			mateOptions: [],
			InventoryType: [], //存货类别
			documentStatus: [], //数据状态
			supplyChainType: [], //供应链
			productLocationType: [], //产品定位
			lifeCycleType: [], //生命周期
			brandType: [], //品牌类型
			safetyType: [], //安规
			fileList: [],
			is211List: [
				{
					id: false,
					name: '否',
				},
				{
					id: true,
					name: '是',
				},
			], //是否211列表
			activeName: 'org',
			orgList: [], //供应组织
			materialPropData: [], //物料属性下拉
			btnType: [
				'copy',
				'revoke',
				's-p-t-g3',
				's-p-t-g4',
				'query',
				's-p-t-g5',
				'delete',
			], // 不需要显示的顶部按钮类型
			pageId: '', // 路由过来的单据id
			unitData: [], //单位
			customlist: [], //客户列表
			specificationlist: [], //供应商
			supplyOrglist: [], //供应组织
			materialPropList: [], //物料属性
			isDisable: false,
			selectRowIndexArr: [],
			selectRowIndex: '', // 当前 选择行
			addRow: {},
			rowArr: [],
			salesPromotionTypelist: [], // 促销类型集合
			storeObj: {
				// 存储的行
				storeRow: '',
				storeCol: '',
				storeVal: '',
				storekey: '',
			},
			saveParams: {
				id: 0,
				name: '',
				number: '',
				specifications: '',
				unitId: '',
				subUnitId: '',
				subUnitMultiple: '',
				groupId: '',
				cost: 0,
				purchasePrice: 0,
				materialType: '',
				picture: '',
				tariff: '',
				isDisable: '',
				materialOrgs: [
					{
						id: 0,
						seq: 1,
						orgId: 0,
						orgName: '',
						materialProperty: '',
						supplyOrgId: 0,
						supplierName: '',
						supplierId: 0,
						deliveryDay: 0,
					},
				],
				materialProduct: {
					id: 0,
					materialId: 0,
					supplyChain: '',
					is211: false,
					is211Compute: false,
					productLocation: '',
					lifeCycle: '',
					barCode: '',
					brand: '',
					brandType: '',
					productFamily: '',
					productSeries: '',
					productNoColor: '',
					productSPU: '',
					version: '',
					performance: '',
					sizeNumber: '',
					color: '',
					safety: '',
					package: '',
					isPriceWar: '', // 否价格战产品
					salesPromotionType: '', // 促销类型
					salesPromotionDate: '', // 促销时间
					isNew: '', // 是否新品
					outFactoryPrice: '', //出厂价
					agentPrice: '', // 代理价
					retailPrice: '', // 零售指导价
					minPrice: '', // 最低活动价
					foreignRetailPrice: '', // 海外零售指导价
					foreignRetailMinPrice: '', // 海外零售最低活动价
				},
				materialSize: {
					id: 0,
					productLength: '',
					productWidth: '',
					productHeight: '',
					productWeight: '',
					packageLength: '',
					packageWidth: '',
					packageHeight: '',
					packageWeight: '',
					outerBoxLength: '',
					outerBoxWidth: '',
					outerBoxHeight: '',
					outerBoxWeight: '',
					boxingWeight: '',
					boxingNumber: '',
					minNumber: '',
				},
				materialCustomers: [
					{
						id: 0,
						seq: 1,
						customer: '',
						specifications: '',
						name: '',
						number: '',
						code: '',
						level: 0,
					},
				],
			}, //保存/提交参数
			reqToken: '',
			dialogVisible: false,
			dialogImageUrl: '',
			imgName: '',
			ImgByte: '',
			checkStatus: '',
			upload_url:
				import.meta.env.VITE_APP_API_BASEURL +
				import.meta.env.VITE_APP_API_VERSION +
				'/Upload?type=material&name=',
			detailBtn: [],
			operateType: '',
		};
	},
	computed: {
		...mapState({
			// 获取当前组织
			orgId: (state) => (state && state.user ? state.user.orgId : null),
			orgIdArr: (state) => (state ? state.user.orgIdArr : null),
			unitDataList: (state) => (state ? state.user.allUnit : null),
			// 取出页面标签
			tags: (state) => (state) => state ? state.topNavTag.tags : null,
			publicidbyname: function () {
				// 根据key值显示对应的键名
				return function (arr, key) {
					return theUnitSet(arr, key);
				};
			},
		}),
	},
	watch: {
		'pagefromData.documentStatus'(newvalue, oldvalue) {
			if (
				this.pagefromData.documentStatus === 'a' ||
				!this.pagefromData.documentStatus
			) {
				this.$topNavTagRename('新增物料');
			} else {
				this.$topNavTagRename('编辑物料');
			}
			if (
				this.pagefromData.documentStatus === 'a' ||
				this.pagefromData.documentStatus === 'd'
			) {
				this.btnType = [
					'copy',
					'revoke',
					'audit',
					'de-approval',
					'delete',
					'push-down',
					'operation',
					'query',
					'refresh',
					's-p-t-g3',
					's-p-t-g4',
					'print-brower',
				]; // 不需要显示的顶部按钮类型
			} else {
				this.btnType = [
					'copy',
					'de-close',
					'close',
					'delete',
					'export',
					'refresh',
					'print-brower',
					'push-down',
					'query',
					'operation',
					's-p-t-g4',
				];
			}
		},
	},
	created() {
		this.heightNum =
			document.documentElement.clientHeight - (40 + 30 + 16 + 16);
		this.reqToken = localStorage.getItem('userToken');
		this.orgList = this.orgIdArr;
		this.supplyOrglist = this.orgIdArr;
		if (this.$route.query.type == 'add') {
			this.pagefromData.materialOrgs = [];
			this.supplyOrglist.forEach((item, index) => {
				this.pagefromData.materialOrgs[index] = reactive({
					id: 0,
					seq: index + 1,
					orgId: item.id,
					orgName: item.name,
					materialProperty: null,
					supplyOrgId: '',
					supplierId: '',
					deliveryDay: 0,
				});
			});
		}
		this.Init();
		if (
			this.$route.query.type == 'copy' ||
			this.$route.query.type == 'edit'
		) {
			this.pageId = this.$route.query.id; //单据id
			this.getDeatails();
		}
		// 获取税率
		this.$http.get('SysConfig/GetTaxRate').then((r) => {
			if (r.status == 200) {
				this.statusForm.getTaxRateList = r.data;
				this.statusForm.getTaxRateList.forEach((element) => {
					element.name = Number(element.name);
				});
			}
		});
	},
	methods: {
		Init() {
			this.getList();
			this.getStatus();
			let data = [];
			if (this.activeName == 'org') {
				data = this.pagefromData.materialOrgs;
			} else if (this.activeName == 'custom') {
				data = this.pagefromData.materialCustomers;
			}
			let keys = Object.keys(data[0]); // 获取添加对象
			for (const key in data[0]) {
				if (keys.indexOf(key) > -1) {
					this.addRow[key] = data[0][key];
					this.addRow.id = 0;
				}
			}
			this.detailBtn = ['add', 'copy', 'delet'];
		},
		pageInputEnter(value, type) {
			if (value) {
				if (type == 'cost') {
					this.pagefromData.cost = inputEnter(value);
				} else if (type == 'purchasePrice') {
					this.pagefromData.purchasePrice = inputEnter(value);
				} else {
					this.pagefromData.materialProduct[type] = inputEnter(
						value,
						'empty'
					);
				}
			}
		},
		// 获取需要状态列表---[单据状态，领料状态，业务状态]
		getStatus() {
			this.$http.get('ProduceOrder/GetStatus').then((r) => {
				if (r.status === 200) {
					this.documentStatuslist = r.data.documentStatus;
				}
			});
		},
		//物料编码 规则 - 限制
		saleRexgu(val, key) {
			var regExp =
				/^[\a-zA-Z0-9\s\·\~\！\@\#\￥\%\……\&\*\（\）\——\-\+\=\【\】\{\}\、\|\；\‘\’\：\“\”\《\》\？\，\。\、\`\~\!\#\$\%\^\&\*\(\)\_\[\]{\}\\\|\;\'\'\:\"\"\,\.\/\<\>\?]+$/; //eslint-disable-line
			if (!regExp.test(val)) {
				this.pagefromData.number = null;
				this.$message.error('物料编码只允许输入英文，数字标点符号');
			}
		},
		...mapActions({
			setAllUnit: 'storeData/setAllUnit',
		}),
		//单位处理
		unitMultipleInput(value) {
			if (value) {
				this.pagefromData.subUnitMultiple = value
					.toString()
					.replace(/[^\d^\\.]+/g, '')
					.replace('.', '$#$')
					.replace(/\./g, '')
					.replace('$#$', '.')
					.replace(/^(\\-)*(\d+)\.(\d\d\d\d\d\d\d\d).*$/, '$1$2.$3');
			}
		},
		numberChage(val) {
			if (val) {
				if (val.toString().indexOf('.') !== -1) {
					this.pagefromData.subUnitMultiple = val.substring(
						0,
						val.indexOf('.') + 6
					);
				} else {
					if (val.length > 8) {
						this.pagefromData.subUnitMultiple = val.substring(0, 8);
					}
				}
			}
		},
		// 客户商品等级下拉改变
		changeLevel(row) {
			// let val = row.level
			// const reg = /^([0-9]|10)$/
			// if (!reg.test(val)) {
			//   row.level = ''
			// }
		},
		inputSize(val) {
			const reg = /^\+?[1-9][0-9]*$/;
			if (!reg.test(val)) {
				this.pagefromData.materialProduct.sizeNumber = '';
			}
		},
		// 获取下拉列表数据 计算出数据
		getList() {
			this.$http.get('Materials/GetStatus').then((res) => {
				if (res.status == 200) {
					this.InventoryType = [];
					this.documentStatus = [];
					this.productLocationType = [];
					this.supplyChainType = [];
					this.lifeCycleType = [];
					this.brandType = [];
					this.safetyType = [];
					this.materialPropData = [];
					this.salesPromotionTypelist = [];
					for (let i in res.data.materialType) {
						//存货类型
						this.InventoryType.push({
							id: Number(i),
							name: res.data.materialType[i],
						});
					}
					for (let i in res.data.documentStatus) {
						//状态
						this.documentStatus.push({
							id: i,
							name: res.data.documentStatus[i],
						});
					}
					for (let i in res.data.productLocationType) {
						//产品定位
						this.productLocationType.push({
							id: Number(i),
							name: res.data.productLocationType[i],
						});
					}
					for (let i in res.data.supplyChainType) {
						//供应链
						this.supplyChainType.push({
							id: Number(i),
							name: res.data.supplyChainType[i],
						});
					}
					for (let i in res.data.lifeCycleType) {
						//生命周期
						this.lifeCycleType.push({
							id: Number(i),
							name: res.data.lifeCycleType[i],
						});
					}
					for (let i in res.data.brandType) {
						//品牌类型
						this.brandType.push({
							id: Number(i),
							name: res.data.brandType[i],
						});
					}
					for (let i in res.data.safetyType) {
						//安规
						this.safetyType.push({
							id: Number(i),
							name: res.data.safetyType[i],
						});
					}
					for (var i in res.data.materialPropertyType) {
						//物料属性
						this.materialPropData.push({
							id: Number(i),
							name: res.data.materialPropertyType[i],
						});
					}
					for (var i in res.data.salesPromotionType) {
						//物料属性
						this.salesPromotionTypelist.push({
							id: Number(i),
							name: res.data.salesPromotionType[i],
						});
					}
				}
			});
			// 物料分类
			this.$http.get('MaterialGroup/GetDropDownAll').then((res) => {
				if (res.status == 200) {
					this.mateOptions = this.removeChildren(res.data);
				}
			});
			this.unitData = [];
			this.$http.get('SysConfig/GetUnitAllProperty').then((r) => {
				if (r.status === 200) {
					this.unitData = r.data;
					this.setAllUnit(r.data);
				}
			});
		},
		removeChildren(arr) {
			if (arr.length) {
				for (let i in arr) {
					if (arr[i].chinds.length) {
						this.removeChildren(arr[i].chinds);
					} else {
						delete arr[i].chinds;
					}
				}
			}
			return arr;
		},
		// 获取详情信息 编辑的时候用 ，或者保存提交后 克隆过了的
		getDeatails() {
			this.$http.get('Materials/Get/' + this.pageId).then((res) => {
				if (res.status == 200) {
					if (
						(this.$route.query.type === 'add' ||
							this.$route.query.type === 'copy') &&
						!this.pagefromData.id
					) {
						this.pagefromData = JSON.parse(
							JSON.stringify(res.data)
						);
						if (res.data.picture) {
							this.fileList = [
								{
									name: '',
									url: res.data.picture
										? res.data.picture
										: '',
								},
							];
						}
						this.pagefromData.id = 0; //复制信息，不复制编码
						this.pagefromData.number = '';
						this.pagefromData.code = '';
						if (
							this.pagefromData.tariff == 0 ||
							this.pagefromData.tariff == null
						) {
							this.pagefromData.tariff = '';
						}
						this.pagefromData.materialCustomers.forEach((item1) => {
							item1.id = 0;
						});
						this.pagefromData.materialProduct.id = 0;
						this.pagefromData.materialSize.id = 0;
						this.pagefromData.documentStatus = 'a';
						this.rowArr = res.data.materialOrgs;
						this.pagefromData.materialOrgs.forEach(
							(item, index) => {
								if (item.supplierId) {
									this.specificationlist[index] = [
										{
											id: item.supplierId,
											name: item.supplierName,
										},
									];
								}
								item.id = 0;
							}
						);
					} else {
						this.dealDetails(res.data);
					}
					if (
						this.$route.query.type == 'copy' &&
						!this.pagefromData.id
					) {
						this.pagefromData.id = null;
					}
				}
			});
		},
		dealDetails(data) {
			this.pagefromData = data;
			this.rowArr = data.materialOrgs;
			this.checkStatus = data.documentStatus;
			this.isUseCheck = data.isUseCheck ? data.isUseCheck : false;
			if (
				this.pagefromData.tariff == 0 ||
				this.pagefromData.tariff == null
			) {
				this.pagefromData.tariff = '';
			}
			if (this.checkStatus == 'a' || this.checkStatus == 'd') {
				this.isEdit = false;
			} else {
				this.isEdit = true;
			}
			let picture = data.picture;
			if (data.picture) {
				this.fileList = [{ name: '', url: picture ? picture : '' }];
			}
			// 图片回显处理
			let index = picture ? picture.indexOf('com/') + 4 : null;
			this.upload_url =
				import.meta.env.VITE_APP_API_BASEURL +
				import.meta.env.VITE_APP_API_VERSION +
				'/Upload?type=material&name=';
			this.pagefromData.materialOrgs.forEach((item, index) => {
				item.id = 0;
				if (item.supplierId) {
					this.specificationlist[index] = [
						{ id: item.supplierId, name: item.supplierName },
					];
				}
			});
		},
		gyorgChange(val, index) {
			if (val && this.pagefromData.materialOrgs[index].supplyOrgId) {
				this.pagefromData.materialOrgs[index].supplierId = '';
			}
		},
		mrgysChange(val, index) {
			if (val && this.pagefromData.materialOrgs[index].supplierId) {
				this.pagefromData.materialOrgs[index].supplyOrgId = '';
			}
		},
		// 查询供应商
		mrgysquery(val, index) {
			if (val !== '') {
				setTimeout(() => {
					this.$http
						.get('SysConfig/supplier/select', { name: val })
						.then((res) => {
							if (res.status === 200) {
								this.specificationlist[index] = res.data;
							}
						});
				}, 200);
			}
		},
		// 选择物料分类
		changeMaterial(val) {
			if (val) {
				this.pagefromData.groupId = val[val.length - 1];
			}
			this.$refs.materialType.isDisabled = true;
		},
		clearData() {
			//清空级联框对应操作
			this.pagefromData.groupId = '';
			this.$refs.materialType.togglePopperVisible();
			// this.getList()
		},
		//tab切换
		handleClick(name) {
			this.activeName = name;
			if (this.activeName == 'org' || this.activeName == 'custom') {
				this.Init();
			}
		},
		// 订单号 复制按钮
		saleOrderCopy() {
			orderCopy();
		},
		//上传图片
		beforeUpload(file) {
			this.ImgByte = file.name;
			let is200k = file.size / 1024 / 1024 < 0.2; // 限制小于200k
			if (!is200k) {
				this.$message.error({
					message: '图片尺寸限制为800 x 800，大小不可超过200k',
					showClose: true,
				});
				return false;
			} else {
				let isSize = new Promise((resolve, reject) => {
					let width = 800;
					let height = 800;
					let _URL = window.URL || window.webkitURL;
					let img = new Image();
					img.onload = () => {
						let valid =
							img.width === width && img.height === height;
						valid ? resolve() : reject();
					};
					img.src = _URL.createObjectURL(file);
				}).then(
					() => {
						return file;
					},
					() => {
						this.$message.error({
							message:
								'图片尺寸限制为800 x 800，大小不可超过200k',
							showClose: true,
						});
						return Promise.reject();
					}
				);
				return isSize;
			}
		},
		// 图片上传成功
		handleSuccess(res, file, fileList) {
			this.pagefromData.picture = res.data;
		},
		handleRemove(file, fileList) {
			this.pagefromData.picture = '';
		},
		selectBlur() {
			let _this = this;
			_this.pagefromData.materialCustomers.forEach((el) => {
				(el.iscustomershow = false),
					(el.isspecificationsshow = false),
					(el.isnameshow = false),
					(el.isnumbershow = false),
					(el.iscodeshow = false),
					(el.islevelshow = false);
			});
		},
		// 插入的行
		getInsertInfo() {
			let newaddRow = {
				code: '',
				customer: '',
				deliveryDay: 0,
				id: 0,
				index: 0,
				level: null,
				materialProperty: null,
				name: '',
				number: '',
				orgId: '',
				orgName: '',
				seq: 1,
				specifications: '',
				supplierId: '',
				supplyOrgId: '',
			};
			this.pagefromData.materialCustomers = bottomAddRow(
				this.pagefromData.materialCustomers,
				JSON.parse(JSON.stringify(newaddRow))
			);
			this.selectBlur();
			this.$nextTick(() => {
				this.$refs.multipleTable.$refs.bodyWrapper.scrollTop =
					this.$refs.multipleTable.$refs.bodyWrapper.scrollHeight;
				this.$refs.multipleTable1.$refs.bodyWrapper.scrollTop =
					this.$refs.multipleTable1.$refs.bodyWrapper.scrollHeight;
			});
			this.$refs.multipleTable.clearSelection();
			this.$refs.multipleTable1.clearSelection();
			// if (data.insertTopVal != 0 && data.insertTopVal != '') {
			//   for (let i = 0; i < data.insertTopVal; i++) {
			//     if (this.activeName == 'org') {
			//       this.pagefromData.materialOrgs.splice(this.selectRowIndex, 0, JSON.parse(JSON.stringify(this.addRow)))
			//     } else if (this.activeName == 'custom') {
			//       this.pagefromData.materialCustomers.splice(this.selectRowIndex, 0, JSON.parse(JSON.stringify(this.addRow)))
			//     }
			//     this.selectRowIndex = parseInt(this.selectRowIndex) + 1
			//   }
			// }
			// if (data.insertBottomVal != 0 && data.insertBottomVal != '') {
			//   for (let i = 0; i < data.insertBottomVal; i++) {
			//     this.selectRowIndex = parseInt(this.selectRowIndex) + 1
			//     if (this.activeName == 'org') {
			//       this.pagefromData.materialOrgs.splice(this.selectRowIndex, 0, JSON.parse(JSON.stringify(this.addRow)))
			//     } else if (this.activeName == 'custom') {
			//       let newaddRow = {
			//         code: '',
			//         customer: '',
			//         deliveryDay: 0,
			//         id: 0,
			//         index: 0,
			//         level: null,
			//         materialProperty: null,
			//         name: '',
			//         number: '',
			//         orgId: '',
			//         orgName: '',
			//         seq: 1,
			//         specifications: '',
			//         supplierId: '',
			//         supplyOrgId: ''
			//       }
			//       this.pagefromData.materialCustomers.splice(this.selectRowIndex, 0, JSON.parse(JSON.stringify(newaddRow)))
			//     }
			//   }
			//   this.selectRowIndex = this.selectRowIndex - data.insertBottomVal // 回朔
			// }
		},
		// 向下复制行
		bottomCopyRow(data) {
			let datas = [];
			if (this.activeName == 'org') {
				datas = this.pagefromData.materialOrgs;
			} else if (this.activeName == 'custom') {
				datas = this.pagefromData.materialCustomers;
			}
			if (this.selectRowIndexArr.length > 0) {
				if (this.selectRowIndexArr.length == 1) {
					let tableArr = JSON.parse(
						JSON.stringify(datas[this.selectRowIndex])
					);
					let insertNum = this.selectRowIndex + 1;
					datas.splice(insertNum, 0, tableArr);
					datas[insertNum].id = 0;
				} else {
					// 获取最后选择的行
					let lastIndex = -1;
					this.selectRowIndexArr.forEach((el) => {
						el > lastIndex ? (lastIndex = el) : false;
					});
					// 添加行
					this.selectRowIndexArr.forEach((el) => {
						lastIndex = lastIndex + 1;
						let tableArr = JSON.parse(JSON.stringify(datas[el]));
						datas.splice(lastIndex, 0, tableArr);
						datas[lastIndex].id = 0;
					});
				}
				this.selectBlur();
				this.$refs.multipleTable.clearSelection();
				this.$refs.multipleTable1.clearSelection();
				this.selectRowIndexArr = [];
			} else {
				this.$message.error({
					message: '只能选择一行进复制!',
					showClose: true,
				});
			}
		},
		// 删除行
		selectDeleteRow(data) {
			let datas = [];
			if (this.activeName == 'org') {
				datas = this.pagefromData.materialOrgs;
			} else if (this.activeName == 'custom') {
				datas = this.pagefromData.materialCustomers;
			}
			if (
				datas.length > 1 &&
				datas.length != this.selectRowIndexArr.length
			) {
				// 不能为空
				if (this.selectRowIndexArr.length != 0) {
					this.selectRowIndexArr.sort(function (a, b) {
						return a - b;
					});
					for (let i = 0; i < this.selectRowIndexArr.length; i++) {
						// 删除一次索引就变一次
						datas.splice(this.selectRowIndexArr[i] - i, 1);
					}
					this.$refs.multipleTable.clearSelection();
					this.$refs.multipleTable1.clearSelection();
					this.selectBlur();
				} else {
					this.$message.error({
						message: '请先选择要删除的行',
						showClose: true,
					});
				}
			} else {
				this.$message.error({
					message: '表格不能为空，至少保留一条数据!',
					showClose: true,
				});
			}
		},
		// 批量填充
		copyCellcolumn(data) {
			let datas = [];
			if (this.activeName == 'org') {
				datas = this.pagefromData.materialOrgs;
			} else if (this.activeName == 'custom') {
				datas = this.pagefromData.materialCustomers;
			}
			let nextRow = this.storeObj.storeRow + 1;
			let storeKey = this.storeObj.storekey;
			const _this = this;
			for (let i = nextRow; i < datas.length; i++) {
				for (const key in datas[i]) {
					if (key === storeKey) {
						if (key == 'supplyOrgId') {
							datas[i][`${key}`] = this.storeObj.storeVal;
							datas[i].supplierId = '';
							datas[i].supplierName = '';
						} else if (key == 'supplierName') {
							datas[i].supplyOrgId = '';
							this.rowArr.forEach((el) => {
								datas[i][`${key}`] = this.storeObj.storeVal;
								if (el.id === datas[i - 1].id) {
									datas[i].supplierId = el.supplierId;
									datas[i].supplierName = el.supplierName;
								}
								datas[i].isEditSupply = false;
							});
						} else {
							if (key == 'supplierId') {
								datas[i].supplyOrgId = '';
								datas[i].supplierId =
									datas[_this.storeObj.storeRow].supplierId;
								_this.specificationlist[i] =
									_this.specificationlist[
										_this.storeObj.storeRow
									];
							}
							datas[i][`${key}`] = _this.storeObj.storeVal;
						}
					}
				}
			}
		},
		getRowCol1(row, column, cell, event) {
			// 单元格被点击
			this.storeObj.storeRow = row.index;
			this.storeObj.storeCol = column.index;
			if (typeof cell === 'string') {
				this.storeObj.storekey = cell;
			} else {
				this.storeObj.storekey = column.property;
			}
			this.storeObj.storeVal = row[this.storeObj.storekey];
			// 处理表格下拉框输入框显示隐藏
			this.pagefromData.materialCustomers.forEach((it, index) => {
				Object.assign(it, {
					iscustomershow: false,
					isspecificationsshow: false,
					isnameshow: false,
					isnumbershow: false,
					iscodeshow: false,
					islevelshow: false,
				});
			});
			var showtagarry = [
				'iscustomershow',
				'isspecificationsshow',
				'isnameshow',
				'isnumbershow',
				'iscodeshow',
				'islevelshow',
			];
			var parentshowtagarry = [
				'customer',
				'specifications',
				'name',
				'number',
				'code',
				'level',
			];
			showtagarry.forEach((k, idx) => {
				if (column.property == parentshowtagarry[idx]) {
					this.pagefromData.materialCustomers[row.index][k] = true;
					this.$nextTick((_) => {
						if (
							document.getElementById(column.property + row.index)
						) {
							document
								.getElementById(column.property + row.index)
								.focus();
						}
					});
				}
			});
		},
		getRowCol(row, column, cell, event) {
			// 单元格被点击
			this.storeObj.storeRow = row.index;
			this.storeObj.storeCol = column.index;
			if (typeof cell === 'string') {
				this.storeObj.storekey = cell;
			} else {
				this.storeObj.storekey = column.property;
			}
			this.storeObj.storeVal = row[this.storeObj.storekey];
			// if (this.storeObj.storekey == 'supplyOrgId') {
			//   row.supplierId = ''
			// } else if (this.storeObj.storekey == 'supplierId') {
			//   row.supplyOrgId = ''
			// }
			// 处理表格下拉框输入框显示隐藏
			this.pagefromData.materialOrgs.forEach((it, index) => {
				Object.assign(it, {
					ismaterialPropertyshow: false,
					issupplyOrgIdshow: false,
					issupplierIdshow: false,
					isdeliveryDayshow: false,
				});
			});
			var showtagarry = [
				'ismaterialPropertyshow',
				'issupplyOrgIdshow',
				'issupplierIdshow',
				'isdeliveryDayshow',
			];
			var parentshowtagarry = [
				'materialProperty',
				'supplyOrgId',
				'supplierId',
				'deliveryDay',
			];
			showtagarry.forEach((k, idx) => {
				if (column.property == parentshowtagarry[idx]) {
					this.pagefromData.materialOrgs[row.index][k] = true;
					this.$nextTick((_) => {
						if (
							document.getElementById(column.property + row.index)
						) {
							document
								.getElementById(column.property + row.index)
								.focus();
						}
					});
				}
			});
		},
		// 明细选择行的数据处理
		selectdataSet(selection, row) {
			this.multipleSelection = [];
			this.multipleSelection = selection;
			if (row) {
				this.selectRowIndex = row.index;
			}
			if (selection && selection.length > 0) {
				this.selectRowIndex = selection[0].index;
			}
			if (selection.length != 0) {
				this.selectRowIndexArr = selection.map((it) => {
					return it.index;
				});
			} else {
				this.selectRowIndexArr = [];
			}
		},
		// 选择全部明细(全选)
		selectAll(selection) {
			this.selectdataSet(selection);
		},
		// 选择的行（单选）
		selectRow(selection, row) {
			this.selectdataSet(selection);
		},
		// 星星--头部必填ico显示
		mustAfter(obj) {
			let arry = [2, 5];
			if (arry.indexOf(obj.columnIndex) !== -1) {
				return 'must';
			}
		},
		mustAfter1(obj) {
			let arry = [];
			if (arry.indexOf(obj.columnIndex) !== -1) {
				return 'must';
			}
		},
		// 表格cell类名--解构
		tableCellClassName({ row, column, rowIndex, columnIndex }) {
			//利用单元格的 className 的回调方法，给行列索引赋值
			row.index = rowIndex;
			column.index = columnIndex;
		},
		// 顶部公共按钮操作
		actionhandel(type) {
			this.isDisable = true;
			setTimeout(() => {
				this.isDisable = false;
			}, 2000);
			this.operateType = type;
			let ids = [];
			ids.push(this.pageId);
			// 点击新增
			if (type === 'add') {
				this.$router.push({
					path: '/material/mateBom/materialSet',
					query: { type: 'add', id: '', sjtag: Math.random() * 36 },
				});
			}
			// 点击撤销
			if (type === 'revoke') {
				if (this.checkStatus === 'b') {
					this.toolarFn('Materials/Revoke', ids);
					return false;
				} else {
					this.$message({
						type: 'error',
						message: '该状态不可进行撤销操作！',
						showClose: true,
					});
				}
			}
			// 点击审核
			if (type === 'audit') {
				if (this.checkStatus === 'b') {
					this.toolarFn('Materials/Check', ids);
					return false;
				} else {
					this.$message({
						type: 'error',
						message: '该状态不可进行审核操作！',
						showClose: true,
					});
				}
			}
			// 点击反审核
			if (type === 'de-approval') {
				if (this.checkStatus === 'c') {
					this.toolarFn('Materials/NoCheck', ids);
					return false;
				} else {
					this.$message({
						type: 'error',
						message: '该状态不可进行反审核操作！',
						showClose: true,
					});
				}
			}
			// 点击删除
			if (type === 'delet') {
				if (this.checkStatus == 'a' || this.checkStatus == 'd') {
					this.toolarFn('Materials/Delete', ids);
				} else {
					this.$message({
						type: 'error',
						message: '该状态不可进行删除操作！',
						showClose: true,
					});
				}
			}
			if (type == 'save' || type == 'submit') {
				if (
					(this.$route.query.type === 'add' ||
						this.$route.query.type === 'copy') &&
					this.pagefromData.documentStatus === 'a'
				) {
					if (
						this.pagefromData.groupId == '' ||
						this.pagefromData.groupId == null
					) {
						this.$message({
							type: 'error',
							message: '请选择物料分类！',
							showClose: true,
						});
						return false;
					}
					let tempList = this.pagefromData.materialOrgs.filter(
						(it) =>
							it.materialProperty == 3 || it.materialProperty == 4
					);
					let tempListQ = this.pagefromData.materialOrgs.filter(
						(it) =>
							it.materialProperty != 3 && it.materialProperty != 4
					);
					if (tempList.length !== 0 && tempListQ.length !== 0) {
						this.$message({
							type: 'error',
							message:
								'物料属性存在服务或费用时，不允许有其它物料属性！',
							showClose: true,
						});
						return false;
					}
				} else {
					let tempList = this.pagefromData.materialOrgs.filter(
						(it) =>
							it.materialProperty == 3 || it.materialProperty == 4
					);
					let tempListQ = this.pagefromData.materialOrgs.filter(
						(it) =>
							it.materialProperty != 3 && it.materialProperty != 4
					);
					if (tempList.length !== 0 && tempListQ.length !== 0) {
						this.$message({
							type: 'error',
							message:
								'物料属性存在服务或费用时，不允许有其它物料属性！',
							showClose: true,
						});
						return false;
					}
				}
			}

			if (
				this.pagefromData.purchasePrice == '' ||
				this.pagefromData.purchasePrice == null
			) {
				this.pagefromData.purchasePrice = 0;
			}
			this.saveParams = {
				id: this.pagefromData.id ? this.pagefromData.id : 0,
				name: this.pagefromData.name,
				number: this.pagefromData.number
					? this.pagefromData.number
					: '',
				specifications: this.pagefromData.specifications,
				unitId: this.pagefromData.unitId,
				subUnitId: this.pagefromData.subUnitId,
				subUnitMultiple: this.pagefromData.subUnitMultiple,
				groupId: this.pagefromData.groupId,
				cost: this.pagefromData.cost,
				isDisable: this.pagefromData.isDisable,
				purchasePrice: this.pagefromData.purchasePrice,
				materialType: this.pagefromData.materialType,
				picture: this.pagefromData.picture,
				tariff: this.pagefromData.tariff,
				materialOrgs: this.pagefromData.materialOrgs,
				materialProduct: this.pagefromData.materialProduct,
				materialSize: this.pagefromData.materialSize,
				materialCustomers: this.pagefromData.materialCustomers,
			};
			this.pagefromData.materialOrgs.forEach((item, index) => {
				this.saveParams.materialOrgs[index].id = item.id;
				this.saveParams.materialOrgs[index].seq = item.seq;
				this.saveParams.materialOrgs[index].orgId = item.orgId;
				this.saveParams.materialOrgs[index].materialProperty = Number(
					item.materialProperty
				);
				this.saveParams.materialOrgs[index].supplyOrgId =
					item.supplyOrgId;
				this.saveParams.materialOrgs[index].supplierId =
					item.supplierId;
				this.saveParams.materialOrgs[index].deliveryDay =
					item.deliveryDay;
			});
			this.pagefromData.materialCustomers.forEach((item1, index) => {
				this.saveParams.materialCustomers[index].id = item1.id;
				this.saveParams.materialCustomers[index].seq = item1.seq;
				this.saveParams.materialCustomers[index].customer =
					item1.customer;
				this.saveParams.materialCustomers[index].specifications =
					item1.specifications;
				this.saveParams.materialCustomers[index].name = item1.name;
				this.saveParams.materialCustomers[index].number = item1.number;
				this.saveParams.materialCustomers[index].code = item1.code;
				this.saveParams.materialCustomers[index].level = item1.level;
			});
			if (type == 'save') {
				this.$http
					.post('Materials/Save', this.saveParams)
					.then((res) => {
						if (res.status == 200) {
							this.dealDetails(res.data);
							this.pagefromData.dataSources =
								this.pagefromData.dataSources + '';
							this.pageId = res.data.id;
							this.$message({
								type: 'success',
								message: '保存成功',
								showClose: true,
							});
						}
					});
			}
			let isOk = true;
			if (type == 'submit') {
				this.saveParams.materialOrgs.forEach((item, index) => {
					if (
						item.deliveryDay == 0 ||
						item.deliveryDay == '' ||
						item.deliveryDay == null
					) {
						isOk = false;
						return false;
					} else {
						isOk = true;
					}
				});
				if (isOk == false) {
					this.$message({
						type: 'error',
						message: '请填写交付天数！',
						showClose: true,
					});
				} else {
					this.$http
						.post('Materials/Commit', this.saveParams)
						.then((res) => {
							if (res.status == 200) {
								this.$message({
									type: 'success',
									message: '提交成功!',
									showClose: true,
								});
								this.dealDetails(res.data);
								this.pagefromData.dataSources =
									this.pagefromData.dataSources + '';
								this.pageId = res.data.id;
							}
						});
				}
			}
		},
		// 顶部操作方法-公共部分封装
		toolarFn(path, newArry) {
			let formdata = { ids: newArry };
			this.$http.post(path, formdata).then((res) => {
				if (res.status === 200) {
					if (this.operateType == 'de-approval') {
						if (res.data[0].msg != '') {
							this.$message({
								type: 'error',
								message: res.data[0].msg,
								showClose: true,
							});
						} else {
							this.$message({
								type: 'success',
								message: '操作成功!',
								showClose: true,
							});
						}
					} else {
						this.$message({
							type: 'success',
							message: '操作成功!',
							showClose: true,
						});
					}
					if (this.operateType != 'delet') {
						this.getDeatails();
					}
				} else {
					if (this.operateType != 'delet') {
						this.$message({
							type: 'error',
							message: '操作失败!',
							showClose: true,
						});
					}
				}
			});
		},
	},
};
</script>
<style lang="scss" scoped>
@import '@/assets/style/saleOrder/saleOrderCommon.scss';
@import '@/assets/style/saleOrder/orderDetails.scss';
@import '@/assets/style/materialBom/bom.scss';
@import '@/assets/style/saleOrder/common.scss';
</style>
