<template>
|
<!-- 搜索工作栏 -->
|
<ContentWrap>
|
<el-form
|
class="-mb-15px"
|
:model="queryParams"
|
ref="queryFormRef"
|
:inline="true"
|
label-width="68px"
|
>
|
<el-form-item label="项目名称" prop="projectName">
|
<el-input
|
v-model="queryParams.projectName"
|
placeholder="请输入项目名称"
|
clearable
|
class="!w-240px"
|
/>
|
</el-form-item>
|
<el-form-item label="项目编码" prop="projectCode">
|
<el-input
|
v-model="queryParams.projectCode"
|
placeholder="请输入项目编码"
|
clearable
|
class="!w-240px"
|
/>
|
</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-button
|
type="primary"
|
plain
|
@click="openForm('create')"
|
v-hasPermi="['mpk:project:create']"
|
>
|
<Icon icon="ep:plus" class="mr-5px"/>
|
新增
|
</el-button>
|
</el-form-item>
|
</el-form>
|
</ContentWrap>
|
|
<!-- 列表 -->
|
<ContentWrap>
|
<el-table
|
v-loading="loading"
|
:data="list"
|
row-key="id"
|
>
|
<el-table-column prop="projectName" label="项目名称"/>
|
<el-table-column prop="projectCode" label="项目编码"/>
|
<el-table-column prop="createTime" label="创建时间" :formatter="dateFormatter" width="300px"/>
|
<el-table-column label="操作" align="center" width="300px">
|
<template #default="scope">
|
<div class="flex items-center justify-center">
|
<el-button
|
link
|
type="primary"
|
@click="openForm('update', scope.row.id)"
|
v-hasPermi="['mpk:project:update']"
|
>
|
<Icon icon="ep:edit"/>
|
修改
|
</el-button>
|
<el-button
|
link
|
type="danger"
|
@click="handleDelete(scope.row.id)"
|
v-hasPermi="['mpk:project:delete']"
|
>
|
<Icon icon="ep:delete"/>
|
删除
|
</el-button>
|
<el-button
|
link
|
type="primary"
|
@click="viewRelevanceModel(scope.row.id)"
|
>
|
<Icon icon="ep:link"/>
|
查看关联模型
|
</el-button>
|
<div class="pl-12px">
|
<el-dropdown @command="(command) => handleCommand(command, scope.row)"
|
trigger="click">
|
<el-button type="primary" link>
|
<Icon icon="ep:d-arrow-right"/>
|
更多
|
</el-button>
|
<template #dropdown>
|
<el-dropdown-menu>
|
<el-dropdown-item
|
command="packageModel"
|
>
|
<el-button link>打包</el-button>
|
</el-dropdown-item>
|
<el-dropdown-item
|
>
|
<router-link :to="'/project/package/history/' + scope.row.id">
|
<el-button link>打包历史</el-button>
|
</router-link>
|
</el-dropdown-item>
|
</el-dropdown-menu>
|
</template>
|
</el-dropdown>
|
</div>
|
</div>
|
</template>
|
</el-table-column>
|
</el-table>
|
<!-- 分页 -->
|
<Pagination
|
v-model:limit="queryParams.limit"
|
v-model:page="queryParams.page"
|
:total="total"
|
@pagination="getList"
|
/>
|
</ContentWrap>
|
|
<!-- 表单弹窗:添加/修改 -->
|
<ProjectForm ref="formRef" @success="getList"/>
|
<ProjectPackage ref="projectPackageRef"/>
|
<RelevanceModel ref="relevanceModelRef"/>
|
</template>
|
<script lang="ts" setup>
|
import {dateFormatter} from '@/utils/formatTime'
|
import * as ProjectApi from '@/api/model/mpk/project'
|
import ProjectForm from './ProjectForm.vue'
|
import ProjectPackage from './ProjectPackage.vue'
|
import RelevanceModel from './ProjectPackageModelDialog.vue'
|
|
defineOptions({name: 'MpkProject'})
|
|
const message = useMessage() // 消息弹窗
|
const {t} = useI18n() // 国际化
|
|
const loading = ref(true) // 列表的加载中
|
const total = ref(0) // 列表的总页数
|
const list = ref([]) // 字典表格数据
|
const queryParams = reactive({
|
page: 1,
|
limit: 10,
|
projectName: '',
|
projectCode: ''
|
})
|
const queryFormRef = ref() // 搜索的表单
|
|
const getList = async () => {
|
loading.value = true
|
try {
|
const data = await ProjectApi.getPage(queryParams)
|
list.value = data.list
|
total.value = data.total
|
} finally {
|
loading.value = false
|
}
|
}
|
|
/** 操作分发 */
|
const handleCommand = (command: string, row) => {
|
switch (command) {
|
case 'packageModel':
|
packageModel(row.id, row.projectName, row.projectCode, row.models)
|
break
|
default:
|
break
|
}
|
}
|
|
//打包
|
const projectPackageRef = ref();
|
const packageModel = (projectId, projectName, projectCode, models) => {
|
let ids = models.map(e => e.id);
|
if (ids && ids.length > 0) {
|
projectPackageRef.value.open(projectId, projectName, projectCode, ids.join(","));
|
} else {
|
message.error("请先为项目添加模型!")
|
}
|
}
|
|
/** 搜索按钮操作 */
|
const handleQuery = () => {
|
getList()
|
}
|
|
/** 重置按钮操作 */
|
const resetQuery = () => {
|
queryParams.page = 1
|
queryFormRef.value.resetFields()
|
handleQuery()
|
}
|
|
/** 添加/修改操作 */
|
const formRef = ref()
|
const openForm = (type: string, id?: number) => {
|
formRef.value.open(type, id)
|
}
|
|
/** 删除按钮操作 */
|
const handleDelete = async (id: number) => {
|
try {
|
// 删除的二次确认
|
await message.delConfirm()
|
// 发起删除
|
await ProjectApi.deleteProject(id)
|
message.success(t('common.delSuccess'))
|
// 刷新列表
|
await getList()
|
} catch {
|
}
|
}
|
|
// 查看关联模型
|
const relevanceModelRef = ref()
|
const viewRelevanceModel = (id) => {
|
relevanceModelRef.value.open('project',id)
|
}
|
|
/** 初始化 **/
|
onMounted(async () => {
|
await getList()
|
})
|
</script>
|