Commit 81a1c4fd36f2a9af4f63d1c3cb1aa71c95f56664
Merge branch 'ft_local_dev' into 'main'
fix:修改Teambition上的问题 See merge request huang/yun-teng-iot-front!408
Showing
15 changed files
with
371 additions
and
358 deletions
1 | import { defHttp } from '/@/utils/http/axios'; | 1 | import { defHttp } from '/@/utils/http/axios'; |
2 | import { ScriptParam, ScriptQueryParam, ScriptRecord } from './model/scriptModel'; | 2 | import { ScriptParam, ScriptQueryParam, ScriptRecord } from './model/scriptModel'; |
3 | import { PaginationResult } from '/#/axios'; | 3 | import { PaginationResult } from '/#/axios'; |
4 | +import { IChangeStatus } from '../ruleengine/model/ruleengineModel'; | ||
4 | 5 | ||
5 | enum ScriptManagerApi { | 6 | enum ScriptManagerApi { |
6 | SCRIPT_POST_URL = '/js', | 7 | SCRIPT_POST_URL = '/js', |
@@ -8,6 +9,7 @@ enum ScriptManagerApi { | @@ -8,6 +9,7 @@ enum ScriptManagerApi { | ||
8 | SCRIPT_DELETE_URL = '/js', | 9 | SCRIPT_DELETE_URL = '/js', |
9 | SCRIPT_MELIST_URL = '/js/me/list', | 10 | SCRIPT_MELIST_URL = '/js/me/list', |
10 | SCRIPT_TEST_URL = '/js/test', | 11 | SCRIPT_TEST_URL = '/js/test', |
12 | + SCRIPT_STATUS = '/js', | ||
11 | } | 13 | } |
12 | 14 | ||
13 | export const ScriptPage = (params: ScriptQueryParam) => { | 15 | export const ScriptPage = (params: ScriptQueryParam) => { |
@@ -17,6 +19,16 @@ export const ScriptPage = (params: ScriptQueryParam) => { | @@ -17,6 +19,16 @@ export const ScriptPage = (params: ScriptQueryParam) => { | ||
17 | }); | 19 | }); |
18 | }; | 20 | }; |
19 | 21 | ||
22 | +/** | ||
23 | + * 改变转换函数状态 | ||
24 | + * @param params id status | ||
25 | + */ | ||
26 | +export const scriptPagePutApi = (params: IChangeStatus) => | ||
27 | + defHttp.post({ | ||
28 | + url: ScriptManagerApi.SCRIPT_STATUS, | ||
29 | + data: params, | ||
30 | + }); | ||
31 | + | ||
20 | //删除脚本 | 32 | //删除脚本 |
21 | export const deleteScriptManage = (ids: string[]) => { | 33 | export const deleteScriptManage = (ids: string[]) => { |
22 | return defHttp.delete({ | 34 | return defHttp.delete({ |
@@ -76,7 +76,7 @@ export const chineseAndEnlishRule: Rule[] = [ | @@ -76,7 +76,7 @@ export const chineseAndEnlishRule: Rule[] = [ | ||
76 | required: true, | 76 | required: true, |
77 | validator: (_, value: string) => { | 77 | validator: (_, value: string) => { |
78 | const reg = /^[a-zA-Z\u4e00-\u9fa5]+$/; | 78 | const reg = /^[a-zA-Z\u4e00-\u9fa5]+$/; |
79 | - if (value === '') { | 79 | + if (value === '' || value === undefined) { |
80 | return Promise.reject('请输入'); | 80 | return Promise.reject('请输入'); |
81 | } else if (!reg.test(value)) { | 81 | } else if (!reg.test(value)) { |
82 | return Promise.reject('格式不正确'); | 82 | return Promise.reject('格式不正确'); |
@@ -123,6 +123,7 @@ export const formSchema: FormSchema[] = [ | @@ -123,6 +123,7 @@ export const formSchema: FormSchema[] = [ | ||
123 | field: 'messageMode', | 123 | field: 'messageMode', |
124 | label: '告警通知方式', | 124 | label: '告警通知方式', |
125 | component: 'ApiSelect', | 125 | component: 'ApiSelect', |
126 | + helpMessage: ['通知方式,需在消息管理配置对应告警消息模板,否则不能成功通知告警联系人'], | ||
126 | required: true, | 127 | required: true, |
127 | componentProps: { | 128 | componentProps: { |
128 | mode: 'multiple', | 129 | mode: 'multiple', |
@@ -96,7 +96,6 @@ export const formSchema: FormSchema[] = [ | @@ -96,7 +96,6 @@ export const formSchema: FormSchema[] = [ | ||
96 | colProps: { span: 24 }, | 96 | colProps: { span: 24 }, |
97 | label: '通知内容', | 97 | label: '通知内容', |
98 | required: true, | 98 | required: true, |
99 | - defaultValue: '', | ||
100 | render: ({ model, field }) => { | 99 | render: ({ model, field }) => { |
101 | return h(Tinymce, { | 100 | return h(Tinymce, { |
102 | value: model[field], | 101 | value: model[field], |
@@ -12,6 +12,13 @@ import { findDictItemByCode } from '/@/api/system/dict'; | @@ -12,6 +12,13 @@ import { findDictItemByCode } from '/@/api/system/dict'; | ||
12 | import { deviceProfile } from '/@/api/device/deviceManager'; | 12 | import { deviceProfile } from '/@/api/device/deviceManager'; |
13 | import { getModelServices } from '/@/api/device/modelOfMatter'; | 13 | import { getModelServices } from '/@/api/device/modelOfMatter'; |
14 | import { ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel'; | 14 | import { ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel'; |
15 | +import useCommonFun from '../hooks/useCommonFun'; | ||
16 | + | ||
17 | +const { useByProductGetAttribute } = useCommonFun(); | ||
18 | +export type TOption = { | ||
19 | + label: string; | ||
20 | + value: string; | ||
21 | +}; | ||
15 | 22 | ||
16 | /** | 23 | /** |
17 | * 所使用的枚举值 | 24 | * 所使用的枚举值 |
@@ -212,31 +219,10 @@ export const trigger_condition_schema: FormSchema[] = [ | @@ -212,31 +219,10 @@ export const trigger_condition_schema: FormSchema[] = [ | ||
212 | onChange: async (e) => { | 219 | onChange: async (e) => { |
213 | if (e) { | 220 | if (e) { |
214 | setFieldsValue({ type2: '' }); | 221 | setFieldsValue({ type2: '' }); |
222 | + setFieldsValue({ entityId: [] }); | ||
215 | const res = await getAttribute(e); | 223 | const res = await getAttribute(e); |
216 | - let options: any = []; | ||
217 | - if (Array.isArray(res)) { | ||
218 | - options = res.map((m) => { | ||
219 | - return { | ||
220 | - label: m?.identifier, | ||
221 | - value: m?.identifier, | ||
222 | - }; | ||
223 | - }); | ||
224 | - updateSchema({ | ||
225 | - field: 'type2', | ||
226 | - componentProps: { | ||
227 | - placeholder: '请选择属性', | ||
228 | - options, | ||
229 | - }, | ||
230 | - }); | ||
231 | - } else { | ||
232 | - updateSchema({ | ||
233 | - field: 'type2', | ||
234 | - componentProps: { | ||
235 | - placeholder: '请选择属性', | ||
236 | - options, | ||
237 | - }, | ||
238 | - }); | ||
239 | - } | 224 | + const options = ref<TOption[]>([]); |
225 | + useByProductGetAttribute(res, updateSchema, options); | ||
240 | } | 226 | } |
241 | }, | 227 | }, |
242 | }; | 228 | }; |
@@ -259,10 +245,22 @@ export const trigger_condition_schema: FormSchema[] = [ | @@ -259,10 +245,22 @@ export const trigger_condition_schema: FormSchema[] = [ | ||
259 | { | 245 | { |
260 | field: 'entityId', | 246 | field: 'entityId', |
261 | label: '', | 247 | label: '', |
262 | - component: 'Select', | ||
263 | - componentProps: { | ||
264 | - placeholder: '请选择设备', | ||
265 | - mode: 'multiple', | 248 | + component: 'ApiSelect', |
249 | + componentProps: ({ formModel }) => { | ||
250 | + const deviceProfileId = formModel['deviceProfileId']; | ||
251 | + if (unref(organizationId)) { | ||
252 | + return { | ||
253 | + placeholder: '请选择设备', | ||
254 | + mode: 'multiple', | ||
255 | + api: byOrganizationIdGetMasterDevice, | ||
256 | + params: { | ||
257 | + organizationId: unref(organizationId), | ||
258 | + deviceProfileId, | ||
259 | + }, | ||
260 | + labelField: 'name', | ||
261 | + valueField: 'id', | ||
262 | + }; | ||
263 | + } | ||
266 | }, | 264 | }, |
267 | ifShow: ({ values }) => isPart(values.device), | 265 | ifShow: ({ values }) => isPart(values.device), |
268 | colProps: { span: 6 }, | 266 | colProps: { span: 6 }, |
@@ -388,6 +386,7 @@ export const actionSchema: FormSchema[] = [ | @@ -388,6 +386,7 @@ export const actionSchema: FormSchema[] = [ | ||
388 | getPopupContainer: () => document.body, | 386 | getPopupContainer: () => document.body, |
389 | onChange: () => { | 387 | onChange: () => { |
390 | setFieldsValue({ deviceId: [] }); | 388 | setFieldsValue({ deviceId: [] }); |
389 | + setFieldsValue({ thingsModelId: '' }); | ||
391 | }, | 390 | }, |
392 | }; | 391 | }; |
393 | }, | 392 | }, |
@@ -511,7 +510,6 @@ export const actionSchema: FormSchema[] = [ | @@ -511,7 +510,6 @@ export const actionSchema: FormSchema[] = [ | ||
511 | valueField: 'id', | 510 | valueField: 'id', |
512 | getPopupContainer: () => document.body, | 511 | getPopupContainer: () => document.body, |
513 | onChange: (_, options: ModelOfMatterParams) => { | 512 | onChange: (_, options: ModelOfMatterParams) => { |
514 | - // console.log(options); | ||
515 | setFieldsValue({ doContext: { ...options.functionJson, callType: options.callType } }); | 513 | setFieldsValue({ doContext: { ...options.functionJson, callType: options.callType } }); |
516 | }, | 514 | }, |
517 | }; | 515 | }; |
@@ -141,7 +141,7 @@ export const genActionData = (actionData) => { | @@ -141,7 +141,7 @@ export const genActionData = (actionData) => { | ||
141 | entityType: device ?? 'ALL', | 141 | entityType: device ?? 'ALL', |
142 | deviceId: device === 'PART' ? deviceId : null, | 142 | deviceId: device === 'PART' ? deviceId : null, |
143 | deviceProfileId, | 143 | deviceProfileId, |
144 | - commandType, | 144 | + commandType: Number(commandType), |
145 | callType, | 145 | callType, |
146 | service, | 146 | service, |
147 | thingsModelId, | 147 | thingsModelId, |
1 | <template> | 1 | <template> |
2 | - <BasicModal v-bind="$attrs" :width="600" title="编辑报警日程" centered @register="registerModal" @ok="handleOk" | ||
3 | - @cancel="handleCancel"> | 2 | + <BasicModal |
3 | + v-bind="$attrs" | ||
4 | + :width="600" | ||
5 | + :title="isUpdateFlag ? '编辑' + title : '新增' + title" | ||
6 | + centered | ||
7 | + @register="registerModal" | ||
8 | + @ok="handleOk" | ||
9 | + @cancel="handleCancel" | ||
10 | + > | ||
4 | <BasicForm @register="registerForm" ref="basicFormRef"> | 11 | <BasicForm @register="registerForm" ref="basicFormRef"> |
5 | <template #customEnable> | 12 | <template #customEnable> |
6 | <template v-for="(item, optionIndex) in options" :key="item.flag"> | 13 | <template v-for="(item, optionIndex) in options" :key="item.flag"> |
@@ -8,222 +15,252 @@ | @@ -8,222 +15,252 @@ | ||
8 | <div class="ml-4 mr-4 flex items-center"> | 15 | <div class="ml-4 mr-4 flex items-center"> |
9 | <Checkbox v-model:checked="item.enabled">星期{{ item.flag }}</Checkbox> | 16 | <Checkbox v-model:checked="item.enabled">星期{{ item.flag }}</Checkbox> |
10 | </div> | 17 | </div> |
11 | - <TimePicker placeholder="开始时间" v-model:value="item.startsOn" value-format="x" format="HH:mm" | ||
12 | - :disabled="!item.enabled" /> | 18 | + <TimePicker |
19 | + placeholder="开始时间" | ||
20 | + v-model:value="item.startsOn" | ||
21 | + value-format="x" | ||
22 | + format="HH:mm" | ||
23 | + :disabled="!item.enabled" | ||
24 | + /> | ||
13 | <span class="ml-4 mr-4 flex items-center">~</span> | 25 | <span class="ml-4 mr-4 flex items-center">~</span> |
14 | - <TimePicker @change="handleBlur(item.startsOn,item.endsOn)" placeholder="结束时间" v-model:value="item.endsOn" | ||
15 | - value-format="x" format="HH:mm" :disabled="!item.enabled" /> | 26 | + <TimePicker |
27 | + @change="handleBlur(item.startsOn, item.endsOn)" | ||
28 | + placeholder="结束时间" | ||
29 | + v-model:value="item.endsOn" | ||
30 | + value-format="x" | ||
31 | + format="HH:mm" | ||
32 | + :disabled="!item.enabled" | ||
33 | + /> | ||
16 | </div> | 34 | </div> |
17 | </template> | 35 | </template> |
18 | </template> | 36 | </template> |
19 | <template #timing> | 37 | <template #timing> |
20 | - <TimePicker placeholder="开始时间" v-model:value="timeState.startsOn" value-format="x" format="HH:mm" /> | 38 | + <TimePicker |
39 | + placeholder="开始时间" | ||
40 | + v-model:value="timeState.startsOn" | ||
41 | + value-format="x" | ||
42 | + format="HH:mm" | ||
43 | + /> | ||
21 | <span class="ml-4 mr-4">~</span> | 44 | <span class="ml-4 mr-4">~</span> |
22 | - <TimePicker @change="handleTimeBlur(timeState.startsOn,timeState.endsOn)" placeholder="结束时间" | ||
23 | - v-model:value="timeState.endsOn" value-format="x" format="HH:mm" /> | 45 | + <TimePicker |
46 | + @change="handleTimeBlur(timeState.startsOn, timeState.endsOn)" | ||
47 | + placeholder="结束时间" | ||
48 | + v-model:value="timeState.endsOn" | ||
49 | + value-format="x" | ||
50 | + format="HH:mm" | ||
51 | + /> | ||
24 | </template> | 52 | </template> |
25 | </BasicForm> | 53 | </BasicForm> |
26 | </BasicModal> | 54 | </BasicModal> |
27 | </template> | 55 | </template> |
28 | 56 | ||
29 | <script lang="ts" setup> | 57 | <script lang="ts" setup> |
30 | -import { reactive, ref, watch, nextTick } from 'vue'; | ||
31 | -import { useModalInner, BasicModal } from '/@/components/Modal'; | ||
32 | -import { BasicForm, useForm } from '/@/components/Form'; | ||
33 | -import { alarmScheduleSchemas } from '../config/config.data.ts'; | ||
34 | -import { Checkbox, TimePicker } from 'ant-design-vue'; | ||
35 | -import { useMessage } from '/@/hooks/web/useMessage'; | 58 | + import { reactive, ref, watch, nextTick } from 'vue'; |
59 | + import { useModalInner, BasicModal } from '/@/components/Modal'; | ||
60 | + import { BasicForm, useForm } from '/@/components/Form'; | ||
61 | + import { alarmScheduleSchemas } from '../config/config.data'; | ||
62 | + import { Checkbox, TimePicker } from 'ant-design-vue'; | ||
63 | + import { useMessage } from '/@/hooks/web/useMessage'; | ||
36 | 64 | ||
37 | -const emit = defineEmits(['register', 'cancel']); | ||
38 | -const { createMessage } = useMessage(); | ||
39 | -const [registerForm, { setFieldsValue, getFieldsValue }] = useForm({ | ||
40 | - showActionButtonGroup: false, | ||
41 | - schemas: alarmScheduleSchemas, | ||
42 | -}); | ||
43 | -const timeState = reactive({ | ||
44 | - startsOn: null, | ||
45 | - endsOn: null, | ||
46 | -}); | ||
47 | - | ||
48 | -const options = ref([ | ||
49 | - { | ||
50 | - enabled: false, | ||
51 | - dayOfWeek: 1, | ||
52 | - flag: '一', | ||
53 | - endsOn: null, | ||
54 | - startsOn: null, | ||
55 | - }, | ||
56 | - { | ||
57 | - enabled: false, | ||
58 | - dayOfWeek: 2, | ||
59 | - flag: '二', | ||
60 | - endsOn: null, | ||
61 | - startsOn: null, | ||
62 | - }, | ||
63 | - { | ||
64 | - enabled: false, | ||
65 | - dayOfWeek: 3, | ||
66 | - flag: '三', | ||
67 | - endsOn: null, | ||
68 | - startsOn: null, | ||
69 | - }, | ||
70 | - { | ||
71 | - enabled: false, | ||
72 | - dayOfWeek: 4, | ||
73 | - flag: '四', | ||
74 | - endsOn: null, | ||
75 | - startsOn: null, | ||
76 | - }, | ||
77 | - { | ||
78 | - enabled: false, | ||
79 | - dayOfWeek: 5, | ||
80 | - flag: '五', | ||
81 | - endsOn: null, | ||
82 | - startsOn: null, | ||
83 | - }, | ||
84 | - { | ||
85 | - enabled: false, | ||
86 | - dayOfWeek: 6, | ||
87 | - flag: '六', | ||
88 | - endsOn: null, | 65 | + const emit = defineEmits(['register', 'cancel']); |
66 | + const title = ref(''); | ||
67 | + const isUpdateFlag = ref(false); | ||
68 | + const { createMessage } = useMessage(); | ||
69 | + const [registerForm, { setFieldsValue, getFieldsValue }] = useForm({ | ||
70 | + showActionButtonGroup: false, | ||
71 | + schemas: alarmScheduleSchemas, | ||
72 | + }); | ||
73 | + const timeState = reactive({ | ||
89 | startsOn: null, | 74 | startsOn: null, |
90 | - }, | ||
91 | - { | ||
92 | - enabled: false, | ||
93 | - dayOfWeek: 7, | ||
94 | - flag: '日', | ||
95 | endsOn: null, | 75 | endsOn: null, |
96 | - startsOn: null, | ||
97 | - }, | ||
98 | -]); | ||
99 | -const basicFormRef = ref<InstanceType<typeof BasicForm>>(); | ||
100 | -let index = ref(null); | ||
101 | -watch( | ||
102 | - options, | ||
103 | - (newValue) => { | ||
104 | - const arr = []; | ||
105 | - for (let item of newValue) { | ||
106 | - if (item.enabled && item.startsOn && item.endsOn) { | ||
107 | - arr.push(true); | ||
108 | - } else if ((!item.enabled && item.startsOn && item.endsOn) || item.enabled) { | ||
109 | - arr.push(false); | 76 | + }); |
77 | + | ||
78 | + const options = ref([ | ||
79 | + { | ||
80 | + enabled: false, | ||
81 | + dayOfWeek: 1, | ||
82 | + flag: '一', | ||
83 | + endsOn: null, | ||
84 | + startsOn: null, | ||
85 | + }, | ||
86 | + { | ||
87 | + enabled: false, | ||
88 | + dayOfWeek: 2, | ||
89 | + flag: '二', | ||
90 | + endsOn: null, | ||
91 | + startsOn: null, | ||
92 | + }, | ||
93 | + { | ||
94 | + enabled: false, | ||
95 | + dayOfWeek: 3, | ||
96 | + flag: '三', | ||
97 | + endsOn: null, | ||
98 | + startsOn: null, | ||
99 | + }, | ||
100 | + { | ||
101 | + enabled: false, | ||
102 | + dayOfWeek: 4, | ||
103 | + flag: '四', | ||
104 | + endsOn: null, | ||
105 | + startsOn: null, | ||
106 | + }, | ||
107 | + { | ||
108 | + enabled: false, | ||
109 | + dayOfWeek: 5, | ||
110 | + flag: '五', | ||
111 | + endsOn: null, | ||
112 | + startsOn: null, | ||
113 | + }, | ||
114 | + { | ||
115 | + enabled: false, | ||
116 | + dayOfWeek: 6, | ||
117 | + flag: '六', | ||
118 | + endsOn: null, | ||
119 | + startsOn: null, | ||
120 | + }, | ||
121 | + { | ||
122 | + enabled: false, | ||
123 | + dayOfWeek: 7, | ||
124 | + flag: '日', | ||
125 | + endsOn: null, | ||
126 | + startsOn: null, | ||
127 | + }, | ||
128 | + ]); | ||
129 | + const basicFormRef = ref<InstanceType<typeof BasicForm>>(); | ||
130 | + let index = ref(null); | ||
131 | + watch( | ||
132 | + options, | ||
133 | + (newValue) => { | ||
134 | + const arr = []; | ||
135 | + for (let item of newValue) { | ||
136 | + if (item.enabled && item.startsOn && item.endsOn) { | ||
137 | + arr.push(true); | ||
138 | + } else if ((!item.enabled && item.startsOn && item.endsOn) || item.enabled) { | ||
139 | + arr.push(false); | ||
140 | + } | ||
110 | } | 141 | } |
142 | + const flag = arr.length ? !arr.every((item) => item) : true; | ||
143 | + nextTick(() => { | ||
144 | + setModalProps({ | ||
145 | + okButtonProps: { | ||
146 | + disabled: flag, | ||
147 | + }, | ||
148 | + }); | ||
149 | + }); | ||
150 | + }, | ||
151 | + { | ||
152 | + deep: true, | ||
111 | } | 153 | } |
112 | - const flag = arr.length ? !arr.every((item) => item) : true; | ||
113 | - nextTick(() => { | 154 | + ); |
155 | + | ||
156 | + const [registerModal, { closeModal, setModalProps }] = useModalInner((data) => { | ||
157 | + watch([timeState, basicFormRef.value.formModel], ([timeState, formModel]) => { | ||
114 | setModalProps({ | 158 | setModalProps({ |
115 | okButtonProps: { | 159 | okButtonProps: { |
116 | - disabled: flag, | 160 | + disabled: |
161 | + timeState.startsOn === null || | ||
162 | + timeState.endsOn === null || | ||
163 | + !formModel.daysOfWeek?.length, | ||
117 | }, | 164 | }, |
118 | }); | 165 | }); |
166 | + watch( | ||
167 | + () => formModel.schedule, | ||
168 | + () => { | ||
169 | + timeState.startsOn = null; | ||
170 | + timeState.endsOn = null; | ||
171 | + } | ||
172 | + ); | ||
119 | }); | 173 | }); |
120 | - }, | ||
121 | - { | ||
122 | - deep: true, | ||
123 | - } | ||
124 | -); | 174 | + const { value, currentIndex, isUpdate, scheduleData } = data; |
175 | + isUpdateFlag.value = isUpdate; | ||
176 | + if (value === 'SPECIFIC_TIME') { | ||
177 | + title.value = '定时启用'; | ||
178 | + } else { | ||
179 | + title.value = '自定义启用'; | ||
180 | + } | ||
125 | 181 | ||
126 | -const [registerModal, { closeModal, setModalProps }] = useModalInner((data) => { | ||
127 | - watch([timeState, basicFormRef.value.formModel], ([timeState, formModel]) => { | ||
128 | - setModalProps({ | ||
129 | - okButtonProps: { | ||
130 | - disabled: | ||
131 | - timeState.startsOn === null || | ||
132 | - timeState.endsOn === null || | ||
133 | - !formModel.daysOfWeek?.length, | ||
134 | - }, | 182 | + index.value = currentIndex; |
183 | + const dayZenoTime = Math.round(new Date(new Date().toLocaleDateString()).getTime()); | ||
184 | + // 编辑 | ||
185 | + setFieldsValue({ | ||
186 | + schedule: value, | ||
135 | }); | 187 | }); |
136 | - watch( | ||
137 | - () => formModel.schedule, | ||
138 | - () => { | ||
139 | - timeState.startsOn = null; | ||
140 | - timeState.endsOn = null; | ||
141 | - } | ||
142 | - ); | ||
143 | - }); | ||
144 | - const { value, currentIndex, isUpdate, scheduleData } = data; | ||
145 | - index.value = currentIndex; | ||
146 | - const dayZenoTime = Math.round(new Date(new Date().toLocaleDateString()).getTime()); | ||
147 | - // 编辑 | ||
148 | - setFieldsValue({ | ||
149 | - schedule: value, | ||
150 | - }); | ||
151 | - if (isUpdate) { | ||
152 | - nextTick(() => { | ||
153 | - // 回显定时启用 | ||
154 | - if (scheduleData.type === 'SPECIFIC_TIME') { | ||
155 | - setFieldsValue({ | ||
156 | - daysOfWeek: scheduleData.daysOfWeek, | ||
157 | - }); | ||
158 | - timeState.startsOn = scheduleData.startsOn + dayZenoTime + ''; | ||
159 | - timeState.endsOn = scheduleData.endsOn + dayZenoTime + ''; | ||
160 | - } | ||
161 | - // 回显自定义启用 | ||
162 | - if (scheduleData.type === 'CUSTOM') { | ||
163 | - for (let [index, item] of scheduleData?.items.entries()) { | ||
164 | - if (item.enabled) { | ||
165 | - options.value[index].enabled = item.enabled; | ||
166 | - options.value[index].startsOn = item.startsOn + dayZenoTime + ''; | ||
167 | - options.value[index].endsOn = item.endsOn + dayZenoTime + ''; | 188 | + if (isUpdate) { |
189 | + nextTick(() => { | ||
190 | + // 回显定时启用 | ||
191 | + if (scheduleData.type === 'SPECIFIC_TIME') { | ||
192 | + setFieldsValue({ | ||
193 | + daysOfWeek: scheduleData.daysOfWeek, | ||
194 | + }); | ||
195 | + timeState.startsOn = scheduleData.startsOn + dayZenoTime + ''; | ||
196 | + timeState.endsOn = scheduleData.endsOn + dayZenoTime + ''; | ||
197 | + } | ||
198 | + // 回显自定义启用 | ||
199 | + if (scheduleData.type === 'CUSTOM') { | ||
200 | + for (let [index, item] of scheduleData?.items.entries()) { | ||
201 | + if (item.enabled) { | ||
202 | + options.value[index].enabled = item.enabled; | ||
203 | + options.value[index].startsOn = item.startsOn + dayZenoTime + ''; | ||
204 | + options.value[index].endsOn = item.endsOn + dayZenoTime + ''; | ||
205 | + } | ||
168 | } | 206 | } |
169 | } | 207 | } |
170 | - } | ||
171 | - }); | ||
172 | - } | ||
173 | -}); | ||
174 | -const scheduleData = ref({ | ||
175 | - type: 'ANY_TIME', | ||
176 | -}); | ||
177 | -const handleBlur = (eS, eE) => { | ||
178 | - if (eS > eE) { | ||
179 | - return createMessage.warn('开始时间不能大于结束时间') | ||
180 | - } | ||
181 | -} | ||
182 | -const handleTimeBlur = (eS, eE) => { | ||
183 | - if (eS > eE) { | ||
184 | - return createMessage.warn('开始时间不能大于结束时间') | ||
185 | - } | ||
186 | -} | ||
187 | -const handleOk = () => { | ||
188 | - const { schedule: type, timezone, daysOfWeek } = getFieldsValue(); | ||
189 | - // 获取当天0时时间戳 | ||
190 | - const dayZenoTime = Math.round(new Date(new Date().toLocaleDateString()).getTime()); | ||
191 | - if (type === 'CUSTOM') { | ||
192 | - const items = options.value.map((item) => { | ||
193 | - return { | ||
194 | - startsOn: item.startsOn ? item.startsOn - dayZenoTime : 0, | ||
195 | - endsOn: item.endsOn ? item.endsOn - dayZenoTime : 0, | ||
196 | - dayOfWeek: item.dayOfWeek, | ||
197 | - enabled: item.enabled, | 208 | + }); |
209 | + } | ||
210 | + }); | ||
211 | + const scheduleData = ref({ | ||
212 | + type: 'ANY_TIME', | ||
213 | + }); | ||
214 | + const handleBlur = (eS, eE) => { | ||
215 | + if (eS > eE) { | ||
216 | + return createMessage.warn('开始时间不能大于结束时间'); | ||
217 | + } | ||
218 | + }; | ||
219 | + const handleTimeBlur = (eS, eE) => { | ||
220 | + if (eS > eE) { | ||
221 | + return createMessage.warn('开始时间不能大于结束时间'); | ||
222 | + } | ||
223 | + }; | ||
224 | + const handleOk = () => { | ||
225 | + const { schedule: type, timezone, daysOfWeek } = getFieldsValue(); | ||
226 | + // 获取当天0时时间戳 | ||
227 | + const dayZenoTime = Math.round(new Date(new Date().toLocaleDateString()).getTime()); | ||
228 | + if (type === 'CUSTOM') { | ||
229 | + const items = options.value.map((item) => { | ||
230 | + return { | ||
231 | + startsOn: item.startsOn ? item.startsOn - dayZenoTime : 0, | ||
232 | + endsOn: item.endsOn ? item.endsOn - dayZenoTime : 0, | ||
233 | + dayOfWeek: item.dayOfWeek, | ||
234 | + enabled: item.enabled, | ||
235 | + }; | ||
236 | + }); | ||
237 | + scheduleData.value = { | ||
238 | + type, | ||
239 | + timezone, | ||
240 | + items, | ||
198 | }; | 241 | }; |
199 | - }); | ||
200 | - scheduleData.value = { | ||
201 | - type, | ||
202 | - timezone, | ||
203 | - items, | ||
204 | - }; | ||
205 | - } else if (type === 'SPECIFIC_TIME') { | ||
206 | - scheduleData.value = { | ||
207 | - type, | ||
208 | - timezone, | ||
209 | - daysOfWeek, | ||
210 | - startsOn: timeState.startsOn - dayZenoTime, | ||
211 | - endsOn: timeState.endsOn - dayZenoTime, | ||
212 | - }; | ||
213 | - } | ||
214 | - closeModal(); | ||
215 | -}; | ||
216 | -const handleCancel = () => { | ||
217 | - emit('cancel', index.value); | ||
218 | -}; | 242 | + } else if (type === 'SPECIFIC_TIME') { |
243 | + scheduleData.value = { | ||
244 | + type, | ||
245 | + timezone, | ||
246 | + daysOfWeek, | ||
247 | + startsOn: timeState.startsOn - dayZenoTime, | ||
248 | + endsOn: timeState.endsOn - dayZenoTime, | ||
249 | + }; | ||
250 | + } | ||
251 | + closeModal(); | ||
252 | + }; | ||
253 | + const handleCancel = () => { | ||
254 | + emit('cancel', index.value); | ||
255 | + }; | ||
219 | 256 | ||
220 | -defineExpose({ | ||
221 | - scheduleData, | ||
222 | -}); | 257 | + defineExpose({ |
258 | + scheduleData, | ||
259 | + }); | ||
223 | </script> | 260 | </script> |
224 | 261 | ||
225 | <style lang="less" scoped> | 262 | <style lang="less" scoped> |
226 | -:deep(.ant-time-picker) { | ||
227 | - width: 12rem; | ||
228 | -} | 263 | + :deep(.ant-time-picker) { |
264 | + width: 12rem; | ||
265 | + } | ||
229 | </style> | 266 | </style> |
@@ -62,7 +62,7 @@ | @@ -62,7 +62,7 @@ | ||
62 | import { CollapseContainer } from '/@/components/Container/index'; | 62 | import { CollapseContainer } from '/@/components/Container/index'; |
63 | import { BasicForm, useForm } from '/@/components/Form/index'; | 63 | import { BasicForm, useForm } from '/@/components/Form/index'; |
64 | import { Card, Select, Input, Tooltip } from 'ant-design-vue'; | 64 | import { Card, Select, Input, Tooltip } from 'ant-design-vue'; |
65 | - import { trigger_condition_schema } from '../config/config.data'; | 65 | + import { trigger_condition_schema, TOption } from '../config/config.data'; |
66 | import { getAttribute } from '/@/api/ruleengine/ruleengineApi'; | 66 | import { getAttribute } from '/@/api/ruleengine/ruleengineApi'; |
67 | import ConditionScreening from './ConditionScreening.vue'; | 67 | import ConditionScreening from './ConditionScreening.vue'; |
68 | import { scheduleOptions, timeUnitOptions, options } from '../config/formatData'; | 68 | import { scheduleOptions, timeUnitOptions, options } from '../config/formatData'; |
@@ -70,7 +70,9 @@ | @@ -70,7 +70,9 @@ | ||
70 | import AlarmSchedule from './AlarmSchedule.vue'; | 70 | import AlarmSchedule from './AlarmSchedule.vue'; |
71 | import { useModal } from '/@/components/Modal'; | 71 | import { useModal } from '/@/components/Modal'; |
72 | import { cloneDeep } from 'lodash-es'; | 72 | import { cloneDeep } from 'lodash-es'; |
73 | + import useCommonFun from '../hooks/useCommonFun'; | ||
73 | 74 | ||
75 | + const { useByProductGetAttribute } = useCommonFun(); | ||
74 | defineProps({ | 76 | defineProps({ |
75 | index: { | 77 | index: { |
76 | type: Number, | 78 | type: Number, |
@@ -100,40 +102,8 @@ | @@ -100,40 +102,8 @@ | ||
100 | }; | 102 | }; |
101 | 103 | ||
102 | const updateFieldDeviceId = (deviceList: any[], _, isUpdate) => { | 104 | const updateFieldDeviceId = (deviceList: any[], _, isUpdate) => { |
103 | - if (isUpdate) { | ||
104 | - updateSchema({ | ||
105 | - field: 'entityId', | ||
106 | - componentProps: { | ||
107 | - options: deviceList, | ||
108 | - }, | ||
109 | - }); | ||
110 | - } | ||
111 | - //新增、编辑都会触发onChang事件 | ||
112 | - updateSchema({ | ||
113 | - field: 'device', | ||
114 | - componentProps: { | ||
115 | - options: [ | ||
116 | - { label: '全部', value: 'ALL' }, | ||
117 | - { label: '部分', value: 'PART' }, | ||
118 | - ], | ||
119 | - async onChange(e) { | ||
120 | - setFieldsValue({ entityId: [] }); | ||
121 | - if (e) { | ||
122 | - //fengtao | ||
123 | - if (e == 'ALL') { | ||
124 | - } else { | ||
125 | - updateSchema({ | ||
126 | - field: 'entityId', | ||
127 | - componentProps: { | ||
128 | - options: deviceList, | ||
129 | - }, | ||
130 | - }); | ||
131 | - } | ||
132 | - //fengtao | ||
133 | - } | ||
134 | - }, | ||
135 | - }, | ||
136 | - }); | 105 | + console.log(deviceList); |
106 | + console.log(isUpdate); | ||
137 | }; | 107 | }; |
138 | 108 | ||
139 | const resetFieldsValueFunc = () => resetFields(); | 109 | const resetFieldsValueFunc = () => resetFields(); |
@@ -143,30 +113,8 @@ | @@ -143,30 +113,8 @@ | ||
143 | }; | 113 | }; |
144 | const updateFieldAttributeFunc = async (e) => { | 114 | const updateFieldAttributeFunc = async (e) => { |
145 | const res = await getAttribute(e); | 115 | const res = await getAttribute(e); |
146 | - let options: any = []; | ||
147 | - if (Array.isArray(res)) { | ||
148 | - options = res.map((m) => { | ||
149 | - return { | ||
150 | - label: m?.identifier, | ||
151 | - value: m?.identifier, | ||
152 | - }; | ||
153 | - }); | ||
154 | - updateSchema({ | ||
155 | - field: 'type2', | ||
156 | - componentProps: { | ||
157 | - placeholder: '请选择属性', | ||
158 | - options, | ||
159 | - }, | ||
160 | - }); | ||
161 | - } else { | ||
162 | - updateSchema({ | ||
163 | - field: 'type2', | ||
164 | - componentProps: { | ||
165 | - placeholder: '请选择属性', | ||
166 | - options, | ||
167 | - }, | ||
168 | - }); | ||
169 | - } | 116 | + const options = ref<TOption[]>([]); |
117 | + useByProductGetAttribute(res, updateSchema, options); | ||
170 | }; | 118 | }; |
171 | //TODO-fengtao | 119 | //TODO-fengtao |
172 | const schedule = ref('ANY_TIME'); | 120 | const schedule = ref('ANY_TIME'); |
@@ -62,7 +62,7 @@ | @@ -62,7 +62,7 @@ | ||
62 | import { BasicForm, useForm } from '/@/components/Form/index'; | 62 | import { BasicForm, useForm } from '/@/components/Form/index'; |
63 | import { Icon } from '/@/components/Icon'; | 63 | import { Icon } from '/@/components/Icon'; |
64 | import { Tooltip, Card, Select, Input } from 'ant-design-vue'; | 64 | import { Tooltip, Card, Select, Input } from 'ant-design-vue'; |
65 | - import { trigger_condition_schema } from '../config/config.data'; | 65 | + import { trigger_condition_schema, TOption } from '../config/config.data'; |
66 | import { getAttribute } from '/@/api/ruleengine/ruleengineApi'; | 66 | import { getAttribute } from '/@/api/ruleengine/ruleengineApi'; |
67 | import ConditionScreening from './ConditionScreening.vue'; | 67 | import ConditionScreening from './ConditionScreening.vue'; |
68 | import { scheduleOptions, timeUnitOptions, options } from '../config/formatData'; | 68 | import { scheduleOptions, timeUnitOptions, options } from '../config/formatData'; |
@@ -70,7 +70,9 @@ | @@ -70,7 +70,9 @@ | ||
70 | import { useModal } from '/@/components/Modal'; | 70 | import { useModal } from '/@/components/Modal'; |
71 | import { cloneDeep } from 'lodash-es'; | 71 | import { cloneDeep } from 'lodash-es'; |
72 | import { useMessage } from '/@/hooks/web/useMessage'; | 72 | import { useMessage } from '/@/hooks/web/useMessage'; |
73 | + import useCommonFun from '../hooks/useCommonFun'; | ||
73 | 74 | ||
75 | + const { useByProductGetAttribute } = useCommonFun(); | ||
74 | defineProps({ | 76 | defineProps({ |
75 | title: { | 77 | title: { |
76 | type: String, | 78 | type: String, |
@@ -111,6 +113,10 @@ | @@ -111,6 +113,10 @@ | ||
111 | ); | 113 | ); |
112 | //TODO-fengtao-设备、属性、条件筛选验证 | 114 | //TODO-fengtao-设备、属性、条件筛选验证 |
113 | const validate = getFieldsValue(); | 115 | const validate = getFieldsValue(); |
116 | + if (validate.deviceProfileId === undefined) { | ||
117 | + createMessage.error('请选择产品'); | ||
118 | + throw '请选择产品'; | ||
119 | + } | ||
114 | if (validate.triggerType == undefined) return createMessage.error('请选择设备触发方式'); | 120 | if (validate.triggerType == undefined) return createMessage.error('请选择设备触发方式'); |
115 | if (validate.type1 == undefined) return createMessage.error('请选择属性触发方式'); | 121 | if (validate.type1 == undefined) return createMessage.error('请选择属性触发方式'); |
116 | if (validate.device == 'PART') { | 122 | if (validate.device == 'PART') { |
@@ -140,41 +146,8 @@ | @@ -140,41 +146,8 @@ | ||
140 | 146 | ||
141 | //TODO-fengtao | 147 | //TODO-fengtao |
142 | const updateFieldDeviceId = (deviceList: any[], _, isUpdate) => { | 148 | const updateFieldDeviceId = (deviceList: any[], _, isUpdate) => { |
143 | - //用于编辑回显 | ||
144 | - if (isUpdate.value) { | ||
145 | - updateSchema({ | ||
146 | - field: 'entityId', | ||
147 | - componentProps: { | ||
148 | - options: deviceList, | ||
149 | - }, | ||
150 | - }); | ||
151 | - } | ||
152 | - //新增、编辑都会触发onChang事件 | ||
153 | - updateSchema({ | ||
154 | - field: 'device', | ||
155 | - componentProps: { | ||
156 | - options: [ | ||
157 | - { label: '全部', value: 'ALL' }, | ||
158 | - { label: '部分', value: 'PART' }, | ||
159 | - ], | ||
160 | - async onChange(e) { | ||
161 | - setFieldsValue({ entityId: [] }); | ||
162 | - if (e) { | ||
163 | - //fengtao | ||
164 | - if (e == 'ALL') { | ||
165 | - } else { | ||
166 | - updateSchema({ | ||
167 | - field: 'entityId', | ||
168 | - componentProps: { | ||
169 | - options: deviceList, | ||
170 | - }, | ||
171 | - }); | ||
172 | - } | ||
173 | - //fengtao | ||
174 | - } | ||
175 | - }, | ||
176 | - }, | ||
177 | - }); | 149 | + console.log(deviceList); |
150 | + console.log(isUpdate); | ||
178 | }; | 151 | }; |
179 | //TODO-fengtao | 152 | //TODO-fengtao |
180 | const resetFieldsValueFunc = () => { | 153 | const resetFieldsValueFunc = () => { |
@@ -188,30 +161,8 @@ | @@ -188,30 +161,8 @@ | ||
188 | //TODO-fengtao | 161 | //TODO-fengtao |
189 | const updateFieldAttributeFunc = async (e) => { | 162 | const updateFieldAttributeFunc = async (e) => { |
190 | const res = await getAttribute(e); | 163 | const res = await getAttribute(e); |
191 | - let options: any = []; | ||
192 | - if (Array.isArray(res)) { | ||
193 | - options = res.map((m) => { | ||
194 | - return { | ||
195 | - label: m?.identifier, | ||
196 | - value: m?.identifier, | ||
197 | - }; | ||
198 | - }); | ||
199 | - updateSchema({ | ||
200 | - field: 'type2', | ||
201 | - componentProps: { | ||
202 | - placeholder: '请选择属性', | ||
203 | - options, | ||
204 | - }, | ||
205 | - }); | ||
206 | - } else { | ||
207 | - updateSchema({ | ||
208 | - field: 'type2', | ||
209 | - componentProps: { | ||
210 | - placeholder: '请选择属性', | ||
211 | - options, | ||
212 | - }, | ||
213 | - }); | ||
214 | - } | 164 | + const options = ref<TOption[]>([]); |
165 | + useByProductGetAttribute(res, updateSchema, options); | ||
215 | }; | 166 | }; |
216 | //TODO-fengtao | 167 | //TODO-fengtao |
217 | const handleDelete = (params: { index: number; title: string }) => { | 168 | const handleDelete = (params: { index: number; title: string }) => { |
@@ -188,6 +188,7 @@ | @@ -188,6 +188,7 @@ | ||
188 | }; | 188 | }; |
189 | }); | 189 | }); |
190 | //TODO-fengtao-清除告警验证 | 190 | //TODO-fengtao-清除告警验证 |
191 | + let productIdIsRequired = false; | ||
191 | let deviceIdIsRequired = false; | 192 | let deviceIdIsRequired = false; |
192 | let attrIsRequired = false; | 193 | let attrIsRequired = false; |
193 | let predicateIsRequired = false; | 194 | let predicateIsRequired = false; |
@@ -201,6 +202,9 @@ | @@ -201,6 +202,9 @@ | ||
201 | deviceIdIsRequired = true; | 202 | deviceIdIsRequired = true; |
202 | } | 203 | } |
203 | } | 204 | } |
205 | + if (s.deviceProfileId === undefined) { | ||
206 | + productIdIsRequired = true; | ||
207 | + } | ||
204 | if (s.type2 == '' || s.type2 == null) { | 208 | if (s.type2 == '' || s.type2 == null) { |
205 | attrIsRequired = true; | 209 | attrIsRequired = true; |
206 | } | 210 | } |
@@ -229,6 +233,7 @@ | @@ -229,6 +233,7 @@ | ||
229 | } | 233 | } |
230 | }); | 234 | }); |
231 | } | 235 | } |
236 | + if (productIdIsRequired) return createMessage.error('请选择产品'); | ||
232 | if (deviceIdIsRequired) return createMessage.error('请选择设备'); | 237 | if (deviceIdIsRequired) return createMessage.error('请选择设备'); |
233 | if (attrIsRequired) return createMessage.error('请选择属性'); | 238 | if (attrIsRequired) return createMessage.error('请选择属性'); |
234 | if (predicateIsRequired) return createMessage.error('请填写条件筛选'); | 239 | if (predicateIsRequired) return createMessage.error('请填写条件筛选'); |
1 | +export default () => { | ||
2 | + //根据产品获取对应属性 | ||
3 | + const useByProductGetAttribute = (res, callback, opt) => { | ||
4 | + const getAttr = (options) => | ||
5 | + callback({ | ||
6 | + field: 'type2', | ||
7 | + componentProps: { | ||
8 | + placeholder: '请选择属性', | ||
9 | + options, | ||
10 | + }, | ||
11 | + }); | ||
12 | + if (Array.isArray(res)) { | ||
13 | + opt = res.map((m) => { | ||
14 | + return { | ||
15 | + label: m?.identifier, | ||
16 | + value: m?.identifier, | ||
17 | + }; | ||
18 | + }); | ||
19 | + getAttr(opt); | ||
20 | + } else { | ||
21 | + getAttr(opt); | ||
22 | + } | ||
23 | + }; | ||
24 | + | ||
25 | + return { | ||
26 | + useByProductGetAttribute, | ||
27 | + }; | ||
28 | +}; |
1 | import { BasicColumn, FormSchema } from '/@/components/Table'; | 1 | import { BasicColumn, FormSchema } from '/@/components/Table'; |
2 | import moment from 'moment'; | 2 | import moment from 'moment'; |
3 | -import { h } from 'vue'; | ||
4 | -import { Tag } from 'ant-design-vue'; | ||
5 | 3 | ||
6 | // 表格配置 | 4 | // 表格配置 |
7 | export const columns: BasicColumn[] = [ | 5 | export const columns: BasicColumn[] = [ |
@@ -14,12 +12,7 @@ export const columns: BasicColumn[] = [ | @@ -14,12 +12,7 @@ export const columns: BasicColumn[] = [ | ||
14 | title: '脚本状态', | 12 | title: '脚本状态', |
15 | dataIndex: 'status', | 13 | dataIndex: 'status', |
16 | width: 120, | 14 | width: 120, |
17 | - customRender: ({ record }) => { | ||
18 | - const status = record.status; | ||
19 | - const color = status == 1 ? 'green' : 'red'; | ||
20 | - const text = status == 1 ? '启用' : '禁用'; | ||
21 | - return h(Tag, { color: color }, () => text); | ||
22 | - }, | 15 | + slots: { customRender: 'status' }, |
23 | }, | 16 | }, |
24 | { | 17 | { |
25 | title: '脚本内容', | 18 | title: '脚本内容', |
@@ -49,6 +49,17 @@ | @@ -49,6 +49,17 @@ | ||
49 | ]" | 49 | ]" |
50 | /> | 50 | /> |
51 | </template> | 51 | </template> |
52 | + <template #status="{ record }"> | ||
53 | + <Switch | ||
54 | + :checked="record.status === 1" | ||
55 | + :loading="record.pendingStatus" | ||
56 | + checkedChildren="启用" | ||
57 | + unCheckedChildren="禁用" | ||
58 | + @change="(checked:boolean)=>statusChange(checked,record)" | ||
59 | + /> | ||
60 | + </template> | ||
61 | + <!-- <Authority value="api:yt:js:update:status"> | ||
62 | + </Authority> --> | ||
52 | </BasicTable> | 63 | </BasicTable> |
53 | <ConverScriptModal @register="registerModal" @success="handleSuccess" /> | 64 | <ConverScriptModal @register="registerModal" @success="handleSuccess" /> |
54 | </div> | 65 | </div> |
@@ -60,13 +71,18 @@ | @@ -60,13 +71,18 @@ | ||
60 | import { searchFormSchema, columns } from './config.data'; | 71 | import { searchFormSchema, columns } from './config.data'; |
61 | import { Authority } from '/@/components/Authority'; | 72 | import { Authority } from '/@/components/Authority'; |
62 | import { useBatchDelete } from '/@/hooks/web/useBatchDelete'; | 73 | import { useBatchDelete } from '/@/hooks/web/useBatchDelete'; |
63 | - import { Popconfirm } from 'ant-design-vue'; | 74 | + import { Switch, Popconfirm } from 'ant-design-vue'; |
64 | import { useModal } from '/@/components/Modal'; | 75 | import { useModal } from '/@/components/Modal'; |
65 | import ConverScriptModal from './ConverScriptModal.vue'; | 76 | import ConverScriptModal from './ConverScriptModal.vue'; |
66 | - import { ScriptPage, deleteScriptManage } from '/@/api/scriptmanage/scriptManager'; | 77 | + import { |
78 | + ScriptPage, | ||
79 | + deleteScriptManage, | ||
80 | + scriptPagePutApi, | ||
81 | + } from '/@/api/scriptmanage/scriptManager'; | ||
82 | + import { useMessage } from '/@/hooks/web/useMessage'; | ||
67 | 83 | ||
68 | const searchInfo = reactive<Recordable>({}); | 84 | const searchInfo = reactive<Recordable>({}); |
69 | - const [registerTable, { reload, setProps }] = useTable({ | 85 | + const [registerTable, { reload, setProps, setSelectedRowKeys }] = useTable({ |
70 | title: '转换脚本列表', | 86 | title: '转换脚本列表', |
71 | api: ScriptPage, | 87 | api: ScriptPage, |
72 | columns, | 88 | columns, |
@@ -94,11 +110,8 @@ | @@ -94,11 +110,8 @@ | ||
94 | reload(); | 110 | reload(); |
95 | }; | 111 | }; |
96 | 112 | ||
97 | - const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions } = useBatchDelete( | ||
98 | - deleteScriptManage, | ||
99 | - handleSuccess, | ||
100 | - setProps | ||
101 | - ); | 113 | + const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions, resetSelectedRowKeys } = |
114 | + useBatchDelete(deleteScriptManage, handleSuccess, setProps); | ||
102 | 115 | ||
103 | nextTick(() => { | 116 | nextTick(() => { |
104 | setProps(selectionOptions); | 117 | setProps(selectionOptions); |
@@ -147,4 +160,26 @@ | @@ -147,4 +160,26 @@ | ||
147 | }); | 160 | }); |
148 | } | 161 | } |
149 | }; | 162 | }; |
163 | + const statusChange = async (checked, record) => { | ||
164 | + setProps({ | ||
165 | + loading: true, | ||
166 | + }); | ||
167 | + setSelectedRowKeys([]); | ||
168 | + resetSelectedRowKeys(); | ||
169 | + const newStatus = checked ? 1 : 0; | ||
170 | + const { createMessage } = useMessage(); | ||
171 | + try { | ||
172 | + await scriptPagePutApi({ id: record.id, status: newStatus }); | ||
173 | + if (newStatus) { | ||
174 | + createMessage.success(`启用成功`); | ||
175 | + } else { | ||
176 | + createMessage.success('禁用成功'); | ||
177 | + } | ||
178 | + } finally { | ||
179 | + setProps({ | ||
180 | + loading: false, | ||
181 | + }); | ||
182 | + reload(); | ||
183 | + } | ||
184 | + }; | ||
150 | </script> | 185 | </script> |
@@ -57,18 +57,21 @@ | @@ -57,18 +57,21 @@ | ||
57 | return f.username == values.username; | 57 | return f.username == values.username; |
58 | } | 58 | } |
59 | }); | 59 | }); |
60 | + console.log(findUserName); | ||
60 | return [ | 61 | return [ |
61 | { | 62 | { |
62 | required: true, | 63 | required: true, |
63 | validator(_, value) { | 64 | validator(_, value) { |
64 | return new Promise((resolve, reject) => { | 65 | return new Promise((resolve, reject) => { |
65 | - if (value == '') { | 66 | + console.log(value); |
67 | + if (value == '' || value === undefined) { | ||
66 | reject('请输入账号'); | 68 | reject('请输入账号'); |
67 | } else if (ChineseRegexp.test(value)) { | 69 | } else if (ChineseRegexp.test(value)) { |
68 | reject('账号不能含有中文'); | 70 | reject('账号不能含有中文'); |
69 | } else if (EmailRegexp.test(value)) { | 71 | } else if (EmailRegexp.test(value)) { |
70 | reject('账号不能为电子邮箱格式'); | 72 | reject('账号不能为电子邮箱格式'); |
71 | - } else if (value == findUserName?.username) { | 73 | + } else if (findUserName && value == findUserName?.username) { |
74 | + console.log(1111111111); | ||
72 | reject('账号已存在'); | 75 | reject('账号已存在'); |
73 | return; | 76 | return; |
74 | } else { | 77 | } else { |
@@ -88,6 +91,7 @@ | @@ -88,6 +91,7 @@ | ||
88 | component: 'Input', | 91 | component: 'Input', |
89 | componentProps: { | 92 | componentProps: { |
90 | maxLength: 255, | 93 | maxLength: 255, |
94 | + placeholder: '请输入真实名字', | ||
91 | }, | 95 | }, |
92 | rules: chineseAndEnlishRule, | 96 | rules: chineseAndEnlishRule, |
93 | }, | 97 | }, |
@@ -129,6 +133,7 @@ | @@ -129,6 +133,7 @@ | ||
129 | await resetFields(); | 133 | await resetFields(); |
130 | isUpdate.value = !!data?.isUpdate; | 134 | isUpdate.value = !!data?.isUpdate; |
131 | tenantId.value = data?.tenantId; | 135 | tenantId.value = data?.tenantId; |
136 | + console.log(data.judgeExistUserName); | ||
132 | isJudgeUserNameExist.value = data.judgeExistUserName; | 137 | isJudgeUserNameExist.value = data.judgeExistUserName; |
133 | if (unref(isUpdate)) { | 138 | if (unref(isUpdate)) { |
134 | await updateSchema({ field: 'username', componentProps: { disabled: true } }); | 139 | await updateSchema({ field: 'username', componentProps: { disabled: true } }); |