<!-- 仓库-其他入库单 -->
<template>
	<div>
		<examineTop
			v-if="isExmaineTop === 2"
			:radios="radios"
			@handleBtns="handleBtns"
			@handleOpen="handleOpen"
			:isexamineBtns="isexamineBtns"
		/>
	</div>
	<div
		:style="{ height: heightNum + 'px!important' }"
		class="sale-details-container order-mc-bg main-container"
	>
		<div class="sale-details-btn-group">
			<!-- 顶部按钮 -->
			<template v-if="isExmaineTop !== 2">
				<toolBtn
					:btnType="btnType"
					:isDisable="isDisable"
					@actionhandel="actionhandel"
					:isExmaineTop="isShow"
				></toolBtn>
			</template>
		</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-row :gutter="10">
								<el-col :span="4">
									<div class="div-col">
										<div class="order-number-bx item-bt-s">
											<el-form-item
												class="Iisshow"
												label="单据编号"
											>
												<el-input
													:maxlength="255"
													disabled
													placeholder="(保存时自动生成)"
													v-model.trim="
														pagefromData.billNo
													"
												>
												</el-input>
												<div
													:data-clipboard-text="
														pagefromData.billNo
													"
													@click="saleOrderCopy"
													class="copyBtn"
												>
													<i
														class="el-icon-document-copy"
													/>
												</div>
											</el-form-item>
										</div>
										<el-form-item
											:required="true"
											class="item-bt-s"
											label="单据类型"
										>
											<el-select
												disabled
												filterable
												v-model="
													pagefromData.billTypeId
												"
											>
												<el-option
													:key="key + index"
													:label="value"
													:value="key"
													style="font-size: 12px"
													v-for="(
														value, key, index
													) in documentTypelist"
												></el-option>
											</el-select>
										</el-form-item>
										<el-form-item
											class="item-bt-s item-date"
											label="入库日期"
										>
											<el-date-picker
												:clearable="false"
												:disabled="
													pagefromData.documentStatus !==
														'a' &&
													pagefromData.documentStatus !==
														'd'
												"
												:disabledDate="
													(data) => {
														return (
															data.getTime() >
															Date.now() - 8.64e6
														);
													}
												"
												format="YYYY-MM-DD"
												type="date"
												v-model="pagefromData.date"
												value-format="YYYY-MM-DD"
											></el-date-picker>
										</el-form-item>
										<el-form-item 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>
									</div>
								</el-col>
								<el-col :span="4">
									<div class="div-col col-2">
										<el-form-item
											:required="true"
											class="item-bt-s"
											label="库存组织"
										>
											<el-select
												:disabled="
													pagefromData.documentStatus !==
														'a' &&
													pagefromData.documentStatus !==
														'd'
												"
												@change="orgChange"
												filterable
												placeholder="请选择组织"
												v-model="
													pagefromData.stockOrgId
												"
											>
												<el-option
													:key="item.name"
													:label="item.name"
													:value="item.id"
													class="f-12"
													:style="{
														height: item.disable
															? '0px'
															: 'auto',
													}"
													v-for="item in orgIdArr"
												></el-option>
											</el-select>
										</el-form-item>
										<el-form-item
											:required="true"
											class="item-bt-s"
											label="部门"
										>
											<el-cascader
												:disabled="
													!pagefromData.stockOrgId ||
													(pagefromData.documentStatus !==
														'a' &&
														pagefromData.documentStatus !==
															'd')
												"
												:options="productDeptList"
												:props="optionProps"
												:show-all-levels="false"
												clearable
												placeholder="请选择部门"
												v-model="pagefromData.deptId"
											></el-cascader>
										</el-form-item>
									</div>
								</el-col>
							</el-row>
						</el-form>
					</div>
				</el-tab-pane>
			</el-tabs>
		</div>
		<!-- 明细信息 -->
		<div class="sale-details-tell-info">
			<div class="tell-info-row-title">
				<h3>明细信息</h3>
				<div class="long-line-bx">
					<div class="long-line"></div>
				</div>
			</div>
			<!-- 明细工具栏 -->
			<div class="tell-info-button-group">
				<DetailsOperation
					:deviationSelectArr="selectRowIndexArr"
					:isEdit="
						pagefromData.documentStatus !== 'a' &&
						pagefromData.documentStatus !== 'd'
					"
					@copyCellcolumn="copyCellcolumn"
					@copyRow="bottomCopyRow"
					@deleteRow="selectDeleteRow"
					@insertObj="getInsertInfo"
				></DetailsOperation>
			</div>
			<!-- 表格信息-->
			<div class="tell-info-table">
				<el-table
					:cell-class-name="tableCellClassName"
					:data="pagefromData.details"
					:header-cell-class-name="mustAfter"
					@cell-click="getRowCol"
					@select="selectRow"
					@select-all="selectRowAll"
					border
					max-height="400"
					ref="multipleTable"
					style="width: 100%; font-size: 12px"
				>
					<el-table-column
						align="center"
						fixed
						type="selection"
						width="40"
					/>
					<el-table-column align="left" prop="materialId" width="190">
						<template #header>
							<span
								class="iconfont icon-bianji1 iconfont-mg"
							></span
							>物料编码
						</template>
						<template #default="scope">
							<el-select
								:disabled="
									pagefromData.documentStatus !== 'a' &&
									pagefromData.documentStatus !== 'd'
								"
								:loading="loading"
								:remote-method="
									(query) => {
										matterCodeChange(
											query,
											'materialId',
											scope.$index
										);
									}
								"
								@change="metterChange($event, scope.$index)"
								@click="
									getRowCol(
										scope.row,
										scope.column,
										'materialId'
									)
								"
								@paste="
									pasteExcel(
										$event,
										scope.$index,
										scope,
										'materialId'
									)
								"
								filterable
								placeholder="请输入关键词"
								remote
								reserve-keyword
								v-if="scope.row.ismaterialIdshow"
								v-model="scope.row.materialId"
							>
								<el-option
									:key="item.idr"
									:label="item.number"
									:value="item.id"
									:style="{
										height: item.disable ? '0px' : 'auto',
									}"
									v-for="item in matterallCodelist[
										scope.$index
									]"
								></el-option>
							</el-select>
							<span v-else>{{ scope.row.materialNumber }}</span>
						</template>
					</el-table-column>
					<el-table-column
						align="left"
						label="规格型号(SKU)"
						prop="specification"
						width="280"
					/>
					<el-table-column
						align="left"
						label="物料名称"
						prop="materialName"
						width="150"
					></el-table-column>
					<el-table-column
						align="left"
						label="单位"
						prop="unitId"
						width="108"
					>
						<template #default="scope">
							<span>{{
								publicidbyname(unitlist, scope.row.unitId)
							}}</span>
						</template>
					</el-table-column>
					<el-table-column align="left" prop="qty" width="120">
						<template #header>
							<span
								class="iconfont icon-bianji1 iconfont-mg"
							></span
							>数量
						</template>
						<template #default="scope">
							<el-input
								:disabled="
									pagefromData.documentStatus !== 'a' &&
									pagefromData.documentStatus !== 'd'
								"
								:id="'qty' + scope.$index"
								:maxlength="13"
								@blur="
									numberChage(
										scope.row.qty,
										scope.$index,
										scope.row,
										'qty'
									)
								"
								@input="
									getRowCol(scope.row, scope.column, 'qty')
								"
								@paste="
									pasteExcel(
										$event,
										scope.$index,
										scope,
										'qty'
									)
								"
								placeholder="0"
								v-if="scope.row.isqtyshow"
								v-model="scope.row.qty"
							></el-input>
							<span v-else>{{
								scope.row.qty ? scope.row.qty : 0
							}}</span>
						</template>
					</el-table-column>
					<el-table-column align="left" prop="stockId" width="150">
						<template #header>
							<span
								class="iconfont icon-bianji1 iconfont-mg"
							></span
							>收货仓库
						</template>
						<template #default="scope">
							<el-select
								:disabled="
									pagefromData.documentStatus !== 'a' &&
									pagefromData.documentStatus !== 'd'
								"
								@change="changeWarehouse($event, scope.$index)"
								@click="
									getRowCol(
										scope.row,
										scope.column,
										'stockId'
									)
								"
								filterable
								placeholder="请选择"
								v-if="scope.row.isstockIdshow"
								v-model="scope.row.stockId"
							>
								<el-option
									:disabled="item.disabled"
									:key="item.id"
									:label="item.name"
									:value="item.id"
									:style="{
										height: item.disable ? '0px' : 'auto',
									}"
									v-for="item in warehouse"
								></el-option>
							</el-select>
							<span v-else>{{
								publicidbyname(warehouse, scope.row.stockId)
							}}</span>
						</template>
					</el-table-column>
					<el-table-column
						align="left"
						label="仓管员"
						prop="stockerName"
						width="108"
					/>
					<el-table-column align="left" prop="customerId" width="200">
						<template #header>
							<span
								class="iconfont icon-bianji1 iconfont-mg"
							></span
							>客户
						</template>
						<template #default="scope">
							<el-select
								:disabled="
									!customerWarehouseTaglist[scope.$index] ||
									(pagefromData.documentStatus !== 'a' &&
										pagefromData.documentStatus !== 'd')
								"
								@change="
									changecustomer(
										$event,
										scope.$index,
										'product'
									)
								"
								@click="
									getRowCol(
										scope.row,
										scope.column,
										'customerId'
									)
								"
								clearable
								filterable
								placeholder="请选择"
								v-if="scope.row.iscustomerIdshow"
								v-model="scope.row.customerId"
							>
								<el-option
									:key="item.id"
									:label="item.name"
									:value="item.id"
									v-for="item in customerlist"
									:style="{
										height: item.disable ? '0px' : 'auto',
									}"
								></el-option>
							</el-select>
							<span v-else>{{
								publicidbyname(
									customerlist,
									scope.row.customerId
								)
							}}</span>
						</template>
					</el-table-column>
					<el-table-column
						align="left"
						prop="customerStockId"
						width="220"
					>
						<template #header>
							<span
								class="iconfont icon-bianji1 iconfont-mg"
							></span
							>客户仓库
						</template>
						<template #default="scope">
							<el-select
								:disabled="
									!customerWarehouseTaglist[scope.$index] ||
									(pagefromData.documentStatus !== 'a' &&
										pagefromData.documentStatus !== 'd') ||
									!scope.row.customerId
								"
								@click="
									getRowCol(
										scope.row,
										scope.column,
										'customerStockId'
									)
								"
								clearable
								filterable
								placeholder="请选择"
								v-if="scope.row.iscustomerStockIdshow"
								v-model="scope.row.customerStockId"
							>
								<el-option
									:disabled="item.disabled"
									:key="item.id"
									:label="item.name"
									:value="item.id"
									:style="{
										height: item.disable ? '0px' : 'auto',
									}"
									v-for="item in customeStockArrylist[
										scope.$index
									]"
								></el-option>
							</el-select>
							<span v-else>{{
								publicidbyname(
									customeStockArrylist[scope.$index],
									scope.row.customerStockId
								)
							}}</span>
						</template>
					</el-table-column>
					<el-table-column align="left" prop="note" width="255">
						<template #header>
							<span
								class="iconfont icon-bianji1 iconfont-mg"
							></span
							>备注
						</template>
						<template #default="scope">
							<el-input
								:disabled="
									pagefromData.documentStatus !== 'a' &&
									pagefromData.documentStatus !== 'd'
								"
								:id="'note' + scope.$index"
								:maxlength="2000"
								@input="
									getRowCol(scope.row, scope.column, 'note')
								"
								v-if="scope.row.isnoteshow"
								v-model.trim="scope.row.note"
							></el-input>
							<span v-else>{{ scope.row.note }}</span>
						</template>
					</el-table-column>
				</el-table>
			</div>
		</div>
	</div>
</template>
<script>
import examineTop from '@/components/examineTop/index.vue';
import toolBtn from '@/components/public/toolBtn/toolBtn.vue';
import { mapState } from 'vuex';
import { unitPriceMethods } from '@/utils/util';
import { countMethodsUnitNumber } from '@/utils/count.js';
import {
	transformTimestamp,
	getObjValue,
	theUnitSet,
	batchhandle,
	quikecopyValue,
	oldstocklist,
} from '@/utils/pubulic.js';
import { pageoPtionProps } from '@/utils/printPagekey.js';
import { orderCopy, bottomAddRow } from '@/utils/takeMethods';

import {
	getStaffListApiUser,
	approvalFlowTrackingCreate,
	approvalFlowTrackingGetby,
	approvalFlowTrackingUpdate,
	// getStaffListApiUser,
} from '@/utils/api.js';

export default {
	name: 'AddWarehouseOutSheetSet',
	components: {
		examineTop,
		toolBtn,
	},
	data() {
		return {
			isexamineBtns: false,
			isExmaineTop: 3,
			radios: {},
			examineObj: {},
			salePrecisionNumber: [],
			isPrecision: [],
			isCount: [],
			isDisable: false,
			optionProps: JSON.parse(JSON.stringify(pageoPtionProps)),
			tableInfo: [], //操作结果
			documentStatuslist: [], // 单据状态
			documentTypelist: [], // 单据类型
			matterallCodelist: [[]], // 物料下拉数据
			specificationlist: [], // 规格型号（sku）下拉数据
			unitlist:
				this.$store.state && this.$store.state.storeData.allUnit
					? this.$store.state.storeData.allUnit
					: [], // 获取计量单位数据
			productDeptList: [], // 部门
			warehouse: [], //仓库下拉数据
			warechildhouse: [], // 仓位下拉数据
			customerlist: [], // 客户数据
			customeStockArrylist: [], // 所有的客户仓库下拉数据
			customeStocklist: [], // 客户仓库下拉数据
			loading: false,
			billNo: '', // 订单号
			customerWarehouseTaglist: [],
			//明细数据
			newdetailsIds: {
				id: 0, // 明细的id
				seq: 0, // 序号
				materialId: null, //物料编码
				materialName: '', //物料名称
				specification: '', //规格型号
				unitId: null, // 单位
				qty: null, // 数量
				stockId: null, // 仓库
				subStockId: null, // 仓位
				customerId: null, // 客户
				customerStockId: null, // 客户仓库
				stockerName: '', // 仓管员
				stockerId: '', //仓管员
				note: '',
			},
			pagefromData: {
				id: 0, // 单据的id
				billNo: '',
				date: transformTimestamp(new Date()), //下单日期
				documentStatus: 'a', // 单据状态
				billTypeId: '', // 单据类型
				stockOrgId: null, //组织
				deptId: '', // 部门
				details: [],
			},
			pageAction:
				this.$route.query && this.$route.query.type
					? this.$route.query.type
					: '', // 判断到该页面的操作状态
			btnType: [
				'copy',
				'save',
				'revoke',
				'audit',
				'de-approval',
				'delete',
				'push-down',
				'operation',
				'up-check',
				'down-check',
				// 'query',
				'refresh',
				's-p-t-g3',
				// 's-p-t-g4',
			],
			//明细数据
			addRow: {},
			selectRowIndexArr: [],
			selectRowIndex: '', // 当前选择行
			// 批量填充
			batchfill: {
				romIndex: null,
				columnIndex: null,
				columnkey: null,
			},
			heightNum: 0,
		};
	},
	watch: {
		orgId(value) {
			if (value) {
				if (
					this.pagefromData.id === 0 ||
					this.pagefromData.id === null ||
					this.pagefromData.id === ''
				) {
					this.pagefromData.stockOrgId = value;
					this.orgChange(value);
				}
				this.orgId = value;
			}
		},
		'pagefromData.documentStatus'() {
			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',
					'save',
					'revoke',
					'delete',
					'push-down',
					'operation',
					'up-check',
					'down-check',
					// 'query',
					'refresh',
					's-p-t-g3',
					// 's-p-t-g4',
				]; // 不需要显示的顶部按钮类型
			} else {
				this.btnType = [
					'save',
					'copy',
					'delete',
					'close-case',
					'split-order',
					'push-down',
					'refresh',
					'operation',
					'up-check',
					'down-check',
					//'s-p-t-g4',
					// 'query',
				];
			}
		},
	},
	computed: {
		...mapState({
			orgIdArr: (state) => (state ? state.user.orgIdArr : null),
			userId: (state) => state.user.userInfo.staffId || null,
			orgId: (state) =>
				state && state.org && state.org.orgId ? state.org.orgId : null,
			getPageObjValue: function () {
				// 根据key值显示对应的键名
				return function (arr, key) {
					return getObjValue(arr, key);
				};
			},
			getApprovalResult: (state) =>
				state.examine.examineStatus.approvalResult,
		}),
		isShow: function () {
			return this.isExmaineTop;
		},
		publicidbyname: function () {
			// 根据key值显示对应的键名
			return function (arr, key) {
				return theUnitSet(arr, key);
			};
		},
	},
	created() {
		this.heightNum =
			document.documentElement.clientHeight - (40 + 30 + 16 + 16);
		this.pagefromData.details = [
			JSON.parse(JSON.stringify(this.newdetailsIds)),
		];
		this.addRow = JSON.parse(JSON.stringify(this.newdetailsIds));
		this.Init();
		this.setApprovalFlowStatus();
	},
	mounted() {},
	methods: {
		setExamine(res) {
			if (
				res.status === 200 &&
				res.data &&
				JSON.stringify(res.data) !== '{}'
			) {
				console.log('调用成功================', res);
				this.examineObj = res.data;
				//有审批流,但是自己不能审批则返回1,否则返回2,如果没有审批流或者报错为了不阻断流程返回3
				let isApprover = res.data.isApprover;
				this.isExmaineTop = isApprover ? 2 : 1;
				console.log(
					this.isExmaineTop,
					'=============this.isExmaineTop =========='
				);
				if (
					!res.data ||
					JSON.stringify(res.data) === '{}' ||
					this.pagefromData.documentStatus !== 'b'
				) {
					console.log('12323232323232323');
					this.isExmaineTop = 3;
				}
				if (res.data.isDone) {
					console.log('1244444444444444444');
					this.pagefromData.documentStatus = 'c';
					this.isExmaineTop = 3;
				}
				this.isexamineBtns = false;
			} else {
				console.log('调用失败================', res);
				this.isexamineBtns = false;
				this.isExmaineTop = 3;
			}
		},

		handleDetails(r) {
			this.$http
				.showLoading(false)
				.get('Miscellaneous/get/' + r.data.sendOrderId)
				.then((req) => {
					if (req.status == 200) {
						this.setpageDate(req);
						this.pagefromData.documentStatus =
							req.data.documentStatus;
						if (
							this.pagefromData.documentStatus === 'a' ||
							this.pagefromData.documentStatus === 'd'
						) {
							this.isEdit = false;
						}
						this.setExamine(r);
					}
				});
			// this.saveIds = r.data.id;
			// this.baseInfoForm = purGetOrderId(this.baseInfoForm, r);
			this.$refs.multipleTable.clearSelection();
			this.multipleSelection = [];
			this.selectRowIndexArr = [];
		},
		handleSubmit(data) {
			this.isexamineBtns = true;
			this.$http
				.post(approvalFlowTrackingUpdate, data)
				.then((res) => {
					if (res.status === 200) {
						this.$message.success({
							message: '操作成功!',
							showClose: true,
						});
					}
					this.handleDetails(res);
				})
				.catch((err) => {
					if (err) {
						this.isExmaineTop = 3;
					}
				})
				.finally(() => {
					// this.isexamineBtns = false;
				});
		},
		//顶部按钮点击
		handleBtns(vals) {
			if (vals.type === 'out') {
				this.$router.go(-1);
			} else {
				let data = {
					approvalDetailsId: this.examineObj.approvalDetailsId,
					approvalOrderType: this.examineObj.sendOrderType,
					orderId: this.examineObj.sendOrderId,
					deptId: this.pagefromData.deptId || 0,
					orgId: this.pagefromData.stockOrgId,
					details: {
						trackId: this.examineObj.id,
						approverId: this.userId,
						approvalMethod: this.examineObj.currentApprovalMethod,
						approvalResult: vals.approvalResult,
						wayId: this.examineObj.currentWayId,
						remark: vals.remark,
						// upperId
					},
				};
				this.handleSubmit(data);
			}
		},
		//跳转到追踪页面
		handleOpen() {
			this.$router.push({
				path: '/examine/mange/examineFollow',
				query: { id: this.examineObj.id },
			});
		},
		//获取处理意见状态
		setApprovalFlowStatus() {
			this.radios = this.getApprovalResult;
		},

		//审批流-详情
		setApprovalFlowTrackingGetby(data) {
			if (
				this.$route.query.type === 'copy' &&
				this.pagefromData.outSourcOrderNo === ''
			) {
				this.examineObj = {};
				return;
			}
			if (data.tracking && data.tracking.remark) {
				this.$message.error({
					message: `单据由-${data.tracking.remark}`,
					showClose: true,
					duration: 5000,
				});
			}
			if (
				data.documentStatus === 'a' ||
				data.documentStatus == 'd' ||
				this.$route.query.type === 'copy'
			) {
				this.examineObj = data.tracking;
				return;
			}
			let obj = {
				orderId: data.id,
				deptId: data.deptId || 0,
				approvalOrderType: 19,
				orgId: data.stockOrgId,
			};
			this.$http
				.post(approvalFlowTrackingGetby, obj)
				.then((res) => {
					this.setExamine(res);
					if (res.status === 200) {
						this.setExamine(res);
						let details = res.data.details || [];
						let length = details.length;

						// if (!length) {
						// 	return false;
						// }
						// if (details[0].approvalResult !== 2) {
						// 	return false;
						// }
						// this.$message.error({
						// 	message: `"单据由${res.data.details[0].approverName}"审核不通过，拒绝理由”${res.data.details[0].remark}”`,
						// 	showClose: true,
						// 	duration: 5000,
						// });
					}
				})
				.catch((err) => {
					if (err) {
						this.isExmaineTop = 3;
					}
				});
		},
		//审批流-创建
		// setApprovalFlowTrackingCreate(data) {
		// 	let _this = this;
		// 	let obj = {
		// 		sendOrderId: data.id,
		// 		deptId: data.sellDept || 0,
		// 		sendId: this.userId,
		// 		sendOrderType: 5,
		// 		sendOrderBillNo: data.billNO,
		// 		orgId: data.sellOrg,
		// 	};
		// 	this.$http
		// 		.post(approvalFlowTrackingCreate, obj)
		// 		.then((res) => {
		// 			this.setExamine(res);
		// 		})
		// 		.catch((err) => {
		// 			if (err) {
		// 				this.isExmaineTop = 3;
		// 			}
		// 		});
		// },

		Init() {
			this.getUnit();
			this.getStatus();
			this.InItEditorCopy();
		},
		// 订单号 复制按钮
		saleOrderCopy() {
			orderCopy();
		},
		// 快粘贴
		pasteExcel(event, index, scope, key) {
			let rows = quikecopyValue(event);
			let recordAddIndex = index; // 记录行
			setTimeout(async () => {
				rows.forEach((it, idx) => {
					if (
						recordAddIndex + 1 <=
						this.pagefromData.details.length
					) {
						if (key == 'materialId') {
							this.matterCodeChange(it, 'number', recordAddIndex);
						}
						if (key === 'qty') {
							this.pagefromData.details[recordAddIndex][key] = it;
						}
						recordAddIndex++;
					}
				});
			}, 100);
		},
		// 保存或者提交的时候，对数据个别字段例如 is211 seq 做数据整理，避免提交保存失败
		arrangeData(type) {
			if (this.pagefromData.details) {
				let newDetails = this.pagefromData.details.map((v, index) => {
					return { ...v, seq: index };
				});
				this.pagefromData.details = newDetails;
				// 清空明细选中
				this.$refs.multipleTable.clearSelection();
				this.selectRowIndexArr = [];
			}
		},
		returnRemove(val, ind, key) {
			let value = unitPriceMethods(val);
			this.pagefromData.details[ind].qty = value;
		},
		// 初始化--编辑或者详情
		InItEditorCopy() {
			// 如果是复制，编辑，查看--过来的新增订单
			if (
				this.$route.query &&
				this.$route.query.type !== 'add' &&
				this.$route.query.productId
			) {
				this.getProductInfo(this.$route.query.productId);
			} else {
				this.pagefromData.stockOrgId = this.orgId;
				this.customerWarehouseTaglist = [true];
				this.getWarehouse(this.orgId);
				this.getAllcustomer();
				this.getProductdept(this.orgId);
			}
		},
		// 获取全部公司客户
		getAllcustomer() {
			var infocustomerlist =
				this.$store.state && this.$store.state.storeData
					? this.$store.state.storeData.customerlist
					: [];
			if (JSON.stringify(infocustomerlist) === '[]') {
				this.$http.get('SysConfig/GetCustomer').then((res) => {
					if (res.status === 200) {
						this.customerlist =
							this.$store.state.storeData.customerlist = res.data;
					}
				});
			} else {
				this.customerlist = infocustomerlist;
			}
		},
		// 根据客户id集合获取客户仓库
		initgetcustomerstocklist(customerStockIds, total) {
			if (customerStockIds && customerStockIds.length > 0) {
				this.$http
					.post('SysConfig/GetCustomerStockList', {
						customerIds: customerStockIds,
						orgId: this.pagefromData.stockOrgId,
					})
					.then((res) => {
						if (res.status == 200) {
							if (total && total > 0) {
								for (let tag = 0; tag < total; tag++) {
									this.customeStockArrylist[tag] = res.data;
								}
							}
						}
					});
			}
		},
		// 改变客户的时候获取对应的客户仓库 ---1 到时候应该替换为公司id
		changecustomer(id, index, type) {
			if (type !== 'init') {
				if (type === 'product') {
					this.pagefromData.details[index].customerStockId = '';
				}
				if (type === 'details') {
					this.pagefromData.details[0].details[
						index
					].customerStockId = '';
				}
			}
			if (id) {
				this.$http
					.post('SysConfig/GetCustomerStock', {
						customerId: this.pagefromData.details[index].customerId,
						orgId: this.pagefromData.stockOrgId,
						stockId: null,
					})
					.then((res) => {
						if (res.status === 200) {
							this.customeStockArrylist[index] =
								res.data && res.data.length > 0
									? oldstocklist(
											res.data.concat(
												oldstocklist(
													this.pagefromData.details
												).customerStockList
											),
											'retrieve'
									  )
									: oldstocklist(
											oldstocklist(
												this.pagefromData.details
											).customerStockList,
											'retrieve'
									  );
						}
					});
			}
		},
		// 生产组织下拉改变是 （会影响生产部门的数据）
		orgChange(value) {
			this.customerWarehouseTaglist = [true];
			this.pagefromData.deptId = null;
			this.getProductdept(value);
			this.getAllcustomer();
			this.getWarehouse(value);
			// 组织改变是清空明细只留一条
			this.pagefromData.details = [
				JSON.parse(JSON.stringify(this.newdetailsIds)),
			];
		},
		numberPrecisionMethods(index, unit, S, P, C) {
			if (this.pagefromData.details[index][unit]) {
				let tempList = this.unitlist.filter(
					(it) => it.id === this.pagefromData.details[index][unit]
				);
				if (tempList && tempList.length > 0) {
					tempList[0].precision == 0
						? (this[P][index] = true)
						: (this[P][index] = false);
					tempList[0].precision == 0
						? (this[S][index] = 0)
						: (this[S][index] = tempList[0].precision);
				}
			}
			this[P][index] = this[P][index] ? this[P][index] : false;
			this[S][index] =
				this[S][index] || this[S][index] == 0 ? this[S][index] : 10;
			if (
				!this.pagefromData.details[index].materialId &&
				!this.$route.query.id
			) {
				this[P][index] = true;
			}
			if (!this[C][index]) {
				this[C][index] = 1;
			}
		},
		// 数量改变时
		numberChage(val, index, item, key) {
			// 判断条件 子单位
			this.numberPrecisionMethods(
				index,
				'unitId',
				'salePrecisionNumber',
				'isPrecision',
				'isCount'
			);
			// 输入规则
			if (val) {
				if (val.toString().indexOf('.') !== -1) {
					let tempList = JSON.parse(
						JSON.stringify(
							this.unitlist.filter(
								(it) =>
									it.id ===
									this.pagefromData.details[index].unitId
							)
						)
					);
					if (tempList && tempList.length > 0) {
						tempList[0].roundoffType = 2;
					}
					let result = countMethodsUnitNumber(
						tempList,
						val,
						this.pagefromData.details[index][key],
						this.isCount[index],
						this.salePrecisionNumber[index]
					);
					this.pagefromData.details[index][key] = result.value;
					this.isCount[index] = result.isDefault;
				}
				let numD = '';
				let count = '\\d';
				for (
					let ind = 0;
					ind < this.salePrecisionNumber[index];
					ind++
				) {
					numD = numD + count;
				}
				let reg = '/^(-)*(\\d+)\\.(' + numD + ').*$/';
				this.pagefromData.details[index][key] =
					this.pagefromData.details[index][key]
						.toString()
						.replace(/[^\d^\\.]+/g, '')
						.replace('.', '$#$')
						.replace(/\./g, '')
						.replace('$#$', '.')
						.replace(eval(reg), '$1$2.$3');
			}
		},
		// 详情或者下推过来的数据处理
		setpageDate(res) {
			const names = [];
			const customerStockIds = [];
			this.pagefromData = JSON.parse(JSON.stringify(res.data));
			this.documentStatus = res.data.documentStatus;
			this.pagefromData.billTypeId = res.data.billTypeId + '';
			this.getAllcustomer();
			this.getWarehouse(res.data.stockOrgId, res.data.details);
			this.customeStockArrylist = [];
			this.matterallCodelist = [];
			if (res.data.details && res.data.details.length > 0) {
				res.data.details.forEach((it, index) => {
					names.push(it.materialNumber);
					if (it.customerId) {
						customerStockIds.push(it.customerId);
					}
					this.pagefromData.details[index].seq = index;
					setTimeout(() => {
						this.changeWarehouse(
							this.pagefromData.details[index].stockId,
							index,
							'init'
						);
					}, 300);
				});
				this.initMatterCode(names, res.data.details.length);
				this.initgetcustomerstocklist(
					customerStockIds,
					res.data.details.length
				);
			} else {
				this.customeStockArrylist.push([]);
				this.matterallCodelist.push([]);
				this.pagefromData.details = JSON.parse(
					JSON.stringify(this.newdetailsIds)
				);
			}
			// 详情里面根据组织id去获取明细的生产部门数据
			this.getProductdept(res.data.stockOrgId);
		},
		// 获取生产订单详情
		getProductInfo(prodctId) {
			this.$http.get('Miscellaneous/get/' + prodctId).then((res) => {
				// if (res.data.tracking && res.data.tracking.remark) {
				// 	this.$message.error({
				// 		message: `单据由-${res.data.tracking.remark}`,
				// 		showClose: true,
				// 		duration: 5000,
				// 	});
				// }
				this.setpageDate(res);
				this.setApprovalFlowTrackingGetby(res.data);
			});
		},
		getUnit() {
			var unitlist =
				this.$store.state && this.$store.state.storeData
					? this.$store.state.storeData.allUnit
					: [];
			if (
				JSON.stringify(
					this.$store.state && this.$store.state.storeData
						? this.$store.state.storeData.allUnit
						: []
				) === '[]'
			) {
				this.$http.get('SysConfig/GetUnitAllProperty').then((r) => {
					if (r.status === 200) {
						this.unitlist = this.$store.state.storeData.allUnit =
							r.data;
					}
				});
			} else {
				this.unitlist = unitlist;
			}
		},
		// 获取需要状态列表---[单据状态，领料状态，业务状态]
		getStatus() {
			this.$http.get('Miscellaneous/status/get').then((r) => {
				if (r.status === 200) {
					this.documentStatuslist = r.data.documentStatus;
					this.documentTypelist = r.data.miscellaneousBillType;
					this.pagefromData.billTypeId = Object.keys(
						r.data.miscellaneousBillType
					)[0];
				}
			});
		},
		// 物料/规格型号--下拉更新
		metterChange(val, index, type) {
			let metterInfo = {};
			if (type !== 'specification' && type !== 'number') {
				//物料
				metterInfo = this.matterallCodelist[index].filter((res) => {
					return val === res.id;
				})[0];
			} else {
				if (type === 'number') {
					//规格型号
					metterInfo = this.matterallCodelist[index].filter((res) => {
						return val === res.number;
					})[0];
				} else {
					//规格型号
					metterInfo = this.specificationalllist[index].filter(
						(res) => {
							return val === res.specifications;
						}
					)[0];
				}
			}
			if (type === 'specification') {
				// 规格型号改变
				this.matterCodeChange(metterInfo.number);
				this.pagefromData.details[index].materialId = metterInfo.id;
			}
			if (metterInfo) {
				this.pagefromData.details[index].materialId = metterInfo.id;
				this.pagefromData.details[index].materialName = metterInfo.name;
				this.pagefromData.details[index].materialNumber =
					metterInfo.number;
				this.pagefromData.details[index].specification =
					metterInfo.specifications;
				this.pagefromData.details[index].unitId = metterInfo.baseUnitId;
				this.pagefromData.details[index].bomId = metterInfo.bomId;
				this.pagefromData.details[index].is211 = metterInfo.is211;
				this.pagefromData.details[index].bomVersion =
					metterInfo.bomVersion;
			}
			this.pagefromData.details[index].qty = 0;
		},
		// 初始化一次性获取物料信息的接口
		initMatterCode(names, total) {
			this.$http
				.post('SysConfig/GetMaterialLikeList', {
					names: names,
					file: 'Number',
					orgId: this.pagefromData.stockOrgId,
				})
				.then((res) => {
					if (res.status == 200) {
						if (total && total > 0) {
							for (let tag = 0; tag < total; tag++) {
								this.matterallCodelist[tag] = res.data;
							}
						}
					}
				});
		},
		// 获取物料编码信息
		matterCodeChange(val, type, index) {
			const _this = this;
			if (val !== '') {
				this.loading = true;
				this.loading = false;
				this.$http
					.showLoading(false)
					.post('SysConfig/GetMaterial', {
						name: val,
						file: 'Number',
						orgId: this.pagefromData.stockOrgId,
					})
					.then((res) => {
						if (res.status === 200) {
							if (type === 'init') {
								_this.matterallCodelist.push(
									res.data && res.data.length > 0
										? res.data
										: []
								);
							} else if (index || index === 0) {
								this.matterallCodelist[index] =
									res.data && res.data.length > 0
										? res.data
										: [];
								if (type === 'number') {
									this.metterChange(val, index, type);
								}
							}
							this.$forceUpdate();
						}
					});
			}
		},
		//顶部按钮操作栏
		actionhandel(type) {
			this.isDisable = true;
			setTimeout(() => {
				this.isDisable = false;
			}, 2000);
			// 点击新增
			if (type === 'add') {
				this.$router.push({
					path: '/warehouse/other/otherWarehouseSet',
					query: { type: 'add', id: '', sjtag: Math.random() * 36 },
				});
			}
			if (type == 'exDetails') {
				if (
					!this.examineObj ||
					JSON.stringify(this.examineObj) === '{}'
				) {
					this.$message.error('该单据不存在审批流!');
					return false;
				}
				this.$router.push({
					path: '/examine/mange/examineFollow',
					query: { id: this.examineObj.id },
				});
			}
			//点击保存
			if (type === 'save') {
				this.savePageData();
			}
			//点击提交
			if (type === 'submit') {
				this.submitPageData();
			}
			//点击撤销
			if (type === 'revoke') {
				this.toolarFn('Miscellaneous/revoke');
			}
			//点击审核
			if (type === 'audit') {
				this.toolarFn('Miscellaneous/check');
			}
			//点击反审核
			if (type === 'de-approval') {
				this.toolarFn('Miscellaneous/recheck');
			}
		},
		// 保存或者提交成功返回数据处理
		saveOrsumitData(res) {
			this.billNo = res.data.billNo;
			this.pagefromData.id = res.data.id;
			this.pagefromData.date = transformTimestamp(res.data.date);
		},
		// 提交
		submitPageData() {
			let data = {};
			data = JSON.parse(JSON.stringify(this.pagefromData));
			// data.details.forEach(it =>)
			this.$http
				.post('Miscellaneous/submit', this.pagefromData)
				.then((res) => {
					if (res.status === 200) {
						this.pagefromData = JSON.parse(
							JSON.stringify(res.data)
						);
						this.pagefromData.billTypeId = res.data.billTypeId + '';
						this.$message.success({
							message: '提交成功',
							showClose: true,
						});
						this.setExamine({
							status: res.status,
							data: res.data.tracking,
						});
					}
				});
		},
		// 顶部操作方法-有公共的部分封装下
		toolarFn(path, detailsIds) {
			let formdata = detailsIds
				? {
						ids: [this.pagefromData.id],
						detailsIds: detailsIds,
				  }
				: { ids: [this.pagefromData.id] };
			this.$http.post(path, formdata).then((res) => {
				if (res.status === 200) {
					if (res.data && !detailsIds) {
						res.data[0].isSuccess
							? this.$message.success({
									message: res.data[0].msg
										? res.data[0].msg
										: '成功',
									showClose: true,
							  })
							: this.$message.error({
									message: res.data[0].msg,
									showClose: true,
							  });
					} else {
						this.tableInfo = res.data;
					}
					this.getProductInfo(this.pagefromData.id);
				}
			});
		},
		// 仓库选择修改-仓位信息更新
		changeWarehouse(value, index, type) {
			// 如果是详情带过来的数据 要根据仓库去查找下对于的仓位下拉数据,初始不要智控对应的仓位id
			let arry = this.warehouse.filter((it) => {
				return value === it.id;
			})
				? this.warehouse.filter((it) => {
						return value === it.id;
				  })
				: [];
			// 仓管员
			if (type !== 'init') {
				this.pagefromData.details[index].subStockId = '';
				this.pagefromData.details[index].customerId = '';
				this.pagefromData.details[index].customerStockId = '';
				this.pagefromData.details[index].stockerName =
					arry && arry.length > 0 ? arry[0].contacts : '';
				this.pagefromData.details[index].stockerId =
					arry && arry.length > 0 ? arry[0].contactsId : '';
			}
			if (this.warehouse.length > 0) {
				this.customerWarehouseTaglist[index] = this.warehouse.filter(
					(it) => {
						return value === it.id;
					}
				)
					? this.warehouse.filter((it) => {
							return value === it.id;
					  })[0].customerWarehouseTag
					: false;
			}
			// this.getWarechildhouse(value)
		},
		// 获取仓库
		getWarehouse(id, res) {
			this.$http.get('SysConfig/GetWarehouseByOrg/' + id).then((r) => {
				if (r.status === 200) {
					this.warehouse =
						r.data && r.data.length > 0
							? oldstocklist(
									r.data.concat(oldstocklist(res).stockList),
									'retrieve'
							  )
							: oldstocklist(
									oldstocklist(res).stockList,
									'retrieve'
							  );
					if (res) {
						this.customerWarehouseTaglist = [];
						res.forEach((item, index) => {
							this.customerWarehouseTaglist.push(
								this.warehouse.filter((it) => {
									return item.stockId === it.id;
								}).length > 0
									? this.warehouse.filter((it) => {
											return item.stockId === it.id;
									  })[0].customerWarehouseTag
									: false
							);
						});
					}
				}
			});
		},
		// 获取子仓位
		getWarechildhouse(id) {
			if (id) {
				this.$http
					.get('SysConfig/GetChildWarehouse/' + id)
					.then((r) => {
						if (r.status === 200) {
							this.warechildhouse = r.data;
						}
					});
			}
		},
		// 星星--头部必填ico显示
		mustAfter(obj) {
			let arry = [1, 5, 6];
			if (arry.indexOf(obj.columnIndex) !== -1) {
				return 'must';
			}
		},
		// 获取部门数据
		getProductdept(orgId) {
			if (orgId) {
				this.$http.post('SysConfig/GetDept/' + orgId).then((res) => {
					if (res.status === 200) {
						this.productDeptList = res.data;
					}
				});
			}
		},
		// 失焦处理
		selectBlur() {
			this.pagefromData.details.forEach((el) => {
				el.ismaterialIdshow = false;
				el.isqtyshow = false;
				el.isstockIdshow = false;
				el.iscustomerIdshow = false;
				el.iscustomerStockIdshow = false;
				el.isnoteshow = false;
			});
		},
		// 插入的行
		getInsertInfo() {
			this.pagefromData.details = bottomAddRow(
				this.pagefromData.details,
				JSON.parse(JSON.stringify(this.addRow))
			);
			this.customeStockArrylist.splice(
				this.pagefromData.details.length,
				0,
				[]
			);
			this.matterallCodelist.splice(
				this.pagefromData.details.length,
				0,
				[]
			);
			this.customerWarehouseTaglist.splice(
				this.pagefromData.details.length,
				0,
				true
			);
			// if (data.insertTopVal != 0) {
			//   for (let i = 0; i < data.insertTopVal; i++) {
			//     this.pagefromData.details.splice(this.selectRowIndex, 0, JSON.parse(JSON.stringify(this.addRow)))
			//     this.customeStockArrylist.splice(this.selectRowIndex, 0, [])
			//     this.matterallCodelist.splice(this.selectRowIndex, 0, [])
			//     this.customerWarehouseTaglist.splice(num, 0, true)
			//     this.selectRowIndex = parseInt(this.selectRowIndex) + 1
			//   }
			// }
			// if (data.insertBottomVal != 0) {
			//   for (let i = 0; i < data.insertBottomVal; i++) {
			//     var num = this.selectRowIndex + 1
			//     this.pagefromData.details.splice(num, 0, JSON.parse(JSON.stringify(this.addRow)))
			//     this.matterallCodelist.splice(num, 0, [])
			//     this.customeStockArrylist.splice(num, 0, [])
			//     this.customerWarehouseTaglist.splice(num, 0, true)
			//   }
			// }
			this.$nextTick(() => {
				this.$refs.multipleTable.$refs.bodyWrapper.scrollTop =
					this.$refs.multipleTable.$refs.bodyWrapper.scrollHeight;
			});
			this.selectBlur();
			this.arrangeData();
		},
		// 向下复制行
		bottomCopyRow(data) {
			// 判断行数
			if (this.selectRowIndexArr.length > 0) {
				if (this.selectRowIndexArr.length == 1) {
					const tableArr = JSON.parse(
						JSON.stringify(
							this.pagefromData.details[this.selectRowIndex]
						)
					);
					tableArr.id = 0;
					var insertNum = this.selectRowIndex + 1;
					this.pagefromData.details.splice(insertNum, 0, tableArr);
					this.matterallCodelist.splice(
						insertNum,
						0,
						JSON.parse(
							JSON.stringify(
								this.matterallCodelist[this.selectRowIndex]
							)
						)
					);
					this.customeStockArrylist.splice(
						insertNum,
						0,
						JSON.parse(
							JSON.stringify(
								this.customeStockArrylist[this.selectRowIndex]
									? this.customeStockArrylist[
											this.selectRowIndex
									  ]
									: []
							)
						)
					);
					this.customerWarehouseTaglist.splice(
						insertNum,
						0,
						JSON.parse(
							JSON.stringify(
								this.customerWarehouseTaglist[
									this.selectRowIndex
								]
							)
						)
					);
					this.selectBlur();
					this.arrangeData();
				} else {
					// 获取最后选择的行
					let lastIndex = -1;
					this.selectRowIndexArr.forEach((el) => {
						el > lastIndex ? (lastIndex = el) : false;
					});
					// 添加行
					this.selectRowIndexArr.forEach((el) => {
						lastIndex = lastIndex + 1;

						const tableArr = JSON.parse(
							JSON.stringify(this.pagefromData.details[el])
						);
						tableArr.id = 0;
						this.pagefromData.details.splice(
							lastIndex,
							0,
							tableArr
						);
						this.matterallCodelist.splice(
							lastIndex,
							0,
							JSON.parse(
								JSON.stringify(this.matterallCodelist[el])
							)
						);
						this.customeStockArrylist.splice(
							lastIndex,
							0,
							JSON.parse(
								JSON.stringify(
									this.customeStockArrylist[el]
										? this.customeStockArrylist[el]
										: []
								)
							)
						);
						this.customerWarehouseTaglist.splice(
							lastIndex,
							0,
							JSON.parse(
								JSON.stringify(
									this.customerWarehouseTaglist[el]
								)
							)
						);
					});
					this.selectBlur();
					this.arrangeData();
				}
			} else {
				this.$message.error({
					message: '请选择一行或多行复制!',
					showClose: true,
				});
			}
		},
		// 删除行
		selectDeleteRow(data) {
			if (this.selectRowIndexArr.length <= 0) {
				this.$message.warning({
					message: '请选择要删除的行!',
					showClose: true,
				});
				return;
			}
			// 不能为空
			if (
				this.pagefromData.details.length > 1 &&
				this.selectRowIndexArr.length < this.pagefromData.details.length
			) {
				this.selectRowIndexArr.forEach((k) => {
					this.pagefromData.details.forEach((l, index) => {
						if (k === l.seq) {
							this.pagefromData.details.splice(index, 1);
							this.matterallCodelist.splice(index, 1);
							this.customeStockArrylist.splice(index, 1);
							this.customerWarehouseTaglist.splice(index, 1);
						}
					});
				});
				this.selectBlur();
				this.arrangeData('delet');
			} else {
				this.$message.warning({
					message: '至少保留一行!',
					showClose: true,
				});
			}
		},
		// 批量填充
		copyCellcolumn(data) {
			let batcharry = [
				'materialId',
				'qty',
				'stockId',
				'customerId',
				'note',
			];
			this.pagefromData = batchhandle(
				this.pagefromData,
				this.matterallCodelist,
				this.batchfill.romIndex,
				this.batchfill.columnkey,
				batcharry
			);
			for (
				let i = this.batchfill.romIndex + 1;
				i < this.pagefromData.details.length;
				i++
			) {
				// 重新判断数量精度
				if (this.batchfill.columnkey == 'qty') {
					this.numberChage(
						this.pagefromData.details[i].qty,
						i,
						this.pagefromData.details[i],
						'qty'
					);
				}
				if (this.batchfill.columnkey == 'materialId') {
					this.pagefromData.details[i].qty = 0;
				}
			}
			// 如果有或者仓库的客户仓库的处理
			if (
				this.batchfill.columnkey === 'stockId' ||
				this.batchfill.columnkey === 'customerId'
			) {
				this.pagefromData.details.forEach((it, index) => {
					if (index > this.batchfill.romIndex) {
						if (this.batchfill.columnkey === 'stockId') {
							this.changeWarehouse(it.stockId, index);
						}
						if (this.batchfill.columnkey === 'customerId') {
							if (this.customerWarehouseTaglist[index]) {
								this.changecustomer(
									it.customerId,
									index,
									'product'
								);
							} else {
								this.pagefromData.details[index].customerId =
									'';
								this.pagefromData.details[
									index
								].customerStockId = '';
							}
						}
					}
				});
			}
			if (this.batchfill.columnkey === 'stockId') {
				let materialIds = [];
				this.pagefromData.details.forEach((it, index) => {
					if (it.materialId) {
						materialIds.push(it.materialId);
					}
				});
				// 获取即时库存
				this.$http
					.post('Public/get/inventorylist', {
						orgId: this.pagefromData.stockOrgId,
						materialIds: materialIds,
						stockId:
							this.pagefromData.details[this.batchfill.romIndex]
								.stockId,
					})
					.then((res) => {
						if (res.status === 200) {
							this.pagefromData.details.forEach((item, index) => {
								if (!res.data || res.data.length === 0) {
									if (index > this.batchfill.romIndex) {
										item.realStock = 0;
									}
								} else {
									res.data.forEach((i) => {
										if (
											i.materialId === item.materialId &&
											index > this.batchfill.romIndex
										) {
											item.realStock =
												i && i.surplusQty
													? i.surplusQty
													: 0;
										}
									});
								}
							});
						}
					});
			}
		},
		//注意这里是解构
		tableCellClassName({ row, column, rowIndex, columnIndex }) {
			row.index = rowIndex;
			column.index = columnIndex;
		},
		getRowCol(row, column, cell, event) {
			this.batchfill.romIndex = row.index;
			this.batchfill.columnIndex = column.index;
			if (typeof cell === 'string') {
				this.batchfill.columnkey = cell;
			} else {
				this.batchfill.columnkey = column.property;
			}
			// 处理表格下拉框输入框显示隐藏
			this.pagefromData.details.forEach((it, index) => {
				Object.assign(it, {
					ismaterialIdshow: false,
					isqtyshow: false,
					isstockIdshow: false,
					iscustomerIdshow: false,
					iscustomerStockIdshow: false,
					isnoteshow: false,
				});
			});
			var showtagarry = [
				'ismaterialIdshow',
				'isqtyshow',
				'isstockIdshow',
				'iscustomerIdshow',
				'iscustomerStockIdshow',
				'isnoteshow',
			];
			var parentshowtagarry = [
				'materialId',
				'qty',
				'stockId',
				'customerId',
				'customerStockId',
				'note',
			];
			showtagarry.forEach((k, idx) => {
				if (column.property == parentshowtagarry[idx]) {
					this.pagefromData.details[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.seq;
			}
			if (selection && selection.length > 0) {
				this.selectRowIndex = selection[0].seq;
			}
			if (selection.length != 0) {
				this.selectRowIndexArr = selection.map((it) => {
					return it.seq;
				});
			} else {
				this.selectRowIndexArr = [];
			}
		},
		// 选择全部明细(全选)
		selectRowAll(selection) {
			this.selectdataSet(selection);
		},
		// 选择的行（单选）
		selectRow(selection, row) {
			this.selectdataSet(selection);
		},
	},
};
</script>
<style lang="scss" scoped>
@import '@/assets/style/saleOrder/saleOrderCommon.scss';
@import '@/assets/style/saleOrder/orderDetails.scss';
@import '@/assets/style/saleOrder/common.scss';

::v-deep(.div-col .el-input__inner) {
	padding: 0 30px 0 8px;
	width: 165px !important;
}
</style>
