Commit a3b35bc44d1cfebbaba9ca7effee207c33376daa

Authored by fengtao
1 parent 3b15c727

fix:修改调度日志

... ... @@ -9,6 +9,7 @@ export type SchedueParam = {
9 9 orderType: string;
10 10 data?: any;
11 11 code?: number;
  12 + jobId?: string;
12 13 };
13 14
14 15 export interface ReportModel {
... ...
... ... @@ -31,7 +31,7 @@ const [register] = useModalInner((data) => {
31 31 const resMap = res.data.executeAttributes.map(d => {
32 32 return {
33 33 device: d.name,
34   - attribute: d.attribute
  34 + attribute: d.attributes.join(',')
35 35 }
36 36 })
37 37 tableData.value = resMap
... ...
1 1 <template>
2   - <BasicDrawer v-bind="$attrs" @register="registerDrawer" showFooter :title="getTitle" width="30%" @ok="handleSubmit">
  2 + <BasicDrawer :maskClosable="false" @close="handleClose" destroyOnClose v-bind="$attrs" @register="registerDrawer"
  3 + showFooter :title="getTitle" width="30%" @ok="handleSubmit">
3 4 <BasicForm @register="registerForm">
4 5 <template #devices>
5 6 <Select placeholder="请选择设备" v-model:value="selectDevice" style="width: 100%" :options="selectOptions"
... ... @@ -12,7 +13,7 @@
12 13 </BasicDrawer>
13 14 </template>
14 15 <script lang="ts" setup>
15   -import { ref, computed, unref, reactive, watch, nextTick, Ref } from 'vue';
  16 +import { ref, computed, unref, reactive, watch, Ref } from 'vue';
16 17 import { BasicForm, useForm } from '/@/components/Form';
17 18 import { formSchema, organizationId } from './config.data';
18 19 import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
... ... @@ -25,6 +26,7 @@ import DeviceAttrCpns from './cpns/DeviceAttrCpns.vue';
25 26 import { SelectTypes } from 'ant-design-vue/es/select';
26 27 import { SchemaFiled } from './config.data';
27 28 import { QueryWay } from '../../device/localtion/cpns/TimePeriodForm/config';
  29 +import { AggregateDataEnum } from '../../device/localtion/cpns/TimePeriodForm/config';
28 30
29 31 type TDeviceList = {
30 32 key?: string,
... ... @@ -45,6 +47,7 @@ const deviceList: Ref<TDeviceList[]> = ref([]);
45 47 const editDeviceList: Ref<TDeviceList[]> = ref([]);
46 48 let editResData: any = reactive({})
47 49 const watchOrgId = ref('')
  50 +const editDeviceAttr: any = ref([])
48 51
49 52 watch(organizationId, async (newValue: string) => {
50 53 if (!newValue) return;
... ... @@ -65,7 +68,7 @@ const handleDeviceChange = (e) => {
65 68 console.log(e)
66 69 deviceList.value = e;
67 70 };
68   -const [registerForm, { validate, setFieldsValue, resetFields }] = useForm({
  71 +const [registerForm, { validate, setFieldsValue, resetFields, updateSchema, getFieldsValue }] = useForm({
69 72 labelWidth: 120,
70 73 schemas: formSchema,
71 74 showActionButtonGroup: false,
... ... @@ -75,13 +78,6 @@ const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (
75 78 await resetFields();
76 79 setDrawerProps({ confirmLoading: false });
77 80 isUpdate.value = !!data?.isUpdate;
78   - editId.value = '';
79   - orgId.value = '';
80   - selectDevice.value = [];
81   - selectOptions.value = [];
82   - deviceList.value = [];
83   - getAttrDevice.value = []
84   - editDeviceList.value = []
85 81 if (unref(isUpdate)) {
86 82 //编辑回显数据
87 83 editResData = await reportEditDetailPage(data.record.id)
... ... @@ -89,13 +85,46 @@ const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (
89 85 editId.value = editResData.data.id;
90 86 await setFieldsValue(editResData.data);
91 87 //回显嵌套数据
92   - setFieldsValue({
  88 + await setFieldsValue({
93 89 agg: editResData.data.queryCondition?.agg,
94 90 interval: editResData.data.queryCondition?.interval,
95   - limit: editResData.data.queryCondition?.limit,
  91 + limit1: editResData.data.queryCondition?.limit,
96 92 orderBy: editResData.data.queryCondition?.orderBy,
97 93 useStrictDataTypes: editResData.data.queryCondition?.useStrictDataTypes
98 94 });
  95 + //回显聚合条件
  96 + const dataCompareOpions = [
  97 + { label: '最小值', value: AggregateDataEnum.MIN },
  98 + { label: '最大值', value: AggregateDataEnum.MAX },
  99 + { label: '平均值', value: AggregateDataEnum.AVG },
  100 + { label: '求和', value: AggregateDataEnum.SUM },
  101 + { label: '空', value: AggregateDataEnum.NONE }
  102 + ]
  103 + const updateSchemaAgg = (options: {}) => {
  104 + updateSchema({
  105 + field: SchemaFiled.AGG,
  106 + componentProps: {
  107 + options,
  108 + },
  109 + });
  110 + }
  111 + if (editResData.data.dataType == 1) updateSchemaAgg(dataCompareOpions.slice(0, 4))
  112 + else updateSchemaAgg(dataCompareOpions.slice(4, 5))
  113 + //回显执行方式和查询周期
  114 + const dataQueryOpions = [
  115 + { label: '固定周期', value: QueryWay.LATEST },
  116 + { label: '自定义周期', value: QueryWay.TIME_PERIOD },
  117 + ];
  118 + const updateSchemaQuery = (options: {}) => {
  119 + updateSchema({
  120 + field: SchemaFiled.WAY,
  121 + componentProps: {
  122 + options,
  123 + },
  124 + });
  125 + }
  126 + if (editResData.data.executeWay == 0) updateSchemaQuery(dataQueryOpions)
  127 + else updateSchemaQuery(dataQueryOpions.slice(0, 1))
99 128 //回显设备
100 129 orgId.value = editResData.data.organizationId;
101 130 const { items } = await screenLinkPageByDeptIdGetDevice({
... ... @@ -116,18 +145,49 @@ const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (
116 145 })
117 146 selectDevice.value = deviceIds;
118 147 //回显设备属性
119   - const editDeviceAttr = editResData.data.executeAttributes?.map(item => {
  148 + editDeviceAttr.value = editResData.data.executeAttributes?.map(item => {
120 149 return {
121 150 label: item.name,
122 151 value: item.device,
123   - attribute: item.attribute,
  152 + attributes: item.attributes,
124 153 }
125 154 })
126   - deviceList.value = editDeviceAttr
  155 + deviceList.value = editDeviceAttr.value
127 156 editDeviceList.value = editResData.data.executeAttributes
128   - nextTick(() => { });
  157 + } else {
  158 + editId.value = '';
  159 + orgId.value = '';
  160 + selectDevice.value = [];
  161 + selectOptions.value = [];
  162 + deviceList.value = [];
  163 + getAttrDevice.value = []
  164 + editDeviceList.value = []
  165 + editDeviceAttr.value = []
  166 + updateSchema({
  167 + field: SchemaFiled.AGG,
  168 + componentProps: {
  169 + options: [],
  170 + },
  171 + });
  172 + //新增显示执行方式和查询周期
  173 + const dataQueryOpions = [
  174 + { label: '固定周期', value: QueryWay.LATEST },
  175 + { label: '自定义周期', value: QueryWay.TIME_PERIOD },
  176 + ];
  177 + const updateSchemaQuery = (options: {}) => {
  178 + updateSchema({
  179 + field: SchemaFiled.WAY,
  180 + componentProps: {
  181 + options,
  182 + },
  183 + });
  184 + }
  185 + if (getFieldsValue().executeWay == 0) updateSchemaQuery(dataQueryOpions)
129 186 }
130 187 });
  188 +const handleClose = () => {
  189 + deviceList.value = [];
  190 +}
131 191 const getAttrDevice: Ref<TDeviceList[]> = ref([]);
132 192 const getTitle = computed(() => (!unref(isUpdate) ? '新增报表配置' : '编辑报表配置'));
133 193 const handleChange = (e: any) => {
... ... @@ -157,7 +217,7 @@ async function handleSubmit() {
157 217 queryCondition = {
158 218 agg: values.agg,
159 219 interval: values.interval,
160   - limit: values.limit,
  220 + limit: values.limit1,
161 221 };
162 222 if (values.way === QueryWay.LATEST) {
163 223 startTs.value = moment().subtract(values.startTs, 'ms').valueOf()
... ... @@ -174,6 +234,7 @@ async function handleSubmit() {
174 234 delete values.cronTime;
175 235 delete values.cronWeek;
176 236 delete values.cronYear;
  237 + delete values.limit1;
177 238 postObj = {
178 239 ...values,
179 240 ...{ executeAttributes: getAttrDevice.value.length == 0 ? editDeviceList.value : getAttrDevice.value },
... ...
... ... @@ -5,7 +5,7 @@ import moment from 'moment';
5 5 import { getOrganizationList } from '/@/api/system/system';
6 6 import { copyTransFun } from '/@/utils/fnUtils';
7 7 import { findDictItemByCode } from '/@/api/system/dict';
8   -import { isTiming, isWeek, isMonth } from './timeConfig';
  8 +import { isTiming, isWeek, isMonth, isFixedTime } from './timeConfig';
9 9 import { AggregateDataEnum } from '../../device/localtion/cpns/TimePeriodForm/config';
10 10 import { Moment } from 'moment';
11 11 import {
... ... @@ -13,6 +13,8 @@ import {
13 13 getPacketIntervalByValue,
14 14 intervalOption,
15 15 } from '../../device/localtion/cpns/TimePeriodForm/helper';
  16 +import { USER_INFO_KEY } from '/@/enums/cacheEnum';
  17 +import { getAuthCache } from '/@/utils/auth';
16 18
17 19 export enum QueryWay {
18 20 LATEST = 'latest',
... ... @@ -45,10 +47,10 @@ export const columns: BasicColumn[] = [
45 47 },
46 48 {
47 49 title: '数据类型',
48   - dataIndex: 'dataCompare',
  50 + dataIndex: 'dataType',
49 51 width: 120,
50 52 format: (_text: string, record: Recordable) => {
51   - return record.dataCompare === 0 ? '历史数据' : record.dataCompare === 1 ? '同比' : '环比';
  53 + return record.dataType === 0 ? '历史数据' : record.dataType === 1 ? '同比' : '环比';
52 54 },
53 55 },
54 56 {
... ... @@ -75,6 +77,10 @@ export const columns: BasicColumn[] = [
75 77 title: '创建人',
76 78 dataIndex: 'creator',
77 79 width: 180,
  80 + format: (_text: string, record: Recordable) => {
  81 + const userInfo: any = getAuthCache(USER_INFO_KEY);
  82 + if (record.creator == userInfo.userId) return userInfo.realName || userInfo.username;
  83 + },
78 84 },
79 85 {
80 86 title: '创建日期',
... ... @@ -191,9 +197,9 @@ export const formSchema: QFormSchema[] = [
191 197 span: 24,
192 198 },
193 199 defaultValue: 0,
194   - componentProps: {
195   - placeholder: '请选择执行方式',
196   - options: [
  200 + componentProps: ({ formActionType }) => {
  201 + const { updateSchema, setFieldsValue } = formActionType;
  202 + const options = [
197 203 {
198 204 label: '立即执行',
199 205 value: 0,
... ... @@ -202,7 +208,38 @@ export const formSchema: QFormSchema[] = [
202 208 label: '定时执行',
203 209 value: 1,
204 210 },
205   - ],
  211 + ];
  212 + return {
  213 + options,
  214 + placeholder: '请选择执行方式',
  215 + onChange(e) {
  216 + let dataCompareOpions: any = [];
  217 + if (e.target.value == 0) {
  218 + setFieldsValue({ way: QueryWay.LATEST });
  219 + dataCompareOpions = [
  220 + { label: '固定周期', value: QueryWay.LATEST },
  221 + { label: '自定义周期', value: QueryWay.TIME_PERIOD },
  222 + ];
  223 + updateSchema({
  224 + field: SchemaFiled.WAY,
  225 + componentProps: {
  226 + options: dataCompareOpions,
  227 + },
  228 + });
  229 + } else {
  230 + setFieldsValue({ way: QueryWay.LATEST });
  231 + dataCompareOpions = [{ label: '固定周期', value: QueryWay.LATEST }];
  232 + updateSchema({
  233 + defaultValue: QueryWay.LATEST,
  234 + field: SchemaFiled.WAY,
  235 + componentProps: {
  236 + options: dataCompareOpions,
  237 + },
  238 + });
  239 + }
  240 + },
  241 + maxLength: 250,
  242 + };
206 243 },
207 244 },
208 245 {
... ... @@ -276,63 +313,6 @@ export const formSchema: QFormSchema[] = [
276 313 },
277 314 ifShow: ({ values }) => isTiming(values.executeWay),
278 315 },
279   -
280   - {
281   - field: 'attributeNature',
282   - component: 'RadioGroup',
283   - label: '属性性质',
284   - required: true,
285   - colProps: {
286   - span: 24,
287   - },
288   - defaultValue: 0,
289   - componentProps: ({ formActionType }) => {
290   - const { updateSchema, setFieldsValue } = formActionType;
291   - const options = [
292   - {
293   - label: '共有',
294   - value: 0,
295   - },
296   - {
297   - label: '全部',
298   - value: 1,
299   - },
300   - ];
301   - return {
302   - options,
303   - async onChange(e) {
304   - if (e) {
305   - let dataCompareOpions: any = [];
306   - if (e.target.value == 1) {
307   - setFieldsValue({ dataCompare: '' });
308   - dataCompareOpions = [{ label: '历史数据', value: 0 }];
309   - updateSchema({
310   - field: 'dataCompare',
311   - componentProps: {
312   - options: dataCompareOpions,
313   - },
314   - });
315   - } else {
316   - setFieldsValue({ dataCompare: '' });
317   - dataCompareOpions = [
318   - { label: '历史数据', value: 0 },
319   - { label: '同比', value: 1 },
320   - { label: '环比', value: 2 },
321   - ];
322   - updateSchema({
323   - field: 'dataCompare',
324   - componentProps: {
325   - options: dataCompareOpions,
326   - },
327   - });
328   - }
329   - }
330   - },
331   - maxLength: 250,
332   - placeholder: '请选择属性性质',
333   - };
334   - },
335   - },
336 316 {
337 317 field: 'devices',
338 318 label: '设备',
... ... @@ -347,17 +327,49 @@ export const formSchema: QFormSchema[] = [
347 327 colProps: { span: 24 },
348 328 },
349 329 {
350   - field: 'dataCompare',
  330 + field: 'dataType',
351 331 label: '数据类型',
352 332 required: true,
353 333 component: 'Select',
354   - componentProps: {
355   - placeholder: '请选择数据类型',
356   - options: [
357   - { label: '历史数据', value: 0 },
358   - { label: '同比', value: 1 },
359   - { label: '环比', value: 2 },
360   - ],
  334 + componentProps: ({ formActionType }) => {
  335 + const { updateSchema, setFieldsValue } = formActionType;
  336 + const options = [
  337 + { label: '原始数据', value: 0 },
  338 + { label: '聚合数据', value: 1 },
  339 + ];
  340 + return {
  341 + options,
  342 + onSelect(e) {
  343 + let dataCompareOpions: any = [];
  344 + if (e == 0) {
  345 + setFieldsValue({ agg: 'NONE' });
  346 + dataCompareOpions = [{ label: '空', value: AggregateDataEnum.NONE }];
  347 + updateSchema({
  348 + field: SchemaFiled.AGG,
  349 + componentProps: {
  350 + options: dataCompareOpions,
  351 + },
  352 + });
  353 + } else {
  354 + setFieldsValue({ agg: '' });
  355 + dataCompareOpions = [
  356 + { label: '最小值', value: AggregateDataEnum.MIN },
  357 + { label: '最大值', value: AggregateDataEnum.MAX },
  358 + { label: '平均值', value: AggregateDataEnum.AVG },
  359 + { label: '求和', value: AggregateDataEnum.SUM },
  360 + { label: '计数', value: AggregateDataEnum.COUNT },
  361 + ];
  362 + updateSchema({
  363 + field: SchemaFiled.AGG,
  364 + componentProps: {
  365 + options: dataCompareOpions,
  366 + },
  367 + });
  368 + }
  369 + },
  370 + maxLength: 250,
  371 + placeholder: '请选择属性性质',
  372 + };
361 373 },
362 374 colProps: { span: 24 },
363 375 },
... ... @@ -369,30 +381,22 @@ export const formSchema: QFormSchema[] = [
369 381 componentProps: {
370 382 placeholder: '请选择聚合条件',
371 383 getPopupContainer: () => document.body,
372   - options: [
373   - { label: '最小值', value: AggregateDataEnum.MIN },
374   - { label: '最大值', value: AggregateDataEnum.MAX },
375   - { label: '平均值', value: AggregateDataEnum.AVG },
376   - { label: '求和', value: AggregateDataEnum.SUM },
377   - { label: '计数', value: AggregateDataEnum.COUNT },
378   - { label: '空', value: AggregateDataEnum.NONE },
379   - ],
380 384 },
381 385 },
382 386 {
383   - field: SchemaFiled.LIMIT,
  387 + field: 'limit1',
  388 + required: true,
384 389 label: '最大值',
385 390 component: 'InputNumber',
386   - required: true,
  391 + defaultValue: 200,
387 392 ifShow({ values }) {
388 393 return values[SchemaFiled.AGG] === AggregateDataEnum.NONE;
389 394 },
390   - defaultValue: 200,
391   - componentProps() {
392   - return {
393   - max: 50000,
394   - min: 7,
395   - };
  395 + colProps: { span: 12 },
  396 + componentProps: {
  397 + placeholder: '请输入最大值',
  398 + min: 7,
  399 + max: 50000,
396 400 },
397 401 },
398 402 {
... ... @@ -404,7 +408,7 @@ export const formSchema: QFormSchema[] = [
404 408 componentProps({ formActionType }) {
405 409 const { setFieldsValue } = formActionType;
406 410 return {
407   - getPopupContainer: () => document.body,
  411 + getPopupContainer: () => document.body,
408 412 placeholder: '请选择查询周期',
409 413 options: [
410 414 { label: '固定周期', value: QueryWay.LATEST },
... ... @@ -428,13 +432,13 @@ export const formSchema: QFormSchema[] = [
428 432 component: 'RangePicker',
429 433 required: true,
430 434 ifShow({ values }) {
431   - return values[SchemaFiled.WAY] === QueryWay.TIME_PERIOD;
  435 + return values[SchemaFiled.WAY] === QueryWay.TIME_PERIOD && !isFixedTime(values.executeWay);
432 436 },
433 437 componentProps({ formActionType }) {
434 438 const { setFieldsValue } = formActionType;
435 439 let dates: Moment[] = [];
436 440 return {
437   - placeholder: ['请选择开始时间','请选择结束时间'],
  441 + placeholder: ['请选择开始时间', '请选择结束时间'],
438 442 showTime: true,
439 443 onCalendarChange(value: Moment[]) {
440 444 dates = value;
... ... @@ -460,17 +464,14 @@ export const formSchema: QFormSchema[] = [
460 464 field: SchemaFiled.START_TS,
461 465 label: '时间周期',
462 466 component: 'Select',
463   - // defaultValue: 1000,
464 467 required: true,
465 468 ifShow({ values }) {
466   - return (
467   - values[SchemaFiled.AGG] !== AggregateDataEnum.NONE &&
468   - values[SchemaFiled.WAY] == QueryWay.LATEST
469   - );
  469 + return values[SchemaFiled.WAY] == QueryWay.LATEST;
470 470 },
471 471 componentProps({ formActionType }) {
472 472 const { setFieldsValue } = formActionType;
473 473 return {
  474 + defaultValue: 1000,
474 475 placeholder: '请选择时间周期',
475 476 options: intervalOption,
476 477 onChange() {
... ... @@ -484,12 +485,8 @@ export const formSchema: QFormSchema[] = [
484 485 label: '间隔时间',
485 486 component: 'Select',
486 487 required: true,
487   - // defaultValue: 1000,
488 488 ifShow({ values }) {
489   - return (
490   - values[SchemaFiled.AGG] !== AggregateDataEnum.NONE &&
491   - values[SchemaFiled.WAY] == QueryWay.LATEST
492   - );
  489 + return values[SchemaFiled.WAY] == QueryWay.LATEST;
493 490 },
494 491 componentProps({ formModel, formActionType }) {
495 492 const options =
... ... @@ -500,6 +497,7 @@ export const formSchema: QFormSchema[] = [
500 497 formActionType.setFieldsValue({ [SchemaFiled.LIMIT]: null });
501 498 }
502 499 return {
  500 + // defaultValue: 1000,
503 501 placeholder: '请选择间隔时间',
504 502 options,
505 503 };
... ...
... ... @@ -2,8 +2,8 @@
2 2 <div v-for="param in dynamicInput.params" :key="param.key" style="display: flex; margin-top: 0.25vh">
3 3 <a-input :disabled="true" v-model:value="param.device" style="width: 38%; margin-bottom: 5px; margin-left: 1vh"
4 4 @change="emitChange" />
5   - <Select placeholder="请选择设备属性" v-model:value="param.attribute" style="width: 160px; margin-left: 1.8vw"
6   - :options="selectOptions" @change="emitChange" allowClear />
  5 + <Select placeholder="请选择设备属性" v-model:value="param.attributes" style="width: 160px; margin-left: 1.8vw"
  6 + :options="selectOptions" @change="emitChange" allowClear mode="multiple" />
7 7 </div>
8 8 </template>
9 9 <script lang="ts">
... ... @@ -20,7 +20,7 @@ import { getAttribute } from '/@/api/ruleengine/ruleengineApi';
20 20
21 21 interface Params {
22 22 [x: string]: string;
23   - attribute: string;
  23 + attributes: any;
24 24 device: string;
25 25 }
26 26 const props = defineProps({
... ... @@ -49,13 +49,14 @@ watchEffect(() => {
49 49 * 初始化数值
50 50 */
51 51 async function initVal() {
  52 + dynamicInput.params = []
52 53 if (props.value && props.orgId) {
53 54 let jsonObj = props.value;
54 55 const deviceId = jsonObj.map((m: any) => m.value);
55 56 await getAttr(props.orgId, deviceId);
56 57 dynamicInput.params = jsonObj.map((item: any) => {
57 58 return {
58   - attribute: item.attribute,
  59 + attributes: item.attributes,
59 60 device: item.label,
60 61 value: item.value,
61 62 }
... ... @@ -70,7 +71,7 @@ function emitChange() {
70 71 if (dynamicInput.params.length > 0) {
71 72 dynamicInput.params.forEach((item: Params) => {
72 73 obj.push({
73   - attribute: item.attribute,
  74 + attributes: item.attributes,
74 75 device: item.value,
75 76 name: item.device
76 77 });
... ...
... ... @@ -86,6 +86,7 @@ export enum TypeEnum {
86 86 IS_AVG = 'AVG',
87 87 IS_SUM = 'SUM',
88 88 COUNT = 'COUNT',
  89 + IS_FIXED_TIME = 1,
89 90 }
90 91
91 92 export enum AggregateDataEnum {
... ... @@ -96,6 +97,9 @@ export enum AggregateDataEnum {
96 97 COUNT = 'COUNT',
97 98 NONE = 'NONE',
98 99 }
  100 +export const isFixedTime = (type: string) => {
  101 + return type === TypeEnum.IS_FIXED_TIME;
  102 +};
99 103
100 104 export const isTiming = (type: string) => {
101 105 return type === TypeEnum.IS_TIMING;
... ...
1 1 <template>
2 2 <div>
3   - <BasicModal
4   - v-bind="$attrs"
5   - width="110rem"
6   - :height="heightNum"
7   - @register="register"
8   - title="调度日志"
9   - @cancel="handleCancel"
10   - :showOkBtn="false"
11   - destroyOnClose
12   - >
  3 + <BasicModal v-bind="$attrs" width="110rem" :height="heightNum" @register="register" title="调度日志"
  4 + @cancel="handleCancel" :showOkBtn="false" destroyOnClose>
13 5 <div>
14 6 <BasicTable @register="registerTable">
15 7 <template #toolbar>
16   - <Popconfirm
17   - title="您确定要清空全部数据"
18   - ok-text="确定"
19   - cancel-text="取消"
20   - @confirm="handleClear"
21   - >
  8 + <Popconfirm title="您确定要清空全部数据" ok-text="确定" cancel-text="取消" @confirm="handleClear">
22 9 <a-button type="primary"> 清空 </a-button>
23 10 </Popconfirm>
24 11 <Popconfirm title="您确定要批量删除数据" ok-text="确定" cancel-text="取消">
... ... @@ -28,24 +15,22 @@
28 15 </Popconfirm>
29 16 </template>
30 17 <template #action="{ record }">
31   - <TableAction
32   - :actions="[
33   - {
34   - label: '查看',
35   - icon: 'clarity:note-edit-line',
36   - onClick: handleView.bind(null, record),
  18 + <TableAction :actions="[
  19 + {
  20 + label: '查看',
  21 + icon: 'clarity:note-edit-line',
  22 + onClick: handleView.bind(null, record),
  23 + },
  24 + {
  25 + label: '删除',
  26 + icon: 'ant-design:delete-outlined',
  27 + color: 'error',
  28 + popConfirm: {
  29 + title: '是否确认删除',
  30 + confirm: handleDeleteOrBatchDelete.bind(null, record),
37 31 },
38   - {
39   - label: '删除',
40   - icon: 'ant-design:delete-outlined',
41   - color: 'error',
42   - popConfirm: {
43   - title: '是否确认删除',
44   - confirm: handleDeleteOrBatchDelete.bind(null, record),
45   - },
46   - },
47   - ]"
48   - />
  32 + },
  33 + ]" />
49 34 </template>
50 35 </BasicTable>
51 36 <ScheduleLogViewModal @register="registerModalScheduleLogView" />
... ... @@ -54,80 +39,85 @@
54 39 </div>
55 40 </template>
56 41 <script setup lang="ts">
57   - import { ref, nextTick } from 'vue';
58   - import { BasicModal, useModalInner } from '/@/components/Modal';
59   - import { BasicTable, useTable, TableAction } from '/@/components/Table';
60   - import { columnSchedue, searchSchedueFormSchema } from './config.data';
61   - import { useBatchDelete } from '/@/hooks/web/useBatchDelete';
62   - import {
63   - deleteSchedueLogManage,
64   - schedueLogPage,
65   - schedueLogCleanPage,
66   - } from '/@/api/schedue/schedueManager';
67   - import { Popconfirm } from 'ant-design-vue';
68   - import { useMessage } from '/@/hooks/web/useMessage';
69   - import ScheduleLogViewModal from './ScheduleLogViewModal.vue';
70   - import { useModal } from '/@/components/Modal';
  42 +import { ref, nextTick } from 'vue';
  43 +import { BasicModal, useModalInner } from '/@/components/Modal';
  44 +import { BasicTable, useTable, TableAction } from '/@/components/Table';
  45 +import { columnSchedue, searchSchedueFormSchema } from './config.data';
  46 +import { useBatchDelete } from '/@/hooks/web/useBatchDelete';
  47 +import {
  48 + deleteSchedueLogManage,
  49 + schedueLogPage,
  50 + schedueLogCleanPage,
  51 +} from '/@/api/schedue/schedueManager';
  52 +import { Popconfirm } from 'ant-design-vue';
  53 +import { useMessage } from '/@/hooks/web/useMessage';
  54 +import ScheduleLogViewModal from './ScheduleLogViewModal.vue';
  55 +import { useModal } from '/@/components/Modal';
71 56
72   - const { createMessage } = useMessage();
73   - const heightNum = ref(800);
74   - const [registerTable, { setProps, reload, getForm }] = useTable({
75   - title: '调度日志列表',
76   - api: schedueLogPage,
77   - columns: columnSchedue,
78   - showIndexColumn: false,
79   - clickToRowSelect: false,
80   - useSearchForm: true,
81   - ellipsis: true,
82   - showTableSetting: true,
83   - bordered: true,
84   - formConfig: {
85   - labelWidth: 120,
86   - schemas: searchSchedueFormSchema,
87   - fieldMapToTime: [['sendTime', ['startTime', 'endTime'], 'YYYY-MM-DD HH:mm:ss']],
88   - },
89   - rowKey: 'id',
90   - actionColumn: {
91   - width: 200,
92   - title: '操作',
93   - dataIndex: 'action',
94   - slots: { customRender: 'action' },
95   - fixed: 'right',
96   - },
97   - });
98   - // 刷新
99   - const handleSuccess = () => {
100   - reload();
101   - };
102   - const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions } = useBatchDelete(
103   - deleteSchedueLogManage,
104   - handleSuccess,
105   - setProps
106   - );
  57 +const { createMessage } = useMessage();
  58 +const heightNum = ref(800);
  59 +const [registerTable, { setProps, reload, getForm, setTableData }] = useTable({
  60 + title: '调度日志列表',
  61 + // api: schedueLogPage,
  62 + columns: columnSchedue,
  63 + showIndexColumn: false,
  64 + clickToRowSelect: false,
  65 + useSearchForm: true,
  66 + ellipsis: true,
  67 + showTableSetting: true,
  68 + bordered: true,
  69 + formConfig: {
  70 + labelWidth: 120,
  71 + schemas: searchSchedueFormSchema,
  72 + fieldMapToTime: [['sendTime', ['startTime', 'endTime'], 'YYYY-MM-DD HH:mm:ss']],
  73 + },
  74 + rowKey: 'id',
  75 + actionColumn: {
  76 + width: 200,
  77 + title: '操作',
  78 + dataIndex: 'action',
  79 + slots: { customRender: 'action' },
  80 + fixed: 'right',
  81 + },
  82 +});
  83 +// 刷新
  84 +const handleSuccess = () => {
  85 + reload();
  86 +};
  87 +const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions } = useBatchDelete(
  88 + deleteSchedueLogManage,
  89 + handleSuccess,
  90 + setProps
  91 +);
107 92
108   - const [register] = useModalInner(() => {
109   - nextTick(() => {
110   - setProps(selectionOptions);
111   - setProps({
112   - rowKey: 'id',
113   - });
114   - //重置清空搜索表单
115   - const { resetFields } = getForm();
116   - resetFields();
  93 +const [register] = useModalInner(async (data) => {
  94 + console.log(data.record)
  95 + const res: any = await schedueLogPage({ jobId: data.record.id, page: 1, pageSize: 10 })
  96 + nextTick(() => {
  97 + console.log(res)
  98 + setTableData(res.items)
  99 + setProps(selectionOptions);
  100 + setProps({
  101 + rowKey: 'id',
117 102 });
  103 + //重置清空搜索表单
  104 + const { resetFields } = getForm();
  105 + resetFields();
118 106 });
119   - const handleCancel = () => {};
120   - const handleClear = async () => {
121   - await schedueLogCleanPage();
122   - createMessage.success(`清空成功`);
123   - handleSuccess();
124   - };
125   - const [registerModalScheduleLogView, { openModal: openModalLogView }] = useModal();
126   - const handleView = (record: Recordable) => {
127   - openModalLogView(true, {
128   - isUpdate: true,
129   - record,
130   - });
131   - };
  107 +});
  108 +const handleCancel = () => { };
  109 +const handleClear = async () => {
  110 + await schedueLogCleanPage();
  111 + createMessage.success(`清空成功`);
  112 + handleSuccess();
  113 +};
  114 +const [registerModalScheduleLogView, { openModal: openModalLogView }] = useModal();
  115 +const handleView = (record: Recordable) => {
  116 + openModalLogView(true, {
  117 + isUpdate: true,
  118 + record,
  119 + });
  120 +};
132 121 </script>
133   -<style lang="less" scoped></style>
  122 +<style lang="less" scoped>
  123 +</style>
... ...
... ... @@ -9,62 +9,53 @@
9 9 <a-button type="primary"> 导出 </a-button>
10 10 </Authority>
11 11 <Authority value="api:yt:schedule:delete">
12   - <Popconfirm title="您确定要批量删除数据" ok-text="确定" cancel-text="取消">
  12 + <Popconfirm title="您确定要批量删除数据" ok-text="确定" cancel-text="取消" @confirm="handleDeleteOrBatchDelete(null)">
13 13 <a-button type="primary" color="error" :disabled="hasBatchDelete"> 批量删除 </a-button>
14 14 </Popconfirm>
15 15 </Authority>
16 16 </template>
17 17 <template #action="{ record }">
18   - <TableAction
19   - :actions="[
20   - {
21   - label: '编辑',
22   - icon: 'clarity:note-edit-line',
23   - auth: 'api:yt:schedule:update',
24   - onClick: handleCreateOrEdit.bind(null, record),
  18 + <TableAction :actions="[
  19 + {
  20 + label: '编辑',
  21 + icon: 'clarity:note-edit-line',
  22 + auth: 'api:yt:schedule:update',
  23 + onClick: handleCreateOrEdit.bind(null, record),
  24 + },
  25 + {
  26 + label: '删除',
  27 + icon: 'ant-design:delete-outlined',
  28 + color: 'error',
  29 + auth: 'api:yt:schedule:delete',
  30 + popConfirm: {
  31 + title: '是否确认删除',
  32 + confirm: handleDeleteOrBatchDelete.bind(null, record),
25 33 },
26   - {
27   - label: '删除',
28   - icon: 'ant-design:delete-outlined',
29   - color: 'error',
30   - auth: 'api:yt:schedule:delete',
31   - popConfirm: {
32   - title: '是否确认删除',
33   - confirm: handleDeleteOrBatchDelete.bind(null, record),
34   - },
35   - },
36   - ]"
37   - :dropDownActions="[
38   - {
39   - label: '执行一次',
40   - icon: 'ant-design:caret-right-filled',
41   - popConfirm: {
42   - title: '确认要立即执行一次' + '“' + record.jobName + '”' + '任务吗?',
43   - confirm: handleRunOne.bind(null, record),
44   - },
45   - },
46   - {
47   - label: '任务详细',
48   - icon: 'ant-design:eye-outlined',
49   - onClick: handleTaskDetailModal.bind(null, record),
50   - },
51   - {
52   - label: '调度日志',
53   - icon: 'ant-design:insert-row-below-outlined',
54   - onClick: handleSchedulingLogFunc.bind(null, record),
55   - },
56   - ]"
57   - />
  34 + },
  35 + ]" :dropDownActions="[
  36 + {
  37 + label: '执行一次',
  38 + icon: 'ant-design:caret-right-filled',
  39 + popConfirm: {
  40 + title: '确认要立即执行一次' + '“' + record.jobName + '”' + '任务吗?',
  41 + confirm: handleRunOne.bind(null, record),
  42 + },
  43 + },
  44 + {
  45 + label: '任务详细',
  46 + icon: 'ant-design:eye-outlined',
  47 + onClick: handleTaskDetailModal.bind(null, record),
  48 + },
  49 + {
  50 + label: '调度日志',
  51 + icon: 'ant-design:insert-row-below-outlined',
  52 + onClick: handleSchedulingLogFunc.bind(null, record),
  53 + },
  54 +]" />
58 55 </template>
59 56 <template #status="{ record }">
60   - <Switch
61   - :disabled="disabledSwitch"
62   - :checked="record.status === 1"
63   - :loading="record.pendingStatus"
64   - checkedChildren="启用"
65   - unCheckedChildren="禁用"
66   - @change="(checked:boolean)=>statusChange(checked,record)"
67   - />
  57 + <Switch :disabled="disabledSwitch" :checked="record.status === 1" :loading="record.pendingStatus"
  58 + checkedChildren="启用" unCheckedChildren="禁用" @change="(checked: boolean) => statusChange(checked, record)" />
68 59 </template>
69 60 </BasicTable>
70 61 <ScheduledDrawer @register="registerDrawer" @success="handleSuccess" />
... ... @@ -73,120 +64,121 @@
73 64 </div>
74 65 </template>
75 66 <script setup lang="ts">
76   - import { nextTick, ref } from 'vue';
77   - import { BasicTable, useTable, TableAction } from '/@/components/Table';
78   - import { columnSchedue, searchSchedueFormSchema } from './config.form.data';
79   - import { useBatchDelete } from '/@/hooks/web/useBatchDelete';
80   - import {
81   - deleteSchedueManage,
82   - scheduePage,
83   - putSchedueByidAndStatusManage,
84   - postRunSchedueConfigManage,
85   - } from '/@/api/schedue/schedueManager';
86   - import { Popconfirm, Switch } from 'ant-design-vue';
87   - import { useModal } from '/@/components/Modal';
88   - import TaskDetailPreviewModal from './TaskDetailPreviewModal.vue';
89   - import SchedueLog from './SchedueLog.vue';
90   - import ScheduledDrawer from './ScheduledDrawer.vue';
91   - import { useDrawer } from '/@/components/Drawer';
92   - import { Authority } from '/@/components/Authority';
93   - import { useMessage } from '/@/hooks/web/useMessage';
  67 +import { nextTick, ref } from 'vue';
  68 +import { BasicTable, useTable, TableAction } from '/@/components/Table';
  69 +import { columnSchedue, searchSchedueFormSchema } from './config.form.data';
  70 +import { useBatchDelete } from '/@/hooks/web/useBatchDelete';
  71 +import {
  72 + deleteSchedueManage,
  73 + scheduePage,
  74 + putSchedueByidAndStatusManage,
  75 + postRunSchedueConfigManage,
  76 +} from '/@/api/schedue/schedueManager';
  77 +import { Popconfirm, Switch } from 'ant-design-vue';
  78 +import { useModal } from '/@/components/Modal';
  79 +import TaskDetailPreviewModal from './TaskDetailPreviewModal.vue';
  80 +import SchedueLog from './SchedueLog.vue';
  81 +import ScheduledDrawer from './ScheduledDrawer.vue';
  82 +import { useDrawer } from '/@/components/Drawer';
  83 +import { Authority } from '/@/components/Authority';
  84 +import { useMessage } from '/@/hooks/web/useMessage';
94 85
95   - const disabledSwitch = ref(false);
96   - const { createMessage } = useMessage();
97   - const [registerTable, { setProps, reload }] = useTable({
98   - title: '定时任务列表',
99   - api: scheduePage,
100   - columns: columnSchedue,
101   - showIndexColumn: false,
102   - clickToRowSelect: false,
103   - useSearchForm: true,
104   - ellipsis: true,
105   - showTableSetting: true,
106   - bordered: true,
107   - formConfig: {
108   - labelWidth: 120,
109   - schemas: searchSchedueFormSchema,
110   - fieldMapToTime: [['sendTime', ['startTime', 'endTime'], 'YYYY-MM-DD HH:mm:ss']],
111   - },
112   - actionColumn: {
113   - width: 200,
114   - title: '操作',
115   - dataIndex: 'action',
116   - slots: { customRender: 'action' },
117   - fixed: 'right',
118   - },
119   - });
120   - // 刷新
121   - const handleSuccess = () => {
122   - reload();
123   - };
124   - const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions } = useBatchDelete(
125   - deleteSchedueManage,
126   - handleSuccess,
127   - setProps
128   - );
  86 +const disabledSwitch = ref(false);
  87 +const { createMessage } = useMessage();
  88 +const [registerTable, { setProps, reload }] = useTable({
  89 + title: '定时任务列表',
  90 + api: scheduePage,
  91 + columns: columnSchedue,
  92 + showIndexColumn: false,
  93 + clickToRowSelect: false,
  94 + useSearchForm: true,
  95 + ellipsis: true,
  96 + showTableSetting: true,
  97 + bordered: true,
  98 + formConfig: {
  99 + labelWidth: 120,
  100 + schemas: searchSchedueFormSchema,
  101 + fieldMapToTime: [['sendTime', ['startTime', 'endTime'], 'YYYY-MM-DD HH:mm:ss']],
  102 + },
  103 + actionColumn: {
  104 + width: 200,
  105 + title: '操作',
  106 + dataIndex: 'action',
  107 + slots: { customRender: 'action' },
  108 + fixed: 'right',
  109 + },
  110 +});
  111 +// 刷新
  112 +const handleSuccess = () => {
  113 + reload();
  114 +};
  115 +const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions } = useBatchDelete(
  116 + deleteSchedueManage,
  117 + handleSuccess,
  118 + setProps
  119 +);
129 120
130   - nextTick(() => {
131   - setProps(selectionOptions);
  121 +nextTick(() => {
  122 + setProps(selectionOptions);
  123 +});
  124 +const [registerDrawer, { openDrawer }] = useDrawer();
  125 +const [registerModalTaskDetail, { openModal: openModalTaskDetail }] = useModal();
  126 +const [registerModalSchedueLog, { openModal: openModalSchedueLog }] = useModal();
  127 +const handleSchedulingLogFunc = (record: Recordable) => {
  128 + openModalSchedueLog(true, {
  129 + isUpdate: 2,
  130 + record,
132 131 });
133   - const [registerDrawer, { openDrawer }] = useDrawer();
134   - const [registerModalTaskDetail, { openModal: openModalTaskDetail }] = useModal();
135   - const [registerModalSchedueLog, { openModal: openModalSchedueLog }] = useModal();
136   - const handleSchedulingLogFunc = (record: Recordable) => {
137   - openModalSchedueLog(true, {
138   - isUpdate: 2,
139   - record,
140   - });
141   - };
142   - const handleTaskDetailModal = (record: Recordable) => {
143   - openModalTaskDetail(true, {
  132 +};
  133 +const handleTaskDetailModal = (record: Recordable) => {
  134 + openModalTaskDetail(true, {
  135 + isUpdate: true,
  136 + record,
  137 + });
  138 +};
  139 +// 新增或编辑
  140 +const handleCreateOrEdit = (record: Recordable | null) => {
  141 + if (record) {
  142 + openDrawer(true, {
144 143 isUpdate: true,
145 144 record,
146 145 });
147   - };
148   - // 新增或编辑
149   - const handleCreateOrEdit = (record: Recordable | null) => {
150   - if (record) {
151   - openDrawer(true, {
152   - isUpdate: true,
153   - record,
154   - });
  146 + } else {
  147 + openDrawer(true, {
  148 + isUpdate: false,
  149 + });
  150 + }
  151 +};
  152 +
  153 +const statusChange = async (checked, record) => {
  154 + try {
  155 + setProps({
  156 + loading: true,
  157 + });
  158 + disabledSwitch.value = true;
  159 + const newStatus = checked ? 1 : 0;
  160 + const res = await putSchedueByidAndStatusManage(record.id, newStatus);
  161 + if (res && newStatus) {
  162 + createMessage.success(`启用成功`);
155 163 } else {
156   - openDrawer(true, {
157   - isUpdate: false,
158   - });
  164 + createMessage.success('禁用成功');
159 165 }
160   - };
161   -
162   - const statusChange = async (checked, record) => {
163   - try {
  166 + } finally {
  167 + setTimeout(() => {
164 168 setProps({
165   - loading: true,
  169 + loading: false,
166 170 });
167   - disabledSwitch.value = true;
168   - const newStatus = checked ? 1 : 0;
169   - const res = await putSchedueByidAndStatusManage(record.id, newStatus);
170   - if (res && newStatus) {
171   - createMessage.success(`启用成功`);
172   - } else {
173   - createMessage.success('禁用成功');
174   - }
175   - } finally {
176   - setTimeout(() => {
177   - setProps({
178   - loading: false,
179   - });
180   - disabledSwitch.value = false;
181   - }, 500);
182   - reload();
183   - }
184   - };
185   - const handleRunOne = async (record: Recordable) => {
186   - const res = await postRunSchedueConfigManage(record.id);
187   - if (res?.code === 200) {
188   - createMessage.success(`执行一次任务"${record.jobName}"成功`);
189   - }
190   - };
  171 + disabledSwitch.value = false;
  172 + }, 500);
  173 + reload();
  174 + }
  175 +};
  176 +const handleRunOne = async (record: Recordable) => {
  177 + const res = await postRunSchedueConfigManage(record.id);
  178 + if (res?.code === 200) {
  179 + createMessage.success(`执行一次任务"${record.jobName}"成功`);
  180 + }
  181 +};
191 182 </script>
192   -<style lang="less" scoped></style>
  183 +<style lang="less" scoped>
  184 +</style>
... ...