提交 | 用户 | 时间
|
7462da
|
1 |
<template> |
L |
2 |
<Dialog v-model="dialogVisible" :title="dialogTitle" width="50%"> |
|
3 |
<el-form |
|
4 |
ref="formRef" |
|
5 |
v-loading="formLoading" |
|
6 |
:model="formData" |
|
7 |
:rules="formRules" |
|
8 |
label-width="120px" |
|
9 |
> |
|
10 |
<el-row> |
|
11 |
<el-col :span="12"> |
|
12 |
<el-form-item label="编号" prop="itemno"> |
|
13 |
<el-input v-model="formData.itemno" placeholder="请输入编号"/> |
|
14 |
</el-form-item> |
|
15 |
</el-col> |
|
16 |
<el-col :span="12"> |
|
17 |
<el-form-item label="预测项名" prop="itemname"> |
|
18 |
<el-input v-model="formData.itemname" placeholder="请输入预测项名"/> |
|
19 |
</el-form-item> |
|
20 |
</el-col> |
|
21 |
</el-row> |
|
22 |
<el-row> |
|
23 |
<el-col :span="12"> |
|
24 |
<el-form-item label="类型ID" prop="itemtypeid"> |
|
25 |
<el-input v-model="formData.itemtypeid" placeholder="请输入类型ID"/> |
|
26 |
</el-form-item> |
|
27 |
</el-col> |
|
28 |
<el-col :span="12"> |
|
29 |
<el-form-item label="类型名称" prop="itemtypename"> |
|
30 |
<el-input v-model="formData.itemtypename" placeholder="请输入类型名称"/> |
|
31 |
</el-form-item> |
|
32 |
</el-col> |
|
33 |
</el-row> |
|
34 |
<el-row> |
|
35 |
<el-col :span="12"> |
|
36 |
<el-form-item label="粒度" prop="granularity"> |
|
37 |
<el-input v-model="formData.granularity" placeholder="请输入粒度"/> |
|
38 |
</el-form-item> |
|
39 |
</el-col> |
|
40 |
<el-col :span="12"> |
|
41 |
<el-form-item label="是否融合" prop="isfuse"> |
|
42 |
<el-input v-model="formData.isfuse" placeholder="请输入是否融合"/> |
|
43 |
</el-form-item> |
|
44 |
</el-col> |
|
45 |
</el-row> |
|
46 |
<el-row> |
|
47 |
<el-col :span="12"> |
|
48 |
<el-form-item label="是否检查" prop="workchecked"> |
|
49 |
<el-input v-model="formData.workchecked" placeholder="请输入是否检查"/> |
|
50 |
</el-form-item> |
|
51 |
</el-col> |
|
52 |
<el-col :span="12"> |
|
53 |
<el-form-item label="模块ID" prop="moduleid"> |
|
54 |
<el-input v-model="formData.moduleid" placeholder="请输入模块ID"/> |
|
55 |
</el-form-item> |
|
56 |
</el-col> |
|
57 |
</el-row> |
|
58 |
<el-row> |
|
59 |
<el-col :span="12"> |
|
60 |
<el-form-item label="排序" prop="itemorder"> |
|
61 |
<el-input v-model="formData.itemorder" placeholder="请输入排序"/> |
|
62 |
</el-form-item> |
|
63 |
</el-col> |
|
64 |
<el-col :span="12"> |
|
65 |
<el-form-item label="是否启用" prop="status"> |
|
66 |
<el-input v-model="formData.status" placeholder="请输入是否启用"/> |
|
67 |
</el-form-item> |
|
68 |
</el-col> |
|
69 |
</el-row> |
|
70 |
<el-row> |
|
71 |
<el-col :span="12"> |
|
72 |
<el-form-item label="类别ID" prop="categoryid"> |
|
73 |
<el-input v-model="formData.categoryid" placeholder="请输入类别ID"/> |
|
74 |
</el-form-item> |
|
75 |
</el-col> |
|
76 |
<el-col :span="12"> |
|
77 |
<el-form-item label="数据点ID" prop="pointid"> |
|
78 |
<el-input v-model="formData.pointid" placeholder="请输入数据点ID"/> |
|
79 |
</el-form-item> |
|
80 |
</el-col> |
|
81 |
</el-row> |
|
82 |
<el-row> |
|
83 |
<el-col :span="12"> |
|
84 |
<el-form-item label="数据点名称" prop="tagname"> |
|
85 |
<el-input v-model="formData.tagname" placeholder="请输入数据点名称"/> |
|
86 |
</el-form-item> |
|
87 |
</el-col> |
|
88 |
<el-col :span="12"> |
|
89 |
<el-form-item label="存放表ID" prop="resulttableid"> |
|
90 |
<el-input v-model="formData.resulttableid" placeholder="请输入存放表ID"/> |
|
91 |
</el-form-item> |
|
92 |
</el-col> |
|
93 |
</el-row> |
|
94 |
<el-row> |
|
95 |
<el-col :span="12"> |
|
96 |
<el-form-item label="存放表" prop="tablename"> |
|
97 |
<el-input v-model="formData.tablename" placeholder="请输入存放表"/> |
|
98 |
</el-form-item> |
|
99 |
</el-col> |
|
100 |
</el-row> |
|
101 |
</el-form> |
|
102 |
<template #footer> |
|
103 |
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button> |
|
104 |
<el-button @click="dialogVisible = false">取 消</el-button> |
|
105 |
</template> |
|
106 |
</Dialog> |
|
107 |
</template> |
|
108 |
<script lang="ts" setup> |
|
109 |
import * as MmPredictItem from '@/api/model/pre/predict' |
|
110 |
|
|
111 |
defineOptions({name: 'DataMmPredictItemForm'}) |
|
112 |
|
|
113 |
const {t} = useI18n() // 国际化 |
|
114 |
const message = useMessage() // 消息弹窗 |
|
115 |
const dialogVisible = ref(false) // 弹窗的是否展示 |
|
116 |
const dialogTitle = ref('') // 弹窗的标题 |
|
117 |
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用 |
|
118 |
const formType = ref('') // 表单的类型:create - 新增;update - 修改 |
|
119 |
const formData = ref({ |
|
120 |
id: undefined, |
|
121 |
itemno: undefined, |
|
122 |
itemname: undefined, |
|
123 |
itemtypeid: undefined, |
|
124 |
itemtypename: undefined, |
|
125 |
granularity: undefined, |
|
126 |
isfuse: undefined, |
|
127 |
workchecked: undefined, |
|
128 |
moduleid: undefined, |
|
129 |
itemorder: undefined, |
|
130 |
status: undefined, |
|
131 |
categoryid: undefined, |
|
132 |
pointid: undefined, |
|
133 |
tagname: undefined, |
|
134 |
resulttableid: undefined, |
|
135 |
tablename: undefined, |
|
136 |
}) |
|
137 |
const formRules = reactive({ |
|
138 |
itemno: [{required: true, message: '编号不能为空', trigger: 'blur'}], |
|
139 |
itemname: [{required: true, message: '预测项名不能为空', trigger: 'blur'}], |
|
140 |
}) |
|
141 |
const formRef = ref() // 表单 Ref |
|
142 |
|
|
143 |
/** 打开弹窗 */ |
|
144 |
const open = async (type: string, id?: number) => { |
|
145 |
dialogVisible.value = true |
|
146 |
dialogTitle.value = t('action.' + type) |
|
147 |
formType.value = type |
|
148 |
resetForm() |
|
149 |
// 修改时,设置数据 |
|
150 |
if (id) { |
|
151 |
formLoading.value = true |
|
152 |
try { |
|
153 |
formData.value = await MmPredictItem.getMmPredictItem(id) |
|
154 |
} finally { |
|
155 |
formLoading.value = false |
|
156 |
} |
|
157 |
} |
|
158 |
} |
|
159 |
defineExpose({open}) // 提供 open 方法,用于打开弹窗 |
|
160 |
|
|
161 |
/** 提交表单 */ |
|
162 |
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调 |
|
163 |
const submitForm = async () => { |
|
164 |
// 校验表单 |
|
165 |
if (!formRef) return |
|
166 |
const valid = await formRef.value.validate() |
|
167 |
if (!valid) return |
|
168 |
// 提交请求 |
|
169 |
formLoading.value = true |
|
170 |
try { |
|
171 |
const data = formData.value as unknown as MmPredictItem.MmPredictItemVO |
|
172 |
if (formType.value === 'create') { |
|
173 |
await MmPredictItem.createMmPredictItem(data) |
|
174 |
message.success(t('common.createSuccess')) |
|
175 |
} else { |
|
176 |
await MmPredictItem.updateMmPredictItem(data) |
|
177 |
message.success(t('common.updateSuccess')) |
|
178 |
} |
|
179 |
dialogVisible.value = false |
|
180 |
// 发送操作成功的事件 |
|
181 |
emit('success') |
|
182 |
} finally { |
|
183 |
formLoading.value = false |
|
184 |
} |
|
185 |
} |
|
186 |
|
|
187 |
/** 重置表单 */ |
|
188 |
const resetForm = () => { |
|
189 |
formData.value = { |
|
190 |
id: undefined, |
|
191 |
itemno: undefined, |
|
192 |
itemname: undefined, |
|
193 |
itemtypeid: undefined, |
|
194 |
itemtypename: undefined, |
|
195 |
granularity: undefined, |
|
196 |
isfuse: undefined, |
|
197 |
workchecked: undefined, |
|
198 |
moduleid: undefined, |
|
199 |
itemorder: undefined, |
|
200 |
status: undefined, |
|
201 |
categoryid: undefined, |
|
202 |
pointid: undefined, |
|
203 |
tagname: undefined, |
|
204 |
resulttableid: undefined, |
|
205 |
tablename: undefined, |
|
206 |
} |
|
207 |
formRef.value?.resetFields() |
|
208 |
} |
|
209 |
</script> |