Commit 60a27752 by wanglizhen

写法更改上传

parent 030e93cb
...@@ -133,6 +133,9 @@ watch( ...@@ -133,6 +133,9 @@ watch(
if (props.itemData) { if (props.itemData) {
const data = JSON.parse(JSON.stringify(props.itemData)); const data = JSON.parse(JSON.stringify(props.itemData));
form.value = { ...form.value, ...data }; form.value = { ...form.value, ...data };
if (props.type === 'edit') {
rulenameList.value = rulenameList.value.filter(item => item !== data.rulename)
}
} }
}, },
{ deep: true, immediate: true } { deep: true, immediate: true }
...@@ -142,6 +145,10 @@ watch( ...@@ -142,6 +145,10 @@ watch(
() => props.nameList, () => props.nameList,
(newVal) => { (newVal) => {
rulenameList.value = props.nameList; rulenameList.value = props.nameList;
const data = JSON.parse(JSON.stringify(props.itemData));
if (props.type === 'edit' && data) {
rulenameList.value = rulenameList.value.filter(item => item !== data.rulename)
}
}, },
{ deep: true, immediate: true } { deep: true, immediate: true }
); );
......
<script setup lang="ts" name="Form"> <script setup lang="ts" name="Form">
import { onMounted, reactive, ref, toRefs, watch } from "vue"; import { onMounted, reactive, ref, toRefs, watch, computed } from "vue";
import { Switch } from "view-ui-plus"; import { Switch } from "view-ui-plus";
import type { FormInstance } from "element-plus"; import type { FormInstance } from "element-plus";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
...@@ -47,10 +47,10 @@ const data = reactive({ ...@@ -47,10 +47,10 @@ const data = reactive({
}); });
const { form, rules } = toRefs(data); const { form, rules } = toRefs(data);
const encryptionList = ref<any[]>([]); // 加密规则选项列表
const secretkeyList = ref<any[]>([]); // 密钥选项列表 const secretkeyList = ref<any[]>([]); // 密钥选项列表
const readOnly = ref(true); const readOnly = ref(true);
const formRef = ref<FormInstance>(); const formRef = ref<FormInstance>();
const encryptionList = computed(() => props.encryptionDict); // 加密规则选项列表
// 重置 // 重置
const reset = () => { const reset = () => {
...@@ -145,13 +145,6 @@ watch( ...@@ -145,13 +145,6 @@ watch(
{ deep: true, immediate: true } { deep: true, immediate: true }
); );
watch(
() => props.encryptionDict,
(newVal) => {
encryptionList.value = props.encryptionDict;
},
{ deep: true, immediate: true }
);
</script> </script>
<template> <template>
......
<script setup lang="ts" name="AddValue"> <script setup lang="ts" name="AddValue">
import { onMounted, reactive, ref, toRefs, watch } from "vue"; import { onMounted, reactive, ref, toRefs, watch, computed } from "vue";
import type { FormInstance } from "element-plus"; import type { FormInstance } from "element-plus";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
...@@ -36,7 +36,7 @@ const data = reactive({ ...@@ -36,7 +36,7 @@ const data = reactive({
const { form, rules } = toRefs(data); const { form, rules } = toRefs(data);
const formRef = ref<FormInstance>(); const formRef = ref<FormInstance>();
const classDictList = ref<any[]>([]); const classDictList = computed(() => props.classDict);
// 重置 // 重置
const reset = () => { const reset = () => {
...@@ -81,20 +81,12 @@ watch( ...@@ -81,20 +81,12 @@ watch(
() => props.itemData, () => props.itemData,
(newVal) => { (newVal) => {
if (props.itemData) { if (props.itemData) {
const data = JSON.parse(JSON.stringify(props.itemData)) const data = JSON.parse(JSON.stringify(props.itemData));
form.value = {...form.value, ...data} form.value = { ...form.value, ...data };
} }
}, },
{ deep: true, immediate: true } { deep: true, immediate: true }
); );
watch(
() => props.classDict,
(newVal) => {
classDictList.value = props.classDict;
},
{ deep: true, immediate: true }
);
</script> </script>
<template> <template>
......
...@@ -30,25 +30,6 @@ const { form, rules } = toRefs(data); ...@@ -30,25 +30,6 @@ const { form, rules } = toRefs(data);
const readOnly = ref(true); const readOnly = ref(true);
const formRef = ref<FormInstance>(); const formRef = ref<FormInstance>();
watch(
() => props.type,
(newVal) => {
readOnly.value = props.type === 'edit' ? true : false;
},
{ deep: true, immediate: true }
);
watch(
() => props.itemData,
(newVal) => {
if (props.type === 'edit' && props.itemData) {
const data = JSON.parse(JSON.stringify(props.itemData));
form.value = { ...form.value, ...data };
}
},
{ deep: true, immediate: true }
);
// 取消 // 取消
const cancel = () => { const cancel = () => {
if (props.type === 'edit') { if (props.type === 'edit') {
...@@ -109,6 +90,24 @@ const addDataAreaFun = () => { ...@@ -109,6 +90,24 @@ const addDataAreaFun = () => {
}) })
} }
watch(
() => props.type,
(newVal) => {
readOnly.value = props.type === 'edit' ? true : false;
},
{ deep: true, immediate: true }
);
watch(
() => props.itemData,
(newVal) => {
if (props.type === 'edit' && props.itemData) {
const data = JSON.parse(JSON.stringify(props.itemData));
form.value = { ...form.value, ...data };
}
},
{ deep: true, immediate: true }
);
</script> </script>
......
...@@ -99,6 +99,9 @@ watch( ...@@ -99,6 +99,9 @@ watch(
if (props.type === 'edit' && props.itemData) { if (props.type === 'edit' && props.itemData) {
const data = JSON.parse(JSON.stringify(props.itemData)); const data = JSON.parse(JSON.stringify(props.itemData));
form.value = { ...form.value, ...data }; form.value = { ...form.value, ...data };
if (props.type === 'edit') {
typeNameList.value = typeNameList.value.filter(item => item !== data.encryption_name)
}
} }
}, },
{ deep: true, immediate: true } { deep: true, immediate: true }
...@@ -108,8 +111,9 @@ watch( ...@@ -108,8 +111,9 @@ watch(
() => props.typeNameDict, () => props.typeNameDict,
(newVal) => { (newVal) => {
typeNameList.value = props.typeNameDict typeNameList.value = props.typeNameDict
if (props.type === 'edit' && props.itemData) { const data = JSON.parse(JSON.stringify(props.itemData));
typeNameList.value = typeNameList.value.filter(item => item !== props.itemData.encryption_name) if (props.type === 'edit' && data) {
typeNameList.value = typeNameList.value.filter(item => item !== data.encryption_name)
} }
}, },
{ deep: true, immediate: true } { deep: true, immediate: true }
......
...@@ -137,6 +137,9 @@ watch( ...@@ -137,6 +137,9 @@ watch(
if (props.itemData) { if (props.itemData) {
const data = JSON.parse(JSON.stringify(props.itemData)); const data = JSON.parse(JSON.stringify(props.itemData));
form.value = { ...form.value, ...data }; form.value = { ...form.value, ...data };
if (props.type === 'edit' && data) {
keyNameList.value = keyNameList.value.filter(item => item !== data.secret_key_name)
}
} }
}, },
{ deep: true, immediate: true } { deep: true, immediate: true }
...@@ -146,8 +149,9 @@ watch( ...@@ -146,8 +149,9 @@ watch(
() => props.keyNameDict, () => props.keyNameDict,
(newVal) => { (newVal) => {
keyNameList.value = props.keyNameDict keyNameList.value = props.keyNameDict
if (props.type === 'edit' && props.itemData) { const data = JSON.parse(JSON.stringify(props.itemData));
keyNameList.value = keyNameList.value.filter(item => item !== props.itemData.secret_key_name) if (props.type === 'edit' && data) {
keyNameList.value = keyNameList.value.filter(item => item !== data.secret_key_name)
} }
}, },
{ deep: true, immediate: true } { deep: true, immediate: true }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论