Commit c2696eb206baad6b3f17c409135c37752e397d9d
Merge branch 'f-dev' into 'main'
fix:修改Teambition上的问题 See merge request huang/yun-teng-iot-front!269
Showing
9 changed files
with
298 additions
and
175 deletions
| ... | ... | @@ -5,8 +5,8 @@ enum ReportManagerApi { |
| 5 | 5 | GET_REPORT_API = '/report_form/config', |
| 6 | 6 | POST_REPORT_API = '/report_form/config', |
| 7 | 7 | DELETE_REPORT_API = '/report_form/config', |
| 8 | - // PUT_REPORT_API = '/report_form', | |
| 9 | - // PUTID_REPORT_API = '/report_form', | |
| 8 | + PUT_REPORT_API = '/report_form/config', | |
| 9 | + PUTID_REPORT_API = '/report_form', | |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | //分页 |
| ... | ... | @@ -27,7 +27,7 @@ export const deleteReportManage = (ids: string[]) => { |
| 27 | 27 | }); |
| 28 | 28 | }; |
| 29 | 29 | |
| 30 | -// 创建或编辑 | |
| 30 | +// 创建 | |
| 31 | 31 | export const createOrEditReportManage = (data) => { |
| 32 | 32 | return defHttp.post<ReportModel>({ |
| 33 | 33 | url: ReportManagerApi.POST_REPORT_API, |
| ... | ... | @@ -35,18 +35,17 @@ export const createOrEditReportManage = (data) => { |
| 35 | 35 | }); |
| 36 | 36 | }; |
| 37 | 37 | |
| 38 | -// // 修改状态 | |
| 39 | -// export const putReportConfigManage = (data) => { | |
| 40 | -// return defHttp.post<ReportModel>({ | |
| 41 | -// url: ReportManagerApi.PUT_REPORT_API, | |
| 42 | -// data, | |
| 43 | -// }); | |
| 44 | -// }; | |
| 38 | +// 编辑 | |
| 39 | +export const putReportConfigManage = (data) => { | |
| 40 | + return defHttp.put<ReportModel>({ | |
| 41 | + url: ReportManagerApi.PUT_REPORT_API, | |
| 42 | + data | |
| 43 | + }); | |
| 44 | +}; | |
| 45 | 45 | |
| 46 | -// // 修改状态 | |
| 47 | -// export const putReportByidAndStatusManage = (data) => { | |
| 48 | -// return defHttp.post<ReportModel>({ | |
| 49 | -// url: ReportManagerApi.PUTID_REPORT_API, | |
| 50 | -// data, | |
| 51 | -// }); | |
| 52 | -// }; | |
| 46 | +// 修改状态 id status | |
| 47 | +export const putReportByidAndStatusManage = (id, status) => { | |
| 48 | + return defHttp.put<ReportModel>({ | |
| 49 | + url: ReportManagerApi.PUTID_REPORT_API + '/config/' + id + '/' + status, | |
| 50 | + }); | |
| 51 | +}; | ... | ... |
| ... | ... | @@ -26,7 +26,7 @@ export const MqttSchemas: FormSchema[] = [ |
| 26 | 26 | componentProps: { |
| 27 | 27 | placeholder: '请输入遥测数据 topic 筛选器', |
| 28 | 28 | }, |
| 29 | - colProps: { span: 11 }, | |
| 29 | + colProps: { span: 23 }, | |
| 30 | 30 | }, |
| 31 | 31 | { |
| 32 | 32 | field: 'deviceAttributesTopic', |
| ... | ... | @@ -37,7 +37,7 @@ export const MqttSchemas: FormSchema[] = [ |
| 37 | 37 | componentProps: { |
| 38 | 38 | placeholder: '请输入Attributes topic 筛选器', |
| 39 | 39 | }, |
| 40 | - colProps: { span: 11 }, | |
| 40 | + colProps: { span: 23 }, | |
| 41 | 41 | }, |
| 42 | 42 | { |
| 43 | 43 | field: 'desc', | ... | ... |
| ... | ... | @@ -9,28 +9,38 @@ |
| 9 | 9 | > |
| 10 | 10 | <BasicForm @register="registerForm"> |
| 11 | 11 | <template #deviceAttr="{ model, field }"> |
| 12 | - <deviceAttrColumn :orgId="model['organizationId']" :value="model['devices']" /> | |
| 12 | + <deviceAttrColumn | |
| 13 | + @change="handleChange" | |
| 14 | + :orgId="!isUpdate ? model['organizationId'] : orgId" | |
| 15 | + :value="!isUpdate ? model['devices'] : deviceAttrData" | |
| 16 | + :isEdit="!isUpdate ? false : true" | |
| 17 | + /> | |
| 13 | 18 | <p style="display: none">{{ field }}</p> |
| 14 | 19 | </template> |
| 15 | 20 | </BasicForm> |
| 16 | 21 | </BasicDrawer> |
| 17 | 22 | </template> |
| 18 | 23 | <script lang="ts" setup> |
| 19 | - import { ref, computed, unref, nextTick } from 'vue'; | |
| 24 | + import { ref, computed, unref, reactive } from 'vue'; | |
| 20 | 25 | import { BasicForm, useForm } from '/@/components/Form'; |
| 21 | 26 | import { formSchema } from './config.data'; |
| 22 | 27 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; |
| 23 | - import { createOrEditReportManage } from '/@/api/report/reportManager'; | |
| 28 | + import { createOrEditReportManage, putReportConfigManage } from '/@/api/report/reportManager'; | |
| 24 | 29 | import { useMessage } from '/@/hooks/web/useMessage'; |
| 25 | 30 | import deviceAttrColumn from './cpns/MappingsForm.vue'; |
| 31 | + import moment from 'moment'; | |
| 32 | + import { screenLinkPageByDeptIdGetDevice } from '/@/api/ruleengine/ruleengineApi'; | |
| 26 | 33 | |
| 27 | 34 | const emit = defineEmits(['success', 'register']); |
| 28 | 35 | const isUpdate = ref(true); |
| 29 | 36 | const editId = ref(''); |
| 30 | - const [registerForm, { validate, setFieldsValue, resetFields }] = useForm({ | |
| 37 | + const orgId = ref(''); | |
| 38 | + let deviceAttrData: any = ref([]); | |
| 39 | + const [registerForm, { validate, setFieldsValue, resetFields, updateSchema }] = useForm({ | |
| 31 | 40 | labelWidth: 120, |
| 32 | 41 | schemas: formSchema, |
| 33 | 42 | showActionButtonGroup: false, |
| 43 | + fieldMapToTime: [['timeZone', ['startTime', 'endTime'], 'YYYY-MM-DD HH:mm:ss']], | |
| 34 | 44 | }); |
| 35 | 45 | |
| 36 | 46 | const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { |
| ... | ... | @@ -38,26 +48,119 @@ |
| 38 | 48 | setDrawerProps({ confirmLoading: false }); |
| 39 | 49 | isUpdate.value = !!data?.isUpdate; |
| 40 | 50 | if (unref(isUpdate)) { |
| 41 | - await nextTick(); | |
| 51 | + //回显 | |
| 42 | 52 | editId.value = data.record.id; |
| 43 | 53 | await setFieldsValue(data.record); |
| 54 | + //TODO 模拟的数据 待服务端返回 | |
| 55 | + const deviceIds: any = [ | |
| 56 | + '8943f0b0-f1f7-11ec-98ad-a9680487d1e0', | |
| 57 | + '8f5b4280-f29e-11ec-98ad-a9680487d1e0', | |
| 58 | + '54e199d0-f1f7-11ec-98ad-a9680487d1e0', | |
| 59 | + '6d9043f0-f1f7-11ec-98ad-a9680487d1e0', | |
| 60 | + ]; | |
| 61 | + setFieldsValue({ | |
| 62 | + agg: queryCondition?.agg, | |
| 63 | + interval: queryCondition?.interval, | |
| 64 | + devices: deviceIds, | |
| 65 | + }); | |
| 66 | + orgId.value = data.record.organizationId; | |
| 67 | + //获取该组织下的设备--排除网关设备 | |
| 68 | + const { items } = await screenLinkPageByDeptIdGetDevice({ | |
| 69 | + organizationId: data.record.organizationId, | |
| 70 | + }); | |
| 71 | + const options = items.map((item) => { | |
| 72 | + if (item.deviceType !== 'GATEWAY') | |
| 73 | + return { | |
| 74 | + label: item.name, | |
| 75 | + value: item.tbDeviceId, | |
| 76 | + }; | |
| 77 | + }); | |
| 78 | + updateSchema({ | |
| 79 | + field: 'devices', | |
| 80 | + componentProps: { | |
| 81 | + options, | |
| 82 | + }, | |
| 83 | + }); | |
| 84 | + //TODO 回显设备属性 模拟的数据 待服务端返回 | |
| 85 | + deviceAttrData.value = [ | |
| 86 | + { | |
| 87 | + device: '8943f0b0-f1f7-11ec-98ad-a9680487d1e0', | |
| 88 | + attribute: 'CO2', | |
| 89 | + name: '奥迪网关子设备', | |
| 90 | + }, | |
| 91 | + { | |
| 92 | + device: '6d9043f0-f1f7-11ec-98ad-a9680487d1e0', | |
| 93 | + attribute: 'co', | |
| 94 | + name: '宝马默认设备', | |
| 95 | + }, | |
| 96 | + { | |
| 97 | + device: '8f5b4280-f29e-11ec-98ad-a9680487d1e0', | |
| 98 | + attribute: 'hot', | |
| 99 | + name: '奔驰默认设备', | |
| 100 | + }, | |
| 101 | + { | |
| 102 | + device: '54e199d0-f1f7-11ec-98ad-a9680487d1e0', | |
| 103 | + attribute: 'wet', | |
| 104 | + name: '新增奥迪测试设备', | |
| 105 | + }, | |
| 106 | + ]; | |
| 44 | 107 | } else { |
| 45 | 108 | editId.value = ''; |
| 109 | + updateSchema({ | |
| 110 | + field: 'devices', | |
| 111 | + componentProps: { | |
| 112 | + options: [], | |
| 113 | + }, | |
| 114 | + }); | |
| 46 | 115 | } |
| 47 | 116 | }); |
| 48 | 117 | |
| 118 | + const getAttrDevice: any = ref([]); | |
| 49 | 119 | const getTitle = computed(() => (!unref(isUpdate) ? '新增报表配置' : '编辑报表配置')); |
| 50 | 120 | |
| 121 | + const handleChange = (e) => (getAttrDevice.value = e); | |
| 122 | + let postObj: any = reactive({}); | |
| 123 | + let queryCondition: any = reactive({}); | |
| 124 | + let executeContent: any = reactive({}); | |
| 125 | + const endTs: any = ref(0); | |
| 51 | 126 | async function handleSubmit() { |
| 52 | 127 | setDrawerProps({ confirmLoading: true }); |
| 53 | 128 | try { |
| 54 | 129 | const { createMessage } = useMessage(); |
| 55 | 130 | const values = await validate(); |
| 56 | - console.log(values); | |
| 57 | 131 | if (!values) return; |
| 132 | + if (values.executeWay == 0) { | |
| 133 | + executeContent = null; | |
| 134 | + } else { | |
| 135 | + executeContent = {}; | |
| 136 | + } | |
| 137 | + if (values.timeZone) { | |
| 138 | + const getTime = JSON.stringify(values.timeZone); | |
| 139 | + endTs.value = moment(JSON.parse(getTime)[0]).valueOf() || 1659424160000; | |
| 140 | + } | |
| 141 | + queryCondition = { | |
| 142 | + agg: values.agg, | |
| 143 | + interval: values.interval, | |
| 144 | + limit: values.limit, | |
| 145 | + }; | |
| 146 | + delete values.devices; | |
| 147 | + delete values.agg; | |
| 148 | + delete values.interval; | |
| 149 | + delete values.timeZone; | |
| 150 | + postObj = { | |
| 151 | + ...values, | |
| 152 | + ...{ executeAttributes: getAttrDevice.value }, | |
| 153 | + ...{ queryCondition }, | |
| 154 | + ...{ endTs: endTs.value }, | |
| 155 | + ...{ executeContent }, | |
| 156 | + ...{ id: editId.value !== '' ? editId.value : '' }, | |
| 157 | + }; | |
| 58 | 158 | let saveMessage = '添加成功'; |
| 59 | 159 | let updateMessage = '修改成功'; |
| 60 | - await createOrEditReportManage(values); | |
| 160 | + editId.value !== '' | |
| 161 | + ? await putReportConfigManage(postObj) | |
| 162 | + : await createOrEditReportManage(postObj); | |
| 163 | + | |
| 61 | 164 | closeDrawer(); |
| 62 | 165 | emit('success'); |
| 63 | 166 | createMessage.success(unref(isUpdate) ? updateMessage : saveMessage); | ... | ... |
| ... | ... | @@ -17,8 +17,20 @@ import { |
| 17 | 17 | isAvg, |
| 18 | 18 | isSum, |
| 19 | 19 | isCountAll, |
| 20 | - AggregateDataEnum, | |
| 21 | 20 | } from './timeConfig'; |
| 21 | +import { AggregateDataEnum } from '../../device/localtion/cpns/TimePeriodForm/config'; | |
| 22 | +export enum SchemaFiled { | |
| 23 | + WAY = 'way', | |
| 24 | + TIME_PERIOD = 'timePeriod', | |
| 25 | + KEYS = 'keys', | |
| 26 | + DATE_RANGE = 'dataRange', | |
| 27 | + START_TS = 'startTs', | |
| 28 | + END_TS = 'endTs', | |
| 29 | + INTERVAL = 'interval', | |
| 30 | + LIMIT = 'limit', | |
| 31 | + AGG = 'agg', | |
| 32 | + ORDER_BY = 'orderBy', | |
| 33 | +} | |
| 22 | 34 | |
| 23 | 35 | // 表格配置 |
| 24 | 36 | export const columns: BasicColumn[] = [ |
| ... | ... | @@ -36,16 +48,23 @@ export const columns: BasicColumn[] = [ |
| 36 | 48 | title: '数据类型', |
| 37 | 49 | dataIndex: 'dataCompare', |
| 38 | 50 | width: 120, |
| 51 | + format: (_text: string, record: Recordable) => { | |
| 52 | + return record.dataCompare === 0 ? '历史数据' : record.dataCompare === 1 ? '同比' : '环比'; | |
| 53 | + }, | |
| 39 | 54 | }, |
| 40 | 55 | { |
| 41 | 56 | title: '配置状态', |
| 42 | 57 | dataIndex: 'status', |
| 43 | 58 | width: 120, |
| 59 | + slots: { customRender: 'status' }, | |
| 44 | 60 | }, |
| 45 | 61 | { |
| 46 | 62 | title: '执行方式', |
| 47 | 63 | dataIndex: 'executeWay', |
| 48 | 64 | width: 160, |
| 65 | + format: (_text: string, record: Recordable) => { | |
| 66 | + return record.executeWay === 0 ? '立即执行' : '定时执行'; | |
| 67 | + }, | |
| 49 | 68 | }, |
| 50 | 69 | { |
| 51 | 70 | title: '执行设备', |
| ... | ... | @@ -67,12 +86,12 @@ export const columns: BasicColumn[] = [ |
| 67 | 86 | export const viewDeviceColumn: BasicColumn[] = [ |
| 68 | 87 | { |
| 69 | 88 | title: '设备', |
| 70 | - dataIndex: 'tdDevice', | |
| 89 | + dataIndex: 'device', | |
| 71 | 90 | width: 80, |
| 72 | 91 | }, |
| 73 | 92 | { |
| 74 | 93 | title: '属性', |
| 75 | - dataIndex: 'attributes', | |
| 94 | + dataIndex: 'attribute', | |
| 76 | 95 | width: 120, |
| 77 | 96 | }, |
| 78 | 97 | ]; |
| ... | ... | @@ -109,7 +128,7 @@ export const searchFormSchema: FormSchema[] = [ |
| 109 | 128 | }, |
| 110 | 129 | }, |
| 111 | 130 | { |
| 112 | - field: 'createTime', | |
| 131 | + field: 'sendTime', | |
| 113 | 132 | label: '创建时间', |
| 114 | 133 | component: 'RangePicker', |
| 115 | 134 | componentProps: { |
| ... | ... | @@ -145,15 +164,16 @@ export const formSchema: QFormSchema[] = [ |
| 145 | 164 | return { |
| 146 | 165 | async onChange(e) { |
| 147 | 166 | if (e) { |
| 148 | - //获取该组织下的设备 | |
| 167 | + //获取该组织下的设备--排除网关设备 | |
| 149 | 168 | const { items } = await screenLinkPageByDeptIdGetDevice({ |
| 150 | 169 | organizationId: e, |
| 151 | 170 | }); |
| 152 | 171 | const options = items.map((item) => { |
| 153 | - return { | |
| 154 | - label: item.name, | |
| 155 | - value: item.tbDeviceId, | |
| 156 | - }; | |
| 172 | + if (item.deviceType !== 'GATEWAY') | |
| 173 | + return { | |
| 174 | + label: item.name, | |
| 175 | + value: item.tbDeviceId, | |
| 176 | + }; | |
| 157 | 177 | }); |
| 158 | 178 | updateSchema({ |
| 159 | 179 | field: 'devices', |
| ... | ... | @@ -190,17 +210,17 @@ export const formSchema: QFormSchema[] = [ |
| 190 | 210 | colProps: { |
| 191 | 211 | span: 24, |
| 192 | 212 | }, |
| 193 | - defaultValue: 1, | |
| 213 | + defaultValue: 0, | |
| 194 | 214 | componentProps: { |
| 195 | 215 | placeholder: '请选择执行方式', |
| 196 | 216 | options: [ |
| 197 | 217 | { |
| 198 | 218 | label: '立即执行', |
| 199 | - value: 1, | |
| 219 | + value: 0, | |
| 200 | 220 | }, |
| 201 | 221 | { |
| 202 | 222 | label: '定时执行', |
| 203 | - value: 0, | |
| 223 | + value: 1, | |
| 204 | 224 | }, |
| 205 | 225 | ], |
| 206 | 226 | }, |
| ... | ... | @@ -280,7 +300,7 @@ export const formSchema: QFormSchema[] = [ |
| 280 | 300 | field: 'devices', |
| 281 | 301 | label: '设备', |
| 282 | 302 | required: true, |
| 283 | - helpMessage: ['报表配置只对拥有数值型属性的设备才能配置'], | |
| 303 | + helpMessage: ['报表配置只对拥有"数值型"属性的设备才能配置'], | |
| 284 | 304 | component: 'Select', |
| 285 | 305 | componentProps: { |
| 286 | 306 | placeholder: '请选择设备', |
| ... | ... | @@ -298,7 +318,7 @@ export const formSchema: QFormSchema[] = [ |
| 298 | 318 | }, |
| 299 | 319 | defaultValue: 0, |
| 300 | 320 | componentProps: ({ formActionType }) => { |
| 301 | - const { updateSchema } = formActionType; | |
| 321 | + const { updateSchema, setFieldsValue } = formActionType; | |
| 302 | 322 | const options = [ |
| 303 | 323 | { |
| 304 | 324 | label: '共有', |
| ... | ... | @@ -315,6 +335,7 @@ export const formSchema: QFormSchema[] = [ |
| 315 | 335 | if (e) { |
| 316 | 336 | let dataCompareOpions: any = []; |
| 317 | 337 | if (e.target.value == 1) { |
| 338 | + setFieldsValue({ dataCompare: '' }); | |
| 318 | 339 | dataCompareOpions = [{ label: '历史数据', value: 0 }]; |
| 319 | 340 | updateSchema({ |
| 320 | 341 | field: 'dataCompare', |
| ... | ... | @@ -323,6 +344,7 @@ export const formSchema: QFormSchema[] = [ |
| 323 | 344 | }, |
| 324 | 345 | }); |
| 325 | 346 | } else { |
| 347 | + setFieldsValue({ dataCompare: '' }); | |
| 326 | 348 | dataCompareOpions = [ |
| 327 | 349 | { label: '历史数据', value: 0 }, |
| 328 | 350 | { label: '同比', value: 1 }, |
| ... | ... | @@ -345,13 +367,12 @@ export const formSchema: QFormSchema[] = [ |
| 345 | 367 | { |
| 346 | 368 | field: 'devices1', |
| 347 | 369 | label: '设备属性', |
| 348 | - required: true, | |
| 349 | 370 | component: 'Select', |
| 350 | 371 | componentProps: { |
| 351 | 372 | placeholder: '请选择设备属性', |
| 352 | 373 | }, |
| 353 | 374 | colProps: { span: 24 }, |
| 354 | - slot:'deviceAttr' | |
| 375 | + slot: 'deviceAttr', | |
| 355 | 376 | }, |
| 356 | 377 | { |
| 357 | 378 | field: 'dataCompare', |
| ... | ... | @@ -369,43 +390,25 @@ export const formSchema: QFormSchema[] = [ |
| 369 | 390 | colProps: { span: 24 }, |
| 370 | 391 | }, |
| 371 | 392 | { |
| 372 | - field: 'agg', | |
| 393 | + field: SchemaFiled.AGG, | |
| 373 | 394 | label: '聚合条件', |
| 374 | 395 | required: true, |
| 375 | 396 | component: 'Select', |
| 376 | 397 | componentProps: { |
| 377 | 398 | placeholder: '请选择聚合条件', |
| 378 | 399 | options: [ |
| 379 | - { | |
| 380 | - label: '平均值', | |
| 381 | - value: AggregateDataEnum.AVG, | |
| 382 | - }, | |
| 383 | - { | |
| 384 | - label: '总和', | |
| 385 | - value: AggregateDataEnum.SUM, | |
| 386 | - }, | |
| 387 | - { | |
| 388 | - label: '最大值', | |
| 389 | - value: AggregateDataEnum.MAX, | |
| 390 | - }, | |
| 391 | - { | |
| 392 | - label: '最小值', | |
| 393 | - value: AggregateDataEnum.MIN, | |
| 394 | - }, | |
| 395 | - { | |
| 396 | - label: '计数', | |
| 397 | - value: AggregateDataEnum.COUNT, | |
| 398 | - }, | |
| 399 | - { | |
| 400 | - label: '空', | |
| 401 | - value: AggregateDataEnum.NONE, | |
| 402 | - }, | |
| 400 | + { label: '最小值', value: AggregateDataEnum.MIN }, | |
| 401 | + { label: '最大值', value: AggregateDataEnum.MAX }, | |
| 402 | + { label: '平均值', value: AggregateDataEnum.AVG }, | |
| 403 | + { label: '求和', value: AggregateDataEnum.SUM }, | |
| 404 | + { label: '计数', value: AggregateDataEnum.COUNT }, | |
| 405 | + { label: '空', value: AggregateDataEnum.NONE }, | |
| 403 | 406 | ], |
| 404 | 407 | }, |
| 405 | 408 | colProps: { span: 24 }, |
| 406 | 409 | }, |
| 407 | 410 | { |
| 408 | - field: 'limit', | |
| 411 | + field: SchemaFiled.LIMIT, | |
| 409 | 412 | component: 'InputNumber', |
| 410 | 413 | label: '最大值', |
| 411 | 414 | required: true, |
| ... | ... | @@ -441,25 +444,23 @@ export const formSchema: QFormSchema[] = [ |
| 441 | 444 | }, |
| 442 | 445 | }, |
| 443 | 446 | { |
| 444 | - field: 'interval', | |
| 447 | + field: 'timeZone', | |
| 445 | 448 | label: '时间段', |
| 446 | - required: true, | |
| 447 | 449 | component: 'RangePicker', |
| 448 | 450 | componentProps: { |
| 449 | - showTime: { | |
| 450 | - defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')], | |
| 451 | - }, | |
| 452 | - placeholder: '请选择时间段', | |
| 451 | + format: 'YYYY-MM-DD HH:mm:ss', | |
| 452 | + placeholder: ['开始时间', '结束时间'], | |
| 453 | + showTime: { format: 'HH:mm:ss' }, | |
| 453 | 454 | }, |
| 454 | 455 | colProps: { span: 24 }, |
| 455 | 456 | ifShow: ({ values }) => isDefultWeek(values.defaultWeek), |
| 456 | 457 | }, |
| 457 | 458 | { |
| 458 | - field: '91112', | |
| 459 | + field: 'startTs', | |
| 459 | 460 | label: '时间周期', |
| 460 | 461 | required: true, |
| 461 | 462 | component: 'ApiSelect', |
| 462 | - defaultValue: '1000', | |
| 463 | + defaultValue: 1000, | |
| 463 | 464 | componentProps: ({ formActionType }) => { |
| 464 | 465 | const { updateSchema } = formActionType; |
| 465 | 466 | return { |
| ... | ... | @@ -468,7 +469,7 @@ export const formSchema: QFormSchema[] = [ |
| 468 | 469 | const option = data.map((item) => { |
| 469 | 470 | return { |
| 470 | 471 | label: item.itemText, |
| 471 | - value: item.itemValue, | |
| 472 | + value: Number(item.itemValue), | |
| 472 | 473 | }; |
| 473 | 474 | }); |
| 474 | 475 | return option; |
| ... | ... | @@ -477,7 +478,7 @@ export const formSchema: QFormSchema[] = [ |
| 477 | 478 | if (Number(e) <= 30000) { |
| 478 | 479 | //30秒以内 -> 1秒 |
| 479 | 480 | updateSchema({ |
| 480 | - field: '102121', | |
| 481 | + field: 'interval', | |
| 481 | 482 | componentProps: { |
| 482 | 483 | options: optionsConfig.slice(0, 1), |
| 483 | 484 | }, |
| ... | ... | @@ -485,7 +486,7 @@ export const formSchema: QFormSchema[] = [ |
| 485 | 486 | } else if (Number(e) == 60000) { |
| 486 | 487 | //1分钟以内 -> 1秒 5秒 |
| 487 | 488 | updateSchema({ |
| 488 | - field: '102121', | |
| 489 | + field: 'interval', | |
| 489 | 490 | componentProps: { |
| 490 | 491 | options: optionsConfig.slice(0, 2), |
| 491 | 492 | }, |
| ... | ... | @@ -493,7 +494,7 @@ export const formSchema: QFormSchema[] = [ |
| 493 | 494 | } else if (Number(e) == 120000) { |
| 494 | 495 | //2分钟以内 -> 1秒 5秒 10 15 |
| 495 | 496 | updateSchema({ |
| 496 | - field: '102121', | |
| 497 | + field: 'interval', | |
| 497 | 498 | componentProps: { |
| 498 | 499 | options: optionsConfig.slice(0, 4), |
| 499 | 500 | }, |
| ... | ... | @@ -501,7 +502,7 @@ export const formSchema: QFormSchema[] = [ |
| 501 | 502 | } else if (Number(e) == 300000) { |
| 502 | 503 | //5分钟以内 -> 1秒 5秒 10 15 30 |
| 503 | 504 | updateSchema({ |
| 504 | - field: '102121', | |
| 505 | + field: 'interval', | |
| 505 | 506 | componentProps: { |
| 506 | 507 | options: optionsConfig.slice(0, 5), |
| 507 | 508 | }, |
| ... | ... | @@ -509,7 +510,7 @@ export const formSchema: QFormSchema[] = [ |
| 509 | 510 | } else if (Number(e) == 600000) { |
| 510 | 511 | //10分钟以内 -> 5秒 10 15 30 1分钟 |
| 511 | 512 | updateSchema({ |
| 512 | - field: '102121', | |
| 513 | + field: 'interval', | |
| 513 | 514 | componentProps: { |
| 514 | 515 | options: optionsConfig.slice(1, 2).concat(optionsConfig.slice(2, 6)), |
| 515 | 516 | }, |
| ... | ... | @@ -517,7 +518,7 @@ export const formSchema: QFormSchema[] = [ |
| 517 | 518 | } else if (Number(e) == 900000 || Number(e) == 1800000) { |
| 518 | 519 | //15 30 分钟以内 -> 5秒 10 15 30 1分钟 2分钟 |
| 519 | 520 | updateSchema({ |
| 520 | - field: '102121', | |
| 521 | + field: 'interval', | |
| 521 | 522 | componentProps: { |
| 522 | 523 | options: optionsConfig.slice(1, 2).concat(optionsConfig.slice(2, 7)), |
| 523 | 524 | }, |
| ... | ... | @@ -525,7 +526,7 @@ export const formSchema: QFormSchema[] = [ |
| 525 | 526 | } else if (Number(e) == 3600000) { |
| 526 | 527 | //1小时以内 -> 10秒 15 30 1分钟 2分钟 5分钟 |
| 527 | 528 | updateSchema({ |
| 528 | - field: '102121', | |
| 529 | + field: 'interval', | |
| 529 | 530 | componentProps: { |
| 530 | 531 | options: optionsConfig.slice(2, 8), |
| 531 | 532 | }, |
| ... | ... | @@ -533,7 +534,7 @@ export const formSchema: QFormSchema[] = [ |
| 533 | 534 | } else if (Number(e) == 7200000) { |
| 534 | 535 | //2小时以内 -> 15秒 30 1分钟 2分钟 5分钟 10 15 |
| 535 | 536 | updateSchema({ |
| 536 | - field: '102121', | |
| 537 | + field: 'interval', | |
| 537 | 538 | componentProps: { |
| 538 | 539 | options: optionsConfig.slice(3, 10), |
| 539 | 540 | }, |
| ... | ... | @@ -541,7 +542,7 @@ export const formSchema: QFormSchema[] = [ |
| 541 | 542 | } else if (Number(e) == 18000000) { |
| 542 | 543 | //5小时以内 -> 1分钟 2分钟 5分钟 10 15 30 |
| 543 | 544 | updateSchema({ |
| 544 | - field: '102121', | |
| 545 | + field: 'interval', | |
| 545 | 546 | componentProps: { |
| 546 | 547 | options: optionsConfig.slice(5, 11), |
| 547 | 548 | }, |
| ... | ... | @@ -549,7 +550,7 @@ export const formSchema: QFormSchema[] = [ |
| 549 | 550 | } else if (Number(e) == 36000000 || Number(e) == 43200000) { |
| 550 | 551 | //10 12小时以内 -> 2分钟 5分钟 10 15 30 1小时 |
| 551 | 552 | updateSchema({ |
| 552 | - field: '102121', | |
| 553 | + field: 'interval', | |
| 553 | 554 | componentProps: { |
| 554 | 555 | options: optionsConfig.slice(6, 12), |
| 555 | 556 | }, |
| ... | ... | @@ -557,7 +558,7 @@ export const formSchema: QFormSchema[] = [ |
| 557 | 558 | } else if (Number(e) == 86400000) { |
| 558 | 559 | //1天以内 -> 5分钟 10 15 30 1小时 2 |
| 559 | 560 | updateSchema({ |
| 560 | - field: '102121', | |
| 561 | + field: 'interval', | |
| 561 | 562 | componentProps: { |
| 562 | 563 | options: optionsConfig.slice(7, 13), |
| 563 | 564 | }, |
| ... | ... | @@ -565,7 +566,7 @@ export const formSchema: QFormSchema[] = [ |
| 565 | 566 | } else if (Number(e) == 604800000) { |
| 566 | 567 | //7天以内 -> 30分钟 1小时 2 5 10 12 1天 |
| 567 | 568 | updateSchema({ |
| 568 | - field: '102121', | |
| 569 | + field: 'interval', | |
| 569 | 570 | componentProps: { |
| 570 | 571 | options: optionsConfig.slice(10, 17), |
| 571 | 572 | }, |
| ... | ... | @@ -573,7 +574,7 @@ export const formSchema: QFormSchema[] = [ |
| 573 | 574 | } else if (Number(e) == 2592000000) { |
| 574 | 575 | //30天以内 -> 2小时 5 10 12 1天 |
| 575 | 576 | updateSchema({ |
| 576 | - field: '102121', | |
| 577 | + field: 'interval', | |
| 577 | 578 | componentProps: { |
| 578 | 579 | options: optionsConfig.slice(12, 17), |
| 579 | 580 | }, |
| ... | ... | @@ -594,18 +595,18 @@ export const formSchema: QFormSchema[] = [ |
| 594 | 595 | isCountAll(values.agg), |
| 595 | 596 | }, |
| 596 | 597 | { |
| 597 | - field: '102121', | |
| 598 | + field: 'interval', | |
| 598 | 599 | label: '间隔时间', |
| 599 | 600 | required: true, |
| 600 | 601 | component: 'Select', |
| 601 | 602 | colProps: { span: 24 }, |
| 602 | - defaultValue: '1000', | |
| 603 | + defaultValue: 1000, | |
| 603 | 604 | componentProps: { |
| 604 | 605 | placeholder: '请选择间隔时间', |
| 605 | 606 | options: [ |
| 606 | 607 | { |
| 607 | 608 | label: '1秒', |
| 608 | - value: '1000', | |
| 609 | + value: 1000, | |
| 609 | 610 | }, |
| 610 | 611 | ], |
| 611 | 612 | }, | ... | ... |
| ... | ... | @@ -7,33 +7,20 @@ |
| 7 | 7 | <a-input |
| 8 | 8 | :disabled="true" |
| 9 | 9 | placeholder="设备" |
| 10 | - v-model:value="param.key" | |
| 10 | + v-model:value="param.device" | |
| 11 | 11 | style="width: 38%; margin-bottom: 5px; margin-left: 1vh" |
| 12 | 12 | @change="emitChange" |
| 13 | 13 | /> |
| 14 | 14 | <Select |
| 15 | 15 | placeholder="请选择设备属性" |
| 16 | - v-model:value="param.dataType" | |
| 16 | + v-model:value="param.attribute" | |
| 17 | 17 | style="width: 160px; margin-left: 1.8vw" |
| 18 | 18 | :options="selectOptions" |
| 19 | 19 | @change="emitChange" |
| 20 | 20 | /> |
| 21 | - <MinusCircleOutlined | |
| 22 | - v-if="dynamicInput.params.length > min" | |
| 23 | - class="dynamic-delete-button" | |
| 24 | - @click="remove(param)" | |
| 25 | - style="width: 50px; display: none" | |
| 26 | - /> | |
| 27 | - </div> | |
| 28 | - <div style="display: none"> | |
| 29 | - <a-button type="text" style="width: 28%; margin-top: 0.25vh" @click="add"> | |
| 30 | - <PlusCircleOutlined /> | |
| 31 | - Add mapping | |
| 32 | - </a-button> | |
| 33 | 21 | </div> |
| 34 | 22 | </template> |
| 35 | 23 | <script lang="ts"> |
| 36 | - import { MinusCircleOutlined, PlusCircleOutlined } from '@ant-design/icons-vue'; | |
| 37 | 24 | import { defineComponent, reactive, UnwrapRef, watchEffect, ref } from 'vue'; |
| 38 | 25 | import { propTypes } from '/@/utils/propTypes'; |
| 39 | 26 | import { SelectTypes } from 'ant-design-vue/es/select'; |
| ... | ... | @@ -43,63 +30,60 @@ |
| 43 | 30 | |
| 44 | 31 | interface Params { |
| 45 | 32 | [x: string]: string; |
| 46 | - dataType: string; | |
| 47 | - key: string; | |
| 33 | + attribute: string; | |
| 34 | + device: string; | |
| 48 | 35 | } |
| 49 | 36 | |
| 50 | 37 | export default defineComponent({ |
| 51 | 38 | name: 'JAddInput', |
| 52 | 39 | components: { |
| 53 | - MinusCircleOutlined, | |
| 54 | - PlusCircleOutlined, | |
| 55 | 40 | Select, |
| 56 | 41 | }, |
| 57 | 42 | //--------------不继承Antd Design Vue Input的所有属性 否则控制台报大片警告-------------- |
| 58 | 43 | inheritAttrs: false, |
| 59 | 44 | props: { |
| 60 | 45 | value: propTypes.array.def([]), |
| 61 | - //自定义删除按钮多少才会显示 | |
| 62 | - min: propTypes.integer.def(0), | |
| 63 | 46 | orgId: propTypes.string.def(''), |
| 47 | + isEdit: propTypes.bool.def(false), | |
| 64 | 48 | }, |
| 65 | 49 | emits: ['change', 'update:value', 'dynamicReduceHeight', 'dynamicAddHeight'], |
| 66 | 50 | setup(props, { emit }) { |
| 67 | 51 | const selectOptions = ref<SelectTypes['options']>([]); |
| 68 | - | |
| 69 | 52 | //input动态数据 |
| 70 | 53 | const dynamicInput: UnwrapRef<{ params: Params[] }> = reactive({ params: [] }); |
| 71 | - //删除Input | |
| 72 | - const remove = (item: Params) => { | |
| 73 | - let index = dynamicInput.params.indexOf(item); | |
| 74 | - if (index !== -1) { | |
| 75 | - dynamicInput.params.splice(index, 1); | |
| 76 | - } | |
| 77 | - emitChange(); | |
| 78 | - emit('dynamicReduceHeight'); | |
| 79 | - }; | |
| 80 | - | |
| 81 | - //新增Input | |
| 82 | - const add = () => { | |
| 83 | - dynamicInput.params.push({ | |
| 84 | - dataType: 'STRING', | |
| 85 | - key: '', | |
| 86 | - }); | |
| 87 | - emitChange(); | |
| 88 | - emit('dynamicAddHeight'); | |
| 89 | - }; | |
| 90 | - | |
| 91 | 54 | //监听传入数据value |
| 92 | 55 | watchEffect(() => { |
| 93 | 56 | initVal(); |
| 94 | 57 | }); |
| 95 | - | |
| 96 | 58 | /** |
| 97 | 59 | * 初始化数值 |
| 98 | 60 | */ |
| 99 | 61 | async function initVal() { |
| 100 | 62 | dynamicInput.params = []; |
| 101 | - if (props.value) { | |
| 102 | - if (props.orgId) { | |
| 63 | + if (props.isEdit) { | |
| 64 | + console.log('edit'); | |
| 65 | + let jsonObj = props.value; | |
| 66 | + let deviceIdArr: any = []; | |
| 67 | + jsonObj.forEach((item: Params) => { | |
| 68 | + dynamicInput.params.push({ | |
| 69 | + attribute: item.attribute, | |
| 70 | + device: item.name, | |
| 71 | + value: item.device, | |
| 72 | + }); | |
| 73 | + deviceIdArr.push(item.device); | |
| 74 | + }); | |
| 75 | + if (deviceIdArr.length > 0) { | |
| 76 | + const res = await getAttribute(props.orgId, deviceIdArr.join(',')); | |
| 77 | + selectOptions.value = res.map((o) => { | |
| 78 | + return { | |
| 79 | + label: o, | |
| 80 | + value: o, | |
| 81 | + }; | |
| 82 | + }); | |
| 83 | + } | |
| 84 | + } else { | |
| 85 | + console.log('add'); | |
| 86 | + if (props.value && props.orgId) { | |
| 103 | 87 | const res = await getAttribute(props.orgId, props.value.join(',')); |
| 104 | 88 | selectOptions.value = res.map((o) => { |
| 105 | 89 | return { |
| ... | ... | @@ -130,8 +114,8 @@ |
| 130 | 114 | let jsonObj = temp; |
| 131 | 115 | jsonObj.forEach((item: Params) => { |
| 132 | 116 | dynamicInput.params.push({ |
| 133 | - dataType: item.dataType, | |
| 134 | - key: item.label, | |
| 117 | + attribute: item.attribute, | |
| 118 | + device: item.label, | |
| 135 | 119 | value: item.value, |
| 136 | 120 | }); |
| 137 | 121 | }); |
| ... | ... | @@ -146,21 +130,17 @@ |
| 146 | 130 | if (dynamicInput.params.length > 0) { |
| 147 | 131 | dynamicInput.params.forEach((item: Params) => { |
| 148 | 132 | obj.push({ |
| 149 | - attr: item.dataType, | |
| 150 | - tbDeviceId: item.value, | |
| 133 | + attribute: item.attribute, | |
| 134 | + device: item.value, | |
| 151 | 135 | }); |
| 152 | 136 | }); |
| 153 | 137 | } |
| 154 | - console.log('数值改变', obj); | |
| 155 | 138 | emit('change', obj); |
| 156 | 139 | emit('update:value', obj); |
| 157 | 140 | } |
| 158 | - | |
| 159 | 141 | return { |
| 160 | 142 | dynamicInput, |
| 161 | 143 | emitChange, |
| 162 | - remove, | |
| 163 | - add, | |
| 164 | 144 | selectOptions, |
| 165 | 145 | }; |
| 166 | 146 | }, | ... | ... |
| ... | ... | @@ -46,6 +46,16 @@ |
| 46 | 46 | ]" |
| 47 | 47 | /> |
| 48 | 48 | </template> |
| 49 | + <template #status="{ record }"> | |
| 50 | + <Switch | |
| 51 | + :disabled="disabledSwitch" | |
| 52 | + :checked="record.status === 1" | |
| 53 | + :loading="record.pendingStatus" | |
| 54 | + checkedChildren="启用" | |
| 55 | + unCheckedChildren="禁用" | |
| 56 | + @change="(checked:boolean)=>statusChange(checked,record)" | |
| 57 | + /> | |
| 58 | + </template> | |
| 49 | 59 | </BasicTable> |
| 50 | 60 | <ReportConfigDrawer @register="registerDrawer" @success="handleSuccess" /> |
| 51 | 61 | <DevicePreviewModal @register="registerModal" /> |
| ... | ... | @@ -53,21 +63,26 @@ |
| 53 | 63 | </template> |
| 54 | 64 | |
| 55 | 65 | <script lang="ts" setup> |
| 56 | - import { reactive, nextTick } from 'vue'; | |
| 66 | + import { reactive, nextTick, ref } from 'vue'; | |
| 57 | 67 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
| 58 | 68 | import { useDrawer } from '/@/components/Drawer'; |
| 59 | 69 | import ReportConfigDrawer from './ReportConfigDrawer.vue'; |
| 60 | 70 | import DevicePreviewModal from './DevicePreviewModal.vue'; |
| 61 | - import { reportPage, deleteReportManage } from '/@/api/report/reportManager'; | |
| 71 | + import { | |
| 72 | + reportPage, | |
| 73 | + deleteReportManage, | |
| 74 | + putReportByidAndStatusManage, | |
| 75 | + } from '/@/api/report/reportManager'; | |
| 62 | 76 | import { searchFormSchema, columns } from './config.data'; |
| 63 | 77 | import { Authority } from '/@/components/Authority'; |
| 64 | 78 | import { useBatchDelete } from '/@/hooks/web/useBatchDelete'; |
| 65 | - import { Popconfirm } from 'ant-design-vue'; | |
| 79 | + import { Popconfirm, Switch } from 'ant-design-vue'; | |
| 66 | 80 | import { useModal } from '/@/components/Modal'; |
| 67 | 81 | import { useGo } from '/@/hooks/web/usePage'; |
| 82 | + import { useMessage } from '/@/hooks/web/useMessage'; | |
| 68 | 83 | |
| 69 | 84 | const searchInfo = reactive<Recordable>({}); |
| 70 | - | |
| 85 | + const disabledSwitch = ref(false); | |
| 71 | 86 | const [registerTable, { reload, setProps }] = useTable({ |
| 72 | 87 | title: '报表列表', |
| 73 | 88 | api: reportPage, |
| ... | ... | @@ -77,6 +92,7 @@ |
| 77 | 92 | formConfig: { |
| 78 | 93 | labelWidth: 120, |
| 79 | 94 | schemas: searchFormSchema, |
| 95 | + fieldMapToTime: [['sendTime', ['startTime', 'endTime'], 'YYYY-MM-DD HH:mm:ss']], | |
| 80 | 96 | }, |
| 81 | 97 | useSearchForm: true, |
| 82 | 98 | showTableSetting: true, |
| ... | ... | @@ -93,6 +109,7 @@ |
| 93 | 109 | |
| 94 | 110 | // 弹框 |
| 95 | 111 | const [registerDrawer, { openDrawer }] = useDrawer(); |
| 112 | + const { createMessage } = useMessage(); | |
| 96 | 113 | |
| 97 | 114 | // 刷新 |
| 98 | 115 | const handleSuccess = () => { |
| ... | ... | @@ -131,5 +148,28 @@ |
| 131 | 148 | record, |
| 132 | 149 | }); |
| 133 | 150 | }; |
| 151 | + const statusChange = async (checked, record) => { | |
| 152 | + try { | |
| 153 | + setProps({ | |
| 154 | + loading: true, | |
| 155 | + }); | |
| 156 | + disabledSwitch.value = true; | |
| 157 | + const newStatus = checked ? 1 : 0; | |
| 158 | + const res = await putReportByidAndStatusManage(record.id, newStatus); | |
| 159 | + if (res && newStatus) { | |
| 160 | + createMessage.success(`启用成功`); | |
| 161 | + } else { | |
| 162 | + createMessage.success('禁用成功'); | |
| 163 | + } | |
| 164 | + } finally { | |
| 165 | + setTimeout(() => { | |
| 166 | + setProps({ | |
| 167 | + loading: false, | |
| 168 | + }); | |
| 169 | + disabledSwitch.value = false; | |
| 170 | + }, 500); | |
| 171 | + reload(); | |
| 172 | + } | |
| 173 | + }; | |
| 134 | 174 | const go = useGo(); |
| 135 | 175 | </script> | ... | ... |
| 1 | 1 | interface IOptionConfig { |
| 2 | 2 | label: string; |
| 3 | - value: string; | |
| 3 | + value: number; | |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | export const optionsConfig: IOptionConfig[] = [ |
| 7 | 7 | { |
| 8 | 8 | label: '1秒', |
| 9 | - value: '1000', | |
| 9 | + value: 1000, | |
| 10 | 10 | }, |
| 11 | 11 | { |
| 12 | 12 | label: '5秒', |
| 13 | - value: '5000', | |
| 13 | + value: 5000, | |
| 14 | 14 | }, |
| 15 | 15 | { |
| 16 | 16 | label: '10秒', |
| 17 | - value: '10000', | |
| 17 | + value: 10000, | |
| 18 | 18 | }, |
| 19 | 19 | { |
| 20 | 20 | label: '15秒', |
| 21 | - value: '15000', | |
| 21 | + value: 15000, | |
| 22 | 22 | }, |
| 23 | 23 | { |
| 24 | 24 | label: '30秒', |
| 25 | - value: '30000', | |
| 25 | + value: 30000, | |
| 26 | 26 | }, |
| 27 | 27 | { |
| 28 | 28 | label: '1分钟', |
| 29 | - value: '60000', | |
| 29 | + value: 60000, | |
| 30 | 30 | }, |
| 31 | 31 | { |
| 32 | 32 | label: '2分钟', |
| 33 | - value: '120000', | |
| 33 | + value: 120000, | |
| 34 | 34 | }, |
| 35 | 35 | { |
| 36 | 36 | label: '5分钟', |
| 37 | - value: '300000', | |
| 37 | + value: 300000, | |
| 38 | 38 | }, |
| 39 | 39 | { |
| 40 | 40 | label: '10分钟', |
| 41 | - value: '600000', | |
| 41 | + value: 600000, | |
| 42 | 42 | }, |
| 43 | 43 | { |
| 44 | 44 | label: '15分钟', |
| 45 | - value: '900000', | |
| 45 | + value: 900000, | |
| 46 | 46 | }, |
| 47 | 47 | { |
| 48 | 48 | label: '30分钟', |
| 49 | - value: '1800000', | |
| 49 | + value: 1800000, | |
| 50 | 50 | }, |
| 51 | 51 | { |
| 52 | 52 | label: '1小时', |
| 53 | - value: '3600000', | |
| 53 | + value: 3600000, | |
| 54 | 54 | }, |
| 55 | 55 | { |
| 56 | 56 | label: '2小时', |
| 57 | - value: '7200000', | |
| 57 | + value: 7200000, | |
| 58 | 58 | }, |
| 59 | 59 | { |
| 60 | 60 | label: '5小时', |
| 61 | - value: '18000000', | |
| 61 | + value: 18000000, | |
| 62 | 62 | }, |
| 63 | 63 | { |
| 64 | 64 | label: '10小时', |
| 65 | - value: '36000000', | |
| 65 | + value: 36000000, | |
| 66 | 66 | }, |
| 67 | 67 | { |
| 68 | 68 | label: '12小时', |
| 69 | - value: '43200000', | |
| 69 | + value: 43200000, | |
| 70 | 70 | }, |
| 71 | 71 | { |
| 72 | 72 | label: '1天', |
| 73 | - value: '86400000', | |
| 73 | + value: 86400000, | |
| 74 | 74 | }, |
| 75 | 75 | ]; |
| 76 | 76 | |
| 77 | 77 | export enum TypeEnum { |
| 78 | - IS_TIMING = 0, | |
| 78 | + IS_TIMING = 1, | |
| 79 | 79 | IS_WEEK = 'week', |
| 80 | 80 | IS_MONTH = 'month', |
| 81 | 81 | IS_EMPTY = 'NONE', | ... | ... |
| ... | ... | @@ -201,9 +201,9 @@ |
| 201 | 201 | if (!isJpgOrPng) { |
| 202 | 202 | createMessage.error('只能上传图片文件!'); |
| 203 | 203 | } |
| 204 | - const isLt2M = (file.size as number) / 1024 / 1024 < 5; | |
| 204 | + const isLt2M = (file.size as number) / 1024 / 1024 < 2; | |
| 205 | 205 | if (!isLt2M) { |
| 206 | - createMessage.error('图片大小不能超过5MB!'); | |
| 206 | + createMessage.error('图片大小不能超过2MB!'); | |
| 207 | 207 | } |
| 208 | 208 | return isJpgOrPng && isLt2M; |
| 209 | 209 | }; |
| ... | ... | @@ -234,9 +234,9 @@ |
| 234 | 234 | if (!isJpgOrPng) { |
| 235 | 235 | createMessage.error('只能上传图片文件!'); |
| 236 | 236 | } |
| 237 | - const isLt2M = (file.size as number) / 1024 / 1024 < 5; | |
| 237 | + const isLt2M = (file.size as number) / 1024 / 1024 < 3; | |
| 238 | 238 | if (!isLt2M) { |
| 239 | - createMessage.error('图片大小不能超过5MB!'); | |
| 239 | + createMessage.error('图片大小不能超过3MB!'); | |
| 240 | 240 | } |
| 241 | 241 | return isJpgOrPng && isLt2M; |
| 242 | 242 | }; | ... | ... |