<template>
|
<Dialog v-model="dialogVisible" :title="dialogTitle">
|
<el-input
|
type="textarea"
|
:rows="4"
|
placeholder="备注"
|
v-model="remark"/>
|
<div style="width: 100%;display: flex;flex-direction: row;justify-content: end;margin-top: 16px">
|
<el-button @click="generatorCode()" type="primary">生成</el-button>
|
</div>
|
</Dialog>
|
</template>
|
<script lang="ts" setup>
|
import * as MpkApi from '@/api/mpk/mpk'
|
import download from "@/utils/download";
|
import {formatToDateString} from "@/utils/dateUtil";
|
|
|
const { t } = useI18n() // 国际化
|
const message = useMessage() // 消息弹窗
|
|
const dialogVisible = ref(false) // 弹窗的是否展示
|
const dialogTitle = ref('生成代码') // 弹窗的标题
|
|
const remark = ref('')
|
const id = ref()
|
const zipFileName = ref()
|
|
/** 打开弹窗 */
|
const open = async (modelId: string,pyName: string) => {
|
dialogVisible.value = true
|
id.value = modelId;
|
zipFileName.value = pyName + '_' + formatToDateString(new Date()) + '.zip';
|
remark.value = "";
|
}
|
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)
|
dialogVisible.value = false
|
}
|
</script>
|