Showing
7 changed files
with
47 additions
and
34 deletions
| @@ -26,7 +26,6 @@ | @@ -26,7 +26,6 @@ | ||
| 26 | const isUpdate = ref(true); | 26 | const isUpdate = ref(true); |
| 27 | let allData: any = reactive({}); | 27 | let allData: any = reactive({}); |
| 28 | const editId = ref(''); | 28 | const editId = ref(''); |
| 29 | - | ||
| 30 | const [registerForm, { validate, setFieldsValue, resetFields }] = useForm({ | 29 | const [registerForm, { validate, setFieldsValue, resetFields }] = useForm({ |
| 31 | labelWidth: 120, | 30 | labelWidth: 120, |
| 32 | schemas: formSchema, | 31 | schemas: formSchema, |
| @@ -172,11 +172,9 @@ | @@ -172,11 +172,9 @@ | ||
| 172 | }; | 172 | }; |
| 173 | }); | 173 | }); |
| 174 | let arr3 = findName.filter((obj: any) => joinArray.some((obj1) => obj1 == obj.id)); | 174 | let arr3 = findName.filter((obj: any) => joinArray.some((obj1) => obj1 == obj.id)); |
| 175 | - let arr4 = arr3 | ||
| 176 | - .map((m: any) => { | ||
| 177 | - return m.username; | ||
| 178 | - }) | ||
| 179 | - .join(); | 175 | + let arr4 = arr3.map((m: any) => { |
| 176 | + return m.username; | ||
| 177 | + }); | ||
| 180 | Modal.info({ | 178 | Modal.info({ |
| 181 | title: '当前告警通知联系人', | 179 | title: '当前告警通知联系人', |
| 182 | width: 600, | 180 | width: 600, |
| @@ -194,11 +192,10 @@ | @@ -194,11 +192,10 @@ | ||
| 194 | }; | 192 | }; |
| 195 | }); | 193 | }); |
| 196 | let arr3 = findName.filter((obj: any) => joinArray.some((obj1) => obj1 == obj.itemValue)); | 194 | let arr3 = findName.filter((obj: any) => joinArray.some((obj1) => obj1 == obj.itemValue)); |
| 197 | - let arr4 = arr3 | ||
| 198 | - .map((m: any) => { | ||
| 199 | - return m.itemText; | ||
| 200 | - }) | ||
| 201 | - .join(); | 195 | + let arr4 = arr3.map((m: any) => { |
| 196 | + return m.itemText; | ||
| 197 | + }); | ||
| 198 | + | ||
| 202 | Modal.info({ | 199 | Modal.info({ |
| 203 | title: '当前告警联系方式', | 200 | title: '当前告警联系方式', |
| 204 | width: 600, | 201 | width: 600, |
| @@ -29,13 +29,14 @@ | @@ -29,13 +29,14 @@ | ||
| 29 | </div> | 29 | </div> |
| 30 | </template> | 30 | </template> |
| 31 | <script lang="ts"> | 31 | <script lang="ts"> |
| 32 | - import { defineComponent, watch, reactive, ref, getCurrentInstance } from 'vue'; | 32 | + import { defineComponent, reactive, ref, getCurrentInstance, onUnmounted } from 'vue'; |
| 33 | import { BasicForm, useForm } from '/@/components/Form'; | 33 | import { BasicForm, useForm } from '/@/components/Form'; |
| 34 | - import { step2Schemas, isChangeType } from './data'; | 34 | + import { step2Schemas } from './data'; |
| 35 | import { Alert, Divider, Descriptions } from 'ant-design-vue'; | 35 | import { Alert, Divider, Descriptions } from 'ant-design-vue'; |
| 36 | import { Button } from '/@/components/Button'; | 36 | import { Button } from '/@/components/Button'; |
| 37 | import MqttCpns from '../step/cpns/mqtt/Mqtt.vue'; | 37 | import MqttCpns from '../step/cpns/mqtt/Mqtt.vue'; |
| 38 | import CoapCpns from '../step/cpns/coap/Coap.vue'; | 38 | import CoapCpns from '../step/cpns/coap/Coap.vue'; |
| 39 | + import { nextTick } from 'process'; | ||
| 39 | 40 | ||
| 40 | export default defineComponent({ | 41 | export default defineComponent({ |
| 41 | components: { | 42 | components: { |
| @@ -57,7 +58,7 @@ | @@ -57,7 +58,7 @@ | ||
| 57 | let step2Data = reactive({ | 58 | let step2Data = reactive({ |
| 58 | transportConfiguration: {}, | 59 | transportConfiguration: {}, |
| 59 | }); | 60 | }); |
| 60 | - const [register, { validate, resetFields, setFieldsValue }] = useForm({ | 61 | + const [register, { validate, resetFields, setFieldsValue, updateSchema }] = useForm({ |
| 61 | labelWidth: 80, | 62 | labelWidth: 80, |
| 62 | schemas: step2Schemas, | 63 | schemas: step2Schemas, |
| 63 | actionColOptions: { | 64 | actionColOptions: { |
| @@ -74,15 +75,33 @@ | @@ -74,15 +75,33 @@ | ||
| 74 | proxy.$refs.coapRef?.setStepFieldsValueFunc(v?.profileData?.transportConfiguration); | 75 | proxy.$refs.coapRef?.setStepFieldsValueFunc(v?.profileData?.transportConfiguration); |
| 75 | }, 100); | 76 | }, 100); |
| 76 | }; | 77 | }; |
| 78 | + | ||
| 77 | const customClearStepTwoValueFunc = () => { | 79 | const customClearStepTwoValueFunc = () => { |
| 78 | - isMqttType.value = 'other'; | 80 | + isMqttType.value = ''; |
| 79 | resetFields(); | 81 | resetFields(); |
| 80 | }; | 82 | }; |
| 81 | async function customResetFunc() { | 83 | async function customResetFunc() { |
| 82 | emit('prev'); | 84 | emit('prev'); |
| 83 | } | 85 | } |
| 84 | - watch(isChangeType, (v) => { | ||
| 85 | - isMqttType.value = v; | 86 | + nextTick(() => { |
| 87 | + updateSchema({ | ||
| 88 | + field: 'transportType', | ||
| 89 | + componentProps() { | ||
| 90 | + return { | ||
| 91 | + options: [ | ||
| 92 | + { label: '默认', value: 'DEFAULT' }, | ||
| 93 | + { label: 'MQTT', value: 'MQTT' }, | ||
| 94 | + { label: 'CoAP', value: 'COAP' }, | ||
| 95 | + ], | ||
| 96 | + onChange(e) { | ||
| 97 | + isMqttType.value = e; | ||
| 98 | + }, | ||
| 99 | + }; | ||
| 100 | + }, | ||
| 101 | + }); | ||
| 102 | + }); | ||
| 103 | + onUnmounted(() => { | ||
| 104 | + isMqttType.value = ''; | ||
| 86 | }); | 105 | }); |
| 87 | const getStep2DataFunc = async () => { | 106 | const getStep2DataFunc = async () => { |
| 88 | const val = await validate(); | 107 | const val = await validate(); |
| 1 | import { FormSchema } from '/@/components/Form'; | 1 | import { FormSchema } from '/@/components/Form'; |
| 2 | import { deviceConfigGetRuleChain } from '/@/api/device/deviceConfigApi'; | 2 | import { deviceConfigGetRuleChain } from '/@/api/device/deviceConfigApi'; |
| 3 | import { findDictItemByCode } from '/@/api/system/dict'; | 3 | import { findDictItemByCode } from '/@/api/system/dict'; |
| 4 | -import { ref } from 'vue'; | ||
| 5 | 4 | ||
| 6 | export const step1Schemas: FormSchema[] = [ | 5 | export const step1Schemas: FormSchema[] = [ |
| 7 | { | 6 | { |
| @@ -66,22 +65,21 @@ export const step1Schemas: FormSchema[] = [ | @@ -66,22 +65,21 @@ export const step1Schemas: FormSchema[] = [ | ||
| 66 | }, | 65 | }, |
| 67 | ]; | 66 | ]; |
| 68 | 67 | ||
| 69 | -export const isChangeType = ref(''); | ||
| 70 | export const step2Schemas: FormSchema[] = [ | 68 | export const step2Schemas: FormSchema[] = [ |
| 71 | { | 69 | { |
| 72 | field: 'transportType', | 70 | field: 'transportType', |
| 73 | component: 'Select', | 71 | component: 'Select', |
| 74 | label: '传输方式', | 72 | label: '传输方式', |
| 75 | defaultValue: 'DEFAULT', | 73 | defaultValue: 'DEFAULT', |
| 76 | - componentProps: { | ||
| 77 | - options: [ | ||
| 78 | - { label: '默认', value: 'DEFAULT' }, | ||
| 79 | - { label: 'MQTT', value: 'MQTT' }, | ||
| 80 | - { label: 'CoAP', value: 'COAP' }, | ||
| 81 | - ], | ||
| 82 | - onChange(e) { | ||
| 83 | - isChangeType.value = e; | ||
| 84 | - }, | 74 | + componentProps() { |
| 75 | + return { | ||
| 76 | + options: [ | ||
| 77 | + { label: '默认', value: 'DEFAULT' }, | ||
| 78 | + { label: 'MQTT', value: 'MQTT' }, | ||
| 79 | + { label: 'CoAP', value: 'COAP' }, | ||
| 80 | + ], | ||
| 81 | + onChange(e) {}, | ||
| 82 | + }; | ||
| 85 | }, | 83 | }, |
| 86 | colProps: { span: 11 }, | 84 | colProps: { span: 11 }, |
| 87 | }, | 85 | }, |
| @@ -46,7 +46,7 @@ export const columns: BasicColumn[] = [ | @@ -46,7 +46,7 @@ export const columns: BasicColumn[] = [ | ||
| 46 | width: 200, | 46 | width: 200, |
| 47 | customRender: ({ record }) => { | 47 | customRender: ({ record }) => { |
| 48 | const status = record.status; | 48 | const status = record.status; |
| 49 | - const enable = status === 0 ? '已发布' : status === 1 ? '草稿' : '其他'; | 49 | + const enable = status === 1 ? '已发布' : status === 0 ? '草稿' : '其他'; |
| 50 | const color = enable === '已发布' ? 'green' : enable === '草稿' ? 'yellow' : 'red'; | 50 | const color = enable === '已发布' ? 'green' : enable === '草稿' ? 'yellow' : 'red'; |
| 51 | const text = enable === '已发布' ? '已发布' : enable === '草稿' ? '草稿' : '其他'; | 51 | const text = enable === '已发布' ? '已发布' : enable === '草稿' ? '草稿' : '其他'; |
| 52 | return h(Tag, { color }, () => text); | 52 | return h(Tag, { color }, () => text); |
| @@ -22,7 +22,6 @@ | @@ -22,7 +22,6 @@ | ||
| 22 | label: '编辑', | 22 | label: '编辑', |
| 23 | icon: 'clarity:note-edit-line', | 23 | icon: 'clarity:note-edit-line', |
| 24 | onClick: handleEdit.bind(null, record), | 24 | onClick: handleEdit.bind(null, record), |
| 25 | - // auth: 'isTenant' || 'isCustomer', | ||
| 26 | ifShow: (_action) => { | 25 | ifShow: (_action) => { |
| 27 | return record.status === 0 && record.creator == userId; | 26 | return record.status === 0 && record.creator == userId; |
| 28 | }, | 27 | }, |
| @@ -31,7 +30,7 @@ | @@ -31,7 +30,7 @@ | ||
| 31 | label: '删除', | 30 | label: '删除', |
| 32 | icon: 'ant-design:delete-outlined', | 31 | icon: 'ant-design:delete-outlined', |
| 33 | color: 'error', | 32 | color: 'error', |
| 34 | - ifShow: record.creator == userId || record.tenantId == tenantId, | 33 | + ifShow: record.creator == userId, |
| 35 | popConfirm: { | 34 | popConfirm: { |
| 36 | title: '是否确认删除', | 35 | title: '是否确认删除', |
| 37 | confirm: handleDeleteOrBatchDelete.bind(null, record), | 36 | confirm: handleDeleteOrBatchDelete.bind(null, record), |
| @@ -35,7 +35,7 @@ | @@ -35,7 +35,7 @@ | ||
| 35 | const { proxy } = getCurrentInstance() as any; | 35 | const { proxy } = getCurrentInstance() as any; |
| 36 | const getChildData = ref(null); | 36 | const getChildData = ref(null); |
| 37 | const editGetId: any = ref(''); | 37 | const editGetId: any = ref(''); |
| 38 | - const [registerForm, { getFieldsValue, resetFields, setFieldsValue }] = useForm({ | 38 | + const [registerForm, { validate, resetFields, setFieldsValue }] = useForm({ |
| 39 | schemas: formSchema, | 39 | schemas: formSchema, |
| 40 | showActionButtonGroup: false, | 40 | showActionButtonGroup: false, |
| 41 | }); | 41 | }); |
| @@ -60,8 +60,9 @@ | @@ -60,8 +60,9 @@ | ||
| 60 | }); | 60 | }); |
| 61 | const getTitle = computed(() => (!unref(isUpdate) ? '新增租户配置' : '编辑租户配置')); | 61 | const getTitle = computed(() => (!unref(isUpdate) ? '新增租户配置' : '编辑租户配置')); |
| 62 | 62 | ||
| 63 | - const getAllFieldsFunc = () => { | ||
| 64 | - getValuesFormData = getFieldsValue(); | 63 | + const getAllFieldsFunc = async () => { |
| 64 | + getValuesFormData = await validate(); | ||
| 65 | + if (!getValuesFormData) return; | ||
| 65 | let getChildValues = proxy.$refs.getChildData.getAllFields(); | 66 | let getChildValues = proxy.$refs.getChildData.getAllFields(); |
| 66 | let profileData1 = { | 67 | let profileData1 = { |
| 67 | configuration: getChildValues, | 68 | configuration: getChildValues, |