﻿<template>
	<div class="hyBarCodeMain-container">
		<el-dialog v-model="state.isShowDialog" v-if="state.isShowDialog" :width="800" draggable="" :close-on-click-modal="false">
			<template #header>
				<div style="color: #fff">
					<!--<el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-Edit /> </el-icon>-->
					<span>{{ props.title }}</span>
				</div>
			</template>
			<el-form :model="state.ruleForm" ref="ruleFormRef" label-width="auto" :rules="rules">
				<el-row :gutter="35">
					<el-form-item v-show="false">
						<el-input v-model="state.ruleForm.barCode" />
					</el-form-item>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="" prop="barCodeRule">
							<el-input v-model="state.ruleForm.barCodeRule" placeholder="请输入" maxlength="20" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="" prop="cInvCode">
							<el-input v-model="state.ruleForm.cInvCode" placeholder="请输入" maxlength="60" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="" prop="cSilvItem">
							<el-input v-model="state.ruleForm.cSilvItem" placeholder="请输入" maxlength="50" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="" prop="qty">
							<el-input v-model="state.ruleForm.qty" placeholder="请输入" maxlength="38" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="" prop="iNum">
							<el-input v-model="state.ruleForm.iNum" placeholder="请输入" maxlength="38" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="" prop="pLot">
							<el-input v-model="state.ruleForm.pLot" placeholder="请输入" maxlength="60" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
				
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="" prop="createDate">
							<el-date-picker v-model="state.ruleForm.createDate" type="date" placeholder="" />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="" prop="dBusDate">
							<el-date-picker v-model="state.ruleForm.dBusDate" type="date" placeholder="" />
							
						</el-form-item>
						
					</el-col>
					
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="" prop="cComUnitCode">
							<el-input v-model="state.ruleForm.cComUnitCode" placeholder="请输入" maxlength="40" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="" prop="cMaker">
							<el-input v-model="state.ruleForm.cMaker" placeholder="请输入" maxlength="50" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="" prop="cLabelCode">
							<el-input v-model="state.ruleForm.cLabelCode" placeholder="请输入" maxlength="10" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="" prop="iPrtCount">
							<el-input-number v-model="state.ruleForm.iPrtCount" placeholder="请输入" clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="" prop="iBarCodeState">
							<el-input v-model="state.ruleForm.iBarCodeState" placeholder="请输入" maxlength="3" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="" prop="bExpSub">
							<el-input-number v-model="state.ruleForm.bExpSub" placeholder="请输入" clearable />
							
						</el-form-item>
						
					</el-col>
					
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="" prop="bUseLs">
							<el-input v-model="state.ruleForm.bUseLs" placeholder="请输入" maxlength="5" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="" prop="iExpiratDateCalcu">
							<el-input v-model="state.ruleForm.iExpiratDateCalcu" placeholder="请输入" maxlength="5" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="" prop="ufts">
							<el-input v-model="state.ruleForm.ufts" placeholder="请输入" maxlength="8" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="" prop="iRelAutoid">
							<el-input-number v-model="state.ruleForm.iRelAutoid" placeholder="请输入" clearable />
							
						</el-form-item>
						
					</el-col>
					
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="" prop="vt_id">
							<el-input-number v-model="state.ruleForm.vt_id" placeholder="请输入" clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="" prop="uBarCode">
							<el-input v-model="state.ruleForm.uBarCode" placeholder="请输入" maxlength="300" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item label="" prop="iPrtPerson">
							<el-input v-model="state.ruleForm.iPrtPerson" placeholder="请输入" maxlength="30" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
				</el-row>
			</el-form>
			<template #footer>
				<span class="dialog-footer">
					<el-button @click="cancel">取 消</el-button>
					<el-button type="primary" @click="submit">确 定</el-button>
				</span>
			</template>
		</el-dialog>
	</div>
</template>
<style lang="scss" scoped>
:deep(.el-select),
:deep(.el-input-number) {
	width: 100%;
}
</style>
<script lang="ts" setup>
    import { ref,onMounted, reactive } from "vue";
	import { ElMessage } from "element-plus";
	import type { FormRules } from "element-plus";
	import {  detailHyBarCodeMain } from "/@/api/simple/hyBarCodeMain";

  	import { formatDate } from '/@/utils/formatTime';

	//父级传递来的参数
	var props = defineProps({
		title: {
		type: String,
		default: "",
	},
	});
	//父级传递来的函数，用于回调
	const emit = defineEmits(["reloadTable"]);
	const ruleFormRef = ref();
    const state = reactive({
    isShowDialog: false,
    ruleForm: {} as any,
});

	//自行添加其他规则
	const rules = ref<FormRules>({
	});

	// 页面加载时
	onMounted(() => {

	});

	// 打开弹窗
	const openDialog = async (row: any) => {
		// state.ruleForm = JSON.parse(JSON.stringify(row));
		// 改用detail获取最新数据来编辑
		let rowData = JSON.parse(JSON.stringify(row));
		if (rowData.id)
			state.ruleForm = (await detailHyBarCodeMain(rowData.id)).data.result;
		else
			state.ruleForm = rowData;
		state.isShowDialog = true;
	};

	// 关闭弹窗
	const closeDialog = () => {
		emit("reloadTable");
		state.isShowDialog = false;
	};

	// 取消
	const cancel = () => {
		state.isShowDialog = false;
	};

	// 提交
	// const submit = async () => {
	// 	ruleFormRef.value.validate(async (isValid: boolean, fields?: any) => {
	// 		if (isValid) {
	// 			let values = state.ruleForm;
	// 			if (state.ruleForm.barCode == undefined || state.ruleForm.barCode == null || state.ruleForm.barCode == "" || state.ruleForm.barCode == 0) {
	// 				await addHyBarCodeMain(values);
	// 			} 
	// 			closeDialog();
	// 		} else {
	// 			ElMessage({
	// 				message: `表单有${Object.keys(fields).length}处验证失败，请修改后再提交`,
	// 				type: "error",
	// 			});
	// 		}
	// 	});
	// };






	//将属性或者函数暴露给父组件
	defineExpose({ openDialog });
</script>




