Commit 48808a479ebb376b4d1651fefd30de926a394413

Authored by fengistao
1 parent b940a049

wip:场景联动页面模拟接口,新增一个emit插件

@@ -12,6 +12,8 @@ tests/server/static/upload @@ -12,6 +12,8 @@ tests/server/static/upload
12 .env.local 12 .env.local
13 .env.*.local 13 .env.*.local
14 .eslintcache 14 .eslintcache
  15 +.package-lock.json
  16 +.yarn.lock
15 17
16 # Log files 18 # Log files
17 npm-debug.log* 19 npm-debug.log*
@@ -49,7 +49,7 @@ @@ -49,7 +49,7 @@
49 const isUpdate = ref<boolean>(true); 49 const isUpdate = ref<boolean>(true);
50 const treeData = ref<TreeItem[]>([]); 50 const treeData = ref<TreeItem[]>([]);
51 const roleMenus = ref<string[]>([]); 51 const roleMenus = ref<string[]>([]);
52 - const allCheckedKeys = ref<string[]>(); 52 + const allCheckedKeys = ref<string[]>([]);
53 const roleHalfCheckedKeys = ref<string[]>([]); 53 const roleHalfCheckedKeys = ref<string[]>([]);
54 const roleId = ref<string>(''); 54 const roleId = ref<string>('');
55 const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({ 55 const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
@@ -103,10 +103,8 @@ @@ -103,10 +103,8 @@
103 103
104 if (unref(isUpdate)) { 104 if (unref(isUpdate)) {
105 if (data.record) { 105 if (data.record) {
106 - // // 通过角色id去获取角色对应的菜单的ids 106 + //通过角色id去获取角色对应的菜单的ids
107 roleMenus.value = await getMenusIdsByRoleId(data.record.id); 107 roleMenus.value = await getMenusIdsByRoleId(data.record.id);
108 - console.log(roleMenus.value);  
109 - console.log(treeData.value);  
110 treeData.value.map((m) => { 108 treeData.value.map((m) => {
111 roleMenus.value.map((m1) => { 109 roleMenus.value.map((m1) => {
112 if (m.key === m1) { 110 if (m.key === m1) {
@@ -116,8 +114,6 @@ @@ -116,8 +114,6 @@
116 }); 114 });
117 console.log(roleMenus.value); 115 console.log(roleMenus.value);
118 proxy.$refs.tree.setCheckedKeys(roleMenus.value); 116 proxy.$refs.tree.setCheckedKeys(roleMenus.value);
119 - // console.log(roleMenus.value, 'roleMenus.value');  
120 - // // TODO: 角色回显问题:待解决  
121 roleId.value = data.record.id; 117 roleId.value = data.record.id;
122 } 118 }
123 setFieldsValue({ 119 setFieldsValue({
@@ -148,11 +144,23 @@ @@ -148,11 +144,23 @@
148 } 144 }
149 } 145 }
150 // Tree check事件 146 // Tree check事件
151 - const handleCheckClick = (checkedKeys: string[], { halfCheckedKeys }) => {  
152 - allCheckedKeys.value = [...checkedKeys, ...halfCheckedKeys];  
153 - // 父节点  
154 - roleHalfCheckedKeys.value = halfCheckedKeys; 147 + const handleCheckClick = (_, e) => {
  148 + let nodes = e.checkedNodes;
  149 + let halfKeys = e.halfCheckedKeys;
  150 + nodes.map((node) => {
  151 + if (node.key != halfKeys[0] && halfKeys.length == []) {
  152 + allCheckedKeys.value.push(node.key);
  153 + } else {
  154 + allCheckedKeys.value.push(node.key);
  155 + }
  156 + });
  157 + allCheckedKeys.value.push(...halfKeys);
155 }; 158 };
  159 + // const handleCheckClick = (checkedKeys: string[], { halfCheckedKeys }) => {
  160 + // allCheckedKeys.value = [...checkedKeys, ...halfCheckedKeys];
  161 + // // 父节点
  162 + // roleHalfCheckedKeys.value = halfCheckedKeys;
  163 + // };
156 164
157 return { 165 return {
158 allCheckedKeys, 166 allCheckedKeys,