<template>
|
<ContentWrap>
|
<el-form
|
class="-mb-15px"
|
:model="queryParams"
|
ref="queryFormRef"
|
:inline="true"
|
label-width="68px"
|
>
|
<el-form-item label="项目名称" prop="projectId">
|
<el-select v-model="queryParams.projectId" class="!w-240px">
|
<el-option
|
v-for="item in projectList"
|
:key="item.id"
|
:label="item.projectName"
|
:value="item.id"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="开始时间" prop="startTime">
|
<el-date-picker
|
v-model="queryParams.startTime"
|
type="datetime"
|
value-format="YYYY-MM-DD HH:mm:ss"
|
placeholder="选择日期时间"/>
|
</el-form-item>
|
<el-form-item label="结束时间" prop="endTime">
|
<el-date-picker
|
v-model="queryParams.endTime"
|
type="datetime"
|
value-format="YYYY-MM-DD HH:mm:ss"
|
placeholder="选择日期时间"/>
|
</el-form-item>
|
<el-form-item>
|
<el-button @click="handleQuery">
|
<Icon icon="ep:search" class="mr-5px"/>
|
搜索
|
</el-button>
|
<el-button @click="resetQuery">
|
<Icon icon="ep:refresh" class="mr-5px"/>
|
重置
|
</el-button>
|
</el-form-item>
|
</el-form>
|
</ContentWrap>
|
|
<!-- 列表 -->
|
<ContentWrap>
|
<el-table v-loading="loading" :data="list">
|
<el-table-column label="文件名" header-align="center" align="center" width="400">
|
<template #default="scope">
|
<a style="cursor: pointer;color: #409eff"
|
@click="downloadHistory(scope.row.filePath,scope.row.fileName)">{{ scope.row.fileName
|
}}</a>
|
</template>
|
</el-table-column>
|
<el-table-column prop="version" label="版本号" header-align="center" align="center" width="200"/>
|
<el-table-column prop="log" label="更新日志" header-align="center" align="center"/>
|
<el-table-column prop="createTime" label="打包时间" :formatter="dateFormatter" header-align="center" align="center" width="200"/>
|
<el-table-column label="操作" align="center" width="230px">
|
<template #default="scope">
|
<el-button
|
link
|
type="primary"
|
@click="viewPackageModel(scope.row.id)"
|
>
|
<Icon icon="ep:link"/>
|
查看关联模型
|
</el-button>
|
<el-button
|
link
|
type="primary"
|
@click="publish(scope.row.id,scope.row.version)"
|
>
|
<Icon icon="ep:upload"/>
|
发布
|
</el-button>
|
</template>
|
</el-table-column>
|
|
</el-table>
|
<!-- 分页 -->
|
<Pagination
|
:total="total"
|
v-model:page="queryParams.page"
|
v-model:limit="queryParams.limit"
|
@pagination="getList"
|
/>
|
</ContentWrap>
|
|
<PackageModel ref="packageModelRef"/>
|
</template>
|
<script lang="ts" setup>
|
import download from "@/utils/download";
|
import * as PackageHistoryApi from '@/api/model/mpk/projectPackageHistory'
|
import * as ProjectApi from '@/api/model/mpk/project'
|
import {dateFormatter} from '@/utils/formatTime'
|
import PackageModel from './ProjectPackageModelDialog.vue'
|
import * as MpkApi from "@/api/model/mpk/mpk";
|
|
defineOptions({name: 'ProjectPackageHistory'})
|
|
const message = useMessage() // 消息弹窗
|
const {t} = useI18n() // 国际化
|
const route = useRoute() // 路由
|
|
const loading = ref(true) // 列表的加载中
|
const total = ref(0) // 列表的总页数
|
const list = ref([]) // 列表的数据
|
const queryParams = reactive({
|
page: 1,
|
limit: 10,
|
projectId: route.params.projectId,
|
startTime: undefined,
|
endTime: undefined,
|
})
|
const queryFormRef = ref() // 搜索的表单
|
const projectList = ref() // 字典类型的列表
|
|
/** 查询列表 */
|
const getList = async () => {
|
loading.value = true
|
try {
|
const data = await PackageHistoryApi.getPage(queryParams)
|
list.value = data.list
|
total.value = data.total
|
} finally {
|
loading.value = false
|
}
|
}
|
|
watch(() => queryParams.projectId, (newVal, oldVal) => {
|
handleQuery()
|
})
|
|
/** 搜索按钮操作 */
|
const handleQuery = () => {
|
queryParams.page = 1
|
getList()
|
}
|
|
/** 重置按钮操作 */
|
const resetQuery = () => {
|
queryFormRef.value.resetFields()
|
handleQuery()
|
}
|
|
const downloadHistory = async (filePath,fileName) => {
|
const param = {
|
filePath,
|
fileName,
|
}
|
const data = await PackageHistoryApi.download(param)
|
download.zip(data, fileName)
|
}
|
|
const packageModelRef = ref()
|
const viewPackageModel = (id) => {
|
packageModelRef.value.open('package',id)
|
}
|
|
// 发布
|
const publish = async (historyId,version) => {
|
// 发布的二次确认
|
await message.confirm('确认发布 ' + projectList.value.find(e => e.id === queryParams.projectId).projectName + '【' + version + '】')
|
|
// 发布
|
await MpkApi.publish({historyId,projectId: queryParams.projectId})
|
|
message.success('发布成功');
|
}
|
|
/** 初始化 **/
|
onMounted(async () => {
|
await getList()
|
// 查询字典(精简)列表
|
projectList.value = await ProjectApi.list()
|
})
|
</script>
|