refactor: nodeDetailDialog 优化
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, nextTick } from 'vue';
|
||||
import { ref, computed, nextTick, watch } from 'vue';
|
||||
import Dialog from '@/components/common/dialog/index.vue';
|
||||
import TableForm from '@/components/common/table/tableForm.vue';
|
||||
import { dataListDirApi, dataQueryDirApi } from '@/api/data/data';
|
||||
@@ -63,6 +63,7 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
operationType: OPERATION_TYPE.ADD,
|
||||
nodeType: '',
|
||||
modalTableNameList: () => (['TASK_POOL_CATEGORY', 'TASK_POOL_TASK', 'TASK_POOL_PERFORMANCE']),
|
||||
detail: null,
|
||||
});
|
||||
|
||||
const emits = defineEmits(['update:modelValue', 'confirm']);
|
||||
@@ -116,7 +117,10 @@ const onConfirmFun = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const open = (nodeType: string, operation:OPERATION_TYPE, detail?: any) => {
|
||||
const prepareFromProps = () => {
|
||||
const nodeType = props.nodeType;
|
||||
const operation = props.operationType;
|
||||
const detail = props.detail;
|
||||
|
||||
let text = operation === OPERATION_TYPE.ADD ? '新增' : '编辑';
|
||||
let targetTableName = props.modalTableNameList?.[1] || '';
|
||||
@@ -154,11 +158,12 @@ const open = (nodeType: string, operation:OPERATION_TYPE, detail?: any) => {
|
||||
} else {
|
||||
localDetail.value = detail ? { ...detail } : null;
|
||||
}
|
||||
emits('update:modelValue', true);
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
open,
|
||||
watch(() => props.modelValue, (val) => {
|
||||
if (val) {
|
||||
prepareFromProps();
|
||||
}
|
||||
});
|
||||
|
||||
const standard = ref();
|
||||
|
||||
Reference in New Issue
Block a user