Commit 281203f2826db5ae5211252742bb1df1a12a462f

Authored by xp.Huang
2 parents 756f7b12 92053b97

Merge branch 'f-dev' into 'main'

fix:修改调度日志分页

See merge request huang/yun-teng-iot-front!275
@@ -9,6 +9,7 @@ export type SchedueParam = { @@ -9,6 +9,7 @@ export type SchedueParam = {
9 orderType: string; 9 orderType: string;
10 data?: any; 10 data?: any;
11 code?: number; 11 code?: number;
  12 + jobId?: string;
12 }; 13 };
13 14
14 export interface ReportModel { 15 export interface ReportModel {
1 <template> 1 <template>
2 <div> 2 <div>
3 - <BasicModal  
4 - v-bind="$attrs"  
5 - width="55rem"  
6 - :height="heightNum"  
7 - @register="register"  
8 - title="执行设备及属性"  
9 - @cancel="handleCancel"  
10 - :showOkBtn="false"  
11 - > 3 + <BasicModal v-bind="$attrs" width="55rem" :height="heightNum" @register="register" title="执行设备及属性"
  4 + @cancel="handleCancel" :showOkBtn="false">
12 <div> 5 <div>
13 <BasicTable @register="registerTable" :dataSource="tableData" /> 6 <BasicTable @register="registerTable" :dataSource="tableData" />
14 </div> 7 </div>
@@ -16,35 +9,38 @@ @@ -16,35 +9,38 @@
16 </div> 9 </div>
17 </template> 10 </template>
18 <script setup lang="ts"> 11 <script setup lang="ts">
19 - import { ref, nextTick } from 'vue';  
20 - import { BasicModal, useModalInner } from '/@/components/Modal';  
21 - import { BasicTable, useTable } from '/@/components/Table';  
22 - import { viewDeviceColumn } from './config.data'; 12 +import { ref, nextTick } from 'vue';
  13 +import { BasicModal, useModalInner } from '/@/components/Modal';
  14 +import { BasicTable, useTable } from '/@/components/Table';
  15 +import { viewDeviceColumn } from './config.data';
  16 +import { reportEditDetailPage } from '/@/api/report/reportManager';
23 17
24 - const heightNum = ref(800);  
25 - const tableData: any = ref([]);  
26 - const [registerTable] = useTable({  
27 - title: '执行设备及属性',  
28 - columns: viewDeviceColumn,  
29 - showIndexColumn: false,  
30 - clickToRowSelect: false,  
31 - showTableSetting: false,  
32 - bordered: true,  
33 - });  
34 - const [register] = useModalInner((data) => {  
35 - console.log(data);  
36 - const getTableData = () => {  
37 - for (let i = 0; i < 100; i++) {  
38 - tableData.value.push({  
39 - device: `设备${i}`,  
40 - attribute: `CO${i}、Temp${i}`,  
41 - }); 18 +const heightNum = ref(800);
  19 +const tableData: any = ref([]);
  20 +const [registerTable] = useTable({
  21 + title: '执行设备及属性',
  22 + columns: viewDeviceColumn,
  23 + showIndexColumn: false,
  24 + clickToRowSelect: false,
  25 + showTableSetting: false,
  26 + bordered: true,
  27 +});
  28 +const [register] = useModalInner((data) => {
  29 + const getTableData = async () => {
  30 + const res: any = await reportEditDetailPage(data.record.id)
  31 + const resMap = res.data.executeAttributes.map(d => {
  32 + return {
  33 + device: d.name,
  34 + attribute: d.attributes.join(',')
42 } 35 }
43 - };  
44 - nextTick(() => {  
45 - getTableData();  
46 - }); 36 + })
  37 + tableData.value = resMap
  38 + };
  39 + nextTick(() => {
  40 + getTableData();
47 }); 41 });
48 - const handleCancel = () => {}; 42 +});
  43 +const handleCancel = () => { };
49 </script> 44 </script>
50 -<style></style> 45 +<style>
  46 +</style>
1 <template> 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 <BasicForm @register="registerForm"> 4 <BasicForm @register="registerForm">
4 <template #devices> 5 <template #devices>
5 <Select placeholder="请选择设备" v-model:value="selectDevice" style="width: 100%" :options="selectOptions" 6 <Select placeholder="请选择设备" v-model:value="selectDevice" style="width: 100%" :options="selectOptions"
6 @change="handleDeviceChange" mode="multiple" labelInValue allowClear notFoundContent="请选择设备" /> 7 @change="handleDeviceChange" mode="multiple" labelInValue allowClear notFoundContent="请选择设备" />
7 <div style="margin-top: 1.5vh"></div> 8 <div style="margin-top: 1.5vh"></div>
8 - <div v-for="(item, index) in deviceList" :key="index">  
9 - <DeviceAttrCpns ref="deviceAttrRef" @change="handleChange" :value="item" :orgId="organizationId || orgId" />  
10 - </div> 9 + <DeviceAttrCpns ref="deviceAttrRef" @change="handleChange" :value="deviceList"
  10 + :orgId="organizationId || orgId" />
11 </template> 11 </template>
12 </BasicForm> 12 </BasicForm>
13 </BasicDrawer> 13 </BasicDrawer>
14 </template> 14 </template>
15 <script lang="ts" setup> 15 <script lang="ts" setup>
16 -import { ref, computed, unref, reactive, watch, nextTick, Ref } from 'vue'; 16 +import { ref, computed, unref, reactive, watch, Ref } from 'vue';
17 import { BasicForm, useForm } from '/@/components/Form'; 17 import { BasicForm, useForm } from '/@/components/Form';
18 import { formSchema, organizationId } from './config.data'; 18 import { formSchema, organizationId } from './config.data';
19 import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; 19 import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
@@ -26,6 +26,7 @@ import DeviceAttrCpns from './cpns/DeviceAttrCpns.vue'; @@ -26,6 +26,7 @@ import DeviceAttrCpns from './cpns/DeviceAttrCpns.vue';
26 import { SelectTypes } from 'ant-design-vue/es/select'; 26 import { SelectTypes } from 'ant-design-vue/es/select';
27 import { SchemaFiled } from './config.data'; 27 import { SchemaFiled } from './config.data';
28 import { QueryWay } from '../../device/localtion/cpns/TimePeriodForm/config'; 28 import { QueryWay } from '../../device/localtion/cpns/TimePeriodForm/config';
  29 +import { AggregateDataEnum } from '../../device/localtion/cpns/TimePeriodForm/config';
29 30
30 type TDeviceList = { 31 type TDeviceList = {
31 key?: string, 32 key?: string,
@@ -36,17 +37,22 @@ type TDeviceList = { @@ -36,17 +37,22 @@ type TDeviceList = {
36 name?: string 37 name?: string
37 } 38 }
38 const emit = defineEmits(['success', 'register']); 39 const emit = defineEmits(['success', 'register']);
39 -const deviceAttrRef: any = ref(null); 40 +const deviceAttrRef = ref<InstanceType<typeof DeviceAttrCpns> | null>(null)
40 const isUpdate = ref(true); 41 const isUpdate = ref(true);
41 const editId = ref(''); 42 const editId = ref('');
42 const orgId = ref(''); 43 const orgId = ref('');
43 const selectOptions: Ref<SelectTypes['options']> = ref([]); 44 const selectOptions: Ref<SelectTypes['options']> = ref([]);
44 const selectDevice = ref([]); 45 const selectDevice = ref([]);
45 const deviceList: Ref<TDeviceList[]> = ref([]); 46 const deviceList: Ref<TDeviceList[]> = ref([]);
  47 +const editDeviceList: Ref<TDeviceList[]> = ref([]);
  48 +let editResData: any = reactive({})
  49 +const watchOrgId = ref('')
  50 +const editDeviceAttr: any = ref([])
46 51
47 watch(organizationId, async (newValue: string) => { 52 watch(organizationId, async (newValue: string) => {
48 if (!newValue) return; 53 if (!newValue) return;
49 //获取设备 54 //获取设备
  55 + watchOrgId.value = newValue
50 const { items } = await screenLinkPageByDeptIdGetDevice({ 56 const { items } = await screenLinkPageByDeptIdGetDevice({
51 organizationId: newValue, 57 organizationId: newValue,
52 }); 58 });
@@ -59,9 +65,10 @@ watch(organizationId, async (newValue: string) => { @@ -59,9 +65,10 @@ watch(organizationId, async (newValue: string) => {
59 }); 65 });
60 }); 66 });
61 const handleDeviceChange = (e) => { 67 const handleDeviceChange = (e) => {
  68 + console.log(e)
62 deviceList.value = e; 69 deviceList.value = e;
63 }; 70 };
64 -const [registerForm, { validate, setFieldsValue, resetFields }] = useForm({ 71 +const [registerForm, { validate, setFieldsValue, resetFields, updateSchema, getFieldsValue }] = useForm({
65 labelWidth: 120, 72 labelWidth: 120,
66 schemas: formSchema, 73 schemas: formSchema,
67 showActionButtonGroup: false, 74 showActionButtonGroup: false,
@@ -73,19 +80,53 @@ const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async ( @@ -73,19 +80,53 @@ const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (
73 isUpdate.value = !!data?.isUpdate; 80 isUpdate.value = !!data?.isUpdate;
74 if (unref(isUpdate)) { 81 if (unref(isUpdate)) {
75 //编辑回显数据 82 //编辑回显数据
76 - const editResData: any = await reportEditDetailPage(data.record.id)  
77 - console.log(editResData.data)  
78 - // //回显基础数据 83 + editResData = await reportEditDetailPage(data.record.id)
  84 + //回显基础数据
79 editId.value = editResData.data.id; 85 editId.value = editResData.data.id;
80 await setFieldsValue(editResData.data); 86 await setFieldsValue(editResData.data);
81 //回显嵌套数据 87 //回显嵌套数据
82 - setFieldsValue({ 88 + await setFieldsValue({
83 agg: editResData.data.queryCondition?.agg, 89 agg: editResData.data.queryCondition?.agg,
84 interval: editResData.data.queryCondition?.interval, 90 interval: editResData.data.queryCondition?.interval,
  91 + limit1: editResData.data.queryCondition?.limit,
  92 + orderBy: editResData.data.queryCondition?.orderBy,
  93 + useStrictDataTypes: editResData.data.queryCondition?.useStrictDataTypes
85 }); 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))
86 //回显设备 128 //回显设备
87 orgId.value = editResData.data.organizationId; 129 orgId.value = editResData.data.organizationId;
88 - //获取该组织下的设备--排除网关设备  
89 const { items } = await screenLinkPageByDeptIdGetDevice({ 130 const { items } = await screenLinkPageByDeptIdGetDevice({
90 organizationId: editResData.data.organizationId, 131 organizationId: editResData.data.organizationId,
91 }); 132 });
@@ -103,25 +144,54 @@ const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async ( @@ -103,25 +144,54 @@ const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (
103 } 144 }
104 }) 145 })
105 selectDevice.value = deviceIds; 146 selectDevice.value = deviceIds;
106 - //回显设备属性 TODO 模拟的数据 待服务端返回  
107 - deviceList.value = editResData.data.executeAttributes  
108 - nextTick(() => { }); 147 + //回显设备属性
  148 + editDeviceAttr.value = editResData.data.executeAttributes?.map(item => {
  149 + return {
  150 + label: item.name,
  151 + value: item.device,
  152 + attributes: item.attributes,
  153 + }
  154 + })
  155 + deviceList.value = editDeviceAttr.value
  156 + editDeviceList.value = editResData.data.executeAttributes
109 } else { 157 } else {
110 editId.value = ''; 158 editId.value = '';
111 orgId.value = ''; 159 orgId.value = '';
112 selectDevice.value = []; 160 selectDevice.value = [];
113 selectOptions.value = []; 161 selectOptions.value = [];
114 deviceList.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)
115 } 186 }
116 }); 187 });
  188 +const handleClose = () => {
  189 + deviceList.value = [];
  190 +}
117 const getAttrDevice: Ref<TDeviceList[]> = ref([]); 191 const getAttrDevice: Ref<TDeviceList[]> = ref([]);
118 const getTitle = computed(() => (!unref(isUpdate) ? '新增报表配置' : '编辑报表配置')); 192 const getTitle = computed(() => (!unref(isUpdate) ? '新增报表配置' : '编辑报表配置'));
119 const handleChange = (e: any) => { 193 const handleChange = (e: any) => {
120 - getAttrDevice.value.push({  
121 - device: e.value,  
122 - attribute: e.attribute,  
123 - name: e.device  
124 - }); 194 + getAttrDevice.value = e
125 }; 195 };
126 let postObj: any = reactive({}); 196 let postObj: any = reactive({});
127 let queryCondition: any = reactive({}); 197 let queryCondition: any = reactive({});
@@ -134,8 +204,10 @@ async function handleSubmit() { @@ -134,8 +204,10 @@ async function handleSubmit() {
134 const { createMessage } = useMessage(); 204 const { createMessage } = useMessage();
135 const values = await validate(); 205 const values = await validate();
136 if (!values) return; 206 if (!values) return;
137 - if (getAttrDevice.value.length === 0) {  
138 - return createMessage.error('请选择设备及其属性'); 207 + if (!unref(isUpdate)) {
  208 + if (getAttrDevice.value.length === 0) {
  209 + return createMessage.error('请选择设备及其属性');
  210 + }
139 } 211 }
140 if (values.executeWay == 0) { 212 if (values.executeWay == 0) {
141 executeContent = null; 213 executeContent = null;
@@ -145,7 +217,7 @@ async function handleSubmit() { @@ -145,7 +217,7 @@ async function handleSubmit() {
145 queryCondition = { 217 queryCondition = {
146 agg: values.agg, 218 agg: values.agg,
147 interval: values.interval, 219 interval: values.interval,
148 - limit: values.limit, 220 + limit: values.limit1,
149 }; 221 };
150 if (values.way === QueryWay.LATEST) { 222 if (values.way === QueryWay.LATEST) {
151 startTs.value = moment().subtract(values.startTs, 'ms').valueOf() 223 startTs.value = moment().subtract(values.startTs, 'ms').valueOf()
@@ -162,9 +234,10 @@ async function handleSubmit() { @@ -162,9 +234,10 @@ async function handleSubmit() {
162 delete values.cronTime; 234 delete values.cronTime;
163 delete values.cronWeek; 235 delete values.cronWeek;
164 delete values.cronYear; 236 delete values.cronYear;
  237 + delete values.limit1;
165 postObj = { 238 postObj = {
166 ...values, 239 ...values,
167 - ...{ executeAttributes: getAttrDevice.value }, 240 + ...{ executeAttributes: getAttrDevice.value.length == 0 ? editDeviceList.value : getAttrDevice.value },
168 ...{ queryCondition }, 241 ...{ queryCondition },
169 ...{ 242 ...{
170 startTs: startTs.value 243 startTs: startTs.value
@@ -5,7 +5,7 @@ import moment from 'moment'; @@ -5,7 +5,7 @@ import moment from 'moment';
5 import { getOrganizationList } from '/@/api/system/system'; 5 import { getOrganizationList } from '/@/api/system/system';
6 import { copyTransFun } from '/@/utils/fnUtils'; 6 import { copyTransFun } from '/@/utils/fnUtils';
7 import { findDictItemByCode } from '/@/api/system/dict'; 7 import { findDictItemByCode } from '/@/api/system/dict';
8 -import { isTiming, isWeek, isMonth } from './timeConfig'; 8 +import { isTiming, isWeek, isMonth, isFixedTime } from './timeConfig';
9 import { AggregateDataEnum } from '../../device/localtion/cpns/TimePeriodForm/config'; 9 import { AggregateDataEnum } from '../../device/localtion/cpns/TimePeriodForm/config';
10 import { Moment } from 'moment'; 10 import { Moment } from 'moment';
11 import { 11 import {
@@ -13,6 +13,8 @@ import { @@ -13,6 +13,8 @@ import {
13 getPacketIntervalByValue, 13 getPacketIntervalByValue,
14 intervalOption, 14 intervalOption,
15 } from '../../device/localtion/cpns/TimePeriodForm/helper'; 15 } from '../../device/localtion/cpns/TimePeriodForm/helper';
  16 +import { USER_INFO_KEY } from '/@/enums/cacheEnum';
  17 +import { getAuthCache } from '/@/utils/auth';
16 18
17 export enum QueryWay { 19 export enum QueryWay {
18 LATEST = 'latest', 20 LATEST = 'latest',
@@ -40,15 +42,15 @@ export const columns: BasicColumn[] = [ @@ -40,15 +42,15 @@ export const columns: BasicColumn[] = [
40 }, 42 },
41 { 43 {
42 title: '所属组织', 44 title: '所属组织',
43 - dataIndex: 'organizationName', 45 + dataIndex: 'organizationDTO.name',
44 width: 120, 46 width: 120,
45 }, 47 },
46 { 48 {
47 title: '数据类型', 49 title: '数据类型',
48 - dataIndex: 'dataCompare', 50 + dataIndex: 'dataType',
49 width: 120, 51 width: 120,
50 format: (_text: string, record: Recordable) => { 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,6 +77,10 @@ export const columns: BasicColumn[] = [
75 title: '创建人', 77 title: '创建人',
76 dataIndex: 'creator', 78 dataIndex: 'creator',
77 width: 180, 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 title: '创建日期', 86 title: '创建日期',
@@ -191,9 +197,9 @@ export const formSchema: QFormSchema[] = [ @@ -191,9 +197,9 @@ export const formSchema: QFormSchema[] = [
191 span: 24, 197 span: 24,
192 }, 198 },
193 defaultValue: 0, 199 defaultValue: 0,
194 - componentProps: {  
195 - placeholder: '请选择执行方式',  
196 - options: [ 200 + componentProps: ({ formActionType }) => {
  201 + const { updateSchema, setFieldsValue } = formActionType;
  202 + const options = [
197 { 203 {
198 label: '立即执行', 204 label: '立即执行',
199 value: 0, 205 value: 0,
@@ -202,7 +208,38 @@ export const formSchema: QFormSchema[] = [ @@ -202,7 +208,38 @@ export const formSchema: QFormSchema[] = [
202 label: '定时执行', 208 label: '定时执行',
203 value: 1, 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,63 +313,6 @@ export const formSchema: QFormSchema[] = [
276 }, 313 },
277 ifShow: ({ values }) => isTiming(values.executeWay), 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 field: 'devices', 317 field: 'devices',
338 label: '设备', 318 label: '设备',
@@ -347,17 +327,49 @@ export const formSchema: QFormSchema[] = [ @@ -347,17 +327,49 @@ export const formSchema: QFormSchema[] = [
347 colProps: { span: 24 }, 327 colProps: { span: 24 },
348 }, 328 },
349 { 329 {
350 - field: 'dataCompare', 330 + field: 'dataType',
351 label: '数据类型', 331 label: '数据类型',
352 required: true, 332 required: true,
353 component: 'Select', 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 colProps: { span: 24 }, 374 colProps: { span: 24 },
363 }, 375 },
@@ -369,30 +381,22 @@ export const formSchema: QFormSchema[] = [ @@ -369,30 +381,22 @@ export const formSchema: QFormSchema[] = [
369 componentProps: { 381 componentProps: {
370 placeholder: '请选择聚合条件', 382 placeholder: '请选择聚合条件',
371 getPopupContainer: () => document.body, 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 label: '最大值', 389 label: '最大值',
385 component: 'InputNumber', 390 component: 'InputNumber',
386 - required: true, 391 + defaultValue: 200,
387 ifShow({ values }) { 392 ifShow({ values }) {
388 return values[SchemaFiled.AGG] === AggregateDataEnum.NONE; 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,7 +408,7 @@ export const formSchema: QFormSchema[] = [
404 componentProps({ formActionType }) { 408 componentProps({ formActionType }) {
405 const { setFieldsValue } = formActionType; 409 const { setFieldsValue } = formActionType;
406 return { 410 return {
407 - getPopupContainer: () => document.body, 411 + getPopupContainer: () => document.body,
408 placeholder: '请选择查询周期', 412 placeholder: '请选择查询周期',
409 options: [ 413 options: [
410 { label: '固定周期', value: QueryWay.LATEST }, 414 { label: '固定周期', value: QueryWay.LATEST },
@@ -428,13 +432,13 @@ export const formSchema: QFormSchema[] = [ @@ -428,13 +432,13 @@ export const formSchema: QFormSchema[] = [
428 component: 'RangePicker', 432 component: 'RangePicker',
429 required: true, 433 required: true,
430 ifShow({ values }) { 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 componentProps({ formActionType }) { 437 componentProps({ formActionType }) {
434 const { setFieldsValue } = formActionType; 438 const { setFieldsValue } = formActionType;
435 let dates: Moment[] = []; 439 let dates: Moment[] = [];
436 return { 440 return {
437 - placeholder: ['请选择开始时间','请选择结束时间'], 441 + placeholder: ['请选择开始时间', '请选择结束时间'],
438 showTime: true, 442 showTime: true,
439 onCalendarChange(value: Moment[]) { 443 onCalendarChange(value: Moment[]) {
440 dates = value; 444 dates = value;
@@ -460,17 +464,14 @@ export const formSchema: QFormSchema[] = [ @@ -460,17 +464,14 @@ export const formSchema: QFormSchema[] = [
460 field: SchemaFiled.START_TS, 464 field: SchemaFiled.START_TS,
461 label: '时间周期', 465 label: '时间周期',
462 component: 'Select', 466 component: 'Select',
463 - // defaultValue: 1000,  
464 required: true, 467 required: true,
465 ifShow({ values }) { 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 componentProps({ formActionType }) { 471 componentProps({ formActionType }) {
472 const { setFieldsValue } = formActionType; 472 const { setFieldsValue } = formActionType;
473 return { 473 return {
  474 + defaultValue: 1000,
474 placeholder: '请选择时间周期', 475 placeholder: '请选择时间周期',
475 options: intervalOption, 476 options: intervalOption,
476 onChange() { 477 onChange() {
@@ -484,12 +485,8 @@ export const formSchema: QFormSchema[] = [ @@ -484,12 +485,8 @@ export const formSchema: QFormSchema[] = [
484 label: '间隔时间', 485 label: '间隔时间',
485 component: 'Select', 486 component: 'Select',
486 required: true, 487 required: true,
487 - // defaultValue: 1000,  
488 ifShow({ values }) { 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 componentProps({ formModel, formActionType }) { 491 componentProps({ formModel, formActionType }) {
495 const options = 492 const options =
@@ -500,6 +497,7 @@ export const formSchema: QFormSchema[] = [ @@ -500,6 +497,7 @@ export const formSchema: QFormSchema[] = [
500 formActionType.setFieldsValue({ [SchemaFiled.LIMIT]: null }); 497 formActionType.setFieldsValue({ [SchemaFiled.LIMIT]: null });
501 } 498 }
502 return { 499 return {
  500 + // defaultValue: 1000,
503 placeholder: '请选择间隔时间', 501 placeholder: '请选择间隔时间',
504 options, 502 options,
505 }; 503 };
1 <template> 1 <template>
2 - <div  
3 - v-for="param in dynamicInput.params"  
4 - :key="param.key"  
5 - style="display: flex; margin-top: 0.25vh"  
6 - >  
7 - <a-input  
8 - :disabled="true"  
9 - v-model:value="param.device"  
10 - style="width: 50%; margin-bottom: 5px; margin-left: 0vh"  
11 - @change="emitChange"  
12 - />  
13 - <Select  
14 - placeholder="请选择设备属性"  
15 - v-model:value="param.attribute"  
16 - style="width: 50%; margin-left: 1.8vw"  
17 - :options="selectOptions"  
18 - @change="emitChange"  
19 - allowClear  
20 - /> 2 + <div v-for="param in dynamicInput.params" :key="param.key" style="display: flex; margin-top: 0.25vh">
  3 + <a-input :disabled="true" v-model:value="param.device" style="width: 38%; margin-bottom: 5px; margin-left: 1vh"
  4 + @change="emitChange" />
  5 + <Select placeholder="请选择设备属性" v-model:value="param.attributes" style="width: 160px; margin-left: 1.8vw"
  6 + :options="selectOptions" @change="emitChange" allowClear mode="multiple" />
21 </div> 7 </div>
22 </template> 8 </template>
23 <script lang="ts"> 9 <script lang="ts">
24 - export default {  
25 - inheritAttrs: false,  
26 - }; 10 +export default {
  11 + inheritAttrs: false,
  12 +};
27 </script> 13 </script>
28 <script lang="ts" setup> 14 <script lang="ts" setup>
29 - import { reactive, UnwrapRef, watchEffect, ref } from 'vue';  
30 - import { propTypes } from '/@/utils/propTypes';  
31 - import { SelectTypes } from 'ant-design-vue/es/select';  
32 - import { Select } from 'ant-design-vue';  
33 - import { getAttribute } from '/@/api/ruleengine/ruleengineApi'; 15 +import { reactive, UnwrapRef, watchEffect, ref } from 'vue';
  16 +import { propTypes } from '/@/utils/propTypes';
  17 +import { SelectTypes } from 'ant-design-vue/es/select';
  18 +import { Select } from 'ant-design-vue';
  19 +import { getAttribute } from '/@/api/ruleengine/ruleengineApi';
34 20
35 - interface Params {  
36 - [x: string]: string;  
37 - attribute: string;  
38 - device: string;  
39 - }  
40 - const props = defineProps({  
41 - value: propTypes.object.def({}),  
42 - orgId: propTypes.string.def(''), 21 +interface Params {
  22 + [x: string]: string;
  23 + attributes: any;
  24 + device: string;
  25 +}
  26 +const props = defineProps({
  27 + value: propTypes.array.def([]),
  28 + orgId: propTypes.string.def(''),
  29 +});
  30 +const emits = defineEmits(['change', 'update:value']);
  31 +const selectOptions = ref<SelectTypes['options']>([]);
  32 +//获取属性
  33 +const getAttr = async (orgId, deviceId) => {
  34 + const res = await getAttribute(orgId, deviceId.join(','));
  35 + selectOptions.value = res.map((o) => {
  36 + return {
  37 + label: o,
  38 + value: o,
  39 + };
43 }); 40 });
44 - const emits = defineEmits(['change', 'update:value']);  
45 - const selectOptions = ref<SelectTypes['options']>([]);  
46 - //获取属性  
47 - const getAttr = async (orgId, deviceId) => {  
48 - const res = await getAttribute(orgId, deviceId);  
49 - selectOptions.value = res.map((o) => { 41 +};
  42 +//动态数据
  43 +const dynamicInput: UnwrapRef<{ params: Params[] }> = reactive({ params: [] });
  44 +//监听传入数据value
  45 +watchEffect(() => {
  46 + initVal();
  47 +});
  48 +/**
  49 + * 初始化数值
  50 + */
  51 +async function initVal() {
  52 + dynamicInput.params = []
  53 + if (props.value && props.orgId) {
  54 + let jsonObj = props.value;
  55 + const deviceId = jsonObj.map((m: any) => m.value);
  56 + await getAttr(props.orgId, deviceId);
  57 + dynamicInput.params = jsonObj.map((item: any) => {
50 return { 58 return {
51 - label: o,  
52 - value: o,  
53 - };  
54 - });  
55 - };  
56 - //动态数据  
57 - const dynamicInput: UnwrapRef<{ params: Params[] }> = reactive({ params: [] });  
58 - const rEffect = watchEffect(() => {  
59 - initVal();  
60 - });  
61 - rEffect();  
62 - /**  
63 - * 初始化数值  
64 - */  
65 - async function initVal() {  
66 - if (props.orgId && props.value.value) {  
67 - await getAttr(props.orgId, props.value.value);  
68 - dynamicInput.params.push({  
69 - device: props.value.label,  
70 - value: props.value.value,  
71 - attribute: props.value.attribute == '' ? '' : props.value.attribute,  
72 - });  
73 - } 59 + attributes: item.attributes,
  60 + device: item.label,
  61 + value: item.value,
  62 + }
  63 + })
74 } 64 }
75 - /**  
76 - * 数值改变  
77 - */  
78 - function emitChange() {  
79 - let obj: any = dynamicInput.params[0];  
80 - emits('change', obj);  
81 - emits('update:value', obj); 65 +}
  66 +/**
  67 + * 数值改变
  68 + */
  69 +function emitChange() {
  70 + let obj: any = [];
  71 + if (dynamicInput.params.length > 0) {
  72 + dynamicInput.params.forEach((item: Params) => {
  73 + obj.push({
  74 + attributes: item.attributes,
  75 + device: item.value,
  76 + name: item.device
  77 + });
  78 + });
82 } 79 }
83 - defineExpose({  
84 - getAttr,  
85 - }); 80 + emits('change', obj);
  81 + emits('update:value', obj);
  82 +}
86 </script> 83 </script>
87 <style scoped lang="css"> 84 <style scoped lang="css">
88 - @import './deviceAttrCpns.css'; 85 +@import './deviceAttrCpns.css';
89 </style> 86 </style>
@@ -86,6 +86,7 @@ export enum TypeEnum { @@ -86,6 +86,7 @@ export enum TypeEnum {
86 IS_AVG = 'AVG', 86 IS_AVG = 'AVG',
87 IS_SUM = 'SUM', 87 IS_SUM = 'SUM',
88 COUNT = 'COUNT', 88 COUNT = 'COUNT',
  89 + IS_FIXED_TIME = 1,
89 } 90 }
90 91
91 export enum AggregateDataEnum { 92 export enum AggregateDataEnum {
@@ -96,6 +97,9 @@ export enum AggregateDataEnum { @@ -96,6 +97,9 @@ export enum AggregateDataEnum {
96 COUNT = 'COUNT', 97 COUNT = 'COUNT',
97 NONE = 'NONE', 98 NONE = 'NONE',
98 } 99 }
  100 +export const isFixedTime = (type: string) => {
  101 + return type === TypeEnum.IS_FIXED_TIME;
  102 +};
99 103
100 export const isTiming = (type: string) => { 104 export const isTiming = (type: string) => {
101 return type === TypeEnum.IS_TIMING; 105 return type === TypeEnum.IS_TIMING;
1 <template> 1 <template>
2 <div> 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 <div> 5 <div>
14 <BasicTable @register="registerTable"> 6 <BasicTable @register="registerTable">
15 <template #toolbar> 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 <a-button type="primary"> 清空 </a-button> 9 <a-button type="primary"> 清空 </a-button>
23 </Popconfirm> 10 </Popconfirm>
24 <Popconfirm title="您确定要批量删除数据" ok-text="确定" cancel-text="取消"> 11 <Popconfirm title="您确定要批量删除数据" ok-text="确定" cancel-text="取消">
@@ -28,24 +15,22 @@ @@ -28,24 +15,22 @@
28 </Popconfirm> 15 </Popconfirm>
29 </template> 16 </template>
30 <template #action="{ record }"> 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 </template> 34 </template>
50 </BasicTable> 35 </BasicTable>
51 <ScheduleLogViewModal @register="registerModalScheduleLogView" /> 36 <ScheduleLogViewModal @register="registerModalScheduleLogView" />
@@ -54,80 +39,85 @@ @@ -54,80 +39,85 @@
54 </div> 39 </div>
55 </template> 40 </template>
56 <script setup lang="ts"> 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 </script> 121 </script>
133 -<style lang="less" scoped></style> 122 +<style lang="less" scoped>
  123 +</style>
@@ -9,62 +9,53 @@ @@ -9,62 +9,53 @@
9 <a-button type="primary"> 导出 </a-button> 9 <a-button type="primary"> 导出 </a-button>
10 </Authority> 10 </Authority>
11 <Authority value="api:yt:schedule:delete"> 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 <a-button type="primary" color="error" :disabled="hasBatchDelete"> 批量删除 </a-button> 13 <a-button type="primary" color="error" :disabled="hasBatchDelete"> 批量删除 </a-button>
14 </Popconfirm> 14 </Popconfirm>
15 </Authority> 15 </Authority>
16 </template> 16 </template>
17 <template #action="{ record }"> 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 </template> 55 </template>
59 <template #status="{ record }"> 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 </template> 59 </template>
69 </BasicTable> 60 </BasicTable>
70 <ScheduledDrawer @register="registerDrawer" @success="handleSuccess" /> 61 <ScheduledDrawer @register="registerDrawer" @success="handleSuccess" />
@@ -73,120 +64,121 @@ @@ -73,120 +64,121 @@
73 </div> 64 </div>
74 </template> 65 </template>
75 <script setup lang="ts"> 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 isUpdate: true, 143 isUpdate: true,
145 record, 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 } else { 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 setProps({ 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 </script> 182 </script>
192 -<style lang="less" scoped></style> 183 +<style lang="less" scoped>
  184 +</style>