dongyukun
5 天以前 f4e6a890da2884777281031a9c736c7659c2a74a
提交 | 用户 | 时间
2f0aa4 1 <template>
2   <!-- 搜索 -->
3   <ContentWrap>
4     <el-form
5       class="-mb-15px"
6       :model="queryParams"
7       ref="queryFormRef"
8       :inline="true"
9       label-width="68px"
10     >
11       <el-form-item label="方案编号" prop="code">
12         <el-input
13           v-model="queryParams.code"
14           placeholder="请输入方案编号"
15           clearable
16           @keyup.enter="handleQuery"
17           class="!w-240px"
18         />
19       </el-form-item>
20       <el-form-item label="方案名称" prop="name">
21         <el-input
22           v-model="queryParams.name"
23           placeholder="请输入方案名称"
24           clearable
25           @keyup.enter="handleQuery"
26           class="!w-240px"
27         />
28       </el-form-item>
29       <el-form-item>
30         <el-button @click="handleQuery">
31           <Icon icon="ep:search" class="mr-5px" />
32           搜索
33         </el-button>
34         <el-button @click="resetQuery">
35           <Icon icon="ep:refresh" class="mr-5px" />
36           重置
37         </el-button>
38         <el-button
39           type="primary"
40           plain
41           @click="openForm('create')"
42           v-hasPermi="['sche:scheme:create']"
43         >
44           <Icon icon="ep:plus" class="mr-5px" />
45           新增
46         </el-button>
47       </el-form-item>
48     </el-form>
49   </ContentWrap>
50
51   <!-- 列表 -->
52   <ContentWrap>
53     <el-table v-loading="loading" :data="list">
6badb7 54       <el-table-column label="方案编号" align="center" prop="code" min-width="100"/>
778f36 55       <el-table-column label="方案名称" header-align="center" align="left" prop="name" min-width="100"/>
6badb7 56       <el-table-column label="触发方式" align="center" prop="triggerMethod" min-width="100">
57         <template #default="scope">
58           <dict-tag :type="DICT_TYPE.SCHE_TRIGGER_METHOD" :value="scope.row.triggerMethod" />
59         </template>
60       </el-table-column>
61       <el-table-column label="触发条件" align="center" prop="triggerCondition" min-width="100"/>
62       <el-table-column label="调整对象" align="center" prop="scheduleObj" min-width="100"/>
63       <el-table-column label="调整类型" align="center" prop="scheduleType" min-width="100"/>
64       <el-table-column label=" 调整策略" align="center" prop="scheduleStrategy" min-width="100"/>
65       <el-table-column label="调度时间" align="center" prop="scheduleTime" min-width="160" />
49a44d 66       <el-table-column label="运行状态" align="center" prop="runStatus">
67         <template #default="scope">
68           <el-tag v-if="scope.row.runStatus + '' === '100'" size="small" type="success">{{scope.row.runStatus}}</el-tag>
69           <el-tag v-else size="small" type="danger">{{scope.row.runStatus}}</el-tag>
70         </template>
71       </el-table-column>
778f36 72       <el-table-column label="备注" header-align="center" align="left" prop="remark" min-width="160" />
49a44d 73       <el-table-column label="是否启用" align="center" prop="status" min-width="100">
6badb7 74         <template #default="scope">
75           <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
76         </template>
77       </el-table-column>
778f36 78       <el-table-column label="操作" align="center" min-width="100" fixed="right">
2f0aa4 79         <template #default="scope">
80           <el-button
81             link
82             type="primary"
83             @click="openForm('update', scope.row.id)"
84             v-hasPermi="['sche:scheme:update']"
85           >
86             编辑
87           </el-button>
88           <el-button
89             link
02bbf2 90             type="primary"
91             @click="openRecordList(scope.row.id)"
92             v-hasPermi="['sche:record:query']"
93           >
94             日志
95           </el-button>
96           <el-button
97             link
2f0aa4 98             type="danger"
99             @click="handleDelete(scope.row.id)"
100             v-hasPermi="['sche:scheme:delete']"
101           >
102             删除
103           </el-button>
104         </template>
105       </el-table-column>
106     </el-table>
107     <!-- 分页 -->
108     <Pagination
109       :total="total"
110       v-model:page="queryParams.pageNo"
111       v-model:limit="queryParams.pageSize"
112       @pagination="getList"
113     />
114   </ContentWrap>
115
116   <!-- 表单弹窗:添加/修改 -->
117   <ScheduleSchemeForm ref="formRef" @success="getList" />
118
02bbf2 119   <!-- 表单弹窗:添加/修改 -->
120   <RecordList ref="recordRef" />
2f0aa4 121 </template>
122 <script lang="ts" setup>
123   import {DICT_TYPE, getIntDictOptions} from '@/utils/dict'
124   import * as ScheduleSchemeApi from '@/api/model/sche/scheme'
125   import ScheduleSchemeForm from './ScheduleSchemeForm.vue'
02bbf2 126   import RecordList from  './record/index.vue'
2f0aa4 127
128   defineOptions({name: 'ScheduleScheme'})
129
130   const message = useMessage() // 消息弹窗
131   const {t} = useI18n() // 国际化
132
133   const loading = ref(true) // 列表的加载中
134   const total = ref(0) // 列表的总页数
135   const list = ref([]) // 列表的数据
136   const queryParams = reactive({
137     pageNo: 1,
138     pageSize: 10,
139     code: undefined,
140     name: undefined
141   })
142   const queryFormRef = ref() // 搜索的表单
143   const exportLoading = ref(false) // 导出的加载中
144
145   /** 查询列表 */
146   const getList = async () => {
147     loading.value = true
148     try {
149       const page = await ScheduleSchemeApi.getScheduleSchemePage(queryParams)
150       list.value = page.list
151       total.value = page.total
152     } finally {
153       loading.value = false
154     }
155   }
156
157   /** 搜索按钮操作 */
158   const handleQuery = () => {
159     queryParams.pageNo = 1
160     getList()
161   }
162
163   /** 重置按钮操作 */
164   const resetQuery = () => {
165     queryFormRef.value.resetFields()
166     handleQuery()
167   }
168
169   /** 添加/修改操作 */
170   const formRef = ref()
171   const openForm = (type: string, id?: number) => {
172     formRef.value.open(type, id)
173   }
174
175   /** 删除按钮操作 */
176   const handleDelete = async (id: number) => {
177     try {
178       // 删除的二次确认
179       await message.delConfirm()
180       // 发起删除
181       await ScheduleSchemeApi.deleteScheduleScheme(id)
182       message.success(t('common.delSuccess'))
183       // 刷新列表
184       await getList()
185     } catch {
186     }
187   }
188
02bbf2 189   /** 调用日志查看 */
190   const recordRef = ref()
191   const openRecordList = (id?: string) => {
192     recordRef.value.open(id)
193   }
194
2f0aa4 195   /** 初始化 **/
196   onMounted(async () => {
197     await getList()
198   })
199 </script>