<template>
	<div class="main-container order-mc-bg">
		<!-- 打印摸版组件-->
		<PrintModel
			v-show="false"
			:printData="{
				tableData: multipleSelection ? multipleSelection : [],
				orderName: '销售订单',
			}"
			:theadDate="theadDate ? theadDate : []"
		></PrintModel>
		<div
			class="sale-container"
			:style="{ height: containerHeight + 'px!important' }"
		>
			<toolBtn
				@actionhandel="actionhandel"
				:btnType="btnType ? btnType : []"
			></toolBtn>
			<div
				class="TopInfo"
				v-if="OrderNoNameslist ? OrderNoNameslist.length > 0 : false"
			>
				关联查询：
				<strong>{{ OrderNoNameStr }}</strong>
				<strong>{{
					OrderNoNameslist
						? OrderNoNameslist.length > 5
							? '等'
							: ''
						: ''
				}}</strong>
				{{ $route.query.actionName ? $route.query.actionName : '' }}所选
				<strong>{{
					OrderNoNameslist ? OrderNoNameslist.length : ''
				}}</strong
				>条明细行的 <strong>{{ CXaction }}</strong
				>结果
			</div>
			<div class="sale-page-body">
				<div class="sale-page-table-header">
					<el-form :inline="true">
						<el-row class="form-row1">
							<el-col :span="20">
								<el-row :gutter="2">
									<el-col :span="4">
										<el-form-item
											class="Iisshow"
											label="订单号"
										>
											<el-input
												v-model.trim="orderNumber"
												placeholder="请输入订单号"
												@keyup.enter="searchList"
												class="f_12"
												@input="
													searchCom(
														orderNumber,
														'orderNum',
														'ipt'
													)
												"
											></el-input>
											<div
												:data-clipboard-text="
													orderNumber
												"
												@click="saleOrderCopy"
												class="copyBtn"
											>
												<i
													class="el-icon-document-copy"
												/>
											</div>
										</el-form-item>
									</el-col>
									<el-col :span="4">
										<el-form-item label="单据状态">
											<el-select
												v-model="formBills"
												filterable
												placeholder="选择状态"
												:clearable="true"
												@change="
													clearCom(
														formBills,
														'billStatus'
													)
												"
											>
												<el-option
													class="f_12"
													v-for="item in statusForm.bills"
													@click="
														searchCom(
															formBills,
															'billStatus',
															'opt'
														)
													"
													:key="item.id"
													:label="item.name"
													:value="item.id"
												></el-option>
											</el-select>
										</el-form-item>
									</el-col>
									<el-col :span="4">
										<el-form-item label="销售部门">
											<el-cascader
												ref="cascader"
												@change="
													searchCom(
														deptSelVal,
														'saleDeptId',
														'ipt',
														'type'
													)
												"
												style="font-size: 12px"
												v-model="deptSelVal"
												placeholder="请选择部门"
												:options="deptList"
												:props="optionProps"
												:show-all-levels="false"
												:clearable="true"
											></el-cascader>
										</el-form-item>
									</el-col>
									<el-col :span="4">
										<el-form-item label="销售员">
											<el-select
												v-model="personVal"
												:clearable="true"
												filterable
												placeholder="选择销售员"
												@change="
													clearCom(
														personVal,
														'salerId'
													)
												"
											>
												<el-option
													class="f_12"
													v-for="item in salePersonsList"
													:key="item.id"
													@click="
														searchCom(
															personVal,
															'salerId',
															'opt'
														)
													"
													:label="item.name"
													:value="item.id"
												></el-option>
											</el-select>
										</el-form-item>
									</el-col>
									<el-col :span="4">
										<el-form-item
											class="Iisshow"
											label="客户"
										>
											<el-input
												class="f-12"
												placeholder="请输入客户"
												@keyup.enter="searchList"
												v-model="search.customers"
											></el-input>
											<div
												:data-clipboard-text="
													search.customers
												"
												@click="saleOrderCopy"
												class="copyBtn"
											>
												<i
													class="el-icon-document-copy"
												/>
											</div>
										</el-form-item>
									</el-col>
									<el-col :span="4">
										<el-form-item
											class="Iisshow"
											label="产品"
										>
											<el-input
												v-model.trim="productVal"
												placeholder="请输入产品物料名称/编码/SKU"
												@keyup.enter="searchList"
												class="f_12"
												@input="
													searchCom(
														productVal,
														'product',
														'ipt'
													)
												"
											></el-input>
											<div
												:data-clipboard-text="
													productVal
												"
												@click="saleOrderCopy"
												class="copyBtn"
											>
												<i
													class="el-icon-document-copy"
												/>
											</div>
										</el-form-item>
									</el-col>
								</el-row>
							</el-col>
							<el-col :span="4" class="form-row-lastcol">
								<el-row :gutter="2">
									<el-col :span="24">
										<el-form-item class="form-group1">
											<div
												class="alias-open"
												@click="openRow"
											>
												<span
													class="iconfont"
													:class="[
														isDown
															? 'icon-shuangjiantouzhankai-xia'
															: 'icon-shuangjiantoushouqi-shang',
													]"
												></span>
											</div>
											<el-button
												size="small"
												@click="resetSearch()"
												>重置</el-button
											>
											<el-button
												type="primary"
												size="small"
												@click="searchList()"
												>搜索</el-button
											>
										</el-form-item>
									</el-col>
								</el-row>
							</el-col>
						</el-row>
						<el-row class="form-row2" v-if="rowShow">
							<el-col :span="21">
								<el-row :gutter="2">
									<el-col :span="4">
										<el-form-item label="订单类型">
											<el-select
												v-model="ordVal"
												:clearable="true"
												placeholder="选择订单类型"
												@change="
													clearCom(
														ordVal,
														'billtypeId'
													)
												"
											>
												<el-option
													class="f_12"
													v-for="item in statusForm.orders"
													@click="
														searchCom(
															item.id,
															'billtypeId',
															'opt'
														)
													"
													:key="item.id"
													:label="item.name"
													:value="item.id"
												></el-option>
											</el-select>
										</el-form-item>
									</el-col>
									<el-col :span="4">
										<el-form-item label="供应组织">
											<el-select
												v-model="supplyVal"
												:clearable="true"
												placeholder="选择供应组织"
												@change="
													clearCom(
														supplyVal,
														'supplyorgId'
													)
												"
											>
												<el-option
													class="f_12"
													v-for="item in statusForm.supplys"
													@click="
														searchCom(
															item.id,
															'supplyorgId',
															'opt'
														)
													"
													:key="item.id"
													:label="item.name"
													:value="item.id"
												></el-option>
											</el-select>
										</el-form-item>
									</el-col>
									<el-col :span="7">
										<el-form-item label="下单日期">
											<el-date-picker
												@change="
													dateCom(
														placeValue,
														'placeValue',
														'placeOrderDateBegin',
														'placeOrderDateOver'
													)
												"
												class="f_12"
												v-model="placeValue"
												value-format="YYYY-MM-DD"
												format="YYYY-MM-DD"
												type="daterange"
												start-placeholder="开始时间"
												end-placeholder="结束时间"
											></el-date-picker>
										</el-form-item>
									</el-col>
									<el-col :span="7">
										<el-form-item label="期望交期">
											<el-date-picker
												class="f_12"
												v-model="expectValue"
												@change="
													dateCom(
														expectValue,
														'expectValue',
														'leadTimeBegin',
														'leadTimeOver'
													)
												"
												value-format="YYYY-MM-DD"
												format="YYYY-MM-DD"
												type="daterange"
												start-placeholder="开始时间"
												end-placeholder="结束时间"
											></el-date-picker>
										</el-form-item>
									</el-col>
								</el-row>
								<el-row :gutter="2" class="form-row2-row2">
									<el-col :span="8" class="form-r2-r2-col">
										<el-form-item label="自定义条件1">
											<CustomCondition
												:getCustomerItem="
													statusForm ? statusForm : {}
												"
												@result="
													resultCom(
														$event,
														'customerSel1',
														'customerObj1',
														'tempObj1'
													)
												"
												:key="compKey1"
												:reset="reset"
											></CustomCondition>
										</el-form-item>
									</el-col>
									<el-col :span="8">
										<el-form-item label="自定义条件2">
											<CustomCondition
												:getCustomerItem="
													statusForm ? statusForm : {}
												"
												@result="
													resultCom(
														$event,
														'customerSel2',
														'customerObj2',
														'tempObj2'
													)
												"
												:key="compKey2"
												:reset="reset"
											></CustomCondition>
										</el-form-item>
									</el-col>
									<el-col :span="8">
										<el-form-item label="自定义条件3">
											<CustomCondition
												:getCustomerItem="
													statusForm ? statusForm : {}
												"
												@result="
													resultCom(
														$event,
														'customerSel3',
														'customerObj3',
														'tempObj3'
													)
												"
												:key="compKey3"
												:reset="reset"
											></CustomCondition>
										</el-form-item>
									</el-col>
								</el-row>
							</el-col>
						</el-row>
					</el-form>
				</div>
				<div
					class="sale-page-table-body"
					:style="{ height: heightNum + 'px' }"
				>
					<el-table
						class="table-box"
						:data="tableData"
						border
						ref="tableInfoRef"
						:max-height="heightNum"
						v-loading="tableLoading"
						@cell-click="openDetails"
						@row-dblclick="openDetailsDB"
						@selection-change="handleSelectionChange"
						style="width: 100%; font-size: 12px"
					>
						<el-table-column
							type="selection"
							align="center"
							width="40"
							fixed
						/>
						<el-table-column
							prop="orderNum"
							label="销售订单号"
							align="left"
							fixed
							width="187"
						>
							<template #default="scope">
								<span style="color: #4178d5">{{
									scope.row.orderNum ? scope.row.orderNum : ''
								}}</span>
							</template>
						</el-table-column>
						<el-table-column
							prop="placeOrderDate"
							label="下单日期"
							align="left"
							width="86"
						/>
						<el-table-column
							prop="leadTime"
							label="期望交期"
							align="left"
							width="86"
						/>
						<el-table-column
							prop="sellOrderType"
							align="left"
							label="销售订单类型"
							width="100"
						/>
						<el-table-column
							prop="billStatus"
							label="单据状态"
							align="center"
							width="80"
						/>
						<el-table-column
							prop="closeStatus"
							label="关闭状态"
							align="center"
							width="80"
						/>
						<el-table-column
							prop="sellPart"
							label="销售部门"
							align="left"
							width="172"
						/>
						<el-table-column
							prop="sellPerson"
							label="销售员"
							align="center"
							width="120"
						/>
						<el-table-column
							prop="qc"
							label="跟单员"
							align="center"
							width="120"
						/>
						<el-table-column
							prop="custom"
							label="客户"
							align="left"
							width="172"
						/>
						<el-table-column
							prop="materialNumber"
							label="物料编码"
							align="left"
							width="172"
						/>
						<el-table-column
							prop="sku"
							label="规格型号(SKU)"
							align="left"
							width="280"
						>
							<template #default="scope">
								<div class="noteOrder">
									{{ scope.row.sku ? scope.row.sku : '' }}
								</div>
							</template>
						</el-table-column>
						<el-table-column
							prop="partName"
							label="物料名称"
							align="left"
							width="150"
						/>
						<el-table-column
							prop="sellNumber"
							label="销售数量"
							align="right"
							width="100"
						/>
						<el-table-column
							prop="purchaseNumber"
							label="采购/排产数量"
							align="right"
							width="120"
						/>
						<el-table-column
							prop="innerStorageNumber"
							label="入库数量"
							align="right"
							width="100"
						>
							<template #default="scope">
								{{
									scope.row.innerStorageNumber
										? scope.row.innerStorageNumber
										: 0
								}}
							</template>
						</el-table-column>
						<el-table-column
							prop="noInnerStorageNumber"
							label="未入库数量"
							align="right"
							width="100"
						>
							<template #default="scope">{{
								scope.row.noInnerStorageNumber
									? scope.row.noInnerStorageNumber
									: 0
							}}</template>
						</el-table-column>

						<el-table-column
							prop="checkoutNumber"
							label="累计出库数量"
							align="right"
							width="100"
						>
							<template #default="scope">{{
								scope.row.checkoutNumber
									? scope.row.checkoutNumber
									: 0
							}}</template>
						</el-table-column>
						<el-table-column
							prop="surplusNumber"
							label="剩余未出数量"
							align="right"
							width="100"
						>
							<template #default="scope">{{
								scope.row.surplusNumber
									? scope.row.surplusNumber
									: 0
							}}</template>
						</el-table-column>
						<el-table-column
							prop="outingNumber"
							label="出货中数量"
							align="right"
							width="100"
						>
							<template #default="scope">{{
								scope.row.outingNumber
									? scope.row.outingNumber
									: 0
							}}</template>
						</el-table-column>
						<el-table-column
							prop="stayOutNumber"
							label="待出数量"
							align="right"
							width="100"
						>
							<template #default="scope">{{
								scope.row.stayOutNumber
									? scope.row.stayOutNumber
									: 0
							}}</template>
						</el-table-column>
						<el-table-column
							prop="unitPrice"
							align="right"
							label="含税单价"
							width="100"
						>
							<template #default="scope">{{
								scope.row.unitPrice
									? scope.row.unitPrice * 1
									: 0
							}}</template>
						</el-table-column>
						<el-table-column
							prop="priceTax"
							align="right"
							label="价税合计(本位币)"
							width="120"
						>
							<template #default="scope"
								>￥{{
									scope.row.priceTax
										? scope.row.priceTax * 1
										: 0
								}}</template
							>
						</el-table-column>
						<el-table-column
							prop="remarks"
							label="备注"
							align="left"
							width="280"
						>
							<template #default="scope">
								<div class="noteOrder">
									{{
										scope.row.remarks
											? scope.row.remarks
											: ''
									}}
								</div>
							</template>
						</el-table-column>
						<el-table-column
							prop="supplyOrigin"
							label="供应组织"
							align="left"
							width="178"
						/>
						<!-- <el-table-column
							prop="sellOrderType"
							align="left"
							label="销售订单类型"
							width="100"
						/> -->
						<el-table-column
							prop="barCode"
							align="left"
							label="条码"
							width="120"
						/>
					</el-table>
				</div>
			</div>
			<!-- 操作结果 -->
			<el-dialog title="操作结果" v-model="dialogVisible" width="40%">
				<div class="sale-page-table-body">
					<el-table
						class="table-box"
						:destroy-on-close="true"
						:data="tableInfo"
						height="300"
						border
						:header-cell-class-name="headerRigthMethod"
						id="tableInfo-table"
					>
						<el-table-column prop="date" label="序号" width="50">
							<template #default="scope">
								<span>{{ scope.$index + 1 }}</span>
							</template>
						</el-table-column>
						<el-table-column
							prop="orderNo"
							label="销售订单号"
							width="200"
						></el-table-column>
						<el-table-column prop="a" label="指令" width="110">
							<template #default>
								<span>
									{{
										actionType === 'submit'
											? '提交'
											: actionType === 'revoke'
											? '撤销'
											: actionType === 'audit'
											? '审核'
											: actionType === 'de-approval'
											? '反审'
											: actionType === 'delet'
											? '删除'
											: actionType === 'finish'
											? '完工'
											: actionType === 'close-case'
											? '结案'
											: actionType === 'de-excute-start'
											? '反执行至开工'
											: actionType === 'de-approval'
											? '反审'
											: actionType === 'delet'
											? '删除'
											: actionType === 'finish'
											? '完工'
											: actionType === 'close-case'
											? '结案'
											: actionType === 'de-excute-finish'
											? '反执行至完工'
											: ''
									}}
								</span>
							</template>
						</el-table-column>
						<el-table-column label="结果" width="80">
							<template #default="scope">
								<span
									:style="{ 'txt-Red': scope.row.isSuccess }"
									>{{
										scope.row.isSuccess ? '成功' : '失败'
									}}</span
								>
							</template>
						</el-table-column>
						<el-table-column prop="msg" label="信息">
							<template #default="scope">
								<span class="txt-Red">{{ scope.row.msg }}</span>
							</template>
						</el-table-column>
					</el-table>
				</div>
				<template #footer>
					<span class="dialog-footer">
						<span
							class="f-12 ext-black-light"
							style="margin-right: 25px"
						>
							共{{ tableInfo ? tableInfo.length : '' }}条
						</span>
						<el-button
							size="small"
							@click="
								handelhtmlToExcel(
									'tableInfo-table',
									'下单结果'
								);
								dialogVisible = false;
							"
							>导 出</el-button
						>
						<el-button
							type="primary"
							size="small"
							@click="dialogVisible = false"
							>关 闭</el-button
						>
					</span>
				</template>
			</el-dialog>
			<!-- 选择下推单据 -->
			<el-dialog
				title="选择下推单据"
				:destroy-on-close="true"
				v-model="dialogxt"
				width="20%"
				top="15%"
			>
				<el-radio-group v-model="pushdownVal">
					<el-radio
						v-for="item in pushDownList"
						:key="item.id"
						:value="item.id"
						:label="item.id"
						>{{ item.value }}</el-radio
					>
				</el-radio-group>
				<template #footer>
					<span class="dialog-footer">
						<el-button size="small" @click="dialogxt = false"
							>取 消</el-button
						>
						<el-button
							type="primary"
							size="small"
							@click="sumitPushdown(pushdownVal)"
							>确 定</el-button
						>
					</span>
				</template>
			</el-dialog>
			<!-- 选择上下查单据 -->
			<el-dialog
				:destroy-on-close="true"
				:title="CXttile"
				v-model="dialogCX"
				width="20%"
				top="15%"
			>
				<div class="sale-page-table-body">
					<el-radio-group
						v-model="CXcheckVal"
						v-if="CXttile === '上查结果'"
					>
						<el-radio
							:label="it.orderType"
							v-for="(it, index) in upOrDownList"
							:key="index"
						>
							{{ it.orderName }}({{ it.orderCount }})
						</el-radio>
					</el-radio-group>
					<el-radio-group
						v-model="CXcheckVal"
						v-if="CXttile === '下查结果'"
					>
						<el-radio
							:label="it.orderType"
							v-for="(it, index) in upOrDownList"
							:key="index"
						>
							{{ it.orderName }}({{ it.orderCount }})
						</el-radio>
					</el-radio-group>
				</div>
				<template #footer>
					<span class="dialog-footer">
						<el-button size="small" @click="dialogCX = false"
							>取 消</el-button
						>
						<el-button type="primary" size="small" @click="submitCX"
							>确 定</el-button
						>
					</span>
				</template>
			</el-dialog>
			<div class="sale-page-footer">
				<div class="footer-left">
					<div>
						<span>销售数量:</span>
						<span class="sale-number-color">{{
							pagingSaleNumber
						}}</span>
					</div>
					<div>
						<span>累计出库数量:</span>
						<span class="sale-number-color">{{
							cumulativeIssueQuantity
						}}</span>
					</div>
					<div>
						<span>剩余未出数量:</span>
						<span class="sale-number-color">{{
							totalOutQuantity
						}}</span>
					</div>
					<div>
						<span>价税合计(本位币):</span>
						<span class="sale-number-color">{{
							totalBaseCurrency
						}}</span>
					</div>
				</div>
				<div class="footer-right">
					<el-pagination
						:page-sizes="pagingList"
						:page-size="pageSize"
						layout="slot,sizes,total, prev,pager, next,jumper"
						:total="totalItemNumber"
						popper-class="每页显示"
						:pager-count="5"
						@size-change="handleSizeChange"
						@current-change="handleCurrentChange"
					>
						<span class="total-select-item">
							共选中
							<text
								style="
									text-align: center;
									color: #4178d5;
									padding: 0 1px;
								"
								>{{ selectItem }}</text
							>行
						</span>
					</el-pagination>
				</div>
				<div class="footer-pagination-total-page">
					<span>共{{ totalPageNumber }}页</span>
				</div>
			</div>
		</div>
	</div>
</template>
<script>
import { orderCopy } from '@/utils/takeMethods';
import { mapState, mapActions } from 'vuex';
import { toRaw } from '@vue/reactivity';
import { ElMessageBox, ElMessage } from 'element-plus';
import {
	getStatusType,
	exporthandel,
	htmlToExcel,
	removeChildren,
	resultComMethods,
	customChangeMethods,
	printPreview,
	dateData,
} from '@/utils/pubulic.js';
import { getStaffListApiUser } from '@/utils/api.js';
import CustomCondition from '@/components/public/CustomCondition.vue';

export default {
	name: 'SaleOrder',
	components: {
		CustomCondition,
	},
	data() {
		return {
			theadDate: [
				{
					thName: 'No.',
					field: '',
				},
				{
					thName: '销售订单号',
					field: 'orderNum',
				},
				{
					thName: '物料编码',
					field: 'materialNumber',
				},
				{
					thName: '物料名称',
					field: 'partName',
				},
				{
					thName: '规格型号',
					field: 'sku',
				},
				{
					thName: '数量',
					field: 'sellNumber',
				},
				{
					thName: '含税单价',
					field: 'unitPrice',
				},
				{
					thName: '单位',
					field: 'unit',
				},
				{
					thName: '价税合计',
					field: 'priceTax',
				},
				{
					thName: '备注',
					field: 'remarks',
				},
			], // 打印要的字段表
			containerHeight: '', // body容器高度
			deptList: [], // 销售部门
			salePersonsList: [], // 销售员集合
			salePerson: '', // 销信员
			tableLoading: false, // 列表加载
			pagingSaleNumber: '', // 底部销售数量
			cumulativeIssueQuantity: '', // 累计出库数量
			totalOutQuantity: '', // 剩余未出数量
			totalBaseCurrency: '', // 价税合计(本位币)
			pagingList: [50, 100, 150], // 底部分页
			getCustomerNumList: [], // 获取客户列表
			optionProps: {
				expandTrigger: 'hover',
				checkStrictly: true,
				value: 'id',
				label: 'name',
				children: 'children',
				emitPath: false,
			},
			reset: false,
			pageSize: 50,
			pageNo: 1,
			totalItemNumber: 0,
			totalPageNumber: 0,
			selectItem: 0,
			statusForm: {
				// 自定义条件 订单类型 单据状态 供应组织 是否211 是否赠品 关闭状态
				customCondition: [],
				orders: [],
				bills: [],
				supplys: [],
				is211: [],
				isFree: [],
				cloStatus: [],
				warehouse: [],
				childWarehouse: [],
				orgAllPerson: [],
				reccondition: [],
				settleType: [],
				dcurrency: [],
				qcPerson: [],
				supplyChainType: [],
				settleOrg: [],
				suppliers: [],
			},
			customerSel1: '', //条件
			customerSel2: '',
			customerSel3: '',
			customerObj1: null,
			customerObj2: null,
			customerObj3: null,
			tempObj1: null,
			tempObj2: null,
			tempObj3: null,
			compKey1: 0,
			compKey2: 0,
			compKey3: 0,
			search: {
				// 列表请求参数
				pageNo: 1,
				pageSize: 50,
				orgId: '',
				customers: '',
				detailsIds: [],
			},
			selectIndex: [], // 选择的条目
			orderNumber: '', // 订单号
			formBills: '', // 单据状态
			deptSelVal: '', // 销售部门
			personVal: '', // 销售人员
			customVal: '', // 客户
			productVal: '', // 产品
			ordVal: '', // 订单类型
			supplyVal: '', // 供应组织
			placeValue: null, // 下单日期
			expectValue: null, // 期望交期
			tableData: [], // 表格数据
			rowShow: false, // 展开行
			heightNum: 0, // 搜索高度
			windowHeight: 0, // 屏幕高度
			isDown: true, // 按钮切换
			multipleSelection: [],
			btnType: [
				'save',
				'split-order',
				'print-aterial-list',
				'finish',
				'close-case',
				'de-excute-start',
				'de-excute-finish',
				'exDetails',
			], // 禁用按钮
			dialogVisible: false, // 操作弹框显示
			tableInfo: [], // 操作结果
			actionType: '', // 操作类型
			pushdownVal: null, // 下推选择
			dialogxt: false, // 选择下推单据弹框显示
			OrdedetailIds: [], // 勾选的明细id集合
			pushDownList: [], // 下推集合
			dialogCX: false, // 上下查弹框控制
			upOrDownList: [], // 上查下查弹窗可选数据
			OrderNoNameslist: [], // 上查下查的订单号
			OrderNoNameStr: '', // 上查下查的订单号str
			CXaction: '', // 判断是上查还是下查
			CXttile: '', // 查询弹框的名称
			CXcheckVal: '', // 选择的查询radio
			OrderNoNames: [], // 选择的单据订单号集合
			isTrue: true, // 关闭反关闭
			testUserPerson: [],
		};
	},
	methods: {
		...mapActions({
			setSettletype: 'storeData/setSettletype',
			setDcurrency: 'storeData/setDcurrency',
			setCustomer: 'storeData/setCustomer',
			setRecondtion: 'storeData/setRecondtion',
			setSupplierSelect: 'storeData/setSupplierSelect',
			setEnumType: 'storeData/setEnumType',
			setDicSale: 'storeData/setDicSale',
			setGetAllUserList: 'storeData/setGetAllUserList',
		}),
		Init() {
			let _this = this;
			let vuexKey = [
				'dcurrency',
				'customer',
				'settletype',
				'recondtion',
				'supplierSelect',
				'dicSale',
			];
			let setVuexData = [
				'setDcurrency',
				'setCustomer',
				'setSettletype',
				'setRecondtion',
				'setSupplierSelect',
				'setDicSale',
			];
			let requestQueryUrl = [
				'SysConfig/GetDcurrency',
				'SysConfig/GetCustomer',
				'SysConfig/GetSettletype',
				'SysConfig/GetReccondition',
				'SysConfig/supplier/select',
				'Dictionary/sale',
			];
			let resDataQuery = [
				'dcurrency',
				'getCustomerNumList',
				'settleType',
				'reccondition',
				'suppliers',
				'customCondition',
			];
			vuexKey.forEach((ele, ind) => {
				if (_this[vuexKey[ind]] && _this[vuexKey[ind]].length > 0) {
					if (typeof resDataQuery[ind] == 'string') {
						_this.statusForm[resDataQuery[ind]] = JSON.parse(
							JSON.stringify(_this[vuexKey[ind]])
						);
					} else {
						resDataQuery[ind].forEach((ele, index) => {
							_this.statusForm[resDataQuery[ind][index]] =
								JSON.parse(JSON.stringify(_this[vuexKey[ind]]));
						});
					}
				} else {
					_this.$http
						.showLoading(false)
						.get(requestQueryUrl[ind])
						.then((r) => {
							if (r.status === 200) {
								if (typeof resDataQuery[ind] == 'string') {
									_this.statusForm[resDataQuery[ind]] =
										r.data;
								} else {
									resDataQuery[ind].forEach((ele, index) => {
										_this.statusForm[
											resDataQuery[ind][index]
										] = r.data;
									});
								}
								_this[setVuexData[ind]](
									_this.statusForm[resDataQuery[ind]]
								);
							}
						});
				}
			});

			// 枚举 - 订单类型、状态
			if (_this.enumType && JSON.stringify(_this.enumType) !== '{}') {
				for (const key in _this.enumType.salOrderType) {
					// 单据类型
					_this.statusForm.orders.push({
						id: key,
						name: _this.enumType.salOrderType[key],
					});
				}
				for (const key in _this.enumType.documentStatus) {
					// 单据状态
					_this.statusForm.bills.push({
						id: key,
						name: _this.enumType.documentStatus[key],
					});
				}
				for (const key in _this.enumType.closeStatus) {
					// 关闭状态
					_this.statusForm.cloStatus.push({
						id: key,
						name: _this.enumType.closeStatus[key],
					});
				}
				for (const key in _this.enumType.supplyChainType) {
					// 供应链
					_this.statusForm.supplyChainType.push({
						id: key,
						name: _this.enumType.supplyChainType[key],
					});
				}
				for (const key in _this.enumType.is211Type) {
					// 是否211
					_this.statusForm.is211.push({
						id: key,
						name: _this.enumType.is211Type[key],
					});
				}
				for (const key in _this.enumType.isFreeType) {
					// 是否赠品
					_this.statusForm.isFree.push({
						id: key,
						name: _this.enumType.isFreeType[key],
					});
				}
			} else {
				_this.$http
					.showLoading(false)
					.get('SalOrder/GetEnum')
					.then((req) => {
						// 获取状态和类型
						if (req.status === 200) {
							if (req.data) {
								_this.setEnumType(req.data);
								for (const key in req.data.salOrderType) {
									// 单据类型
									_this.statusForm.orders.push({
										id: key,
										name: req.data.salOrderType[key],
									});
								}
								for (const key in req.data.documentStatus) {
									// 单据状态
									_this.statusForm.bills.push({
										id: key,
										name: req.data.documentStatus[key],
									});
								}
								for (const key in req.data.closeStatus) {
									// 关闭状态
									_this.statusForm.cloStatus.push({
										id: key,
										name: req.data.closeStatus[key],
									});
								}
								for (const key in req.data.supplyChainType) {
									// 供应链
									_this.statusForm.supplyChainType.push({
										id: key,
										name: req.data.supplyChainType[key],
									});
								}
								for (const key in req.data.is211Type) {
									// 是否211
									_this.statusForm.is211.push({
										id: key,
										name: req.data.is211Type[key],
									});
								}
								for (const key in req.data.isFreeType) {
									// 是否赠品
									_this.statusForm.isFree.push({
										id: key,
										name: req.data.isFreeType[key],
									});
								}
							}
						}
					});
			}
			_this.windowHeight = document.documentElement.clientHeight; // 计算表格高度和底部位置
			_this.$route.query.detailsIds
				? (_this.heightNum = _this.windowHeight - 301)
				: (_this.heightNum = _this.windowHeight - 258);
			_this.containerHeight = _this.windowHeight - 102; // 计算容器的高度
			_this.getList(_this.search); // 获取列表

			// 公共人员接口 - 'SysConfig/GetUserList','testUserPerson','setGetAllUserList' 'getAllUserList'
			if (_this.getAllUserList && _this.getAllUserList.length > 0) {
				_this.salePersonsList = _this.getAllUserList;
				_this.statusForm.orgAllPerson = _this.getAllUserList;
			} else {
				getStaffListApiUser().then((r) => {
					r.status == 200 ? _this.setGetAllUserList(r.data) : false;
					r.status == 200
						? (_this.salePersonsList = r.data)
						: (_this.salePersonsList = []);
					r.status == 200
						? (_this.statusForm.orgAllPerson = r.data)
						: (_this.statusForm.orgAllPerson = []);
				});
			}
		},
		resultCom(result, fieldSale, fieldObj, tempObj) {
			// 自定义条件赋值
			let _this = this;
			let returnResult = resultComMethods(
				result,
				_this[fieldSale],
				toRaw(result.outResult),
				_this[tempObj],
				this.search
			);
			_this[fieldSale] = returnResult.fieldSale;
			_this[fieldObj] = returnResult.fieldObj;
			_this[tempObj] = returnResult.tempObj;
			_this.search = returnResult.search;
		},
		actionhandel(type) {
			// 顶部公共按钮操作
			let _this = this;
			_this.actionType = type;
			if (type === 'add') {
				_this.$router.push({
					path: '/sale/salemange/orderCreate',
					query: { type: 'add', id: '', sjtag: Math.random() * 36 },
				});
			}
			if (_this.multipleSelection && _this.multipleSelection.length > 0) {
				let nweArysize = 0;
				let newArry = [
					...new Set(
						_this.multipleSelection.map((item) => {
							return item.orderId;
						})
					),
				];
				let detailsIds = [
					...new Set(
						_this.multipleSelection.map((item) => {
							return item.id;
						})
					),
				];
				let closArr = [
					...new Set(
						_this.multipleSelection.map((item) => {
							return item.billStatus;
						})
					),
				];
				_this.OrdedetailIds = [];
				_this.OrdedetailIds = detailsIds;
				let orderNoArry = [
					// 取单据订单号
					...new Set(
						_this.multipleSelection.map((item) => {
							return item.orderNum;
						})
					),
				];
				_this.OrderNoNames = [];
				_this.OrderNoNames = orderNoArry;
				nweArysize = new Set(
					_this.multipleSelection.map((item) => {
						return item.orderId;
					})
				).size;
				if (type === 'copy') {
					// 点击复制
					if (nweArysize !== 1 && nweArysize > 0) {
						_this.$message.error({
							message: '只能克隆单号相同的数据',
							showClose: true,
						});
					} else {
						_this.$router.push({
							path: '/sale/salemange/orderCreate',
							query: {
								type: 'copy',
								id: _this.multipleSelection[0].orderId,
								detailsIds: detailsIds,
								sjtag: Math.random() * 36,
							},
						});
					}
				}
				if (type === 'submit') {
					// 点击提交
					_this.toolarFn('SalOrder/CommitList', newArry);
				}
				if (type === 'revoke') {
					// 点击撤销
					_this.toolarFn('SalOrder/Revoke', newArry);
				}
				if (type === 'audit') {
					// 点击审核
					_this.toolarFn('SalOrder/Check', newArry);
				}
				if (type === 'de-approval') {
					// 点击反审核
					_this.toolarFn('SalOrder/NoCheck', newArry);
				}
				if (type === 'delet') {
					// 点击删除
					_this.toolarFn('SalOrder/Delete', newArry);
				}
				if (type === 'close') {
					// 点击关闭
					_this.closeOrder(
						'SalOrder/Close',
						newArry,
						detailsIds,
						type,
						closArr,
						'关闭'
					);
				}
				if (type === 'de-close') {
					// 点击反关闭
					_this.closeOrder(
						'SalOrder/Reclose',
						newArry,
						detailsIds,
						type,
						closArr,
						'反关闭'
					);
				}
				if (type === 'push-down') {
					// 点击下推
					if (detailsIds.length <= 20) {
						if (
							_this.multipleSelection.filter((it) => {
								return it.billStatus !== '已审核';
							}).length > 0
						) {
							_this.$message.error({
								message:
									'单据状态错误，只能选择单据状态为已审核单据，请重新选择！',
								showClose: true,
							});
						} else {
							_this.$http
								.get('SalOrder/GetOrderType')
								.then((r) => {
									// 得到下推单据的类型
									if (r.status == 200) {
										_this.pushDownList = [];
										for (const key in r.data.orderType) {
											_this.pushDownList.push({
												id: key,
												value: r.data.orderType[key],
											});
										}
									}
								});
							_this.dialogxt = true;
						}
					} else {
						_this.$message.warning({
							message: '最多一次性下推二十条明细',
							showClose: true,
						});
					}
				}
				if (type === 'up-check') {
					// 点击查询--上查
					_this.$http
						.post('SalOrder/GetUpNumber', { ids: detailsIds })
						.then((res) => {
							if (res.status === 200) {
								if (res.data.length === 0 || res.data === []) {
									_this.$message.warning({
										message: '没有可上查的单据!',
										showClose: true,
									});
								} else {
									_this.upOrDownList = res.data;
									_this.dialogCX = true;
									_this.CXttile = '上查结果';
									_this.CXcheckVal =
										res.data && res.data.length === 1
											? res.data[0].orderType
											: null; // 只有一个，就个默认值
								}
							}
						});
				}
				if (type === 'down-check') {
					// 点击查询--下查
					_this.$http
						.post('SalOrder/GetPushDownNumber', { ids: detailsIds })
						.then((res) => {
							if (res.status === 200) {
								if (res.data.length === 0 || res.data === []) {
									_this.$message.warning({
										message: '没有可下查的单据!',
										showClose: true,
									});
								} else {
									_this.upOrDownList = res.data;
									_this.dialogCX = true;
									_this.CXttile = '下查结果';
									_this.CXcheckVal =
										res.data && res.data.length === 1
											? res.data[0].orderType
											: null; // 只有一个，就个默认值
								}
							}
						});
				}
				// 打印预览
				if (type === 'print-brower') {
					if (
						_this.multipleSelection.filter((it) => {
							return it.billStatus !== '已审核';
						}).length > 0
					) {
						_this.$message.error({
							message: '仅可打印已审核的单据',
							showClose: true,
						});
					} else {
						_this.multipleSelection = _this.multipleSelection.sort(
							dateData('placeOrderDate', false)
						);
						setTimeout(() => {
							printPreview(1);
						}, 200);
					}
				}
			} else {
				//按列表字段导出,点击全部导出
				if (
					type !== 'add' &&
					type !== 'refresh' &&
					type !== 'list-export' &&
					type !== 'all-export'
				) {
					_this.$message.error({
						message: '请先勾选',
						showClose: true,
					});
				}
			}
			if (type === 'list-export' || type === 'all-export') {
				exporthandel(
					type === 'list-export'
						? 'SalOrder/Export'
						: 'SalOrder/ExportAll',
					_this.search
				);
			}
			if (type === 'refresh') {
				// 点击刷新
				_this.getList(_this.search);
			}
		},

		sumitPushdown(id) {
			let _this = this;
			// 下推确定
			_this.CXcheckVal = id;
			if (id) {
				let pathName = '';
				let routerName = '';
				if (_this.CXcheckVal === '1') {
					// "生产订单"
					pathName = 'SalOrder/PushDownProduceOrder';
					routerName = 'ProductOrderCreate';
				}
				if (_this.CXcheckVal === '2') {
					// "采购订单"
					pathName = 'SalOrder/PushDownPurchaseOrder';
					routerName = 'CreatePurchase';
				}
				if (_this.CXcheckVal === '3') {
					// "委外订单"
					pathName = 'SalOrder/PushDownOutSourc';
					routerName = 'AddOutSourcOrder';
				}
				if (_this.CXcheckVal === '5') {
					// "发货通知单"
					pathName = 'SalOrder/PushDownDeliveryNoticeOrder';
					routerName = 'SaleDeliveryAddnotice';
				}
				if (_this.CXcheckVal === '6') {
					// "销售退货单"
					pathName = 'SalOrder/PushDownReturnStockOrder';
					routerName = 'CreateRuturnOrder';
				}
				if (_this.CXcheckVal === '10') {
					// "组织间需求单"
					pathName = 'SalOrder/PushDownOrganizationOrder';
					routerName = 'CreateOrgNeeds';
				}
				_this.$http
					.post(pathName, { ids: _this.OrdedetailIds })
					.then((res) => {
						if (res.status === 200) {
							_this.dialogxt = false;
							// ljm 用来判断下推的携带数据（用来判断下游数据不能够修改或者能修改）
							let newdata = [];
							if (res.data.details) {
								res.data.details.map((item, index) => {
									newdata.push(
										Object.assign({}, item, {
											pushkey: true,
										})
									);
								});
								res.data.details = newdata;
							}
							// endljm 用来判断下推的携带数据
							_this.$router.push({
								name: routerName,
								query: {
									type: 'pushDown',
									pushDownData: JSON.stringify(res.data),
									typeId: 1,
									sjtag: Math.random() * 36,
								},
							});
							_this.dialogxt = false;
						}
					});
			} else {
				_this.$message.error({
					message: '请先选中在确认',
					showClose: true,
				});
			}
		},
		getcheckInfo() {
			// 上下查数据
			let _this = this;
			if (_this.$route.query) {
				_this.search.detailsIds = _this.$route.query.detailsIds
					? JSON.parse(
							decodeURIComponent(_this.$route.query.detailsIds)
					  )
					: [];
				_this.CXaction =
					_this.$route.query.actionType === 'up' ? '上查' : '下查';
				let ordNostr = '';
				_this.OrderNoNameslist = _this.$route.query.OrderNoNames
					? JSON.parse(
							decodeURIComponent(_this.$route.query.OrderNoNames)
					  )
					: [];
				if (_this.OrderNoNameslist.length > 0) {
					_this.heightNum = _this.heightNum - 36;
				}
				if (_this.OrderNoNameslist) {
					_this.OrderNoNameslist.forEach((it, index) => {
						if (index < 5) {
							ordNostr = ordNostr + it + ',';
						}
					});
				}
				_this.OrderNoNameStr = ordNostr;
			}
		},
		submitCX() {
			// 确定上下查
			let _this = this;
			if (_this.CXcheckVal) {
				let pathName = '';
				if (_this.CXcheckVal === 1) {
					// "生产订单"
					pathName = 'ProductOrder';
				}
				if (_this.CXcheckVal === 2) {
					// "采购订单"
					pathName = 'DemandOrder';
				}
				if (_this.CXcheckVal === 3) {
					// "委外订单"
					pathName = 'OutsourcOrder';
				}
				if (_this.CXcheckVal === 5) {
					// "发货通知单"
					pathName = 'WarehouseSalesDeliveryNorice';
				}
				if (_this.CXcheckVal === 6) {
					// "销售退货单"
					pathName = 'SaleReturnOrder';
				}
				if (_this.CXcheckVal === 10) {
					// "组织间需求单"
					pathName = 'OrgNeeds';
				}
				let ary = [];
				ary = _this.upOrDownList.filter((it) => {
					return it.orderType === _this.CXcheckVal;
				});
				if (pathName) {
					_this.dialogCX = false;
					_this.$router.push({
						name: pathName,
						query: {
							detailsIds: JSON.stringify(ary[0].detailsIds),
							actionType:
								_this.CXttile === '上查结果' ? 'up' : 'down',
							actionName: '销售订单',
							OrderNoNames: JSON.stringify(_this.OrderNoNames),
						},
					});
					_this.dialogCX = false;
				}
			} else {
				_this.$message.error({
					message: '请先选择在确认',
					showClose: true,
				});
			}
		},
		closeOrder(path, newArry, detailsIds, type, closArr, val) {
			let _this = this;
			if (type === 'close' || type === 'de-close') {
				_this.isTrue = true;
				closArr.forEach((element) => {
					if (element != '已审核') {
						_this.$message.warning({
							message: '请选择已审核的单据行进行关闭!',
							showClose: true,
						});
						_this.isTrue = false;
					}
				});
				if (_this.isTrue) {
					let formdata = detailsIds
						? { ids: detailsIds }
						: { ids: newArry };
					ElMessageBox.confirm(
						'你确认要' + val + '所选单据行',
						'操作确认',
						{
							confirmButtonText: '确认',
							cancelButtonText: '取消',
							type: 'Success',
						}
					)
						.then(() => {
							_this.$http.post(path, formdata).then((res) => {
								if (res.status === 200) {
									ElMessage({
										type: 'success',
										message: val + '成功',
									});
									_this.getList(_this.search);
								}
							});
						})
						.catch(() => {
							ElMessage({
								type: 'info',
								message: '未' + val + '成功',
							});
						});
				}
			}
		},
		toolarFn(path, newArry, detailsIds, type, closArr) {
			// 顶部操作方法
			let _this = this;
			let formdata = detailsIds ? { ids: detailsIds } : { ids: newArry };
			_this.$http.post(path, formdata).then((res) => {
				if (res.status === 200) {
					_this.dialogVisible = true;
					_this.tableInfo = res.data;
					_this.getList(_this.search);
				}
			});
		},
		handelhtmlToExcel(domid, title) {
			// 操作弹框导出
			htmlToExcel(domid, title);
		},
		headerRigthMethod({ row, column, rowIndex, columnIndex }) {
			return 'headerRight';
		},
		handleSelectionChange(val) {
			// 表格选中条目发生改变
			let _this = this;
			_this.selectItem = val.length;
			_this.multipleSelection = val;
		},
		handleSizeChange(val) {
			// 每页条数
			let _this = this;
			_this.pageSize = val;
			_this.search.pageSize = val;
			_this.totalPageNumber = Math.ceil(
				_this.totalItemNumber / _this.pageSize
			);
			_this.getList(_this.search);
		},
		handleCurrentChange(val) {
			// 分页当前页切换
			let _this = this;
			_this.pageNo = val;
			_this.search.pageNo = val;
			_this.getList(_this.search);
		},
		openRow() {
			// 搜索切换高度
			let _this = this;
			_this.isDown = !_this.isDown;
			_this.rowShow = !_this.rowShow;
			_this.rowShow
				? (_this.heightNum = _this.heightNum - 80)
				: (_this.heightNum = _this.heightNum + 80);
		},
		openDetails(row, column) {
			// 打开详情页
			let _this = this;
			if (column.property == 'orderNum') {
				_this.$router.push({
					path: '/sale/salemange/orderCreate',
					query: {
						type: 'details',
						id: row.orderId,
						status: row.documentStatus,
					},
				});
			}
		},
		openDetailsDB(row, column) {
			let _this = this;
			_this.$router.push({
				path: '/sale/salemange/orderCreate',
				query: {
					type: 'details',
					id: row.orderId,
					status: row.documentStatus,
				},
			});
		},
		getList(search) {
			// 列表请求
			let _this = this;
			_this.tableLoading = true;
			_this.$http
				.showLoading(false)
				.post('SalOrder/GetList', search)
				.then((req) => {
					if (req.status == 200) {
						_this.tableLoading = false;
						_this.tableData = req.data.list;
						_this.totalItemNumber = req.data.totalCount;
						_this.totalPageNumber = Math.ceil(
							_this.totalItemNumber / _this.pageSize
						);
						_this.pagingSaleNumber = req.data.sellNumberSum;
						_this.cumulativeIssueQuantity =
							req.data.checkoutNumberSum;
						_this.totalOutQuantity = req.data.surplusNumberSum;
						_this.totalBaseCurrency = req.data.priceTaxSum;
						if (_this.multipleSelection) {
							if (
								_this.multipleSelection.length &&
								_this.multipleSelection.length > 0
							) {
								let detailsIds = [
									...new Set(
										_this.multipleSelection.map((item) => {
											return item.id;
										})
									),
								];
								_this.tableData.forEach((el, ind) => {
									if (detailsIds.indexOf(el.id) !== -1) {
										_this.$refs.tableInfoRef.toggleRowSelection(
											_this.tableData[ind],
											true
										);
									}
								});
							}
						}
					}
				});
		},
		dateCom(val, keyO, keyS, keyE) {
			// 日期
			let _this = this;
			_this[keyO] = val;
			if (this[keyO] == null) {
				delete _this.search[keyS];
				delete _this.search[keyE];
			} else {
				_this.search[keyS] = _this[keyO][0];
				_this.search[keyE] = _this[keyO][1];
			}
			_this.searchList();
		},
		// 订单号 复制按钮
		saleOrderCopy() {
			orderCopy();
		},
		searchList() {
			// 搜索
			let _this = this;
			_this.getList(_this.search);
		},
		searchCom(val, key, ipt, type) {
			// 搜索公共方法
			let _this = this;
			if (type) {
				_this.$refs.cascader.togglePopperVisible(); // 选择之后将下拉框界面收起
			}
			_this.search[key] = val;
		},
		clearCom(val, key) {
			// 删除的公共方法
			let _this = this;
			if (!val) {
				delete _this.search[key];
			}
		},
		resetSearch() {
			// 重置
			let _this = this;
			let arr = [
				'orderNumber',
				'formBills',
				'deptSelVal',
				'personVal',
				'customVal',
				'productVal',
				'ordVal',
				'supplyVal',
				'placeValue',
				'expectValue',
			];
			for (let index = 0; index < arr.length; index++) {
				_this[arr[index]] = '';
			}
			_this.reset = true;
			_this.search = {
				customers: '',
				pageNo: _this.pageNo,
				pageSize: _this.pageSize,
				orgId:
					_this.$store.state && _this.$store.state.org
						? _this.$store.state.org.orgId
						: null,
			};
			_this.search.detailsIds = [];
			_this.search.extention = {};
			_this.customerSel1 = '';
			_this.customerSel2 = '';
			_this.customerSel3 = '';
			if (_this.$route.query.detailsIds) {
				// this.search.detailsIds = JSON.parse(decodeURIComponent(this.$route.query.detailsIds))
				_this.search.detailsIds = _this.$route.query.detailsIds;
			}
			if (_this.$route.query.type == 'copy') {
				_this.search.detailsIds = [];
			}
			setTimeout(() => {
				_this.reset = false;
			}, 200);
			_this.searchList();
		},
		async getStatusTypeInfo() {
			let _this = this;
			if (_this.getOrgId) {
				_this.statusForm.warehouse = await getStatusType(
					'SysConfig/GetWarehouseByOrg/',
					_this.getOrgId
				); // 获取仓库
				let saleDeptArr = await getStatusType(
					'SysConfig/GetDept/',
					_this.getOrgId,
					'post'
				); // 根据组织获取部门
				_this.deptList = removeChildren(saleDeptArr);
			}
		},
		getStatusTypeObject() {
			let _this = this;
			_this.statusForm.supplys = _this.orgIdArr; // 供应组织
			_this.statusForm.settleOrg = _this.orgIdArr; // 结算组织
		},
		addListSal(event) {
			if (event.keyCode === 13) {
				this.searchList();
			}
		},
	},
	computed: {
		...mapState({
			orgId: (state) =>
				state && state.org && state.org.orgId ? state.org.orgId : null,
			orgIdArr: (state) =>
				state && state.user && state.user.orgIdArr
					? state.user.orgIdArr
					: null,
			getOrgId: (state) =>
				state && state.org && state.org.orgId ? state.org.orgId : null,
			settletype: (state) => state.storeData.settletype,
			dcurrency: (state) => state.storeData.dcurrency,
			customer: (state) => state.storeData.customer,
			supplierSelect: (state) => state.storeData.supplierSelect,
			recondtion: (state) => state.storeData.recondtion,
			enumType: (state) => state.storeData.enumType,
			dicSale: (state) => state.storeData.dicSale,
			getAllUserList: (state) => state.storeData.getAllUserList,
		}),
	},
	created() {
		let _this = this;
		_this.search.orgId = this.orgId;
		_this.getcheckInfo();
		_this.Init();
		_this.getStatusTypeInfo();
		_this.getStatusTypeObject();
	},
	activated() {
		document.addEventListener('keyup', this.addListSal, false);
	},
	deactivated() {
		document.removeEventListener('keyup', this.addListSal, false);
	},
	watch: {
		orgId(val) {
			if (val) {
				let _this = this;
				_this.search.orgId = val;
				// 监听组织发生变化重新获取列表
				_this.getStatusTypeInfo();
				_this.personVal = '';
				delete _this.search.salerId;
				// this.getList(this.search)
				_this.resetSearch();
			}
		},
		customerSel1: function () {
			let _this = this;
			let returnR = customChangeMethods(
				_this.customerSel1,
				_this.customerSel2,
				_this.customerSel3,
				'x',
				_this.compKey1
			);
			_this.customerSel1 = returnR.selfVal;
			_this.customerSel2 = returnR.otherO;
			_this.customerSel3 = returnR.otherT;
			_this.compKey1 = returnR.keyRsf;
		},
		customerSel2: function () {
			let _this = this;
			let returnR = customChangeMethods(
				_this.customerSel2,
				_this.customerSel1,
				_this.customerSel3,
				'y',
				_this.compKey2
			);
			_this.customerSel2 = returnR.selfVal;
			_this.customerSel1 = returnR.otherO;
			_this.customerSel3 = returnR.otherT;
			_this.compKey2 = returnR.keyRsf;
		},
		customerSel3: function () {
			let _this = this;
			let returnR = customChangeMethods(
				_this.customerSel3,
				_this.customerSel1,
				_this.customerSel2,
				'z',
				_this.compKey3
			);
			_this.customerSel3 = returnR.selfVal;
			_this.customerSel1 = returnR.otherO;
			_this.customerSel2 = returnR.otherT;
			_this.compKey3 = returnR.keyRsf;
		},
	},
};
// 测试 - jenkins
</script>
<style lang="scss" scoped>
@import '@/assets/style/saleOrder/saleOrderCommon.scss';
@import '@/assets/style/saleOrder/orderList.scss';
@import '@/assets/style/saleOrder/common.scss';
</style>
