Commit 8a6e1ea46e6bfefc7fe3c651bfe23919d51b5a97
Merge branch 'f-dev' into 'main'
fix:修改Teambition上的问题 See merge request huang/yun-teng-iot-front!236
Showing
30 changed files
with
516 additions
and
193 deletions
| ... | ... | @@ -56,16 +56,6 @@ export const screenLinkPageAddApi = (params: ScreenAddModel, isUpdate: boolean) |
| 56 | 56 | }; |
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | - * 获取主设备列表(exclude子设备) | |
| 60 | - * @param params organizationId | |
| 61 | - */ | |
| 62 | -export const byOganizationIdGetMasterDevice = (params) => { | |
| 63 | - return defHttp.get({ | |
| 64 | - url: ScreenManagerApi.MASTER_GET_DEVICE + '/' + params, | |
| 65 | - }); | |
| 66 | -}; | |
| 67 | - | |
| 68 | -/** | |
| 69 | 59 | * 删除场景联动 |
| 70 | 60 | * @param params pageSize page name |
| 71 | 61 | */ |
| ... | ... | @@ -107,6 +97,7 @@ export const getOrganizationAlarmConfig = (params: { organizationId }) => { |
| 107 | 97 | }); |
| 108 | 98 | }; |
| 109 | 99 | |
| 100 | +//TODO-fengtao | |
| 110 | 101 | /** |
| 111 | 102 | * 获取设备属性列表 |
| 112 | 103 | */ |
| ... | ... | @@ -116,3 +107,14 @@ export const getAttribute = (orgId, deviceIds) => { |
| 116 | 107 | url: ScreenManagerApi.GET_ATTRBUTELIST + '/' + orgId + joinText, |
| 117 | 108 | }); |
| 118 | 109 | }; |
| 110 | + | |
| 111 | +/** | |
| 112 | + * 获取主设备列表(exclude子设备)---执行动作 | |
| 113 | + * @param params organizationId | |
| 114 | + */ | |
| 115 | +export const byOganizationIdGetMasterDevice = (params) => { | |
| 116 | + return defHttp.get({ | |
| 117 | + url: ScreenManagerApi.MASTER_GET_DEVICE + '/' + params, | |
| 118 | + }); | |
| 119 | +}; | |
| 120 | +//TODO-fengtao | ... | ... |
| ... | ... | @@ -56,6 +56,7 @@ |
| 56 | 56 | const getTitle = computed(() => (!unref(isUpdate) ? '新增告警配置' : '编辑告警配置')); |
| 57 | 57 | |
| 58 | 58 | async function handleSubmit() { |
| 59 | + setDrawerProps({ confirmLoading: true }); | |
| 59 | 60 | try { |
| 60 | 61 | const { createMessage } = useMessage(); |
| 61 | 62 | const values = await validate(); |
| ... | ... | @@ -77,7 +78,6 @@ |
| 77 | 78 | if (!unref(isUpdate)) { |
| 78 | 79 | delete allData.id; |
| 79 | 80 | } |
| 80 | - setDrawerProps({ confirmLoading: true }); | |
| 81 | 81 | let saveMessage = '添加成功'; |
| 82 | 82 | let updateMessage = '修改成功'; |
| 83 | 83 | await saveOrEditAlarmConfig(allData); |
| ... | ... | @@ -85,7 +85,9 @@ |
| 85 | 85 | emit('success'); |
| 86 | 86 | createMessage.success(unref(isUpdate) ? updateMessage : saveMessage); |
| 87 | 87 | } finally { |
| 88 | - setDrawerProps({ confirmLoading: false }); | |
| 88 | + setTimeout(() => { | |
| 89 | + setDrawerProps({ confirmLoading: false }); | |
| 90 | + }, 300); | |
| 89 | 91 | } |
| 90 | 92 | } |
| 91 | 93 | ... | ... |
| ... | ... | @@ -48,10 +48,10 @@ |
| 48 | 48 | const getTitle = computed(() => (!unref(isUpdate) ? '新增联系人配置' : '编辑联系人配置')); |
| 49 | 49 | |
| 50 | 50 | async function handleSubmit() { |
| 51 | + setDrawerProps({ confirmLoading: true }); | |
| 51 | 52 | try { |
| 52 | 53 | const { createMessage } = useMessage(); |
| 53 | 54 | const values = await validate(); |
| 54 | - setDrawerProps({ confirmLoading: true }); | |
| 55 | 55 | let saveMessage = '添加成功'; |
| 56 | 56 | let updateMessage = '修改成功'; |
| 57 | 57 | await saveOrEditAlarmContact(values, unref(isUpdate)); |
| ... | ... | @@ -59,7 +59,9 @@ |
| 59 | 59 | emit('success'); |
| 60 | 60 | createMessage.success(unref(isUpdate) ? updateMessage : saveMessage); |
| 61 | 61 | } finally { |
| 62 | - setDrawerProps({ confirmLoading: false }); | |
| 62 | + setTimeout(() => { | |
| 63 | + setDrawerProps({ confirmLoading: false }); | |
| 64 | + }, 300); | |
| 63 | 65 | } |
| 64 | 66 | } |
| 65 | 67 | ... | ... |
| ... | ... | @@ -19,7 +19,8 @@ |
| 19 | 19 | > |
| 20 | 20 | <img v-if="tenantLogo" :src="tenantLogo" alt="avatar" /> |
| 21 | 21 | <div v-else> |
| 22 | - <plus-outlined /> | |
| 22 | + <loading-outlined v-if="loading"></loading-outlined> | |
| 23 | + <plus-outlined v-else /> | |
| 23 | 24 | <div class="ant-upload-text">上传</div> |
| 24 | 25 | </div> |
| 25 | 26 | </Upload> |
| ... | ... | @@ -35,15 +36,17 @@ |
| 35 | 36 | import { createOrEditCameraManage } from '/@/api/camera/cameraManager'; |
| 36 | 37 | import { message, Upload } from 'ant-design-vue'; |
| 37 | 38 | import { useMessage } from '/@/hooks/web/useMessage'; |
| 38 | - import { PlusOutlined } from '@ant-design/icons-vue'; | |
| 39 | + import { PlusOutlined, LoadingOutlined } from '@ant-design/icons-vue'; | |
| 39 | 40 | import { upload } from '/@/api/oss/ossFileUploader'; |
| 40 | 41 | import { FileItem } from '/@/components/Upload/src/typing'; |
| 41 | 42 | |
| 42 | 43 | export default defineComponent({ |
| 43 | 44 | name: 'ContactDrawer', |
| 44 | - components: { BasicDrawer, BasicForm, Upload, PlusOutlined }, | |
| 45 | + components: { BasicDrawer, BasicForm, Upload, PlusOutlined, LoadingOutlined }, | |
| 45 | 46 | emits: ['success', 'register'], |
| 46 | 47 | setup(_, { emit }) { |
| 48 | + const loading = ref(false); | |
| 49 | + | |
| 47 | 50 | const isUpdate = ref(true); |
| 48 | 51 | const editId = ref(''); |
| 49 | 52 | const [registerForm, { validate, setFieldsValue, resetFields }] = useForm({ |
| ... | ... | @@ -70,11 +73,14 @@ |
| 70 | 73 | |
| 71 | 74 | async function customUpload({ file }) { |
| 72 | 75 | if (beforeUpload(file)) { |
| 76 | + loading.value = true; | |
| 77 | + | |
| 73 | 78 | const formData = new FormData(); |
| 74 | 79 | formData.append('file', file); |
| 75 | 80 | const response = await upload(formData); |
| 76 | 81 | if (response.fileStaticUri) { |
| 77 | 82 | tenantLogo.value = response.fileStaticUri; |
| 83 | + loading.value = true; | |
| 78 | 84 | } |
| 79 | 85 | } |
| 80 | 86 | } |
| ... | ... | @@ -94,6 +100,7 @@ |
| 94 | 100 | const getTitle = computed(() => (!unref(isUpdate) ? '新增视频配置' : '编辑视频配置')); |
| 95 | 101 | |
| 96 | 102 | async function handleSubmit() { |
| 103 | + setDrawerProps({ confirmLoading: true }); | |
| 97 | 104 | try { |
| 98 | 105 | const { createMessage } = useMessage(); |
| 99 | 106 | const values = await validate(); |
| ... | ... | @@ -105,7 +112,6 @@ |
| 105 | 112 | } else { |
| 106 | 113 | delete values.id; |
| 107 | 114 | } |
| 108 | - setDrawerProps({ confirmLoading: true }); | |
| 109 | 115 | let saveMessage = '添加成功'; |
| 110 | 116 | let updateMessage = '修改成功'; |
| 111 | 117 | await createOrEditCameraManage(values); |
| ... | ... | @@ -113,7 +119,9 @@ |
| 113 | 119 | emit('success'); |
| 114 | 120 | createMessage.success(unref(isUpdate) ? updateMessage : saveMessage); |
| 115 | 121 | } finally { |
| 116 | - setDrawerProps({ confirmLoading: false }); | |
| 122 | + setTimeout(() => { | |
| 123 | + setDrawerProps({ confirmLoading: false }); | |
| 124 | + }, 300); | |
| 117 | 125 | } |
| 118 | 126 | } |
| 119 | 127 | |
| ... | ... | @@ -125,6 +133,7 @@ |
| 125 | 133 | customUpload, |
| 126 | 134 | beforeUpload, |
| 127 | 135 | tenantLogo, |
| 136 | + loading, | |
| 128 | 137 | }; |
| 129 | 138 | }, |
| 130 | 139 | }); | ... | ... |
| ... | ... | @@ -5,15 +5,16 @@ |
| 5 | 5 | <template #iconSelect> |
| 6 | 6 | <Upload |
| 7 | 7 | name="avatar" |
| 8 | + :show-upload-list="false" | |
| 8 | 9 | list-type="picture-card" |
| 9 | 10 | class="avatar-uploader" |
| 10 | - :show-upload-list="false" | |
| 11 | 11 | :customRequest="customUpload" |
| 12 | 12 | :before-upload="beforeUpload" |
| 13 | 13 | > |
| 14 | 14 | <img v-if="devicePic" :src="devicePic" alt="avatar" /> |
| 15 | 15 | <div v-else> |
| 16 | - <PlusOutlined /> | |
| 16 | + <loading-outlined v-if="loading"></loading-outlined> | |
| 17 | + <PlusOutlined v-else /> | |
| 17 | 18 | <div class="ant-upload-text">图片上传</div> |
| 18 | 19 | </div> |
| 19 | 20 | </Upload> |
| ... | ... | @@ -85,7 +86,7 @@ |
| 85 | 86 | import { step1Schemas } from '../../config/data'; |
| 86 | 87 | import { useScript } from '/@/hooks/web/useScript'; |
| 87 | 88 | import { Input, Upload, message, Modal, Form, Row, Col, AutoComplete } from 'ant-design-vue'; |
| 88 | - import { EnvironmentTwoTone, PlusOutlined } from '@ant-design/icons-vue'; | |
| 89 | + import { EnvironmentTwoTone, PlusOutlined, LoadingOutlined } from '@ant-design/icons-vue'; | |
| 89 | 90 | import { upload } from '/@/api/oss/ossFileUploader'; |
| 90 | 91 | import { FileItem } from '/@/components/Upload/src/typing'; |
| 91 | 92 | import { BAI_DU_MAP_URL } from '/@/utils/fnUtils'; |
| ... | ... | @@ -105,6 +106,7 @@ |
| 105 | 106 | FormItem: Form.Item, |
| 106 | 107 | Row, |
| 107 | 108 | Col, |
| 109 | + LoadingOutlined, | |
| 108 | 110 | }, |
| 109 | 111 | props: { |
| 110 | 112 | isUpdate: { |
| ... | ... | @@ -114,6 +116,7 @@ |
| 114 | 116 | emits: ['next'], |
| 115 | 117 | setup(props, { emit }) { |
| 116 | 118 | const devicePic = ref(''); |
| 119 | + const loading = ref(false); | |
| 117 | 120 | |
| 118 | 121 | const [register, { validate, resetFields, setFieldsValue, getFieldsValue, updateSchema }] = |
| 119 | 122 | useForm({ |
| ... | ... | @@ -140,11 +143,13 @@ |
| 140 | 143 | // 图片上传 |
| 141 | 144 | async function customUpload({ file }) { |
| 142 | 145 | if (beforeUpload(file)) { |
| 146 | + loading.value = true; | |
| 143 | 147 | const formData = new FormData(); |
| 144 | 148 | formData.append('file', file); |
| 145 | 149 | const response = await upload(formData); |
| 146 | 150 | if (response.fileStaticUri) { |
| 147 | 151 | devicePic.value = response.fileStaticUri; |
| 152 | + loading.value = false; | |
| 148 | 153 | } |
| 149 | 154 | } |
| 150 | 155 | } |
| ... | ... | @@ -371,6 +376,7 @@ |
| 371 | 376 | dataSource, |
| 372 | 377 | debounceSearch, |
| 373 | 378 | generateSN, |
| 379 | + loading, | |
| 374 | 380 | }; |
| 375 | 381 | }, |
| 376 | 382 | }); | ... | ... |
| ... | ... | @@ -20,7 +20,8 @@ |
| 20 | 20 | style="width: 6.25rem; height: 6.25rem" |
| 21 | 21 | /> |
| 22 | 22 | <div v-else> |
| 23 | - <PlusOutlined /> | |
| 23 | + <loading-outlined v-if="loading"></loading-outlined> | |
| 24 | + <PlusOutlined v-else /> | |
| 24 | 25 | <div class="ant-upload-text">图片上传</div> |
| 25 | 26 | </div> |
| 26 | 27 | </Upload> |
| ... | ... | @@ -37,7 +38,7 @@ |
| 37 | 38 | import { Select, Input, Divider } from 'ant-design-vue'; |
| 38 | 39 | import { uploadApi } from '/@/api/personal/index'; |
| 39 | 40 | import { Upload } from 'ant-design-vue'; |
| 40 | - import { PlusOutlined } from '@ant-design/icons-vue'; | |
| 41 | + import { PlusOutlined, LoadingOutlined } from '@ant-design/icons-vue'; | |
| 41 | 42 | import { useMessage } from '/@/hooks/web/useMessage'; |
| 42 | 43 | import type { FileItem } from '/@/components/Upload/src/typing'; |
| 43 | 44 | |
| ... | ... | @@ -50,9 +51,12 @@ |
| 50 | 51 | [Divider.name]: Divider, |
| 51 | 52 | Upload, |
| 52 | 53 | PlusOutlined, |
| 54 | + LoadingOutlined, | |
| 53 | 55 | }, |
| 54 | 56 | emits: ['next', 'resetFunc', 'register'], |
| 55 | 57 | setup(_, { emit }) { |
| 58 | + const loading = ref(false); | |
| 59 | + | |
| 56 | 60 | const { createMessage } = useMessage(); |
| 57 | 61 | const peresonalPic = ref(''); |
| 58 | 62 | |
| ... | ... | @@ -75,11 +79,14 @@ |
| 75 | 79 | }; |
| 76 | 80 | const customUploadqrcodePic = async ({ file }) => { |
| 77 | 81 | if (beforeUploadqrcodePic(file)) { |
| 82 | + loading.value = true; | |
| 83 | + | |
| 78 | 84 | const formData = new FormData(); |
| 79 | 85 | formData.append('file', file); |
| 80 | 86 | const response = await uploadApi(formData); |
| 81 | 87 | if (response.fileStaticUri) { |
| 82 | 88 | peresonalPic.value = response.fileStaticUri; |
| 89 | + loading.value = false; | |
| 83 | 90 | } |
| 84 | 91 | } |
| 85 | 92 | }; |
| ... | ... | @@ -122,6 +129,7 @@ |
| 122 | 129 | beforeUploadqrcodePic, |
| 123 | 130 | customUploadqrcodePic, |
| 124 | 131 | getStep1Func, |
| 132 | + loading, | |
| 125 | 133 | }; |
| 126 | 134 | }, |
| 127 | 135 | }); | ... | ... |
| ... | ... | @@ -49,10 +49,10 @@ |
| 49 | 49 | const getTitle = computed(() => (!unref(isUpdate) ? '新增消息配置' : '编辑消息配置')); |
| 50 | 50 | |
| 51 | 51 | async function handleSubmit() { |
| 52 | + setDrawerProps({ confirmLoading: true }); | |
| 52 | 53 | try { |
| 53 | 54 | const values = await validate(); |
| 54 | 55 | const { createMessage } = useMessage(); |
| 55 | - setDrawerProps({ confirmLoading: true }); | |
| 56 | 56 | let config = {}; |
| 57 | 57 | if (values.messageType === 'PHONE_MESSAGE') { |
| 58 | 58 | config = { |
| ... | ... | @@ -75,7 +75,9 @@ |
| 75 | 75 | emit('success'); |
| 76 | 76 | createMessage.success(unref(isUpdate) ? updateMessage : saveMessage); |
| 77 | 77 | } finally { |
| 78 | - setDrawerProps({ confirmLoading: false }); | |
| 78 | + setTimeout(() => { | |
| 79 | + setDrawerProps({ confirmLoading: false }); | |
| 80 | + }, 300); | |
| 79 | 81 | } |
| 80 | 82 | } |
| 81 | 83 | ... | ... |
| ... | ... | @@ -103,10 +103,10 @@ |
| 103 | 103 | const getTitle = computed(() => (!unref(isUpdate) ? '新增模板配置' : '编辑模板配置')); |
| 104 | 104 | |
| 105 | 105 | async function handleSubmit() { |
| 106 | + setDrawerProps({ confirmLoading: true }); | |
| 106 | 107 | try { |
| 107 | 108 | const values = await validate(); |
| 108 | 109 | const { createMessage } = useMessage(); |
| 109 | - setDrawerProps({ confirmLoading: true }); | |
| 110 | 110 | let config = {}; |
| 111 | 111 | if (values.messageType === 'PHONE_MESSAGE') { |
| 112 | 112 | config = { |
| ... | ... | @@ -129,7 +129,9 @@ |
| 129 | 129 | emit('success'); |
| 130 | 130 | createMessage.success(unref(isUpdate) ? updateMessage : saveMessage); |
| 131 | 131 | } finally { |
| 132 | - setDrawerProps({ confirmLoading: false }); | |
| 132 | + setTimeout(() => { | |
| 133 | + setDrawerProps({ confirmLoading: false }); | |
| 134 | + }, 300); | |
| 133 | 135 | } |
| 134 | 136 | } |
| 135 | 137 | ... | ... |
| ... | ... | @@ -119,7 +119,9 @@ |
| 119 | 119 | openDrawerAdd(true, { |
| 120 | 120 | isUpdate: false, |
| 121 | 121 | }); |
| 122 | - NotifyManagerDrawerRef.value.setFieldsValue({ content: '' }); | |
| 122 | + nextTick(() => { | |
| 123 | + NotifyManagerDrawerRef.value.setFieldsValue({ content: '' }); | |
| 124 | + }); | |
| 123 | 125 | } |
| 124 | 126 | |
| 125 | 127 | const handleView = (record: Recordable) => { | ... | ... |
| ... | ... | @@ -10,8 +10,8 @@ |
| 10 | 10 | <BasicForm @register="registerForm" /> |
| 11 | 11 | <template #footer> |
| 12 | 12 | <a-button @click="handleCancel">取消</a-button> |
| 13 | - <a-button @click="handleSaveDraft">保存草稿</a-button> | |
| 14 | - <a-button type="primary" @click="handleSend">发布通知</a-button> | |
| 13 | + <a-button :disabled="draftDisable" @click="handleSaveDraft">保存草稿</a-button> | |
| 14 | + <a-button :disabled="sendDisable" type="primary" @click="handleSend">发布通知</a-button> | |
| 15 | 15 | </template> |
| 16 | 16 | </BasicDrawer> |
| 17 | 17 | </div> |
| ... | ... | @@ -31,6 +31,8 @@ |
| 31 | 31 | components: { BasicDrawer, BasicForm }, |
| 32 | 32 | emits: ['success', 'register'], |
| 33 | 33 | setup(_, { emit }) { |
| 34 | + const draftDisable = ref(false); | |
| 35 | + const sendDisable = ref(false); | |
| 34 | 36 | const { createMessage } = useMessage(); |
| 35 | 37 | const isUpdate = ref<Boolean>(); |
| 36 | 38 | const getTitle = computed(() => (!unref(isUpdate) ? '新增通知' : '编辑通知')); |
| ... | ... | @@ -41,9 +43,9 @@ |
| 41 | 43 | showActionButtonGroup: false, |
| 42 | 44 | }); |
| 43 | 45 | const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { |
| 44 | - setDrawerProps({ confirmLoading: false }); | |
| 45 | 46 | await resetFields(); |
| 46 | - isUpdate.value = data.isUpdate; | |
| 47 | + setDrawerProps({ confirmLoading: false }); | |
| 48 | + isUpdate.value = !!data.isUpdate; | |
| 47 | 49 | //编辑 |
| 48 | 50 | if (data.isUpdate) { |
| 49 | 51 | noticeId.value = data.record.id; |
| ... | ... | @@ -58,13 +60,13 @@ |
| 58 | 60 | }); |
| 59 | 61 | // 发布通知 |
| 60 | 62 | const handleSend = async () => { |
| 61 | - const valid = await validate(); | |
| 62 | - if (!valid) return; | |
| 63 | - const field = getFieldsValue(); | |
| 64 | - const pointId = field.receiverType === 1 ? field.organizationId + '' : null; | |
| 65 | - // 新增情况 | |
| 66 | 63 | try { |
| 67 | - setDrawerProps({ confirmLoading: true }); | |
| 64 | + sendDisable.value = true; | |
| 65 | + const valid = await validate(); | |
| 66 | + if (!valid) return; | |
| 67 | + const field = getFieldsValue(); | |
| 68 | + const pointId = field.receiverType === 1 ? field.organizationId + '' : null; | |
| 69 | + // 新增情况 | |
| 68 | 70 | const editNotice = { |
| 69 | 71 | ...field, |
| 70 | 72 | pointId, |
| ... | ... | @@ -75,14 +77,17 @@ |
| 75 | 77 | closeDrawer(); |
| 76 | 78 | createMessage.success('发布成功'); |
| 77 | 79 | } catch { |
| 80 | + sendDisable.value = false; | |
| 78 | 81 | } finally { |
| 79 | - setDrawerProps({ confirmLoading: false }); | |
| 82 | + setTimeout(() => { | |
| 83 | + sendDisable.value = false; | |
| 84 | + }, 300); | |
| 80 | 85 | } |
| 81 | 86 | }; |
| 82 | 87 | // 保存草稿 |
| 83 | 88 | const handleSaveDraft = async () => { |
| 89 | + draftDisable.value = true; | |
| 84 | 90 | try { |
| 85 | - setDrawerProps({ confirmLoading: true }); | |
| 86 | 91 | await validate(); |
| 87 | 92 | const field = getFieldsValue(); |
| 88 | 93 | const pointId = field.receiverType === 1 ? field.organizationId + '' : null; |
| ... | ... | @@ -104,8 +109,11 @@ |
| 104 | 109 | closeDrawer(); |
| 105 | 110 | createMessage.success('保存草稿成功'); |
| 106 | 111 | } catch { |
| 112 | + draftDisable.value = false; | |
| 107 | 113 | } finally { |
| 108 | - setDrawerProps({ confirmLoading: false }); | |
| 114 | + setTimeout(() => { | |
| 115 | + draftDisable.value = false; | |
| 116 | + }, 300); | |
| 109 | 117 | } |
| 110 | 118 | }; |
| 111 | 119 | const handleCancel = () => { |
| ... | ... | @@ -113,6 +121,8 @@ |
| 113 | 121 | closeDrawer(); |
| 114 | 122 | }; |
| 115 | 123 | return { |
| 124 | + draftDisable, | |
| 125 | + sendDisable, | |
| 116 | 126 | getTitle, |
| 117 | 127 | handleSend, |
| 118 | 128 | handleCancel, | ... | ... |
| ... | ... | @@ -67,7 +67,8 @@ |
| 67 | 67 | :actionData="actionData" |
| 68 | 68 | :triggerData="triggerData" |
| 69 | 69 | :ref="skipUnwrap.actionItemRefs" |
| 70 | - :deviceList="deviceList" | |
| 70 | + :provideOrgid="provideOrgid" | |
| 71 | + :deviceList="getMasterDeviceList" | |
| 71 | 72 | :arr="arr" |
| 72 | 73 | @deleteAction="deleteAction" |
| 73 | 74 | @getActionFormArr="getActionFormArr" |
| ... | ... | @@ -99,7 +100,6 @@ |
| 99 | 100 | screenLinkPageByDeptIdGetDevice, |
| 100 | 101 | getOrganizationAlarmConfig, |
| 101 | 102 | byOganizationIdGetMasterDevice, |
| 102 | - getAttribute, | |
| 103 | 103 | } from '/@/api/ruleengine/ruleengineApi'; |
| 104 | 104 | import TriggerOrCondition from './cpns/Trigger-Condition.vue'; |
| 105 | 105 | import Action from './cpns/Action.vue'; |
| ... | ... | @@ -107,8 +107,8 @@ |
| 107 | 107 | import { formatToDateTime } from '/@/utils/dateUtil'; |
| 108 | 108 | |
| 109 | 109 | const emit = defineEmits(['register', 'success']); |
| 110 | - | |
| 111 | 110 | const provideOrgid = ref(''); |
| 111 | + | |
| 112 | 112 | const { createMessage } = useMessage(); |
| 113 | 113 | const triggerData = ref([]); |
| 114 | 114 | const conditionData = ref([]); |
| ... | ... | @@ -125,8 +125,6 @@ |
| 125 | 125 | let getConditionFormValue = ref([]); |
| 126 | 126 | let getActionFormValue = ref([]); |
| 127 | 127 | const editEntryIdData = ref([]); |
| 128 | - const editEntryIdExcludeDoActionData = ref([]); | |
| 129 | - let editAttrIdData = []; | |
| 130 | 128 | const editAlarmConfigData = ref([]); |
| 131 | 129 | const isUpdate = ref(false); |
| 132 | 130 | const id = ref(undefined); |
| ... | ... | @@ -158,31 +156,24 @@ |
| 158 | 156 | await setFieldsValue(data.record); |
| 159 | 157 | id.value = recordId; |
| 160 | 158 | tenantId.value = recordTenantId; |
| 159 | + //TODO-fengtao-把组织id传给子组件 | |
| 161 | 160 | provideOrgid.value = organizationId; |
| 161 | + //TODO-fengtao获取当前执行动作下的设备(master那个接口) | |
| 162 | + getMasterDeviceList.value = await byOganizationIdGetMasterDevice(organizationId); | |
| 163 | + //TODO-fengtao | |
| 162 | 164 | // 获取当前组织下的设备列表 |
| 163 | - const options = await byOganizationIdGetMasterDevice(organizationId); | |
| 164 | - const optionsExcludeDoAction = await screenLinkPageByDeptIdGetDevice({ organizationId }); | |
| 165 | + const options = await screenLinkPageByDeptIdGetDevice({ | |
| 166 | + organizationId, | |
| 167 | + }); | |
| 165 | 168 | // 获取当前组织下的告警配置 |
| 166 | 169 | const alarmConfig = await getOrganizationAlarmConfig({ organizationId }); |
| 167 | - // 获取当前组织下的属性列表 | |
| 168 | - const attrList = await getAttribute( | |
| 169 | - organizationId, | |
| 170 | - triggers.map((m) => m.entityId).join(',') | |
| 171 | - ); | |
| 172 | - watchAttrList.value = await getAttribute(organizationId, null); | |
| 173 | 170 | |
| 174 | 171 | // 生成回显时对应得组件数量 |
| 175 | 172 | triggerData.value = [...new Array(triggers.length).keys()]; |
| 176 | 173 | conditionData.value = [...new Array(doConditions.length).keys()]; |
| 177 | 174 | actionData.value = [...new Array(doActions.length).keys()]; |
| 178 | 175 | // 回显设备列表 |
| 179 | - editEntryIdData.value = options.map((item) => { | |
| 180 | - return { | |
| 181 | - value: item.id, | |
| 182 | - label: item.name, | |
| 183 | - }; | |
| 184 | - }); | |
| 185 | - editEntryIdExcludeDoActionData.value = optionsExcludeDoAction.items.map((item) => { | |
| 176 | + editEntryIdData.value = options.items.map((item) => { | |
| 186 | 177 | return { |
| 187 | 178 | value: item.tbDeviceId, |
| 188 | 179 | label: item.name, |
| ... | ... | @@ -195,17 +186,11 @@ |
| 195 | 186 | }; |
| 196 | 187 | }); |
| 197 | 188 | deviceList.value = editEntryIdData.value; |
| 198 | - deviceExcludeDoAction.value = editEntryIdExcludeDoActionData.value; | |
| 199 | - | |
| 200 | - //回显属性列表 | |
| 201 | - editAttrIdData = attrList; | |
| 202 | 189 | nextTick(() => { |
| 203 | - setEditFields(skipUnwrap.triggerItemRefs, editEntryIdExcludeDoActionData); | |
| 204 | - setEditFields(skipUnwrap.conditionItemRefs, editEntryIdExcludeDoActionData); | |
| 205 | - setEditFields(skipUnwrap.actionItemRefs, editEntryIdData); | |
| 190 | + setEditFields(skipUnwrap.triggerItemRefs, editEntryIdData); | |
| 191 | + setEditFields(skipUnwrap.conditionItemRefs, editEntryIdData); | |
| 192 | + setEditFields(skipUnwrap.actionItemRefs, getMasterDeviceList); | |
| 206 | 193 | setEditAlarmConfig(skipUnwrap.actionItemRefs, editAlarmConfigData); |
| 207 | - setEditAttr(skipUnwrap.triggerItemRefs, editAttrIdData); | |
| 208 | - setEditAttr(skipUnwrap.conditionItemRefs, editAttrIdData); | |
| 209 | 194 | }); |
| 210 | 195 | |
| 211 | 196 | const map = { |
| ... | ... | @@ -216,6 +201,7 @@ |
| 216 | 201 | // 回显触发器数据---此处是个闭包! |
| 217 | 202 | triggers.forEach((trigger, index) => { |
| 218 | 203 | nextTick(async () => { |
| 204 | + const selectDeviceId = ref(''); | |
| 219 | 205 | // 回显启用规则 |
| 220 | 206 | unref(skipUnwrap.triggerItemRefs)[index].currentIndex = |
| 221 | 207 | map[trigger.triggerCondition.schedule.type]; |
| ... | ... | @@ -223,15 +209,12 @@ |
| 223 | 209 | unref(skipUnwrap.triggerItemRefs)[index].isUpdate = true; |
| 224 | 210 | unref(skipUnwrap.triggerItemRefs)[index].alarmScheduleRef.scheduleData = |
| 225 | 211 | trigger.triggerCondition.schedule; |
| 226 | - const getAttrKeyOption = trigger?.triggerCondition?.condition?.condition?.map( | |
| 227 | - (m) => m.key.key | |
| 228 | - ); | |
| 229 | 212 | unref(skipUnwrap.triggerItemRefs)[index].setFieldsFormValueFun({ |
| 230 | 213 | triggered: trigger?.triggerCondition?.condition?.spec?.type, |
| 231 | 214 | device: trigger?.entityType, |
| 232 | 215 | triggerType: trigger?.triggerType, |
| 233 | 216 | type1: trigger?.triggerCondition?.condition?.condition[0]?.key?.type, |
| 234 | - type2: getAttrKeyOption, | |
| 217 | + type2: trigger?.triggerCondition?.condition?.condition[0]?.key?.key, | |
| 235 | 218 | operationType: trigger?.triggerCondition?.condition?.condition[0]?.valueType, |
| 236 | 219 | detail: trigger?.triggerCondition?.alarmDetails, |
| 237 | 220 | entityId: trigger?.entityId, |
| ... | ... | @@ -239,6 +222,15 @@ |
| 239 | 222 | time: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue, |
| 240 | 223 | timeUnit: trigger?.triggerCondition?.condition?.spec?.unit, |
| 241 | 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 | |
| 242 | 234 | // 设置值operationType |
| 243 | 235 | unref(skipUnwrap.triggerItemRefs)[index].operationType = |
| 244 | 236 | trigger.triggerCondition?.condition.condition[0].valueType; |
| ... | ... | @@ -290,6 +282,7 @@ |
| 290 | 282 | |
| 291 | 283 | doConditions.forEach((condition, index) => { |
| 292 | 284 | nextTick(async () => { |
| 285 | + const selectDeviceId = ref(''); | |
| 293 | 286 | // 回显启用规则 |
| 294 | 287 | unref(skipUnwrap.conditionItemRefs)[index].currentIndex = |
| 295 | 288 | map[condition.triggerCondition.schedule.type]; |
| ... | ... | @@ -298,15 +291,12 @@ |
| 298 | 291 | unref(skipUnwrap.conditionItemRefs)[index].isUpdate = true; |
| 299 | 292 | unref(skipUnwrap.conditionItemRefs)[index].alarmScheduleRef.scheduleData = |
| 300 | 293 | condition.triggerCondition.schedule; |
| 301 | - const getAttrKeyOption = condition?.triggerCondition?.condition?.condition?.map( | |
| 302 | - (m) => m.key.key | |
| 303 | - ); | |
| 304 | 294 | unref(skipUnwrap.conditionItemRefs)[index].setFieldsFormValueFun({ |
| 305 | 295 | triggered: condition?.triggerCondition?.condition?.spec?.type, |
| 306 | 296 | device: condition?.entityType, |
| 307 | 297 | triggerType: condition?.triggerType, |
| 308 | 298 | type1: condition?.triggerCondition?.condition?.condition[0]?.key?.type, |
| 309 | - type2: getAttrKeyOption, | |
| 299 | + type2: condition?.triggerCondition?.condition?.condition[0]?.key?.key, | |
| 310 | 300 | operationType: condition?.triggerCondition?.condition?.condition[0]?.valueType, |
| 311 | 301 | detail: condition?.triggerCondition?.alarmDetails, |
| 312 | 302 | entityId: condition?.entityId, |
| ... | ... | @@ -314,6 +304,15 @@ |
| 314 | 304 | time: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue, |
| 315 | 305 | timeUnit: condition?.triggerCondition?.condition?.spec?.unit, |
| 316 | 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 | |
| 317 | 316 | // 设置值operationType |
| 318 | 317 | unref(skipUnwrap.conditionItemRefs)[index].operationType = |
| 319 | 318 | condition.triggerCondition?.condition.condition[0].valueType; |
| ... | ... | @@ -365,6 +364,7 @@ |
| 365 | 364 | |
| 366 | 365 | doActions.forEach((action, index) => { |
| 367 | 366 | nextTick(() => { |
| 367 | + const selectDeviceId = ref(''); | |
| 368 | 368 | // 设置执行动作外层值 |
| 369 | 369 | unref(skipUnwrap.actionItemRefs)[index].setFieldsFormValueFun({ |
| 370 | 370 | outTarget: action.outTarget, |
| ... | ... | @@ -419,6 +419,18 @@ |
| 419 | 419 | timeUnit: |
| 420 | 420 | action.doContext.clearRule[index].triggerCondition.condition.spec.unit, |
| 421 | 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 | |
| 422 | 434 | // 单独设置operationType值 操作符类型 NUMERIC|String|Boolean|DATE_TIME |
| 423 | 435 | item.operationType = |
| 424 | 436 | action.doContext.clearRule[ |
| ... | ... | @@ -444,6 +456,7 @@ |
| 444 | 456 | nextTick(() => { |
| 445 | 457 | const richTextList = []; |
| 446 | 458 | rule.triggerCondition.condition.condition.forEach((item, conditionIndex) => { |
| 459 | + //TODO-fengtao之前是Number( item.predicate.value.defaultValue)-发现回显是Invalide Time | |
| 447 | 460 | const formItem = { |
| 448 | 461 | operation: item.predicate.operation, |
| 449 | 462 | value: |
| ... | ... | @@ -456,18 +469,20 @@ |
| 456 | 469 | ignoreCase: |
| 457 | 470 | item.valueType === 'STRING' ? item.predicate.ignoreCase : undefined, |
| 458 | 471 | }; |
| 472 | + //TODO-fengtao之前是Number( item.predicate.value.defaultValue)-发现回显是Invalide Time | |
| 459 | 473 | richTextList.push({ |
| 460 | 474 | // 查询中文操作符 |
| 461 | 475 | operation: findOperation(item.valueType, item.predicate.operation).label, |
| 462 | 476 | value: |
| 463 | 477 | item.valueType === 'DATE_TIME' |
| 464 | 478 | ? formatToDateTime( |
| 465 | - Number(item.predicate.value.defaultValue), | |
| 479 | + item.predicate.value.defaultValue, | |
| 466 | 480 | 'YYYY-MM-DD HH:mm:ss' |
| 467 | 481 | ) |
| 468 | 482 | : String(item.predicate.value.defaultValue), |
| 469 | 483 | attribute: item?.key?.key, |
| 470 | 484 | }); |
| 485 | + //TODO-fengtao之前是Number( item.predicate.value.defaultValue)-发现回显是Invalide Time | |
| 471 | 486 | ConditionScreeningForm[ruleIndex].value[conditionIndex].setFieldsValue( |
| 472 | 487 | formItem |
| 473 | 488 | ); |
| ... | ... | @@ -493,11 +508,9 @@ |
| 493 | 508 | // 设置设备的options |
| 494 | 509 | const setEditFields = (linkAge, deviceList) => { |
| 495 | 510 | unref(linkAge).map((item) => { |
| 496 | - if (item.isTriggerAndConditionFlag == 'isTriggerAndConditionFlag') { | |
| 497 | - item.updateExcludeActionFieldDeviceId(deviceList); | |
| 498 | - } else { | |
| 499 | - item.updateFieldDeviceId(deviceList); | |
| 500 | - } | |
| 511 | + //TODO-fengtao | |
| 512 | + item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList); | |
| 513 | + //TODO-fengtao | |
| 501 | 514 | }); |
| 502 | 515 | }; |
| 503 | 516 | // 设置告警配置options |
| ... | ... | @@ -506,29 +519,21 @@ |
| 506 | 519 | item.updateEditFieldAlarmConfig(alarmConfigList); |
| 507 | 520 | }); |
| 508 | 521 | }; |
| 509 | - //设置设备属性的options | |
| 510 | - const setEditAttr = (linkAge, attrList) => { | |
| 511 | - unref(linkAge).map((item) => { | |
| 512 | - item.updateFieldAttr(attrList); | |
| 513 | - }); | |
| 514 | - }; | |
| 515 | - | |
| 516 | 522 | // 监听组织变化更新设备列表 |
| 517 | 523 | const deviceList = ref([]); |
| 524 | + const getMasterDeviceList = ref([]); | |
| 525 | + const orgId = ref(''); | |
| 518 | 526 | const alarmConfigList = ref([]); |
| 519 | - const watchAttrList = ref([]); | |
| 520 | - const deviceExcludeDoAction = ref([]); | |
| 521 | 527 | watch(organizationId, async (newValue: string) => { |
| 522 | 528 | if (!newValue) return; |
| 523 | - provideOrgid.value = newValue; | |
| 524 | - const items = await byOganizationIdGetMasterDevice(newValue); | |
| 525 | - const itemExcludeDoAction = await screenLinkPageByDeptIdGetDevice({ organizationId: newValue }); | |
| 526 | - deviceExcludeDoAction.value = itemExcludeDoAction.items.map((item) => ({ | |
| 527 | - label: item.name, | |
| 528 | - value: item.tbDeviceId, | |
| 529 | - })); | |
| 530 | - deviceList.value = items.map((item) => ({ label: item.name, value: item.id })); | |
| 531 | - watchAttrList.value = await getAttribute(newValue, null); | |
| 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 })); | |
| 534 | + //TODO fengtao | |
| 535 | + orgId.value = newValue; | |
| 536 | + //TODO fengtao | |
| 532 | 537 | setFields(skipUnwrap.triggerItemRefs, true); |
| 533 | 538 | setFields(skipUnwrap.conditionItemRefs, true); |
| 534 | 539 | setFields(skipUnwrap.actionItemRefs, true); |
| ... | ... | @@ -541,12 +546,9 @@ |
| 541 | 546 | function setFields(linkAge, isOrganizationChange = false) { |
| 542 | 547 | unref(linkAge).map((item) => { |
| 543 | 548 | isOrganizationChange && item.resetFieldsValueFunc(); |
| 544 | - if (item.isTriggerAndConditionFlag == 'isTriggerAndConditionFlag') { | |
| 545 | - item.updateExcludeActionFieldDeviceId(deviceExcludeDoAction); | |
| 546 | - item.updateFieldAttr(watchAttrList); | |
| 547 | - } else { | |
| 548 | - item.updateFieldDeviceId(deviceList); | |
| 549 | - } | |
| 549 | + //TODO fengtao | |
| 550 | + item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList); | |
| 551 | + //TODO fengtao | |
| 550 | 552 | }); |
| 551 | 553 | } |
| 552 | 554 | function setAlarmConfig(linkAge, isOrganizationChange = false) { |
| ... | ... | @@ -609,7 +611,21 @@ |
| 609 | 611 | id: unref(id), |
| 610 | 612 | tenantId: unref(tenantId), |
| 611 | 613 | }; |
| 612 | - | |
| 614 | + //TODO fengtao---修改之前如果是新增,如果条件筛选页面打开,但没填值,还是可以新增成功 | |
| 615 | + const typeBoolean = postAddOrEditData?.triggers?.some((f) => { | |
| 616 | + let type = false; | |
| 617 | + f?.triggerCondition?.condition?.condition?.some((s) => { | |
| 618 | + if (s?.predicate?.value?.defaultValue == undefined) { | |
| 619 | + type = true; | |
| 620 | + } else { | |
| 621 | + type = false; | |
| 622 | + } | |
| 623 | + }); | |
| 624 | + return type; | |
| 625 | + }); | |
| 626 | + if (typeBoolean) return createMessage.error('请填写条件筛选'); | |
| 627 | + //TODO 先暂时不加验证--设备-属性-填了加验证 | |
| 628 | + //TODO fengtao | |
| 613 | 629 | await screenLinkPageAddApi(postAddOrEditData, unref(isUpdate)); |
| 614 | 630 | createMessage.success(`${unref(isUpdate) ? '编辑' : '新增'}成功`); |
| 615 | 631 | closeDrawer(); |
| ... | ... | @@ -659,8 +675,14 @@ |
| 659 | 675 | </script> |
| 660 | 676 | |
| 661 | 677 | <style lang="less" scoped> |
| 662 | - ///统一下拉选择框宽度,否则超出默认宽度会造成页面样式错乱 | |
| 663 | - :deep(.ant-select-selector) { | |
| 664 | - max-width: 14.2rem; | |
| 678 | + //TODO-fengtao | |
| 679 | + ///移除选择框默认样式(24px)否则超出默认宽度会造成页面样式错乱 | |
| 680 | + ::v-deep(.ant-select-selector) { | |
| 681 | + padding-right: 0px !important; | |
| 682 | + } | |
| 683 | + | |
| 684 | + ::v-deep(.ant-select-selection-overflow) { | |
| 685 | + max-width: 10vw !important; | |
| 665 | 686 | } |
| 687 | + //TODO-fengtao | |
| 666 | 688 | </style> | ... | ... |
| ... | ... | @@ -69,6 +69,7 @@ |
| 69 | 69 | import { Icon } from '/@/components/Icon'; |
| 70 | 70 | import AlarmSchedule from './AlarmSchedule.vue'; |
| 71 | 71 | import { useModal } from '/@/components/Modal'; |
| 72 | + import { cloneDeep } from 'lodash-es'; | |
| 72 | 73 | |
| 73 | 74 | defineProps({ |
| 74 | 75 | index: { |
| ... | ... | @@ -84,7 +85,9 @@ |
| 84 | 85 | const isUpdate = ref(false); |
| 85 | 86 | const conditionScreeningRef = ref(); |
| 86 | 87 | const [registerForm, { resetFields, getFieldsValue, updateSchema, setFieldsValue }] = useForm({ |
| 87 | - schemas: trigger_condition_schema, | |
| 88 | + //TODO-wenwei-修复 | |
| 89 | + schemas: cloneDeep(trigger_condition_schema), | |
| 90 | + //TODO-wenwei-修复 | |
| 88 | 91 | showActionButtonGroup: false, |
| 89 | 92 | }); |
| 90 | 93 | |
| ... | ... | @@ -96,14 +99,83 @@ |
| 96 | 99 | return { ...getFieldsValue(), predicate, schedule: alarmScheduleRef.value.scheduleData }; |
| 97 | 100 | }; |
| 98 | 101 | |
| 99 | - const updateFieldDeviceId = (deviceList: any[]) => { | |
| 102 | + const updateFieldDeviceId = (deviceList: any[], orgId, isUpdate) => { | |
| 103 | + if (isUpdate) { | |
| 104 | + updateSchema({ | |
| 105 | + field: 'entityId', | |
| 106 | + componentProps: { | |
| 107 | + options: deviceList, | |
| 108 | + onChange(e) { | |
| 109 | + if (e) { | |
| 110 | + if (isUpdate) { | |
| 111 | + setFieldsValue({ type2: '' }); | |
| 112 | + } | |
| 113 | + //fengtao | |
| 114 | + updateFieldAttributeFunc(e, orgId); | |
| 115 | + //fengtao | |
| 116 | + } | |
| 117 | + }, | |
| 118 | + }, | |
| 119 | + }); | |
| 120 | + } | |
| 121 | + //新增、编辑都会触发onChang事件 | |
| 100 | 122 | updateSchema({ |
| 101 | - field: 'entityId', | |
| 123 | + field: 'device', | |
| 102 | 124 | componentProps: { |
| 103 | - options: deviceList, | |
| 104 | - onChange(e) { | |
| 125 | + options: [ | |
| 126 | + { label: '全部', value: 'ALL' }, | |
| 127 | + { label: '部分', value: 'PART' }, | |
| 128 | + ], | |
| 129 | + async onChange(e) { | |
| 130 | + setFieldsValue({ type2: '' }); | |
| 131 | + setFieldsValue({ entityId: [] }); | |
| 132 | + //部分切换-清空或者重置为初始值 | |
| 133 | + updateSchema({ | |
| 134 | + field: 'type2', | |
| 135 | + componentProps: { | |
| 136 | + options: [], | |
| 137 | + }, | |
| 138 | + }); | |
| 105 | 139 | if (e) { |
| 106 | - updateFieldAttributeFunc(); | |
| 140 | + //fengtao | |
| 141 | + if (e == 'ALL') { | |
| 142 | + const data = await getAttribute(orgId, null); | |
| 143 | + //fengtao | |
| 144 | + const options = data.map((m) => { | |
| 145 | + return { | |
| 146 | + label: m, | |
| 147 | + value: m, | |
| 148 | + }; | |
| 149 | + }); | |
| 150 | + updateSchema({ | |
| 151 | + field: 'type2', | |
| 152 | + componentProps: { | |
| 153 | + placeholder: '请选择属性', | |
| 154 | + options, | |
| 155 | + }, | |
| 156 | + }); | |
| 157 | + } else { | |
| 158 | + const getT = getFieldsValue(); | |
| 159 | + const entityId = getT.entityId; | |
| 160 | + if (entityId !== undefined && entityId.length > 0) { | |
| 161 | + updateFieldAttributeFunc(entityId, orgId); | |
| 162 | + } | |
| 163 | + updateSchema({ | |
| 164 | + field: 'entityId', | |
| 165 | + componentProps: { | |
| 166 | + options: deviceList, | |
| 167 | + onChange(e) { | |
| 168 | + if (e) { | |
| 169 | + setFieldsValue({ type2: '' }); | |
| 170 | + //fengtao | |
| 171 | + updateFieldAttributeFunc(e, orgId); | |
| 172 | + //fengtao | |
| 173 | + } | |
| 174 | + }, | |
| 175 | + }, | |
| 176 | + }); | |
| 177 | + } | |
| 178 | + //fengtao | |
| 107 | 179 | } |
| 108 | 180 | }, |
| 109 | 181 | }, |
| ... | ... | @@ -115,8 +187,17 @@ |
| 115 | 187 | const setFieldsFormValueFun = (fieldsValue) => { |
| 116 | 188 | setFieldsValue(fieldsValue); |
| 117 | 189 | }; |
| 118 | - const updateFieldAttributeFunc = async () => { | |
| 119 | - const data = await getAttribute(); | |
| 190 | + //TODO-fengtao | |
| 191 | + const updateFieldAttributeFunc = async (deviceId, orgId) => { | |
| 192 | + //TODO-fengtao | |
| 193 | + let data; | |
| 194 | + if (deviceId !== undefined && deviceId.length > 0) { | |
| 195 | + const joinDeviceIds = deviceId.join(','); | |
| 196 | + data = await getAttribute(orgId, joinDeviceIds); | |
| 197 | + } else { | |
| 198 | + data = await getAttribute(orgId, null); | |
| 199 | + } | |
| 200 | + //TODO-fengtao | |
| 120 | 201 | const options = data.map((m) => { |
| 121 | 202 | return { |
| 122 | 203 | label: m, |
| ... | ... | @@ -127,10 +208,11 @@ |
| 127 | 208 | field: 'type2', |
| 128 | 209 | componentProps: { |
| 129 | 210 | placeholder: '请选择属性', |
| 130 | - options, | |
| 211 | + options: options, | |
| 131 | 212 | }, |
| 132 | 213 | }); |
| 133 | 214 | }; |
| 215 | + //TODO-fengtao | |
| 134 | 216 | const schedule = ref('ANY_TIME'); |
| 135 | 217 | const operationType = ref<string>(''); |
| 136 | 218 | provide('operationType', operationType); |
| ... | ... | @@ -196,6 +278,7 @@ |
| 196 | 278 | scheduleData, |
| 197 | 279 | isUpdate, |
| 198 | 280 | alarmScheduleRef, |
| 281 | + updateFieldAttributeFunc, | |
| 199 | 282 | }); |
| 200 | 283 | </script> |
| 201 | 284 | <style> | ... | ... |
| ... | ... | @@ -68,6 +68,7 @@ |
| 68 | 68 | import { scheduleOptions, timeUnitOptions, options } from '../config/formatData.ts'; |
| 69 | 69 | import AlarmSchedule from './AlarmSchedule.vue'; |
| 70 | 70 | import { useModal } from '/@/components/Modal'; |
| 71 | + import { cloneDeep } from 'lodash-es'; | |
| 71 | 72 | |
| 72 | 73 | const props = defineProps({ |
| 73 | 74 | title: { |
| ... | ... | @@ -87,7 +88,9 @@ |
| 87 | 88 | const isUpdate = ref(false); |
| 88 | 89 | const conditionScreeningRef = ref(); |
| 89 | 90 | const [registerForm, { resetFields, getFieldsValue, updateSchema, setFieldsValue }] = useForm({ |
| 90 | - schemas: trigger_condition_schema, | |
| 91 | + //TODO-wenwei-修复 | |
| 92 | + schemas: cloneDeep(trigger_condition_schema), | |
| 93 | + //TODO-wenwei-修复 | |
| 91 | 94 | showActionButtonGroup: false, |
| 92 | 95 | }); |
| 93 | 96 | |
| ... | ... | @@ -98,42 +101,107 @@ |
| 98 | 101 | ); |
| 99 | 102 | return { ...getFieldsValue(), predicate, schedule: alarmScheduleRef.value.scheduleData }; |
| 100 | 103 | }; |
| 101 | - const updateExcludeActionFieldDeviceId = (deviceList: any[]) => { | |
| 104 | + | |
| 105 | + //TODO-fengtao | |
| 106 | + const updateFieldDeviceId = (deviceList: any[], orgId, isUpdate) => { | |
| 107 | + //用于编辑回显 | |
| 108 | + if (isUpdate.value) { | |
| 109 | + updateSchema({ | |
| 110 | + field: 'entityId', | |
| 111 | + componentProps: { | |
| 112 | + options: deviceList, | |
| 113 | + onChange(e) { | |
| 114 | + if (e) { | |
| 115 | + if (isUpdate.value) { | |
| 116 | + setFieldsValue({ type2: '' }); | |
| 117 | + } | |
| 118 | + //fengtao | |
| 119 | + updateFieldAttributeFunc(e, orgId.value); | |
| 120 | + //fengtao | |
| 121 | + } | |
| 122 | + }, | |
| 123 | + }, | |
| 124 | + }); | |
| 125 | + } | |
| 126 | + //新增、编辑都会触发onChang事件 | |
| 102 | 127 | updateSchema({ |
| 103 | - field: 'entityId', | |
| 128 | + field: 'device', | |
| 104 | 129 | componentProps: { |
| 105 | - options: deviceList, | |
| 106 | - onChange(e) { | |
| 130 | + options: [ | |
| 131 | + { label: '全部', value: 'ALL' }, | |
| 132 | + { label: '部分', value: 'PART' }, | |
| 133 | + ], | |
| 134 | + async onChange(e) { | |
| 135 | + setFieldsValue({ type2: '' }); | |
| 136 | + setFieldsValue({ entityId: [] }); | |
| 137 | + updateSchema({ | |
| 138 | + field: 'type2', | |
| 139 | + componentProps: { | |
| 140 | + options: [], | |
| 141 | + }, | |
| 142 | + }); | |
| 107 | 143 | if (e) { |
| 108 | - updateFieldAttributeFunc(e); | |
| 144 | + //fengtao | |
| 145 | + if (e == 'ALL') { | |
| 146 | + const data = await getAttribute(props.provideOrgid || orgId.value, null); | |
| 147 | + //fengtao | |
| 148 | + const options = data.map((m) => { | |
| 149 | + return { | |
| 150 | + label: m, | |
| 151 | + value: m, | |
| 152 | + }; | |
| 153 | + }); | |
| 154 | + updateSchema({ | |
| 155 | + field: 'type2', | |
| 156 | + componentProps: { | |
| 157 | + placeholder: '请选择属性', | |
| 158 | + options, | |
| 159 | + }, | |
| 160 | + }); | |
| 161 | + } else { | |
| 162 | + const getT = getFieldsValue(); | |
| 163 | + const entityId = getT.entityId; | |
| 164 | + if (entityId !== undefined && entityId.length > 0) { | |
| 165 | + updateFieldAttributeFunc(entityId, orgId.value); | |
| 166 | + } | |
| 167 | + updateSchema({ | |
| 168 | + field: 'entityId', | |
| 169 | + componentProps: { | |
| 170 | + options: deviceList, | |
| 171 | + onChange(e) { | |
| 172 | + if (e) { | |
| 173 | + setFieldsValue({ type2: '' }); | |
| 174 | + //fengtao | |
| 175 | + updateFieldAttributeFunc(e, orgId.value); | |
| 176 | + //fengtao | |
| 177 | + } | |
| 178 | + }, | |
| 179 | + }, | |
| 180 | + }); | |
| 181 | + } | |
| 182 | + //fengtao | |
| 109 | 183 | } |
| 110 | 184 | }, |
| 111 | 185 | }, |
| 112 | 186 | }); |
| 113 | 187 | }; |
| 114 | - const updateFieldAttr = (attrList: any[]) => { | |
| 115 | - const attrMapList = attrList.value?.map((m) => { | |
| 116 | - return { | |
| 117 | - label: m, | |
| 118 | - value: m, | |
| 119 | - }; | |
| 120 | - }); | |
| 121 | - updateSchema({ | |
| 122 | - field: 'type2', | |
| 123 | - componentProps: { | |
| 124 | - placeholder: '请选择属性', | |
| 125 | - options: attrMapList, | |
| 126 | - }, | |
| 127 | - }); | |
| 128 | - }; | |
| 188 | + //TODO-fengtao | |
| 129 | 189 | const resetFieldsValueFunc = () => resetFields(); |
| 130 | 190 | // 回显数据函数 |
| 131 | 191 | const setFieldsFormValueFun = (fieldsValue) => { |
| 132 | 192 | setFieldsValue(fieldsValue); |
| 133 | 193 | }; |
| 134 | - const updateFieldAttributeFunc = async (e) => { | |
| 135 | - const joinDeviceIds = e.join(','); | |
| 136 | - const data = await getAttribute(props.provideOrgid, joinDeviceIds); | |
| 194 | + //TODO-fengtao | |
| 195 | + const updateFieldAttributeFunc = async (deviceId, orgId) => { | |
| 196 | + //TODO-fengtao | |
| 197 | + let data; | |
| 198 | + if (deviceId !== undefined && deviceId.length > 0) { | |
| 199 | + const joinDeviceIds = deviceId.join(','); | |
| 200 | + data = await getAttribute(orgId || props.provideOrgid, joinDeviceIds); | |
| 201 | + } else { | |
| 202 | + data = await getAttribute(orgId || props.provideOrgid, null); | |
| 203 | + } | |
| 204 | + //TODO-fengtao | |
| 137 | 205 | const options = data.map((m) => { |
| 138 | 206 | return { |
| 139 | 207 | label: m, |
| ... | ... | @@ -144,11 +212,11 @@ |
| 144 | 212 | field: 'type2', |
| 145 | 213 | componentProps: { |
| 146 | 214 | placeholder: '请选择属性', |
| 147 | - options, | |
| 215 | + options: options, | |
| 148 | 216 | }, |
| 149 | 217 | }); |
| 150 | 218 | }; |
| 151 | - | |
| 219 | + //TODO-fengtao | |
| 152 | 220 | const handleDelete = (params: { index: number; title: string }) => { |
| 153 | 221 | emit('delete', params); |
| 154 | 222 | }; |
| ... | ... | @@ -195,12 +263,9 @@ |
| 195 | 263 | currentIndex.value = index; |
| 196 | 264 | }; |
| 197 | 265 | const scheduleData = ref(null); |
| 198 | - const isTriggerAndConditionFlag = 'isTriggerAndConditionFlag'; | |
| 199 | 266 | defineExpose({ |
| 200 | - isTriggerAndConditionFlag, | |
| 201 | 267 | getFieldsValueFunc, |
| 202 | - updateExcludeActionFieldDeviceId, | |
| 203 | - updateFieldAttr, | |
| 268 | + updateFieldDeviceId, | |
| 204 | 269 | resetFieldsValueFunc, |
| 205 | 270 | setFieldsFormValueFun, |
| 206 | 271 | childGetFieldsValue, |
| ... | ... | @@ -212,9 +277,17 @@ |
| 212 | 277 | scheduleData, |
| 213 | 278 | isUpdate, |
| 214 | 279 | alarmScheduleRef, |
| 280 | + updateFieldAttributeFunc, | |
| 215 | 281 | }); |
| 216 | 282 | </script> |
| 217 | 283 | |
| 284 | +<style lang="less" scoped> | |
| 285 | + ///移除选择框默认样式(24px)否则超出默认宽度会造成页面样式错乱 | |
| 286 | + ::v-deep(.ant-select-selector) { | |
| 287 | + padding-right: 0px !important; | |
| 288 | + } | |
| 289 | +</style> | |
| 290 | + | |
| 218 | 291 | <style> |
| 219 | 292 | .active { |
| 220 | 293 | color: #377dff; | ... | ... |
| ... | ... | @@ -90,6 +90,10 @@ |
| 90 | 90 | type: Array, |
| 91 | 91 | default: () => [], |
| 92 | 92 | }, |
| 93 | + provideOrgid: { | |
| 94 | + type: String, | |
| 95 | + default: '', | |
| 96 | + }, | |
| 93 | 97 | }); |
| 94 | 98 | const isAddClearRule = computed(() => clearRuleList.value.length < props.triggerData.length); |
| 95 | 99 | const refItem = { |
| ... | ... | @@ -140,14 +144,34 @@ |
| 140 | 144 | setFieldsValue(fieldsValue); |
| 141 | 145 | }; |
| 142 | 146 | const resetFieldsValueFunc = () => resetFields(); |
| 143 | - const updateFieldDeviceId = (deviceList) => { | |
| 147 | + | |
| 148 | + const orgIdItem = ref(''); | |
| 149 | + const isUpdateItem = ref(''); | |
| 150 | + const deviceListItem = ref([]); | |
| 151 | + | |
| 152 | + //TODO-fengtao | |
| 153 | + const updateFieldDeviceId = (deviceList, orgId, isUpdate, getMasterDeviceList) => { | |
| 154 | + if (isUpdate.value) { | |
| 155 | + orgIdItem.value = orgId.value; | |
| 156 | + } | |
| 157 | + orgIdItem.value = orgId.value; | |
| 158 | + isUpdateItem.value = isUpdate.value; | |
| 159 | + const options = getMasterDeviceList.value.map((m) => { | |
| 160 | + return { | |
| 161 | + value: m.id, | |
| 162 | + label: m.name, | |
| 163 | + }; | |
| 164 | + }); | |
| 165 | + deviceListItem.value = deviceList.value; | |
| 166 | + console.log(' deviceListItem.value', deviceListItem.value); | |
| 144 | 167 | updateSchema({ |
| 145 | 168 | field: 'deviceId', |
| 146 | 169 | componentProps: { |
| 147 | - options: deviceList, | |
| 170 | + options, | |
| 148 | 171 | }, |
| 149 | 172 | }); |
| 150 | 173 | }; |
| 174 | + //TODO-fengtao | |
| 151 | 175 | const updateEditFieldAlarmConfig = (alarmConfigList) => { |
| 152 | 176 | updateSchema({ |
| 153 | 177 | field: 'alarm_config', |
| ... | ... | @@ -191,7 +215,11 @@ |
| 191 | 215 | |
| 192 | 216 | function setFields(refs) { |
| 193 | 217 | unref(refs).map((item) => { |
| 194 | - item.updateFieldDeviceId(props.deviceList); | |
| 218 | + item.updateFieldDeviceId( | |
| 219 | + deviceListItem.value, | |
| 220 | + props.provideOrgid || orgIdItem.value, | |
| 221 | + isUpdateItem.value | |
| 222 | + ); | |
| 195 | 223 | }); |
| 196 | 224 | } |
| 197 | 225 | const deleteClearRule = (index) => { | ... | ... |
| ... | ... | @@ -84,10 +84,9 @@ |
| 84 | 84 | emit('isStatus', { status: 1, jsCode }); |
| 85 | 85 | }; |
| 86 | 86 | const handleSubmit = async () => { |
| 87 | + setDrawerProps({ confirmLoading: true }); | |
| 87 | 88 | const fieldsValue = getFieldsValue(); |
| 88 | 89 | try { |
| 89 | - setDrawerProps({ confirmLoading: true }); | |
| 90 | - | |
| 91 | 90 | await createOrEditTransformScriptApi({ |
| 92 | 91 | configuration: { |
| 93 | 92 | jsScript: aceEditor.value.getValue(), |
| ... | ... | @@ -103,7 +102,9 @@ |
| 103 | 102 | const { createMessage } = useMessage(); |
| 104 | 103 | createMessage.success('保存失败'); |
| 105 | 104 | } finally { |
| 106 | - setDrawerProps({ confirmLoading: false }); | |
| 105 | + setTimeout(() => { | |
| 106 | + setDrawerProps({ confirmLoading: false }); | |
| 107 | + }, 300); | |
| 107 | 108 | } |
| 108 | 109 | }; |
| 109 | 110 | const handleFormat = () => { | ... | ... |
| ... | ... | @@ -111,6 +111,7 @@ |
| 111 | 111 | const getTitle = computed(() => (!unref(isUpdate) ? '新增账号' : '编辑账号')); |
| 112 | 112 | |
| 113 | 113 | async function handleSubmit() { |
| 114 | + setModalProps({ confirmLoading: true }); | |
| 114 | 115 | try { |
| 115 | 116 | const { createMessage } = useMessage(); |
| 116 | 117 | if (unref(isUpdate)) { |
| ... | ... | @@ -133,7 +134,6 @@ |
| 133 | 134 | typeof values.accountExpireTime != 'undefined' && values.accountExpireTime != null |
| 134 | 135 | ? values.accountExpireTime.format('YYYY-MM-DD HH:mm:ss') |
| 135 | 136 | : null; |
| 136 | - setModalProps({ confirmLoading: true }); | |
| 137 | 137 | Object.assign(postData, values); |
| 138 | 138 | if (unref(isUpdate)) { |
| 139 | 139 | if (values.email == '') { |
| ... | ... | @@ -149,7 +149,9 @@ |
| 149 | 149 | emit('success'); |
| 150 | 150 | createMessage.success(unref(isUpdate) ? '编辑成功' : '新增成功'); |
| 151 | 151 | } finally { |
| 152 | - setModalProps({ confirmLoading: false }); | |
| 152 | + setTimeout(() => { | |
| 153 | + setModalProps({ confirmLoading: false }); | |
| 154 | + }, 300); | |
| 153 | 155 | } |
| 154 | 156 | } |
| 155 | 157 | return { | ... | ... |
| ... | ... | @@ -45,10 +45,10 @@ |
| 45 | 45 | const getTitle = computed(() => (!unref(isUpdate) ? '新增字典配置' : '编辑字典配置')); |
| 46 | 46 | |
| 47 | 47 | async function handleSubmit() { |
| 48 | + setDrawerProps({ confirmLoading: true }); | |
| 48 | 49 | try { |
| 49 | 50 | const values = await validate(); |
| 50 | 51 | const { createMessage } = useMessage(); |
| 51 | - setDrawerProps({ confirmLoading: true }); | |
| 52 | 52 | let successMessage = '添加成功'; |
| 53 | 53 | //如果是修改需要传入id |
| 54 | 54 | if (unref(isUpdate)) { |
| ... | ... | @@ -61,7 +61,9 @@ |
| 61 | 61 | createMessage.success(successMessage); |
| 62 | 62 | }); |
| 63 | 63 | } finally { |
| 64 | - setDrawerProps({ confirmLoading: false }); | |
| 64 | + setTimeout(() => { | |
| 65 | + setDrawerProps({ confirmLoading: false }); | |
| 66 | + }, 300); | |
| 65 | 67 | } |
| 66 | 68 | } |
| 67 | 69 | ... | ... |
| 1 | 1 | import { BasicColumn, FormSchema } from '/@/components/Table'; |
| 2 | 2 | import moment from 'moment'; |
| 3 | 3 | import { findDictItemByCode } from '/@/api/system/dict'; |
| 4 | +import { format } from '../util'; | |
| 4 | 5 | |
| 5 | 6 | //格式化资源类型和操作类型 |
| 6 | 7 | let formatText; |
| ... | ... | @@ -71,7 +72,7 @@ export const columns: BasicColumn[] = [ |
| 71 | 72 | dataIndex: 'createdTime', |
| 72 | 73 | width: 180, |
| 73 | 74 | format: (_, record) => { |
| 74 | - return moment(record.createdTime).format('YYYY-MM-DD HH:MM:ss'); | |
| 75 | + return format(record.createdTime, 'yyyy-MM-dd HH:mm:ss'); | |
| 75 | 76 | }, |
| 76 | 77 | }, |
| 77 | 78 | ]; | ... | ... |
| 1 | 1 | import { BasicColumn, FormSchema } from '/@/components/Table'; |
| 2 | 2 | import moment from 'moment'; |
| 3 | 3 | import { findDictItemByCode } from '/@/api/system/dict'; |
| 4 | +import { format } from '../util'; | |
| 4 | 5 | |
| 5 | 6 | //格式化资源类型和操作类型 |
| 6 | 7 | let formatText; |
| ... | ... | @@ -72,7 +73,7 @@ export const columns: BasicColumn[] = [ |
| 72 | 73 | dataIndex: 'createdTime', |
| 73 | 74 | width: 180, |
| 74 | 75 | format: (_, record) => { |
| 75 | - return moment(record.createdTime).format('YYYY-MM-DD HH:MM:ss'); | |
| 76 | + return format(record.createdTime, 'yyyy-MM-dd HH:mm:ss'); | |
| 76 | 77 | }, |
| 77 | 78 | }, |
| 78 | 79 | ]; | ... | ... |
| 1 | 1 | import { BasicColumn, FormSchema } from '/@/components/Table'; |
| 2 | 2 | import moment from 'moment'; |
| 3 | 3 | import { findDictItemByCode } from '/@/api/system/dict'; |
| 4 | +import { format } from '../util'; | |
| 4 | 5 | |
| 5 | 6 | // 表格数据 |
| 6 | 7 | export const columns: BasicColumn[] = [ |
| ... | ... | @@ -40,7 +41,7 @@ export const columns: BasicColumn[] = [ |
| 40 | 41 | dataIndex: 'createdTime', |
| 41 | 42 | width: 180, |
| 42 | 43 | format: (_, record) => { |
| 43 | - return moment(record.createdTime).format('YYYY-MM-DD HH:MM:ss'); | |
| 44 | + return format(record.createdTime, 'yyyy-MM-dd HH:mm:ss'); | |
| 44 | 45 | }, |
| 45 | 46 | }, |
| 46 | 47 | ]; | ... | ... |
src/views/system/log/util.ts
0 → 100644
| 1 | +/** | |
| 2 | + * 毫秒时间戳格式化时间 | |
| 3 | + */ | |
| 4 | +export function format(time, format) { | |
| 5 | + const t = new Date(time); | |
| 6 | + const tf = function (i) { | |
| 7 | + return (i < 10 ? '0' : '') + i; | |
| 8 | + }; | |
| 9 | + return format.replace(/yyyy|MM|dd|HH|mm|ss/g, function (a) { | |
| 10 | + switch (a) { | |
| 11 | + case 'yyyy': | |
| 12 | + return tf(t.getFullYear()); | |
| 13 | + break; | |
| 14 | + case 'MM': | |
| 15 | + return tf(t.getMonth() + 1); | |
| 16 | + break; | |
| 17 | + case 'mm': | |
| 18 | + return tf(t.getMinutes()); | |
| 19 | + break; | |
| 20 | + case 'dd': | |
| 21 | + return tf(t.getDate()); | |
| 22 | + break; | |
| 23 | + case 'HH': | |
| 24 | + return tf(t.getHours()); | |
| 25 | + break; | |
| 26 | + case 'ss': | |
| 27 | + return tf(t.getSeconds()); | |
| 28 | + break; | |
| 29 | + } | |
| 30 | + }); | |
| 31 | +} | ... | ... |
| ... | ... | @@ -67,9 +67,9 @@ |
| 67 | 67 | |
| 68 | 68 | //提交按钮 |
| 69 | 69 | async function handleSubmit() { |
| 70 | + setDrawerProps({ confirmLoading: true }); | |
| 70 | 71 | try { |
| 71 | 72 | const values = await validate(); |
| 72 | - setDrawerProps({ confirmLoading: true }); | |
| 73 | 73 | if (isUpdate.value) { |
| 74 | 74 | Reflect.set(values, 'id', organizationId); |
| 75 | 75 | } |
| ... | ... | @@ -82,7 +82,9 @@ |
| 82 | 82 | emit('success'); |
| 83 | 83 | } catch { |
| 84 | 84 | } finally { |
| 85 | - setDrawerProps({ confirmLoading: false }); | |
| 85 | + setTimeout(() => { | |
| 86 | + setDrawerProps({ confirmLoading: false }); | |
| 87 | + }, 300); | |
| 86 | 88 | } |
| 87 | 89 | } |
| 88 | 90 | ... | ... |
| ... | ... | @@ -79,6 +79,8 @@ |
| 79 | 79 | const originMenus = ref(); |
| 80 | 80 | const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { |
| 81 | 81 | allCheckedKeys.value = []; |
| 82 | + originMenus.value = []; | |
| 83 | + allCheckedKeys.value.length = 0; | |
| 82 | 84 | resetFields(); |
| 83 | 85 | roleId.value = ''; |
| 84 | 86 | // 在打开弹窗时清除所有选择的菜单 |
| ... | ... | @@ -90,6 +92,11 @@ |
| 90 | 92 | const menuListModel = await getMenuList(); |
| 91 | 93 | processChildren(menuListModel); |
| 92 | 94 | treeData.value = menuListModel; |
| 95 | + //修复角色菜单新增-全部展开问题-只展开第一级即可 | |
| 96 | + nextTick(() => { | |
| 97 | + const getAllIds = lookForAllId(treeData.value, []); | |
| 98 | + treeExpandData.value = getAllIds; | |
| 99 | + }); | |
| 93 | 100 | } |
| 94 | 101 | // 更新 |
| 95 | 102 | if (unref(isUpdate)) { |
| ... | ... | @@ -130,10 +137,10 @@ |
| 130 | 137 | const getTitle = computed(() => (!unref(isUpdate) ? '新增角色' : '编辑角色')); |
| 131 | 138 | |
| 132 | 139 | async function handleSubmit() { |
| 140 | + setDrawerProps({ confirmLoading: true }); | |
| 133 | 141 | const { createMessage } = useMessage(); |
| 134 | 142 | try { |
| 135 | 143 | const values = await validate(); |
| 136 | - setDrawerProps({ confirmLoading: true }); | |
| 137 | 144 | const req = { |
| 138 | 145 | id: roleId.value, |
| 139 | 146 | name: values.name, |
| ... | ... | @@ -141,7 +148,6 @@ |
| 141 | 148 | status: values.status, |
| 142 | 149 | menu: allCheckedKeys.value.length ? allCheckedKeys.value : originMenus.value, |
| 143 | 150 | }; |
| 144 | - if (allCheckedKeys.value.length == 0) return createMessage.error('请勾选权限菜单'); | |
| 145 | 151 | if (req.menu == undefined) return createMessage.error('请勾选权限菜单'); |
| 146 | 152 | saveOrUpdateRoleInfoWithMenu(req).then(() => { |
| 147 | 153 | closeDrawer(); |
| ... | ... | @@ -149,7 +155,9 @@ |
| 149 | 155 | createMessage.success(`${unref(isUpdate) ? '编辑' : '新增'}成功`); |
| 150 | 156 | }); |
| 151 | 157 | } finally { |
| 152 | - setDrawerProps({ confirmLoading: false }); | |
| 158 | + setTimeout(() => { | |
| 159 | + setDrawerProps({ confirmLoading: false }); | |
| 160 | + }, 300); | |
| 153 | 161 | } |
| 154 | 162 | } |
| 155 | 163 | // Tree check事件 | ... | ... |
| ... | ... | @@ -90,8 +90,8 @@ |
| 90 | 90 | }; |
| 91 | 91 | |
| 92 | 92 | async function handleSubmit() { |
| 93 | + setDrawerProps({ confirmLoading: true }); | |
| 93 | 94 | try { |
| 94 | - setDrawerProps({ confirmLoading: true }); | |
| 95 | 95 | if (!unref(isUpdate)) { |
| 96 | 96 | getAllFieldsFunc(); |
| 97 | 97 | await saveTenantProfileApi(postAllData); |
| ... | ... | @@ -108,7 +108,9 @@ |
| 108 | 108 | } |
| 109 | 109 | } catch (e) { |
| 110 | 110 | } finally { |
| 111 | - setDrawerProps({ confirmLoading: false }); | |
| 111 | + setTimeout(() => { | |
| 112 | + setDrawerProps({ confirmLoading: false }); | |
| 113 | + }, 300); | |
| 112 | 114 | } |
| 113 | 115 | } |
| 114 | 116 | return { | ... | ... |
| ... | ... | @@ -143,6 +143,7 @@ |
| 143 | 143 | const getTitle = computed(() => (!unref(isUpdate) ? '新增租户管理员' : '编辑租户管理员')); |
| 144 | 144 | |
| 145 | 145 | async function handleSubmit() { |
| 146 | + setDrawerProps({ confirmLoading: true }); | |
| 146 | 147 | try { |
| 147 | 148 | const values = await validate(); |
| 148 | 149 | const requestParams = { |
| ... | ... | @@ -158,13 +159,14 @@ |
| 158 | 159 | : null, |
| 159 | 160 | tenantId: tenantId.value, |
| 160 | 161 | }; |
| 161 | - setDrawerProps({ confirmLoading: true }); | |
| 162 | 162 | saveTenantAdmin(requestParams as any as UserDTO).then(() => { |
| 163 | 163 | closeDrawer(); //关闭侧框 |
| 164 | 164 | emit('success'); |
| 165 | 165 | }); |
| 166 | 166 | } finally { |
| 167 | - setDrawerProps({ confirmLoading: false }); | |
| 167 | + setTimeout(() => { | |
| 168 | + setDrawerProps({ confirmLoading: false }); | |
| 169 | + }, 300); | |
| 168 | 170 | } |
| 169 | 171 | } |
| 170 | 172 | ... | ... |
| ... | ... | @@ -19,7 +19,8 @@ |
| 19 | 19 | > |
| 20 | 20 | <img v-if="tenantLogo" :src="tenantLogo" alt="avatar" /> |
| 21 | 21 | <div v-else> |
| 22 | - <plus-outlined /> | |
| 22 | + <loading-outlined v-if="loading"></loading-outlined> | |
| 23 | + <plus-outlined v-else /> | |
| 23 | 24 | <div class="ant-upload-text">上传</div> |
| 24 | 25 | </div> |
| 25 | 26 | </Upload> |
| ... | ... | @@ -31,7 +32,7 @@ |
| 31 | 32 | import { defineComponent, ref, computed, unref } from 'vue'; |
| 32 | 33 | import { BasicForm, useForm } from '/@/components/Form/index'; |
| 33 | 34 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; |
| 34 | - import { PlusOutlined } from '@ant-design/icons-vue'; | |
| 35 | + import { PlusOutlined, LoadingOutlined } from '@ant-design/icons-vue'; | |
| 35 | 36 | import { message, Upload } from 'ant-design-vue'; |
| 36 | 37 | |
| 37 | 38 | import { useI18n } from '/@/hooks/web/useI18n'; |
| ... | ... | @@ -47,19 +48,25 @@ |
| 47 | 48 | BasicForm, |
| 48 | 49 | Upload, |
| 49 | 50 | PlusOutlined, |
| 51 | + LoadingOutlined, | |
| 50 | 52 | }, |
| 51 | 53 | emits: ['success', 'register'], |
| 52 | 54 | setup(_, { emit }) { |
| 55 | + const loading = ref(false); | |
| 56 | + | |
| 53 | 57 | const isUpdate = ref(true); |
| 54 | 58 | const tenantLogo = ref(''); |
| 55 | 59 | |
| 56 | 60 | async function customUpload({ file }) { |
| 57 | 61 | if (beforeUpload(file)) { |
| 62 | + loading.value = true; | |
| 63 | + | |
| 58 | 64 | const formData = new FormData(); |
| 59 | 65 | formData.append('file', file); |
| 60 | 66 | const response = await upload(formData); |
| 61 | 67 | if (response.fileStaticUri) { |
| 62 | 68 | tenantLogo.value = response.fileStaticUri; |
| 69 | + loading.value = false; | |
| 63 | 70 | } |
| 64 | 71 | } |
| 65 | 72 | } |
| ... | ... | @@ -113,9 +120,9 @@ |
| 113 | 120 | |
| 114 | 121 | //提交按钮 |
| 115 | 122 | async function handleSubmit() { |
| 123 | + setDrawerProps({ confirmLoading: true }); | |
| 116 | 124 | try { |
| 117 | 125 | const values = await validate(); |
| 118 | - setDrawerProps({ confirmLoading: true }); | |
| 119 | 126 | const req = { |
| 120 | 127 | id: values.id, |
| 121 | 128 | icon: tenantLogo.value, |
| ... | ... | @@ -133,16 +140,20 @@ |
| 133 | 140 | entityType: 'TENANT_PROFILE', |
| 134 | 141 | }, |
| 135 | 142 | }; |
| 136 | - await updateOrCreateTenant(req); | |
| 137 | - closeDrawer(); //关闭侧框 | |
| 138 | - emit('success'); | |
| 143 | + updateOrCreateTenant(req) | |
| 144 | + .then((res) => { | |
| 145 | + closeDrawer(); //关闭侧框 | |
| 146 | + emit('success'); | |
| 147 | + }) | |
| 148 | + .catch((e) => { | |
| 149 | + const { createMessage } = useMessage(); | |
| 150 | + createMessage.error(`${e.message}`); | |
| 151 | + }); | |
| 139 | 152 | } catch (e) { |
| 140 | - const { createMessage } = useMessage(); | |
| 141 | - createMessage.error("Can't use isolated tenant profiles in monolith setup!"); | |
| 142 | 153 | } finally { |
| 143 | - setDrawerProps({ | |
| 144 | - confirmLoading: false, | |
| 145 | - }); | |
| 154 | + setTimeout(() => { | |
| 155 | + setDrawerProps({ confirmLoading: false }); | |
| 156 | + }, 300); | |
| 146 | 157 | } |
| 147 | 158 | } |
| 148 | 159 | |
| ... | ... | @@ -154,6 +165,7 @@ |
| 154 | 165 | tenantLogo, |
| 155 | 166 | beforeUpload, |
| 156 | 167 | customUpload, |
| 168 | + loading, | |
| 157 | 169 | }; |
| 158 | 170 | }, |
| 159 | 171 | }); | ... | ... |
| ... | ... | @@ -13,7 +13,6 @@ |
| 13 | 13 | v-if="treeData.length > 0" |
| 14 | 14 | :treeData="treeData" |
| 15 | 15 | :expandedKeys="treeExpandData" |
| 16 | - autoExpandParent | |
| 17 | 16 | :replaceFields="{ title: 'menuName' }" |
| 18 | 17 | :checkedKeys="roleMenus" |
| 19 | 18 | @check="handleCheckClick" |
| ... | ... | @@ -85,6 +84,9 @@ |
| 85 | 84 | const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { |
| 86 | 85 | setDrawerProps({ confirmLoading: false }); |
| 87 | 86 | allCheckedKeys.value = []; |
| 87 | + originMenus.value = []; | |
| 88 | + treeExpandData.value; | |
| 89 | + allCheckedKeys.value.length = 0; | |
| 88 | 90 | resetFields(); |
| 89 | 91 | roleId.value = ''; |
| 90 | 92 | // 在打开弹窗时清除所有选择的菜单 |
| ... | ... | @@ -96,6 +98,11 @@ |
| 96 | 98 | const menuListModel = await getMenuList(); |
| 97 | 99 | processChildren(menuListModel); |
| 98 | 100 | treeData.value = menuListModel; |
| 101 | + //修复角色菜单新增-全部展开问题-只展开第一级即可 | |
| 102 | + nextTick(() => { | |
| 103 | + const getAllIds = lookForAllId(treeData.value, []); | |
| 104 | + treeExpandData.value = getAllIds; | |
| 105 | + }); | |
| 99 | 106 | } |
| 100 | 107 | // 更新 |
| 101 | 108 | if (unref(isUpdate)) { |
| ... | ... | @@ -132,11 +139,10 @@ |
| 132 | 139 | const getTitle = computed(() => (!unref(isUpdate) ? '新增角色' : '编辑角色')); |
| 133 | 140 | |
| 134 | 141 | async function handleSubmit() { |
| 142 | + setDrawerProps({ confirmLoading: true }); | |
| 135 | 143 | const { createMessage } = useMessage(); |
| 136 | - | |
| 137 | 144 | try { |
| 138 | 145 | const values = await validate(); |
| 139 | - setDrawerProps({ confirmLoading: true }); | |
| 140 | 146 | const req = { |
| 141 | 147 | id: roleId.value, |
| 142 | 148 | name: values.name, |
| ... | ... | @@ -145,7 +151,6 @@ |
| 145 | 151 | roleType: RoleEnum.TENANT_ADMIN, |
| 146 | 152 | menu: allCheckedKeys.value.length ? allCheckedKeys.value : originMenus.value, |
| 147 | 153 | }; |
| 148 | - if (allCheckedKeys.value.length == 0) return createMessage.error('请勾选权限菜单'); | |
| 149 | 154 | if (req.menu == undefined) return createMessage.error('请勾选权限菜单'); |
| 150 | 155 | saveOrUpdateRoleInfoWithMenu(req).then(() => { |
| 151 | 156 | closeDrawer(); |
| ... | ... | @@ -154,7 +159,9 @@ |
| 154 | 159 | }); |
| 155 | 160 | } catch { |
| 156 | 161 | } finally { |
| 157 | - setDrawerProps({ confirmLoading: false }); | |
| 162 | + setTimeout(() => { | |
| 163 | + setDrawerProps({ confirmLoading: false }); | |
| 164 | + }, 300); | |
| 158 | 165 | } |
| 159 | 166 | } |
| 160 | 167 | // Tree check事件 | ... | ... |