Commit ac144ecc8f2df93ef1256501c7aa1bfb60baabab

Authored by fengtao
1 parent 4bb13c74

fix:修改报表配置设备取消删除问题

... ... @@ -23,7 +23,6 @@
23 23 @deselect="handleDeselect"
24 24 mode="multiple"
25 25 labelInValue
26   - allowClear
27 26 notFoundContent="请选择设备"
28 27 />
29 28 <div style="margin-top: 1.5vh"></div>
... ... @@ -66,6 +65,7 @@
66 65 attribute?: string;
67 66 device?: string;
68 67 name?: string;
  68 + attributes?: string | undefined;
69 69 };
70 70 const emit = defineEmits(['success', 'register']);
71 71 const bindDeviceRefObj = {
... ... @@ -105,8 +105,10 @@
105 105 //设备Select选中
106 106 const handleDeviceChange = (e) => {
107 107 if (unref(isUpdate)) {
  108 + //编辑
  109 + let temp: any = [];
108 110 editDeviceAttr.value.forEach((f) => {
109   - deviceList.value = [f, ...e];
  111 + temp = [f, ...e];
110 112 });
111 113 let deWeightThree = () => {
112 114 let map = new Map();
... ... @@ -117,7 +119,11 @@
117 119 }
118 120 return [...map.values()];
119 121 };
120   - deviceList.value = deWeightThree();
  122 + temp = deWeightThree();
  123 + deviceList.value = temp;
  124 + if (e.length !== 0) {
  125 + deviceList.value = e;
  126 + }
121 127 } else {
122 128 deviceList.value = e;
123 129 }
... ... @@ -125,7 +131,7 @@
125 131 //设备取消删除
126 132 const handleDeselect = (e) => {
127 133 if (unref(isUpdate)) {
128   - const eEditDevice = e.key || e.value;
  134 + //编辑
129 135 let deWeightThree = () => {
130 136 let map = new Map();
131 137 for (let item of deviceList.value) {
... ... @@ -136,8 +142,13 @@
136 142 return [...map.values()];
137 143 };
138 144 deviceList.value = deWeightThree();
139   - const findEditValue = deviceList.value.findIndex((f) => f.value == eEditDevice);
  145 + const findEditValue = deviceList.value.findIndex((f) => f.value == e.value);
140 146 if (findEditValue !== -1) deviceList.value.splice(findEditValue, 1);
  147 + // try {
  148 + // if (deviceList.value[0]?.attributes.length > 0) {
  149 + // deviceList.value.splice(0, 1);
  150 + // }
  151 + // } catch {}
141 152 } else {
142 153 const eDevice = e.key || e.value;
143 154 const findValue = deviceList.value.findIndex((f) => f.value == eDevice);
... ... @@ -179,12 +190,29 @@
179 190 await setFieldsValue({
180 191 agg: editResData.data.queryCondition?.agg,
181 192 interval: editResData.data.queryCondition?.interval,
182   - limit1: editResData.data.queryCondition?.limit,
  193 + limit: editResData.data.queryCondition?.limit,
183 194 orderBy: editResData.data.queryCondition?.orderBy,
184 195 useStrictDataTypes: editResData.data.queryCondition?.useStrictDataTypes,
185 196 startTs: editResData.data.queryCondition?.startTs,
186 197 endTs: editResData.data.queryCondition?.endTs,
  198 + way: editResData.data?.way,
  199 + queryMode: editResData.data.queryCondition?.queryMode === 0 ? 'latest' : 'timePeriod',
  200 + });
  201 + const endTsTime = editResData.data.queryCondition?.endTs;
  202 + const startTsTime = editResData.data.queryCondition?.startTs;
  203 + const mathFloor = (endTsTime - startTsTime) / 10;
  204 + const multTen = Math.floor(mathFloor) * 10;
  205 + await setFieldsValue({
  206 + startTs: multTen,
187 207 });
  208 + if (editResData.data.queryCondition?.queryMode == 1) {
  209 + await setFieldsValue({
  210 + dataRange: [
  211 + editResData.data.queryCondition?.startTs,
  212 + editResData.data.queryCondition?.endTs,
  213 + ],
  214 + });
  215 + }
188 216 //回显聚合条件
189 217 const dataCompareOpions = [
190 218 { label: '最小值', value: AggregateDataEnum.MIN },
... ... @@ -248,6 +276,10 @@
248 276 deviceList.value = editDeviceAttr.value;
249 277 editDeviceList.value = editResData.data.executeAttributes;
250 278 } else {
  279 + setFieldsValue({
  280 + startTs: 1000,
  281 + interval: 1000,
  282 + });
251 283 editId.value = '';
252 284 orgId.value = '';
253 285 selectDevice.value = [];
... ... @@ -312,13 +344,17 @@
312 344 if (getAttrDevice.value.length === 0) {
313 345 return createMessage.error('请选择设备及其属性');
314 346 }
  347 + } else {
  348 + if (getAttrDevice.value.length === 0) {
  349 + return createMessage.error('请选择设备及其属性');
  350 + }
315 351 }
316 352 if (values.executeWay == 0) {
317 353 executeContent = null;
318 354 } else {
319 355 executeContent = values.cronTime;
320 356 }
321   - if (values.way === QueryWay.LATEST) {
  357 + if (values.queryMode === QueryWay.LATEST) {
322 358 startTs.value = moment().subtract(values.startTs, 'ms').valueOf();
323 359 endTs.value = Date.now();
324 360 } else {
... ... @@ -335,6 +371,7 @@
335 371 ...{
336 372 endTs: endTs.value,
337 373 },
  374 + queryMode: values?.queryMode === 'latest' ? 0 : 1,
338 375 };
339 376
340 377 delete values.devices;
... ... @@ -347,6 +384,7 @@
347 384 delete values.cronYear;
348 385 delete values.limit1;
349 386 delete values.startTs;
  387 + delete values.queryMode;
350 388 postObj = {
351 389 ...values,
352 390 ...{
... ...
... ... @@ -21,7 +21,7 @@ export enum QueryWay {
21 21 TIME_PERIOD = 'timePeriod',
22 22 }
23 23 export enum SchemaFiled {
24   - WAY = 'way',
  24 + WAY = 'queryMode',
25 25 TIME_PERIOD = 'timePeriod',
26 26 KEYS = 'keys',
27 27 DATE_RANGE = 'dataRange',
... ... @@ -214,8 +214,12 @@ export const formSchema: QFormSchema[] = [
214 214 placeholder: '请选择执行方式',
215 215 onChange(e) {
216 216 let dataCompareOpions: any = [];
  217 + setFieldsValue({
  218 + startTs: 1000,
  219 + interval: 1000,
  220 + });
217 221 if (e.target.value == 0) {
218   - setFieldsValue({ way: QueryWay.LATEST });
  222 + setFieldsValue({ queryMode: QueryWay.LATEST });
219 223 dataCompareOpions = [
220 224 { label: '固定周期', value: QueryWay.LATEST },
221 225 { label: '自定义周期', value: QueryWay.TIME_PERIOD },
... ... @@ -227,7 +231,7 @@ export const formSchema: QFormSchema[] = [
227 231 },
228 232 });
229 233 } else {
230   - setFieldsValue({ way: QueryWay.LATEST });
  234 + setFieldsValue({ queryMode: QueryWay.LATEST });
231 235 dataCompareOpions = [{ label: '固定周期', value: QueryWay.LATEST }];
232 236 updateSchema({
233 237 defaultValue: QueryWay.LATEST,
... ... @@ -492,7 +496,6 @@ export const formSchema: QFormSchema[] = [
492 496 formActionType.setFieldsValue({ [SchemaFiled.LIMIT]: null });
493 497 }
494 498 return {
495   - // defaultValue: 1000,
496 499 placeholder: '请选择间隔时间',
497 500 options,
498 501 };
... ...
... ... @@ -20,8 +20,11 @@
20 20 label: '报表导出',
21 21 icon: 'ant-design:dot-chart-outlined',
22 22 auth: 'api:yt:reportExport:export',
23   - onClick: handleExport.bind(null, record),
24 23 ifShow: record.executeStatus === 1,
  24 + popConfirm: {
  25 + title: '是否需要导出',
  26 + confirm: handleExport.bind(null, record),
  27 + },
25 28 },
26 29 {
27 30 label: '报表查看',
... ... @@ -99,7 +102,7 @@
99 102 });
100 103
101 104 const [registerModal, { openModal }] = useModal();
102   - const handleView = (_, record) => {
  105 + const handleView = (record) => {
103 106 openModal(true, {
104 107 isUpdate: true,
105 108 record,
... ...