Commit a77e24ac575eeadc98a380d755d5d533c0227f08

Authored by ww
1 parent 31a31840

fix: 修复规则链查看详情时无法打开启用规则

@@ -13,14 +13,16 @@ @@ -13,14 +13,16 @@
13 <template v-for="(item, optionIndex) in options" :key="item.flag"> 13 <template v-for="(item, optionIndex) in options" :key="item.flag">
14 <div :class="optionIndex >= 1 ? 'mt-4' : ''" class="flex"> 14 <div :class="optionIndex >= 1 ? 'mt-4' : ''" class="flex">
15 <div class="ml-4 mr-4 flex items-center"> 15 <div class="ml-4 mr-4 flex items-center">
16 - <Checkbox v-model:checked="item.enabled">星期{{ item.flag }}</Checkbox> 16 + <Checkbox v-model:checked="item.enabled" :disabled="modalStatus"
  17 + >星期{{ item.flag }}</Checkbox
  18 + >
17 </div> 19 </div>
18 <TimePicker 20 <TimePicker
19 placeholder="开始时间" 21 placeholder="开始时间"
20 v-model:value="item.startsOn" 22 v-model:value="item.startsOn"
21 value-format="x" 23 value-format="x"
22 format="HH:mm" 24 format="HH:mm"
23 - :disabled="!item.enabled" 25 + :disabled="!item.enabled || modalStatus"
24 /> 26 />
25 <span class="ml-4 mr-4 flex items-center">~</span> 27 <span class="ml-4 mr-4 flex items-center">~</span>
26 <TimePicker 28 <TimePicker
@@ -29,7 +31,7 @@ @@ -29,7 +31,7 @@
29 v-model:value="item.endsOn" 31 v-model:value="item.endsOn"
30 value-format="x" 32 value-format="x"
31 format="HH:mm" 33 format="HH:mm"
32 - :disabled="!item.enabled" 34 + :disabled="!item.enabled || modalStatus"
33 /> 35 />
34 </div> 36 </div>
35 </template> 37 </template>
@@ -40,6 +42,7 @@ @@ -40,6 +42,7 @@
40 v-model:value="timeState.startsOn" 42 v-model:value="timeState.startsOn"
41 value-format="x" 43 value-format="x"
42 format="HH:mm" 44 format="HH:mm"
  45 + :disabled="modalStatus"
43 /> 46 />
44 <span class="ml-4 mr-4">~</span> 47 <span class="ml-4 mr-4">~</span>
45 <TimePicker 48 <TimePicker
@@ -48,6 +51,7 @@ @@ -48,6 +51,7 @@
48 v-model:value="timeState.endsOn" 51 v-model:value="timeState.endsOn"
49 value-format="x" 52 value-format="x"
50 format="HH:mm" 53 format="HH:mm"
  54 + :disabled="modalStatus"
51 /> 55 />
52 </template> 56 </template>
53 </BasicForm> 57 </BasicForm>
@@ -55,7 +59,7 @@ @@ -55,7 +59,7 @@
55 </template> 59 </template>
56 60
57 <script lang="ts" setup> 61 <script lang="ts" setup>
58 - import { reactive, ref, watch, nextTick } from 'vue'; 62 + import { reactive, ref, watch, nextTick, unref } from 'vue';
59 import { useModalInner, BasicModal } from '/@/components/Modal'; 63 import { useModalInner, BasicModal } from '/@/components/Modal';
60 import { BasicForm, useForm } from '/@/components/Form'; 64 import { BasicForm, useForm } from '/@/components/Form';
61 import { alarmScheduleSchemas } from '../config/config.data'; 65 import { alarmScheduleSchemas } from '../config/config.data';
@@ -66,7 +70,7 @@ @@ -66,7 +70,7 @@
66 const title = ref(''); 70 const title = ref('');
67 const isUpdateFlag = ref(false); 71 const isUpdateFlag = ref(false);
68 const { createMessage } = useMessage(); 72 const { createMessage } = useMessage();
69 - const [registerForm, { setFieldsValue, getFieldsValue }] = useForm({ 73 + const [registerForm, { setFieldsValue, getFieldsValue, setProps }] = useForm({
70 showActionButtonGroup: false, 74 showActionButtonGroup: false,
71 schemas: alarmScheduleSchemas, 75 schemas: alarmScheduleSchemas,
72 }); 76 });
@@ -143,7 +147,7 @@ @@ -143,7 +147,7 @@
143 nextTick(() => { 147 nextTick(() => {
144 setModalProps({ 148 setModalProps({
145 okButtonProps: { 149 okButtonProps: {
146 - disabled: flag, 150 + disabled: flag || unref(modalStatus),
147 }, 151 },
148 }); 152 });
149 }); 153 });
@@ -153,6 +157,7 @@ @@ -153,6 +157,7 @@
153 } 157 }
154 ); 158 );
155 159
  160 + const modalStatus = ref(false);
156 const [registerModal, { closeModal, setModalProps }] = useModalInner((data) => { 161 const [registerModal, { closeModal, setModalProps }] = useModalInner((data) => {
157 watch([timeState, basicFormRef.value.formModel], ([timeState, formModel]) => { 162 watch([timeState, basicFormRef.value.formModel], ([timeState, formModel]) => {
158 setModalProps({ 163 setModalProps({
@@ -160,7 +165,8 @@ @@ -160,7 +165,8 @@
160 disabled: 165 disabled:
161 timeState.startsOn === null || 166 timeState.startsOn === null ||
162 timeState.endsOn === null || 167 timeState.endsOn === null ||
163 - !formModel.daysOfWeek?.length, 168 + !formModel.daysOfWeek?.length ||
  169 + unref(modalStatus),
164 }, 170 },
165 }); 171 });
166 watch( 172 watch(
@@ -171,7 +177,7 @@ @@ -171,7 +177,7 @@
171 } 177 }
172 ); 178 );
173 }); 179 });
174 - const { value, currentIndex, isUpdate, scheduleData } = data; 180 + const { value, currentIndex, isUpdate, scheduleData, disabled } = data;
175 isUpdateFlag.value = isUpdate; 181 isUpdateFlag.value = isUpdate;
176 if (value === 'SPECIFIC_TIME') { 182 if (value === 'SPECIFIC_TIME') {
177 title.value = '定时启用'; 183 title.value = '定时启用';
@@ -179,6 +185,16 @@ @@ -179,6 +185,16 @@
179 title.value = '自定义启用'; 185 title.value = '自定义启用';
180 } 186 }
181 187
  188 + if (disabled) {
  189 + modalStatus.value = disabled;
  190 + setProps({ disabled });
  191 + setModalProps({
  192 + okButtonProps: {
  193 + disabled,
  194 + },
  195 + });
  196 + }
  197 +
182 index.value = currentIndex; 198 index.value = currentIndex;
183 const dayZenoTime = Math.round(new Date(new Date().toLocaleDateString()).getTime()); 199 const dayZenoTime = Math.round(new Date(new Date().toLocaleDateString()).getTime());
184 // 编辑 200 // 编辑
@@ -147,7 +147,7 @@ @@ -147,7 +147,7 @@
147 const currentIndex = ref(0); 147 const currentIndex = ref(0);
148 const [registerModal, { openModal }] = useModal(); 148 const [registerModal, { openModal }] = useModal();
149 const handleScheduleChange = (value) => { 149 const handleScheduleChange = (value) => {
150 - if (unref(disabled)) return; 150 + // if (unref(disabled)) return;
151 const index = scheduleOptions.findIndex((item) => item.value === value); 151 const index = scheduleOptions.findIndex((item) => item.value === value);
152 // 报警日程弹窗 152 // 报警日程弹窗
153 if (index !== 0) { 153 if (index !== 0) {
@@ -156,6 +156,7 @@ @@ -156,6 +156,7 @@
156 value, 156 value,
157 currentIndex: currentIndex.value, 157 currentIndex: currentIndex.value,
158 scheduleData, 158 scheduleData,
  159 + disabled: unref(disabled),
159 }); 160 });
160 } else { 161 } else {
161 alarmScheduleRef.value.scheduleData = { 162 alarmScheduleRef.value.scheduleData = {
@@ -199,7 +199,7 @@ @@ -199,7 +199,7 @@
199 const [registerModal, { openModal }] = useModal(); 199 const [registerModal, { openModal }] = useModal();
200 const currentIndex = ref(0); 200 const currentIndex = ref(0);
201 const handleScheduleChange = (value) => { 201 const handleScheduleChange = (value) => {
202 - if (unref(disabled)) return; 202 + // if (unref(disabled)) return;
203 const index = scheduleOptions.findIndex((item) => item.value === value); 203 const index = scheduleOptions.findIndex((item) => item.value === value);
204 // 报警日程弹窗 204 // 报警日程弹窗
205 if (index !== 0) { 205 if (index !== 0) {
@@ -208,6 +208,7 @@ @@ -208,6 +208,7 @@
208 value, 208 value,
209 currentIndex: currentIndex.value, 209 currentIndex: currentIndex.value,
210 scheduleData, 210 scheduleData,
  211 + disabled: unref(disabled),
211 }); 212 });
212 } else { 213 } else {
213 alarmScheduleRef.value.scheduleData = { 214 alarmScheduleRef.value.scheduleData = {