From 13c97d76348b5451381320aa54efa0706f38ecb6 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期四, 31 十月 2024 08:49:52 +0800 Subject: [PATCH] 测点列表.xlsx --- src/views/model/mpk/file/MpkGenerator.vue | 59 +++++++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 41 insertions(+), 18 deletions(-) diff --git a/src/views/model/mpk/file/MpkGenerator.vue b/src/views/model/mpk/file/MpkGenerator.vue index 5a86965..2756e05 100644 --- a/src/views/model/mpk/file/MpkGenerator.vue +++ b/src/views/model/mpk/file/MpkGenerator.vue @@ -1,10 +1,22 @@ <template> <Dialog v-model="dialogVisible" :title="dialogTitle"> - <el-input - type="textarea" - :rows="4" - placeholder="备注" - v-model="remark"/> + <el-form + ref="formRef" + :model="formData" + :rules="formRules" + label-width="0px" + > + <el-form-item prop="pyName"> + <el-input v-model="formData.pyName" readonly /> + </el-form-item> + <el-form-item prop="remark"> + <el-input + type="textarea" + :rows="4" + placeholder="备注" + v-model="formData.remark"/> + </el-form-item> + </el-form> <div style="width: 100%;display: flex;flex-direction: row;justify-content: end;margin-top: 16px"> <el-button @click="generatorCode()" type="primary">生成</el-button> </div> @@ -22,28 +34,39 @@ const dialogVisible = ref(false) // 弹窗的是否展示 const dialogTitle = ref('生成代码') // 弹窗的标题 - const remark = ref('') - const id = ref() - const zipFileName = ref() + const formData = ref({ + id: undefined, + pyName: '', + zipFileName: '', + remark: '' + }) + const formRules = reactive({ + }) + const formRef = ref() /** 打开弹窗 */ const open = async (modelId: string,pyName: string) => { dialogVisible.value = true - id.value = modelId; - zipFileName.value = pyName + '_' + formatToDateString(new Date()) + '.zip'; - remark.value = ""; + resetForm() + formData.value.id = modelId + formData.value.pyName = pyName + formData.value.zipFileName = pyName + '_' + formatToDateString(new Date()) + '.zip'; } defineExpose({ open }) // 提供 open 方法,用于打开弹窗 /** 提交表单 */ const generatorCode = async () => { - const param = { - 'id': id.value, - 'remark': remark.value, - 'zipFileName': zipFileName.value - } - const data = await MpkApi.generatorCode(param) - download.zip(data, zipFileName.value) + const data = await MpkApi.generatorCode(formData.value) + download.zip(data, formData.value.zipFileName) dialogVisible.value = false } + /** 重置表单 */ + const resetForm = () => { + formData.value = { + id: undefined, + zipFileName: '', + remark: '' + } + formRef.value?.resetFields() + } </script> -- Gitblit v1.9.3