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