<!--
 * @Author: zwq
 * @Date: 2023-08-01 13:52:10
 * @LastEditors: zwq
 * @LastEditTime: 2023-11-23 15:27:55
 * @Description:
-->
<template>
	<el-form
		:model="dataForm"
		:rules="dataRule"
		ref="dataForm"
		v-if="visible"
		@keyup.enter.native="dataFormSubmit()"
		label-width="100px"
    label-position="top">
		<el-row :gutter="20">
			<el-col :span="12">
				<el-form-item label="物品名称" prop="name">
					<el-input
						v-model="dataForm.name"
						clearable
						placeholder="请输入物品名称" />
				</el-form-item>
			</el-col>
			<el-col :span="12">
				<el-form-item label="物品编码" prop="code">
					<el-input
						v-model="dataForm.code"
						clearable
						placeholder="请输入物品编码" />
				</el-form-item>
			</el-col>
			<el-col :span="12">
				<el-form-item label="物品规格" prop="spec">
					<el-input
						v-model="dataForm.spec"
						clearable
						placeholder="请输入物品规格" />
				</el-form-item>
			</el-col>
			<el-col :span="12">
				<el-form-item label="物品单位" prop="unit">
					<el-select
						v-model="dataForm.unit"
						filterable
						clearable
						:style="{ width: '100%' }"
						placeholder="请选择单位">
						<el-option
							v-for="item in urlOptions.dictList.dict0"
							:key="item.id"
							:label="item.label"
							:value="parseInt(item.value)"></el-option>
					</el-select>
				</el-form-item>
			</el-col>
			<el-col :span="12">
				<el-form-item label="单日消耗量" prop="dailyUse">
					<el-input-number
            :min="0"
						v-model="dataForm.dailyUse"
						clearable
            style="width: 100%;"
						placeholder="请输入单日消耗量" />
				</el-form-item>
			</el-col>
			<el-col :span="12">
				<el-form-item label="允许留存时间" prop="allowTime">
					<el-input-number
            :min="0"
						v-model="dataForm.allowTime"
						clearable
            style="width: 90%;"
						placeholder="请输入允许留存时间" /> (天)
				</el-form-item>
			</el-col>
			<el-col :span="12">
				<el-form-item prop="enabled" label="是否可用">
					<el-select
						v-model="dataForm.enabled"
						filterable
						clearable
						:style="{ width: '100%' }"
						placeholder="请选择是否可用">
						<el-option
							v-for="item in isorno"
							:key="item.id"
							:label="item.name"
							:value="item.id"></el-option>
					</el-select>
				</el-form-item>
			</el-col>
			<el-col :span="12">
				<el-form-item label="备注" prop="remark">
					<el-input
						v-model="dataForm.remark"
						clearable
						placeholder="请输入备注" />
				</el-form-item>
			</el-col>
		</el-row>
	</el-form>
</template>

<script>
import basicAdd from '../../mixins/basic-add';
import {
	createWarehouseGoods,
	updateWarehouseGoods,
	getWarehouseGoods,
	getCode,
} from '@/api/warehouse/warehouseGoods';

export default {
	mixins: [basicAdd],
	data() {
		return {
			urlOptions: {
				isGetCode: true,
				getDictList: true,
				codeURL: getCode,
				createURL: createWarehouseGoods,
				updateURL: updateWarehouseGoods,
				infoURL: getWarehouseGoods,
			},
			nameList: ['unit_dict'],
			dataForm: {
				id: undefined,
				code: '',
				name: '',
				spec: '',
				unit: '',
				dailyUse: 0,
				allowTime: 0,
				enabled: 1,
				remark: '',
        storageType:2
			},
			dataRule: {
				code: [
					{ required: true, message: '物品编码不能为空', trigger: 'blur' },
				],
				name: [
					{ required: true, message: '物品名称不能为空', trigger: 'blur' },
				],
			},
			isorno: [
				{
					id: 0,
					name: '不可用',
				},
				{
					id: 1,
					name: '可用',
				},
			],
		};
	},
	methods: {},
};
</script>
