Commit 54b92f45efae6e0d716d51ec82a3a6d1e1ef0f7c
Merge branch 'f-dev' into 'main'
F dev See merge request huang/yun-teng-iot-front!273
Showing
28 changed files
with
452 additions
and
551 deletions
... | ... | @@ -16,7 +16,7 @@ export { |
16 | 16 | JEasyCron, |
17 | 17 | JEasyCronInner, |
18 | 18 | JEasyCronModal, |
19 | -} from '/@/components/Form/src/jeecg/components/JEasyCron'; | |
19 | +} from '/@/components/Form/src/externalCompns/components/JEasyCron'; | |
20 | 20 | // Jeecg自定义校验 |
21 | -export { JCronValidator } from '/@/components/Form/src/jeecg/components/JEasyCron'; | |
21 | +export { JCronValidator } from '/@/components/Form/src/externalCompns/components/JEasyCron'; | |
22 | 22 | export { BasicForm }; | ... | ... |
... | ... | @@ -29,8 +29,8 @@ import { IconPicker } from '/@/components/Icon'; |
29 | 29 | import { CountdownInput } from '/@/components/CountDown'; |
30 | 30 | import ApiRadioGroup from './components/ApiRadioGroup.vue'; |
31 | 31 | //自定义组件 |
32 | -import JAddInput from './jeecg/components/JAddInput.vue'; | |
33 | -import { JEasyCron } from './jeecg/components/JEasyCron'; | |
32 | +import JAddInput from './externalCompns/components/JAddInput.vue'; | |
33 | +import { JEasyCron } from './externalCompns/components/JEasyCron'; | |
34 | 34 | |
35 | 35 | const componentMap = new Map<ComponentType, Component>(); |
36 | 36 | ... | ... |
src/components/Form/src/externalCompns/components/JAddInput.vue
renamed from
src/components/Form/src/jeecg/components/JAddInput.vue
src/components/Form/src/externalCompns/components/JEasyCron/EasyCronInner.vue
renamed from
src/components/Form/src/jeecg/components/JEasyCron/EasyCronInner.vue
src/components/Form/src/externalCompns/components/JEasyCron/EasyCronInput.vue
renamed from
src/components/Form/src/jeecg/components/JEasyCron/EasyCronInput.vue
src/components/Form/src/externalCompns/components/JEasyCron/EasyCronModal.vue
renamed from
src/components/Form/src/jeecg/components/JEasyCron/EasyCronModal.vue
src/components/Form/src/externalCompns/components/JEasyCron/LICENSE
renamed from
src/components/Form/src/jeecg/components/JEasyCron/LICENSE
src/components/Form/src/externalCompns/components/JEasyCron/easy.cron.data.ts
renamed from
src/components/Form/src/jeecg/components/JEasyCron/easy.cron.data.ts
src/components/Form/src/externalCompns/components/JEasyCron/easy.cron.inner.less
renamed from
src/components/Form/src/jeecg/components/JEasyCron/easy.cron.inner.less
src/components/Form/src/externalCompns/components/JEasyCron/easy.cron.input.less
renamed from
src/components/Form/src/jeecg/components/JEasyCron/easy.cron.input.less
src/components/Form/src/externalCompns/components/JEasyCron/index.ts
renamed from
src/components/Form/src/jeecg/components/JEasyCron/index.ts
src/components/Form/src/externalCompns/components/JEasyCron/tabs/DayUI.vue
renamed from
src/components/Form/src/jeecg/components/JEasyCron/tabs/DayUI.vue
src/components/Form/src/externalCompns/components/JEasyCron/tabs/HourUI.vue
renamed from
src/components/Form/src/jeecg/components/JEasyCron/tabs/HourUI.vue
src/components/Form/src/externalCompns/components/JEasyCron/tabs/MinuteUI.vue
renamed from
src/components/Form/src/jeecg/components/JEasyCron/tabs/MinuteUI.vue
src/components/Form/src/externalCompns/components/JEasyCron/tabs/MonthUI.vue
renamed from
src/components/Form/src/jeecg/components/JEasyCron/tabs/MonthUI.vue
src/components/Form/src/externalCompns/components/JEasyCron/tabs/SecondUI.vue
renamed from
src/components/Form/src/jeecg/components/JEasyCron/tabs/SecondUI.vue
src/components/Form/src/externalCompns/components/JEasyCron/tabs/WeekUI.vue
renamed from
src/components/Form/src/jeecg/components/JEasyCron/tabs/WeekUI.vue
src/components/Form/src/externalCompns/components/JEasyCron/tabs/YearUI.vue
renamed from
src/components/Form/src/jeecg/components/JEasyCron/tabs/YearUI.vue
src/components/Form/src/externalCompns/components/JEasyCron/tabs/useTabMixin.ts
renamed from
src/components/Form/src/jeecg/components/JEasyCron/tabs/useTabMixin.ts
src/components/Form/src/externalCompns/components/JEasyCron/validator.ts
renamed from
src/components/Form/src/jeecg/components/JEasyCron/validator.ts
1 | 1 | <template> |
2 | - <BasicDrawer | |
3 | - v-bind="$attrs" | |
4 | - @register="registerDrawer" | |
5 | - showFooter | |
6 | - :title="getTitle" | |
7 | - width="30%" | |
8 | - @ok="handleSubmit" | |
9 | - > | |
2 | + <BasicDrawer v-bind="$attrs" @register="registerDrawer" showFooter :title="getTitle" width="30%" @ok="handleSubmit"> | |
10 | 3 | <BasicForm @register="registerForm"> |
11 | 4 | <template #devices> |
12 | - <Select | |
13 | - placeholder="请选择设备" | |
14 | - v-model:value="selectDevice" | |
15 | - style="width: 100%" | |
16 | - :options="selectOptions" | |
17 | - @change="handleDeviceChange" | |
18 | - mode="multiple" | |
19 | - labelInValue | |
20 | - allowClear | |
21 | - @deselect="handleDeSelect" | |
22 | - notFoundContent="请选择设备" | |
23 | - /> | |
5 | + <Select placeholder="请选择设备" v-model:value="selectDevice" style="width: 100%" :options="selectOptions" | |
6 | + @change="handleDeviceChange" mode="multiple" labelInValue allowClear notFoundContent="请选择设备" /> | |
24 | 7 | <div style="margin-top: 1.5vh"></div> |
25 | - <DeviceAttrCpns | |
26 | - ref="deviceAttrRef" | |
27 | - @change="handleChange" | |
28 | - :value="deviceList" | |
29 | - :orgId="organizationId || orgId" | |
30 | - :deSelectValue="deSelectValue" | |
31 | - /> | |
8 | + <div v-for="(item, index) in deviceList" :key="index"> | |
9 | + <DeviceAttrCpns ref="deviceAttrRef" @change="handleChange" :value="item" :orgId="organizationId || orgId" /> | |
10 | + </div> | |
32 | 11 | </template> |
33 | 12 | </BasicForm> |
34 | 13 | </BasicDrawer> |
35 | 14 | </template> |
36 | 15 | <script lang="ts" setup> |
37 | - import { ref, computed, unref, reactive, watch } from 'vue'; | |
38 | - import { BasicForm, useForm } from '/@/components/Form'; | |
39 | - import { formSchema, organizationId } from './config.data'; | |
40 | - import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | |
41 | - import { createOrEditReportManage, putReportConfigManage } from '/@/api/report/reportManager'; | |
42 | - import { useMessage } from '/@/hooks/web/useMessage'; | |
43 | - import moment from 'moment'; | |
44 | - import { screenLinkPageByDeptIdGetDevice } from '/@/api/ruleengine/ruleengineApi'; | |
45 | - import { Select } from 'ant-design-vue'; | |
46 | - import DeviceAttrCpns from './cpns/DeviceAttrCpns.vue'; | |
16 | +import { ref, computed, unref, reactive, watch, nextTick, Ref } from 'vue'; | |
17 | +import { BasicForm, useForm } from '/@/components/Form'; | |
18 | +import { formSchema, organizationId } from './config.data'; | |
19 | +import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | |
20 | +import { createOrEditReportManage, putReportConfigManage } from '/@/api/report/reportManager'; | |
21 | +import { useMessage } from '/@/hooks/web/useMessage'; | |
22 | +import moment from 'moment'; | |
23 | +import { screenLinkPageByDeptIdGetDevice } from '/@/api/ruleengine/ruleengineApi'; | |
24 | +import { Select } from 'ant-design-vue'; | |
25 | +import DeviceAttrCpns from './cpns/DeviceAttrCpns.vue'; | |
26 | +import { SelectTypes } from 'ant-design-vue/es/select'; | |
47 | 27 | |
48 | - const emit = defineEmits(['success', 'register']); | |
49 | - const deviceAttrRef: any = ref(null); | |
50 | - const isUpdate = ref(true); | |
51 | - const editId = ref(''); | |
52 | - const orgId = ref(''); | |
53 | - let deviceAttrData: any = ref([]); | |
54 | - const selectOptions: any = ref([]); | |
55 | - const selectDevice = ref([]); | |
56 | - const deviceList = ref([]); | |
57 | - watch(organizationId, async (newValue: string) => { | |
58 | - if (!newValue) return; | |
59 | - //获取设备 | |
28 | +type TDeviceList = { | |
29 | + key?: string, | |
30 | + value?: string, | |
31 | + label?: string, | |
32 | + attribute?: string, | |
33 | + device?: string | |
34 | +} | |
35 | +const emit = defineEmits(['success', 'register']); | |
36 | +const deviceAttrRef: any = ref(null); | |
37 | +const isUpdate = ref(true); | |
38 | +const editId = ref(''); | |
39 | +const orgId = ref(''); | |
40 | +const selectOptions: Ref<SelectTypes['options']> = ref([]); | |
41 | +const selectDevice = ref([]); | |
42 | +const deviceList: Ref<TDeviceList[]> = ref([]); | |
43 | + | |
44 | +watch(organizationId, async (newValue: string) => { | |
45 | + if (!newValue) return; | |
46 | + //获取设备 | |
47 | + const { items } = await screenLinkPageByDeptIdGetDevice({ | |
48 | + organizationId: newValue, | |
49 | + }); | |
50 | + selectOptions.value = items.map((item) => { | |
51 | + if (item.deviceType !== 'GATEWAY') | |
52 | + return { | |
53 | + label: item.name, | |
54 | + value: item.tbDeviceId, | |
55 | + }; | |
56 | + }); | |
57 | +}); | |
58 | +const handleDeviceChange = (e) => { | |
59 | + deviceList.value = e; | |
60 | +}; | |
61 | +const [registerForm, { validate, setFieldsValue, resetFields }] = useForm({ | |
62 | + labelWidth: 120, | |
63 | + schemas: formSchema, | |
64 | + showActionButtonGroup: false, | |
65 | + fieldMapToTime: [['timeZone', ['startTime', 'endTime'], 'YYYY-MM-DD HH:mm:ss']], | |
66 | +}); | |
67 | +const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { | |
68 | + await resetFields(); | |
69 | + setDrawerProps({ confirmLoading: false }); | |
70 | + isUpdate.value = !!data?.isUpdate; | |
71 | + if (unref(isUpdate)) { | |
72 | + //回显基础数据 | |
73 | + editId.value = data.record.id; | |
74 | + await setFieldsValue(data.record); | |
75 | + //回显嵌套数据 | |
76 | + setFieldsValue({ | |
77 | + agg: queryCondition?.agg, | |
78 | + interval: queryCondition?.interval, | |
79 | + }); | |
80 | + //回显设备 | |
81 | + orgId.value = data.record.organizationId; | |
82 | + //获取该组织下的设备--排除网关设备 | |
60 | 83 | const { items } = await screenLinkPageByDeptIdGetDevice({ |
61 | - organizationId: newValue, | |
84 | + organizationId: data.record.organizationId, | |
62 | 85 | }); |
63 | 86 | selectOptions.value = items.map((item) => { |
64 | 87 | if (item.deviceType !== 'GATEWAY') |
... | ... | @@ -67,154 +90,118 @@ |
67 | 90 | value: item.tbDeviceId, |
68 | 91 | }; |
69 | 92 | }); |
93 | + //TODO 模拟的数据 待服务端返回 | |
94 | + const deviceIds: any = [ | |
95 | + { | |
96 | + label: '奥迪网关子设备', | |
97 | + key: '8a4cc9a0-f201-11ec-98ad-a9680487d1e0', | |
98 | + }, | |
99 | + { | |
100 | + label: '宝马默认设备', | |
101 | + key: '8943f0b0-f1f7-11ec-98ad-a9680487d1e0', | |
102 | + }, | |
103 | + { | |
104 | + label: '奔驰默认设备', | |
105 | + key: '6d9043f0-f1f7-11ec-98ad-a9680487d1e0', | |
106 | + }, | |
107 | + { | |
108 | + label: '新增奥迪测试设备', | |
109 | + key: '8f5b4280-f29e-11ec-98ad-a9680487d1e0', | |
110 | + }, | |
111 | + ]; | |
112 | + selectDevice.value = deviceIds; | |
113 | + //回显设备属性 TODO 模拟的数据 待服务端返回 | |
114 | + deviceList.value = [ | |
115 | + { | |
116 | + value: '8a4cc9a0-f201-11ec-98ad-a9680487d1e0', | |
117 | + attribute: 'CO2', | |
118 | + label: '奥迪网关子设备', | |
119 | + }, | |
120 | + { | |
121 | + value: '8943f0b0-f1f7-11ec-98ad-a9680487d1e0', | |
122 | + attribute: 'co', | |
123 | + label: '宝马默认设备', | |
124 | + }, | |
125 | + { | |
126 | + value: '6d9043f0-f1f7-11ec-98ad-a9680487d1e0', | |
127 | + attribute: 'hot', | |
128 | + label: '奔驰默认设备', | |
129 | + }, | |
130 | + { | |
131 | + value: '8f5b4280-f29e-11ec-98ad-a9680487d1e0', | |
132 | + attribute: 'wet', | |
133 | + label: '新增奥迪测试设备', | |
134 | + }, | |
135 | + ]; | |
136 | + nextTick(() => { }); | |
137 | + } else { | |
138 | + editId.value = ''; | |
139 | + orgId.value = ''; | |
140 | + selectDevice.value = []; | |
141 | + selectOptions.value = []; | |
142 | + deviceList.value = []; | |
143 | + } | |
144 | +}); | |
145 | +const getAttrDevice: Ref<TDeviceList[]> = ref([]); | |
146 | +const getTitle = computed(() => (!unref(isUpdate) ? '新增报表配置' : '编辑报表配置')); | |
147 | +const handleChange = (e: any) => { | |
148 | + getAttrDevice.value.push({ | |
149 | + device: e.value, | |
150 | + attribute: e.attribute | |
70 | 151 | }); |
71 | - const handleDeviceChange = (e) => { | |
72 | - deviceList.value = e; | |
73 | - }; | |
74 | - const deSelectValue = ref(''); | |
75 | - const handleDeSelect = ({ key }) => { | |
76 | - //取消选中的key | |
77 | - deSelectValue.value = key; | |
78 | - }; | |
79 | - const [registerForm, { validate, setFieldsValue, resetFields }] = useForm({ | |
80 | - labelWidth: 120, | |
81 | - schemas: formSchema, | |
82 | - showActionButtonGroup: false, | |
83 | - fieldMapToTime: [['timeZone', ['startTime', 'endTime'], 'YYYY-MM-DD HH:mm:ss']], | |
84 | - }); | |
85 | - const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { | |
86 | - await resetFields(); | |
87 | - setDrawerProps({ confirmLoading: false }); | |
88 | - isUpdate.value = !!data?.isUpdate; | |
89 | - if (unref(isUpdate)) { | |
90 | - //回显基础数据 | |
91 | - editId.value = data.record.id; | |
92 | - await setFieldsValue(data.record); | |
93 | - //回显嵌套数据 | |
94 | - setFieldsValue({ | |
95 | - agg: queryCondition?.agg, | |
96 | - interval: queryCondition?.interval, | |
97 | - }); | |
98 | - //回显设备 | |
99 | - orgId.value = data.record.organizationId; | |
100 | - //获取该组织下的设备--排除网关设备 | |
101 | - const { items } = await screenLinkPageByDeptIdGetDevice({ | |
102 | - organizationId: data.record.organizationId, | |
103 | - }); | |
104 | - selectOptions.value = items.map((item) => { | |
105 | - if (item.deviceType !== 'GATEWAY') | |
106 | - return { | |
107 | - label: item.name, | |
108 | - value: item.tbDeviceId, | |
109 | - }; | |
110 | - }); | |
111 | - //TODO 模拟的数据 待服务端返回 | |
112 | - const deviceIds: any = [ | |
113 | - { | |
114 | - label: '奥迪网关子设备', | |
115 | - key: '8a4cc9a0-f201-11ec-98ad-a9680487d1e0', | |
116 | - }, | |
117 | - { | |
118 | - label: '宝马默认设备', | |
119 | - key: '8943f0b0-f1f7-11ec-98ad-a9680487d1e0', | |
120 | - }, | |
121 | - { | |
122 | - label: '奔驰默认设备', | |
123 | - key: '6d9043f0-f1f7-11ec-98ad-a9680487d1e0', | |
124 | - }, | |
125 | - { | |
126 | - label: '新增奥迪测试设备', | |
127 | - key: '8f5b4280-f29e-11ec-98ad-a9680487d1e0', | |
128 | - }, | |
129 | - ]; | |
130 | - selectDevice.value = deviceIds; | |
131 | - //回显设备属性 TODO 模拟的数据 待服务端返回 | |
132 | - deviceAttrData.value = [ | |
133 | - { | |
134 | - device: '8943f0b0-f1f7-11ec-98ad-a9680487d1e0', | |
135 | - attribute: 'CO2', | |
136 | - name: '宝马默认设备', | |
137 | - }, | |
138 | - { | |
139 | - device: '8f5b4280-f29e-11ec-98ad-a9680487d1e0', | |
140 | - attribute: 'co', | |
141 | - name: '新增奥迪测试设备', | |
142 | - }, | |
143 | - { | |
144 | - device: '54e199d0-f1f7-11ec-98ad-a9680487d1e0', | |
145 | - attribute: 'hot', | |
146 | - name: '奥迪默认设备', | |
147 | - }, | |
148 | - { | |
149 | - device: '6d9043f0-f1f7-11ec-98ad-a9680487d1e0', | |
150 | - attribute: 'wet', | |
151 | - name: '奔驰默认设备', | |
152 | - }, | |
153 | - ]; | |
154 | - deviceAttrRef.value?.echoDynamicInputFunc(deviceAttrData.value); | |
152 | +}; | |
153 | +let postObj: any = reactive({}); | |
154 | +let queryCondition: any = reactive({}); | |
155 | +let executeContent: any = reactive({}); | |
156 | +const endTs = ref(0); | |
157 | +async function handleSubmit() { | |
158 | + setDrawerProps({ confirmLoading: true }); | |
159 | + try { | |
160 | + const { createMessage } = useMessage(); | |
161 | + const values = await validate(); | |
162 | + if (!values) return; | |
163 | + if (getAttrDevice.value.length === 0) { | |
164 | + return createMessage.error('请选择设备及其属性'); | |
165 | + } | |
166 | + if (values.executeWay == 0) { | |
167 | + executeContent = null; | |
155 | 168 | } else { |
156 | - editId.value = ''; | |
157 | - orgId.value = ''; | |
158 | - selectDevice.value = []; | |
159 | - selectOptions.value = []; | |
160 | - deviceList.value = []; | |
169 | + executeContent = {}; | |
161 | 170 | } |
162 | - }); | |
163 | - const getAttrDevice: any = ref([]); | |
164 | - const getTitle = computed(() => (!unref(isUpdate) ? '新增报表配置' : '编辑报表配置')); | |
165 | - const handleChange = (e) => (getAttrDevice.value = e); | |
166 | - let postObj: any = reactive({}); | |
167 | - let queryCondition: any = reactive({}); | |
168 | - let executeContent: any = reactive({}); | |
169 | - const endTs: any = ref(0); | |
170 | - async function handleSubmit() { | |
171 | - setDrawerProps({ confirmLoading: true }); | |
172 | - try { | |
173 | - const { createMessage } = useMessage(); | |
174 | - const values = await validate(); | |
175 | - if (!values) return; | |
176 | - if (getAttrDevice.value.length === 0) { | |
177 | - return createMessage.error('请选择设备及其属性'); | |
178 | - } | |
179 | - if (values.executeWay == 0) { | |
180 | - executeContent = null; | |
181 | - } else { | |
182 | - executeContent = {}; | |
183 | - } | |
184 | - if (values.timeZone) { | |
185 | - const getTime = JSON.stringify(values.timeZone); | |
186 | - endTs.value = moment(JSON.parse(getTime)[0]).valueOf() || 1659424160000; | |
187 | - } | |
188 | - queryCondition = { | |
189 | - agg: values.agg, | |
190 | - interval: values.interval, | |
191 | - limit: values.limit, | |
192 | - }; | |
193 | - delete values.devices; | |
194 | - delete values.agg; | |
195 | - delete values.interval; | |
196 | - delete values.timeZone; | |
197 | - postObj = { | |
198 | - ...values, | |
199 | - ...{ executeAttributes: getAttrDevice.value }, | |
200 | - ...{ queryCondition }, | |
201 | - ...{ endTs: endTs.value }, | |
202 | - ...{ executeContent }, | |
203 | - ...{ id: editId.value !== '' ? editId.value : '' }, | |
204 | - }; | |
205 | - let saveMessage = '添加成功'; | |
206 | - let updateMessage = '修改成功'; | |
207 | - editId.value !== '' | |
208 | - ? await putReportConfigManage(postObj) | |
209 | - : await createOrEditReportManage(postObj); | |
210 | - | |
211 | - closeDrawer(); | |
212 | - emit('success'); | |
213 | - createMessage.success(unref(isUpdate) ? updateMessage : saveMessage); | |
214 | - } finally { | |
215 | - setTimeout(() => { | |
216 | - setDrawerProps({ confirmLoading: false }); | |
217 | - }, 300); | |
171 | + if (values.timeZone) { | |
172 | + const getTime = JSON.stringify(values.timeZone); | |
173 | + endTs.value = moment(JSON.parse(getTime)[0]).valueOf() || 1659424160000; | |
218 | 174 | } |
175 | + queryCondition = { | |
176 | + agg: values.agg, | |
177 | + interval: values.interval, | |
178 | + limit: values.limit, | |
179 | + }; | |
180 | + delete values.devices; | |
181 | + delete values.agg; | |
182 | + delete values.interval; | |
183 | + delete values.timeZone; | |
184 | + postObj = { | |
185 | + ...values, | |
186 | + ...{ executeAttributes: getAttrDevice.value }, | |
187 | + ...{ queryCondition }, | |
188 | + ...{ endTs: endTs.value }, | |
189 | + ...{ executeContent }, | |
190 | + ...{ id: editId.value !== '' ? editId.value : '' }, | |
191 | + }; | |
192 | + let saveMessage = '添加成功'; | |
193 | + let updateMessage = '修改成功'; | |
194 | + editId.value !== '' | |
195 | + ? await putReportConfigManage(postObj) | |
196 | + : await createOrEditReportManage(postObj); | |
197 | + | |
198 | + closeDrawer(); | |
199 | + emit('success'); | |
200 | + createMessage.success(unref(isUpdate) ? updateMessage : saveMessage); | |
201 | + } finally { | |
202 | + setTimeout(() => { | |
203 | + setDrawerProps({ confirmLoading: false }); | |
204 | + }, 300); | |
219 | 205 | } |
206 | +} | |
220 | 207 | </script> | ... | ... |
... | ... | @@ -5,17 +5,19 @@ import moment from 'moment'; |
5 | 5 | import { getOrganizationList } from '/@/api/system/system'; |
6 | 6 | import { copyTransFun } from '/@/utils/fnUtils'; |
7 | 7 | import { findDictItemByCode } from '/@/api/system/dict'; |
8 | -import { | |
9 | - optionsConfig, | |
10 | - isTiming, | |
11 | - isWeek, | |
12 | - isMonth, | |
13 | - isEmpty, | |
14 | - isDefultWeek, | |
15 | - isFixedWeek, | |
16 | -} from './timeConfig'; | |
8 | +import { isTiming, isWeek, isMonth } from './timeConfig'; | |
17 | 9 | import { AggregateDataEnum } from '../../device/localtion/cpns/TimePeriodForm/config'; |
10 | +import { Moment } from 'moment'; | |
11 | +import { | |
12 | + getPacketIntervalByRange, | |
13 | + getPacketIntervalByValue, | |
14 | + intervalOption, | |
15 | +} from '../../device/localtion/cpns/TimePeriodForm/helper'; | |
18 | 16 | |
17 | +export enum QueryWay { | |
18 | + LATEST = 'latest', | |
19 | + TIME_PERIOD = 'timePeriod', | |
20 | +} | |
19 | 21 | export enum SchemaFiled { |
20 | 22 | WAY = 'way', |
21 | 23 | TIME_PERIOD = 'timePeriod', |
... | ... | @@ -360,10 +362,11 @@ export const formSchema: QFormSchema[] = [ |
360 | 362 | { |
361 | 363 | field: SchemaFiled.AGG, |
362 | 364 | label: '聚合条件', |
363 | - required: true, | |
364 | 365 | component: 'Select', |
366 | + required: true, | |
365 | 367 | componentProps: { |
366 | 368 | placeholder: '请选择聚合条件', |
369 | + getPopupContainer: () => document.body, | |
367 | 370 | options: [ |
368 | 371 | { label: '最小值', value: AggregateDataEnum.MIN }, |
369 | 372 | { label: '最大值', value: AggregateDataEnum.MAX }, |
... | ... | @@ -373,205 +376,130 @@ export const formSchema: QFormSchema[] = [ |
373 | 376 | { label: '空', value: AggregateDataEnum.NONE }, |
374 | 377 | ], |
375 | 378 | }, |
376 | - colProps: { span: 24 }, | |
377 | 379 | }, |
378 | 380 | { |
379 | 381 | field: SchemaFiled.LIMIT, |
380 | - component: 'InputNumber', | |
381 | 382 | label: '最大值', |
383 | + component: 'InputNumber', | |
382 | 384 | required: true, |
383 | - defaultValue: 200, | |
384 | - colProps: { span: 22 }, | |
385 | - componentProps: { | |
386 | - min: 7, | |
387 | - max: 50000, | |
385 | + ifShow({ values }) { | |
386 | + return values[SchemaFiled.AGG] === AggregateDataEnum.NONE; | |
387 | + }, | |
388 | + // defaultValue: 200, | |
389 | + componentProps() { | |
390 | + return { | |
391 | + max: 50000, | |
392 | + min: 7, | |
393 | + }; | |
388 | 394 | }, |
389 | - ifShow: ({ values }) => isEmpty(values.agg), | |
390 | 395 | }, |
391 | 396 | { |
392 | - field: 'defaultWeek', | |
393 | - component: 'ApiRadioGroup', | |
397 | + field: SchemaFiled.WAY, | |
394 | 398 | label: '查询周期', |
399 | + component: 'RadioGroup', | |
400 | + defaultValue: QueryWay.LATEST, | |
395 | 401 | required: true, |
396 | - colProps: { | |
397 | - span: 24, | |
398 | - }, | |
399 | - defaultValue: '2', | |
400 | - componentProps: { | |
401 | - placeholder: '请选择查询周期', | |
402 | - options: [ | |
403 | - { | |
404 | - label: '自定义周期', | |
405 | - value: 'defaultIsWeek', | |
406 | - }, | |
407 | - { | |
408 | - label: '固定周期', | |
409 | - value: '2', | |
402 | + componentProps({ formActionType }) { | |
403 | + const { setFieldsValue } = formActionType; | |
404 | + return { | |
405 | + placeholder: '请选择查询周期', | |
406 | + options: [ | |
407 | + { label: '固定周期', value: QueryWay.LATEST }, | |
408 | + { label: '自定义周期', value: QueryWay.TIME_PERIOD }, | |
409 | + ], | |
410 | + onChange(value) { | |
411 | + value === QueryWay.LATEST | |
412 | + ? setFieldsValue({ | |
413 | + [SchemaFiled.DATE_RANGE]: [], | |
414 | + [SchemaFiled.START_TS]: null, | |
415 | + [SchemaFiled.END_TS]: null, | |
416 | + }) | |
417 | + : setFieldsValue({ [SchemaFiled.START_TS]: null }); | |
410 | 418 | }, |
411 | - ], | |
419 | + }; | |
412 | 420 | }, |
413 | 421 | }, |
414 | 422 | { |
415 | - field: 'timeZone', | |
423 | + field: SchemaFiled.DATE_RANGE, | |
416 | 424 | label: '时间段', |
417 | 425 | component: 'RangePicker', |
418 | - componentProps: { | |
419 | - format: 'YYYY-MM-DD HH:mm:ss', | |
420 | - placeholder: ['开始时间', '结束时间'], | |
421 | - showTime: { format: 'HH:mm:ss' }, | |
426 | + required: true, | |
427 | + ifShow({ values }) { | |
428 | + return values[SchemaFiled.WAY] === QueryWay.TIME_PERIOD; | |
429 | + }, | |
430 | + componentProps({ formActionType }) { | |
431 | + const { setFieldsValue } = formActionType; | |
432 | + let dates: Moment[] = []; | |
433 | + return { | |
434 | + placeholder: '请选择时间段', | |
435 | + showTime: true, | |
436 | + onCalendarChange(value: Moment[]) { | |
437 | + dates = value; | |
438 | + }, | |
439 | + disabledDate(current: Moment) { | |
440 | + if (!dates || dates.length === 0 || !current) { | |
441 | + return false; | |
442 | + } | |
443 | + const diffDate = current.diff(dates[0], 'years', true); | |
444 | + return Math.abs(diffDate) > 1; | |
445 | + }, | |
446 | + onChange() { | |
447 | + dates = []; | |
448 | + setFieldsValue({ [SchemaFiled.INTERVAL]: null }); | |
449 | + }, | |
450 | + }; | |
451 | + }, | |
452 | + colProps: { | |
453 | + span: 10, | |
422 | 454 | }, |
423 | - colProps: { span: 24 }, | |
424 | - ifShow: ({ values }) => isDefultWeek(values.defaultWeek), | |
425 | 455 | }, |
426 | 456 | { |
427 | - field: 'startTs', | |
457 | + field: SchemaFiled.START_TS, | |
428 | 458 | label: '时间周期', |
459 | + component: 'Select', | |
460 | + // defaultValue: 1000, | |
429 | 461 | required: true, |
430 | - component: 'ApiSelect', | |
431 | - defaultValue: 1000, | |
432 | - componentProps: ({ formActionType }) => { | |
433 | - const { updateSchema } = formActionType; | |
462 | + ifShow({ values }) { | |
463 | + return ( | |
464 | + values[SchemaFiled.AGG] !== AggregateDataEnum.NONE && | |
465 | + values[SchemaFiled.WAY] == QueryWay.LATEST | |
466 | + ); | |
467 | + }, | |
468 | + componentProps({ formActionType }) { | |
469 | + const { setFieldsValue } = formActionType; | |
434 | 470 | return { |
435 | - api: async () => { | |
436 | - const data: any = await findDictItemByCode({ dictCode: 'query_week' }); | |
437 | - const option = data.map((item) => { | |
438 | - return { | |
439 | - label: item.itemText, | |
440 | - value: Number(item.itemValue), | |
441 | - }; | |
442 | - }); | |
443 | - return option; | |
444 | - }, | |
445 | - async onChange(e) { | |
446 | - if (Number(e) <= 30000) { | |
447 | - //30秒以内 -> 1秒 | |
448 | - updateSchema({ | |
449 | - field: 'interval', | |
450 | - componentProps: { | |
451 | - options: optionsConfig.slice(0, 1), | |
452 | - }, | |
453 | - }); | |
454 | - } else if (Number(e) == 60000) { | |
455 | - //1分钟以内 -> 1秒 5秒 | |
456 | - updateSchema({ | |
457 | - field: 'interval', | |
458 | - componentProps: { | |
459 | - options: optionsConfig.slice(0, 2), | |
460 | - }, | |
461 | - }); | |
462 | - } else if (Number(e) == 120000) { | |
463 | - //2分钟以内 -> 1秒 5秒 10 15 | |
464 | - updateSchema({ | |
465 | - field: 'interval', | |
466 | - componentProps: { | |
467 | - options: optionsConfig.slice(0, 4), | |
468 | - }, | |
469 | - }); | |
470 | - } else if (Number(e) == 300000) { | |
471 | - //5分钟以内 -> 1秒 5秒 10 15 30 | |
472 | - updateSchema({ | |
473 | - field: 'interval', | |
474 | - componentProps: { | |
475 | - options: optionsConfig.slice(0, 5), | |
476 | - }, | |
477 | - }); | |
478 | - } else if (Number(e) == 600000) { | |
479 | - //10分钟以内 -> 5秒 10 15 30 1分钟 | |
480 | - updateSchema({ | |
481 | - field: 'interval', | |
482 | - componentProps: { | |
483 | - options: optionsConfig.slice(1, 2).concat(optionsConfig.slice(2, 6)), | |
484 | - }, | |
485 | - }); | |
486 | - } else if (Number(e) == 900000 || Number(e) == 1800000) { | |
487 | - //15 30 分钟以内 -> 5秒 10 15 30 1分钟 2分钟 | |
488 | - updateSchema({ | |
489 | - field: 'interval', | |
490 | - componentProps: { | |
491 | - options: optionsConfig.slice(1, 2).concat(optionsConfig.slice(2, 7)), | |
492 | - }, | |
493 | - }); | |
494 | - } else if (Number(e) == 3600000) { | |
495 | - //1小时以内 -> 10秒 15 30 1分钟 2分钟 5分钟 | |
496 | - updateSchema({ | |
497 | - field: 'interval', | |
498 | - componentProps: { | |
499 | - options: optionsConfig.slice(2, 8), | |
500 | - }, | |
501 | - }); | |
502 | - } else if (Number(e) == 7200000) { | |
503 | - //2小时以内 -> 15秒 30 1分钟 2分钟 5分钟 10 15 | |
504 | - updateSchema({ | |
505 | - field: 'interval', | |
506 | - componentProps: { | |
507 | - options: optionsConfig.slice(3, 10), | |
508 | - }, | |
509 | - }); | |
510 | - } else if (Number(e) == 18000000) { | |
511 | - //5小时以内 -> 1分钟 2分钟 5分钟 10 15 30 | |
512 | - updateSchema({ | |
513 | - field: 'interval', | |
514 | - componentProps: { | |
515 | - options: optionsConfig.slice(5, 11), | |
516 | - }, | |
517 | - }); | |
518 | - } else if (Number(e) == 36000000 || Number(e) == 43200000) { | |
519 | - //10 12小时以内 -> 2分钟 5分钟 10 15 30 1小时 | |
520 | - updateSchema({ | |
521 | - field: 'interval', | |
522 | - componentProps: { | |
523 | - options: optionsConfig.slice(6, 12), | |
524 | - }, | |
525 | - }); | |
526 | - } else if (Number(e) == 86400000) { | |
527 | - //1天以内 -> 5分钟 10 15 30 1小时 2 | |
528 | - updateSchema({ | |
529 | - field: 'interval', | |
530 | - componentProps: { | |
531 | - options: optionsConfig.slice(7, 13), | |
532 | - }, | |
533 | - }); | |
534 | - } else if (Number(e) == 604800000) { | |
535 | - //7天以内 -> 30分钟 1小时 2 5 10 12 1天 | |
536 | - updateSchema({ | |
537 | - field: 'interval', | |
538 | - componentProps: { | |
539 | - options: optionsConfig.slice(10, 17), | |
540 | - }, | |
541 | - }); | |
542 | - } else if (Number(e) == 2592000000) { | |
543 | - //30天以内 -> 2小时 5 10 12 1天 | |
544 | - updateSchema({ | |
545 | - field: 'interval', | |
546 | - componentProps: { | |
547 | - options: optionsConfig.slice(12, 17), | |
548 | - }, | |
549 | - }); | |
550 | - } | |
471 | + placeholder: '请选择时间周期', | |
472 | + options: intervalOption, | |
473 | + onChange() { | |
474 | + setFieldsValue({ [SchemaFiled.INTERVAL]: null }); | |
551 | 475 | }, |
552 | - maxLength: 250, | |
553 | - placeholder: '请选择查询周期', | |
554 | 476 | }; |
555 | 477 | }, |
556 | - colProps: { span: 24 }, | |
557 | - ifShow: ({ values }) => isFixedWeek(values.defaultWeek) && !isEmpty(values.agg), | |
558 | 478 | }, |
559 | 479 | { |
560 | - field: 'interval', | |
480 | + field: SchemaFiled.INTERVAL, | |
561 | 481 | label: '间隔时间', |
562 | - required: true, | |
563 | 482 | component: 'Select', |
564 | - colProps: { span: 24 }, | |
565 | - defaultValue: 1000, | |
566 | - componentProps: { | |
567 | - placeholder: '请选择间隔时间', | |
568 | - options: [ | |
569 | - { | |
570 | - label: '1秒', | |
571 | - value: 1000, | |
572 | - }, | |
573 | - ], | |
483 | + required: true, | |
484 | + // defaultValue: 1000, | |
485 | + ifShow({ values }) { | |
486 | + return ( | |
487 | + values[SchemaFiled.AGG] !== AggregateDataEnum.NONE && | |
488 | + values[SchemaFiled.WAY] == QueryWay.LATEST | |
489 | + ); | |
490 | + }, | |
491 | + componentProps({ formModel, formActionType }) { | |
492 | + const options = | |
493 | + formModel[SchemaFiled.WAY] === QueryWay.LATEST | |
494 | + ? getPacketIntervalByValue(formModel[SchemaFiled.START_TS]) | |
495 | + : getPacketIntervalByRange(formModel[SchemaFiled.DATE_RANGE]); | |
496 | + if (formModel[SchemaFiled.AGG] !== AggregateDataEnum.NONE) { | |
497 | + formActionType.setFieldsValue({ [SchemaFiled.LIMIT]: null }); | |
498 | + } | |
499 | + return { | |
500 | + placeholder: '请选择间隔时间', | |
501 | + options, | |
502 | + }; | |
574 | 503 | }, |
575 | - ifShow: ({ values }) => isFixedWeek(values.defaultWeek) && !isEmpty(values.agg), | |
576 | 504 | }, |
577 | 505 | ]; | ... | ... |
... | ... | @@ -7,13 +7,13 @@ |
7 | 7 | <a-input |
8 | 8 | :disabled="true" |
9 | 9 | v-model:value="param.device" |
10 | - style="width: 38%; margin-bottom: 5px; margin-left: 1vh" | |
10 | + style="width: 50%; margin-bottom: 5px; margin-left: 0vh" | |
11 | 11 | @change="emitChange" |
12 | 12 | /> |
13 | 13 | <Select |
14 | 14 | placeholder="请选择设备属性" |
15 | 15 | v-model:value="param.attribute" |
16 | - style="width: 160px; margin-left: 1.8vw" | |
16 | + style="width: 50%; margin-left: 1.8vw" | |
17 | 17 | :options="selectOptions" |
18 | 18 | @change="emitChange" |
19 | 19 | allowClear |
... | ... | @@ -38,14 +38,14 @@ |
38 | 38 | device: string; |
39 | 39 | } |
40 | 40 | const props = defineProps({ |
41 | - value: propTypes.array.def([]), | |
41 | + value: propTypes.object.def({}), | |
42 | 42 | orgId: propTypes.string.def(''), |
43 | 43 | }); |
44 | 44 | const emits = defineEmits(['change', 'update:value']); |
45 | 45 | const selectOptions = ref<SelectTypes['options']>([]); |
46 | 46 | //获取属性 |
47 | 47 | const getAttr = async (orgId, deviceId) => { |
48 | - const res = await getAttribute(orgId, deviceId.join(',')); | |
48 | + const res = await getAttribute(orgId, deviceId); | |
49 | 49 | selectOptions.value = res.map((o) => { |
50 | 50 | return { |
51 | 51 | label: o, |
... | ... | @@ -55,25 +55,20 @@ |
55 | 55 | }; |
56 | 56 | //动态数据 |
57 | 57 | const dynamicInput: UnwrapRef<{ params: Params[] }> = reactive({ params: [] }); |
58 | - //监听传入数据value | |
59 | - watchEffect(() => { | |
58 | + const rEffect = watchEffect(() => { | |
60 | 59 | initVal(); |
61 | 60 | }); |
61 | + rEffect(); | |
62 | 62 | /** |
63 | 63 | * 初始化数值 |
64 | 64 | */ |
65 | 65 | async function initVal() { |
66 | - dynamicInput.params = []; | |
67 | - if (props.value && props.orgId) { | |
68 | - let jsonObj = props.value; | |
69 | - const deviceId = jsonObj.map((m: any) => m.value); | |
70 | - await getAttr(props.orgId, deviceId); | |
71 | - jsonObj.forEach((item: any) => { | |
72 | - dynamicInput.params.push({ | |
73 | - attribute: '', | |
74 | - device: item.label, | |
75 | - value: item.value, | |
76 | - }); | |
66 | + if (props.orgId && props.value.value) { | |
67 | + await getAttr(props.orgId, props.value.value); | |
68 | + dynamicInput.params.push({ | |
69 | + device: props.value.label, | |
70 | + value: props.value.value, | |
71 | + attribute: props.value.attribute == '' ? '' : props.value.attribute, | |
77 | 72 | }); |
78 | 73 | } |
79 | 74 | } |
... | ... | @@ -81,32 +76,12 @@ |
81 | 76 | * 数值改变 |
82 | 77 | */ |
83 | 78 | function emitChange() { |
84 | - let obj: any = []; | |
85 | - if (dynamicInput.params.length > 0) { | |
86 | - dynamicInput.params.forEach((item: Params) => { | |
87 | - obj.push({ | |
88 | - attribute: item.attribute, | |
89 | - device: item.value, | |
90 | - }); | |
91 | - }); | |
92 | - } | |
93 | - console.log('emitChange', obj); | |
79 | + let obj: any = dynamicInput.params[0]; | |
94 | 80 | emits('change', obj); |
95 | 81 | emits('update:value', obj); |
96 | 82 | } |
97 | - //回显 | |
98 | - const echoDynamicInputFunc = (o) => { | |
99 | - dynamicInput.params = []; | |
100 | - o.forEach((m: any) => { | |
101 | - dynamicInput.params.push({ | |
102 | - device: m.name, | |
103 | - attribute: m.attribute, | |
104 | - value: m.device, | |
105 | - }); | |
106 | - }); | |
107 | - }; | |
108 | 83 | defineExpose({ |
109 | - echoDynamicInputFunc, | |
84 | + getAttr, | |
110 | 85 | }); |
111 | 86 | </script> |
112 | 87 | <style scoped lang="css"> | ... | ... |
... | ... | @@ -162,7 +162,7 @@ export const modeKafkaForm: FormSchema[] = [ |
162 | 162 | { |
163 | 163 | field: 'keySerializer', |
164 | 164 | label: '键序列化', |
165 | - colProps: { span: 12 }, | |
165 | + colProps: { span: 24 }, | |
166 | 166 | required: true, |
167 | 167 | component: 'Input', |
168 | 168 | defaultValue: 'org.apache.kafka.common.serialization.StringSerializer', |
... | ... | @@ -174,7 +174,7 @@ export const modeKafkaForm: FormSchema[] = [ |
174 | 174 | { |
175 | 175 | field: 'valueSerializer', |
176 | 176 | label: '值序列化', |
177 | - colProps: { span: 12 }, | |
177 | + colProps: { span: 24 }, | |
178 | 178 | required: true, |
179 | 179 | component: 'Input', |
180 | 180 | defaultValue: 'org.apache.kafka.common.serialization.StringSerializer', | ... | ... |
... | ... | @@ -4,13 +4,24 @@ import moment from 'moment'; |
4 | 4 | import { h } from 'vue'; |
5 | 5 | import { Tag } from 'ant-design-vue'; |
6 | 6 | |
7 | +///任务组名Enum | |
8 | +export enum EJobGroup { | |
9 | + DEFAULT = 'DEFAULT', | |
10 | + SYSTEM = 'SYSTEM', | |
11 | + REPORT = 'REPORT', | |
12 | +} | |
13 | + | |
7 | 14 | //任务详细配置 |
8 | 15 | export const personSchema: DescItem[] = [ |
9 | 16 | { |
10 | 17 | field: 'jobGroup', |
11 | 18 | label: '任务分组:', |
12 | 19 | render: (_, data) => { |
13 | - return data.jobGroup == 'Default' ? '默认' : data.jobGroup == 'System' ? '系统' : '报表'; | |
20 | + return data.jobGroup == EJobGroup.DEFAULT | |
21 | + ? '默认' | |
22 | + : data.jobGroup == EJobGroup.SYSTEM | |
23 | + ? '系统' | |
24 | + : '报表'; | |
14 | 25 | }, |
15 | 26 | }, |
16 | 27 | { |
... | ... | @@ -62,9 +73,9 @@ export const columnSchedue: BasicColumn[] = [ |
62 | 73 | dataIndex: 'jobGroup', |
63 | 74 | width: 120, |
64 | 75 | format: (_text: string, record: Recordable) => { |
65 | - return record.jobGroup === 'Default' | |
76 | + return record.jobGroup === EJobGroup.DEFAULT | |
66 | 77 | ? '默认' |
67 | - : record.jobGroup === 'System' | |
78 | + : record.jobGroup === EJobGroup.SYSTEM | |
68 | 79 | ? '系统' |
69 | 80 | : '报表'; |
70 | 81 | }, |
... | ... | @@ -121,15 +132,15 @@ export const searchSchedueFormSchema: FormSchema[] = [ |
121 | 132 | options: [ |
122 | 133 | { |
123 | 134 | label: '默认', |
124 | - value: 'Default', | |
135 | + value: EJobGroup.DEFAULT, | |
125 | 136 | }, |
126 | 137 | { |
127 | 138 | label: '系统', |
128 | - value: 'System', | |
139 | + value: EJobGroup.SYSTEM, | |
129 | 140 | }, |
130 | 141 | { |
131 | 142 | label: '报表', |
132 | - value: 'Report', | |
143 | + value: EJobGroup.REPORT, | |
133 | 144 | }, |
134 | 145 | ], |
135 | 146 | placeholder: '请选择任务组名', |
... | ... | @@ -176,7 +187,11 @@ export const scheduleLogDetailSchema: DescItem[] = [ |
176 | 187 | field: 'jobGroup', |
177 | 188 | label: '任务组名:', |
178 | 189 | render: (_, data) => { |
179 | - return data.jobGroup == 'Default' ? '默认' : data.jobGroup == 'System' ? '系统' : '报表'; | |
190 | + return data.jobGroup == EJobGroup.DEFAULT | |
191 | + ? '默认' | |
192 | + : data.jobGroup == EJobGroup.SYSTEM | |
193 | + ? '系统' | |
194 | + : '报表'; | |
180 | 195 | }, |
181 | 196 | }, |
182 | 197 | { | ... | ... |
1 | 1 | import { BasicColumn, FormSchema } from '/@/components/Table'; |
2 | 2 | import type { FormSchema as QFormSchema } from '/@/components/Form/index'; |
3 | 3 | import { JCronValidator } from '/@/components/Form'; |
4 | +import { EJobGroup } from './config.data'; | |
4 | 5 | |
5 | 6 | // 定时任务表格配置 |
6 | 7 | export const columnSchedue: BasicColumn[] = [ |
... | ... | @@ -14,9 +15,9 @@ export const columnSchedue: BasicColumn[] = [ |
14 | 15 | dataIndex: 'jobGroup', |
15 | 16 | width: 120, |
16 | 17 | format: (_text: string, record: Recordable) => { |
17 | - return record.jobGroup === 'Default' | |
18 | + return record.jobGroup === EJobGroup.DEFAULT | |
18 | 19 | ? '默认' |
19 | - : record.jobGroup === 'System' | |
20 | + : record.jobGroup === EJobGroup.SYSTEM | |
20 | 21 | ? '系统' |
21 | 22 | : '报表'; |
22 | 23 | }, |
... | ... | @@ -60,15 +61,15 @@ export const searchSchedueFormSchema: FormSchema[] = [ |
60 | 61 | options: [ |
61 | 62 | { |
62 | 63 | label: '默认', |
63 | - value: 'Default', | |
64 | + value: EJobGroup.DEFAULT, | |
64 | 65 | }, |
65 | 66 | { |
66 | 67 | label: '系统', |
67 | - value: 'System', | |
68 | + value: EJobGroup.SYSTEM, | |
68 | 69 | }, |
69 | 70 | { |
70 | 71 | label: '报表', |
71 | - value: 'Report', | |
72 | + value: EJobGroup.REPORT, | |
72 | 73 | }, |
73 | 74 | ], |
74 | 75 | placeholder: '请选择任务组名', |
... | ... | @@ -120,15 +121,15 @@ export const formSchema: QFormSchema[] = [ |
120 | 121 | options: [ |
121 | 122 | { |
122 | 123 | label: '默认', |
123 | - value: 'Default', | |
124 | + value: EJobGroup.DEFAULT, | |
124 | 125 | }, |
125 | 126 | { |
126 | 127 | label: '系统', |
127 | - value: 'System', | |
128 | + value: EJobGroup.SYSTEM, | |
128 | 129 | }, |
129 | 130 | { |
130 | 131 | label: '报表', |
131 | - value: 'Report', | |
132 | + value: EJobGroup.REPORT, | |
132 | 133 | }, |
133 | 134 | ], |
134 | 135 | }, | ... | ... |
1 | 1 | <template> |
2 | 2 | <div class="drawer-class"> |
3 | - <BasicDrawer | |
4 | - v-bind="$attrs" | |
5 | - @register="registerDrawer" | |
6 | - showFooter | |
7 | - :title="getTitle" | |
8 | - width="700px" | |
9 | - @ok="handleSubmit" | |
10 | - > | |
3 | + <BasicDrawer v-bind="$attrs" @register="registerDrawer" showFooter :title="getTitle" width="700px" | |
4 | + @ok="handleSubmit"> | |
11 | 5 | <BasicForm @register="registerForm" /> |
12 | 6 | <CpnsTenantSet ref="getChildData" :parentData="parentSetData" /> |
13 | 7 | </BasicDrawer> |
14 | 8 | </div> |
15 | 9 | </template> |
16 | 10 | <script lang="ts"> |
17 | - import { defineComponent, ref, computed, unref, getCurrentInstance, reactive } from 'vue'; | |
18 | - import { BasicForm, useForm } from '/@/components/Form'; | |
19 | - import { formSchema } from './config'; | |
20 | - import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | |
21 | - import CpnsTenantSet from './cpns/index.vue'; | |
22 | - import { saveTenantProfileApi } from '/@/api/tenant/tenantApi'; | |
23 | - import { useMessage } from '/@/hooks/web/useMessage'; | |
11 | +import { defineComponent, ref, computed, unref, getCurrentInstance, reactive } from 'vue'; | |
12 | +import { BasicForm, useForm } from '/@/components/Form'; | |
13 | +import { formSchema } from './config'; | |
14 | +import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | |
15 | +import CpnsTenantSet from './cpns/index.vue'; | |
16 | +import { saveTenantProfileApi } from '/@/api/tenant/tenantApi'; | |
17 | +import { useMessage } from '/@/hooks/web/useMessage'; | |
24 | 18 | |
25 | - export default defineComponent({ | |
26 | - name: 'ConfigDrawer', | |
27 | - components: { BasicDrawer, BasicForm, CpnsTenantSet }, | |
28 | - emits: ['success', 'register'], | |
29 | - setup(_, { emit }) { | |
30 | - const { createMessage } = useMessage(); | |
31 | - const isUpdate = ref(true); | |
32 | - let postAllData: any = reactive({}); | |
33 | - const parentSetData: any = ref(null); | |
34 | - let getValuesFormData: any = reactive({}); | |
35 | - const { proxy } = getCurrentInstance() as any; | |
36 | - const getChildData = ref(null); | |
37 | - const editGetId: any = ref(''); | |
38 | - const [registerForm, { validate, resetFields, setFieldsValue }] = useForm({ | |
39 | - schemas: formSchema, | |
40 | - showActionButtonGroup: false, | |
41 | - }); | |
42 | - const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { | |
43 | - //清除表单值 | |
44 | - proxy.$refs.getChildData.funcResetFields(); | |
45 | - await resetFields(); | |
46 | - setDrawerProps({ confirmLoading: false }); | |
47 | - isUpdate.value = !!data?.isUpdate; | |
48 | - if (!unref(isUpdate)) { | |
49 | - editGetId.value = ''; | |
50 | - } | |
51 | - //编辑 | |
52 | - if (unref(isUpdate)) { | |
53 | - parentSetData.value = { ...data.record.profileData.configuration }; | |
54 | - proxy.$refs.getChildData.setFieldsValueFunc(parentSetData.value); | |
55 | - editGetId.value = data.record.id; | |
56 | - await setFieldsValue({ | |
57 | - ...data.record, | |
58 | - }); | |
59 | - } | |
60 | - }); | |
61 | - const getTitle = computed(() => (!unref(isUpdate) ? '新增租户配置' : '编辑租户配置')); | |
62 | - | |
63 | - const getAllFieldsFunc = async () => { | |
64 | - getValuesFormData = await validate(); | |
65 | - if (!getValuesFormData) return; | |
66 | - let getChildValues = proxy.$refs.getChildData.getAllFields(); | |
67 | - let profileData1 = { | |
68 | - configuration: getChildValues, | |
69 | - }; | |
70 | - const id: any = { | |
71 | - id: unref(isUpdate) ? editGetId.value : '', | |
72 | - }; | |
19 | +export default defineComponent({ | |
20 | + name: 'ConfigDrawer', | |
21 | + components: { BasicDrawer, BasicForm, CpnsTenantSet }, | |
22 | + emits: ['success', 'register'], | |
23 | + setup(_, { emit }) { | |
24 | + const { createMessage } = useMessage(); | |
25 | + const isUpdate = ref(true); | |
26 | + let postAllData: any = reactive({}); | |
27 | + const parentSetData: any = ref(null); | |
28 | + let getValuesFormData: any = reactive({}); | |
29 | + const { proxy } = getCurrentInstance() as any; | |
30 | + const getChildData = ref(null); | |
31 | + const editGetId: any = ref(''); | |
32 | + const [registerForm, { validate, resetFields, setFieldsValue }] = useForm({ | |
33 | + schemas: formSchema, | |
34 | + showActionButtonGroup: false, | |
35 | + }); | |
36 | + const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { | |
37 | + //清除表单值 | |
38 | + proxy.$refs.getChildData.funcResetFields(); | |
39 | + await resetFields(); | |
40 | + setDrawerProps({ confirmLoading: false }); | |
41 | + isUpdate.value = !!data?.isUpdate; | |
42 | + if (!unref(isUpdate)) { | |
43 | + editGetId.value = ''; | |
44 | + } | |
45 | + //编辑 | |
46 | + if (unref(isUpdate)) { | |
47 | + parentSetData.value = { ...data.record.profileData.configuration }; | |
48 | + proxy.$refs.getChildData.setFieldsValueFunc(parentSetData.value); | |
49 | + editGetId.value = data.record.id; | |
50 | + await setFieldsValue({ | |
51 | + ...data.record, | |
52 | + }); | |
53 | + } | |
54 | + }); | |
55 | + const getTitle = computed(() => (!unref(isUpdate) ? '新增租户配置' : '编辑租户配置')); | |
73 | 56 | |
74 | - const createTime = { | |
75 | - createdTime: Date.now(), | |
76 | - }; | |
57 | + const getAllFieldsFunc = async () => { | |
58 | + getValuesFormData = await validate(); | |
59 | + if (!getValuesFormData) return; | |
60 | + let getChildValues = proxy.$refs.getChildData.getAllFields(); | |
61 | + let profileData1 = { | |
62 | + configuration: getChildValues, | |
63 | + }; | |
64 | + const id: any = { | |
65 | + id: unref(isUpdate) ? editGetId.value : '', | |
66 | + }; | |
77 | 67 | |
78 | - Object.assign( | |
79 | - postAllData, | |
80 | - { | |
81 | - profileData: profileData1, | |
82 | - }, | |
83 | - getValuesFormData, | |
84 | - id, | |
85 | - createTime | |
86 | - ); | |
87 | - if (!unref(isUpdate)) { | |
88 | - delete postAllData.id; | |
89 | - } | |
68 | + const createTime = { | |
69 | + createdTime: Date.now(), | |
90 | 70 | }; |
91 | 71 | |
92 | - async function handleSubmit() { | |
93 | - setDrawerProps({ confirmLoading: true }); | |
94 | - try { | |
95 | - if (!unref(isUpdate)) { | |
96 | - getAllFieldsFunc(); | |
97 | - await saveTenantProfileApi(postAllData); | |
98 | - createMessage.success('租户配置新增成功'); | |
99 | - closeDrawer(); | |
100 | - emit('success'); | |
101 | - resetFields(); | |
102 | - } else { | |
103 | - getAllFieldsFunc(); | |
104 | - await saveTenantProfileApi(postAllData); | |
105 | - createMessage.success('租户配置编辑成功'); | |
106 | - closeDrawer(); | |
107 | - emit('success'); | |
108 | - } | |
109 | - } catch (e) { | |
110 | - } finally { | |
111 | - setTimeout(() => { | |
112 | - setDrawerProps({ confirmLoading: false }); | |
113 | - }, 300); | |
72 | + Object.assign( | |
73 | + postAllData, | |
74 | + { | |
75 | + profileData: profileData1, | |
76 | + }, | |
77 | + getValuesFormData, | |
78 | + id, | |
79 | + createTime | |
80 | + ); | |
81 | + if (!unref(isUpdate)) { | |
82 | + delete postAllData.id; | |
83 | + } | |
84 | + }; | |
85 | + | |
86 | + async function handleSubmit() { | |
87 | + setDrawerProps({ confirmLoading: true }); | |
88 | + try { | |
89 | + if (!unref(isUpdate)) { | |
90 | + await getAllFieldsFunc(); | |
91 | + await saveTenantProfileApi(postAllData); | |
92 | + createMessage.success('租户配置新增成功'); | |
93 | + closeDrawer(); | |
94 | + emit('success'); | |
95 | + resetFields(); | |
96 | + } else { | |
97 | + await getAllFieldsFunc(); | |
98 | + await saveTenantProfileApi(postAllData); | |
99 | + createMessage.success('租户配置编辑成功'); | |
100 | + closeDrawer(); | |
101 | + emit('success'); | |
114 | 102 | } |
103 | + } catch (e) { | |
104 | + } finally { | |
105 | + setTimeout(() => { | |
106 | + setDrawerProps({ confirmLoading: false }); | |
107 | + }, 300); | |
115 | 108 | } |
116 | - return { | |
117 | - parentSetData, | |
118 | - getChildData, | |
119 | - registerDrawer, | |
120 | - registerForm, | |
121 | - getTitle, | |
122 | - handleSubmit, | |
123 | - }; | |
124 | - }, | |
125 | - }); | |
109 | + } | |
110 | + return { | |
111 | + parentSetData, | |
112 | + getChildData, | |
113 | + registerDrawer, | |
114 | + registerForm, | |
115 | + getTitle, | |
116 | + handleSubmit, | |
117 | + }; | |
118 | + }, | |
119 | +}); | |
126 | 120 | </script> |
127 | 121 | |
128 | 122 | <style lang="less"> |
129 | - .drawer-class { | |
130 | - .ant-row { | |
131 | - .ant-col { | |
132 | - :deep .ant-input-number { | |
133 | - width: 34vw !important; | |
134 | - } | |
123 | +.drawer-class { | |
124 | + .ant-row { | |
125 | + .ant-col { | |
126 | + :deep .ant-input-number { | |
127 | + width: 34vw !important; | |
135 | 128 | } |
136 | 129 | } |
137 | 130 | } |
131 | +} | |
138 | 132 | </style> | ... | ... |