提交 | 用户 | 时间
|
9ec4bd
|
1 |
<template> |
潘 |
2 |
<Dialog v-model="dialogVisible" :title="dialogTitle"> |
|
3 |
<el-input |
|
4 |
type="textarea" |
|
5 |
:rows="4" |
|
6 |
placeholder="备注" |
|
7 |
v-model="remark"/> |
|
8 |
<div style="width: 100%;display: flex;flex-direction: row;justify-content: end;margin-top: 16px"> |
|
9 |
<el-button @click="generatorCode()" type="primary">生成</el-button> |
|
10 |
</div> |
|
11 |
</Dialog> |
|
12 |
</template> |
|
13 |
<script lang="ts" setup> |
aff5c9
|
14 |
import * as MpkApi from '@/api/model/mpk/mpk' |
9ec4bd
|
15 |
import download from "@/utils/download"; |
潘 |
16 |
import {formatToDateString} from "@/utils/dateUtil"; |
|
17 |
|
|
18 |
|
|
19 |
const { t } = useI18n() // 国际化 |
|
20 |
const message = useMessage() // 消息弹窗 |
|
21 |
|
|
22 |
const dialogVisible = ref(false) // 弹窗的是否展示 |
|
23 |
const dialogTitle = ref('生成代码') // 弹窗的标题 |
|
24 |
|
|
25 |
const remark = ref('') |
|
26 |
const id = ref() |
|
27 |
const zipFileName = ref() |
|
28 |
|
|
29 |
/** 打开弹窗 */ |
|
30 |
const open = async (modelId: string,pyName: string) => { |
|
31 |
dialogVisible.value = true |
|
32 |
id.value = modelId; |
|
33 |
zipFileName.value = pyName + '_' + formatToDateString(new Date()) + '.zip'; |
|
34 |
remark.value = ""; |
|
35 |
} |
|
36 |
defineExpose({ open }) // 提供 open 方法,用于打开弹窗 |
|
37 |
|
|
38 |
/** 提交表单 */ |
|
39 |
const generatorCode = async () => { |
|
40 |
const param = { |
|
41 |
'id': id.value, |
|
42 |
'remark': remark.value, |
|
43 |
'zipFileName': zipFileName.value |
|
44 |
} |
|
45 |
const data = await MpkApi.generatorCode(param) |
|
46 |
download.zip(data, zipFileName.value) |
|
47 |
dialogVisible.value = false |
|
48 |
} |
|
49 |
</script> |