Showing
30 changed files
with
1674 additions
and
1636 deletions
| ... | ... | @@ -69,10 +69,13 @@ export function checkStatus( |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | if (errMessage) { |
| 72 | - if (errorMessageMode === 'modal') { | |
| 73 | - createErrorModal({ title: t('sys.api.errorTip'), content: errMessage }); | |
| 74 | - } else if (errorMessageMode === 'message') { | |
| 72 | + if (errorMessageMode === 'message') { | |
| 75 | 73 | error({ content: errMessage, key: `global_error_message_status_${status}` }); |
| 76 | 74 | } |
| 75 | + // if (errorMessageMode === 'modal') { | |
| 76 | + // createErrorModal({ title: t('sys.api.errorTip'), content: errMessage }); | |
| 77 | + // } else if (errorMessageMode === 'message') { | |
| 78 | + // error({ content: errMessage, key: `global_error_message_status_${status}` }); | |
| 79 | + // } | |
| 77 | 80 | } |
| 78 | 81 | } | ... | ... |
| ... | ... | @@ -4,6 +4,35 @@ import { Rule } from 'ant-design-vue/lib/form/interface'; |
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | +//正整数并且可以是英文 | |
| 8 | +export const numberAndEngLishRule: Rule[] = [ | |
| 9 | + { | |
| 10 | + validator: (_, value: string) => { | |
| 11 | + const reg1 = /^[0-9]*[1-9][0-9]*$/; | |
| 12 | + const reg2 = /^[A-Za-z0-9]+$/; | |
| 13 | + if (!reg1.test(value) && !reg2.test(value)) { | |
| 14 | + return Promise.reject('不能为负数'); | |
| 15 | + } | |
| 16 | + return Promise.resolve(); | |
| 17 | + }, | |
| 18 | + validateTrigger: 'blur', | |
| 19 | + }, | |
| 20 | +]; | |
| 21 | + | |
| 22 | +//数字和非负数 | |
| 23 | +export const numberAndNonegativeRule: Rule[] = [ | |
| 24 | + { | |
| 25 | + validator: (_, value: string) => { | |
| 26 | + const reg = /^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d+)$/; | |
| 27 | + if (!reg.test(value)) { | |
| 28 | + return Promise.reject('不能为负数或者不能输入非数字'); | |
| 29 | + } | |
| 30 | + return Promise.resolve(); | |
| 31 | + }, | |
| 32 | + validateTrigger: 'blur', | |
| 33 | + }, | |
| 34 | +]; | |
| 35 | + | |
| 7 | 36 | // 数字验证 |
| 8 | 37 | export const numberRule: Rule[] = [ |
| 9 | 38 | { | ... | ... |
| ... | ... | @@ -10,7 +10,9 @@ |
| 10 | 10 | baseColProps: { |
| 11 | 11 | span: 5, |
| 12 | 12 | }, |
| 13 | - fieldMapToTime: [[SchemaFiled.DATE_RANGE, [SchemaFiled.START_TS, SchemaFiled.END_TS]]], | |
| 13 | + fieldMapToTime: [ | |
| 14 | + [SchemaFiled.DATE_RANGE, [SchemaFiled.START_TS, SchemaFiled.END_TS], 'YYYY-MM-DD HH:mm:ss'], | |
| 15 | + ], | |
| 14 | 16 | }); |
| 15 | 17 | onMounted(() => { |
| 16 | 18 | emit('register', method); | ... | ... |
| 1 | -import { Moment } from 'moment'; | |
| 1 | +import moment, { Moment } from 'moment'; | |
| 2 | 2 | import { getPacketIntervalByRange, getPacketIntervalByValue, intervalOption } from './helper'; |
| 3 | 3 | import { FormSchema } from '/@/components/Form'; |
| 4 | 4 | import { ColEx } from '/@/components/Form/src/types'; |
| ... | ... | @@ -86,7 +86,9 @@ export const defaultSchemas: FormSchema[] = [ |
| 86 | 86 | const { setFieldsValue } = formActionType; |
| 87 | 87 | let dates: Moment[] = []; |
| 88 | 88 | return { |
| 89 | - showTime: true, | |
| 89 | + showTime: { | |
| 90 | + defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')], | |
| 91 | + }, | |
| 90 | 92 | onCalendarChange(value: Moment[]) { |
| 91 | 93 | dates = value; |
| 92 | 94 | }, | ... | ... |
| ... | ... | @@ -112,7 +112,7 @@ |
| 112 | 112 | const wrapRef = ref<HTMLDivElement | null>(null); |
| 113 | 113 | const chartRef = ref<HTMLDivElement | null>(null); |
| 114 | 114 | const deviceAttrs = ref<string[]>([]); |
| 115 | - const { setOptions, getInstance, resize } = useECharts(chartRef as Ref<HTMLDivElement>); | |
| 115 | + const { setOptions, getInstance } = useECharts(chartRef as Ref<HTMLDivElement>); | |
| 116 | 116 | const isNull = ref(true); |
| 117 | 117 | const { toPromise } = useScript({ src: BAI_DU_MAP_URL }); |
| 118 | 118 | const [registerDetailDrawer, { openDrawer }] = useDrawer(); |
| ... | ... | @@ -141,9 +141,25 @@ |
| 141 | 141 | const BMap = (window as any).BMap; |
| 142 | 142 | if (!wrapEl) return; |
| 143 | 143 | const map = new BMap.Map(wrapEl); |
| 144 | - const point = new BMap.Point(104.04666605565338, 30.543516387560476); | |
| 145 | - map.centerAndZoom(point, 15); | |
| 146 | - map.enableScrollWheelZoom(true); | |
| 144 | + | |
| 145 | + const getLocation = new BMap.Geolocation(); | |
| 146 | + getLocation.getCurrentPosition((position) => { | |
| 147 | + if (position) { | |
| 148 | + let preMarker = null; | |
| 149 | + const point = new BMap.Point(position.point.lng, position.point.lat); | |
| 150 | + let marker = new BMap.Marker(point, { size: 30 }); | |
| 151 | + if (marker) { | |
| 152 | + map.removeOverlay(preMarker); | |
| 153 | + } | |
| 154 | + map.addOverlay(marker); | |
| 155 | + map.centerAndZoom(point, 15); | |
| 156 | + map.enableScrollWheelZoom(true); | |
| 157 | + } else { | |
| 158 | + const point = new BMap.Point(104.04666605565338, 30.543516387560476); | |
| 159 | + map.centerAndZoom(point, 15); | |
| 160 | + map.enableScrollWheelZoom(true); | |
| 161 | + } | |
| 162 | + }); | |
| 147 | 163 | } |
| 148 | 164 | // 点击表格某一行触发 |
| 149 | 165 | const deviceRowClick = async (record) => { |
| ... | ... | @@ -254,7 +270,6 @@ |
| 254 | 270 | // 发送请求 |
| 255 | 271 | loading.value = true; |
| 256 | 272 | const res = await getDeviceHistoryInfo(searchParams); |
| 257 | - loading.value = false; | |
| 258 | 273 | // 判断数据对象是否为空 |
| 259 | 274 | if (!Object.keys(res).length) { |
| 260 | 275 | isNull.value = false; |
| ... | ... | @@ -263,6 +278,7 @@ |
| 263 | 278 | isNull.value = true; |
| 264 | 279 | } |
| 265 | 280 | setChartOptions(res, value.keys); |
| 281 | + loading.value = false; | |
| 266 | 282 | }, |
| 267 | 283 | }); |
| 268 | 284 | |
| ... | ... | @@ -316,7 +332,6 @@ |
| 316 | 332 | startTs: Date.now() - 1 * 24 * 60 * 60 * 1000, |
| 317 | 333 | endTs: Date.now(), |
| 318 | 334 | agg: AggregateDataEnum.NONE, |
| 319 | - limit: 7, | |
| 320 | 335 | }); |
| 321 | 336 | |
| 322 | 337 | // 判断对象是否为空 |
| ... | ... | @@ -356,7 +371,6 @@ |
| 356 | 371 | data: dataArray.filter((item1) => item1[2] === item), |
| 357 | 372 | }; |
| 358 | 373 | }); |
| 359 | - resize(); | |
| 360 | 374 | // 设置数据 |
| 361 | 375 | setOptions(eChartOptions(series, keys)); |
| 362 | 376 | } |
| ... | ... | @@ -403,10 +417,12 @@ |
| 403 | 417 | <style scoped lang="less"> |
| 404 | 418 | .wrapper { |
| 405 | 419 | position: relative; |
| 420 | + | |
| 406 | 421 | :deep(.BMap_shadow) { |
| 407 | 422 | display: none; |
| 408 | 423 | } |
| 409 | 424 | } |
| 425 | + | |
| 410 | 426 | .right-wrap { |
| 411 | 427 | padding-top: 10px; |
| 412 | 428 | width: 28%; | ... | ... |
| 1 | 1 | <template> |
| 2 | 2 | <div> |
| 3 | - <BasicModal | |
| 4 | - v-bind="$attrs" | |
| 5 | - width="55rem" | |
| 6 | - @register="register" | |
| 7 | - :title="getTitle" | |
| 8 | - @ok="handleSubmit" | |
| 9 | - @cancel="handleCancel" | |
| 10 | - :showOkBtn="isShowOkBtnFalse" | |
| 11 | - > | |
| 3 | + <BasicModal v-bind="$attrs" width="55rem" @register="register" :title="getTitle" @ok="handleSubmit" | |
| 4 | + @cancel="handleCancel" :showOkBtn="isShowOkBtnFalse"> | |
| 12 | 5 | <div class="step-form-form"> |
| 13 | 6 | <a-steps :current="current"> |
| 14 | 7 | <a-step title="设备配置" /> |
| ... | ... | @@ -18,281 +11,289 @@ |
| 18 | 11 | <div class="mt-5"> |
| 19 | 12 | <!-- 设备配置 --> |
| 20 | 13 | <div v-show="current === 0"> |
| 21 | - <DeviceProfileStep1 ref="DeviceProfileStep1Ref" @next="handleStepNext1" | |
| 22 | - /></div> | |
| 14 | + <DeviceProfileStep1 ref="DeviceProfileStep1Ref" @next="handleStepNext1" /> | |
| 15 | + </div> | |
| 23 | 16 | <!-- 设备配置 --> |
| 24 | 17 | <!-- 传输配置 --> |
| 25 | 18 | <div v-show="current === 1"> |
| 26 | - <DeviceProfileStep2 ref="DeviceProfileStep2Ref" @prev="handleStepPrev" | |
| 27 | - /></div> | |
| 19 | + <DeviceProfileStep2 ref="DeviceProfileStep2Ref" @prev="handleStepPrev" /> | |
| 20 | + </div> | |
| 28 | 21 | <!-- 传输配置 --> |
| 29 | 22 | </div> |
| 30 | 23 | </BasicModal> |
| 31 | 24 | </div> |
| 32 | 25 | </template> |
| 33 | 26 | <script lang="ts"> |
| 34 | - import { | |
| 35 | - defineComponent, | |
| 36 | - nextTick, | |
| 37 | - ref, | |
| 38 | - computed, | |
| 39 | - unref, | |
| 40 | - getCurrentInstance, | |
| 41 | - reactive, | |
| 42 | - } from 'vue'; | |
| 43 | - import { BasicModal, useModalInner } from '/@/components/Modal'; | |
| 44 | - import DeviceProfileStep1 from '/@/views/device/profiles/step/DeviceProfileStep1.vue'; | |
| 45 | - import DeviceProfileStep2 from '/@/views/device/profiles/step/DeviceProfileStep2.vue'; | |
| 46 | - import { Steps } from 'ant-design-vue'; | |
| 47 | - import { deviceConfigAddOrEdit, deviceConfigGetDetail } from '/@/api/device/deviceConfigApi'; | |
| 48 | - import { useMessage } from '/@/hooks/web/useMessage'; | |
| 27 | +import { | |
| 28 | + defineComponent, | |
| 29 | + nextTick, | |
| 30 | + ref, | |
| 31 | + computed, | |
| 32 | + unref, | |
| 33 | + getCurrentInstance, | |
| 34 | + reactive, | |
| 35 | +} from 'vue'; | |
| 36 | +import { BasicModal, useModalInner } from '/@/components/Modal'; | |
| 37 | +import DeviceProfileStep1 from '/@/views/device/profiles/step/DeviceProfileStep1.vue'; | |
| 38 | +import DeviceProfileStep2 from '/@/views/device/profiles/step/DeviceProfileStep2.vue'; | |
| 39 | +import { Steps } from 'ant-design-vue'; | |
| 40 | +import { deviceConfigAddOrEdit, deviceConfigGetDetail } from '/@/api/device/deviceConfigApi'; | |
| 41 | +import { useMessage } from '/@/hooks/web/useMessage'; | |
| 42 | + | |
| 43 | +export default defineComponent({ | |
| 44 | + name: 'DeviceModal', | |
| 45 | + components: { | |
| 46 | + BasicModal, | |
| 47 | + DeviceProfileStep1, | |
| 48 | + DeviceProfileStep2, | |
| 49 | + [Steps.name]: Steps, | |
| 50 | + [Steps.Step.name]: Steps.Step, | |
| 51 | + }, | |
| 52 | + props: { | |
| 53 | + userData: { type: Object }, | |
| 54 | + }, | |
| 55 | + emits: ['success', 'register', 'handleStepPrev', 'handleStep3Next', 'handleRedo'], | |
| 56 | + setup(_, { emit }) { | |
| 57 | + const { proxy } = getCurrentInstance() as any; | |
| 58 | + const DeviceProfileStep1Ref = ref(null); | |
| 59 | + const DeviceProfileStep2Ref = ref(null); | |
| 60 | + const { createMessage } = useMessage(); | |
| 61 | + let postDeviceConfogData: any = reactive({}); | |
| 62 | + let getStepOneData: any = reactive({}); | |
| 63 | + let getStepTwoData: any = reactive({}); | |
| 64 | + const editData: any = ref({}); | |
| 65 | + const postEditId = ref(''); | |
| 66 | + const createTime = ref(''); | |
| 67 | + const current = ref(0); | |
| 68 | + const isUpdate = ref(0); | |
| 69 | + const isShowOkBtnFalse = ref(true); | |
| 70 | + const isNextStatus = ref(false); | |
| 71 | + let transportTypeObj = reactive({ | |
| 72 | + transportType: '', | |
| 73 | + }); | |
| 74 | + let profileDataObj: any = reactive({ | |
| 75 | + profileData: null, | |
| 76 | + }); | |
| 77 | + let isEdit = ref(true); | |
| 78 | + let noEditObj: any = reactive({}); | |
| 79 | + const getTitle = computed(() => | |
| 80 | + isUpdate.value == 1 ? '新增设备配置' : isUpdate.value == 2 ? '编辑设备配置' : '设备配置详情' | |
| 81 | + ); | |
| 82 | + const editTransportType = ref(''); | |
| 83 | + const getViewTitle = computed(() => (!unref(isShowOkBtnFalse) ? '设备配置详情' : '')); | |
| 84 | + const [register, { closeModal }] = useModalInner(async (data) => { | |
| 85 | + isUpdate.value = data.isUpdate; | |
| 86 | + if (isUpdate.value == 1) { | |
| 87 | + handleCancel(); | |
| 88 | + isShowOkBtnFalse.value = true; | |
| 89 | + current.value = 0; | |
| 90 | + isEdit.value = false; | |
| 91 | + proxy.$refs.DeviceProfileStep1Ref.editOrAddNameStatus(false) | |
| 92 | + } else if (isUpdate.value == 2) { | |
| 93 | + isEdit.value = true; | |
| 94 | + handleCancel(); | |
| 95 | + isShowOkBtnFalse.value = true; | |
| 96 | + current.value = 0; | |
| 97 | + postEditId.value = data.record.id; | |
| 98 | + createTime.value = data.record.createTime; | |
| 99 | + editTransportType.value = data.record.transportType; | |
| 100 | + editData.value = await deviceConfigGetDetail(postEditId.value); | |
| 101 | + proxy.$refs.DeviceProfileStep1Ref.setStepOneFieldsValueFunc({ | |
| 102 | + name: editData.value.name, | |
| 103 | + defaultRuleChainId: editData.value.defaultRuleChainId, | |
| 104 | + defaultQueueName: editData.value.defaultQueueName, | |
| 105 | + description: editData.value.description, | |
| 106 | + image: editData.value.image, | |
| 107 | + }); | |
| 108 | + if (editData.value.default) { | |
| 109 | + proxy.$refs.DeviceProfileStep1Ref.editOrAddNameStatus(true) | |
| 110 | + | |
| 111 | + } else { | |
| 112 | + proxy.$refs.DeviceProfileStep1Ref.editOrAddNameStatus(false) | |
| 49 | 113 | |
| 50 | - export default defineComponent({ | |
| 51 | - name: 'DeviceModal', | |
| 52 | - components: { | |
| 53 | - BasicModal, | |
| 54 | - DeviceProfileStep1, | |
| 55 | - DeviceProfileStep2, | |
| 56 | - [Steps.name]: Steps, | |
| 57 | - [Steps.Step.name]: Steps.Step, | |
| 58 | - }, | |
| 59 | - props: { | |
| 60 | - userData: { type: Object }, | |
| 61 | - }, | |
| 62 | - emits: ['success', 'register', 'handleStepPrev', 'handleStep3Next', 'handleRedo'], | |
| 63 | - setup(_, { emit }) { | |
| 64 | - const { proxy } = getCurrentInstance() as any; | |
| 65 | - const DeviceProfileStep1Ref = ref(null); | |
| 66 | - const DeviceProfileStep2Ref = ref(null); | |
| 67 | - const { createMessage } = useMessage(); | |
| 68 | - let postDeviceConfogData: any = reactive({}); | |
| 69 | - let getStepOneData: any = reactive({}); | |
| 70 | - let getStepTwoData: any = reactive({}); | |
| 71 | - const editData: any = ref({}); | |
| 72 | - const postEditId = ref(''); | |
| 73 | - const createTime = ref(''); | |
| 74 | - const current = ref(0); | |
| 75 | - const isUpdate = ref(0); | |
| 76 | - const isShowOkBtnFalse = ref(true); | |
| 77 | - const isNextStatus = ref(false); | |
| 78 | - let transportTypeObj = reactive({ | |
| 79 | - transportType: '', | |
| 80 | - }); | |
| 81 | - let profileDataObj: any = reactive({ | |
| 82 | - profileData: null, | |
| 83 | - }); | |
| 84 | - let isEdit = ref(true); | |
| 85 | - let noEditObj: any = reactive({}); | |
| 86 | - const getTitle = computed(() => | |
| 87 | - isUpdate.value == 1 ? '新增设备配置' : isUpdate.value == 2 ? '编辑设备配置' : '设备配置详情' | |
| 88 | - ); | |
| 89 | - const editTransportType = ref(''); | |
| 90 | - const getViewTitle = computed(() => (!unref(isShowOkBtnFalse) ? '设备配置详情' : '')); | |
| 91 | - const [register, { closeModal }] = useModalInner(async (data) => { | |
| 92 | - isUpdate.value = data.isUpdate; | |
| 93 | - if (isUpdate.value == 1) { | |
| 94 | - handleCancel(); | |
| 95 | - isShowOkBtnFalse.value = true; | |
| 96 | - current.value = 0; | |
| 97 | - isEdit.value = false; | |
| 98 | - } else if (isUpdate.value == 2) { | |
| 99 | - isEdit.value = true; | |
| 100 | - handleCancel(); | |
| 101 | - isShowOkBtnFalse.value = true; | |
| 102 | - current.value = 0; | |
| 103 | - postEditId.value = data.record.id; | |
| 104 | - createTime.value = data.record.createTime; | |
| 105 | - editTransportType.value = data.record.transportType; | |
| 106 | - editData.value = await deviceConfigGetDetail(postEditId.value); | |
| 107 | - proxy.$refs.DeviceProfileStep1Ref.setStepOneFieldsValueFunc({ | |
| 108 | - name: editData.value.name, | |
| 109 | - defaultRuleChainId: editData.value.defaultRuleChainId, | |
| 110 | - defaultQueueName: editData.value.defaultQueueName, | |
| 111 | - description: editData.value.description, | |
| 112 | - image: editData.value.image, | |
| 113 | - }); | |
| 114 | - noEditObj = { | |
| 115 | - id: editData.value.id, | |
| 116 | - name: editData.value?.name, | |
| 117 | - createTime: createTime.value, | |
| 118 | - transportType: editTransportType.value, | |
| 119 | - type: editData.value?.type, | |
| 120 | - profileData: editData.value?.profileData, | |
| 121 | - defaultQueueName: editData.value.defaultQueueName, | |
| 122 | - image: editData.value.image, | |
| 123 | - defaultRuleChainId: editData.value.defaultRuleChainId, | |
| 124 | - description: editData.value.description, | |
| 125 | - tenantId: editData.value.tenantId, | |
| 126 | - }; | |
| 127 | - } else if (isUpdate.value == 3) { | |
| 128 | - handleCancel(); | |
| 129 | - isShowOkBtnFalse.value = false; | |
| 130 | - current.value = 0; | |
| 131 | - postEditId.value = data.record.id; | |
| 132 | - createTime.value = data.record.createTime; | |
| 133 | - editData.value = await deviceConfigGetDetail(postEditId.value); | |
| 134 | - proxy.$refs.DeviceProfileStep1Ref.setStepOneFieldsValueFunc({ | |
| 135 | - name: editData.value.name, | |
| 136 | - defaultRuleChainId: editData.value.defaultRuleChainId, | |
| 137 | - defaultQueueName: editData.value.defaultQueueName, | |
| 138 | - description: editData.value.description, | |
| 139 | - image: editData.value.image, | |
| 140 | - }); | |
| 141 | - } | |
| 142 | - }); | |
| 143 | - function handleStepPrev() { | |
| 144 | - current.value--; | |
| 145 | - if (isUpdate.value == 2) { | |
| 146 | - isEdit.value = true; | |
| 147 | - noEditObj = { | |
| 148 | - id: editData.value.id, | |
| 149 | - name: editData.value?.name, | |
| 150 | - createTime: createTime.value, | |
| 151 | - transportType: editTransportType.value, | |
| 152 | - type: editData.value?.type, | |
| 153 | - profileData: editData.value?.profileData, | |
| 154 | - defaultQueueName: editData.value.defaultQueueName, | |
| 155 | - image: editData.value.image, | |
| 156 | - defaultRuleChainId: editData.value.defaultRuleChainId, | |
| 157 | - description: editData.value.description, | |
| 158 | - tenantId: editData.value.tenantId, | |
| 159 | - }; | |
| 160 | - nextTick(async () => { | |
| 161 | - let getPic = null; | |
| 162 | - const getStep1Obj = await proxy.$refs.DeviceProfileStep1Ref?.getStep1Func(); | |
| 163 | - getPic = getStep1Obj.icon; | |
| 164 | - Object.assign(noEditObj, { image: getPic }, getStep1Obj.key); | |
| 165 | - }); | |
| 166 | - } | |
| 167 | - } | |
| 168 | - //第一步 | |
| 169 | - function handleStepNext1(v, v1) { | |
| 170 | - isNextStatus.value = true; | |
| 171 | - if (isNextStatus.value) { | |
| 172 | - getStepOneData = { | |
| 173 | - ...v, | |
| 174 | - ...{ image: v1 }, | |
| 175 | - }; | |
| 176 | - } | |
| 177 | - current.value++; | |
| 178 | - if (isUpdate.value == 2) { | |
| 179 | - isEdit.value = false; | |
| 180 | - proxy.$refs.DeviceProfileStep2Ref?.setStepTwoFieldsValueFunc(editData.value); | |
| 181 | - } else if (isUpdate.value == 3) { | |
| 182 | - proxy.$refs.DeviceProfileStep2Ref?.setStepTwoFieldsValueFunc(editData.value); | |
| 183 | 114 | } |
| 115 | + noEditObj = { | |
| 116 | + id: editData.value.id, | |
| 117 | + name: editData.value?.name, | |
| 118 | + createTime: createTime.value, | |
| 119 | + transportType: editTransportType.value, | |
| 120 | + type: editData.value?.type, | |
| 121 | + profileData: editData.value?.profileData, | |
| 122 | + defaultQueueName: editData.value.defaultQueueName, | |
| 123 | + image: editData.value.image, | |
| 124 | + defaultRuleChainId: editData.value.defaultRuleChainId, | |
| 125 | + description: editData.value.description, | |
| 126 | + tenantId: editData.value.tenantId, | |
| 127 | + }; | |
| 128 | + } else if (isUpdate.value == 3) { | |
| 129 | + handleCancel(); | |
| 130 | + isShowOkBtnFalse.value = false; | |
| 131 | + current.value = 0; | |
| 132 | + postEditId.value = data.record.id; | |
| 133 | + createTime.value = data.record.createTime; | |
| 134 | + editData.value = await deviceConfigGetDetail(postEditId.value); | |
| 135 | + proxy.$refs.DeviceProfileStep1Ref.setStepOneFieldsValueFunc({ | |
| 136 | + name: editData.value.name, | |
| 137 | + defaultRuleChainId: editData.value.defaultRuleChainId, | |
| 138 | + defaultQueueName: editData.value.defaultQueueName, | |
| 139 | + description: editData.value.description, | |
| 140 | + image: editData.value.image, | |
| 141 | + }); | |
| 184 | 142 | } |
| 185 | - const handleSubmit = async () => { | |
| 186 | - let getPic = null; | |
| 187 | - getStepTwoData = await proxy.$refs.DeviceProfileStep2Ref?.getStep2DataFunc(); | |
| 188 | - profileDataObj.profileData = getStepTwoData; | |
| 189 | - transportTypeObj.transportType = getStepTwoData?.transportConfiguration?.transportType; | |
| 190 | - delete profileDataObj?.profileData?.transportConfiguration?.transportType; | |
| 191 | - //没有点击下一步 | |
| 192 | - if (!isNextStatus.value) { | |
| 143 | + }); | |
| 144 | + function handleStepPrev() { | |
| 145 | + current.value--; | |
| 146 | + if (isUpdate.value == 2) { | |
| 147 | + isEdit.value = true; | |
| 148 | + noEditObj = { | |
| 149 | + id: editData.value.id, | |
| 150 | + name: editData.value?.name, | |
| 151 | + createTime: createTime.value, | |
| 152 | + transportType: editTransportType.value, | |
| 153 | + type: editData.value?.type, | |
| 154 | + profileData: editData.value?.profileData, | |
| 155 | + defaultQueueName: editData.value.defaultQueueName, | |
| 156 | + image: editData.value.image, | |
| 157 | + defaultRuleChainId: editData.value.defaultRuleChainId, | |
| 158 | + description: editData.value.description, | |
| 159 | + tenantId: editData.value.tenantId, | |
| 160 | + }; | |
| 161 | + nextTick(async () => { | |
| 162 | + let getPic = null; | |
| 193 | 163 | const getStep1Obj = await proxy.$refs.DeviceProfileStep1Ref?.getStep1Func(); |
| 194 | 164 | getPic = getStep1Obj.icon; |
| 195 | - getStepOneData = { | |
| 196 | - ...getStep1Obj.key, | |
| 197 | - ...{ image: getPic }, | |
| 198 | - }; | |
| 199 | 165 | Object.assign(noEditObj, { image: getPic }, getStep1Obj.key); |
| 200 | - } | |
| 201 | - const id = isUpdate.value == 1 ? '' : postEditId.value; | |
| 202 | - const createTimePost = isUpdate.value == 1 ? {} : { createTime: createTime.value }; | |
| 203 | - | |
| 204 | - if (Object.keys(getStepTwoData?.transportConfiguration).length == 0) { | |
| 205 | - profileDataObj.profileData = null; | |
| 206 | - } | |
| 207 | - postDeviceConfogData = { | |
| 208 | - ...getStepOneData, | |
| 209 | - ...profileDataObj, | |
| 210 | - ...transportTypeObj, | |
| 211 | - id, | |
| 212 | - ...createTimePost, | |
| 166 | + }); | |
| 167 | + } | |
| 168 | + } | |
| 169 | + //第一步 | |
| 170 | + function handleStepNext1(v, v1) { | |
| 171 | + isNextStatus.value = true; | |
| 172 | + if (isNextStatus.value) { | |
| 173 | + getStepOneData = { | |
| 174 | + ...v, | |
| 175 | + ...{ image: v1 }, | |
| 213 | 176 | }; |
| 214 | - if (isUpdate.value == 1) { | |
| 215 | - delete postDeviceConfogData.id; | |
| 216 | - } | |
| 217 | - let isMappingsKey = ref(false); | |
| 218 | - let isMappingValue = ref(false); | |
| 219 | - let isQueryings = ref(false); | |
| 220 | - let isOIDRepet = ref(false); | |
| 221 | - postDeviceConfogData?.profileData?.transportConfiguration?.communicationConfigs?.forEach( | |
| 222 | - (f: any) => { | |
| 223 | - if (f.spec == 'TELEMETRY_QUERYING' || f.spec == 'CLIENT_ATTRIBUTES_QUERYING') { | |
| 224 | - if (f.queryingFrequencyMs == null) { | |
| 225 | - isQueryings.value = true; | |
| 226 | - return createMessage.error('请填写查询频率'); | |
| 227 | - } else { | |
| 228 | - isQueryings.value = false; | |
| 229 | - } | |
| 230 | - } | |
| 231 | - if (f.mappings.length == 0) { | |
| 232 | - isMappingsKey.value = true; | |
| 233 | - isMappingValue.value = true; | |
| 177 | + } | |
| 178 | + current.value++; | |
| 179 | + if (isUpdate.value == 2) { | |
| 180 | + isEdit.value = false; | |
| 181 | + proxy.$refs.DeviceProfileStep2Ref?.setStepTwoFieldsValueFunc(editData.value); | |
| 182 | + } else if (isUpdate.value == 3) { | |
| 183 | + proxy.$refs.DeviceProfileStep2Ref?.setStepTwoFieldsValueFunc(editData.value); | |
| 184 | + } | |
| 185 | + } | |
| 186 | + const handleSubmit = async () => { | |
| 187 | + let getPic = null; | |
| 188 | + getStepTwoData = await proxy.$refs.DeviceProfileStep2Ref?.getStep2DataFunc(); | |
| 189 | + profileDataObj.profileData = getStepTwoData; | |
| 190 | + transportTypeObj.transportType = getStepTwoData?.transportConfiguration?.transportType; | |
| 191 | + delete profileDataObj?.profileData?.transportConfiguration?.transportType; | |
| 192 | + //没有点击下一步 | |
| 193 | + if (!isNextStatus.value) { | |
| 194 | + const getStep1Obj = await proxy.$refs.DeviceProfileStep1Ref?.getStep1Func(); | |
| 195 | + getPic = getStep1Obj.icon; | |
| 196 | + getStepOneData = { | |
| 197 | + ...getStep1Obj.key, | |
| 198 | + ...{ image: getPic }, | |
| 199 | + }; | |
| 200 | + Object.assign(noEditObj, { image: getPic }, getStep1Obj.key); | |
| 201 | + } | |
| 202 | + const id = isUpdate.value == 1 ? '' : postEditId.value; | |
| 203 | + const createTimePost = isUpdate.value == 1 ? {} : { createTime: createTime.value }; | |
| 204 | + | |
| 205 | + if (Object.keys(getStepTwoData?.transportConfiguration).length == 0) { | |
| 206 | + profileDataObj.profileData = null; | |
| 207 | + } | |
| 208 | + postDeviceConfogData = { | |
| 209 | + ...getStepOneData, | |
| 210 | + ...profileDataObj, | |
| 211 | + ...transportTypeObj, | |
| 212 | + id, | |
| 213 | + ...createTimePost, | |
| 214 | + }; | |
| 215 | + if (isUpdate.value == 1) { | |
| 216 | + delete postDeviceConfogData.id; | |
| 217 | + } | |
| 218 | + let isMappingsKey = ref(false); | |
| 219 | + let isMappingValue = ref(false); | |
| 220 | + let isQueryings = ref(false); | |
| 221 | + let isOIDRepet = ref(false); | |
| 222 | + postDeviceConfogData?.profileData?.transportConfiguration?.communicationConfigs?.forEach( | |
| 223 | + (f: any) => { | |
| 224 | + if (f.spec == 'TELEMETRY_QUERYING' || f.spec == 'CLIENT_ATTRIBUTES_QUERYING') { | |
| 225 | + if (f.queryingFrequencyMs == null) { | |
| 226 | + isQueryings.value = true; | |
| 227 | + return createMessage.error('请填写查询频率'); | |
| 234 | 228 | } else { |
| 235 | - f.mappings.forEach((f1) => { | |
| 236 | - const findNoneKey = Object.keys(f1).includes(''); | |
| 237 | - if (findNoneKey) { | |
| 238 | - isMappingsKey.value = true; | |
| 239 | - } | |
| 240 | - }); | |
| 241 | - f.mappings.forEach((f2) => { | |
| 242 | - const findNoneVal = Object.values(f2).includes(''); | |
| 243 | - if (findNoneVal) { | |
| 244 | - isMappingValue.value = true; | |
| 245 | - } | |
| 246 | - }); | |
| 247 | - //新增OID不能重复=====同一层级的OID不能重复 | |
| 248 | - f.mappings.forEach((item, _) => { | |
| 249 | - if (f.mappings.some((citem) => citem !== item && citem.oid === item.oid)) { | |
| 250 | - isOIDRepet.value = true; | |
| 251 | - } | |
| 252 | - }); | |
| 229 | + isQueryings.value = false; | |
| 253 | 230 | } |
| 254 | 231 | } |
| 255 | - ); | |
| 256 | - if (isQueryings.value) return createMessage.error('请填写查询频率'); | |
| 257 | - if (isMappingsKey.value) return createMessage.error('请填写Date key和OID'); | |
| 258 | - if (isMappingValue.value) return createMessage.error('请填写Date key和OID'); | |
| 259 | - if (isOIDRepet.value) return createMessage.error('OID不能重复'); | |
| 260 | - deviceConfigAddOrEdit(isEdit.value ? noEditObj : postDeviceConfogData) | |
| 261 | - .then((res) => { | |
| 262 | - if (!res) return; | |
| 263 | - createMessage.success(isUpdate.value == 1 ? '新增' + '成功' : '编辑' + '成功'); | |
| 264 | - closeModal(); | |
| 265 | - emit('success'); | |
| 266 | - isNextStatus.value = false; | |
| 267 | - }) | |
| 268 | - .catch((e) => { | |
| 269 | - createMessage.error(e); | |
| 270 | - }); | |
| 271 | - }; | |
| 272 | - const handleCancel = () => { | |
| 273 | - nextTick(() => { | |
| 274 | - proxy.$refs.DeviceProfileStep1Ref?.customResetStepOneFunc(); | |
| 275 | - proxy.$refs.DeviceProfileStep2Ref?.customClearStepTwoValueFunc(); | |
| 232 | + if (f.mappings.length == 0) { | |
| 233 | + isMappingsKey.value = true; | |
| 234 | + isMappingValue.value = true; | |
| 235 | + } else { | |
| 236 | + f.mappings.forEach((f1) => { | |
| 237 | + const findNoneKey = Object.keys(f1).includes(''); | |
| 238 | + if (findNoneKey) { | |
| 239 | + isMappingsKey.value = true; | |
| 240 | + } | |
| 241 | + }); | |
| 242 | + f.mappings.forEach((f2) => { | |
| 243 | + const findNoneVal = Object.values(f2).includes(''); | |
| 244 | + if (findNoneVal) { | |
| 245 | + isMappingValue.value = true; | |
| 246 | + } | |
| 247 | + }); | |
| 248 | + //新增OID不能重复=====同一层级的OID不能重复 | |
| 249 | + f.mappings.forEach((item, _) => { | |
| 250 | + if (f.mappings.some((citem) => citem !== item && citem.oid === item.oid)) { | |
| 251 | + isOIDRepet.value = true; | |
| 252 | + } | |
| 253 | + }); | |
| 254 | + } | |
| 255 | + } | |
| 256 | + ); | |
| 257 | + if (isQueryings.value) return createMessage.error('请填写查询频率'); | |
| 258 | + if (isMappingsKey.value) return createMessage.error('请填写Date key和OID'); | |
| 259 | + if (isMappingValue.value) return createMessage.error('请填写Date key和OID'); | |
| 260 | + if (isOIDRepet.value) return createMessage.error('OID不能重复'); | |
| 261 | + deviceConfigAddOrEdit(isEdit.value ? noEditObj : postDeviceConfogData) | |
| 262 | + .then((res) => { | |
| 263 | + if (!res) return; | |
| 264 | + createMessage.success(isUpdate.value == 1 ? '新增' + '成功' : '编辑' + '成功'); | |
| 265 | + closeModal(); | |
| 266 | + emit('success'); | |
| 267 | + isNextStatus.value = false; | |
| 268 | + }) | |
| 269 | + .catch((e) => { | |
| 270 | + // createMessage.error(e); | |
| 276 | 271 | }); |
| 277 | - }; | |
| 278 | - function handleRedo() { | |
| 279 | - current.value = 0; | |
| 280 | - } | |
| 281 | - return { | |
| 282 | - isShowOkBtnFalse, | |
| 283 | - DeviceProfileStep2Ref, | |
| 284 | - DeviceProfileStep1Ref, | |
| 285 | - editData, | |
| 286 | - handleSubmit, | |
| 287 | - handleCancel, | |
| 288 | - register, | |
| 289 | - getTitle, | |
| 290 | - getViewTitle, | |
| 291 | - current, | |
| 292 | - handleStepPrev, | |
| 293 | - handleStepNext1, | |
| 294 | - handleRedo, | |
| 295 | - }; | |
| 296 | - }, | |
| 297 | - }); | |
| 272 | + }; | |
| 273 | + const handleCancel = () => { | |
| 274 | + nextTick(() => { | |
| 275 | + proxy.$refs.DeviceProfileStep1Ref?.customResetStepOneFunc(); | |
| 276 | + proxy.$refs.DeviceProfileStep2Ref?.customClearStepTwoValueFunc(); | |
| 277 | + }); | |
| 278 | + }; | |
| 279 | + function handleRedo() { | |
| 280 | + current.value = 0; | |
| 281 | + } | |
| 282 | + return { | |
| 283 | + isShowOkBtnFalse, | |
| 284 | + DeviceProfileStep2Ref, | |
| 285 | + DeviceProfileStep1Ref, | |
| 286 | + editData, | |
| 287 | + handleSubmit, | |
| 288 | + handleCancel, | |
| 289 | + register, | |
| 290 | + getTitle, | |
| 291 | + getViewTitle, | |
| 292 | + current, | |
| 293 | + handleStepPrev, | |
| 294 | + handleStepNext1, | |
| 295 | + handleRedo, | |
| 296 | + }; | |
| 297 | + }, | |
| 298 | +}); | |
| 298 | 299 | </script> | ... | ... |
| ... | ... | @@ -4,21 +4,9 @@ |
| 4 | 4 | <div> |
| 5 | 5 | <BasicForm @register="register"> |
| 6 | 6 | <template #imageSelect> |
| 7 | - <Upload | |
| 8 | - style="width: 20vw" | |
| 9 | - name="avatar" | |
| 10 | - list-type="picture-card" | |
| 11 | - class="avatar-uploader" | |
| 12 | - :show-upload-list="false" | |
| 13 | - :customRequest="customUploadqrcodePic" | |
| 14 | - :before-upload="beforeUploadqrcodePic" | |
| 15 | - > | |
| 16 | - <img | |
| 17 | - v-if="peresonalPic" | |
| 18 | - :src="peresonalPic" | |
| 19 | - alt="avatar" | |
| 20 | - style="width: 6.25rem; height: 6.25rem" | |
| 21 | - /> | |
| 7 | + <Upload style="width: 20vw" name="avatar" list-type="picture-card" class="avatar-uploader" | |
| 8 | + :show-upload-list="false" :customRequest="customUploadqrcodePic" :before-upload="beforeUploadqrcodePic"> | |
| 9 | + <img v-if="peresonalPic" :src="peresonalPic" alt="avatar" style="width: 6.25rem; height: 6.25rem" /> | |
| 22 | 10 | <div v-else> |
| 23 | 11 | <LoadingOutlined v-if="loading" /> |
| 24 | 12 | <PlusOutlined v-else /> |
| ... | ... | @@ -32,154 +20,161 @@ |
| 32 | 20 | </div> |
| 33 | 21 | </template> |
| 34 | 22 | <script lang="ts"> |
| 35 | - import { defineComponent, ref } from 'vue'; | |
| 36 | - import { BasicForm, useForm } from '/@/components/Form'; | |
| 37 | - import { step1Schemas } from './data'; | |
| 38 | - import { Select, Input, Divider } from 'ant-design-vue'; | |
| 39 | - import { uploadApi } from '/@/api/personal/index'; | |
| 40 | - import { Upload } from 'ant-design-vue'; | |
| 41 | - import { PlusOutlined, LoadingOutlined } from '@ant-design/icons-vue'; | |
| 42 | - import { useMessage } from '/@/hooks/web/useMessage'; | |
| 43 | - import type { FileItem } from '/@/components/Upload/src/typing'; | |
| 23 | +import { defineComponent, ref } from 'vue'; | |
| 24 | +import { BasicForm, useForm } from '/@/components/Form'; | |
| 25 | +import { step1Schemas } from './data'; | |
| 26 | +import { Select, Input, Divider } from 'ant-design-vue'; | |
| 27 | +import { uploadApi } from '/@/api/personal/index'; | |
| 28 | +import { Upload } from 'ant-design-vue'; | |
| 29 | +import { PlusOutlined, LoadingOutlined } from '@ant-design/icons-vue'; | |
| 30 | +import { useMessage } from '/@/hooks/web/useMessage'; | |
| 31 | +import type { FileItem } from '/@/components/Upload/src/typing'; | |
| 44 | 32 | |
| 45 | - export default defineComponent({ | |
| 46 | - components: { | |
| 47 | - BasicForm, | |
| 48 | - [Select.name]: Select, | |
| 49 | - [Input.name]: Input, | |
| 50 | - [Input.Group.name]: Input.Group, | |
| 51 | - [Divider.name]: Divider, | |
| 52 | - Upload, | |
| 53 | - PlusOutlined, | |
| 54 | - LoadingOutlined, | |
| 55 | - }, | |
| 56 | - emits: ['next', 'resetFunc', 'register'], | |
| 57 | - setup(_, { emit }) { | |
| 58 | - const loading = ref(false); | |
| 33 | +export default defineComponent({ | |
| 34 | + components: { | |
| 35 | + BasicForm, | |
| 36 | + [Select.name]: Select, | |
| 37 | + [Input.name]: Input, | |
| 38 | + [Input.Group.name]: Input.Group, | |
| 39 | + [Divider.name]: Divider, | |
| 40 | + Upload, | |
| 41 | + PlusOutlined, | |
| 42 | + LoadingOutlined, | |
| 43 | + }, | |
| 44 | + emits: ['next', 'resetFunc', 'register'], | |
| 45 | + setup(_, { emit }) { | |
| 46 | + const loading = ref(false); | |
| 59 | 47 | |
| 60 | - const { createMessage } = useMessage(); | |
| 61 | - const peresonalPic = ref(''); | |
| 48 | + const { createMessage } = useMessage(); | |
| 49 | + const peresonalPic = ref(''); | |
| 62 | 50 | |
| 63 | - const [register, { validate, setFieldsValue, resetFields }] = useForm({ | |
| 64 | - labelWidth: 100, | |
| 65 | - schemas: step1Schemas, | |
| 66 | - actionColOptions: { | |
| 67 | - span: 14, | |
| 68 | - }, | |
| 69 | - showResetButton: false, | |
| 70 | - submitButtonOptions: { | |
| 71 | - text: '下一步', | |
| 72 | - }, | |
| 73 | - submitFunc: customSubmitFunc, | |
| 74 | - }); | |
| 75 | - //回显数据 | |
| 76 | - const setStepOneFieldsValueFunc = (v) => { | |
| 77 | - setFieldsValue(v); | |
| 78 | - peresonalPic.value = v.image; | |
| 79 | - }; | |
| 80 | - const customUploadqrcodePic = async ({ file }) => { | |
| 81 | - if (beforeUploadqrcodePic(file)) { | |
| 82 | - peresonalPic.value = ''; | |
| 83 | - loading.value = true; | |
| 84 | - const formData = new FormData(); | |
| 85 | - formData.append('file', file); | |
| 86 | - const response = await uploadApi(formData); | |
| 87 | - if (response.fileStaticUri) { | |
| 88 | - peresonalPic.value = response.fileStaticUri; | |
| 89 | - loading.value = false; | |
| 90 | - } | |
| 91 | - } | |
| 92 | - }; | |
| 93 | - const beforeUploadqrcodePic = (file: FileItem) => { | |
| 94 | - const isJpgOrPng = | |
| 95 | - file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'image/jpg'; | |
| 96 | - if (!isJpgOrPng) { | |
| 97 | - createMessage.error('只能上传图片文件!'); | |
| 98 | - } | |
| 99 | - const isLt2M = (file.size as number) / 1024 / 1024 < 5; | |
| 100 | - if (!isLt2M) { | |
| 101 | - createMessage.error('图片大小不能超过5MB!'); | |
| 102 | - } | |
| 103 | - return isJpgOrPng && isLt2M; | |
| 104 | - }; | |
| 105 | - | |
| 106 | - async function customSubmitFunc() { | |
| 107 | - const values = await validate(); | |
| 108 | - emit('next', values, peresonalPic.value); | |
| 51 | + const [register, { validate, setFieldsValue, resetFields, updateSchema }] = useForm({ | |
| 52 | + labelWidth: 100, | |
| 53 | + schemas: step1Schemas, | |
| 54 | + actionColOptions: { | |
| 55 | + span: 14, | |
| 56 | + }, | |
| 57 | + showResetButton: false, | |
| 58 | + submitButtonOptions: { | |
| 59 | + text: '下一步', | |
| 60 | + }, | |
| 61 | + submitFunc: customSubmitFunc, | |
| 62 | + }); | |
| 63 | + const editOrAddNameStatus = (nameStatus) => updateSchema({ | |
| 64 | + field: 'name', componentProps: { | |
| 65 | + disabled: nameStatus | |
| 109 | 66 | } |
| 110 | - //清空数据 | |
| 111 | - const customResetStepOneFunc = () => { | |
| 112 | - resetFields(); | |
| 67 | + }) | |
| 68 | + //回显数据 | |
| 69 | + const setStepOneFieldsValueFunc = (v) => { | |
| 70 | + setFieldsValue(v); | |
| 71 | + peresonalPic.value = v.image; | |
| 72 | + }; | |
| 73 | + const customUploadqrcodePic = async ({ file }) => { | |
| 74 | + if (beforeUploadqrcodePic(file)) { | |
| 113 | 75 | peresonalPic.value = ''; |
| 114 | - }; | |
| 115 | - const getStep1Func = async () => { | |
| 116 | - const valueStep1 = await validate(); | |
| 117 | - const pic = peresonalPic.value; | |
| 118 | - return { | |
| 119 | - key: valueStep1, | |
| 120 | - icon: pic, | |
| 121 | - }; | |
| 122 | - }; | |
| 76 | + loading.value = true; | |
| 77 | + const formData = new FormData(); | |
| 78 | + formData.append('file', file); | |
| 79 | + const response = await uploadApi(formData); | |
| 80 | + if (response.fileStaticUri) { | |
| 81 | + peresonalPic.value = response.fileStaticUri; | |
| 82 | + loading.value = false; | |
| 83 | + } | |
| 84 | + } | |
| 85 | + }; | |
| 86 | + const beforeUploadqrcodePic = (file: FileItem) => { | |
| 87 | + const isJpgOrPng = | |
| 88 | + file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'image/jpg'; | |
| 89 | + if (!isJpgOrPng) { | |
| 90 | + createMessage.error('只能上传图片文件!'); | |
| 91 | + } | |
| 92 | + const isLt2M = (file.size as number) / 1024 / 1024 < 5; | |
| 93 | + if (!isLt2M) { | |
| 94 | + createMessage.error('图片大小不能超过5MB!'); | |
| 95 | + } | |
| 96 | + return isJpgOrPng && isLt2M; | |
| 97 | + }; | |
| 98 | + | |
| 99 | + async function customSubmitFunc() { | |
| 100 | + const values = await validate(); | |
| 101 | + emit('next', values, peresonalPic.value); | |
| 102 | + } | |
| 103 | + //清空数据 | |
| 104 | + const customResetStepOneFunc = () => { | |
| 105 | + resetFields(); | |
| 106 | + peresonalPic.value = ''; | |
| 107 | + }; | |
| 108 | + const getStep1Func = async () => { | |
| 109 | + const valueStep1 = await validate(); | |
| 110 | + const pic = peresonalPic.value; | |
| 123 | 111 | return { |
| 124 | - register, | |
| 125 | - setStepOneFieldsValueFunc, | |
| 126 | - customResetStepOneFunc, | |
| 127 | - uploadApi, | |
| 128 | - peresonalPic, | |
| 129 | - beforeUploadqrcodePic, | |
| 130 | - customUploadqrcodePic, | |
| 131 | - getStep1Func, | |
| 132 | - loading, | |
| 112 | + key: valueStep1, | |
| 113 | + icon: pic, | |
| 133 | 114 | }; |
| 134 | - }, | |
| 135 | - }); | |
| 115 | + }; | |
| 116 | + return { | |
| 117 | + register, | |
| 118 | + setStepOneFieldsValueFunc, | |
| 119 | + customResetStepOneFunc, | |
| 120 | + uploadApi, | |
| 121 | + peresonalPic, | |
| 122 | + beforeUploadqrcodePic, | |
| 123 | + customUploadqrcodePic, | |
| 124 | + getStep1Func, | |
| 125 | + loading, | |
| 126 | + editOrAddNameStatus | |
| 127 | + }; | |
| 128 | + }, | |
| 129 | +}); | |
| 136 | 130 | </script> |
| 137 | 131 | <style lang="less" scoped> |
| 138 | - .step1 { | |
| 139 | - &-form { | |
| 140 | - width: 500px; | |
| 141 | - margin: 0 auto; | |
| 142 | - } | |
| 143 | - | |
| 144 | - h3 { | |
| 145 | - margin: 0 0 12px; | |
| 146 | - font-size: 16px; | |
| 147 | - line-height: 32px; | |
| 148 | - color: @text-color; | |
| 149 | - } | |
| 132 | +.step1 { | |
| 133 | + &-form { | |
| 134 | + width: 500px; | |
| 135 | + margin: 0 auto; | |
| 136 | + } | |
| 150 | 137 | |
| 151 | - h4 { | |
| 152 | - margin: 0 0 4px; | |
| 153 | - font-size: 14px; | |
| 154 | - line-height: 22px; | |
| 155 | - color: @text-color; | |
| 156 | - } | |
| 138 | + h3 { | |
| 139 | + margin: 0 0 12px; | |
| 140 | + font-size: 16px; | |
| 141 | + line-height: 32px; | |
| 142 | + color: @text-color; | |
| 143 | + } | |
| 157 | 144 | |
| 158 | - p { | |
| 159 | - color: @text-color; | |
| 160 | - } | |
| 161 | - .device-icon-style { | |
| 162 | - :deep .ant-upload-select-picture-card { | |
| 163 | - display: inherit; | |
| 164 | - float: none; | |
| 165 | - width: 4.9vw; | |
| 166 | - height: 9.5vh; | |
| 167 | - margin-right: 8px; | |
| 168 | - text-align: center; | |
| 169 | - vertical-align: top; | |
| 170 | - background-color: #fafafa; | |
| 171 | - border: 1px dashed #d9d9d9; | |
| 172 | - cursor: pointer; | |
| 173 | - transition: border-color 0.3s ease; | |
| 174 | - } | |
| 175 | - } | |
| 145 | + h4 { | |
| 146 | + margin: 0 0 4px; | |
| 147 | + font-size: 14px; | |
| 148 | + line-height: 22px; | |
| 149 | + color: @text-color; | |
| 176 | 150 | } |
| 177 | 151 | |
| 178 | - .pay-select { | |
| 179 | - width: 20%; | |
| 152 | + p { | |
| 153 | + color: @text-color; | |
| 180 | 154 | } |
| 181 | 155 | |
| 182 | - .pay-input { | |
| 183 | - width: 70%; | |
| 156 | + .device-icon-style { | |
| 157 | + :deep .ant-upload-select-picture-card { | |
| 158 | + display: inherit; | |
| 159 | + float: none; | |
| 160 | + width: 4.9vw; | |
| 161 | + height: 9.5vh; | |
| 162 | + margin-right: 8px; | |
| 163 | + text-align: center; | |
| 164 | + vertical-align: top; | |
| 165 | + background-color: #fafafa; | |
| 166 | + border: 1px dashed #d9d9d9; | |
| 167 | + cursor: pointer; | |
| 168 | + transition: border-color 0.3s ease; | |
| 169 | + } | |
| 184 | 170 | } |
| 171 | +} | |
| 172 | + | |
| 173 | +.pay-select { | |
| 174 | + width: 20%; | |
| 175 | +} | |
| 176 | + | |
| 177 | +.pay-input { | |
| 178 | + width: 70%; | |
| 179 | +} | |
| 185 | 180 | </style> | ... | ... |
| ... | ... | @@ -4,7 +4,7 @@ import { findDictItemByCode } from '/@/api/system/dict'; |
| 4 | 4 | |
| 5 | 5 | export const step1Schemas: FormSchema[] = [ |
| 6 | 6 | { |
| 7 | - field: 'name', | |
| 7 | + field: 'image', | |
| 8 | 8 | label: '上传图片', |
| 9 | 9 | component: 'Input', |
| 10 | 10 | slot: 'imageSelect', |
| ... | ... | @@ -14,9 +14,12 @@ export const step1Schemas: FormSchema[] = [ |
| 14 | 14 | label: '配置名称', |
| 15 | 15 | required: true, |
| 16 | 16 | component: 'Input', |
| 17 | - componentProps: { | |
| 18 | - maxLength: 255, | |
| 19 | - placeholder: '请输入配置名称', | |
| 17 | + componentProps() { | |
| 18 | + return { | |
| 19 | + disabled: false, | |
| 20 | + ength: 255, | |
| 21 | + placeholder: '请输入配置名称', | |
| 22 | + }; | |
| 20 | 23 | }, |
| 21 | 24 | }, |
| 22 | 25 | { | ... | ... |
| ... | ... | @@ -54,7 +54,7 @@ export const columns: BasicColumn[] = [ |
| 54 | 54 | title: '配置状态', |
| 55 | 55 | dataIndex: 'status', |
| 56 | 56 | width: 120, |
| 57 | - slots: { customRender: 'status' }, | |
| 57 | + slots: { customRender: 'configStatus' }, | |
| 58 | 58 | }, |
| 59 | 59 | { |
| 60 | 60 | title: '执行方式', |
| ... | ... | @@ -431,30 +431,6 @@ export const formSchema: QFormSchema[] = [ |
| 431 | 431 | defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')], |
| 432 | 432 | }, |
| 433 | 433 | }, |
| 434 | - // componentProps({ formActionType }) { | |
| 435 | - // const { setFieldsValue } = formActionType; | |
| 436 | - // let dates: Moment[] = []; | |
| 437 | - // return { | |
| 438 | - // placeholder: ['请选择开始时间', '请选择结束时间'], | |
| 439 | - // showTime: { | |
| 440 | - // defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')], | |
| 441 | - // }, | |
| 442 | - // // onCalendarChange(value: Moment[]) { | |
| 443 | - // // dates = value; | |
| 444 | - // // }, | |
| 445 | - // // disabledDate(current: Moment) { | |
| 446 | - // // if (!dates || dates.length === 0 || !current) { | |
| 447 | - // // return false; | |
| 448 | - // // } | |
| 449 | - // // const diffDate = current.diff(dates[0], 'years', true); | |
| 450 | - // // return Math.abs(diffDate) > 1; | |
| 451 | - // // }, | |
| 452 | - // onChange() { | |
| 453 | - // dates = []; | |
| 454 | - // setFieldsValue({ [SchemaFiled.INTERVAL]: null }); | |
| 455 | - // }, | |
| 456 | - // }; | |
| 457 | - // }, | |
| 458 | 434 | colProps: { |
| 459 | 435 | span: 10, |
| 460 | 436 | }, | ... | ... |
| ... | ... | @@ -29,7 +29,7 @@ |
| 29 | 29 | :actions="[ |
| 30 | 30 | { |
| 31 | 31 | label: '查看', |
| 32 | - icon: 'clarity:note-edit-line', | |
| 32 | + icon: 'ant-design:eye-outlined', | |
| 33 | 33 | onClick: handleViewDetail.bind(null, record), |
| 34 | 34 | ifShow: record.status === 1, |
| 35 | 35 | }, |
| ... | ... | @@ -54,7 +54,7 @@ |
| 54 | 54 | ]" |
| 55 | 55 | /> |
| 56 | 56 | </template> |
| 57 | - <template #status="{ record }"> | |
| 57 | + <template #configStatus="{ record }"> | |
| 58 | 58 | <Switch |
| 59 | 59 | :disabled="disabledSwitch" |
| 60 | 60 | :checked="record.status === 1" |
| ... | ... | @@ -92,7 +92,7 @@ |
| 92 | 92 | const searchInfo = reactive<Recordable>({}); |
| 93 | 93 | const disabledSwitch = ref(false); |
| 94 | 94 | |
| 95 | - const [registerTable, { reload, setProps }] = useTable({ | |
| 95 | + const [registerTable, { reload, setProps, setSelectedRowKeys }] = useTable({ | |
| 96 | 96 | title: '报表列表', |
| 97 | 97 | api: reportPage, |
| 98 | 98 | columns, |
| ... | ... | @@ -125,11 +125,8 @@ |
| 125 | 125 | reload(); |
| 126 | 126 | }; |
| 127 | 127 | |
| 128 | - const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions } = useBatchDelete( | |
| 129 | - deleteReportManage, | |
| 130 | - handleSuccess, | |
| 131 | - setProps | |
| 132 | - ); | |
| 128 | + const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions, resetSelectedRowKeys } = | |
| 129 | + useBatchDelete(deleteReportManage, handleSuccess, setProps); | |
| 133 | 130 | selectionOptions.rowSelection.getCheckboxProps = (record: Recordable) => { |
| 134 | 131 | // Demo:status为1的选择框禁用 |
| 135 | 132 | if (record.status === 1) { |
| ... | ... | @@ -181,6 +178,8 @@ |
| 181 | 178 | setProps({ |
| 182 | 179 | loading: true, |
| 183 | 180 | }); |
| 181 | + setSelectedRowKeys([]); | |
| 182 | + resetSelectedRowKeys(); | |
| 184 | 183 | disabledSwitch.value = true; |
| 185 | 184 | const newStatus = checked ? 1 : 0; |
| 186 | 185 | const res = await putReportByidAndStatusManage(record.id, newStatus); | ... | ... |
| 1 | 1 | <template> |
| 2 | 2 | <div> |
| 3 | - <BasicDrawer | |
| 4 | - v-bind="$attrs" | |
| 5 | - @register="registerDrawer" | |
| 6 | - @ok="handleSubmit" | |
| 7 | - width="50%" | |
| 8 | - showFooter | |
| 9 | - @close="handleClose" | |
| 10 | - :title="title" | |
| 11 | - > | |
| 3 | + <BasicDrawer v-bind="$attrs" @register="registerDrawer" @ok="handleSubmit" width="50%" showFooter | |
| 4 | + @close="handleClose" :title="title"> | |
| 12 | 5 | <div> |
| 13 | 6 | <!-- 基础表单 --> |
| 14 | 7 | <BasicForm @register="registerForm" /> |
| ... | ... | @@ -17,20 +10,14 @@ |
| 17 | 10 | <Divider orientation="left">触发器</Divider> |
| 18 | 11 | <div> |
| 19 | 12 | <template v-for="(item, index) in triggerData" :key="item"> |
| 20 | - <TriggerOrCondition | |
| 21 | - class="mt-4" | |
| 22 | - title="触发器" | |
| 23 | - :index="index" | |
| 24 | - :provideOrgid="provideOrgid" | |
| 25 | - :ref="skipUnwrap.triggerItemRefs" | |
| 26 | - @delete="deleteTriggerOrCondition" | |
| 27 | - /> | |
| 13 | + <TriggerOrCondition class="mt-4" title="触发器" :index="index" :provideOrgid="provideOrgid" | |
| 14 | + :ref="skipUnwrap.triggerItemRefs" @delete="deleteTriggerOrCondition" /> | |
| 28 | 15 | </template> |
| 29 | 16 | <!-- 按钮 --> |
| 30 | 17 | <a-button type="primary" class="mt-4" @click="addTrigger" v-if="isView"> |
| 31 | 18 | <PlusOutlined /> |
| 32 | - 新增触发器</a-button | |
| 33 | - > | |
| 19 | + 新增触发器 | |
| 20 | + </a-button> | |
| 34 | 21 | <!-- 按钮 --> |
| 35 | 22 | </div> |
| 36 | 23 | <!-- 触发器-end --> |
| ... | ... | @@ -39,20 +26,14 @@ |
| 39 | 26 | <Divider orientation="left">执行条件</Divider> |
| 40 | 27 | <div> |
| 41 | 28 | <template v-for="(item, index) in conditionData" :key="item"> |
| 42 | - <TriggerOrCondition | |
| 43 | - class="mt-4" | |
| 44 | - title="执行条件" | |
| 45 | - :index="index" | |
| 46 | - :provideOrgid="provideOrgid" | |
| 47 | - :ref="skipUnwrap.conditionItemRefs" | |
| 48 | - @delete="deleteTriggerOrCondition" | |
| 49 | - /> | |
| 29 | + <TriggerOrCondition class="mt-4" title="执行条件" :index="index" :provideOrgid="provideOrgid" | |
| 30 | + :ref="skipUnwrap.conditionItemRefs" @delete="deleteTriggerOrCondition" /> | |
| 50 | 31 | </template> |
| 51 | 32 | <!-- 按钮 --> |
| 52 | 33 | <a-button type="primary" class="mt-4" @click="addCondition" v-if="isView"> |
| 53 | 34 | <PlusOutlined /> |
| 54 | - 新增执行条件</a-button | |
| 55 | - > | |
| 35 | + 新增执行条件 | |
| 36 | + </a-button> | |
| 56 | 37 | <!-- 按钮 --> |
| 57 | 38 | </div> |
| 58 | 39 | <!-- 执行条件-end --> |
| ... | ... | @@ -61,24 +42,15 @@ |
| 61 | 42 | <Divider orientation="left">执行动作</Divider> |
| 62 | 43 | <div> |
| 63 | 44 | <template v-for="(item, index) in actionData" :key="item"> |
| 64 | - <Action | |
| 65 | - class="mt-4" | |
| 66 | - :actionIndex="index" | |
| 67 | - :actionData="actionData" | |
| 68 | - :triggerData="triggerData" | |
| 69 | - :ref="skipUnwrap.actionItemRefs" | |
| 70 | - :provideOrgid="provideOrgid" | |
| 71 | - :deviceList="getMasterDeviceList" | |
| 72 | - :arr="arr" | |
| 73 | - @deleteAction="deleteAction" | |
| 74 | - @getActionFormArr="getActionFormArr" | |
| 75 | - /> | |
| 45 | + <Action class="mt-4" :actionIndex="index" :actionData="actionData" :triggerData="triggerData" | |
| 46 | + :ref="skipUnwrap.actionItemRefs" :provideOrgid="provideOrgid" :deviceList="getMasterDeviceList" :arr="arr" | |
| 47 | + @deleteAction="deleteAction" @getActionFormArr="getActionFormArr" /> | |
| 76 | 48 | </template> |
| 77 | 49 | <!-- 按钮 --> |
| 78 | 50 | <a-button type="primary" class="mt-4" @click="addAction" v-if="isView"> |
| 79 | 51 | <PlusOutlined /> |
| 80 | - 新增执行动作</a-button | |
| 81 | - > | |
| 52 | + 新增执行动作 | |
| 53 | + </a-button> | |
| 82 | 54 | <!-- 按钮 --> |
| 83 | 55 | </div> |
| 84 | 56 | <!-- 执行动作-end --> |
| ... | ... | @@ -87,587 +59,591 @@ |
| 87 | 59 | </div> |
| 88 | 60 | </template> |
| 89 | 61 | <script lang="ts" setup> |
| 90 | - import { ref, watch, unref, computed, nextTick } from 'vue'; | |
| 91 | - import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | |
| 92 | - import { formSchema, organizationId } from './config/config.data.ts'; | |
| 93 | - import { BasicForm, useForm } from '/@/components/Form'; | |
| 94 | - import { genTriggerOrConditionData, genActionData } from './config/formatData.ts'; | |
| 95 | - import { Divider } from 'ant-design-vue'; | |
| 96 | - import { PlusOutlined } from '@ant-design/icons-vue'; | |
| 97 | - import { useMessage } from '/@/hooks/web/useMessage'; | |
| 98 | - import { | |
| 99 | - screenLinkPageAddApi, | |
| 100 | - screenLinkPageByDeptIdGetDevice, | |
| 101 | - getOrganizationAlarmConfig, | |
| 102 | - byOganizationIdGetMasterDevice, | |
| 103 | - } from '/@/api/ruleengine/ruleengineApi'; | |
| 104 | - import TriggerOrCondition from './cpns/Trigger-Condition.vue'; | |
| 105 | - import Action from './cpns/Action.vue'; | |
| 106 | - import { findOperation } from './config/formatData.ts'; | |
| 107 | - import { formatToDateTime } from '/@/utils/dateUtil'; | |
| 62 | +import { ref, watch, unref, computed, nextTick } from 'vue'; | |
| 63 | +import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | |
| 64 | +import { formSchema, organizationId } from './config/config.data.ts'; | |
| 65 | +import { BasicForm, useForm } from '/@/components/Form'; | |
| 66 | +import { genTriggerOrConditionData, genActionData } from './config/formatData.ts'; | |
| 67 | +import { Divider } from 'ant-design-vue'; | |
| 68 | +import { PlusOutlined } from '@ant-design/icons-vue'; | |
| 69 | +import { useMessage } from '/@/hooks/web/useMessage'; | |
| 70 | +import { | |
| 71 | + screenLinkPageAddApi, | |
| 72 | + screenLinkPageByDeptIdGetDevice, | |
| 73 | + getOrganizationAlarmConfig, | |
| 74 | + byOganizationIdGetMasterDevice, | |
| 75 | +} from '/@/api/ruleengine/ruleengineApi'; | |
| 76 | +import TriggerOrCondition from './cpns/Trigger-Condition.vue'; | |
| 77 | +import Action from './cpns/Action.vue'; | |
| 78 | +import { findOperation } from './config/formatData.ts'; | |
| 79 | +import { formatToDateTime } from '/@/utils/dateUtil'; | |
| 108 | 80 | |
| 109 | - const emit = defineEmits(['register', 'success']); | |
| 110 | - const provideOrgid = ref(''); | |
| 81 | +const emit = defineEmits(['register', 'success']); | |
| 82 | +const provideOrgid = ref(''); | |
| 111 | 83 | |
| 112 | - const { createMessage } = useMessage(); | |
| 113 | - const triggerData = ref([]); | |
| 114 | - const conditionData = ref([]); | |
| 115 | - const actionData = ref([]); | |
| 116 | - const skipUnwrap = { | |
| 117 | - triggerItemRefs: ref([]), | |
| 118 | - conditionItemRefs: ref([]), | |
| 119 | - actionItemRefs: ref([]), | |
| 120 | - }; | |
| 121 | - const title = computed( | |
| 122 | - () => `${isUpdate.value === 3 ? '查看' : isUpdate.value ? '编辑' : '新增'}场景联动` | |
| 123 | - ); | |
| 124 | - let getTriggerFormValue = ref([]); | |
| 125 | - let getConditionFormValue = ref([]); | |
| 126 | - let getActionFormValue = ref([]); | |
| 127 | - const editEntryIdData = ref([]); | |
| 128 | - const editAlarmConfigData = ref([]); | |
| 129 | - const isUpdate = ref(false); | |
| 130 | - const id = ref(undefined); | |
| 131 | - const tenantId = ref(undefined); | |
| 132 | - const isView = ref(true); | |
| 133 | - const [registerForm, { resetFields, validate, setFieldsValue }] = useForm({ | |
| 134 | - labelWidth: 120, | |
| 135 | - schemas: formSchema, | |
| 136 | - showActionButtonGroup: false, | |
| 137 | - }); | |
| 138 | - const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { | |
| 139 | - setDrawerProps({ confirmLoading: false, loading: true }); | |
| 140 | - isUpdate.value = data.isUpdate; | |
| 141 | - if (!unref(isUpdate)) { | |
| 142 | - resetFields(); | |
| 143 | - //初始化执行动作 | |
| 144 | - actionData.value = [Date.now()]; | |
| 145 | - } else { | |
| 146 | - // 取值 | |
| 147 | - const { | |
| 148 | - id: recordId, | |
| 149 | - tenantId: recordTenantId, | |
| 150 | - organizationId, | |
| 151 | - triggers, | |
| 152 | - doConditions, | |
| 153 | - doActions, | |
| 154 | - } = data.record; | |
| 155 | - // 赋值 | |
| 156 | - await setFieldsValue(data.record); | |
| 157 | - id.value = recordId; | |
| 158 | - tenantId.value = recordTenantId; | |
| 159 | - //TODO-fengtao-把组织id传给子组件 | |
| 160 | - provideOrgid.value = organizationId; | |
| 161 | - //TODO-fengtao获取当前执行动作下的设备(master那个接口) | |
| 162 | - getMasterDeviceList.value = await byOganizationIdGetMasterDevice(organizationId); | |
| 163 | - //TODO-fengtao | |
| 164 | - // 获取当前组织下的设备列表 | |
| 165 | - const options = await screenLinkPageByDeptIdGetDevice({ | |
| 166 | - organizationId, | |
| 167 | - }); | |
| 168 | - // 获取当前组织下的告警配置 | |
| 169 | - const alarmConfig = await getOrganizationAlarmConfig({ organizationId }); | |
| 170 | - | |
| 171 | - // 生成回显时对应得组件数量 | |
| 172 | - triggerData.value = [...new Array(triggers.length).keys()]; | |
| 173 | - conditionData.value = [...new Array(doConditions.length).keys()]; | |
| 174 | - actionData.value = [...new Array(doActions.length).keys()]; | |
| 175 | - // 回显设备列表 | |
| 176 | - editEntryIdData.value = options.items.map((item) => { | |
| 177 | - return { | |
| 178 | - value: item.tbDeviceId, | |
| 179 | - label: item.name, | |
| 180 | - }; | |
| 181 | - }); | |
| 182 | - editAlarmConfigData.value = alarmConfig.map((item) => { | |
| 183 | - return { | |
| 184 | - value: item.id, | |
| 185 | - label: item.name, | |
| 186 | - }; | |
| 187 | - }); | |
| 188 | - deviceList.value = editEntryIdData.value; | |
| 189 | - nextTick(() => { | |
| 190 | - setEditFields(skipUnwrap.triggerItemRefs, editEntryIdData); | |
| 191 | - setEditFields(skipUnwrap.conditionItemRefs, editEntryIdData); | |
| 192 | - setEditFields(skipUnwrap.actionItemRefs, getMasterDeviceList); | |
| 193 | - setEditAlarmConfig(skipUnwrap.actionItemRefs, editAlarmConfigData); | |
| 194 | - }); | |
| 84 | +const { createMessage } = useMessage(); | |
| 85 | +const triggerData = ref([]); | |
| 86 | +const conditionData = ref([]); | |
| 87 | +const actionData = ref([]); | |
| 88 | +const skipUnwrap = { | |
| 89 | + triggerItemRefs: ref([]), | |
| 90 | + conditionItemRefs: ref([]), | |
| 91 | + actionItemRefs: ref([]), | |
| 92 | +}; | |
| 93 | +const title = computed( | |
| 94 | + () => `${isUpdate.value === 3 ? '查看' : isUpdate.value ? '编辑' : '新增'}场景联动` | |
| 95 | +); | |
| 96 | +let getTriggerFormValue = ref([]); | |
| 97 | +let getConditionFormValue = ref([]); | |
| 98 | +let getActionFormValue = ref([]); | |
| 99 | +const editEntryIdData = ref([]); | |
| 100 | +const editAlarmConfigData = ref([]); | |
| 101 | +const isUpdate = ref(false); | |
| 102 | +const id = ref(undefined); | |
| 103 | +const tenantId = ref(undefined); | |
| 104 | +const isView = ref(true); | |
| 105 | +const [registerForm, { resetFields, validate, setFieldsValue }] = useForm({ | |
| 106 | + labelWidth: 120, | |
| 107 | + schemas: formSchema, | |
| 108 | + showActionButtonGroup: false, | |
| 109 | +}); | |
| 110 | +const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { | |
| 111 | + setDrawerProps({ confirmLoading: false, loading: true }); | |
| 112 | + isUpdate.value = data.isUpdate; | |
| 113 | + if (!unref(isUpdate)) { | |
| 114 | + resetFields(); | |
| 115 | + //初始化执行动作 | |
| 116 | + actionData.value = [Date.now()]; | |
| 117 | + } else { | |
| 118 | + // 取值 | |
| 119 | + const { | |
| 120 | + id: recordId, | |
| 121 | + tenantId: recordTenantId, | |
| 122 | + organizationId, | |
| 123 | + triggers, | |
| 124 | + doConditions, | |
| 125 | + doActions, | |
| 126 | + } = data.record; | |
| 127 | + // 赋值 | |
| 128 | + await setFieldsValue(data.record); | |
| 129 | + id.value = recordId; | |
| 130 | + tenantId.value = recordTenantId; | |
| 131 | + //TODO-fengtao-把组织id传给子组件 | |
| 132 | + provideOrgid.value = organizationId; | |
| 133 | + //TODO-fengtao获取当前执行动作下的设备(master那个接口) | |
| 134 | + getMasterDeviceList.value = await byOganizationIdGetMasterDevice(organizationId); | |
| 135 | + //TODO-fengtao | |
| 136 | + // 获取当前组织下的设备列表 | |
| 137 | + const options = await screenLinkPageByDeptIdGetDevice({ | |
| 138 | + organizationId, | |
| 139 | + }); | |
| 140 | + // 获取当前组织下的告警配置 | |
| 141 | + const alarmConfig = await getOrganizationAlarmConfig({ organizationId }); | |
| 195 | 142 | |
| 196 | - const map = { | |
| 197 | - ANY_TIME: 0, | |
| 198 | - SPECIFIC_TIME: 1, | |
| 199 | - CUSTOM: 2, | |
| 143 | + // 生成回显时对应得组件数量 | |
| 144 | + triggerData.value = [...new Array(triggers.length).keys()]; | |
| 145 | + conditionData.value = [...new Array(doConditions.length).keys()]; | |
| 146 | + actionData.value = [...new Array(doActions.length).keys()]; | |
| 147 | + // 回显设备列表 | |
| 148 | + editEntryIdData.value = options.items.map((item) => { | |
| 149 | + return { | |
| 150 | + value: item.tbDeviceId, | |
| 151 | + label: item.name, | |
| 200 | 152 | }; |
| 201 | - // 回显触发器数据---此处是个闭包! | |
| 202 | - triggers.forEach((trigger, index) => { | |
| 203 | - nextTick(async () => { | |
| 204 | - const selectDeviceId = ref(''); | |
| 205 | - // 回显启用规则 | |
| 206 | - unref(skipUnwrap.triggerItemRefs)[index].currentIndex = | |
| 207 | - map[trigger.triggerCondition.schedule.type]; | |
| 208 | - unref(skipUnwrap.triggerItemRefs)[index].scheduleData = trigger.triggerCondition.schedule; | |
| 209 | - unref(skipUnwrap.triggerItemRefs)[index].isUpdate = true; | |
| 210 | - unref(skipUnwrap.triggerItemRefs)[index].alarmScheduleRef.scheduleData = | |
| 211 | - trigger.triggerCondition.schedule; | |
| 212 | - unref(skipUnwrap.triggerItemRefs)[index].setFieldsFormValueFun({ | |
| 213 | - triggered: trigger?.triggerCondition?.condition?.spec?.type, | |
| 214 | - device: trigger?.entityType, | |
| 215 | - triggerType: trigger?.triggerType, | |
| 216 | - type1: trigger?.triggerCondition?.condition?.condition[0]?.key?.type, | |
| 217 | - type2: trigger?.triggerCondition?.condition?.condition[0]?.key?.key, | |
| 218 | - operationType: trigger?.triggerCondition?.condition?.condition[0]?.valueType, | |
| 219 | - detail: trigger?.triggerCondition?.alarmDetails, | |
| 220 | - entityId: trigger?.entityId, | |
| 221 | - replaceValue: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue, | |
| 222 | - time: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue, | |
| 223 | - timeUnit: trigger?.triggerCondition?.condition?.spec?.unit, | |
| 224 | - }); | |
| 225 | - if (trigger.entityId != undefined) { | |
| 226 | - selectDeviceId.value = trigger?.entityId; | |
| 227 | - } | |
| 228 | - //fengtao-把设备id回传给子组件 | |
| 229 | - unref(skipUnwrap.triggerItemRefs)[index].updateFieldAttributeFunc( | |
| 230 | - selectDeviceId.value, | |
| 231 | - provideOrgid.value | |
| 232 | - ); | |
| 233 | - //fengtao | |
| 234 | - // 设置值operationType | |
| 235 | - unref(skipUnwrap.triggerItemRefs)[index].operationType = | |
| 236 | - trigger.triggerCondition?.condition.condition[0].valueType; | |
| 153 | + }); | |
| 154 | + editAlarmConfigData.value = alarmConfig.map((item) => { | |
| 155 | + return { | |
| 156 | + value: item.id, | |
| 157 | + label: item.name, | |
| 158 | + }; | |
| 159 | + }); | |
| 160 | + deviceList.value = editEntryIdData.value; | |
| 161 | + nextTick(() => { | |
| 162 | + setEditFields(skipUnwrap.triggerItemRefs, editEntryIdData); | |
| 163 | + setEditFields(skipUnwrap.conditionItemRefs, editEntryIdData); | |
| 164 | + setEditFields(skipUnwrap.actionItemRefs, getMasterDeviceList); | |
| 165 | + setEditAlarmConfig(skipUnwrap.actionItemRefs, editAlarmConfigData); | |
| 166 | + }); | |
| 167 | + | |
| 168 | + const map = { | |
| 169 | + ANY_TIME: 0, | |
| 170 | + SPECIFIC_TIME: 1, | |
| 171 | + CUSTOM: 2, | |
| 172 | + }; | |
| 173 | + // 回显触发器数据---此处是个闭包! | |
| 174 | + triggers.forEach((trigger, index) => { | |
| 175 | + nextTick(async () => { | |
| 176 | + const selectDeviceId = ref(''); | |
| 177 | + // 回显启用规则 | |
| 178 | + unref(skipUnwrap.triggerItemRefs)[index].currentIndex = | |
| 179 | + map[trigger.triggerCondition.schedule.type]; | |
| 180 | + unref(skipUnwrap.triggerItemRefs)[index].scheduleData = trigger.triggerCondition.schedule; | |
| 181 | + unref(skipUnwrap.triggerItemRefs)[index].isUpdate = true; | |
| 182 | + unref(skipUnwrap.triggerItemRefs)[index].alarmScheduleRef.scheduleData = | |
| 183 | + trigger.triggerCondition.schedule; | |
| 184 | + unref(skipUnwrap.triggerItemRefs)[index].setFieldsFormValueFun({ | |
| 185 | + triggered: trigger?.triggerCondition?.condition?.spec?.type, | |
| 186 | + device: trigger?.entityType, | |
| 187 | + triggerType: trigger?.triggerType, | |
| 188 | + type1: trigger?.triggerCondition?.condition?.condition[0]?.key?.type, | |
| 189 | + type2: trigger?.triggerCondition?.condition?.condition[0]?.key?.key, | |
| 190 | + operationType: trigger?.triggerCondition?.condition?.condition[0]?.valueType, | |
| 191 | + detail: trigger?.triggerCondition?.alarmDetails, | |
| 192 | + entityId: trigger?.entityId, | |
| 193 | + replaceValue: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue, | |
| 194 | + time: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue, | |
| 195 | + timeUnit: trigger?.triggerCondition?.condition?.spec?.unit, | |
| 196 | + }); | |
| 197 | + if (trigger.entityId != undefined) { | |
| 198 | + selectDeviceId.value = trigger?.entityId; | |
| 199 | + } | |
| 200 | + //fengtao-把设备id回传给子组件 | |
| 201 | + unref(skipUnwrap.triggerItemRefs)[index].updateFieldAttributeFunc( | |
| 202 | + selectDeviceId.value, | |
| 203 | + provideOrgid.value | |
| 204 | + ); | |
| 205 | + //fengtao | |
| 206 | + // 设置值operationType | |
| 207 | + unref(skipUnwrap.triggerItemRefs)[index].operationType = | |
| 208 | + trigger.triggerCondition?.condition.condition[0].valueType; | |
| 237 | 209 | |
| 238 | - const ConditionScreeningForm = await unref(skipUnwrap.triggerItemRefs)[ | |
| 239 | - index | |
| 240 | - ].getRefItemConditionScreeningRefs(); | |
| 210 | + const ConditionScreeningForm = await unref(skipUnwrap.triggerItemRefs)[ | |
| 211 | + index | |
| 212 | + ].getRefItemConditionScreeningRefs(); | |
| 241 | 213 | |
| 242 | - // 设置对应条件筛选的个数 | |
| 243 | - unref(skipUnwrap.triggerItemRefs)[index].setConditionScreeningList([ | |
| 244 | - ...new Array(trigger.triggerCondition.condition.condition.length).keys(), | |
| 245 | - ]); | |
| 246 | - // 操作符类型 NUMERIC|String|Boolean|DATE_TIME | |
| 247 | - const valueType = trigger.triggerCondition?.condition.condition[0].valueType; | |
| 214 | + // 设置对应条件筛选的个数 | |
| 215 | + unref(skipUnwrap.triggerItemRefs)[index].setConditionScreeningList([ | |
| 216 | + ...new Array(trigger.triggerCondition.condition.condition.length).keys(), | |
| 217 | + ]); | |
| 218 | + // 操作符类型 NUMERIC|String|Boolean|DATE_TIME | |
| 219 | + const valueType = trigger.triggerCondition?.condition.condition[0].valueType; | |
| 248 | 220 | |
| 249 | - // 循环设置条件筛选值。TODO:此处设置顺序有问题 | |
| 250 | - nextTick(() => { | |
| 251 | - const richTextList = []; | |
| 252 | - trigger.triggerCondition.condition.condition.forEach((item, index) => { | |
| 253 | - const formItem = { | |
| 254 | - operation: item.predicate.operation, | |
| 255 | - value: | |
| 256 | - valueType === 'DATE_TIME' | |
| 257 | - ? formatToDateTime( | |
| 258 | - Number(item.predicate.value.defaultValue), | |
| 259 | - 'YYYY-MM-DD HH:mm:ss' | |
| 260 | - ) | |
| 261 | - : String(item.predicate.value.defaultValue), | |
| 262 | - ignoreCase: item.valueType === 'STRING' ? item.predicate.ignoreCase : undefined, | |
| 263 | - }; | |
| 264 | - richTextList.push({ | |
| 265 | - // 查询中文操作符 | |
| 266 | - operation: findOperation(valueType, item.predicate.operation).label, | |
| 267 | - value: | |
| 268 | - valueType === 'DATE_TIME' | |
| 269 | - ? formatToDateTime( | |
| 270 | - Number(item.predicate.value.defaultValue), | |
| 271 | - 'YYYY-MM-DD HH:mm:ss' | |
| 272 | - ) | |
| 273 | - : String(item.predicate.value.defaultValue), | |
| 274 | - attribute: trigger.triggerCondition?.condition.condition[0]?.key?.key, | |
| 275 | - }); | |
| 276 | - ConditionScreeningForm.value[index].setFieldsValue(formItem); | |
| 221 | + // 循环设置条件筛选值。TODO:此处设置顺序有问题 | |
| 222 | + nextTick(() => { | |
| 223 | + const richTextList = []; | |
| 224 | + trigger.triggerCondition.condition.condition.forEach((item, index) => { | |
| 225 | + const formItem = { | |
| 226 | + operation: item.predicate.operation, | |
| 227 | + value: | |
| 228 | + valueType === 'DATE_TIME' | |
| 229 | + ? formatToDateTime( | |
| 230 | + Number(item.predicate.value.defaultValue), | |
| 231 | + 'YYYY-MM-DD HH:mm:ss' | |
| 232 | + ) | |
| 233 | + : String(item.predicate.value.defaultValue), | |
| 234 | + ignoreCase: item.valueType === 'STRING' ? item.predicate.ignoreCase : undefined, | |
| 235 | + }; | |
| 236 | + richTextList.push({ | |
| 237 | + // 查询中文操作符 | |
| 238 | + operation: findOperation(valueType, item.predicate.operation).label, | |
| 239 | + value: | |
| 240 | + valueType === 'DATE_TIME' | |
| 241 | + ? formatToDateTime( | |
| 242 | + Number(item.predicate.value.defaultValue), | |
| 243 | + 'YYYY-MM-DD HH:mm:ss' | |
| 244 | + ) | |
| 245 | + : String(item.predicate.value.defaultValue), | |
| 246 | + attribute: trigger.triggerCondition?.condition.condition[0]?.key?.key, | |
| 277 | 247 | }); |
| 278 | - unref(skipUnwrap.triggerItemRefs)[index].setRichText(richTextList); | |
| 248 | + ConditionScreeningForm.value[index].setFieldsValue(formItem); | |
| 279 | 249 | }); |
| 250 | + unref(skipUnwrap.triggerItemRefs)[index].setRichText(richTextList); | |
| 280 | 251 | }); |
| 281 | 252 | }); |
| 253 | + }); | |
| 282 | 254 | |
| 283 | - doConditions.forEach((condition, index) => { | |
| 284 | - nextTick(async () => { | |
| 285 | - const selectDeviceId = ref(''); | |
| 286 | - // 回显启用规则 | |
| 287 | - unref(skipUnwrap.conditionItemRefs)[index].currentIndex = | |
| 288 | - map[condition.triggerCondition.schedule.type]; | |
| 289 | - unref(skipUnwrap.conditionItemRefs)[index].scheduleData = | |
| 290 | - condition.triggerCondition.schedule; | |
| 291 | - unref(skipUnwrap.conditionItemRefs)[index].isUpdate = true; | |
| 292 | - unref(skipUnwrap.conditionItemRefs)[index].alarmScheduleRef.scheduleData = | |
| 293 | - condition.triggerCondition.schedule; | |
| 294 | - unref(skipUnwrap.conditionItemRefs)[index].setFieldsFormValueFun({ | |
| 295 | - triggered: condition?.triggerCondition?.condition?.spec?.type, | |
| 296 | - device: condition?.entityType, | |
| 297 | - triggerType: condition?.triggerType, | |
| 298 | - type1: condition?.triggerCondition?.condition?.condition[0]?.key?.type, | |
| 299 | - type2: condition?.triggerCondition?.condition?.condition[0]?.key?.key, | |
| 300 | - operationType: condition?.triggerCondition?.condition?.condition[0]?.valueType, | |
| 301 | - detail: condition?.triggerCondition?.alarmDetails, | |
| 302 | - entityId: condition?.entityId, | |
| 303 | - replaceValue: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue, | |
| 304 | - time: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue, | |
| 305 | - timeUnit: condition?.triggerCondition?.condition?.spec?.unit, | |
| 306 | - }); | |
| 307 | - if (condition?.entityId != undefined) { | |
| 308 | - selectDeviceId.value = condition?.entityId; | |
| 309 | - } | |
| 310 | - //fengtao-把设备id回传给子组件 | |
| 311 | - unref(skipUnwrap.conditionItemRefs)[index].updateFieldAttributeFunc( | |
| 312 | - selectDeviceId.value, | |
| 313 | - provideOrgid.value | |
| 314 | - ); | |
| 315 | - //fengtao | |
| 316 | - // 设置值operationType | |
| 317 | - unref(skipUnwrap.conditionItemRefs)[index].operationType = | |
| 318 | - condition.triggerCondition?.condition.condition[0].valueType; | |
| 255 | + doConditions.forEach((condition, index) => { | |
| 256 | + nextTick(async () => { | |
| 257 | + const selectDeviceId = ref(''); | |
| 258 | + // 回显启用规则 | |
| 259 | + unref(skipUnwrap.conditionItemRefs)[index].currentIndex = | |
| 260 | + map[condition.triggerCondition.schedule.type]; | |
| 261 | + unref(skipUnwrap.conditionItemRefs)[index].scheduleData = | |
| 262 | + condition.triggerCondition.schedule; | |
| 263 | + unref(skipUnwrap.conditionItemRefs)[index].isUpdate = true; | |
| 264 | + unref(skipUnwrap.conditionItemRefs)[index].alarmScheduleRef.scheduleData = | |
| 265 | + condition.triggerCondition.schedule; | |
| 266 | + unref(skipUnwrap.conditionItemRefs)[index].setFieldsFormValueFun({ | |
| 267 | + triggered: condition?.triggerCondition?.condition?.spec?.type, | |
| 268 | + device: condition?.entityType, | |
| 269 | + triggerType: condition?.triggerType, | |
| 270 | + type1: condition?.triggerCondition?.condition?.condition[0]?.key?.type, | |
| 271 | + type2: condition?.triggerCondition?.condition?.condition[0]?.key?.key, | |
| 272 | + operationType: condition?.triggerCondition?.condition?.condition[0]?.valueType, | |
| 273 | + detail: condition?.triggerCondition?.alarmDetails, | |
| 274 | + entityId: condition?.entityId, | |
| 275 | + replaceValue: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue, | |
| 276 | + time: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue, | |
| 277 | + timeUnit: condition?.triggerCondition?.condition?.spec?.unit, | |
| 278 | + }); | |
| 279 | + if (condition?.entityId != undefined) { | |
| 280 | + selectDeviceId.value = condition?.entityId; | |
| 281 | + } | |
| 282 | + //fengtao-把设备id回传给子组件 | |
| 283 | + unref(skipUnwrap.conditionItemRefs)[index].updateFieldAttributeFunc( | |
| 284 | + selectDeviceId.value, | |
| 285 | + provideOrgid.value | |
| 286 | + ); | |
| 287 | + //fengtao | |
| 288 | + // 设置值operationType | |
| 289 | + unref(skipUnwrap.conditionItemRefs)[index].operationType = | |
| 290 | + condition.triggerCondition?.condition.condition[0].valueType; | |
| 319 | 291 | |
| 320 | - const ConditionScreeningForm = await unref(skipUnwrap.conditionItemRefs)[ | |
| 321 | - index | |
| 322 | - ].getRefItemConditionScreeningRefs(); | |
| 292 | + const ConditionScreeningForm = await unref(skipUnwrap.conditionItemRefs)[ | |
| 293 | + index | |
| 294 | + ].getRefItemConditionScreeningRefs(); | |
| 323 | 295 | |
| 324 | - // 设置对应条件筛选的个数 | |
| 325 | - unref(skipUnwrap.conditionItemRefs)[index].setConditionScreeningList([ | |
| 326 | - ...new Array(condition.triggerCondition.condition.condition.length).keys(), | |
| 327 | - ]); | |
| 328 | - // 操作符类型 NUMERIC|String|Boolean|DATE_TIME | |
| 329 | - const valueType = condition.triggerCondition?.condition.condition[0].valueType; | |
| 296 | + // 设置对应条件筛选的个数 | |
| 297 | + unref(skipUnwrap.conditionItemRefs)[index].setConditionScreeningList([ | |
| 298 | + ...new Array(condition.triggerCondition.condition.condition.length).keys(), | |
| 299 | + ]); | |
| 300 | + // 操作符类型 NUMERIC|String|Boolean|DATE_TIME | |
| 301 | + const valueType = condition.triggerCondition?.condition.condition[0].valueType; | |
| 330 | 302 | |
| 331 | - // 循环设置条件筛选值。TODO:此处设置顺序有问题 | |
| 332 | - nextTick(() => { | |
| 333 | - const richTextList = []; | |
| 334 | - condition.triggerCondition.condition.condition.forEach((item, index) => { | |
| 335 | - const formItem = { | |
| 336 | - operation: item.predicate.operation, | |
| 337 | - value: | |
| 338 | - valueType === 'DATE_TIME' | |
| 339 | - ? formatToDateTime( | |
| 340 | - Number(item.predicate.value.defaultValue), | |
| 341 | - 'YYYY-MM-DD HH:mm:ss' | |
| 342 | - ) | |
| 343 | - : String(item.predicate.value.defaultValue), | |
| 344 | - ignoreCase: item.valueType === 'STRING' ? item.predicate.ignoreCase : undefined, | |
| 345 | - }; | |
| 346 | - richTextList.push({ | |
| 347 | - // 查询中文操作符 | |
| 348 | - operation: findOperation(valueType, item.predicate.operation).label, | |
| 349 | - value: | |
| 350 | - valueType === 'DATE_TIME' | |
| 351 | - ? formatToDateTime( | |
| 352 | - Number(item.predicate.value.defaultValue), | |
| 353 | - 'YYYY-MM-DD HH:mm:ss' | |
| 354 | - ) | |
| 355 | - : String(item.predicate.value.defaultValue), | |
| 356 | - attribute: condition.triggerCondition?.condition.condition[0]?.key?.key, | |
| 357 | - }); | |
| 358 | - ConditionScreeningForm.value[index].setFieldsValue(formItem); | |
| 303 | + // 循环设置条件筛选值。TODO:此处设置顺序有问题 | |
| 304 | + nextTick(() => { | |
| 305 | + const richTextList = []; | |
| 306 | + condition.triggerCondition.condition.condition.forEach((item, index) => { | |
| 307 | + const formItem = { | |
| 308 | + operation: item.predicate.operation, | |
| 309 | + value: | |
| 310 | + valueType === 'DATE_TIME' | |
| 311 | + ? formatToDateTime( | |
| 312 | + Number(item.predicate.value.defaultValue), | |
| 313 | + 'YYYY-MM-DD HH:mm:ss' | |
| 314 | + ) | |
| 315 | + : String(item.predicate.value.defaultValue), | |
| 316 | + ignoreCase: item.valueType === 'STRING' ? item.predicate.ignoreCase : undefined, | |
| 317 | + }; | |
| 318 | + richTextList.push({ | |
| 319 | + // 查询中文操作符 | |
| 320 | + operation: findOperation(valueType, item.predicate.operation).label, | |
| 321 | + value: | |
| 322 | + valueType === 'DATE_TIME' | |
| 323 | + ? formatToDateTime( | |
| 324 | + Number(item.predicate.value.defaultValue), | |
| 325 | + 'YYYY-MM-DD HH:mm:ss' | |
| 326 | + ) | |
| 327 | + : String(item.predicate.value.defaultValue), | |
| 328 | + attribute: condition.triggerCondition?.condition.condition[0]?.key?.key, | |
| 359 | 329 | }); |
| 360 | - unref(skipUnwrap.conditionItemRefs)[index].setRichText(richTextList); | |
| 330 | + ConditionScreeningForm.value[index].setFieldsValue(formItem); | |
| 361 | 331 | }); |
| 332 | + unref(skipUnwrap.conditionItemRefs)[index].setRichText(richTextList); | |
| 362 | 333 | }); |
| 363 | 334 | }); |
| 335 | + }); | |
| 364 | 336 | |
| 365 | - doActions.forEach((action, index) => { | |
| 366 | - nextTick(() => { | |
| 367 | - const selectDeviceId = ref(''); | |
| 368 | - // 设置执行动作外层值 | |
| 369 | - unref(skipUnwrap.actionItemRefs)[index].setFieldsFormValueFun({ | |
| 370 | - outTarget: action.outTarget, | |
| 371 | - device: action.entityType, | |
| 372 | - deviceId: action.deviceId, | |
| 373 | - alarm_config: action.alarmProfileId, | |
| 374 | - alarm_level: action.doContext.alarmLevel, | |
| 375 | - }); | |
| 376 | - // 如果是设备输出设置脚本值 | |
| 377 | - if (action.outTarget === 'DEVICE_OUT') { | |
| 378 | - unref(skipUnwrap.actionItemRefs)[index].setJsonValue(action.doContext.params); | |
| 379 | - } | |
| 380 | - // 清除告警有值?{数组} | |
| 381 | - if (action?.doContext?.clearRule?.length) { | |
| 382 | - unref(skipUnwrap.actionItemRefs)[index].checked = true; | |
| 383 | - // 生成对应清除告警的数组长度 | |
| 384 | - unref(skipUnwrap.actionItemRefs)[index].clearRuleList = [ | |
| 385 | - ...new Array(action?.doContext?.clearRule?.length).keys(), | |
| 386 | - ]; | |
| 387 | - // 推迟执行时机-DOM渲染完毕在执行 | |
| 388 | - nextTick(async () => { | |
| 389 | - unref(skipUnwrap.actionItemRefs)[index].refItem.clearRuleRefs.value.map( | |
| 390 | - (item, index) => { | |
| 391 | - // 回显启用规则 | |
| 392 | - item.currentIndex = | |
| 393 | - map[action.doContext.clearRule[index].triggerCondition.schedule.type]; | |
| 394 | - item.scheduleData = action.doContext.clearRule[index].triggerCondition.schedule; | |
| 395 | - item.isUpdate = true; | |
| 396 | - item.alarmScheduleRef.scheduleData = | |
| 397 | - action.doContext.clearRule[index].triggerCondition.schedule; | |
| 398 | - item.setFieldsFormValueFun({ | |
| 399 | - triggered: | |
| 400 | - action.doContext.clearRule[index].triggerCondition.condition.spec.type, | |
| 401 | - device: action.doContext.clearRule[index].entityType, | |
| 402 | - triggerType: action.doContext.clearRule[index].triggerType, | |
| 403 | - type1: | |
| 404 | - action.doContext.clearRule[index].triggerCondition.condition.condition[0].key | |
| 405 | - .type, | |
| 406 | - type2: | |
| 407 | - action.doContext.clearRule[index].triggerCondition.condition.condition[0].key | |
| 408 | - .key, | |
| 409 | - operationType: | |
| 410 | - action.doContext.clearRule[index].triggerCondition.condition.condition[0] | |
| 411 | - .valueType, | |
| 412 | - detail: action.doContext.clearRule[index].triggerCondition.alarmDetails, | |
| 413 | - entityId: action.doContext.clearRule[index].entityId, | |
| 414 | - replaceValue: | |
| 415 | - action.doContext.clearRule[index].triggerCondition.condition.spec.predicate | |
| 416 | - .defaultValue, | |
| 417 | - time: action.doContext.clearRule[index].triggerCondition.condition.spec | |
| 418 | - .predicate.defaultValue, | |
| 419 | - timeUnit: | |
| 420 | - action.doContext.clearRule[index].triggerCondition.condition.spec.unit, | |
| 421 | - }); | |
| 422 | - if (action.doContext.clearRule[index].entityId != undefined) { | |
| 423 | - selectDeviceId.value = action.doContext.clearRule[index].entityId; | |
| 424 | - } | |
| 425 | - //fengtao-把设备id回传给子组件 | |
| 426 | - item.updateFieldAttributeFunc(selectDeviceId.value, provideOrgid.value); | |
| 427 | - item.updateFieldDeviceId( | |
| 428 | - deviceList.value, | |
| 429 | - provideOrgid.value, | |
| 430 | - isUpdate.value, | |
| 431 | - getMasterDeviceList.value | |
| 432 | - ); | |
| 433 | - //fengtao | |
| 434 | - // 单独设置operationType值 操作符类型 NUMERIC|String|Boolean|DATE_TIME | |
| 435 | - item.operationType = | |
| 436 | - action.doContext.clearRule[ | |
| 437 | - index | |
| 438 | - ].triggerCondition.condition.condition[0].valueType; | |
| 337 | + doActions.forEach((action, index) => { | |
| 338 | + nextTick(() => { | |
| 339 | + const selectDeviceId = ref(''); | |
| 340 | + // 设置执行动作外层值 | |
| 341 | + unref(skipUnwrap.actionItemRefs)[index].setFieldsFormValueFun({ | |
| 342 | + outTarget: action.outTarget, | |
| 343 | + device: action.entityType, | |
| 344 | + deviceId: action.deviceId, | |
| 345 | + alarm_config: action.alarmProfileId, | |
| 346 | + alarm_level: action.doContext.alarmLevel, | |
| 347 | + }); | |
| 348 | + // 如果是设备输出设置脚本值 | |
| 349 | + if (action.outTarget === 'DEVICE_OUT') { | |
| 350 | + unref(skipUnwrap.actionItemRefs)[index].setJsonValue(action.doContext.params); | |
| 351 | + } | |
| 352 | + // 清除告警有值?{数组} | |
| 353 | + if (action?.doContext?.clearRule?.length) { | |
| 354 | + unref(skipUnwrap.actionItemRefs)[index].checked = true; | |
| 355 | + // 生成对应清除告警的数组长度 | |
| 356 | + unref(skipUnwrap.actionItemRefs)[index].clearRuleList = [ | |
| 357 | + ...new Array(action?.doContext?.clearRule?.length).keys(), | |
| 358 | + ]; | |
| 359 | + // 推迟执行时机-DOM渲染完毕在执行 | |
| 360 | + nextTick(async () => { | |
| 361 | + unref(skipUnwrap.actionItemRefs)[index].refItem.clearRuleRefs.value.map( | |
| 362 | + (item, index) => { | |
| 363 | + // 回显启用规则 | |
| 364 | + item.currentIndex = | |
| 365 | + map[action.doContext.clearRule[index].triggerCondition.schedule.type]; | |
| 366 | + item.scheduleData = action.doContext.clearRule[index].triggerCondition.schedule; | |
| 367 | + item.isUpdate = true; | |
| 368 | + item.alarmScheduleRef.scheduleData = | |
| 369 | + action.doContext.clearRule[index].triggerCondition.schedule; | |
| 370 | + item.setFieldsFormValueFun({ | |
| 371 | + triggered: | |
| 372 | + action.doContext.clearRule[index].triggerCondition.condition.spec.type, | |
| 373 | + device: action.doContext.clearRule[index].entityType, | |
| 374 | + triggerType: action.doContext.clearRule[index].triggerType, | |
| 375 | + type1: | |
| 376 | + action.doContext.clearRule[index].triggerCondition.condition.condition[0].key | |
| 377 | + .type, | |
| 378 | + type2: | |
| 379 | + action.doContext.clearRule[index].triggerCondition.condition.condition[0].key | |
| 380 | + .key, | |
| 381 | + operationType: | |
| 382 | + action.doContext.clearRule[index].triggerCondition.condition.condition[0] | |
| 383 | + .valueType, | |
| 384 | + detail: action.doContext.clearRule[index].triggerCondition.alarmDetails, | |
| 385 | + entityId: action.doContext.clearRule[index].entityId, | |
| 386 | + replaceValue: | |
| 387 | + action.doContext.clearRule[index].triggerCondition.condition.spec.predicate | |
| 388 | + .defaultValue, | |
| 389 | + time: action.doContext.clearRule[index].triggerCondition.condition.spec | |
| 390 | + .predicate.defaultValue, | |
| 391 | + timeUnit: | |
| 392 | + action.doContext.clearRule[index].triggerCondition.condition.spec.unit, | |
| 393 | + }); | |
| 394 | + if (action.doContext.clearRule[index].entityId != undefined) { | |
| 395 | + selectDeviceId.value = action.doContext.clearRule[index].entityId; | |
| 439 | 396 | } |
| 440 | - ); | |
| 397 | + //fengtao-把设备id回传给子组件 | |
| 398 | + item.updateFieldAttributeFunc(selectDeviceId.value, provideOrgid.value); | |
| 399 | + item.updateFieldDeviceId( | |
| 400 | + deviceList.value, | |
| 401 | + provideOrgid.value, | |
| 402 | + isUpdate.value, | |
| 403 | + getMasterDeviceList.value | |
| 404 | + ); | |
| 405 | + //fengtao | |
| 406 | + // 单独设置operationType值 操作符类型 NUMERIC|String|Boolean|DATE_TIME | |
| 407 | + item.operationType = | |
| 408 | + action.doContext.clearRule[ | |
| 409 | + index | |
| 410 | + ].triggerCondition.condition.condition[0].valueType; | |
| 411 | + } | |
| 412 | + ); | |
| 441 | 413 | |
| 442 | - const ConditionScreeningForm = await unref(skipUnwrap.actionItemRefs)[ | |
| 443 | - index | |
| 444 | - ].getRefItemConditionScreeningRefs(); | |
| 414 | + const ConditionScreeningForm = await unref(skipUnwrap.actionItemRefs)[ | |
| 415 | + index | |
| 416 | + ].getRefItemConditionScreeningRefs(); | |
| 445 | 417 | |
| 446 | - // 循环设置条件筛选值。TODO:此处设置顺序有问题 | |
| 447 | - action.doContext.clearRule.map((rule, ruleIndex) => { | |
| 448 | - // 生成对应条件筛选的数组个数 | |
| 449 | - unref(skipUnwrap.actionItemRefs)[index].setConditionScreeningList([ | |
| 450 | - ...new Array( | |
| 451 | - action.doContext.clearRule[ | |
| 452 | - ruleIndex | |
| 453 | - ].triggerCondition.condition.condition.length | |
| 454 | - ).keys(), | |
| 455 | - ]); | |
| 456 | - nextTick(() => { | |
| 457 | - const richTextList = []; | |
| 458 | - rule.triggerCondition.condition.condition.forEach((item, conditionIndex) => { | |
| 459 | - //TODO-fengtao之前是Number( item.predicate.value.defaultValue)-发现回显是Invalide Time | |
| 460 | - const formItem = { | |
| 461 | - operation: item.predicate.operation, | |
| 462 | - value: | |
| 463 | - item.valueType === 'DATE_TIME' | |
| 464 | - ? formatToDateTime( | |
| 465 | - Number(item.predicate.value.defaultValue), | |
| 466 | - 'YYYY-MM-DD HH:mm:ss' | |
| 467 | - ) | |
| 468 | - : String(item.predicate.value.defaultValue), | |
| 469 | - ignoreCase: | |
| 470 | - item.valueType === 'STRING' ? item.predicate.ignoreCase : undefined, | |
| 471 | - }; | |
| 472 | - //TODO-fengtao之前是Number( item.predicate.value.defaultValue)-发现回显是Invalide Time | |
| 473 | - richTextList.push({ | |
| 474 | - // 查询中文操作符 | |
| 475 | - operation: findOperation(item.valueType, item.predicate.operation).label, | |
| 476 | - value: | |
| 477 | - item.valueType === 'DATE_TIME' | |
| 478 | - ? formatToDateTime( | |
| 479 | - item.predicate.value.defaultValue, | |
| 480 | - 'YYYY-MM-DD HH:mm:ss' | |
| 481 | - ) | |
| 482 | - : String(item.predicate.value.defaultValue), | |
| 483 | - attribute: item?.key?.key, | |
| 484 | - }); | |
| 485 | - //TODO-fengtao之前是Number( item.predicate.value.defaultValue)-发现回显是Invalide Time | |
| 486 | - ConditionScreeningForm[ruleIndex].value[conditionIndex].setFieldsValue( | |
| 487 | - formItem | |
| 488 | - ); | |
| 418 | + // 循环设置条件筛选值。TODO:此处设置顺序有问题 | |
| 419 | + action.doContext.clearRule.map((rule, ruleIndex) => { | |
| 420 | + // 生成对应条件筛选的数组个数 | |
| 421 | + unref(skipUnwrap.actionItemRefs)[index].setConditionScreeningList([ | |
| 422 | + ...new Array( | |
| 423 | + action.doContext.clearRule[ | |
| 424 | + ruleIndex | |
| 425 | + ].triggerCondition.condition.condition.length | |
| 426 | + ).keys(), | |
| 427 | + ]); | |
| 428 | + nextTick(() => { | |
| 429 | + const richTextList = []; | |
| 430 | + rule.triggerCondition.condition.condition.forEach((item, conditionIndex) => { | |
| 431 | + //TODO-fengtao之前是Number( item.predicate.value.defaultValue)-发现回显是Invalide Time | |
| 432 | + const formItem = { | |
| 433 | + operation: item.predicate.operation, | |
| 434 | + value: | |
| 435 | + item.valueType === 'DATE_TIME' | |
| 436 | + ? formatToDateTime( | |
| 437 | + Number(item.predicate.value.defaultValue), | |
| 438 | + 'YYYY-MM-DD HH:mm:ss' | |
| 439 | + ) | |
| 440 | + : String(item.predicate.value.defaultValue), | |
| 441 | + ignoreCase: | |
| 442 | + item.valueType === 'STRING' ? item.predicate.ignoreCase : undefined, | |
| 443 | + }; | |
| 444 | + //TODO-fengtao之前是Number( item.predicate.value.defaultValue)-发现回显是Invalide Time | |
| 445 | + richTextList.push({ | |
| 446 | + // 查询中文操作符 | |
| 447 | + operation: findOperation(item.valueType, item.predicate.operation).label, | |
| 448 | + value: | |
| 449 | + item.valueType === 'DATE_TIME' | |
| 450 | + ? formatToDateTime( | |
| 451 | + item.predicate.value.defaultValue, | |
| 452 | + 'YYYY-MM-DD HH:mm:ss' | |
| 453 | + ) | |
| 454 | + : String(item.predicate.value.defaultValue), | |
| 455 | + attribute: item?.key?.key, | |
| 489 | 456 | }); |
| 490 | - unref(skipUnwrap.actionItemRefs)[index].setRichText(richTextList, ruleIndex); | |
| 457 | + //TODO-fengtao之前是Number( item.predicate.value.defaultValue)-发现回显是Invalide Time | |
| 458 | + ConditionScreeningForm[ruleIndex].value[conditionIndex].setFieldsValue( | |
| 459 | + formItem | |
| 460 | + ); | |
| 491 | 461 | }); |
| 462 | + unref(skipUnwrap.actionItemRefs)[index].setRichText(richTextList, ruleIndex); | |
| 492 | 463 | }); |
| 493 | 464 | }); |
| 494 | - } | |
| 495 | - nextTick(() => { | |
| 496 | - setEditFields(skipUnwrap.actionItemRefs, editEntryIdData); | |
| 497 | 465 | }); |
| 466 | + } | |
| 467 | + nextTick(() => { | |
| 468 | + setEditFields(skipUnwrap.actionItemRefs, editEntryIdData); | |
| 498 | 469 | }); |
| 499 | 470 | }); |
| 500 | - } | |
| 501 | - if (unref(isUpdate) === 3) isView.value = false; | |
| 502 | - setDrawerProps({ | |
| 503 | - showFooter: unref(isView), | |
| 504 | - loading: false, | |
| 505 | 471 | }); |
| 472 | + } | |
| 473 | + if (unref(isUpdate) === 3) isView.value = false; | |
| 474 | + setDrawerProps({ | |
| 475 | + showFooter: unref(isView), | |
| 476 | + loading: false, | |
| 506 | 477 | }); |
| 478 | +}); | |
| 507 | 479 | |
| 508 | - // 设置设备的options | |
| 509 | - const setEditFields = (linkAge, deviceList) => { | |
| 510 | - unref(linkAge).map((item) => { | |
| 511 | - //TODO-fengtao | |
| 512 | - item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList); | |
| 513 | - //TODO-fengtao | |
| 514 | - }); | |
| 515 | - }; | |
| 516 | - // 设置告警配置options | |
| 517 | - const setEditAlarmConfig = (linkAge, alarmConfigList) => { | |
| 518 | - unref(linkAge).map((item) => { | |
| 519 | - item.updateEditFieldAlarmConfig(alarmConfigList); | |
| 520 | - }); | |
| 521 | - }; | |
| 522 | - // 监听组织变化更新设备列表 | |
| 523 | - const deviceList = ref([]); | |
| 524 | - const getMasterDeviceList = ref([]); | |
| 525 | - const orgId = ref(''); | |
| 526 | - const alarmConfigList = ref([]); | |
| 527 | - watch(organizationId, async (newValue: string) => { | |
| 528 | - if (!newValue) return; | |
| 529 | - const { items } = await screenLinkPageByDeptIdGetDevice({ organizationId: newValue }); | |
| 530 | - //TODO fengtao | |
| 531 | - getMasterDeviceList.value = await byOganizationIdGetMasterDevice(newValue); | |
| 532 | - //TODO fengtao | |
| 533 | - deviceList.value = items.map((item) => ({ label: item.name, value: item.tbDeviceId })); | |
| 480 | + | |
| 481 | +// 设置设备的options | |
| 482 | +const setEditFields = (linkAge, deviceList) => { | |
| 483 | + unref(linkAge).map((item) => { | |
| 484 | + //TODO-fengtao | |
| 485 | + item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList); | |
| 486 | + //TODO-fengtao | |
| 487 | + }); | |
| 488 | +}; | |
| 489 | +// 设置告警配置options | |
| 490 | +const setEditAlarmConfig = (linkAge, alarmConfigList) => { | |
| 491 | + unref(linkAge).map((item) => { | |
| 492 | + item.updateEditFieldAlarmConfig(alarmConfigList); | |
| 493 | + }); | |
| 494 | +}; | |
| 495 | +// 监听组织变化更新设备列表 | |
| 496 | +const deviceList = ref([]); | |
| 497 | +const getMasterDeviceList = ref([]); | |
| 498 | +const orgId = ref(''); | |
| 499 | +const alarmConfigList = ref([]); | |
| 500 | +watch(organizationId, async (newValue: string) => { | |
| 501 | + if (!newValue) return; | |
| 502 | + const { items } = await screenLinkPageByDeptIdGetDevice({ organizationId: newValue }); | |
| 503 | + //TODO fengtao | |
| 504 | + getMasterDeviceList.value = await byOganizationIdGetMasterDevice(newValue); | |
| 505 | + //TODO fengtao | |
| 506 | + deviceList.value = items.map((item) => ({ label: item.name, value: item.tbDeviceId })); | |
| 507 | + //TODO fengtao | |
| 508 | + orgId.value = newValue; | |
| 509 | + //TODO fengtao | |
| 510 | + setFields(skipUnwrap.triggerItemRefs, true); | |
| 511 | + setFields(skipUnwrap.conditionItemRefs, true); | |
| 512 | + setFields(skipUnwrap.actionItemRefs, true); | |
| 513 | + const data = await getOrganizationAlarmConfig({ organizationId: newValue }); | |
| 514 | + alarmConfigList.value = data.map((item) => ({ label: item.name, value: item.id })); | |
| 515 | + setAlarmConfig(skipUnwrap.actionItemRefs, true); | |
| 516 | +}); | |
| 517 | + | |
| 518 | +// 根据上面组织变化动态改变触发器,执行条件,执行动作的设备值 | |
| 519 | +function setFields(linkAge, isOrganizationChange = false) { | |
| 520 | + unref(linkAge).map((item) => { | |
| 521 | + isOrganizationChange && item.resetFieldsValueFunc(); | |
| 534 | 522 | //TODO fengtao |
| 535 | - orgId.value = newValue; | |
| 523 | + item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList); | |
| 536 | 524 | //TODO fengtao |
| 537 | - setFields(skipUnwrap.triggerItemRefs, true); | |
| 538 | - setFields(skipUnwrap.conditionItemRefs, true); | |
| 539 | - setFields(skipUnwrap.actionItemRefs, true); | |
| 540 | - const data = await getOrganizationAlarmConfig({ organizationId: newValue }); | |
| 541 | - alarmConfigList.value = data.map((item) => ({ label: item.name, value: item.id })); | |
| 542 | - setAlarmConfig(skipUnwrap.actionItemRefs, true); | |
| 543 | 525 | }); |
| 526 | +} | |
| 527 | +function setAlarmConfig(linkAge, isOrganizationChange = false) { | |
| 528 | + unref(linkAge).map((item) => { | |
| 529 | + isOrganizationChange && item.resetFieldsValueFunc(); | |
| 530 | + item.updateFieldAlarmConfig(alarmConfigList); | |
| 531 | + }); | |
| 532 | +} | |
| 533 | +// 添加触发器 | |
| 534 | +const addTrigger = () => { | |
| 535 | + unref(triggerData).push(Date.now()); | |
| 536 | + nextTick(() => { | |
| 537 | + setFields(skipUnwrap.triggerItemRefs); | |
| 538 | + }); | |
| 539 | +}; | |
| 540 | +// 添加执行条件 | |
| 541 | +const addCondition = () => { | |
| 542 | + unref(conditionData).push(Date.now()); | |
| 543 | + nextTick(() => { | |
| 544 | + setFields(skipUnwrap.conditionItemRefs); | |
| 545 | + }); | |
| 546 | +}; | |
| 547 | +// 添加执行动作 | |
| 548 | +const addAction = () => { | |
| 549 | + unref(actionData).push(Date.now()); | |
| 550 | + nextTick(() => { | |
| 551 | + setFields(skipUnwrap.actionItemRefs); | |
| 552 | + }); | |
| 553 | +}; | |
| 544 | 554 | |
| 545 | - // 根据上面组织变化动态改变触发器,执行条件,执行动作的设备值 | |
| 546 | - function setFields(linkAge, isOrganizationChange = false) { | |
| 547 | - unref(linkAge).map((item) => { | |
| 548 | - isOrganizationChange && item.resetFieldsValueFunc(); | |
| 549 | - //TODO fengtao | |
| 550 | - item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList); | |
| 551 | - //TODO fengtao | |
| 552 | - }); | |
| 555 | +/** | |
| 556 | + * 获取触发器、执行条件、执行动作表单值--多个 | |
| 557 | + */ | |
| 558 | +const getFormValueFunc = () => { | |
| 559 | + getTriggerFormValue.value = unref(skipUnwrap.triggerItemRefs)?.map((item) => | |
| 560 | + genTriggerOrConditionData(item.getFieldsValueFunc()) | |
| 561 | + ); | |
| 562 | + getConditionFormValue.value = unref(skipUnwrap.conditionItemRefs)?.map((item) => | |
| 563 | + genTriggerOrConditionData(item.getFieldsValueFunc()) | |
| 564 | + ); | |
| 565 | + getActionFormValue.value = unref(skipUnwrap.actionItemRefs)?.map((item) => | |
| 566 | + genActionData(item.getFieldsValueFunc()) | |
| 567 | + ); | |
| 568 | +}; | |
| 569 | +const handleSubmit = async () => { | |
| 570 | + let basicFormValue = await validate(); | |
| 571 | + if (!basicFormValue) return; | |
| 572 | + for (const item of unref(skipUnwrap.actionItemRefs)) { | |
| 573 | + const valid = await item.validateForm(); | |
| 574 | + if (!valid) return; | |
| 553 | 575 | } |
| 554 | - function setAlarmConfig(linkAge, isOrganizationChange = false) { | |
| 555 | - unref(linkAge).map((item) => { | |
| 556 | - isOrganizationChange && item.resetFieldsValueFunc(); | |
| 557 | - item.updateFieldAlarmConfig(alarmConfigList); | |
| 558 | - }); | |
| 576 | + try { | |
| 577 | + setDrawerProps({ confirmLoading: true }); | |
| 578 | + getFormValueFunc(); | |
| 579 | + const postAddOrEditData = { | |
| 580 | + ...basicFormValue, | |
| 581 | + triggers: !unref(getTriggerFormValue).length ? null : unref(getTriggerFormValue), | |
| 582 | + doConditions: !unref(getConditionFormValue).length ? null : unref(getConditionFormValue), | |
| 583 | + doActions: unref(getActionFormValue).flat(), | |
| 584 | + id: unref(id), | |
| 585 | + tenantId: unref(tenantId), | |
| 586 | + }; | |
| 587 | + await screenLinkPageAddApi(postAddOrEditData, unref(isUpdate)); | |
| 588 | + createMessage.success(`${unref(isUpdate) ? '编辑' : '新增'}成功`); | |
| 589 | + closeDrawer(); | |
| 590 | + handleClose(); | |
| 591 | + emit('success'); | |
| 592 | + } finally { | |
| 593 | + setDrawerProps({ confirmLoading: false }); | |
| 559 | 594 | } |
| 560 | - // 添加触发器 | |
| 561 | - const addTrigger = () => { | |
| 562 | - unref(triggerData).push(Date.now()); | |
| 563 | - nextTick(() => { | |
| 564 | - setFields(skipUnwrap.triggerItemRefs); | |
| 565 | - }); | |
| 566 | - }; | |
| 567 | - // 添加执行条件 | |
| 568 | - const addCondition = () => { | |
| 569 | - unref(conditionData).push(Date.now()); | |
| 570 | - nextTick(() => { | |
| 571 | - setFields(skipUnwrap.conditionItemRefs); | |
| 572 | - }); | |
| 573 | - }; | |
| 574 | - // 添加执行动作 | |
| 575 | - const addAction = () => { | |
| 576 | - unref(actionData).push(Date.now()); | |
| 577 | - nextTick(() => { | |
| 578 | - setFields(skipUnwrap.actionItemRefs); | |
| 579 | - }); | |
| 580 | - }; | |
| 581 | - | |
| 582 | - /** | |
| 583 | - * 获取触发器、执行条件、执行动作表单值--多个 | |
| 584 | - */ | |
| 585 | - const getFormValueFunc = () => { | |
| 586 | - getTriggerFormValue.value = unref(skipUnwrap.triggerItemRefs)?.map((item) => | |
| 587 | - genTriggerOrConditionData(item.getFieldsValueFunc()) | |
| 588 | - ); | |
| 589 | - getConditionFormValue.value = unref(skipUnwrap.conditionItemRefs)?.map((item) => | |
| 590 | - genTriggerOrConditionData(item.getFieldsValueFunc()) | |
| 591 | - ); | |
| 592 | - getActionFormValue.value = unref(skipUnwrap.actionItemRefs)?.map((item) => | |
| 593 | - genActionData(item.getFieldsValueFunc()) | |
| 594 | - ); | |
| 595 | - }; | |
| 596 | - const handleSubmit = async () => { | |
| 597 | - let basicFormValue = await validate(); | |
| 598 | - if (!basicFormValue) return; | |
| 599 | - for (const item of unref(skipUnwrap.actionItemRefs)) { | |
| 600 | - const valid = await item.validateForm(); | |
| 601 | - if (!valid) return; | |
| 602 | - } | |
| 603 | - try { | |
| 604 | - setDrawerProps({ confirmLoading: true }); | |
| 605 | - getFormValueFunc(); | |
| 606 | - const postAddOrEditData = { | |
| 607 | - ...basicFormValue, | |
| 608 | - triggers: !unref(getTriggerFormValue).length ? null : unref(getTriggerFormValue), | |
| 609 | - doConditions: !unref(getConditionFormValue).length ? null : unref(getConditionFormValue), | |
| 610 | - doActions: unref(getActionFormValue).flat(), | |
| 611 | - id: unref(id), | |
| 612 | - tenantId: unref(tenantId), | |
| 613 | - }; | |
| 614 | - await screenLinkPageAddApi(postAddOrEditData, unref(isUpdate)); | |
| 615 | - createMessage.success(`${unref(isUpdate) ? '编辑' : '新增'}成功`); | |
| 616 | - closeDrawer(); | |
| 617 | - handleClose(); | |
| 618 | - emit('success'); | |
| 619 | - } finally { | |
| 620 | - setDrawerProps({ confirmLoading: false }); | |
| 621 | - } | |
| 622 | - }; | |
| 623 | - // 删除 | |
| 624 | - const deleteTriggerOrCondition = ({ index, title }) => { | |
| 625 | - if (title === '触发器') { | |
| 626 | - unref(triggerData).splice(index, 1); | |
| 627 | - } else if (title === '执行条件') { | |
| 628 | - unref(conditionData).splice(index, 1); | |
| 629 | - } | |
| 630 | - }; | |
| 631 | - const deleteAction = (actionIndex) => { | |
| 632 | - unref(actionData).splice(actionIndex, 1); | |
| 633 | - unref(arr).splice(actionIndex, 1); | |
| 634 | - }; | |
| 635 | - const arr = ref([]); | |
| 636 | - const getActionFormArr = () => { | |
| 637 | - arr.value = unref(skipUnwrap.actionItemRefs).map((item) => item.getFieldsValue()); | |
| 638 | - }; | |
| 639 | - const handleClose = () => { | |
| 640 | - id.value = undefined; | |
| 641 | - tenantId.value = undefined; | |
| 642 | - organizationId.value = undefined; | |
| 643 | - isView.value = true; | |
| 644 | - getTriggerFormValue.value = []; | |
| 645 | - getConditionFormValue.value = []; | |
| 646 | - getActionFormValue.value = []; | |
| 647 | - triggerData.value = []; | |
| 648 | - conditionData.value = []; | |
| 649 | - actionData.value = []; | |
| 650 | - unref(skipUnwrap.triggerItemRefs).map((item) => { | |
| 651 | - item.resetFieldsValueFunc(); | |
| 652 | - }); | |
| 653 | - unref(skipUnwrap.conditionItemRefs).map((item) => { | |
| 654 | - item.resetFieldsValueFunc(); | |
| 655 | - }); | |
| 656 | - unref(skipUnwrap.actionItemRefs).map((item) => { | |
| 657 | - item.resetFieldsValueFunc(); | |
| 658 | - }); | |
| 659 | - }; | |
| 595 | +}; | |
| 596 | +// 删除 | |
| 597 | +const deleteTriggerOrCondition = ({ index, title }) => { | |
| 598 | + if (title === '触发器') { | |
| 599 | + unref(triggerData).splice(index, 1); | |
| 600 | + } else if (title === '执行条件') { | |
| 601 | + unref(conditionData).splice(index, 1); | |
| 602 | + } | |
| 603 | +}; | |
| 604 | +const deleteAction = (actionIndex) => { | |
| 605 | + unref(actionData).splice(actionIndex, 1); | |
| 606 | + unref(arr).splice(actionIndex, 1); | |
| 607 | +}; | |
| 608 | +const arr = ref([]); | |
| 609 | +const getActionFormArr = () => { | |
| 610 | + arr.value = unref(skipUnwrap.actionItemRefs).map((item) => item.getFieldsValue()); | |
| 611 | +}; | |
| 612 | +const handleClose = () => { | |
| 613 | + id.value = undefined; | |
| 614 | + tenantId.value = undefined; | |
| 615 | + organizationId.value = undefined; | |
| 616 | + isView.value = true; | |
| 617 | + getTriggerFormValue.value = []; | |
| 618 | + getConditionFormValue.value = []; | |
| 619 | + getActionFormValue.value = []; | |
| 620 | + triggerData.value = []; | |
| 621 | + conditionData.value = []; | |
| 622 | + actionData.value = []; | |
| 623 | + unref(skipUnwrap.triggerItemRefs).map((item) => { | |
| 624 | + item.resetFieldsValueFunc(); | |
| 625 | + }); | |
| 626 | + unref(skipUnwrap.conditionItemRefs).map((item) => { | |
| 627 | + item.resetFieldsValueFunc(); | |
| 628 | + }); | |
| 629 | + unref(skipUnwrap.actionItemRefs).map((item) => { | |
| 630 | + item.resetFieldsValueFunc(); | |
| 631 | + }); | |
| 632 | + window.localStorage.removeItem('isViewDisabledBtn') | |
| 633 | + // window.localStorage.setItem('isViewDisabledBtn', 'no') | |
| 634 | +}; | |
| 660 | 635 | </script> |
| 661 | 636 | |
| 662 | 637 | <style lang="less" scoped> |
| 663 | - //TODO-fengtao | |
| 664 | - ///移除选择框默认样式(24px)否则超出默认宽度会造成页面样式错乱 | |
| 665 | - :deep(.ant-select-selector) { | |
| 666 | - padding-right: 0px !important; | |
| 667 | - } | |
| 638 | +//TODO-fengtao | |
| 639 | +///移除选择框默认样式(24px)否则超出默认宽度会造成页面样式错乱 | |
| 640 | +:deep(.ant-select-selector) { | |
| 641 | + padding-right: 0px !important; | |
| 642 | +} | |
| 668 | 643 | |
| 669 | - :deep(.ant-select-selection-overflow) { | |
| 670 | - max-width: 10vw !important; | |
| 671 | - } | |
| 672 | - //TODO-fengtao | |
| 644 | +:deep(.ant-select-selection-overflow) { | |
| 645 | + max-width: 10vw !important; | |
| 646 | +} | |
| 647 | + | |
| 648 | +//TODO-fengtao | |
| 673 | 649 | </style> | ... | ... |
| ... | ... | @@ -2,8 +2,8 @@ import { ref } from 'vue'; |
| 2 | 2 | import { BasicColumn, FormSchema } from '/@/components/Table'; |
| 3 | 3 | import { screenLinkOrganizationGetApi } from '/@/api/ruleengine/ruleengineApi'; |
| 4 | 4 | import { scheduleOptions } from './formatData'; |
| 5 | - | |
| 6 | 5 | import { copyTransFun } from '/@/utils/fnUtils'; |
| 6 | +import { numberAndNonegativeRule,numberAndEngLishRule } from '/@/utils/rules'; | |
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * 所使用的枚举值 |
| ... | ... | @@ -208,6 +208,7 @@ export const trigger_condition_schema: FormSchema[] = [ |
| 208 | 208 | ifShow: ({ values }) => isTimeDuration(values.triggered), |
| 209 | 209 | colProps: { span: 6 }, |
| 210 | 210 | slot: 'time', |
| 211 | + rules: numberAndNonegativeRule, | |
| 211 | 212 | }, |
| 212 | 213 | { |
| 213 | 214 | field: 'timeUnit', |
| ... | ... | @@ -226,6 +227,7 @@ export const trigger_condition_schema: FormSchema[] = [ |
| 226 | 227 | }, |
| 227 | 228 | ifShow: ({ values }) => isReplace(values.triggered), |
| 228 | 229 | colProps: { span: 6 }, |
| 230 | + rules: numberAndNonegativeRule, | |
| 229 | 231 | }, |
| 230 | 232 | { |
| 231 | 233 | field: 'triggerType', |
| ... | ... | @@ -263,6 +265,7 @@ export const trigger_condition_schema: FormSchema[] = [ |
| 263 | 265 | }, |
| 264 | 266 | ifShow: ({ values }) => isDevice(values.triggerType), |
| 265 | 267 | colProps: { span: 6 }, |
| 268 | + rules: numberAndEngLishRule, | |
| 266 | 269 | }, |
| 267 | 270 | { |
| 268 | 271 | field: 'operationType', | ... | ... |
| 1 | 1 | import { formatToDateTime } from '/@/utils/dateUtil'; |
| 2 | 2 | import { Number_Operation, String_Operation, Boolean_Operation } from '/@/enums/operationEnum'; |
| 3 | +import { numberAndNonegativeRule } from '/@/utils/rules'; | |
| 4 | + | |
| 3 | 5 | // 生成触发器或执行条件JSON数据 |
| 4 | 6 | export const genTriggerOrConditionData = (triggerData) => { |
| 5 | 7 | const { |
| ... | ... | @@ -244,6 +246,10 @@ export function isType(operationType) { |
| 244 | 246 | label: '操作值', |
| 245 | 247 | required: true, |
| 246 | 248 | component: 'InputNumber', |
| 249 | + componentProps: { | |
| 250 | + min: 0, | |
| 251 | + max: 99999999999, | |
| 252 | + }, | |
| 247 | 253 | colProps: { |
| 248 | 254 | span: 8, |
| 249 | 255 | }, |
| ... | ... | @@ -256,7 +262,7 @@ export function isType(operationType) { |
| 256 | 262 | label: '忽略大小写', |
| 257 | 263 | component: 'Checkbox', |
| 258 | 264 | colProps: { |
| 259 | - span: 6, | |
| 265 | + span: 4, | |
| 260 | 266 | }, |
| 261 | 267 | }, |
| 262 | 268 | { |
| ... | ... | @@ -264,22 +270,20 @@ export function isType(operationType) { |
| 264 | 270 | label: '执行操作', |
| 265 | 271 | component: 'Select', |
| 266 | 272 | required: true, |
| 267 | - | |
| 268 | 273 | componentProps: { |
| 269 | 274 | options: operationString, |
| 270 | 275 | }, |
| 271 | 276 | colProps: { |
| 272 | - span: 7, | |
| 277 | + span: 8, | |
| 273 | 278 | }, |
| 274 | 279 | }, |
| 275 | 280 | { |
| 276 | 281 | field: 'value', |
| 277 | 282 | label: '操作值', |
| 278 | 283 | required: true, |
| 279 | - | |
| 280 | 284 | component: 'Input', |
| 281 | 285 | colProps: { |
| 282 | - span: 7, | |
| 286 | + span: 9, | |
| 283 | 287 | }, |
| 284 | 288 | }, |
| 285 | 289 | ]; |
| ... | ... | @@ -330,7 +334,7 @@ export function isType(operationType) { |
| 330 | 334 | options: operationNumber_OR_TIME, |
| 331 | 335 | }, |
| 332 | 336 | colProps: { |
| 333 | - span: 7, | |
| 337 | + span: 8, | |
| 334 | 338 | }, |
| 335 | 339 | }, |
| 336 | 340 | { | ... | ... |
| 1 | 1 | <template> |
| 2 | - <BasicModal | |
| 3 | - v-bind="$attrs" | |
| 4 | - :width="600" | |
| 5 | - title="编辑报警日程" | |
| 6 | - centered | |
| 7 | - @register="registerModal" | |
| 8 | - @ok="handleOk" | |
| 9 | - @cancel="handleCancel" | |
| 10 | - > | |
| 2 | + <BasicModal v-bind="$attrs" :width="600" title="编辑报警日程" centered @register="registerModal" @ok="handleOk" | |
| 3 | + @cancel="handleCancel"> | |
| 11 | 4 | <BasicForm @register="registerForm" ref="basicFormRef"> |
| 12 | 5 | <template #customEnable> |
| 13 | 6 | <template v-for="(item, optionIndex) in options" :key="item.flag"> |
| ... | ... | @@ -15,230 +8,222 @@ |
| 15 | 8 | <div class="ml-4 mr-4 flex items-center"> |
| 16 | 9 | <Checkbox v-model:checked="item.enabled">星期{{ item.flag }}</Checkbox> |
| 17 | 10 | </div> |
| 18 | - <TimePicker | |
| 19 | - placeholder="开始时间" | |
| 20 | - v-model:value="item.startsOn" | |
| 21 | - value-format="x" | |
| 22 | - format="HH:mm" | |
| 23 | - :disabled="!item.enabled" | |
| 24 | - /> | |
| 11 | + <TimePicker placeholder="开始时间" v-model:value="item.startsOn" value-format="x" format="HH:mm" | |
| 12 | + :disabled="!item.enabled" /> | |
| 25 | 13 | <span class="ml-4 mr-4 flex items-center">~</span> |
| 26 | - <TimePicker | |
| 27 | - placeholder="结束时间" | |
| 28 | - v-model:value="item.endsOn" | |
| 29 | - value-format="x" | |
| 30 | - format="HH:mm" | |
| 31 | - :disabled="!item.enabled" | |
| 32 | - /> </div | |
| 33 | - ></template> | |
| 14 | + <TimePicker @change="handleBlur(item.startsOn,item.endsOn)" placeholder="结束时间" v-model:value="item.endsOn" | |
| 15 | + value-format="x" format="HH:mm" :disabled="!item.enabled" /> | |
| 16 | + </div> | |
| 17 | + </template> | |
| 34 | 18 | </template> |
| 35 | 19 | <template #timing> |
| 36 | - <TimePicker | |
| 37 | - placeholder="开始时间" | |
| 38 | - v-model:value="timeState.startsOn" | |
| 39 | - value-format="x" | |
| 40 | - format="HH:mm" | |
| 41 | - /> | |
| 20 | + <TimePicker placeholder="开始时间" v-model:value="timeState.startsOn" value-format="x" format="HH:mm" /> | |
| 42 | 21 | <span class="ml-4 mr-4">~</span> |
| 43 | - <TimePicker | |
| 44 | - placeholder="结束时间" | |
| 45 | - v-model:value="timeState.endsOn" | |
| 46 | - value-format="x" | |
| 47 | - format="HH:mm" | |
| 48 | - /> | |
| 22 | + <TimePicker @change="handleTimeBlur(timeState.startsOn,timeState.endsOn)" placeholder="结束时间" | |
| 23 | + v-model:value="timeState.endsOn" value-format="x" format="HH:mm" /> | |
| 49 | 24 | </template> |
| 50 | 25 | </BasicForm> |
| 51 | 26 | </BasicModal> |
| 52 | 27 | </template> |
| 53 | 28 | |
| 54 | 29 | <script lang="ts" setup> |
| 55 | - import { reactive, ref, watch, nextTick } from 'vue'; | |
| 56 | - import { useModalInner, BasicModal } from '/@/components/Modal'; | |
| 57 | - import { BasicForm, useForm } from '/@/components/Form'; | |
| 58 | - import { alarmScheduleSchemas } from '../config/config.data.ts'; | |
| 59 | - import { Checkbox, TimePicker } from 'ant-design-vue'; | |
| 30 | +import { reactive, ref, watch, nextTick } from 'vue'; | |
| 31 | +import { useModalInner, BasicModal } from '/@/components/Modal'; | |
| 32 | +import { BasicForm, useForm } from '/@/components/Form'; | |
| 33 | +import { alarmScheduleSchemas } from '../config/config.data.ts'; | |
| 34 | +import { Checkbox, TimePicker } from 'ant-design-vue'; | |
| 35 | +import { useMessage } from '/@/hooks/web/useMessage'; | |
| 60 | 36 | |
| 61 | - const emit = defineEmits(['register', 'cancel']); | |
| 62 | - const [registerForm, { setFieldsValue, getFieldsValue }] = useForm({ | |
| 63 | - showActionButtonGroup: false, | |
| 64 | - schemas: alarmScheduleSchemas, | |
| 65 | - }); | |
| 66 | - const timeState = reactive({ | |
| 37 | +const emit = defineEmits(['register', 'cancel']); | |
| 38 | +const { createMessage } = useMessage(); | |
| 39 | +const [registerForm, { setFieldsValue, getFieldsValue }] = useForm({ | |
| 40 | + showActionButtonGroup: false, | |
| 41 | + schemas: alarmScheduleSchemas, | |
| 42 | +}); | |
| 43 | +const timeState = reactive({ | |
| 44 | + startsOn: null, | |
| 45 | + endsOn: null, | |
| 46 | +}); | |
| 47 | + | |
| 48 | +const options = ref([ | |
| 49 | + { | |
| 50 | + enabled: false, | |
| 51 | + dayOfWeek: 1, | |
| 52 | + flag: '一', | |
| 53 | + endsOn: null, | |
| 67 | 54 | startsOn: null, |
| 55 | + }, | |
| 56 | + { | |
| 57 | + enabled: false, | |
| 58 | + dayOfWeek: 2, | |
| 59 | + flag: '二', | |
| 68 | 60 | endsOn: null, |
| 69 | - }); | |
| 70 | - | |
| 71 | - const options = ref([ | |
| 72 | - { | |
| 73 | - enabled: false, | |
| 74 | - dayOfWeek: 1, | |
| 75 | - flag: '一', | |
| 76 | - endsOn: null, | |
| 77 | - startsOn: null, | |
| 78 | - }, | |
| 79 | - { | |
| 80 | - enabled: false, | |
| 81 | - dayOfWeek: 2, | |
| 82 | - flag: '二', | |
| 83 | - endsOn: null, | |
| 84 | - startsOn: null, | |
| 85 | - }, | |
| 86 | - { | |
| 87 | - enabled: false, | |
| 88 | - dayOfWeek: 3, | |
| 89 | - flag: '三', | |
| 90 | - endsOn: null, | |
| 91 | - startsOn: null, | |
| 92 | - }, | |
| 93 | - { | |
| 94 | - enabled: false, | |
| 95 | - dayOfWeek: 4, | |
| 96 | - flag: '四', | |
| 97 | - endsOn: null, | |
| 98 | - startsOn: null, | |
| 99 | - }, | |
| 100 | - { | |
| 101 | - enabled: false, | |
| 102 | - dayOfWeek: 5, | |
| 103 | - flag: '五', | |
| 104 | - endsOn: null, | |
| 105 | - startsOn: null, | |
| 106 | - }, | |
| 107 | - { | |
| 108 | - enabled: false, | |
| 109 | - dayOfWeek: 6, | |
| 110 | - flag: '六', | |
| 111 | - endsOn: null, | |
| 112 | - startsOn: null, | |
| 113 | - }, | |
| 114 | - { | |
| 115 | - enabled: false, | |
| 116 | - dayOfWeek: 7, | |
| 117 | - flag: '日', | |
| 118 | - endsOn: null, | |
| 119 | - startsOn: null, | |
| 120 | - }, | |
| 121 | - ]); | |
| 122 | - const basicFormRef = ref<InstanceType<typeof BasicForm>>(); | |
| 123 | - let index = ref(null); | |
| 124 | - watch( | |
| 125 | - options, | |
| 126 | - (newValue) => { | |
| 127 | - const arr = []; | |
| 128 | - for (let item of newValue) { | |
| 129 | - if (item.enabled && item.startsOn && item.endsOn) { | |
| 130 | - arr.push(true); | |
| 131 | - } else if ((!item.enabled && item.startsOn && item.endsOn) || item.enabled) { | |
| 132 | - arr.push(false); | |
| 133 | - } | |
| 61 | + startsOn: null, | |
| 62 | + }, | |
| 63 | + { | |
| 64 | + enabled: false, | |
| 65 | + dayOfWeek: 3, | |
| 66 | + flag: '三', | |
| 67 | + endsOn: null, | |
| 68 | + startsOn: null, | |
| 69 | + }, | |
| 70 | + { | |
| 71 | + enabled: false, | |
| 72 | + dayOfWeek: 4, | |
| 73 | + flag: '四', | |
| 74 | + endsOn: null, | |
| 75 | + startsOn: null, | |
| 76 | + }, | |
| 77 | + { | |
| 78 | + enabled: false, | |
| 79 | + dayOfWeek: 5, | |
| 80 | + flag: '五', | |
| 81 | + endsOn: null, | |
| 82 | + startsOn: null, | |
| 83 | + }, | |
| 84 | + { | |
| 85 | + enabled: false, | |
| 86 | + dayOfWeek: 6, | |
| 87 | + flag: '六', | |
| 88 | + endsOn: null, | |
| 89 | + startsOn: null, | |
| 90 | + }, | |
| 91 | + { | |
| 92 | + enabled: false, | |
| 93 | + dayOfWeek: 7, | |
| 94 | + flag: '日', | |
| 95 | + endsOn: null, | |
| 96 | + startsOn: null, | |
| 97 | + }, | |
| 98 | +]); | |
| 99 | +const basicFormRef = ref<InstanceType<typeof BasicForm>>(); | |
| 100 | +let index = ref(null); | |
| 101 | +watch( | |
| 102 | + options, | |
| 103 | + (newValue) => { | |
| 104 | + const arr = []; | |
| 105 | + for (let item of newValue) { | |
| 106 | + if (item.enabled && item.startsOn && item.endsOn) { | |
| 107 | + arr.push(true); | |
| 108 | + } else if ((!item.enabled && item.startsOn && item.endsOn) || item.enabled) { | |
| 109 | + arr.push(false); | |
| 134 | 110 | } |
| 135 | - console.log(arr); | |
| 136 | - const flag = arr.length ? !arr.every((item) => item) : true; | |
| 137 | - console.log(flag); | |
| 138 | - nextTick(() => { | |
| 139 | - setModalProps({ | |
| 140 | - okButtonProps: { | |
| 141 | - disabled: flag, | |
| 142 | - }, | |
| 143 | - }); | |
| 144 | - }); | |
| 145 | - }, | |
| 146 | - { | |
| 147 | - deep: true, | |
| 148 | 111 | } |
| 149 | - ); | |
| 150 | - | |
| 151 | - const [registerModal, { closeModal, setModalProps }] = useModalInner((data) => { | |
| 152 | - watch([timeState, basicFormRef.value.formModel], ([timeState, formModel]) => { | |
| 112 | + const flag = arr.length ? !arr.every((item) => item) : true; | |
| 113 | + nextTick(() => { | |
| 153 | 114 | setModalProps({ |
| 154 | 115 | okButtonProps: { |
| 155 | - disabled: | |
| 156 | - timeState.startsOn === null || | |
| 157 | - timeState.endsOn === null || | |
| 158 | - !formModel.daysOfWeek?.length, | |
| 116 | + disabled: flag, | |
| 159 | 117 | }, |
| 160 | 118 | }); |
| 161 | - watch( | |
| 162 | - () => formModel.schedule, | |
| 163 | - () => { | |
| 164 | - timeState.startsOn = null; | |
| 165 | - timeState.endsOn = null; | |
| 166 | - } | |
| 167 | - ); | |
| 168 | 119 | }); |
| 169 | - const { value, currentIndex, isUpdate, scheduleData } = data; | |
| 170 | - index.value = currentIndex; | |
| 171 | - const dayZenoTime = Math.round(new Date(new Date().toLocaleDateString()).getTime()); | |
| 172 | - // 编辑 | |
| 173 | - setFieldsValue({ | |
| 174 | - schedule: value, | |
| 120 | + }, | |
| 121 | + { | |
| 122 | + deep: true, | |
| 123 | + } | |
| 124 | +); | |
| 125 | + | |
| 126 | +const [registerModal, { closeModal, setModalProps }] = useModalInner((data) => { | |
| 127 | + watch([timeState, basicFormRef.value.formModel], ([timeState, formModel]) => { | |
| 128 | + setModalProps({ | |
| 129 | + okButtonProps: { | |
| 130 | + disabled: | |
| 131 | + timeState.startsOn === null || | |
| 132 | + timeState.endsOn === null || | |
| 133 | + !formModel.daysOfWeek?.length, | |
| 134 | + }, | |
| 175 | 135 | }); |
| 176 | - if (isUpdate) { | |
| 177 | - nextTick(() => { | |
| 178 | - // 回显定时启用 | |
| 179 | - if (scheduleData.type === 'SPECIFIC_TIME') { | |
| 180 | - setFieldsValue({ | |
| 181 | - daysOfWeek: scheduleData.daysOfWeek, | |
| 182 | - }); | |
| 183 | - timeState.startsOn = scheduleData.startsOn + dayZenoTime + ''; | |
| 184 | - timeState.endsOn = scheduleData.endsOn + dayZenoTime + ''; | |
| 185 | - } | |
| 186 | - // 回显自定义启用 | |
| 187 | - if (scheduleData.type === 'CUSTOM') { | |
| 188 | - for (let [index, item] of scheduleData?.items.entries()) { | |
| 189 | - if (item.enabled) { | |
| 190 | - options.value[index].enabled = item.enabled; | |
| 191 | - options.value[index].startsOn = item.startsOn + dayZenoTime + ''; | |
| 192 | - options.value[index].endsOn = item.endsOn + dayZenoTime + ''; | |
| 193 | - } | |
| 194 | - } | |
| 195 | - } | |
| 196 | - }); | |
| 197 | - } | |
| 136 | + watch( | |
| 137 | + () => formModel.schedule, | |
| 138 | + () => { | |
| 139 | + timeState.startsOn = null; | |
| 140 | + timeState.endsOn = null; | |
| 141 | + } | |
| 142 | + ); | |
| 198 | 143 | }); |
| 199 | - const scheduleData = ref({ | |
| 200 | - type: 'ANY_TIME', | |
| 144 | + const { value, currentIndex, isUpdate, scheduleData } = data; | |
| 145 | + index.value = currentIndex; | |
| 146 | + const dayZenoTime = Math.round(new Date(new Date().toLocaleDateString()).getTime()); | |
| 147 | + // 编辑 | |
| 148 | + setFieldsValue({ | |
| 149 | + schedule: value, | |
| 201 | 150 | }); |
| 202 | - const handleOk = () => { | |
| 203 | - const { schedule: type, timezone, daysOfWeek } = getFieldsValue(); | |
| 204 | - // 获取当天0时时间戳 | |
| 205 | - const dayZenoTime = Math.round(new Date(new Date().toLocaleDateString()).getTime()); | |
| 206 | - if (type === 'CUSTOM') { | |
| 207 | - const items = options.value.map((item) => { | |
| 208 | - return { | |
| 209 | - startsOn: item.startsOn ? item.startsOn - dayZenoTime : 0, | |
| 210 | - endsOn: item.endsOn ? item.endsOn - dayZenoTime : 0, | |
| 211 | - dayOfWeek: item.dayOfWeek, | |
| 212 | - enabled: item.enabled, | |
| 213 | - }; | |
| 214 | - }); | |
| 215 | - scheduleData.value = { | |
| 216 | - type, | |
| 217 | - timezone, | |
| 218 | - items, | |
| 219 | - }; | |
| 220 | - } else if (type === 'SPECIFIC_TIME') { | |
| 221 | - scheduleData.value = { | |
| 222 | - type, | |
| 223 | - timezone, | |
| 224 | - daysOfWeek, | |
| 225 | - startsOn: timeState.startsOn - dayZenoTime, | |
| 226 | - endsOn: timeState.endsOn - dayZenoTime, | |
| 151 | + if (isUpdate) { | |
| 152 | + nextTick(() => { | |
| 153 | + // 回显定时启用 | |
| 154 | + if (scheduleData.type === 'SPECIFIC_TIME') { | |
| 155 | + setFieldsValue({ | |
| 156 | + daysOfWeek: scheduleData.daysOfWeek, | |
| 157 | + }); | |
| 158 | + timeState.startsOn = scheduleData.startsOn + dayZenoTime + ''; | |
| 159 | + timeState.endsOn = scheduleData.endsOn + dayZenoTime + ''; | |
| 160 | + } | |
| 161 | + // 回显自定义启用 | |
| 162 | + if (scheduleData.type === 'CUSTOM') { | |
| 163 | + for (let [index, item] of scheduleData?.items.entries()) { | |
| 164 | + if (item.enabled) { | |
| 165 | + options.value[index].enabled = item.enabled; | |
| 166 | + options.value[index].startsOn = item.startsOn + dayZenoTime + ''; | |
| 167 | + options.value[index].endsOn = item.endsOn + dayZenoTime + ''; | |
| 168 | + } | |
| 169 | + } | |
| 170 | + } | |
| 171 | + }); | |
| 172 | + } | |
| 173 | +}); | |
| 174 | +const scheduleData = ref({ | |
| 175 | + type: 'ANY_TIME', | |
| 176 | +}); | |
| 177 | +const handleBlur = (eS, eE) => { | |
| 178 | + if (eS > eE) { | |
| 179 | + return createMessage.error('开始时间不能大于结束时间') | |
| 180 | + } | |
| 181 | +} | |
| 182 | +const handleTimeBlur = (eS, eE) => { | |
| 183 | + if (eS > eE) { | |
| 184 | + return createMessage.error('开始时间不能大于结束时间') | |
| 185 | + } | |
| 186 | +} | |
| 187 | +const handleOk = () => { | |
| 188 | + const { schedule: type, timezone, daysOfWeek } = getFieldsValue(); | |
| 189 | + // 获取当天0时时间戳 | |
| 190 | + const dayZenoTime = Math.round(new Date(new Date().toLocaleDateString()).getTime()); | |
| 191 | + if (type === 'CUSTOM') { | |
| 192 | + const items = options.value.map((item) => { | |
| 193 | + return { | |
| 194 | + startsOn: item.startsOn ? item.startsOn - dayZenoTime : 0, | |
| 195 | + endsOn: item.endsOn ? item.endsOn - dayZenoTime : 0, | |
| 196 | + dayOfWeek: item.dayOfWeek, | |
| 197 | + enabled: item.enabled, | |
| 227 | 198 | }; |
| 228 | - } | |
| 229 | - closeModal(); | |
| 230 | - }; | |
| 231 | - const handleCancel = () => { | |
| 232 | - emit('cancel', index.value); | |
| 233 | - }; | |
| 199 | + }); | |
| 200 | + scheduleData.value = { | |
| 201 | + type, | |
| 202 | + timezone, | |
| 203 | + items, | |
| 204 | + }; | |
| 205 | + } else if (type === 'SPECIFIC_TIME') { | |
| 206 | + scheduleData.value = { | |
| 207 | + type, | |
| 208 | + timezone, | |
| 209 | + daysOfWeek, | |
| 210 | + startsOn: timeState.startsOn - dayZenoTime, | |
| 211 | + endsOn: timeState.endsOn - dayZenoTime, | |
| 212 | + }; | |
| 213 | + } | |
| 214 | + closeModal(); | |
| 215 | +}; | |
| 216 | +const handleCancel = () => { | |
| 217 | + emit('cancel', index.value); | |
| 218 | +}; | |
| 234 | 219 | |
| 235 | - defineExpose({ | |
| 236 | - scheduleData, | |
| 237 | - }); | |
| 220 | +defineExpose({ | |
| 221 | + scheduleData, | |
| 222 | +}); | |
| 238 | 223 | </script> |
| 239 | 224 | |
| 240 | 225 | <style lang="less" scoped> |
| 241 | - :deep(.ant-time-picker) { | |
| 242 | - width: 12rem; | |
| 243 | - } | |
| 226 | +:deep(.ant-time-picker) { | |
| 227 | + width: 12rem; | |
| 228 | +} | |
| 244 | 229 | </style> | ... | ... |
| ... | ... | @@ -3,96 +3,94 @@ |
| 3 | 3 | <CollapseContainer ref="collapseContainerRef" @expand="handleExpand"> |
| 4 | 4 | <template #title> |
| 5 | 5 | <div>条件筛选</div> |
| 6 | - <RichText :otherAttribute="otherAttribute" @resetFilter="resetFilter" | |
| 7 | - /></template> | |
| 6 | + <RichText :otherAttribute="otherAttribute" @resetFilter="resetFilter" /> | |
| 7 | + </template> | |
| 8 | 8 | |
| 9 | 9 | <template v-for="(item, index) in conditionScreeningList" :key="item"> |
| 10 | - <ConditionScreeningForm | |
| 11 | - :conditionScreeningList="conditionScreeningList" | |
| 12 | - :ref="refItem.conditionScreeningRefs" | |
| 13 | - :index="index" | |
| 14 | - @deleteConditionForm="deleteConditionForm" | |
| 15 | - /> | |
| 10 | + <ConditionScreeningForm :conditionScreeningList="conditionScreeningList" :ref="refItem.conditionScreeningRefs" | |
| 11 | + :index="index" @deleteConditionForm="deleteConditionForm" /> | |
| 16 | 12 | </template> |
| 17 | 13 | </CollapseContainer> |
| 18 | 14 | |
| 19 | 15 | <div class="flex justify-between"> |
| 20 | - <a-button type="primary" class="mt-4 ml-2" @click="addConditionForm">新增条件筛选</a-button> | |
| 21 | - <a-button type="primary" class="mt-4 mr-2" @click="preView" v-if="isPreview">保存</a-button> | |
| 16 | + <a-button :disabled="isViewDisabledBtn=='isView'?true:false" type="primary" class="mt-4 ml-2" | |
| 17 | + @click="addConditionForm">新增条件筛选</a-button> | |
| 18 | + <a-button :disabled="isViewDisabledBtn=='isView'?true:false" type="primary" class="mt-4 mr-2" @click="preView" | |
| 19 | + v-if="isPreview">保存</a-button> | |
| 22 | 20 | </div> |
| 23 | 21 | </div> |
| 24 | 22 | </template> |
| 25 | 23 | |
| 26 | 24 | <script lang="ts" setup> |
| 27 | - import { unref, ref } from 'vue'; | |
| 28 | - import ConditionScreeningForm from './ConditionScreeningForm.vue'; | |
| 29 | - import { conditionPreView } from '../config/formatData.ts'; | |
| 30 | - import { CollapseContainer } from '/@/components/Container/index'; | |
| 31 | - import RichText from './RichText.vue'; | |
| 32 | - const props = defineProps({ | |
| 33 | - childGetFieldsValue: { | |
| 34 | - type: Function, | |
| 35 | - required: true, | |
| 25 | +import { unref, ref } from 'vue'; | |
| 26 | +import ConditionScreeningForm from './ConditionScreeningForm.vue'; | |
| 27 | +import { conditionPreView } from '../config/formatData.ts'; | |
| 28 | +import { CollapseContainer } from '/@/components/Container/index'; | |
| 29 | +import RichText from './RichText.vue'; | |
| 30 | +const props = defineProps({ | |
| 31 | + childGetFieldsValue: { | |
| 32 | + type: Function, | |
| 33 | + required: true, | |
| 34 | + }, | |
| 35 | +}); | |
| 36 | +const refItem = { | |
| 37 | + conditionScreeningRefs: ref([]), | |
| 38 | +}; | |
| 39 | +const isViewDisabledBtn = window.localStorage.getItem('isViewDisabledBtn') | |
| 40 | +const isPreview = ref(true); | |
| 41 | +const collapseContainerRef = ref(); | |
| 42 | +const conditionScreeningList = ref([Date.now()]); | |
| 43 | +const addConditionForm = () => { | |
| 44 | + if (!unref(isPreview)) { | |
| 45 | + collapseContainerRef.value.handleExpand(); | |
| 46 | + } | |
| 47 | + unref(conditionScreeningList).push(Date.now()); | |
| 48 | + const lastIndex = refItem.conditionScreeningRefs.value.length - 1; | |
| 49 | + refItem.conditionScreeningRefs.value[lastIndex]?.appendSchemaByField( | |
| 50 | + { | |
| 51 | + field: 'AND', | |
| 52 | + label: '和', | |
| 53 | + component: 'Input', | |
| 54 | + slot: 'and', | |
| 55 | + // labelWidth: 50, | |
| 56 | + colProps: { span: 3 }, | |
| 36 | 57 | }, |
| 37 | - }); | |
| 38 | - const refItem = { | |
| 39 | - conditionScreeningRefs: ref([]), | |
| 40 | - }; | |
| 58 | + 'value' | |
| 59 | + ); | |
| 60 | +}; | |
| 61 | +const handleExpand = (show) => { | |
| 62 | + isPreview.value = show; | |
| 63 | +}; | |
| 41 | 64 | |
| 42 | - const isPreview = ref(true); | |
| 43 | - const collapseContainerRef = ref(); | |
| 44 | - const conditionScreeningList = ref([Date.now()]); | |
| 45 | - const addConditionForm = () => { | |
| 46 | - if (!unref(isPreview)) { | |
| 47 | - collapseContainerRef.value.handleExpand(); | |
| 48 | - } | |
| 49 | - unref(conditionScreeningList).push(Date.now()); | |
| 50 | - const lastIndex = refItem.conditionScreeningRefs.value.length - 1; | |
| 51 | - refItem.conditionScreeningRefs.value[lastIndex]?.appendSchemaByField( | |
| 52 | - { | |
| 53 | - field: 'AND', | |
| 54 | - label: '和', | |
| 55 | - component: 'Input', | |
| 56 | - slot: 'and', | |
| 57 | - // labelWidth: 50, | |
| 58 | - colProps: { span: 3 }, | |
| 59 | - }, | |
| 60 | - 'value' | |
| 61 | - ); | |
| 62 | - }; | |
| 63 | - const handleExpand = (show) => { | |
| 64 | - isPreview.value = show; | |
| 65 | - }; | |
| 66 | - | |
| 67 | - const otherAttribute = ref([]); | |
| 68 | - // 预览条件筛选结果 | |
| 69 | - const preView = async () => { | |
| 70 | - const attributes = []; | |
| 71 | - const fieldsValue = props.childGetFieldsValue(); | |
| 72 | - for (let i = 0; i < unref(refItem.conditionScreeningRefs).length; i++) { | |
| 73 | - const valid = await unref(refItem.conditionScreeningRefs)[i].validate(); | |
| 74 | - if (!valid) return; | |
| 75 | - attributes.push({ | |
| 76 | - ...unref(refItem.conditionScreeningRefs)[i].getFieldsValue(), | |
| 77 | - attribute: fieldsValue.type2, | |
| 78 | - }); | |
| 79 | - } | |
| 80 | - otherAttribute.value = conditionPreView(attributes, fieldsValue.operationType); | |
| 81 | - collapseContainerRef.value.handleExpand(); | |
| 82 | - }; | |
| 65 | +const otherAttribute = ref([]); | |
| 66 | +// 预览条件筛选结果 | |
| 67 | +const preView = async () => { | |
| 68 | + const attributes = []; | |
| 69 | + const fieldsValue = props.childGetFieldsValue(); | |
| 70 | + for (let i = 0; i < unref(refItem.conditionScreeningRefs).length; i++) { | |
| 71 | + const valid = await unref(refItem.conditionScreeningRefs)[i].validate(); | |
| 72 | + if (!valid) return; | |
| 73 | + attributes.push({ | |
| 74 | + ...unref(refItem.conditionScreeningRefs)[i].getFieldsValue(), | |
| 75 | + attribute: fieldsValue.type2, | |
| 76 | + }); | |
| 77 | + } | |
| 78 | + otherAttribute.value = conditionPreView(attributes, fieldsValue.operationType); | |
| 79 | + collapseContainerRef.value.handleExpand(); | |
| 80 | +}; | |
| 83 | 81 | |
| 84 | - const resetFilter = () => { | |
| 85 | - otherAttribute.value = []; | |
| 86 | - }; | |
| 87 | - const deleteConditionForm = (index) => { | |
| 88 | - unref(conditionScreeningList).splice(index, 1); | |
| 89 | - const lastIndex = refItem.conditionScreeningRefs.value.length - 2; | |
| 90 | - refItem.conditionScreeningRefs.value[lastIndex]?.removeSchemaByFiled('AND'); | |
| 91 | - }; | |
| 82 | +const resetFilter = () => { | |
| 83 | + otherAttribute.value = []; | |
| 84 | +}; | |
| 85 | +const deleteConditionForm = (index) => { | |
| 86 | + unref(conditionScreeningList).splice(index, 1); | |
| 87 | + const lastIndex = refItem.conditionScreeningRefs.value.length - 2; | |
| 88 | + refItem.conditionScreeningRefs.value[lastIndex]?.removeSchemaByFiled('AND'); | |
| 89 | +}; | |
| 92 | 90 | |
| 93 | - defineExpose({ | |
| 94 | - refItem, | |
| 95 | - conditionScreeningList, | |
| 96 | - otherAttribute, | |
| 97 | - }); | |
| 91 | +defineExpose({ | |
| 92 | + refItem, | |
| 93 | + conditionScreeningList, | |
| 94 | + otherAttribute, | |
| 95 | +}); | |
| 98 | 96 | </script> | ... | ... |
| ... | ... | @@ -6,158 +6,149 @@ |
| 6 | 6 | <a-button type="primary" @click="handleAdd"> 新增场景联动 </a-button> |
| 7 | 7 | </Authority> |
| 8 | 8 | <Authority value="api:yt:sceneLinkage:delete"> |
| 9 | - <Popconfirm | |
| 10 | - title="您确定要批量删除数据" | |
| 11 | - ok-text="确定" | |
| 12 | - cancel-text="取消" | |
| 13 | - @confirm="handleDeleteOrBatchDelete(null)" | |
| 14 | - > | |
| 9 | + <Popconfirm title="您确定要批量删除数据" ok-text="确定" cancel-text="取消" @confirm="handleDeleteOrBatchDelete(null)"> | |
| 15 | 10 | <a-button color="error" :disabled="hasBatchDelete"> 批量删除 </a-button> |
| 16 | 11 | </Popconfirm> |
| 17 | 12 | </Authority> |
| 18 | 13 | </template> |
| 19 | 14 | <template #action="{ record }"> |
| 20 | - <TableAction | |
| 21 | - :actions="[ | |
| 22 | - { | |
| 23 | - label: '查看', | |
| 24 | - auth: 'api:yt:sceneLinkage:get', | |
| 25 | - icon: 'ant-design:eye-outlined', | |
| 26 | - onClick: handleView.bind(null, record), | |
| 15 | + <TableAction :actions="[ | |
| 16 | + { | |
| 17 | + label: '查看', | |
| 18 | + auth: 'api:yt:sceneLinkage:get', | |
| 19 | + icon: 'ant-design:eye-outlined', | |
| 20 | + onClick: handleView.bind(null, record), | |
| 21 | + }, | |
| 22 | + { | |
| 23 | + label: '编辑', | |
| 24 | + auth: 'api:yt:sceneLinkage:update', | |
| 25 | + icon: 'clarity:note-edit-line', | |
| 26 | + onClick: handleEdit.bind(null, record), | |
| 27 | + ifShow: record.creator === userId && record.status !== 1, | |
| 28 | + }, | |
| 29 | + { | |
| 30 | + label: '删除', | |
| 31 | + auth: 'api:yt:sceneLinkage:delete', | |
| 32 | + icon: 'ant-design:delete-outlined', | |
| 33 | + color: 'error', | |
| 34 | + ifShow: record.creator === userId && record.status !== 1, | |
| 35 | + popConfirm: { | |
| 36 | + title: '是否确认删除', | |
| 37 | + confirm: handleDeleteOrBatchDelete.bind(null, record), | |
| 27 | 38 | }, |
| 28 | - { | |
| 29 | - label: '编辑', | |
| 30 | - auth: 'api:yt:sceneLinkage:update', | |
| 31 | - icon: 'clarity:note-edit-line', | |
| 32 | - onClick: handleEdit.bind(null, record), | |
| 33 | - ifShow: record.creator === userId && record.status !== 1, | |
| 34 | - }, | |
| 35 | - { | |
| 36 | - label: '删除', | |
| 37 | - auth: 'api:yt:sceneLinkage:delete', | |
| 38 | - icon: 'ant-design:delete-outlined', | |
| 39 | - color: 'error', | |
| 40 | - ifShow: record.creator === userId && record.status !== 1, | |
| 41 | - popConfirm: { | |
| 42 | - title: '是否确认删除', | |
| 43 | - confirm: handleDeleteOrBatchDelete.bind(null, record), | |
| 44 | - }, | |
| 45 | - }, | |
| 46 | - ]" | |
| 47 | - /> | |
| 39 | + }, | |
| 40 | + ]" /> | |
| 48 | 41 | </template> |
| 49 | 42 | |
| 50 | 43 | <template #status="{ record }"> |
| 51 | - <Switch | |
| 52 | - :checked="record.status === 1" | |
| 53 | - :loading="record.pendingStatus" | |
| 54 | - checkedChildren="启用" | |
| 55 | - unCheckedChildren="禁用" | |
| 56 | - @change="(checked:boolean)=>statusChange(checked,record)" | |
| 57 | - /> | |
| 44 | + <Switch :checked="record.status === 1" :loading="record.pendingStatus" checkedChildren="启用" | |
| 45 | + unCheckedChildren="禁用" @change="(checked:boolean)=>statusChange(checked,record)" /> | |
| 58 | 46 | </template> |
| 59 | 47 | </BasicTable> |
| 60 | 48 | <SceneLinkAgeDrawer @register="registerDrawer" @success="handleSuccess" /> |
| 61 | 49 | </div> |
| 62 | 50 | </template> |
| 63 | 51 | <script lang="ts" setup> |
| 64 | - import { nextTick } from 'vue'; | |
| 65 | - import { BasicTable, useTable, TableAction } from '/@/components/Table'; | |
| 66 | - import { useDrawer } from '/@/components/Drawer'; | |
| 67 | - import { | |
| 68 | - screenLinkPageGetApi, | |
| 69 | - screenLinkPageDeleteApi, | |
| 70 | - screenLinkPagePutApi, | |
| 71 | - } from '/@/api/ruleengine/ruleengineApi'; | |
| 72 | - import { useBatchDelete } from '/@/hooks/web/useBatchDelete'; | |
| 73 | - import { Switch, Popconfirm } from 'ant-design-vue'; | |
| 74 | - import { columns, searchFormSchema } from './config/config.data.ts'; | |
| 75 | - import { USER_INFO_KEY } from '/@/enums/cacheEnum'; | |
| 76 | - import { getAuthCache } from '/@/utils/auth'; | |
| 77 | - import SceneLinkAgeDrawer from './SceneLinkAgeDrawer.vue'; | |
| 78 | - import { useMessage } from '/@/hooks/web/useMessage'; | |
| 79 | - import { Authority } from '/@/components/Authority'; | |
| 52 | +import { nextTick } from 'vue'; | |
| 53 | +import { BasicTable, useTable, TableAction } from '/@/components/Table'; | |
| 54 | +import { useDrawer } from '/@/components/Drawer'; | |
| 55 | +import { | |
| 56 | + screenLinkPageGetApi, | |
| 57 | + screenLinkPageDeleteApi, | |
| 58 | + screenLinkPagePutApi, | |
| 59 | +} from '/@/api/ruleengine/ruleengineApi'; | |
| 60 | +import { useBatchDelete } from '/@/hooks/web/useBatchDelete'; | |
| 61 | +import { Switch, Popconfirm } from 'ant-design-vue'; | |
| 62 | +import { columns, searchFormSchema } from './config/config.data.ts'; | |
| 63 | +import { USER_INFO_KEY } from '/@/enums/cacheEnum'; | |
| 64 | +import { getAuthCache } from '/@/utils/auth'; | |
| 65 | +import SceneLinkAgeDrawer from './SceneLinkAgeDrawer.vue'; | |
| 66 | +import { useMessage } from '/@/hooks/web/useMessage'; | |
| 67 | +import { Authority } from '/@/components/Authority'; | |
| 80 | 68 | |
| 81 | - const userInfo: any = getAuthCache(USER_INFO_KEY); | |
| 82 | - const userId = userInfo.userId; | |
| 69 | +const userInfo: any = getAuthCache(USER_INFO_KEY); | |
| 70 | +const userId = userInfo.userId; | |
| 83 | 71 | |
| 84 | - const [registerDrawer, { openDrawer }] = useDrawer(); | |
| 85 | - const [registerTable, { reload, setProps, setSelectedRowKeys }] = useTable({ | |
| 86 | - title: '场景联动列表', | |
| 87 | - api: screenLinkPageGetApi, | |
| 88 | - columns, | |
| 89 | - formConfig: { | |
| 90 | - labelWidth: 120, | |
| 91 | - schemas: searchFormSchema, | |
| 92 | - }, | |
| 93 | - useSearchForm: true, | |
| 94 | - showTableSetting: true, | |
| 95 | - bordered: true, | |
| 96 | - showIndexColumn: false, | |
| 97 | - actionColumn: { | |
| 98 | - width: 200, | |
| 99 | - title: '操作', | |
| 100 | - dataIndex: 'action', | |
| 101 | - slots: { customRender: 'action' }, | |
| 102 | - fixed: 'right', | |
| 103 | - }, | |
| 104 | - }); | |
| 105 | - const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions, resetSelectedRowKeys } = | |
| 106 | - useBatchDelete(screenLinkPageDeleteApi, handleSuccess, setProps); | |
| 107 | - selectionOptions.rowSelection.getCheckboxProps = (record: Recordable) => { | |
| 108 | - // Demo:status为1的选择框禁用 | |
| 109 | - if (record.status === 1) { | |
| 110 | - return { disabled: true }; | |
| 111 | - } else { | |
| 112 | - return { disabled: false }; | |
| 113 | - } | |
| 114 | - }; | |
| 115 | - nextTick(() => { | |
| 116 | - setProps(selectionOptions); | |
| 72 | +const [registerDrawer, { openDrawer }] = useDrawer(); | |
| 73 | +const [registerTable, { reload, setProps, setSelectedRowKeys }] = useTable({ | |
| 74 | + title: '场景联动列表', | |
| 75 | + api: screenLinkPageGetApi, | |
| 76 | + columns, | |
| 77 | + formConfig: { | |
| 78 | + labelWidth: 120, | |
| 79 | + schemas: searchFormSchema, | |
| 80 | + }, | |
| 81 | + useSearchForm: true, | |
| 82 | + showTableSetting: true, | |
| 83 | + bordered: true, | |
| 84 | + showIndexColumn: false, | |
| 85 | + actionColumn: { | |
| 86 | + width: 200, | |
| 87 | + title: '操作', | |
| 88 | + dataIndex: 'action', | |
| 89 | + slots: { customRender: 'action' }, | |
| 90 | + fixed: 'right', | |
| 91 | + }, | |
| 92 | +}); | |
| 93 | +const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions, resetSelectedRowKeys } = | |
| 94 | + useBatchDelete(screenLinkPageDeleteApi, handleSuccess, setProps); | |
| 95 | +selectionOptions.rowSelection.getCheckboxProps = (record: Recordable) => { | |
| 96 | + // Demo:status为1的选择框禁用 | |
| 97 | + if (record.status === 1) { | |
| 98 | + return { disabled: true }; | |
| 99 | + } else { | |
| 100 | + return { disabled: false }; | |
| 101 | + } | |
| 102 | +}; | |
| 103 | +nextTick(() => { | |
| 104 | + setProps(selectionOptions); | |
| 105 | +}); | |
| 106 | + | |
| 107 | +function handleAdd() { | |
| 108 | + window.localStorage.setItem('isViewDisabledBtn', 'noView') | |
| 109 | + openDrawer(true, { | |
| 110 | + isUpdate: false, | |
| 117 | 111 | }); |
| 112 | +} | |
| 118 | 113 | |
| 119 | - function handleAdd() { | |
| 120 | - openDrawer(true, { | |
| 121 | - isUpdate: false, | |
| 122 | - }); | |
| 123 | - } | |
| 114 | +function handleEdit(record: Recordable) { | |
| 115 | + window.localStorage.setItem('isViewDisabledBtn', 'noView') | |
| 116 | + openDrawer(true, { | |
| 117 | + record, | |
| 118 | + isUpdate: true, | |
| 119 | + }); | |
| 120 | +} | |
| 121 | +function handleView(record: Recordable) { | |
| 122 | + window.localStorage.setItem('isViewDisabledBtn', 'isView') | |
| 123 | + openDrawer(true, { | |
| 124 | + record, | |
| 125 | + isUpdate: 3, | |
| 126 | + }); | |
| 127 | +} | |
| 128 | +function handleSuccess() { | |
| 129 | + reload(); | |
| 130 | +} | |
| 124 | 131 | |
| 125 | - function handleEdit(record: Recordable) { | |
| 126 | - openDrawer(true, { | |
| 127 | - record, | |
| 128 | - isUpdate: true, | |
| 129 | - }); | |
| 130 | - } | |
| 131 | - function handleView(record: Recordable) { | |
| 132 | - openDrawer(true, { | |
| 133 | - record, | |
| 134 | - isUpdate: 3, | |
| 132 | +const statusChange = async (checked, record) => { | |
| 133 | + setProps({ | |
| 134 | + loading: true, | |
| 135 | + }); | |
| 136 | + setSelectedRowKeys([]); | |
| 137 | + resetSelectedRowKeys(); | |
| 138 | + const newStatus = checked ? 1 : 0; | |
| 139 | + const { createMessage } = useMessage(); | |
| 140 | + try { | |
| 141 | + await screenLinkPagePutApi({ id: record.id, status: newStatus }); | |
| 142 | + if (newStatus) { | |
| 143 | + createMessage.success(`启用成功`); | |
| 144 | + } else { | |
| 145 | + createMessage.success('禁用成功'); | |
| 146 | + } | |
| 147 | + } finally { | |
| 148 | + setProps({ | |
| 149 | + loading: false, | |
| 135 | 150 | }); |
| 136 | - } | |
| 137 | - function handleSuccess() { | |
| 138 | 151 | reload(); |
| 139 | 152 | } |
| 140 | - | |
| 141 | - const statusChange = async (checked, record) => { | |
| 142 | - setProps({ | |
| 143 | - loading: true, | |
| 144 | - }); | |
| 145 | - setSelectedRowKeys([]); | |
| 146 | - resetSelectedRowKeys(); | |
| 147 | - const newStatus = checked ? 1 : 0; | |
| 148 | - const { createMessage } = useMessage(); | |
| 149 | - try { | |
| 150 | - await screenLinkPagePutApi({ id: record.id, status: newStatus }); | |
| 151 | - if (newStatus) { | |
| 152 | - createMessage.success(`启用成功`); | |
| 153 | - } else { | |
| 154 | - createMessage.success('禁用成功'); | |
| 155 | - } | |
| 156 | - } finally { | |
| 157 | - setProps({ | |
| 158 | - loading: false, | |
| 159 | - }); | |
| 160 | - reload(); | |
| 161 | - } | |
| 162 | - }; | |
| 153 | +}; | |
| 163 | 154 | </script> | ... | ... |
| 1 | 1 | <template> |
| 2 | 2 | <div :class="prefixCls" class="relative w-full h-full px-4"> |
| 3 | - <AppLocalePicker | |
| 4 | - class="absolute text-white top-4 right-4 enter-x xl:text-gray-600" | |
| 5 | - :showText="false" | |
| 6 | - v-if="!sessionTimeout && showLocale" | |
| 7 | - /> | |
| 3 | + <AppLocalePicker class="absolute text-white top-4 right-4 enter-x xl:text-gray-600" :showText="false" | |
| 4 | + v-if="!sessionTimeout && showLocale" /> | |
| 8 | 5 | <AppDarkModeToggle class="absolute top-3 right-7 enter-x" v-if="!sessionTimeout" /> |
| 9 | 6 | |
| 10 | 7 | <span class="-enter-x xl:hidden"> |
| 11 | - <AppLogo :alwaysShowTitle="true" /> | |
| 8 | + <!-- <AppLogo :alwaysShowTitle="true" /> --> | |
| 12 | 9 | </span> |
| 13 | 10 | |
| 14 | 11 | <div class="container relative h-full py-2 mx-auto sm:px-10"> |
| 15 | 12 | <div class="flex h-full"> |
| 16 | 13 | <div class="hidden min-h-full pl-4 mr-4 xl:flex xl:flex-col xl:w-6/12"> |
| 17 | - <AppLogo class="-enter-x" /> | |
| 14 | + <!-- <AppLogo class="-enter-x" /> --> | |
| 15 | + <div style="display:flex;margin-top: 10px;"> | |
| 16 | + <img v-if="getLogo" :src="getLogo" style="width: 48px;height:48px" /> | |
| 17 | + <img style="width: 48px;height:48px" v-else src="/src/assets/images/logo.png" /> | |
| 18 | + <div class="ml-2 truncate md:opacity-100" | |
| 19 | + style="line-height: 45px;margin-left: 5px;font-size: 24px;color: #fff;font-weight: 700;"> | |
| 20 | + {{ getTitle }} | |
| 21 | + </div> | |
| 22 | + </div> | |
| 18 | 23 | <div class="my-auto"> |
| 19 | - <img | |
| 20 | - :alt="title" | |
| 21 | - src="../../../assets/svg/thingskit-login-background.svg" | |
| 22 | - class="w-1/2 -mt-16 -enter-x" | |
| 23 | - /> | |
| 24 | + <img :alt="title" src="../../../assets/svg/thingskit-login-background.svg" class="w-1/2 -mt-16 -enter-x" /> | |
| 24 | 25 | <div class="mt-10 font-medium text-white -enter-x"> |
| 25 | 26 | <span class="inline-block mt-4 text-3xl"> {{ t('sys.login.signInTitle') }}</span> |
| 26 | 27 | </div> |
| ... | ... | @@ -30,10 +31,8 @@ |
| 30 | 31 | </div> |
| 31 | 32 | </div> |
| 32 | 33 | <div class="flex w-full h-full py-5 xl:h-auto xl:py-0 xl:my-0 xl:w-6/12"> |
| 33 | - <div | |
| 34 | - :class="`${prefixCls}-form`" | |
| 35 | - class="relative w-full px-5 py-8 mx-auto my-auto rounded-md shadow-md xl:ml-16 xl:bg-transparent sm:px-8 xl:p-4 xl:shadow-none sm:w-3/4 lg:w-2/4 xl:w-auto enter-x" | |
| 36 | - > | |
| 34 | + <div :class="`${prefixCls}-form`" | |
| 35 | + class="relative w-full px-5 py-8 mx-auto my-auto rounded-md shadow-md xl:ml-16 xl:bg-transparent sm:px-8 xl:p-4 xl:shadow-none sm:w-3/4 lg:w-2/4 xl:w-auto enter-x"> | |
| 37 | 36 | <LoginForm /> |
| 38 | 37 | <ForgetPasswordForm /> |
| 39 | 38 | <RegisterForm /> |
| ... | ... | @@ -45,168 +44,188 @@ |
| 45 | 44 | </div> |
| 46 | 45 | </template> |
| 47 | 46 | <script lang="ts" setup> |
| 48 | - import { computed } from 'vue'; | |
| 49 | - import { AppLogo } from '/@/components/Application'; | |
| 50 | - import { AppLocalePicker, AppDarkModeToggle } from '/@/components/Application'; | |
| 51 | - import LoginForm from './LoginForm.vue'; | |
| 52 | - import ForgetPasswordForm from './ForgetPasswordForm.vue'; | |
| 53 | - import RegisterForm from './RegisterForm.vue'; | |
| 54 | - import MobileForm from './MobileForm.vue'; | |
| 55 | - import { useGlobSetting } from '/@/hooks/setting'; | |
| 56 | - import { useI18n } from '/@/hooks/web/useI18n'; | |
| 57 | - import { useDesign } from '/@/hooks/web/useDesign'; | |
| 58 | - import { useLocaleStore } from '/@/store/modules/locale'; | |
| 59 | - defineProps({ | |
| 60 | - sessionTimeout: { | |
| 61 | - type: Boolean, | |
| 62 | - }, | |
| 63 | - }); | |
| 64 | - | |
| 65 | - const globSetting = useGlobSetting(); | |
| 66 | - const { prefixCls } = useDesign('login'); | |
| 67 | - const { t } = useI18n(); | |
| 68 | - const localeStore = useLocaleStore(); | |
| 69 | - const showLocale = localeStore.getShowPicker; | |
| 70 | - const title = computed(() => globSetting?.title ?? ''); | |
| 47 | +import { computed } from 'vue'; | |
| 48 | +import { AppLogo } from '/@/components/Application'; | |
| 49 | +import { AppLocalePicker, AppDarkModeToggle } from '/@/components/Application'; | |
| 50 | +import LoginForm from './LoginForm.vue'; | |
| 51 | +import ForgetPasswordForm from './ForgetPasswordForm.vue'; | |
| 52 | +import RegisterForm from './RegisterForm.vue'; | |
| 53 | +import MobileForm from './MobileForm.vue'; | |
| 54 | +import { useGlobSetting } from '/@/hooks/setting'; | |
| 55 | +import { useI18n } from '/@/hooks/web/useI18n'; | |
| 56 | +import { useDesign } from '/@/hooks/web/useDesign'; | |
| 57 | +import { useLocaleStore } from '/@/store/modules/locale'; | |
| 58 | +import { useUserStore } from '/@/store/modules/user'; | |
| 59 | + | |
| 60 | +defineProps({ | |
| 61 | + sessionTimeout: { | |
| 62 | + type: Boolean, | |
| 63 | + }, | |
| 64 | +}); | |
| 65 | + | |
| 66 | +const userStore = useUserStore(); | |
| 67 | + | |
| 68 | +const getLogo = computed(() => { | |
| 69 | + return userStore.platInfo?.logo; | |
| 70 | +}); | |
| 71 | +const { title } = useGlobSetting(); | |
| 72 | +const getTitle = computed(() => { | |
| 73 | + // 设置icon | |
| 74 | + let link = (document.querySelector("link[rel*='icon']") || | |
| 75 | + document.createElement('link')) as HTMLLinkElement; | |
| 76 | + link.type = 'image/x-icon'; | |
| 77 | + link.rel = 'shortcut icon'; | |
| 78 | + link.href = userStore.platInfo?.icon ?? '/favicon.ico'; | |
| 79 | + document.getElementsByTagName('head')[0].appendChild(link); | |
| 80 | + return userStore.platInfo?.name ?? title; | |
| 81 | +}); | |
| 82 | +// const globSetting = useGlobSetting(); | |
| 83 | +const { prefixCls } = useDesign('login'); | |
| 84 | +const { t } = useI18n(); | |
| 85 | +const localeStore = useLocaleStore(); | |
| 86 | +const showLocale = localeStore.getShowPicker; | |
| 87 | +// const title = computed(() => globSetting?.title ?? ''); | |
| 71 | 88 | </script> |
| 72 | 89 | <style lang="less"> |
| 73 | - @prefix-cls: ~'@{namespace}-login'; | |
| 74 | - @logo-prefix-cls: ~'@{namespace}-app-logo'; | |
| 75 | - @countdown-prefix-cls: ~'@{namespace}-countdown-input'; | |
| 76 | - @dark-bg: #293146; | |
| 90 | +@prefix-cls: ~'@{namespace}-login'; | |
| 91 | +@logo-prefix-cls: ~'@{namespace}-app-logo'; | |
| 92 | +@countdown-prefix-cls: ~'@{namespace}-countdown-input'; | |
| 93 | +@dark-bg: #293146; | |
| 77 | 94 | |
| 78 | - html[data-theme='dark'] { | |
| 79 | - .@{prefix-cls} { | |
| 80 | - background-color: @dark-bg; | |
| 95 | +html[data-theme='dark'] { | |
| 96 | + .@{prefix-cls} { | |
| 97 | + background-color: @dark-bg; | |
| 81 | 98 | |
| 82 | - &::before { | |
| 83 | - background-image: url(/@/assets/svg/login-bg-dark.svg); | |
| 84 | - } | |
| 99 | + &::before { | |
| 100 | + background-image: url(/@/assets/svg/login-bg-dark.svg); | |
| 101 | + } | |
| 85 | 102 | |
| 86 | - .ant-input, | |
| 87 | - .ant-input-password { | |
| 88 | - background-color: #232a3b; | |
| 89 | - } | |
| 103 | + .ant-input, | |
| 104 | + .ant-input-password { | |
| 105 | + background-color: #232a3b; | |
| 106 | + } | |
| 90 | 107 | |
| 91 | - .ant-btn:not(.ant-btn-link):not(.ant-btn-primary) { | |
| 92 | - border: 1px solid #4a5569; | |
| 93 | - } | |
| 108 | + .ant-btn:not(.ant-btn-link):not(.ant-btn-primary) { | |
| 109 | + border: 1px solid #4a5569; | |
| 110 | + } | |
| 94 | 111 | |
| 95 | - &-form { | |
| 96 | - background: transparent !important; | |
| 97 | - } | |
| 112 | + &-form { | |
| 113 | + background: transparent !important; | |
| 114 | + } | |
| 98 | 115 | |
| 99 | - .app-iconify { | |
| 100 | - color: #fff; | |
| 101 | - } | |
| 116 | + .app-iconify { | |
| 117 | + color: #fff; | |
| 102 | 118 | } |
| 119 | + } | |
| 120 | + | |
| 121 | + input.fix-auto-fill, | |
| 122 | + .fix-auto-fill input { | |
| 123 | + -webkit-text-fill-color: #c9d1d9 !important; | |
| 124 | + box-shadow: inherit !important; | |
| 125 | + } | |
| 126 | +} | |
| 127 | + | |
| 128 | +.@{prefix-cls} { | |
| 129 | + min-height: 100%; | |
| 130 | + overflow: hidden; | |
| 103 | 131 | |
| 104 | - input.fix-auto-fill, | |
| 105 | - .fix-auto-fill input { | |
| 106 | - -webkit-text-fill-color: #c9d1d9 !important; | |
| 107 | - box-shadow: inherit !important; | |
| 132 | + @media (max-width: @screen-xl) { | |
| 133 | + background-color: #293146; | |
| 134 | + | |
| 135 | + .@{prefix-cls}-form { | |
| 136 | + background-color: #fff; | |
| 108 | 137 | } |
| 109 | 138 | } |
| 110 | 139 | |
| 111 | - .@{prefix-cls} { | |
| 112 | - min-height: 100%; | |
| 113 | - overflow: hidden; | |
| 140 | + &::before { | |
| 141 | + position: absolute; | |
| 142 | + top: 0; | |
| 143 | + left: 0; | |
| 144 | + width: 100%; | |
| 145 | + height: 100%; | |
| 146 | + margin-left: -48%; | |
| 147 | + background-image: url(/@/assets/svg/login-bg.svg); | |
| 148 | + background-position: 100%; | |
| 149 | + background-repeat: no-repeat; | |
| 150 | + background-size: auto 100%; | |
| 151 | + content: ''; | |
| 152 | + | |
| 114 | 153 | @media (max-width: @screen-xl) { |
| 115 | - background-color: #293146; | |
| 154 | + display: none; | |
| 155 | + } | |
| 156 | + } | |
| 116 | 157 | |
| 117 | - .@{prefix-cls}-form { | |
| 118 | - background-color: #fff; | |
| 119 | - } | |
| 158 | + .@{logo-prefix-cls} { | |
| 159 | + position: absolute; | |
| 160 | + top: 12px; | |
| 161 | + height: 30px; | |
| 162 | + | |
| 163 | + &__title { | |
| 164 | + font-size: 16px; | |
| 165 | + color: #fff; | |
| 120 | 166 | } |
| 121 | 167 | |
| 122 | - &::before { | |
| 123 | - position: absolute; | |
| 124 | - top: 0; | |
| 125 | - left: 0; | |
| 126 | - width: 100%; | |
| 127 | - height: 100%; | |
| 128 | - margin-left: -48%; | |
| 129 | - background-image: url(/@/assets/svg/login-bg.svg); | |
| 130 | - background-position: 100%; | |
| 131 | - background-repeat: no-repeat; | |
| 132 | - background-size: auto 100%; | |
| 133 | - content: ''; | |
| 134 | - @media (max-width: @screen-xl) { | |
| 135 | - display: none; | |
| 136 | - } | |
| 168 | + img { | |
| 169 | + width: 32px; | |
| 137 | 170 | } |
| 171 | + } | |
| 138 | 172 | |
| 173 | + .container { | |
| 139 | 174 | .@{logo-prefix-cls} { |
| 140 | - position: absolute; | |
| 141 | - top: 12px; | |
| 142 | - height: 30px; | |
| 175 | + display: flex; | |
| 176 | + width: 60%; | |
| 177 | + height: 80px; | |
| 143 | 178 | |
| 144 | 179 | &__title { |
| 145 | - font-size: 16px; | |
| 180 | + font-size: 24px; | |
| 146 | 181 | color: #fff; |
| 147 | 182 | } |
| 148 | 183 | |
| 149 | 184 | img { |
| 150 | - width: 32px; | |
| 185 | + width: 48px; | |
| 151 | 186 | } |
| 152 | 187 | } |
| 188 | + } | |
| 153 | 189 | |
| 154 | - .container { | |
| 155 | - .@{logo-prefix-cls} { | |
| 156 | - display: flex; | |
| 157 | - width: 60%; | |
| 158 | - height: 80px; | |
| 159 | - | |
| 160 | - &__title { | |
| 161 | - font-size: 24px; | |
| 162 | - color: #fff; | |
| 163 | - } | |
| 190 | + &-sign-in-way { | |
| 191 | + .anticon { | |
| 192 | + font-size: 22px; | |
| 193 | + color: #888; | |
| 194 | + cursor: pointer; | |
| 164 | 195 | |
| 165 | - img { | |
| 166 | - width: 48px; | |
| 167 | - } | |
| 196 | + &:hover { | |
| 197 | + color: @primary-color; | |
| 168 | 198 | } |
| 169 | 199 | } |
| 200 | + } | |
| 170 | 201 | |
| 171 | - &-sign-in-way { | |
| 172 | - .anticon { | |
| 173 | - font-size: 22px; | |
| 174 | - color: #888; | |
| 175 | - cursor: pointer; | |
| 202 | + input:not([type='checkbox']) { | |
| 203 | + min-width: 360px; | |
| 176 | 204 | |
| 177 | - &:hover { | |
| 178 | - color: @primary-color; | |
| 179 | - } | |
| 180 | - } | |
| 205 | + @media (max-width: @screen-xl) { | |
| 206 | + min-width: 320px; | |
| 181 | 207 | } |
| 182 | 208 | |
| 183 | - input:not([type='checkbox']) { | |
| 184 | - min-width: 360px; | |
| 185 | - | |
| 186 | - @media (max-width: @screen-xl) { | |
| 187 | - min-width: 320px; | |
| 188 | - } | |
| 189 | - | |
| 190 | - @media (max-width: @screen-lg) { | |
| 191 | - min-width: 260px; | |
| 192 | - } | |
| 193 | - | |
| 194 | - @media (max-width: @screen-md) { | |
| 195 | - min-width: 240px; | |
| 196 | - } | |
| 197 | - | |
| 198 | - @media (max-width: @screen-sm) { | |
| 199 | - min-width: 160px; | |
| 200 | - } | |
| 209 | + @media (max-width: @screen-lg) { | |
| 210 | + min-width: 260px; | |
| 201 | 211 | } |
| 202 | 212 | |
| 203 | - .@{countdown-prefix-cls} input { | |
| 204 | - min-width: unset; | |
| 213 | + @media (max-width: @screen-md) { | |
| 214 | + min-width: 240px; | |
| 205 | 215 | } |
| 206 | 216 | |
| 207 | - .ant-divider-inner-text { | |
| 208 | - font-size: 12px; | |
| 209 | - color: @text-color-secondary; | |
| 217 | + @media (max-width: @screen-sm) { | |
| 218 | + min-width: 160px; | |
| 210 | 219 | } |
| 211 | 220 | } |
| 221 | + | |
| 222 | + .@{countdown-prefix-cls} input { | |
| 223 | + min-width: unset; | |
| 224 | + } | |
| 225 | + | |
| 226 | + .ant-divider-inner-text { | |
| 227 | + font-size: 12px; | |
| 228 | + color: @text-color-secondary; | |
| 229 | + } | |
| 230 | +} | |
| 212 | 231 | </style> | ... | ... |
| ... | ... | @@ -116,9 +116,14 @@ |
| 116 | 116 | mode: 'modal', //不要默认的错误提示 |
| 117 | 117 | }) |
| 118 | 118 | .catch((data) => { |
| 119 | - //登录失败返回的html,所以提示框什么都没有 | |
| 120 | - //去掉提示框 | |
| 121 | - // createMessage.error(data.message); | |
| 119 | + //登录失败如果是502,返回的html,那么提示框什么都没有 | |
| 120 | + if (data.message == 'Invalid username or password' && typeof data.message == 'string') { | |
| 121 | + createMessage.error(data.message); | |
| 122 | + } else if (data.message == '账号已过期,请联系管理员') { | |
| 123 | + createMessage.error(data.message); | |
| 124 | + } else { | |
| 125 | + createMessage.error(data.message); | |
| 126 | + } | |
| 122 | 127 | }); |
| 123 | 128 | if (userInfo) { |
| 124 | 129 | notification.success({ | ... | ... |
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | <div> |
| 3 | 3 | <BasicModal |
| 4 | 4 | v-bind="$attrs" |
| 5 | - width="110rem" | |
| 5 | + width="1460px" | |
| 6 | 6 | :height="heightNum" |
| 7 | 7 | @register="register" |
| 8 | 8 | title="调度日志" |
| ... | ... | @@ -47,7 +47,7 @@ |
| 47 | 47 | format="YYYY-MM-DD HH:mm:ss" |
| 48 | 48 | /> |
| 49 | 49 | </a-col> |
| 50 | - <a-col :span="4" style="margin-left: 10rem"> | |
| 50 | + <a-col :span="4" style="margin-left: 12rem"> | |
| 51 | 51 | <a-button type="primary" @click="handleClearData">重置</a-button> |
| 52 | 52 | <a-button style="margin-left: 10px" @click="handleSearchInfo">查询</a-button> |
| 53 | 53 | </a-col> | ... | ... |
| ... | ... | @@ -27,10 +27,25 @@ |
| 27 | 27 | showActionButtonGroup: false, |
| 28 | 28 | fieldMapToTime: [['timeZone', ['startTime', 'endTime'], 'YYYY-MM-DD HH:mm:ss']], |
| 29 | 29 | }); |
| 30 | + const isViewDetail = ref(false); | |
| 30 | 31 | const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { |
| 31 | 32 | await resetFields(); |
| 32 | 33 | setDrawerProps({ confirmLoading: false }); |
| 33 | 34 | isUpdate.value = !!data?.isUpdate; |
| 35 | + isViewDetail.value = !!data?.isView; | |
| 36 | + | |
| 37 | + if (unref(isViewDetail)) { | |
| 38 | + setDrawerProps({ showFooter: true }); | |
| 39 | + if (unref(isUpdate)) { | |
| 40 | + setDrawerProps({ title: '编辑定时任务' }); | |
| 41 | + } else { | |
| 42 | + setDrawerProps({ title: '新增定时任务' }); | |
| 43 | + } | |
| 44 | + } else { | |
| 45 | + setDrawerProps({ showFooter: false }); | |
| 46 | + setDrawerProps({ title: '查看定时任务' }); | |
| 47 | + } | |
| 48 | + | |
| 34 | 49 | if (unref(isUpdate)) { |
| 35 | 50 | //回显基础数据 |
| 36 | 51 | editId.value = data.record.id; | ... | ... |
| ... | ... | @@ -40,6 +40,12 @@ |
| 40 | 40 | confirm: handleDeleteOrBatchDelete.bind(null, record), |
| 41 | 41 | }, |
| 42 | 42 | }, |
| 43 | + { | |
| 44 | + label: '查看', | |
| 45 | + icon: 'ant-design:eye-outlined', | |
| 46 | + onClick: handleViewDetail.bind(null, record), | |
| 47 | + ifShow: record.status === 1, | |
| 48 | + }, | |
| 43 | 49 | ]" |
| 44 | 50 | :dropDownActions="[ |
| 45 | 51 | { |
| ... | ... | @@ -101,7 +107,7 @@ |
| 101 | 107 | |
| 102 | 108 | const disabledSwitch = ref(false); |
| 103 | 109 | const { createMessage } = useMessage(); |
| 104 | - const [registerTable, { setProps, reload }] = useTable({ | |
| 110 | + const [registerTable, { setProps, reload, setSelectedRowKeys }] = useTable({ | |
| 105 | 111 | title: '定时任务列表', |
| 106 | 112 | api: scheduePage, |
| 107 | 113 | columns: columnSchedue, |
| ... | ... | @@ -128,11 +134,8 @@ |
| 128 | 134 | const handleSuccess = () => { |
| 129 | 135 | reload(); |
| 130 | 136 | }; |
| 131 | - const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions } = useBatchDelete( | |
| 132 | - deleteSchedueManage, | |
| 133 | - handleSuccess, | |
| 134 | - setProps | |
| 135 | - ); | |
| 137 | + const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions, resetSelectedRowKeys } = | |
| 138 | + useBatchDelete(deleteSchedueManage, handleSuccess, setProps); | |
| 136 | 139 | selectionOptions.rowSelection.getCheckboxProps = (record: Recordable) => { |
| 137 | 140 | // Demo:status为1的选择框禁用 |
| 138 | 141 | if (record.status === 1) { |
| ... | ... | @@ -166,10 +169,12 @@ |
| 166 | 169 | openDrawer(true, { |
| 167 | 170 | isUpdate: true, |
| 168 | 171 | record, |
| 172 | + isView: true, | |
| 169 | 173 | }); |
| 170 | 174 | } else { |
| 171 | 175 | openDrawer(true, { |
| 172 | 176 | isUpdate: false, |
| 177 | + isView: true, | |
| 173 | 178 | }); |
| 174 | 179 | } |
| 175 | 180 | }; |
| ... | ... | @@ -179,6 +184,8 @@ |
| 179 | 184 | setProps({ |
| 180 | 185 | loading: true, |
| 181 | 186 | }); |
| 187 | + setSelectedRowKeys([]); | |
| 188 | + resetSelectedRowKeys(); | |
| 182 | 189 | disabledSwitch.value = true; |
| 183 | 190 | const newStatus = checked ? 1 : 0; |
| 184 | 191 | const res = await putSchedueByidAndStatusManage(record.id, newStatus); |
| ... | ... | @@ -203,5 +210,14 @@ |
| 203 | 210 | createMessage.success(`执行一次任务"${record.jobName}"成功`); |
| 204 | 211 | } |
| 205 | 212 | }; |
| 213 | + const handleViewDetail = (record: Recordable) => { | |
| 214 | + if (record) { | |
| 215 | + openDrawer(true, { | |
| 216 | + isUpdate: true, | |
| 217 | + record, | |
| 218 | + isView: false, | |
| 219 | + }); | |
| 220 | + } | |
| 221 | + }; | |
| 206 | 222 | </script> |
| 207 | 223 | <style lang="less" scoped></style> | ... | ... |
| ... | ... | @@ -18,14 +18,20 @@ |
| 18 | 18 | icon: 'ant-design:send-outlined', |
| 19 | 19 | tooltip: '发送通知短信', |
| 20 | 20 | ifShow: record.phoneNumber != null && !record.hasPassword, |
| 21 | - onClick: handleSendMsg.bind(null, record), | |
| 21 | + popConfirm: { | |
| 22 | + title: '是否需要发送通知短信', | |
| 23 | + confirm: handleSendMsg.bind(null, record), | |
| 24 | + }, | |
| 22 | 25 | }, |
| 23 | 26 | { |
| 24 | 27 | label: '清除密码', |
| 25 | 28 | icon: 'ant-design:clear-outlined', |
| 26 | 29 | tooltip: '清除密码', |
| 27 | 30 | ifShow: record.hasPassword, |
| 28 | - onClick: handleResetPassword.bind(null, record), | |
| 31 | + popConfirm: { | |
| 32 | + title: '是否需要清除密码', | |
| 33 | + confirm: handleResetPassword.bind(null, record), | |
| 34 | + }, | |
| 29 | 35 | }, |
| 30 | 36 | { |
| 31 | 37 | label: '编辑', | ... | ... |