dongyukun
4 天以前 4d3aa775fe40cdf97ff503e0c078c08a8f9e5f1d
提交 | 用户 | 时间
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
4d3aa7 39           type="success"
D 40           plain
41           @click="enable"
42           v-hasPermi="['sche:scheme:update']"
43         >启用
44         </el-button>
45         <el-button
46           type="danger"
47           plain
48           @click="disable"
49           v-hasPermi="['sche:scheme:update']"
50         >禁用
51         </el-button>
52         <el-button
2f0aa4 53           type="primary"
54           plain
55           @click="openForm('create')"
56           v-hasPermi="['sche:scheme:create']"
57         >
58           <Icon icon="ep:plus" class="mr-5px" />
59           新增
60         </el-button>
61       </el-form-item>
62     </el-form>
63   </ContentWrap>
64
65   <!-- 列表 -->
66   <ContentWrap>
4d3aa7 67     <el-table v-loading="loading" :data="list" @selection-change="selectionChangeHandle">
D 68       <el-table-column type="selection" header-align="center" align="center" fixed="left" width="50"/>
6badb7 69       <el-table-column label="方案编号" align="center" prop="code" min-width="100"/>
778f36 70       <el-table-column label="方案名称" header-align="center" align="left" prop="name" min-width="100"/>
6badb7 71       <el-table-column label="触发方式" align="center" prop="triggerMethod" min-width="100">
72         <template #default="scope">
73           <dict-tag :type="DICT_TYPE.SCHE_TRIGGER_METHOD" :value="scope.row.triggerMethod" />
74         </template>
75       </el-table-column>
76       <el-table-column label="触发条件" align="center" prop="triggerCondition" min-width="100"/>
77       <el-table-column label="调整对象" align="center" prop="scheduleObj" min-width="100"/>
78       <el-table-column label="调整类型" align="center" prop="scheduleType" min-width="100"/>
79       <el-table-column label=" 调整策略" align="center" prop="scheduleStrategy" min-width="100"/>
80       <el-table-column label="调度时间" align="center" prop="scheduleTime" min-width="160" />
49a44d 81       <el-table-column label="运行状态" align="center" prop="runStatus">
82         <template #default="scope">
83           <el-tag v-if="scope.row.runStatus + '' === '100'" size="small" type="success">{{scope.row.runStatus}}</el-tag>
84           <el-tag v-else size="small" type="danger">{{scope.row.runStatus}}</el-tag>
85         </template>
86       </el-table-column>
778f36 87       <el-table-column label="备注" header-align="center" align="left" prop="remark" min-width="160" />
49a44d 88       <el-table-column label="是否启用" align="center" prop="status" min-width="100">
6badb7 89         <template #default="scope">
90           <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
91         </template>
92       </el-table-column>
778f36 93       <el-table-column label="操作" align="center" min-width="100" fixed="right">
2f0aa4 94         <template #default="scope">
95           <el-button
96             link
97             type="primary"
98             @click="openForm('update', scope.row.id)"
99             v-hasPermi="['sche:scheme:update']"
100           >
101             编辑
102           </el-button>
103           <el-button
104             link
02bbf2 105             type="primary"
106             @click="openRecordList(scope.row.id)"
107             v-hasPermi="['sche:record:query']"
108           >
109             日志
110           </el-button>
111           <el-button
112             link
2f0aa4 113             type="danger"
114             @click="handleDelete(scope.row.id)"
115             v-hasPermi="['sche:scheme:delete']"
116           >
117             删除
118           </el-button>
119         </template>
120       </el-table-column>
121     </el-table>
122     <!-- 分页 -->
123     <Pagination
124       :total="total"
125       v-model:page="queryParams.pageNo"
126       v-model:limit="queryParams.pageSize"
127       @pagination="getList"
128     />
129   </ContentWrap>
130
131   <!-- 表单弹窗:添加/修改 -->
132   <ScheduleSchemeForm ref="formRef" @success="getList" />
133
02bbf2 134   <!-- 表单弹窗:添加/修改 -->
135   <RecordList ref="recordRef" />
2f0aa4 136 </template>
137 <script lang="ts" setup>
138   import {DICT_TYPE, getIntDictOptions} from '@/utils/dict'
139   import * as ScheduleSchemeApi from '@/api/model/sche/scheme'
140   import ScheduleSchemeForm from './ScheduleSchemeForm.vue'
02bbf2 141   import RecordList from  './record/index.vue'
4d3aa7 142   import * as DaPoint from "@/api/data/da/point";
D 143   import {reactive} from "vue";
144   import {InfraJobStatusEnum} from "@/utils/constants";
2f0aa4 145
146   defineOptions({name: 'ScheduleScheme'})
147
148   const message = useMessage() // 消息弹窗
149   const {t} = useI18n() // 国际化
150
151   const loading = ref(true) // 列表的加载中
152   const total = ref(0) // 列表的总页数
153   const list = ref([]) // 列表的数据
154   const queryParams = reactive({
155     pageNo: 1,
156     pageSize: 10,
157     code: undefined,
158     name: undefined
159   })
160   const queryFormRef = ref() // 搜索的表单
161   const exportLoading = ref(false) // 导出的加载中
162
163   /** 查询列表 */
164   const getList = async () => {
165     loading.value = true
166     try {
167       const page = await ScheduleSchemeApi.getScheduleSchemePage(queryParams)
168       list.value = page.list
169       total.value = page.total
170     } finally {
171       loading.value = false
172     }
173   }
174
175   /** 搜索按钮操作 */
176   const handleQuery = () => {
177     queryParams.pageNo = 1
178     getList()
179   }
180
181   /** 重置按钮操作 */
182   const resetQuery = () => {
183     queryFormRef.value.resetFields()
184     handleQuery()
185   }
186
187   /** 添加/修改操作 */
188   const formRef = ref()
189   const openForm = (type: string, id?: number) => {
190     formRef.value.open(type, id)
191   }
192
193   /** 删除按钮操作 */
194   const handleDelete = async (id: number) => {
195     try {
196       // 删除的二次确认
197       await message.delConfirm()
198       // 发起删除
199       await ScheduleSchemeApi.deleteScheduleScheme(id)
200       message.success(t('common.delSuccess'))
201       // 刷新列表
202       await getList()
203     } catch {
204     }
205   }
206
02bbf2 207   /** 调用日志查看 */
208   const recordRef = ref()
209   const openRecordList = (id?: string) => {
210     recordRef.value.open(id)
211   }
212
4d3aa7 213   let dataListSelections = reactive([])
D 214   // 多选
215   function selectionChangeHandle (val) {
216     dataListSelections = val
217   }
218   // 启用
219   async function enable() {
220     let ids = dataListSelections.map(item => {
221       return item.id
222     })
223     // 二次确认
224     await message.confirm('是否确认要启用所选调度方案?')
225     await ScheduleSchemeApi.enable(ids)
226     message.success(t('common.enableSuccess'))
227     await getList()
228   }
229   // 禁用
230   async function disable(){
231     let ids = dataListSelections.map(item => {
232       return item.id
233     })
234     // 二次确认
235     await message.confirm('确认要禁用所选调度方案?')
236     await ScheduleSchemeApi.disable(ids)
237     message.success(t('common.disableSuccess'))
238     await getList()
239   }
240
2f0aa4 241   /** 初始化 **/
242   onMounted(async () => {
243     await getList()
244   })
245 </script>