提交 | 用户 | 时间
|
9ec4bd
|
1 |
<template> |
潘 |
2 |
<Dialog v-model="dialogVisible" :title="dialogTitle"> |
|
3 |
<el-form |
|
4 |
ref="formRef" |
|
5 |
v-loading="formLoading" |
|
6 |
:model="formData" |
|
7 |
:rules="formRules" |
|
8 |
label-width="80px" |
|
9 |
> |
|
10 |
<el-row> |
|
11 |
<el-col :span="8"> |
|
12 |
<el-form-item label="版本号" prop="version"> |
|
13 |
<el-input v-model="formData.version" placeholder="请输入版本号"/> |
|
14 |
</el-form-item> |
|
15 |
</el-col> |
|
16 |
</el-row> |
|
17 |
<el-row> |
|
18 |
<el-col :span="24"> |
|
19 |
<el-form-item label="更新日志" prop="log"> |
|
20 |
<el-input type="textarea" :rows="4" placeholder="请输入更新日志" v-model="formData.log"/> |
|
21 |
</el-form-item> |
|
22 |
</el-col> |
|
23 |
</el-row> |
|
24 |
<el-row justify="end"> |
|
25 |
<el-col :span="3"> |
|
26 |
<el-button @click="packageProject()" type="primary">打包</el-button> |
|
27 |
</el-col> |
|
28 |
</el-row> |
|
29 |
</el-form> |
|
30 |
</Dialog> |
|
31 |
</template> |
|
32 |
<script lang="ts" setup> |
aff5c9
|
33 |
import * as ProjectApi from '@/api/model/mpk/project' |
9ec4bd
|
34 |
import download from "@/utils/download"; |
潘 |
35 |
import {FormRules} from "element-plus"; |
|
36 |
import {formatToDateString} from "@/utils/dateUtil"; |
|
37 |
|
|
38 |
|
|
39 |
const { t } = useI18n() // 国际化 |
|
40 |
const message = useMessage() // 消息弹窗 |
|
41 |
|
|
42 |
const dialogVisible = ref(false) // 弹窗的是否展示 |
|
43 |
const dialogTitle = ref('打包') // 弹窗的标题 |
|
44 |
const formLoading = ref(false) // 表单的加载中 |
|
45 |
|
|
46 |
const formRules = reactive<FormRules>({ |
|
47 |
version: [ |
|
48 |
{required: true, message: '版本号不能为空', trigger: 'blur'}, |
|
49 |
], |
|
50 |
log: [ |
|
51 |
{required: true, message: '更新日志不能为空', trigger: 'blur'}, |
|
52 |
] |
|
53 |
}) |
|
54 |
|
|
55 |
const formData = reactive({ |
|
56 |
log: undefined, |
|
57 |
projectId: undefined, |
|
58 |
projectName: undefined, |
|
59 |
projectCode: undefined, |
|
60 |
version: undefined, |
|
61 |
}) |
|
62 |
|
|
63 |
/** 打开弹窗 */ |
d6b754
|
64 |
const open = async (projectId,projectName,projectCode) => { |
9ec4bd
|
65 |
dialogVisible.value = true |
潘 |
66 |
formData.projectId = projectId |
|
67 |
formData.projectName = projectName |
|
68 |
formData.projectCode = projectCode |
|
69 |
formData.log = undefined |
|
70 |
formData.version = 'V' |
|
71 |
} |
|
72 |
defineExpose({ open }) // 提供 open 方法,用于打开弹窗 |
|
73 |
|
|
74 |
const formRef = ref() // 表单 Ref |
|
75 |
/** 提交表单 */ |
|
76 |
const packageProject = async () => { |
|
77 |
// 校验表单 |
|
78 |
try { |
|
79 |
if (!formRef) return |
|
80 |
const valid = await formRef.value.validate() |
|
81 |
if (!valid) return |
|
82 |
|
|
83 |
formLoading.value = true |
|
84 |
formData.zipFileName = 'IAILMPK.' + formData.projectCode + '.' + formatToDateString(new Date()) + '.zip' |
|
85 |
const data = await ProjectApi.packageProject(formData) |
|
86 |
download.zip(data, formData.zipFileName) |
|
87 |
formLoading.value = false |
|
88 |
dialogVisible.value = false |
|
89 |
} catch (e) { |
|
90 |
formLoading.value = false |
|
91 |
} |
|
92 |
} |
|
93 |
</script> |