<!--
 * @Descripttion: (工艺路线-抛光 库存表/wm_polish_inventory)
 * @version: (1.0)
 * @Author: (admin)
 * @Date: (2024-07-25)
 * @LastEditors: (admin)
 * @LastEditTime: (2024-07-25)
-->
<template>
	<div class="app-container">
		<!-- :model属性用于表单验证使用 比如下面的el-form-item 的 prop属性用于对表单值进行验证操作 -->
		<el-form :model="queryParams" size="small" label-position="right" inline ref="queryForm" :label-width="labelWidth" v-show="showSearch" @submit.native.prevent>
			<el-form-item label="零件号" prop="partnumber">
				<el-input v-model.trim="queryParams.partnumber" placeholder="请输入零件号" clearable />
			</el-form-item>
			<el-form-item label="产品描述" prop="description">
				<el-input v-model.trim="queryParams.description" placeholder="请输入产品描述" clearable />
			</el-form-item>
			<el-form-item label="类别" prop="type">
				<el-select v-model="queryParams.type" placeholder="请选择类别" @change="handleQuery">
					<el-option v-for="item in typeOptions" :key="item.dictValue" :label="item.dictLabel" :value="parseInt(item.dictValue)"></el-option>
					<el-option label="全部" :value="0"></el-option>
				</el-select>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
				<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
			</el-form-item>
		</el-form>
		<!-- 工具区域 -->
		<el-row :gutter="10" class="mb10">
			<el-col :span="1.5">
				<el-button type="success" icon="el-icon-plus" size="mini" @click="handlePolishWarehousing()">抛光零件入库</el-button>
			</el-col>
			<el-col :span="1.5">
				<el-button type="primary" icon="el-icon-minus" size="mini" @click="handlePolishRetrieval()">抛光零件出库</el-button>
			</el-col>
			<el-col :span="1.5">
				<el-button type="danger" :disabled="multiple" icon="el-icon-delete" size="mini" @click="handleDelete">删除</el-button>
			</el-col>
			<el-col :span="1.5">
				<el-button type="info" icon="el-icon-upload2" size="mini" @click="handleImport">导入</el-button>
			</el-col>
			<el-col :span="1.5">
				<el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport">导出 </el-button>
			</el-col>
			<right-toolbar :columns="columns" :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
		</el-row>
		<div style="display: flex; align-items: center; justify-content: center; margin-bottom: 10px">
			<span style="font-size: 18px; font-weight: 600">抛光仓库总零件数:{{ partTotal }}</span>
			<span style="font-size: 18px; font-weight: 600; margin-left: 20px">盘点零件数:{{ totalQuantity }}</span>
			<span style="font-size: 18px; font-weight: 600; margin-left: 20px">当前零件数:{{ realTotalQuantity }}</span>
		</div>
		<!-- 数据区域 -->
		<el-table :data="dataList" v-loading="loading" ref="table" border highlight-current-row @sort-change="sortChange" @selection-change="handleSelectionChange">
			<el-table-column type="selection" width="50" align="center" />
			<el-table-column prop="id" label="主键" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('id')" />
			<el-table-column prop="blankNum" label="毛坯号" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('blankNum')" />
			<el-table-column min-width="200" prop="partnumber" label="零件号" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('partnumber')">
				<template slot-scope="scope">
					<el-link type="primary" @click="handleShowInfo(scope.row)">{{ scope.row.partnumber }}</el-link>
				</template>
			</el-table-column>
			<el-table-column prop="description" label="产品描述" align="center" min-width="300" :show-overflow-tooltip="true" v-if="columns.showColumn('description')" />
			<el-table-column prop="color" label="颜色" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('color')" />
			<el-table-column prop="specification" label="规格" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('specification')" />
			<el-table-column prop="quantity" label="盘点库存" align="center" v-if="columns.showColumn('quantity')" />
			<el-table-column prop="realQuantity" label="实际库存" align="center" v-if="columns.showColumn('realQuantity')" />
			<el-table-column prop="maxNum" label="最大库存" align="center" v-if="columns.showColumn('maxNum')" />
			<el-table-column prop="minNum" label="最小库存" align="center" v-if="columns.showColumn('minNum')" />
			<el-table-column prop="warnNum" label="预警库存" align="center" v-if="columns.showColumn('warnNum')" />
			<el-table-column prop="type" label="类别" align="center" v-if="columns.showColumn('type')">
				<template slot-scope="scope">
					<el-tag effect="plain" v-if="scope.row.type === 1" type="primary">正常</el-tag>
					<el-tag effect="plain" v-if="scope.row.type === 2" type="warning">返工件</el-tag>
				</template>
			</el-table-column>
			<el-table-column prop="remark" label="备注" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('remark')" />
			<el-table-column prop="createdBy" label="创建人" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('createdBy')" />
			<el-table-column prop="createdTime" label="盘点时间" align="center" width="160px" :show-overflow-tooltip="true" v-if="columns.showColumn('createdTime')" />
			<el-table-column prop="updatedBy" label="更新人" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('updatedBy')" />
			<el-table-column prop="updatedTime" label="更新时间" align="center" min-width="160px" :show-overflow-tooltip="true" v-if="columns.showColumn('updatedTime')" />
			<el-table-column label="操作" align="center" fixed="right" width="200">
				<template slot-scope="scope">
					<el-button size="mini" type="info" @click="handleShowInfo(scope.row)">记录</el-button>
					<el-button size="mini" type="warning" @click="handlePolishStocktaking(scope.row)">盘点</el-button>
					<el-button size="mini" type="danger" icon="el-icon-delete" title="删除" @click="handleDelete(scope.row)"></el-button>
				</template>
			</el-table-column>
		</el-table>
		<pagination class="mt10" background :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />

		<!-- 入库，出库，盘点 -->
		<el-dialog :close-on-click-modal="false" :title="title" :lock-scroll="false" :visible.sync="open" @opened="dialogOpened">
			<el-form ref="form" :model="form" :rules="rules" :label-width="formLabelWidth">
				<el-row :gutter="20">
					<el-col :lg="24">
						<el-form-item label="操作类别">
							<el-tag effect="dark" style="font-size: 18px" v-if="opertype === 1" type="success">入库</el-tag>
							<el-tag effect="dark" style="font-size: 18px" v-if="opertype === 2" type="primary">出库</el-tag>
							<el-tag effect="dark" style="font-size: 18px" v-if="opertype === 3" type="warning">盘点</el-tag>
						</el-form-item>
					</el-col>
					<el-col :lg="24" v-if="opertype != 3">
						<el-form-item label="零件搜索">
							<ThePartNumberSelect ref="ThePartNumberSelectRef" @selected="PartNumberSelect"></ThePartNumberSelect>
						</el-form-item>
					</el-col>
					<el-col :lg="12">
						<el-form-item label="零件号" prop="partnumber">
							<el-input v-model="form.partnumber" placeholder="请输入零件号" />
						</el-form-item>
					</el-col>

					<el-col :lg="12">
						<el-form-item v-if="opertype === 1" label="入库数" prop="quantity">
							<el-input-number v-model="form.quantity" :min="0" label="入库数量"></el-input-number>
						</el-form-item>
						<el-form-item v-if="opertype === 2" label="出库数" prop="quantity">
							<el-input-number v-model="form.quantity" :min="0" label="出库数量"></el-input-number>
						</el-form-item>
						<el-form-item v-if="opertype === 3" label="盘点数" prop="quantity">
							<el-input-number v-model="form.quantity" :min="0" label="请输入盘点结果"></el-input-number>
							<el-button style="margin-left: 5px" @click="handlarAddQuantity" icon="el-icon-plus" circle></el-button>
						</el-form-item>
					</el-col>
					<el-col :lg="12">
						<el-form-item label="零件类别" prop="type">
							<el-select v-model="form.type" placeholder="请选择类别">
								<el-option v-for="item in typeOptions" :key="item.dictValue" :label="item.dictLabel" :value="parseInt(item.dictValue)"></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :lg="12">
						<el-form-item label="操作时间" prop="actionTime">
							<el-date-picker v-model="form.actionTime" type="datetime" :clearable="false" placeholder="选择日期时间"></el-date-picker>
						</el-form-item>
					</el-col>
					<el-col :lg="24">
						<el-form-item label="备注" prop="remark">
							<el-input type="textarea" v-model="form.remark" placeholder="请输入备注" />
						</el-form-item>
					</el-col>
				</el-row>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button type="text" @click="cancel">取 消</el-button>
				<el-button type="primary" @click="submitForm">确 定</el-button>
			</div>
		</el-dialog>
		<!-- 操作记录 -->
		<el-dialog :close-on-click-modal="false" :title="RecordTitle" :lock-scroll="false" :visible.sync="RecordOpen" @opened="RecordOpened" width="80%" destroy-on-close>
			<el-form :model="RecordQueryParams" size="small" label-position="right" inline ref="RecordQueryForm" @submit.native.prevent>
				<el-form-item label="操作时间" prop="startActionTime">
					<el-date-picker v-model="RecordQueryParams.startActionTime" type="datetime" :clearable="true" placeholder="开始时间"></el-date-picker>
				</el-form-item>
				<el-form-item label="至" prop="endActionTime">
					<el-date-picker v-model="RecordQueryParams.endActionTime" type="datetime" :clearable="true" placeholder="结束时间" default-time="23:59:59"></el-date-picker>
				</el-form-item>
				<el-form-item label="工单号" prop="remark">
					<el-input v-model.trim="RecordQueryParams.remark" placeholder="请输入工单号" clearable />
				</el-form-item>
				<el-form-item label="类别" prop="changeType">
					<el-select v-model="RecordQueryParams.changeType" placeholder="请选择类别" @change="getRecordList">
						<el-option label="全部" :value="-1"></el-option>
						<el-option v-for="item in RecordTypeOptions" :key="item.dictValue" :label="item.dictLabel" :value="parseInt(item.dictValue)"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" icon="el-icon-search" size="mini" @click="resetRecordQuery">搜索</el-button>
				</el-form-item>
			</el-form>
			<!-- 数据区域 -->
			<el-table :data="RecordDataList" v-loading="RecordLoading" border>
				<el-table-column prop="partnumber" min-width="180" label="零件号" align="center" :show-overflow-tooltip="true" />
				<el-table-column prop="changeType" label="变动类别" align="center">
					<template slot-scope="scope">
						<el-tag effect="plain" v-if="scope.row.changeType === 1" type="success">入库</el-tag>
						<el-tag effect="plain" v-if="scope.row.changeType === 2" type="danger">出库</el-tag>
						<el-tag effect="plain" v-if="scope.row.changeType === 3" type="warning">盘点</el-tag>
						<el-tag effect="plain" v-if="scope.row.changeType === 4" type="primary">检验</el-tag>
					</template>
				</el-table-column>
				<el-table-column prop="changeQuantity" label="变动数量" align="center" />
				<el-table-column prop="actionTime" min-width="160" label="操作时间" align="center" :show-overflow-tooltip="true" />
				<el-table-column prop="remark" min-width="300" label="备注" align="center" :show-overflow-tooltip="true" />
				<el-table-column prop="createdBy" label="创建人" align="center" :show-overflow-tooltip="true" />
				<el-table-column prop="createdTime" min-width="160" label="创建时间" align="center" :show-overflow-tooltip="true" />
			</el-table>
			<pagination class="mt10" background :total="RecordTotal" :page.sync="RecordQueryParams.pageNum" :limit.sync="RecordQueryParams.pageSize" @pagination="getRecordList" />
		</el-dialog>
		<!-- 导入对话框 -->
		<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
			<el-upload
				name="file"
				ref="upload"
				:limit="1"
				accept=".xlsx, .xls"
				:headers="upload.headers"
				:action="upload.url + '?updateSupport=' + upload.updateSupport"
				:disabled="upload.isUploading"
				:on-progress="handleFileUploadProgress"
				:on-success="handleFileSuccess"
				:auto-upload="false"
				drag
			>
				<i class="el-icon-upload"></i>
				<div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
				<div class="el-upload__tip text-center" slot="tip">
					<div class="el-upload__tip" slot="tip"><el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的数据</div>
					<span>仅允许导入xls、xlsx格式文件。</span>
					<el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline" @click="importTemplate">下载模板</el-link>
				</div>
			</el-upload>
			<div slot="footer" class="dialog-footer">
				<el-button type="primary" @click="submitFileForm">确 定</el-button>
				<el-button @click="upload.open = false">取 消</el-button>
			</div>
		</el-dialog>
	</div>
</template>
<script>
import {
	listWmPolishInventory,
	addWmPolishInventory,
	delWmPolishInventory,
	updateWmPolishInventory,
	getWmPolishInventory,
	doWmPolishWarehousing,
	doWmPolishRetrieval,
	doWmPolishStocktaking,
	getWmPolishRecordList,
	getPartNumber,
	exportPolish,
} from '@/api/wmsManagement/wmPolishInventory.js'
import ThePartNumberSelect from './ThePartNumberSelect.vue'
import { getToken } from '@/utils/auth'
export default {
	name: 'wmpolishinventory',
	components: {
		ThePartNumberSelect,
	},
	data() {
		return {
			labelWidth: '100px',
			formLabelWidth: '100px',
			// 选中id数组
			ids: [],
			// 非单个禁用
			single: true,
			// 非多个禁用
			multiple: true,
			// 遮罩层
			loading: false,
			// 显示搜索条件
			showSearch: true,
			// 查询参数
			queryParams: {
				pageNum: 1,
				pageSize: 10,
				status: 1,
				type: 1,
				sort: 'updatedTime',
				sortType: 'desc',
			},
			// 弹出层标题
			title: '',
			// 操作类型 1、入库 2、出库 3.盘点
			opertype: 0,
			// 是否显示弹出层
			open: false,
			// 表单参数
			form: {
				type: 1,
				status: 1,
				partnumber: '',
				remark: '',
				actionTime: new Date(),
			},
			columns: [
				{ index: 0, key: 'id', label: `主键`, checked: false },
				{ index: 1, key: 'blankNum', label: `毛坯号`, checked: false },
				{ index: 2, key: 'partnumber', label: `零件号`, checked: true },
				{ index: 2, key: 'description', label: `产品描述`, checked: true },
				{ index: 2, key: 'color', label: `颜色`, checked: true },
				{ index: 2, key: 'specification', label: `规格`, checked: true },
				{ index: 3, key: 'quantity', label: `库存数量`, checked: true },
				
				{ index: 4, key: 'maxNum', label: `最大库存`, checked: false },
				{ index: 5, key: 'minNum', label: `最小库存`, checked: false },
				{ index: 6, key: 'warnNum', label: `预警库存`, checked: false },
				{ index: 7, key: 'type', label: `类别`, checked: true },
				{ index: 8, key: 'status', label: `状态`, checked: true },
				{ index: 9, key: 'remark', label: `备注`, checked: false },
				{ index: 10, key: 'createdBy', label: `创建人`, checked: false },
				{ index: 11, key: 'createdTime', label: `盘点时间`, checked: true },
				{ index: 12, key: 'updatedBy', label: `更新人`, checked: false },
				{ index: 13, key: 'updatedTime', label: `更新时间`, checked: false },
				{ index: 14, key: 'realQuantity', label: `实际库存`, checked: true },
			],
			// 类别(1-正常 2-返工件)选项列表 格式 eg:{ dictLabel: '标签', dictValue: '0'}
			typeOptions: [
				{ dictLabel: '正常', dictValue: 1 },
				{ dictLabel: '返工件', dictValue: 2 },
			],
			// 状态（0-停用1-启用）选项列表 格式 eg:{ dictLabel: '标签', dictValue: '0'}
			statusOptions: [],
			// 数据列表
			dataList: [],
			allDataList: [],
			// 总记录数
			total: 0,
			// 提交按钮是否显示
			btnSubmitVisible: true,
			// 表单校验
			rules: {
				partnumber: [{ required: true, message: '零件号不能为空', trigger: 'blur' }],
				quantity: [{ required: true, message: '库存数量不能为空', trigger: 'blur' }],
			},
			ThePartNumberSelectRef: null,

			//抛光仓库零件数
			partTotal: 0,

			// 详情
			RecordLoading: false,
			RecordTitle: '',
			RecordOpen: false,
			RecordDataList: [],
			RecordTotal: 0,
			RecordQueryParams: {
				pageNum: 1,
				pageSize: 10,
				fkInventoryId: '',
				status: 1,
				changeType: -1,
				sort: 'updatedTime',
				sortType: 'desc',
			},
			RecordTypeOptions: [
				{ dictLabel: '入库', dictValue: 1 },
				{ dictLabel: '出库', dictValue: 2 },
				{ dictLabel: '盘点', dictValue: 3 },
				// { dictLabel: '质检', dictValue: 4 },
			],
			// 导入参数
			upload: {
				// 是否显示弹出层（用户导入）
				open: false,
				// 弹出层标题（用户导入）
				title: '',
				// 是否禁用上传
				isUploading: false,
				// 是否更新已经存在的数据
				updateSupport: 0,
				// 设置上传的请求头部
				headers: { Authorization: 'Bearer ' + getToken() },
				// 上传的地址
				url: process.env.VUE_APP_BASE_API + '/mes/wm/WmPolishInventory/importData',
			},
		}
	},
	computed: {
		// 当前查询库存数量（盘点）
		totalQuantity() {
			return this.allDataList.reduce((acc, data) => acc + data.quantity, 0)
		},
		// 当前查询库存数量（查询结果）
		realTotalQuantity() {
			return this.allDataList.reduce((acc, data) => acc + data.realQuantity, 0)
		},
	},
	created() {
		// 列表数据查询
		this.getList()

		var dictParams = []
	},
	methods: {
		// 查询数据
		getList() {
			this.loading = true
			listWmPolishInventory(this.queryParams).then((res) => {
				if (res.code == 200) {
					this.dataList = res.data.result
					this.total = res.data.totalNum
					this.loading = false
				}
			})
			let params = JSON.parse(JSON.stringify(this.queryParams))
			params.pageNum = 1
			params.pageSize = 100000
			listWmPolishInventory(params).then((res) => {
				if (res.code == 200) {
					this.allDataList = res.data.result
				}
			})
			getPartNumber().then((res) => {
				if (res.code === 200) {
					this.partTotal = res.data
				}
			})
		},
		// 取消按钮
		cancel() {
			this.open = false
			this.reset()
		},
		// 重置数据表单
		reset() {
			this.form = {
				id: undefined,
				blankNum: undefined,
				partnumber: undefined,
				quantity: 0,
				maxNum: 0,
				minNum: 0,
				warnNum: 0,
				type: 1,
				status: 1,
				actionTime: new Date(),
				remark: '',
				createdBy: undefined,
				createdTime: undefined,
				updatedBy: undefined,
				updatedTime: undefined,
			}
			this.resetForm('form')
		},
		// 重置查询操作
		resetQuery() {
			this.timeRange = []
			this.resetForm('queryForm')
			this.handleQuery()
		},
		// 多选框选中数据
		handleSelectionChange(selection) {
			this.ids = selection.map((item) => item.id)
			this.single = selection.length != 1
			this.multiple = !selection.length
		},
		// 自定义排序
		sortChange(column) {
			if (column.prop == null || column.order == null) {
				this.queryParams.sort = undefined
				this.queryParams.sortType = undefined
			} else {
				this.queryParams.sort = column.prop
				this.queryParams.sortType = column.order
			}

			this.handleQuery()
		},
		/** 搜索按钮操作 */
		handleQuery() {
			this.queryParams.pageNum = 1
			this.getList()
		},
		/** 修改按钮操作 */
		handleUpdate(row) {
			this.reset()
			const id = row.id || this.ids
			getWmPolishInventory(id).then((res) => {
				const { code, data } = res
				if (code == 200) {
					this.open = true
					this.title = '修改数据'
					this.opertype = 2

					this.form = {
						...data,
					}
				}
			})
		},
		/** 删除按钮操作 */
		handleDelete(row) {
			const Ids = row.id || this.ids

			this.$confirm('是否确认删除数据项？')
				.then(function () {
					return delWmPolishInventory(Ids)
				})
				.then(() => {
					this.handleQuery()
					this.msgSuccess('删除成功')
				})
				.catch(() => {})
		},
		// 弹窗打开
		dialogOpened() {
			if (this.opertype != 3) {
				this.$refs.ThePartNumberSelectRef.init()
			}
		},
		// 仓库操作=====================================================
		/** 入库操作 */
		handlePolishWarehousing() {
			this.reset()
			this.open = true
			this.title = '抛光零件入库'
			this.opertype = 1
			this.form.id = null
		},
		/** 出库操作 */
		handlePolishRetrieval() {
			this.reset()
			this.open = true
			this.title = '抛光零件出库'
			this.opertype = 2
			this.form.id = null
		},
		/** 盘点操作 */
		handlePolishStocktaking(row = null) {
			this.reset()
			this.open = true
			this.title = `零件号:${row.partnumber} 盘点`
			this.opertype = 3
			this.form.id = row.id
			this.form.partnumber = row.partnumber
			this.form.type = row.type
			this.form.quantity = row.quantity
		},
		// 盘点数据计算
		handlarAddQuantity() {
			this.$prompt('请输入变动数量', '盘点数变动', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
			})
				.then(({ value }) => {
					this.form.quantity += value * 1
				})
				.catch(() => {})
		},
		PartNumberSelect(value) {
			this.form.partnumber = value
		},
		handleShowInfo(row) {
			this.RecordDataList = []
			this.RecordTotal = 0
			this.RecordTitle = `零件号：${row.partnumber}`
			this.RecordOpen = true
			this.RecordQueryParams.fkInventoryId = row.id
		},
		// 详情
		RecordOpened() {
			this.resetRecordQuery()
		},
		// 查询记录数据
		resetRecordQuery() {
			this.RecordQueryParams.pageNum = 1
			this.RecordQueryParams.changeType = -1
			// this.RecordQueryParams.startTime = ''
			// this.RecordQueryParams.endTime = ''
			this.getRecordList()
		},
		getRecordList() {
			this.RecordLoading = true
			getWmPolishRecordList(this.RecordQueryParams).then((res) => {
				if (res.code == 200) {
					this.RecordDataList = res.data.result
					this.RecordTotal = res.data.totalNum
					this.RecordLoading = false
				}
			})
		},
		// 仓库操作=====================================================
		/** 导出按钮操作 **/
		handleExport() {
			const queryParams = this.queryParams
			this.$confirm('是否确认导出所查询数据项?', '警告', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning',
			})
				.then(async () => {
					await exportPolish(queryParams)
				})
				.catch()
		},
		// 导入按钮
		handleImport() {
			this.upload.title = '用户导入'
			this.upload.open = true
		},
		/** 下载模板操作 */
		importTemplate() {
			this.download('/mes/wm/WmPolishInventory/importTemplate', '抛光仓库盘点模板')
		},
		// 文件上传中处理
		handleFileUploadProgress(event, file, fileList) {
			this.upload.isUploading = true
		},
		// 文件上传成功处理
		handleFileSuccess(response, file, fileList) {
			this.upload.open = false
			this.upload.isUploading = false
			this.$refs.upload.clearFiles()
			this.$alert(response.msg, '导入结果', { dangerouslyUseHTMLString: true })
			this.getList()
		},
		// 提交上传文件
		submitFileForm() {
			this.$refs.upload.submit()
		},
		// 类别(1-正常 2-返工件)字典翻译
		// typeFormat(row, column) {
		// 	return this.selectDictLabel(this.typeOptions, row.type)
		// },
		// 状态（0-停用1-启用）字典翻译
		// statusFormat(row, column) {
		// 	return this.selectDictLabel(this.statusOptions, row.status)
		// },
		/** 提交按钮 */
		submitForm: function () {
			this.$refs['form'].validate((valid) => {
				if (valid) {
					const _opertype = this.opertype
					if (_opertype === 1) {
						this.form.remark = '手动入库 ' + this.form.remark
						doWmPolishWarehousing(this.form)
							.then((res) => {
								this.msgSuccess('入库成功')
								this.open = false
								this.getList()
							})
							.catch((err) => {
								//TODO 错误逻辑
							})
					} else if (_opertype === 2) {
						this.form.remark = '手动出库 ' + this.form.remark
						doWmPolishRetrieval(this.form)
							.then((res) => {
								this.msgSuccess('出库成功')
								this.open = false
								this.getList()
							})
							.catch((err) => {
								//TODO 错误逻辑
							})
					} else if (_opertype === 3) {
						this.form.remark = '手动盘点 ' + this.form.remark
						doWmPolishStocktaking(this.form)
							.then((res) => {
								this.msgSuccess('盘点成功')
								this.open = false
								this.getList()
							})
							.catch((err) => {
								//TODO 错误逻辑
							})
					}
				}
			})
		},
	},
}
</script>
