feat:优化
This commit is contained in:
		
							parent
							
								
									141a3553e0
								
							
						
					
					
						commit
						8c3dbf9717
					
				| @ -2,14 +2,18 @@ | |||||||
|   <div :class="`custom-table-tree ${shadow ? 'custom-table-tree__shadow' : ''}`"> |   <div :class="`custom-table-tree ${shadow ? 'custom-table-tree__shadow' : ''}`"> | ||||||
|     <div v-if="title" class="title">{{ title }}</div> |     <div v-if="title" class="title">{{ title }}</div> | ||||||
|     <el-tree |     <el-tree | ||||||
|       node-key="id" |  | ||||||
|       :data="data" |       :data="data" | ||||||
|  |       :node-key="option.nodeKey" | ||||||
|       :show-checkbox="option.showCheckbox" |       :show-checkbox="option.showCheckbox" | ||||||
|       :default-expanded-keys="option.defaultExpandedKeys" |       :default-expanded-keys="option.defaultExpandedKeys" | ||||||
|       :default-checked-keys="option.defaultCheckedKeys" |       :default-checked-keys="option.defaultCheckedKeys" | ||||||
|       :props="option.defaultProps" |       :props="option.props ?? option.defaultProps" | ||||||
|       @node-click="handleNodeClick" |       @node-click="handleNodeClick" | ||||||
|     /> |     > | ||||||
|  |       <template #default="{ data: rows }"> | ||||||
|  |         <slot :data="rows"></slot> | ||||||
|  |       </template> | ||||||
|  |     </el-tree> | ||||||
|   </div> |   </div> | ||||||
| </template> | </template> | ||||||
| <script setup name="custom-table-tree"> | <script setup name="custom-table-tree"> | ||||||
| @ -21,7 +25,9 @@ const props = defineProps({ | |||||||
|     type: Object, |     type: Object, | ||||||
|     default: () => { |     default: () => { | ||||||
|       return { |       return { | ||||||
|  |         nodeKey: 'id', | ||||||
|         showCheckbox: false, |         showCheckbox: false, | ||||||
|  |         props: {}, | ||||||
|         defaultProps: { |         defaultProps: { | ||||||
|           children: 'children', |           children: 'children', | ||||||
|           label: 'label', |           label: 'label', | ||||||
| @ -34,8 +40,8 @@ const props = defineProps({ | |||||||
| }); | }); | ||||||
| const emit = defineEmits(['node-click']); | const emit = defineEmits(['node-click']); | ||||||
| 
 | 
 | ||||||
| const handleNodeClick = (data) => { | const handleNodeClick = (data, node) => { | ||||||
|   emit('node-click', data); |   emit('node-click', data, node); | ||||||
| }; | }; | ||||||
| </script> | </script> | ||||||
| <style lang="scss" scoped> | <style lang="scss" scoped> | ||||||
|  | |||||||
| @ -3,13 +3,14 @@ | |||||||
|     <div> |     <div> | ||||||
|       <el-row :gutter="20"> |       <el-row :gutter="20"> | ||||||
|         <el-col :span="4"> |         <el-col :span="4"> | ||||||
|           <el-tree |           <!-- <el-tree | ||||||
|             style="max-width: 600px" |             style="max-width: 600px" | ||||||
|             :data="typeTree" |             :data="typeTree" | ||||||
|             node-key="areaCode" |             node-key="areaCode" | ||||||
|             :props="{ children: 'areaChildVOS', label: 'areaName' }" |             :props="{ children: 'areaChildVOS', label: 'areaName' }" | ||||||
|             @node-click="handleNodeClick" |             @node-click="handleNodeClick" | ||||||
|           /> |           /> --> | ||||||
|  |           <custom-table-tree title="行政区域" :data="typeTree" :option="treeOption" @node-click="handleNodeClick" /> | ||||||
|         </el-col> |         </el-col> | ||||||
|         <el-col :span="20"> |         <el-col :span="20"> | ||||||
|           <avue-crud |           <avue-crud | ||||||
| @ -126,35 +127,13 @@ const state = reactive({ | |||||||
|   currentRow: {}, |   currentRow: {}, | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| let typeTree = ref([ | const typeTree = ref([]); | ||||||
|   // { | const treeOption = ref({ | ||||||
|   //   label: '耿马县', |   nodeKey: 'areaCode', | ||||||
|   //   id: '0', |   props: { children: 'areaChildVOS', label: 'areaName' }, | ||||||
|   //   level: '0', | }); | ||||||
|   //   children: [ | const townOptions = reactive([]); | ||||||
|   //     { | const infoData = reactive({ | ||||||
|   //       label: '镇1', |  | ||||||
|   //       level: '1', |  | ||||||
|   //       id: '01', |  | ||||||
|   //       children: [ |  | ||||||
|   //         { label: '村1', children: [], id: '0101', pId: '01', level: '2' }, |  | ||||||
|   //         { label: '村2', children: [], id: '0102', pId: '01', level: '2' }, |  | ||||||
|   //       ], |  | ||||||
|   //       pId: '0', |  | ||||||
|   //     }, |  | ||||||
|   //     { label: '镇2', level: '1', children: [], id: '02', pId: '0' }, |  | ||||||
|   //   ], |  | ||||||
|   // }, |  | ||||||
|   // { |  | ||||||
|   //   label: '县1', |  | ||||||
|   //   id: '1', |  | ||||||
|   //   level: '0', |  | ||||||
|   //   children: [{ label: '镇1', children: [], id: '11', pId: '10', level: '1' }], |  | ||||||
|   // }, |  | ||||||
| ]); |  | ||||||
| let townOptions = reactive([]); |  | ||||||
| 
 |  | ||||||
| let infoData = reactive({ |  | ||||||
|   countyId: '', |   countyId: '', | ||||||
|   townId: '', |   townId: '', | ||||||
|   name: '', |   name: '', | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user