@ebiz/designer-components 0.0.21 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ebiz/designer-components",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -0,0 +1,137 @@
1
+ <template>
2
+ <div>
3
+ <t-cascader v-model="selectedValue" :options="departmentTreeData" :placeholder="placeholder" :clearable="clearable"
4
+ :disabled="disabled" :size="size" :multiple="multiple" :max="max" :checkStrictly="checkStrictly"
5
+ :filterable="filterable" :loading="loading" @change="handleChange">
6
+ <template v-if="$slots.empty" #empty>
7
+ <slot name="empty"></slot>
8
+ </template>
9
+ <template v-if="$slots.dropdownItem" #dropdownItem="slotProps">
10
+ <slot name="dropdownItem" v-bind="slotProps"></slot>
11
+ </template>
12
+ <template v-if="$slots.collapsedItems" #collapsedItems="slotProps">
13
+ <slot name="collapsedItems" v-bind="slotProps"></slot>
14
+ </template>
15
+ <template v-if="$slots.suffix" #suffix>
16
+ <slot name="suffix"></slot>
17
+ </template>
18
+ <template v-if="$slots.prefixIcon" #prefixIcon>
19
+ <slot name="prefixIcon"></slot>
20
+ </template>
21
+ </t-cascader>
22
+ </div>
23
+ </template>
24
+
25
+ <script setup>
26
+ import { ref, computed, onMounted, watch } from 'vue';
27
+ import { Cascader as TCascader } from 'tdesign-vue-next';
28
+ import { dataService } from '../index.js';
29
+
30
+ // 定义组件属性
31
+ const props = defineProps({
32
+ modelValue: {
33
+ type: [String, Number, Array],
34
+ default: undefined
35
+ },
36
+ placeholder: {
37
+ type: String,
38
+ default: '请选择部门'
39
+ },
40
+ clearable: {
41
+ type: Boolean,
42
+ default: true
43
+ },
44
+ disabled: {
45
+ type: Boolean,
46
+ default: false
47
+ },
48
+ size: {
49
+ type: String,
50
+ default: undefined,
51
+ validator: (val) => ['small', 'medium', 'large'].includes(val)
52
+ },
53
+ multiple: {
54
+ type: Boolean,
55
+ default: false
56
+ },
57
+ max: {
58
+ type: Number,
59
+ default: 0
60
+ },
61
+ checkStrictly: {
62
+ type: Boolean,
63
+ default: true
64
+ },
65
+ filterable: {
66
+ type: Boolean,
67
+ default: true
68
+ }
69
+ });
70
+
71
+ // 定义组件事件
72
+ const emit = defineEmits(['update:modelValue', 'change']);
73
+
74
+ // 内部状态变量
75
+ const departmentData = ref([]);
76
+ const departmentTreeData = ref([]);
77
+ const loading = ref(false);
78
+ const selectedValue = computed({
79
+ get: () => props.modelValue,
80
+ set: (val) => emit('update:modelValue', val)
81
+ });
82
+
83
+ // 处理变更事件
84
+ const handleChange = (value, context) => {
85
+ emit('change', value, context);
86
+ };
87
+
88
+ // 将部门列表数据转换为树形结构
89
+ const buildDepartmentTree = (data, parentId = null) => {
90
+ return data
91
+ .filter(item => item.manager_dept === parentId)
92
+ .map(item => {
93
+ const children = buildDepartmentTree(data, item.id);
94
+ return {
95
+ ...item,
96
+ label: item.name,
97
+ value: item.id,
98
+ children: children.length > 0 ? children : undefined
99
+ };
100
+ });
101
+ };
102
+
103
+ // 加载部门数据
104
+ const loadDepartmentData = async () => {
105
+ try {
106
+ loading.value = true;
107
+ dataService.fetch({},{
108
+ apiId: 1933,
109
+ apiType: 'MULTIPLE_DATA_SEARCH'
110
+ }).then(res => {
111
+ departmentData.value = res.data || [];
112
+ departmentTreeData.value = buildDepartmentTree(departmentData.value,0);
113
+ }).catch(err => {
114
+ console.error('获取部门数据失败:', err);
115
+ }).finally(() => {
116
+ loading.value = false;
117
+ });
118
+ } catch (error) {
119
+ console.error('获取部门数据失败:', error);
120
+ departmentData.value = [];
121
+ departmentTreeData.value = [];
122
+ } finally {
123
+ loading.value = false;
124
+ }
125
+ };
126
+
127
+ // 组件挂载时加载数据
128
+ onMounted(() => {
129
+ loadDepartmentData();
130
+ });
131
+ </script>
132
+
133
+ <style>
134
+ .ebiz-department-selector {
135
+ width: 100%;
136
+ }
137
+ </style>
@@ -0,0 +1,108 @@
1
+ <template>
2
+ <t-loading :delay="delay" :duration="duration" :indicator="indicator" :inherit-color="inheritColor" :layout="layout"
3
+ :loading="loading" :loading-props="loadingProps" :pause="pause" :reverse="reverse" :show-overlay="showOverlay"
4
+ :size="size" :text="text" :theme="theme">
5
+ <!-- 默认插槽 -->
6
+ <slot></slot>
7
+
8
+ <!-- 文本内容插槽 -->
9
+ <template v-if="$slots.text" #text>
10
+ <slot name="text"></slot>
11
+ </template>
12
+
13
+ <!-- 加载指示器插槽 -->
14
+ <template v-if="$slots.indicator" #indicator>
15
+ <slot name="indicator"></slot>
16
+ </template>
17
+
18
+ <!-- 加载内容插槽 -->
19
+ <template v-if="$slots.content" #content>
20
+ <slot name="content"></slot>
21
+ </template>
22
+ </t-loading>
23
+ </template>
24
+
25
+ <script>
26
+ export default {
27
+ name: "EbizTdesignLoading"
28
+ }
29
+ </script>
30
+
31
+ <script setup>
32
+ import { defineProps } from 'vue';
33
+ import { Loading as TLoading } from 'tdesign-vue-next';
34
+
35
+ const props = defineProps({
36
+ // 延迟显示加载效果的时间,用于防止请求速度过快引起的加载闪烁,单位:毫秒
37
+ delay: {
38
+ type: Number,
39
+ default: 0
40
+ },
41
+ // 加载动画执行完成一次的时间,单位:毫秒
42
+ duration: {
43
+ type: Number,
44
+ default: 800
45
+ },
46
+ // 加载指示符,值为 true 显示默认指示符,值为 false 则不显示,也可以自定义指示符
47
+ indicator: {
48
+ type: [Boolean, Function],
49
+ default: true
50
+ },
51
+ // 是否继承父元素颜色
52
+ inheritColor: {
53
+ type: Boolean,
54
+ default: false
55
+ },
56
+ // 对齐方式
57
+ layout: {
58
+ type: String,
59
+ default: 'horizontal',
60
+ validator: (val) => ['horizontal', 'vertical'].includes(val)
61
+ },
62
+ // 是否处于加载状态
63
+ loading: {
64
+ type: Boolean,
65
+ default: true
66
+ },
67
+ // 透传加载组件全部属性
68
+ loadingProps: {
69
+ type: Object,
70
+ default: () => ({})
71
+ },
72
+ // 是否暂停动画
73
+ pause: {
74
+ type: Boolean,
75
+ default: false
76
+ },
77
+ // 加载动画是否反向
78
+ reverse: {
79
+ type: Boolean,
80
+ default: false
81
+ },
82
+ // 是否需要遮罩层
83
+ showOverlay: {
84
+ type: Boolean,
85
+ default: true
86
+ },
87
+ // 尺寸,示例:small/medium/large/12px/56px
88
+ size: {
89
+ type: String,
90
+ default: 'medium'
91
+ },
92
+ // 加载提示文案
93
+ text: {
94
+ type: String,
95
+ default: ''
96
+ },
97
+ // 加载组件类型
98
+ theme: {
99
+ type: String,
100
+ default: 'circular',
101
+ validator: (val) => ['circular', 'spinner', 'dots', 'bar'].includes(val)
102
+ }
103
+ });
104
+ </script>
105
+
106
+ <style lang="less" scoped>
107
+ /* 自定义样式 */
108
+ </style>
@@ -161,7 +161,7 @@
161
161
  <div class="org-selected-container">
162
162
  <div v-if="tempGlobalSelectedOrgs.length === 0" class="no-selected-tip">请从左侧选择组织</div>
163
163
  <div v-else class="selected-orgs-tags">
164
- <t-tag v-for="org in tempGlobalSelectedOrgs" :key="org.id" closable @close="removeGlobalOrg(org.id)"
164
+ <t-tag v-for="org in tempGlobalSelectedOrgs" :key="org.id" closable @close="removeGlobalSelectedOrg(org.id)"
165
165
  theme="primary" variant="light" class="org-tag">
166
166
  {{ org.name }}
167
167
  </t-tag>
@@ -310,7 +310,8 @@ import {
310
310
  Input as TInput,
311
311
  Tree as TTree,
312
312
  Tag as TTag,
313
- Icon as TIcon
313
+ Icon as TIcon,
314
+ Message
314
315
  } from 'tdesign-vue-next'
315
316
 
316
317
  const apis = {
@@ -372,10 +373,12 @@ function getRoleConfig() {
372
373
  if (matchedFunction) {
373
374
  // 设置功能勾选状态为true
374
375
  matchedFunction.checked = true;
375
-
376
+
376
377
  // 保存数据权限配置(如果有)
377
378
  if (item.dataScope) {
378
379
  row.dataPermission = item.dataScope;
380
+ // 标记为自定义配置
381
+ row.hasCustomConfig = true;
379
382
  // 如果是自定义数据权限,则设置已选组织
380
383
  if (item.dataScope === 6 && item.deptIds && item.deptIds.length > 0) {
381
384
  row.selectedOrgs = item.deptIds.map(id => {
@@ -387,7 +390,7 @@ function getRoleConfig() {
387
390
  });
388
391
  }
389
392
  }
390
-
393
+
391
394
  // 更新父级勾选状态(模块、子模块)
392
395
  updateParentCheckStatus(row);
393
396
  }
@@ -761,16 +764,17 @@ const handleOrgNodeExpand = (value) => {
761
764
  // 打开数据权限配置弹窗
762
765
  const openPermissionDialog = (row) => {
763
766
  currentRow.value = row
764
- // 只做展示,不写入行权限
765
- if (row.dataPermission) {
766
- selectedPermission.value = row.dataPermission
767
+ // 检查是否已有自定义配置
768
+ if (row.hasCustomConfig) {
769
+ // 已有自定义配置,使用自身配置
770
+ selectedPermission.value = row.dataPermission || 1
767
771
  if (row.dataPermission === 6 && row.selectedOrgs) {
768
772
  selectedOrgs.value = [...row.selectedOrgs]
769
773
  } else {
770
774
  selectedOrgs.value = []
771
775
  }
772
776
  } else {
773
- // 没有配置则展示全局,但不写入行
777
+ // 没有自定义配置,继承全局配置
774
778
  selectedPermission.value = globalPermission.value
775
779
  if (globalPermission.value === 6) {
776
780
  selectedOrgs.value = [...globalSelectedOrgs.value]
@@ -818,15 +822,19 @@ const handleGlobalOrgNodeSelect = (node, checked) => {
818
822
  }
819
823
  } else {
820
824
  // 从已选中中移除
821
- removeGlobalOrg(node.id)
825
+ removeGlobalSelectedOrg(node.id)
822
826
  }
823
827
  }
824
828
 
825
829
  // 移除选中的全局组织(对话框中使用)
826
830
  const removeGlobalSelectedOrg = (id) => {
827
- const index = tempGlobalSelectedOrgs.value.findIndex((org) => org.id === id)
831
+ console.log('移除临时全局组织', id);
832
+ const index = tempGlobalSelectedOrgs.value.findIndex((org) => org.id === id);
828
833
  if (index !== -1) {
829
- tempGlobalSelectedOrgs.value.splice(index, 1)
834
+ tempGlobalSelectedOrgs.value.splice(index, 1);
835
+ console.log('移除成功,剩余组织数量:', tempGlobalSelectedOrgs.value.length);
836
+ } else {
837
+ console.log('未找到对应组织');
830
838
  }
831
839
  }
832
840
 
@@ -864,7 +872,7 @@ const handleGlobalOrgConfirm = () => {
864
872
  // 保存选择结果
865
873
  globalSelectedOrgs.value = [...tempGlobalSelectedOrgs.value]
866
874
 
867
- // 应用到所有选择了自定义数据的行
875
+ // 应用到未配置自定义数据权限的行
868
876
  applyGlobalOrgsToCustomRows()
869
877
 
870
878
  globalOrgDialogVisible.value = false
@@ -875,11 +883,21 @@ const handleGlobalOrgCancel = () => {
875
883
  globalOrgDialogVisible.value = false
876
884
  }
877
885
 
878
- // 将全局组织应用到所有自定义数据权限的行
886
+ // 将全局组织应用到未配置自定义数据权限的行
879
887
  const applyGlobalOrgsToCustomRows = () => {
888
+ // 遍历每一行数据
880
889
  data.value.forEach((row) => {
881
- if (row.dataPermission === 6) {
882
- row.selectedOrgs = [...globalSelectedOrgs.value]
890
+ // 只对没有自定义配置的行应用全局设置
891
+ if (!row.hasCustomConfig) {
892
+ // 应用全局权限设置
893
+ row.dataPermission = globalPermission.value
894
+
895
+ // 如果全局设置是自定义数据权限,则应用全局选择的组织
896
+ if (globalPermission.value === 6) {
897
+ row.selectedOrgs = [...globalSelectedOrgs.value]
898
+ } else {
899
+ row.selectedOrgs = []
900
+ }
883
901
  }
884
902
  })
885
903
  }
@@ -887,6 +905,8 @@ const applyGlobalOrgsToCustomRows = () => {
887
905
  // 确认权限配置(修改处理全局配置的情况)
888
906
  const handlePermissionConfirm = () => {
889
907
  if (currentRow.value) {
908
+ // 标记该行已有自定义配置
909
+ currentRow.value.hasCustomConfig = true;
890
910
  currentRow.value.dataPermission = selectedPermission.value
891
911
  if (selectedPermission.value === 6) {
892
912
  currentRow.value.selectedOrgs = [...selectedOrgs.value]
@@ -899,6 +919,7 @@ const handlePermissionConfirm = () => {
899
919
 
900
920
  // 取消权限配置(修改处理全局配置的情况)
901
921
  const handlePermissionCancel = () => {
922
+ // 只关闭弹窗,不做其他操作
902
923
  permissionDialogVisible.value = false
903
924
  }
904
925
 
package/src/index.js CHANGED
@@ -57,7 +57,9 @@ import EbizTreeSelector from './components/EbizTreeSelector.vue';
57
57
  import EbizTimePicker from './components/EbizTimePicker.vue';
58
58
  import EbizPopconfirm from './components/EbizPopconfirm.vue';
59
59
  import EbizTreeMergeTable from './components/EbizTreeMergeTable.vue';
60
+ import EbizTdesignLoading from './components/EbizTdesignLoading.vue';
60
61
  import EbizAutoForm from './components/EbizAutoForm.vue';
62
+ import EbizDepartmentSelector from './components/EbizDepartmentSelector.vue';
61
63
  import { MessagePlugin as EbizMessage } from 'tdesign-vue-next';
62
64
 
63
65
  // import EbizDescriptions from './components/EbizDescriptions.vue';
@@ -77,6 +79,7 @@ import "./assets/styles/charts/main.less";
77
79
  // 时间轴组件
78
80
  import EbizTimeline from "./components/TdesignTimeline.vue";
79
81
  import {TimelineItem as EbizTimelineItem} from 'tdesign-vue-next';
82
+ import { LoadingPlugin as EbizLoading } from 'tdesign-vue-next';
80
83
 
81
84
  // 导出组件
82
85
  export {
@@ -181,8 +184,12 @@ export {
181
184
  EbizTreeMergeTable,
182
185
  // 自动表单组件
183
186
  EbizAutoForm,
187
+ // 部门选择器组件
188
+ EbizDepartmentSelector,
184
189
  // 新增 EbizDescriptions 和 EbizDescriptionsItem
185
190
  EbizDescriptions,
186
191
  EbizDescriptionsItem,
187
- TDescriptionsItem
192
+ TDescriptionsItem,
193
+ EbizTdesignLoading,
194
+ EbizLoading
188
195
  };
@@ -304,6 +304,12 @@ const routes = [
304
304
  name: 'TreeMergeTableDemo',
305
305
  component: () => import('../views/TreeMergeTableDemo.vue'),
306
306
  meta: { title: '树形合并表格组件示例' }
307
+ },
308
+ {
309
+ path: '/ebiz-department-selector',
310
+ name: 'EbizDepartmentSelector',
311
+ component: () => import('../views/EbizDepartmentSelectorDemo.vue'),
312
+ meta: { title: 'Ebiz部门选择器组件示例' }
307
313
  }
308
314
  ]
309
315
 
@@ -0,0 +1,170 @@
1
+ <template>
2
+ <div class="department-selector-demo">
3
+ <h1>部门选择器组件</h1>
4
+
5
+ <section class="demo-section">
6
+ <h2>基础用法</h2>
7
+ <div>
8
+ <EbizDepartmentSelector v-model="selectedDepartment" placeholder="请选择部门" />
9
+ <div class="result-container">
10
+ <p>选中结果: {{ selectedDepartment }}</p>
11
+ </div>
12
+ </div>
13
+ </section>
14
+
15
+ <section class="demo-section">
16
+ <h2>多选模式</h2>
17
+ <div class="demo-box">
18
+ <EbizDepartmentSelector
19
+ v-model="selectedMultipleDepartments"
20
+ placeholder="请选择多个部门"
21
+ :multiple="true"
22
+ />
23
+ <div class="result-container">
24
+ <p>选中结果: {{ selectedMultipleDepartments }}</p>
25
+ </div>
26
+ </div>
27
+ </section>
28
+
29
+ <section class="demo-section">
30
+ <h2>可选择任意层级</h2>
31
+ <div class="demo-box">
32
+ <EbizDepartmentSelector
33
+ v-model="selectedWithStrictly"
34
+ placeholder="任意层级皆可选择"
35
+ :checkStrictly="true"
36
+ :multiple="true"
37
+ />
38
+ <div class="result-container">
39
+ <p>选中结果: {{ selectedWithStrictly }}</p>
40
+ </div>
41
+ </div>
42
+ </section>
43
+
44
+ <section class="demo-section">
45
+ <h2>不同尺寸</h2>
46
+ <div class="demo-box">
47
+ <div class="size-row">
48
+ <EbizDepartmentSelector
49
+ v-model="selectedSizeSmall"
50
+ placeholder="小型尺寸"
51
+ size="small"
52
+ />
53
+ <EbizDepartmentSelector
54
+ v-model="selectedSizeMedium"
55
+ placeholder="中型尺寸"
56
+ size="medium"
57
+ />
58
+ <EbizDepartmentSelector
59
+ v-model="selectedSizeLarge"
60
+ placeholder="大型尺寸"
61
+ size="large"
62
+ />
63
+ </div>
64
+ </div>
65
+ </section>
66
+
67
+ <section class="demo-section">
68
+ <h2>自定义API地址</h2>
69
+ <div class="demo-box">
70
+ <EbizDepartmentSelector
71
+ v-model="selectedCustomApi"
72
+ placeholder="自定义API地址"
73
+ apiUrl="/api/custom-departments"
74
+ />
75
+ </div>
76
+ </section>
77
+
78
+ <section class="demo-section">
79
+ <h2>禁用状态</h2>
80
+ <div class="demo-box">
81
+ <EbizDepartmentSelector
82
+ v-model="selectedDisabled"
83
+ placeholder="禁用状态"
84
+ :disabled="true"
85
+ />
86
+ </div>
87
+ </section>
88
+ </div>
89
+ </template>
90
+
91
+ <script setup>
92
+ import { ref } from 'vue';
93
+ import { EbizDepartmentSelector } from '../index.js';
94
+
95
+ // 单选模式
96
+ const selectedDepartment = ref(90);
97
+
98
+ // 多选模式
99
+ const selectedMultipleDepartments = ref([]);
100
+
101
+ // 可选择任意层级
102
+ const selectedWithStrictly = ref([]);
103
+
104
+ // 不同尺寸
105
+ const selectedSizeSmall = ref();
106
+ const selectedSizeMedium = ref();
107
+ const selectedSizeLarge = ref();
108
+
109
+ // 自定义API地址
110
+ const selectedCustomApi = ref();
111
+
112
+ // 禁用状态
113
+ const selectedDisabled = ref();
114
+
115
+ // 模拟的Mock数据,用于在实际环境无法请求API时展示
116
+ // 在实际开发环境下,可以查看浏览器控制台的网络请求
117
+ // 这里模拟的数据可在开发环境下直接测试组件功能
118
+ console.log('提示:实际环境中组件会请求API获取数据,这里为了演示效果,提供一些模拟数据');
119
+ console.log('模拟数据结构:[{ id: 1, name: "总部", manager_dept: null }, { id: 2, name: "研发部", manager_dept: 1 }, ...]');
120
+
121
+ </script>
122
+
123
+ <style scoped>
124
+ .department-selector-demo {
125
+ padding: 20px;
126
+ max-width: 1000px;
127
+ margin: 0 auto;
128
+ }
129
+
130
+ h1 {
131
+ margin-bottom: 30px;
132
+ font-size: 24px;
133
+ font-weight: 500;
134
+ color: #0052d9;
135
+ }
136
+
137
+ .demo-section {
138
+ margin-bottom: 40px;
139
+ }
140
+
141
+ h2 {
142
+ margin-bottom: 16px;
143
+ font-size: 18px;
144
+ font-weight: 500;
145
+ color: #333;
146
+ }
147
+
148
+ .demo-box {
149
+ padding: 24px;
150
+ border: 1px solid #e7e7e7;
151
+ border-radius: 6px;
152
+ background-color: #fff;
153
+ }
154
+
155
+ .result-container {
156
+ margin-top: 16px;
157
+ padding: 12px;
158
+ background-color: #f9f9f9;
159
+ border-radius: 4px;
160
+ }
161
+
162
+ .size-row {
163
+ display: flex;
164
+ gap: 16px;
165
+ }
166
+
167
+ .size-row > * {
168
+ flex: 1;
169
+ }
170
+ </style>
@@ -78,7 +78,8 @@ export default {
78
78
  { path: '/tdesign-descriptions', title: 'Ebiz描述列表组件示例' },
79
79
  { path: '/popconfirm', title: 'Ebiz气泡确认框组件示例' },
80
80
  { path: '/tree-merge-table-demo', title: '树形合并表格组件示例' },
81
- { path: '/auto-form-demo', title: 'Ebiz自动表单组件示例' }
81
+ { path: '/auto-form-demo', title: 'Ebiz自动表单组件示例' },
82
+ { path: '/ebiz-department-selector', title: 'Ebiz部门选择器组件示例' }
82
83
  ]
83
84
 
84
85
  return {