hookehuyr

✨ feat(组织结构组件): tab根据后端字段控制显示,详情可点击查看

1 <!-- 1 <!--
2 * @Date: 2022-08-29 14:31:20 2 * @Date: 2022-08-29 14:31:20
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-06-17 09:46:57 4 + * @LastEditTime: 2024-06-26 10:02:40
5 * @FilePath: /data-table/src/components/OrgPickerField/MyComponent.vue 5 * @FilePath: /data-table/src/components/OrgPickerField/MyComponent.vue
6 * @Description: 树形组件 6 * @Description: 树形组件
7 --> 7 -->
8 <template> 8 <template>
9 <div class="tree-field-page"> 9 <div class="tree-field-page">
10 <div class="select-tree-box" @click="openTree"> 10 <div class="select-tree-box" @click="openTree">
11 - <div class="select-tree-item" v-for="(dept) in emitCheckedGroup.dept" :key="dept.id"> 11 + <div class="select-tree-item" v-for="(dept) in emitCheckedGroup.dept" :key="dept.id" @click="clickNode(dept)">
12 {{ dept.name }} 12 {{ dept.name }}
13 </div> 13 </div>
14 - <div class="select-tree-item" v-for="(role) in emitCheckedGroup.role" :key="role.id"> 14 + <div class="select-tree-item" v-for="(role) in emitCheckedGroup.role" :key="role.id" @click="clickNode(role)">
15 {{ role.name }} 15 {{ role.name }}
16 </div> 16 </div>
17 - <div class="select-tree-item" v-for="(user) in emitCheckedGroup.user" :key="user.id"> 17 + <div class="select-tree-item" v-for="(user) in emitCheckedGroup.user" :key="user.id" @click="clickNode(user)">
18 {{ user.name }} 18 {{ user.name }}
19 </div> 19 </div>
20 </div> 20 </div>
...@@ -56,9 +56,10 @@ ...@@ -56,9 +56,10 @@
56 56
57 <div v-show="!is_search" class="tab-tree-container"> 57 <div v-show="!is_search" class="tab-tree-container">
58 <van-tabs ref="tabRef" :color="styleColor.baseColor" v-model:active="tabActive" @click-tab="onClickTab" style="margin-bottom: 1rem;"> 58 <van-tabs ref="tabRef" :color="styleColor.baseColor" v-model:active="tabActive" @click-tab="onClickTab" style="margin-bottom: 1rem;">
59 - <van-tab title="组织结构" :name="0"></van-tab> 59 + <!-- <van-tab title="组织结构" :name="0"></van-tab>
60 <van-tab title="角色" :name="1"></van-tab> 60 <van-tab title="角色" :name="1"></van-tab>
61 - <van-tab title="成员" :name="2"></van-tab> 61 + <van-tab title="成员" :name="2"></van-tab> -->
62 + <van-tab v-for="(tab, index) in tabList" :key="index" :title="tab.title" :name="tab.name"></van-tab>
62 </van-tabs> 63 </van-tabs>
63 64
64 <div v-show="tabActive === 0" style="padding: 0 0 0 1rem;"> 65 <div v-show="tabActive === 0" style="padding: 0 0 0 1rem;">
...@@ -232,6 +233,7 @@ import '@wsfe/vue-tree/style.css'; ...@@ -232,6 +233,7 @@ import '@wsfe/vue-tree/style.css';
232 // import dept_list from './flow_dept_list.json' 233 // import dept_list from './flow_dept_list.json'
233 import $ from 'jquery'; 234 import $ from 'jquery';
234 import _ from 'lodash'; 235 import _ from 'lodash';
236 +import { showDialog } from 'vant';
235 237
236 // 获取父组件传值 238 // 获取父组件传值
237 const props = inject('props'); 239 const props = inject('props');
...@@ -244,6 +246,32 @@ const $router = useRouter(); ...@@ -244,6 +246,32 @@ const $router = useRouter();
244 let role_list = []; 246 let role_list = [];
245 let dept_list = []; 247 let dept_list = [];
246 248
249 +// 处理Tab显示问题
250 +// TODO:等待后台数据
251 +const tree_tabs = ['dept', 'role', 'user'];
252 +const tabList = computed(() => {
253 + let arr = [];
254 + if (tree_tabs.indexOf('dept') !== -1) {
255 + arr.push({
256 + title: '组织结构',
257 + name: 0
258 + })
259 + }
260 + if (tree_tabs.indexOf('role') !== -1) {
261 + arr.push({
262 + title: '角色',
263 + name: 1
264 + })
265 + }
266 + if (tree_tabs.indexOf('user') !== -1) {
267 + arr.push({
268 + title: '成员',
269 + name: 2
270 + })
271 + }
272 + return arr;
273 +});
274 +
247 onMounted(async () => { 275 onMounted(async () => {
248 // TAG: 获取后台数据 276 // TAG: 获取后台数据
249 const flowDeptList = await getFlowDeptListAPI({ form_code: $route.query.code }); 277 const flowDeptList = await getFlowDeptListAPI({ form_code: $route.query.code });
...@@ -291,6 +319,19 @@ const openTree = () => { ...@@ -291,6 +319,19 @@ const openTree = () => {
291 }); 319 });
292 } 320 }
293 321
322 +// TODO:等待后台数据显示更多详情字段
323 +const clickNode = (node) => { // 点击显示选择详情
324 + if (!props.component_props.readonly) return false; // 非只读不予许操作
325 + console.warn(node);
326 + showDialog({
327 + title: '详情',
328 + message: `${node.id}-${node.name}-${node.type}`,
329 + confirmButtonColor: styleColor.baseColor
330 + }).then(() => {
331 + // on close
332 + });
333 +}
334 +
294 const emitCheckedGroup = ref({ 335 const emitCheckedGroup = ref({
295 dept: [], // 组织结构 336 dept: [], // 组织结构
296 role: [], // 角色 337 role: [], // 角色
......