Commit 9580973a97edb89344987cf0356d55b30e615525
Merge branch 'ft-dev' into 'main'
feat:新增租户配置的创建时间字段,fix:修复消息配置编辑控制台警告问题 See merge request huang/yun-teng-iot-front!95
Showing
9 changed files
with
140 additions
and
75 deletions
1 | 1 | // 时间戳转时间 |
2 | -export const transformTime = (timestamp = +new Date()) => { | |
3 | - if (timestamp) { | |
4 | - const time = new Date(timestamp); | |
5 | - const y = time.getFullYear(); //getFullYear方法以四位数字返回年份 | |
6 | - const M = time.getMonth() + 1; // getMonth方法从 Date 对象返回月份 (0 ~ 11),返回结果需要手动加一 | |
7 | - const d = time.getDate(); // getDate方法从 Date 对象返回一个月中的某一天 (1 ~ 31) | |
8 | - // const h = time.getHours(); // getHours方法返回 Date 对象的小时 (0 ~ 23) | |
9 | - // const m = time.getMinutes(); // getMinutes方法返回 Date 对象的分钟 (0 ~ 59) | |
10 | - // const s = time.getSeconds(); // getSeconds方法返回 Date 对象的秒数 (0 ~ 59) | |
11 | - // h + ':' + m + ':' + s | |
12 | - return y + '-' + M + '-' + d; | |
13 | - } else { | |
14 | - return ''; | |
15 | - } | |
2 | +export const transformTime = (str) => { | |
3 | + const n = parseInt(str); | |
4 | + const D = new Date(n); | |
5 | + const year = D.getFullYear(); //四位数年份 | |
6 | + let month = D.getMonth() + 1; //月份(0-11),0为一月份 | |
7 | + month = month < 10 ? '0' + month : month; | |
8 | + let day = D.getDate(); //月的某一天(1-31) | |
9 | + day = day < 10 ? '0' + day : day; | |
10 | + let hours = D.getHours(); //小时(0-23) | |
11 | + hours = hours < 10 ? '0' + hours : hours; | |
12 | + let minutes = D.getMinutes(); //分钟(0-59) | |
13 | + minutes = minutes < 10 ? '0' + minutes : minutes; | |
14 | + const now_time = year + '-' + month + '-' + day + ' ' + hours + ':' + minutes; | |
15 | + return now_time; | |
16 | 16 | }; | ... | ... |
... | ... | @@ -36,12 +36,33 @@ |
36 | 36 | setDrawerProps({ confirmLoading: false }); |
37 | 37 | isUpdate.value = !!data?.isUpdate; |
38 | 38 | if (unref(isUpdate)) { |
39 | - const config = data.record.config; | |
40 | - for (const key in config) { | |
41 | - Reflect.set(data.record, key + '', config[key]); | |
42 | - } | |
39 | + console.log(data); | |
40 | + // const config = data.record.config; | |
41 | + // for (const key in config) { | |
42 | + // Reflect.set(data.record, key + '', config[key]); | |
43 | + // } | |
44 | + // await setFieldsValue({ | |
45 | + // ...data.record, | |
46 | + // }); | |
43 | 47 | await setFieldsValue({ |
44 | - ...data.record, | |
48 | + accessKeyId: data.record.config.accessKeyId, | |
49 | + accessKeySecret: data.record.config.accessKeySecret, | |
50 | + platformTypeDictText: data.record.platformTypeDictText, | |
51 | + messageTypeDictText: data.record.messageTypeDictText, | |
52 | + messageType: data.record.messageType, | |
53 | + platformType: data.record.platformType, | |
54 | + configName: data.record.configName, | |
55 | + createTime: data.record.createTime, | |
56 | + creator: data.record.creator, | |
57 | + enabled: data.record.enabled, | |
58 | + id: data.record.id, | |
59 | + key: data.record.key, | |
60 | + pendingStatus: data.record.pendingStatus, | |
61 | + remark: data.record.remark, | |
62 | + status: data.record.status, | |
63 | + tenantId: data.record.tenantId, | |
64 | + updateTime: data.record.updateTime, | |
65 | + updater: data.record.updater, | |
45 | 66 | }); |
46 | 67 | } |
47 | 68 | }); | ... | ... |
... | ... | @@ -49,26 +49,12 @@ export const searchFormSchema: FormSchema[] = [ |
49 | 49 | maxLength: 255, |
50 | 50 | placeholder: '请输入用户名', |
51 | 51 | }, |
52 | - dynamicRules: () => { | |
53 | - return [ | |
54 | - { | |
55 | - required: false, | |
56 | - validator: (_, value) => { | |
57 | - if (String(value).length > 255) { | |
58 | - return Promise.reject('字数不超过255个字'); | |
59 | - } | |
60 | - return Promise.resolve(); | |
61 | - }, | |
62 | - }, | |
63 | - ]; | |
64 | - }, | |
65 | 52 | }, |
66 | 53 | { |
67 | 54 | field: 'realName', |
68 | 55 | label: '姓名', |
69 | 56 | component: 'Input', |
70 | 57 | colProps: { span: 8 }, |
71 | - required: true, | |
72 | 58 | componentProps: { |
73 | 59 | maxLength: 255, |
74 | 60 | placeholder: '请输入姓名', | ... | ... |
... | ... | @@ -10,6 +10,7 @@ |
10 | 10 | <BasicForm @register="registerForm"> |
11 | 11 | <template #menu="{ model, field }"> |
12 | 12 | <BasicTree |
13 | + v-if="treeData.length > 0" | |
13 | 14 | ref="tree" |
14 | 15 | v-model:value="model[field]" |
15 | 16 | :treeData="treeData" |
... | ... | @@ -19,6 +20,7 @@ |
19 | 20 | toolbar |
20 | 21 | title="菜单分配" |
21 | 22 | @check="handleCheckClick" |
23 | + :defaultExpandAll="true" | |
22 | 24 | /> |
23 | 25 | </template> |
24 | 26 | </BasicForm> | ... | ... |
... | ... | @@ -4,7 +4,9 @@ import { h } from 'vue'; |
4 | 4 | import { Switch } from 'ant-design-vue'; |
5 | 5 | import { setRoleStatus } from '/@/api/system/system'; |
6 | 6 | import { useMessage } from '/@/hooks/web/useMessage'; |
7 | -import { getAllRoleList } from '/@/api/system/system'; | |
7 | +import { getRoleListByPage } from '/@/api/system/system'; | |
8 | +import { USER_INFO_KEY } from '/@/enums/cacheEnum'; | |
9 | +import { getAuthCache } from '/@/utils/auth'; | |
8 | 10 | |
9 | 11 | export const columns: BasicColumn[] = [ |
10 | 12 | { |
... | ... | @@ -34,9 +36,18 @@ export const columns: BasicColumn[] = [ |
34 | 36 | record.pendingStatus = true; |
35 | 37 | const newStatus = checked ? 1 : 0; |
36 | 38 | const { createMessage } = useMessage(); |
37 | - const data = await getAllRoleList(); | |
38 | - const findById = data.find((f) => f.id == record.id); | |
39 | - if (findById?.id) return createMessage.error(`该租户下面有此用户,无法禁用`); | |
39 | + const data = await getRoleListByPage({ | |
40 | + page: 1, | |
41 | + pageSize: 100, | |
42 | + // roleType: 'CUSTOMER_USER', | |
43 | + }); | |
44 | + const userInfo = (await getAuthCache(USER_INFO_KEY)) as unknown as any; | |
45 | + const findById = data.items.find((f) => { | |
46 | + if (f.id === userInfo.plainRoles[0].roleId) { | |
47 | + return f.id; | |
48 | + } | |
49 | + }); | |
50 | + if (record.id == findById?.id) return createMessage.error(`该租户下面有此客户,无法禁用`); | |
40 | 51 | record.pendingStatus = true; |
41 | 52 | setRoleStatus(record.id, newStatus) |
42 | 53 | .then(() => { |
... | ... | @@ -112,6 +123,49 @@ export const formSchema: FormSchema[] = [ |
112 | 123 | { label: '停用', value: 0 }, |
113 | 124 | ], |
114 | 125 | }, |
126 | + // componentProps({ formModel, formActionType }) { | |
127 | + // const initStatus = formModel.status; | |
128 | + // const { createMessage } = useMessage(); | |
129 | + // let initBoolean = false; | |
130 | + // const { setFieldsValue } = formActionType; | |
131 | + // if (formModel.name !== undefined) { | |
132 | + // initBoolean = true; | |
133 | + // } else if (formModel.name == undefined) { | |
134 | + // initBoolean = false; | |
135 | + // } | |
136 | + // return { | |
137 | + // options: [ | |
138 | + // { label: '启用', value: 1 }, | |
139 | + // { label: '停用', value: 0 }, | |
140 | + // ], | |
141 | + // async onChange(e) { | |
142 | + // // const data = await getAllRoleList(); | |
143 | + // // const findById = data.find((f) => f.id); | |
144 | + // if (!initBoolean) { | |
145 | + // setFieldsValue({ | |
146 | + // status: initStatus, | |
147 | + // }); | |
148 | + // } else { | |
149 | + // if (e == 0 && formModel.name !== undefined) { | |
150 | + // createMessage.error(`该租户下面有此用户,无法停用`); | |
151 | + // setFieldsValue({ | |
152 | + // status: Number(1), | |
153 | + // }); | |
154 | + // } else { | |
155 | + // setFieldsValue({ | |
156 | + // status: initStatus, | |
157 | + // }); | |
158 | + // } | |
159 | + // } | |
160 | + // // if (e == 0) { | |
161 | + // // if (findById?.id) return createMessage.error(`该租户下面有此用户,无法禁用`); | |
162 | + // // setFieldsValue({ | |
163 | + // // status: 1, | |
164 | + // // }); | |
165 | + // // } | |
166 | + // }, | |
167 | + // }; | |
168 | + // }, | |
115 | 169 | }, |
116 | 170 | { |
117 | 171 | label: '备注', | ... | ... |
... | ... | @@ -10,6 +10,7 @@ |
10 | 10 | <BasicForm @register="registerForm"> |
11 | 11 | <template #menu="{ model, field }"> |
12 | 12 | <BasicTree |
13 | + v-if="treeData.length > 0" | |
13 | 14 | v-model:value="model[field]" |
14 | 15 | :treeData="treeData" |
15 | 16 | :replaceFields="{ title: 'menuName' }" |
... | ... | @@ -19,6 +20,7 @@ |
19 | 20 | ref="tree" |
20 | 21 | title="菜单分配" |
21 | 22 | @check="handleCheckClick" |
23 | + :defaultExpandAll="true" | |
22 | 24 | /> |
23 | 25 | </template> |
24 | 26 | </BasicForm> | ... | ... |
... | ... | @@ -35,17 +35,19 @@ |
35 | 35 | const { proxy } = getCurrentInstance(); |
36 | 36 | const getChildData = ref(null); |
37 | 37 | const editGetId: any = ref(''); |
38 | - const [registerForm, { validateFields, getFieldsValue, resetFields, setFieldsValue }] = | |
39 | - useForm({ | |
40 | - schemas: formSchema, | |
41 | - showActionButtonGroup: false, | |
42 | - }); | |
38 | + const [registerForm, { getFieldsValue, resetFields, setFieldsValue }] = useForm({ | |
39 | + schemas: formSchema, | |
40 | + showActionButtonGroup: false, | |
41 | + }); | |
43 | 42 | const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { |
44 | 43 | //清除表单值 |
45 | 44 | proxy.$refs.getChildData.funcResetFields(); |
46 | 45 | await resetFields(); |
47 | 46 | setDrawerProps({ confirmLoading: false }); |
48 | 47 | isUpdate.value = !!data?.isUpdate; |
48 | + if (!unref(isUpdate)) { | |
49 | + editGetId.value = ''; | |
50 | + } | |
49 | 51 | //编辑 |
50 | 52 | if (unref(isUpdate)) { |
51 | 53 | parentSetData.value = { ...data.record.profileData.configuration }; |
... | ... | @@ -58,44 +60,44 @@ |
58 | 60 | }); |
59 | 61 | const getTitle = computed(() => (!unref(isUpdate) ? '新增租户配置' : '编辑租户配置')); |
60 | 62 | |
63 | + const getAllFieldsFunc = () => { | |
64 | + getValuesFormData = getFieldsValue(); | |
65 | + let getChildValues = proxy.$refs.getChildData.getAllFields(); | |
66 | + let profileData1 = { | |
67 | + configuration: getChildValues, | |
68 | + }; | |
69 | + const id: any = { | |
70 | + id: unref(isUpdate) ? editGetId.value : '', | |
71 | + }; | |
72 | + | |
73 | + const createTime = { | |
74 | + createdTime: Date.now(), | |
75 | + }; | |
76 | + | |
77 | + Object.assign( | |
78 | + postAllData, | |
79 | + { | |
80 | + profileData: profileData1, | |
81 | + }, | |
82 | + getValuesFormData, | |
83 | + id, | |
84 | + createTime | |
85 | + ); | |
86 | + if (!unref(isUpdate)) { | |
87 | + delete postAllData.id; | |
88 | + } | |
89 | + }; | |
90 | + | |
61 | 91 | async function handleSubmit() { |
62 | 92 | if (!unref(isUpdate)) { |
63 | - let res = validateFields(); | |
64 | - if (!res) return; | |
65 | - getValuesFormData = getFieldsValue(); | |
66 | - let getChildValues = proxy.$refs.getChildData.getAllFields(); | |
67 | - let profileData1 = { | |
68 | - configuration: getChildValues, | |
69 | - }; | |
70 | - Object.assign( | |
71 | - postAllData, | |
72 | - { | |
73 | - profileData: profileData1, | |
74 | - }, | |
75 | - getValuesFormData | |
76 | - ); | |
93 | + getAllFieldsFunc(); | |
77 | 94 | await saveTenantProfileApi(postAllData); |
78 | 95 | createMessage.success('租户配置新增成功'); |
79 | 96 | closeDrawer(); |
80 | 97 | emit('success'); |
81 | 98 | resetFields(); |
82 | - } | |
83 | - if (unref(isUpdate)) { | |
84 | - let res = validateFields(); | |
85 | - if (!res) return; | |
86 | - getValuesFormData = getFieldsValue(); | |
87 | - getValuesFormData.id = editGetId.value; | |
88 | - let getChildValues = proxy.$refs.getChildData.getAllFields(); | |
89 | - let profileData1 = { | |
90 | - configuration: getChildValues, | |
91 | - }; | |
92 | - Object.assign( | |
93 | - postAllData, | |
94 | - { | |
95 | - profileData: profileData1, | |
96 | - }, | |
97 | - getValuesFormData | |
98 | - ); | |
99 | + } else { | |
100 | + getAllFieldsFunc(); | |
99 | 101 | await saveTenantProfileApi(postAllData); |
100 | 102 | createMessage.success('租户配置编辑成功'); |
101 | 103 | closeDrawer(); | ... | ... |