Commit 4eb4c405a0db7d20c1c942e939ec545957edd32b
1 parent
a50efc3d
fix: 修复场景联动查看全部都要置灰,不允许点击,还有数据流转中的数据源
Showing
8 changed files
with
48 additions
and
14 deletions
| @@ -126,10 +126,16 @@ | @@ -126,10 +126,16 @@ | ||
| 126 | } | 126 | } |
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | - async function handleFetch() { | ||
| 130 | - if (!props.immediate && unref(isFirstLoad)) { | 129 | + // async function handleFetch() { |
| 130 | + // if (!props.immediate && unref(isFirstLoad)) { | ||
| 131 | + // await fetch(); | ||
| 132 | + // isFirstLoad.value = false; | ||
| 133 | + // } | ||
| 134 | + // } | ||
| 135 | + | ||
| 136 | + async function handleFetch(open) { | ||
| 137 | + if (open) { | ||
| 131 | await fetch(); | 138 | await fetch(); |
| 132 | - isFirstLoad.value = false; | ||
| 133 | } | 139 | } |
| 134 | } | 140 | } |
| 135 | 141 |
| @@ -30,12 +30,14 @@ | @@ -30,12 +30,14 @@ | ||
| 30 | modalProps?: ExtractPropTypes<InstanceType<typeof BasicModal>['$props']>; | 30 | modalProps?: ExtractPropTypes<InstanceType<typeof BasicModal>['$props']>; |
| 31 | transferProps?: ExtractPropTypes<TransferType['$props']>; | 31 | transferProps?: ExtractPropTypes<TransferType['$props']>; |
| 32 | buttonProps?: ExtractPropTypes<InstanceType<typeof Button>['$props']>; | 32 | buttonProps?: ExtractPropTypes<InstanceType<typeof Button>['$props']>; |
| 33 | + disabled?: any; | ||
| 33 | }>(), | 34 | }>(), |
| 34 | { | 35 | { |
| 35 | labelField: 'label', | 36 | labelField: 'label', |
| 36 | valueField: 'value', | 37 | valueField: 'value', |
| 37 | buttonName: '选择产品', | 38 | buttonName: '选择产品', |
| 38 | maxTagLength: 2, | 39 | maxTagLength: 2, |
| 40 | + disabled: false, | ||
| 39 | } | 41 | } |
| 40 | ); | 42 | ); |
| 41 | 43 | ||
| @@ -146,6 +148,8 @@ | @@ -146,6 +148,8 @@ | ||
| 146 | ); | 148 | ); |
| 147 | 149 | ||
| 148 | const handleOpenModal = () => { | 150 | const handleOpenModal = () => { |
| 151 | + const { disabled } = props; | ||
| 152 | + if (disabled) return; | ||
| 149 | openModal(true); | 153 | openModal(true); |
| 150 | }; | 154 | }; |
| 151 | 155 |
| @@ -42,6 +42,7 @@ | @@ -42,6 +42,7 @@ | ||
| 42 | onValueChange?: (selectedRowkeys: string[]) => any[]; | 42 | onValueChange?: (selectedRowkeys: string[]) => any[]; |
| 43 | onRemoveAfter?: (actionType: ActionType) => Promise<any>; | 43 | onRemoveAfter?: (actionType: ActionType) => Promise<any>; |
| 44 | onSelectedAfter?: (actionType: ActionType) => Promise<any>; | 44 | onSelectedAfter?: (actionType: ActionType) => Promise<any>; |
| 45 | + disabled?: any; | ||
| 45 | }>(), | 46 | }>(), |
| 46 | { | 47 | { |
| 47 | buttonName: '选择设备', | 48 | buttonName: '选择设备', |
| @@ -49,6 +50,7 @@ | @@ -49,6 +50,7 @@ | ||
| 49 | maxTagLength: 2, | 50 | maxTagLength: 2, |
| 50 | labelField: 'label', | 51 | labelField: 'label', |
| 51 | valueField: 'value', | 52 | valueField: 'value', |
| 53 | + disabled: false, | ||
| 52 | } | 54 | } |
| 53 | ); | 55 | ); |
| 54 | 56 | ||
| @@ -217,6 +219,8 @@ | @@ -217,6 +219,8 @@ | ||
| 217 | } | 219 | } |
| 218 | 220 | ||
| 219 | const handleOpenModal = async () => { | 221 | const handleOpenModal = async () => { |
| 222 | + const { disabled } = props; | ||
| 223 | + if (disabled) return; | ||
| 220 | openModal(true); | 224 | openModal(true); |
| 221 | await nextTick(); | 225 | await nextTick(); |
| 222 | if (props.value && !props.value.length) { | 226 | if (props.value && !props.value.length) { |
| @@ -61,7 +61,6 @@ | @@ -61,7 +61,6 @@ | ||
| 61 | //input动态数据 | 61 | //input动态数据 |
| 62 | const dynamicInput: UnwrapRef<{ params: Params[] }> = reactive({ params: [] }); | 62 | const dynamicInput: UnwrapRef<{ params: Params[] }> = reactive({ params: [] }); |
| 63 | 63 | ||
| 64 | - console.log(dynamicInput, 'dynamicInput'); | ||
| 65 | //删除Input | 64 | //删除Input |
| 66 | const remove = (item: Params) => { | 65 | const remove = (item: Params) => { |
| 67 | let index = dynamicInput.params.indexOf(item); | 66 | let index = dynamicInput.params.indexOf(item); |
| @@ -71,11 +70,6 @@ | @@ -71,11 +70,6 @@ | ||
| 71 | emitChange(); | 70 | emitChange(); |
| 72 | }; | 71 | }; |
| 73 | 72 | ||
| 74 | - // const disabled = computed(() => { | ||
| 75 | - // const { disabled } = props || {}; | ||
| 76 | - // return disabled; | ||
| 77 | - // }); | ||
| 78 | - | ||
| 79 | //新增Input | 73 | //新增Input |
| 80 | const add = () => { | 74 | const add = () => { |
| 81 | dynamicInput.params.push({ | 75 | dynamicInput.params.push({ |
| @@ -16,6 +16,7 @@ | @@ -16,6 +16,7 @@ | ||
| 16 | import { BasicInfoFormField } from './enum'; | 16 | import { BasicInfoFormField } from './enum'; |
| 17 | import { BasicInfoRecord } from './types'; | 17 | import { BasicInfoRecord } from './types'; |
| 18 | import { Button } from 'ant-design-vue'; | 18 | import { Button } from 'ant-design-vue'; |
| 19 | + import { ref, unref } from 'vue'; | ||
| 19 | 20 | ||
| 20 | const props = defineProps({ | 21 | const props = defineProps({ |
| 21 | saveContent: { | 22 | saveContent: { |
| @@ -25,8 +26,9 @@ | @@ -25,8 +26,9 @@ | ||
| 25 | 26 | ||
| 26 | const emit = defineEmits(['currentDataFlowMethodEmitNext']); | 27 | const emit = defineEmits(['currentDataFlowMethodEmitNext']); |
| 27 | 28 | ||
| 29 | + const disabled = ref<boolean>(false); | ||
| 28 | const [register, { validateFields, setFieldsValue, resetFields, setProps }] = useForm({ | 30 | const [register, { validateFields, setFieldsValue, resetFields, setProps }] = useForm({ |
| 29 | - schemas: modeForm(props.saveContent), | 31 | + schemas: modeForm(props.saveContent, unref(disabled)), |
| 30 | ...modelFormPublicConfig, | 32 | ...modelFormPublicConfig, |
| 31 | }); | 33 | }); |
| 32 | 34 | ||
| @@ -61,12 +63,21 @@ | @@ -61,12 +63,21 @@ | ||
| 61 | emit('currentDataFlowMethodEmitNext', getValue()); | 63 | emit('currentDataFlowMethodEmitNext', getValue()); |
| 62 | }; | 64 | }; |
| 63 | 65 | ||
| 66 | + const setDisabledProps = (value) => { | ||
| 67 | + setProps(value); | ||
| 68 | + disabled.value = false; | ||
| 69 | + }; | ||
| 70 | + const setCancelDisabled = () => { | ||
| 71 | + disabled.value = false; | ||
| 72 | + }; | ||
| 73 | + | ||
| 64 | const resetValue = () => resetFields(); | 74 | const resetValue = () => resetFields(); |
| 65 | defineExpose({ | 75 | defineExpose({ |
| 66 | getValue, | 76 | getValue, |
| 67 | setValue, | 77 | setValue, |
| 68 | resetValue, | 78 | resetValue, |
| 69 | - setProps, | 79 | + setDisabledProps, |
| 80 | + setCancelDisabled, | ||
| 70 | }); | 81 | }); |
| 71 | </script> | 82 | </script> |
| 72 | <style lang="less" scoped> | 83 | <style lang="less" scoped> |
| @@ -75,7 +75,9 @@ | @@ -75,7 +75,9 @@ | ||
| 75 | const { text, record } = data; | 75 | const { text, record } = data; |
| 76 | businessText.value = text; | 76 | businessText.value = text; |
| 77 | if (businessText.value == BusinessDataFlowTextEnum.BUSINESS_MODAL_VIEW_TEXT) { | 77 | if (businessText.value == BusinessDataFlowTextEnum.BUSINESS_MODAL_VIEW_TEXT) { |
| 78 | - dataFlowMethodRef.value?.setProps({ disabled: true }); | 78 | + dataFlowMethodRef.value?.setDisabledProps({ disabled: true }); |
| 79 | + } else { | ||
| 80 | + dataFlowMethodRef.value?.setCancelDisabled(); | ||
| 79 | } | 81 | } |
| 80 | restData.data = record; | 82 | restData.data = record; |
| 81 | setModalProps(modalProps(businessText.value)); | 83 | setModalProps(modalProps(businessText.value)); |
| @@ -150,7 +150,10 @@ const TransferTableProps: BasicTableProps = { | @@ -150,7 +150,10 @@ const TransferTableProps: BasicTableProps = { | ||
| 150 | fetchSetting: FETCH_SETTING, | 150 | fetchSetting: FETCH_SETTING, |
| 151 | } as BasicTableProps; | 151 | } as BasicTableProps; |
| 152 | 152 | ||
| 153 | -export const modeForm = (submitFn?: Function): FormSchema[] => { | 153 | +export const modeForm = ( |
| 154 | + submitFn: Function | undefined, | ||
| 155 | + disabled?: boolean | any | ||
| 156 | +): FormSchema[] => { | ||
| 154 | return [ | 157 | return [ |
| 155 | { | 158 | { |
| 156 | field: BasicInfoFormField.CONVERT_CONFIG_ID, | 159 | field: BasicInfoFormField.CONVERT_CONFIG_ID, |
| @@ -187,6 +190,7 @@ export const modeForm = (submitFn?: Function): FormSchema[] => { | @@ -187,6 +190,7 @@ export const modeForm = (submitFn?: Function): FormSchema[] => { | ||
| 187 | api: getDeviceProfile, | 190 | api: getDeviceProfile, |
| 188 | labelField: 'name', | 191 | labelField: 'name', |
| 189 | valueField: 'tbProfileId', | 192 | valueField: 'tbProfileId', |
| 193 | + disabled, | ||
| 190 | transferProps: { | 194 | transferProps: { |
| 191 | listStyle: { height: '400px' }, | 195 | listStyle: { height: '400px' }, |
| 192 | showSearch: true, | 196 | showSearch: true, |
| @@ -222,6 +226,7 @@ export const modeForm = (submitFn?: Function): FormSchema[] => { | @@ -222,6 +226,7 @@ export const modeForm = (submitFn?: Function): FormSchema[] => { | ||
| 222 | labelField: 'name', | 226 | labelField: 'name', |
| 223 | valueField: 'tbDeviceId', | 227 | valueField: 'tbDeviceId', |
| 224 | primaryKey: 'tbDeviceId', | 228 | primaryKey: 'tbDeviceId', |
| 229 | + disabled, | ||
| 225 | pendingTableProps: { | 230 | pendingTableProps: { |
| 226 | ...TransferTableProps, | 231 | ...TransferTableProps, |
| 227 | api: devicePage, | 232 | api: devicePage, |
| @@ -208,7 +208,15 @@ | @@ -208,7 +208,15 @@ | ||
| 208 | }; | 208 | }; |
| 209 | const [ | 209 | const [ |
| 210 | registerAction, | 210 | registerAction, |
| 211 | - { getFieldsValue, resetFields, setFieldsValue, validate, clearValidate, validateFields }, | 211 | + { |
| 212 | + getFieldsValue, | ||
| 213 | + resetFields, | ||
| 214 | + setFieldsValue, | ||
| 215 | + validate, | ||
| 216 | + clearValidate, | ||
| 217 | + validateFields, | ||
| 218 | + setProps, | ||
| 219 | + }, | ||
| 212 | ] = useForm({ | 220 | ] = useForm({ |
| 213 | schemas: actionSchema, | 221 | schemas: actionSchema, |
| 214 | showActionButtonGroup: false, | 222 | showActionButtonGroup: false, |