<template>
|
<Dialog v-model="dialogVisible" :title="dialogTitle">
|
<el-form
|
ref="formRef"
|
v-loading="formLoading"
|
:model="formData"
|
:rules="formRules"
|
label-width="80px"
|
>
|
<el-row>
|
<el-col :span="8">
|
<el-form-item label="版本号" prop="version">
|
<el-input v-model="formData.version" placeholder="请输入版本号"/>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="24">
|
<el-form-item label="更新日志" prop="log">
|
<el-input type="textarea" :rows="4" placeholder="请输入更新日志" v-model="formData.log"/>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row justify="end">
|
<el-col :span="3">
|
<el-button @click="packageProject()" type="primary">打包</el-button>
|
</el-col>
|
</el-row>
|
</el-form>
|
</Dialog>
|
</template>
|
<script lang="ts" setup>
|
import * as ProjectApi from '@/api/model/mpk/project'
|
import download from "@/utils/download";
|
import {FormRules} from "element-plus";
|
import {formatToDateString} from "@/utils/dateUtil";
|
|
|
const { t } = useI18n() // 国际化
|
const message = useMessage() // 消息弹窗
|
|
const dialogVisible = ref(false) // 弹窗的是否展示
|
const dialogTitle = ref('打包') // 弹窗的标题
|
const formLoading = ref(false) // 表单的加载中
|
|
const formRules = reactive<FormRules>({
|
version: [
|
{required: true, message: '版本号不能为空', trigger: 'blur'},
|
],
|
log: [
|
{required: true, message: '更新日志不能为空', trigger: 'blur'},
|
]
|
})
|
|
const formData = reactive({
|
log: undefined,
|
projectId: undefined,
|
projectName: undefined,
|
projectCode: undefined,
|
ids: undefined,
|
version: undefined,
|
})
|
|
/** 打开弹窗 */
|
const open = async (projectId,projectName,projectCode,ids) => {
|
dialogVisible.value = true
|
formData.projectId = projectId
|
formData.projectName = projectName
|
formData.projectCode = projectCode
|
formData.ids = ids
|
formData.log = undefined
|
formData.version = 'V'
|
}
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
|
const formRef = ref() // 表单 Ref
|
/** 提交表单 */
|
const packageProject = async () => {
|
// 校验表单
|
try {
|
if (!formRef) return
|
const valid = await formRef.value.validate()
|
if (!valid) return
|
|
formLoading.value = true
|
formData.zipFileName = 'IAILMPK.' + formData.projectCode + '.' + formatToDateString(new Date()) + '.zip'
|
const data = await ProjectApi.packageProject(formData)
|
debugger
|
download.zip(data, formData.zipFileName)
|
formLoading.value = false
|
dialogVisible.value = false
|
} catch (e) {
|
formLoading.value = false
|
}
|
}
|
</script>
|