dengzedong
2025-02-27 3933d80769776a812cb73cbf6762762959297c09
提交 | 用户 | 时间
3933d8 1 <template>
D 2   <!-- 搜索工作栏 -->
3   <ContentWrap>
4     <el-form
5       class="-mb-15px"
6       :model="queryParams"
7       ref="queryFormRef"
8       :inline="true"
9       label-width="68px"
10       @submit.prevent
11     >
12       <el-form-item label="模型名称" prop="pyChineseName">
13         <el-input
14           v-model="queryParams.modelName"
15           placeholder="请输入模型名称"
16           clearable
17           class="!w-240px"
18         />
19       </el-form-item>
20       <el-form-item label="模型文件" prop="modelFileName">
21         <el-input
22           v-model="queryParams.modelFileName"
23           placeholder="请输入模型文件名称"
24           clearable
25           class="!w-240px"
26         />
27       </el-form-item>
28       <el-form-item>
29         <el-button @click="handleQuery">
30           <Icon icon="ep:search" class="mr-5px"/>
31           搜索
32         </el-button>
33         <el-button @click="resetQuery">
34           <Icon icon="ep:refresh" class="mr-5px"/>
35           重置
36         </el-button>
37         <div class="ml-12px">
38           <router-link :to="'/matlab/model/form'">
39             <el-button type="primary" plain v-hasPermi="['ml:model:create']">
40               <Icon icon="ep:plus" class="mr-5px"/>新增</el-button>
41           </router-link>
42         </div>
43
44       </el-form-item>
45     </el-form>
46   </ContentWrap>
47
48   <!-- 列表 -->
49   <ContentWrap>
50     <el-table
51       v-loading="loading"
52       :data="list"
53       row-key="id"
54     >
55       <el-table-column prop="modelName" label="模型名称" header-align="center" align="center" min-width="100" />
56       <el-table-column prop="modelFileName" label="模型文件" header-align="center" align="center" min-width="250"/>
57       <el-table-column prop="modelType" label="模型类型" header-align="center" align="center" :formatter="(r,c,v) => getDictLabel(DICT_TYPE.MODEL_TYPE,v)"/>
58       <el-table-column prop="matlabPlatform" label="matlab平台" header-align="center" align="center"/>
59       <el-table-column prop="matlabVersion" label="matlab版本" header-align="center" align="center"/>
60 <!--      <el-table-column prop="remark" label="备注" header-align="center" align="center" min-width="100px"/>-->
61       <el-table-column prop="createDate" label="创建时间" header-align="center" align="center" :formatter="dateFormatter" width="180px"/>
62       <el-table-column prop="updateDate" label="修改时间" header-align="center" align="center" :formatter="dateFormatter" width="180px"/>
63       <el-table-column label="操作" align="center" width="200px">
64         <template #default="scope">
65           <div class="flex items-center justify-center">
66             <router-link :to="'/matlab/model/form/' + scope.row.id">
67               <el-button type="primary" link v-hasPermi="['ml:model:update']">
68                 <Icon icon="ep:edit"/>修改
69               </el-button>
70             </router-link>
71             <el-button link type="danger" @click="handleDelete(scope.row.id)" v-hasPermi="['ml:model:delete']">
72               <Icon icon="ep:delete"/>删除
73             </el-button>
74             <div class="pl-12px">
75               <el-dropdown @command="(command) => handleCommand(command, scope.row)" trigger="click">
76                 <el-button type="primary" link>
77                   <Icon icon="ep:d-arrow-right" /> 更多
78                 </el-button>
79                 <template #dropdown>
80                   <el-dropdown-menu>
81                     <el-dropdown-item
82                       command="mpkRunDialog"
83                     >
84                       运行
85                     </el-dropdown-item>
86                   </el-dropdown-menu>
87                 </template>
88               </el-dropdown>
89             </div>
90           </div>
91         </template>
92       </el-table-column>
93     </el-table>
94     <!-- 分页 -->
95     <Pagination
96       v-model:limit="queryParams.limit"
97       v-model:page="queryParams.page"
98       :total="total"
99       @pagination="getList"
100     />
101   </ContentWrap>
102
103   <MatlabRun ref="matlabRun" />
104 </template>
105 <script lang="ts" setup>
106   import {dateFormatter} from '@/utils/formatTime'
107   import * as MlModelApi from '@/api/model/matlab/mlModel'
108   import { DICT_TYPE, getDictLabel } from '@/utils/dict'
109   import MatlabRun from './MatlabRun.vue'
110
111   defineOptions({name: 'MatlabModel'})
112
113   const message = useMessage() // 消息弹窗
114   const {t} = useI18n() // 国际化
115
116   const loading = ref(true) // 列表的加载中
117   const total = ref(0) // 列表的总页数
118   const list = ref([]) // 字典表格数据
119   const queryParams = reactive({
120     page: 1,
121     limit: 10,
122     modelName: '',
123     modelFileName: ''
124   })
125   const queryFormRef = ref() // 搜索的表单
126
127   const getList = async () => {
128     loading.value = true
129     try {
130       const data = await MlModelApi.getPage(queryParams)
131       list.value = data.list
132       total.value = data.total
133     } finally {
134       loading.value = false
135     }
136   }
137
138   /** 操作分发 */
139   const handleCommand = (command: string, row) => {
140     switch (command) {
141       case 'mpkRunDialog':
142         matlabRunDialog(row)
143         break
144       default:
145         break
146     }
147   }
148
149   /** 搜索按钮操作 */
150   const handleQuery = () => {
151     getList()
152   }
153
154   /** 重置按钮操作 */
155   const resetQuery = () => {
156     queryParams.page = 1
157     queryFormRef.value.resetFields()
158     handleQuery()
159   }
160
161   /** 删除按钮操作 */
162   const handleDelete = async (id: number) => {
163     try {
164       // 删除的二次确认
165       await message.delConfirm()
166       // 发起删除
167       await MlModelApi.deleteModel(id)
168       message.success(t('common.delSuccess'))
169       // 刷新列表
170       await getList()
171     } catch {
172     }
173   }
174
175   const matlabRun = ref();
176   const matlabRunDialog = (row) => {
177     matlabRun.value.open(row);
178   }
179
180   onActivated((to) => {
181     getList()
182   })
183
184   /** 初始化 **/
185   onMounted(async () => {
186     await getList()
187   })
188 </script>