@ebiz/designer-components 0.1.13 → 0.1.15

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.1.13",
3
+ "version": "0.1.15",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -1,101 +1,77 @@
1
1
  <template>
2
- <div class="ebiz-approval">
3
- <t-card>
4
- <!-- 审批人部分 -->
5
- <div class="approval-section">
6
- <div class="approval-title">审批流程</div>
7
-
8
- <div class="section-header">
9
- <t-icon name="user" class="section-icon" />
10
- <span class="section-title">
11
- 审批人
12
- <span class="required" v-if="required">*</span>
13
- </span>
2
+ <div class="ebiz-approval">
3
+ <t-card>
4
+ <!-- 审批人部分 -->
5
+ <div class="approval-section">
6
+ <div class="approval-title">审批流程</div>
7
+
8
+ <div class="section-header">
9
+ <t-icon name="user" class="section-icon" />
10
+ <span class="section-title">
11
+ 审批人
12
+ <span class="required" v-if="required">*</span>
13
+ </span>
14
+ </div>
15
+ <div class="approver-list">
16
+ <div class="approver-row">
17
+ <template v-for="(approver, index) in approvers" :key="index">
18
+ <div class="approver-item">
19
+ <t-avatar :image="approver.avatar" size="small">
20
+ {{ getAvatarText(approver.name) }}
21
+ </t-avatar>
22
+ <div class="user-info" :class="{ 'no-delete': required && approvers.length <= 1 }">
23
+ <span class="approver-name">{{ approver.name }}</span>
24
+ <t-icon v-if="!required || approvers.length > 1" name="close" size="16px"
25
+ @click="removeEmployee(approver, 'approver')" />
14
26
  </div>
15
- <div class="approver-list">
16
- <div class="approver-row" v-if="props.type != 'limited'">
17
- <template v-for="(approver, index) in approvers" :key="index">
18
- <div class="approver-item">
19
- <t-avatar :image="approver.avatar" size="small">
20
- {{ getAvatarText(approver.name) }}
21
- </t-avatar>
22
- <div class="user-info">
23
- <span class="approver-name">{{ approver.name }}</span>
24
- <t-icon name="close" size="16px"
25
- @click="removeEmployee(approver.id, 'approver')" />
26
- </div>
27
- </div>
28
- <t-icon v-if="index < approvers.length - 1" name="chevron-right" class="arrow-icon" />
29
- </template>
30
- <t-button theme="default" variant="text" @click="handleAddApprover" v-if="canEdit">
31
- <template #icon>
32
- <t-icon name="add" />
33
- </template>
34
- 添加审批人
35
- </t-button>
36
- </div>
37
- <div v-else class="approver-row">
38
- <div style="display:flex;align-items:center" v-for="(i,inx) in props.limitedMap" :key="inx">
39
- <template v-if="approvers[inx]">
40
- <div class="approver-item">
41
- <t-avatar :image="approvers[inx].avatar" size="small">
42
- {{ getAvatarText(approvers[inx].name) }}
43
- </t-avatar>
44
- <div class="user-info">
45
- <span class="approver-name">{{ approvers[inx].name }}</span>
46
- <t-icon name="close" size="16px"
47
- @click="removeEmployee(inx, 'approver',true)" />
48
- </div>
49
- </div>
50
- <t-icon name="chevron-right" class="arrow-icon" v-if="inx!=props.limitedMap.length-1"/>
51
- </template>
52
- <t-button v-else theme="default" variant="text" @click="addLimitedApprover(inx)" v-if="canEdit">
53
- <template #icon>
54
- <t-icon name="add" />
55
- </template>
56
- 添加{{i.label}}
57
- </t-button>
58
- </div>
59
- </div>
27
+ </div>
28
+ <t-icon v-if="index < approvers.length - 1" name="chevron-right" class="arrow-icon" />
29
+ </template>
30
+ <t-button theme="default" variant="text" @click="handleAddApprover" v-if="canEdit">
31
+ <template #icon>
32
+ <t-icon name="add" />
33
+ </template>
34
+ 添加审批人
35
+ </t-button>
36
+ </div>
37
+ </div>
38
+ </div>
39
+
40
+ <!-- 抄送人部分 -->
41
+ <div v-if="showCC" class="cc-section">
42
+ <div class="section-header">
43
+ <t-icon name="user-add" class="section-icon" />
44
+ <span class="section-title">抄送人</span>
45
+ </div>
46
+ <div class="cc-list">
47
+ <div class="cc-row">
48
+ <template v-for="(cc, index) in ccEmployees" :key="index">
49
+ <div class="cc-item">
50
+ <t-avatar :image="cc.avatar" size="small">
51
+ {{ getAvatarText(cc.name) }}
52
+ </t-avatar>
53
+ <div class="user-info">
54
+ <span class="cc-name">{{ cc.name }}</span>
55
+ <t-icon name="close" size="16px" @click="removeEmployee(cc, 'cc')" />
60
56
  </div>
61
- </div>
62
-
63
- <!-- 抄送人部分 -->
64
- <div v-if="showCC" class="cc-section">
65
- <div class="section-header">
66
- <t-icon name="user-add" class="section-icon" />
67
- <span class="section-title">抄送人</span>
68
- </div>
69
- <div class="cc-list">
70
- <div class="cc-row">
71
- <template v-for="(cc, index) in ccEmployees" :key="index">
72
- <div class="cc-item">
73
- <t-avatar :image="cc.avatar" size="small">
74
- {{ getAvatarText(cc.name) }}
75
- </t-avatar>
76
- <div class="user-info">
77
- <span class="cc-name">{{ cc.name }}</span>
78
- <t-icon name="close" size="16px" @click="removeEmployee(cc.id, 'cc')" />
79
- </div>
80
- </div>
81
- </template>
82
- <t-button theme="default" variant="text" @click="handleAddCC" v-if="canEdit">
83
- <template #icon>
84
- <t-icon name="add" />
85
- </template>
86
- 添加抄送人
87
- </t-button>
88
- </div>
89
- </div>
90
- </div>
91
- </t-card>
92
-
93
- <!-- 审批人选择弹窗 -->
94
- <ebiz-employee-selector :showDefault="false" v-model:visible="showApproverSelector" v-model:value="tempApprover"
95
- @change="handleApproverSelect" :single="true" />
96
- <ebiz-employee-selector :showDefault="false" v-model:visible="showCCSelector" v-model:value="selectedCC" @change="handleCCSelect"
97
- />
98
- </div>
57
+ </div>
58
+ </template>
59
+ <t-button theme="default" variant="text" @click="handleAddCC" v-if="canEdit">
60
+ <template #icon>
61
+ <t-icon name="add" />
62
+ </template>
63
+ 添加抄送人
64
+ </t-button>
65
+ </div>
66
+ </div>
67
+ </div>
68
+ </t-card>
69
+
70
+ <!-- 审批人选择弹窗 -->
71
+ <ebiz-employee-selector :showDefault="false" v-model:visible="showApproverSelector" @change="handleApproverSelect"
72
+ :single="true" />
73
+ <ebiz-employee-selector :showDefault="false" v-model:visible="showCCSelector" @change="handleCCSelect" />
74
+ </div>
99
75
  </template>
100
76
 
101
77
  <script setup lang="ts">
@@ -111,20 +87,13 @@ interface Employee {
111
87
  avatar?: string
112
88
  }
113
89
 
114
- interface LimitItem{
115
- label:string,
116
- value:string
117
- }
118
-
119
90
  interface Props {
120
91
  approverList: (string | number)[] // 选中的审批人ID列表
121
92
  ccList: (string | number)[] // 选中的抄送人ID列表
122
93
  key: string // 审批流程的唯一标识
123
94
  id: number // 审批流程的编号
124
95
  required: boolean // 是否必填
125
- type?: 'organization' | 'role' | 'all' | 'limited' // 查询类型
126
- limitedType?:'organization' | 'role'
127
- limitedMap?:LimitItem[]
96
+ type?: 'organization' | 'role' | 'all' // 查询类型
128
97
  value?: string // 查询值
129
98
  showRootOrg?: boolean // 是否显示顶层组织
130
99
  childDeptEnable?: boolean // 是否包含子部门
@@ -137,8 +106,6 @@ const props = withDefaults(defineProps<Props>(), {
137
106
  ccList: () => [],
138
107
  key: '',
139
108
  id: 0,
140
- limitedType:'role',
141
- limitedMap:()=>[],
142
109
  required: true,
143
110
  showRootOrg: true,
144
111
  childDeptEnable: false,
@@ -149,22 +116,23 @@ const props = withDefaults(defineProps<Props>(), {
149
116
  const emit = defineEmits(['update:approverList', 'update:ccList', 'change'])
150
117
 
151
118
  const fetchHistory = () => {
152
- dataService.fetch({
153
- bussinessKey: props.id?props.id.toString():null,
154
- type: props.key
155
- }, {}, '/tasks/process/detail').then(res=>{
156
- selectedApprover.value = res?.variables?.form?.approverList ?? [];
157
- selectedCC.value = res?.variables?.form?.ccList ?? [];
158
- if(!selectedApprover.value.length){
159
- dataService.fetch({
160
- apiKey: "offer_Application"
161
- }, {},"/appdata/process?key=offer_Application").then(res=>{
162
- selectedApprover.value = res?.data?.at(0)?.approve_list || [];
163
- })
164
- }
165
- })
119
+ dataService.fetch({
120
+ bussinessKey: props.id ? props.id.toString() : null,
121
+ type: props.key
122
+ }, {}, '/tasks/process/detail').then(res => {
123
+ selectedApprover.value = res?.variables?.form?.approverList ?? [];
124
+ selectedCC.value = res?.variables?.form?.ccList ?? [];
125
+ if (!selectedApprover.value.length) {
126
+ dataService.fetch({
127
+ apiKey: "offer_Application"
128
+ }, {}, "/appdata/process?key=offer_Application").then(res => {
129
+ selectedApprover.value = res?.data?.at(0)?.approve_list || [];
130
+ })
131
+ }
132
+ })
166
133
  }
167
134
 
135
+
168
136
  // 状态变量
169
137
  const showApproverSelector = ref(false)
170
138
  const showCCSelector = ref(false)
@@ -181,7 +149,8 @@ const ccEmployees = ref<Employee[]>([])
181
149
  const selectedApprover = computed({
182
150
  get: () => props.approverList,
183
151
  set: (val) => {
184
- approvers.value = val.map(id => employeeList.value.find(emp => emp.id == id) || null)
152
+ approvers.value = val.map(id => employeeList.value.find(emp => emp.id == id)).filter(Boolean)
153
+ console.log(approvers.value, val)
185
154
  emit('change', {
186
155
  type: 'approver',
187
156
  ids: val,
@@ -195,8 +164,9 @@ const selectedApprover = computed({
195
164
  const selectedCC = computed({
196
165
  get: () => props.ccList,
197
166
  set: (val) => {
167
+
198
168
  ccEmployees.value = val.map(id => employeeList.value.find(emp => emp.id == id)).filter(Boolean)
199
- console.log(ccEmployees.value,161,val)
169
+ console.log(ccEmployees.value, 161, val)
200
170
  emit('change', {
201
171
  type: 'cc',
202
172
  ids: val,
@@ -214,20 +184,6 @@ const getAvatarText = (name: string) => {
214
184
  // 获取员工列表
215
185
  const fetchEmployeeList = async () => {
216
186
  loading.value = true
217
- if(props.type === 'limited') {
218
- switch(props.limitedType) {
219
- case 'organization':
220
- break;
221
- case 'role':{
222
- Promise.all(props.limitedMap.map(i=>dataService.fetch({
223
- roleKeyWord:i.value
224
- },{},'/process/userList'))).then(res=>{
225
- selectedApprover.value = new Array(res.length).fill(0);
226
- })
227
- break;
228
- }
229
- }
230
- }
231
187
  try {
232
188
  const response = await dataService.fetch(
233
189
  {},
@@ -235,9 +191,9 @@ const fetchEmployeeList = async () => {
235
191
  '/process/userList'
236
192
  )
237
193
  employeeList.value = response || [];
238
- if(props.id) {
239
- fetchHistory();
240
- }
194
+ if (props.id) {
195
+ fetchHistory();
196
+ }
241
197
  } catch (error) {
242
198
  employeeList.value = []
243
199
  } finally {
@@ -247,20 +203,15 @@ const fetchEmployeeList = async () => {
247
203
 
248
204
  // 处理审批人选择
249
205
  const handleApproverSelect = (data: []) => {
250
- if(!data[0]) return;
251
- if(props.type === 'limited') {
252
- selectedApprover.value[nowAdd.value] = data[0];
253
- selectedApprover.value = [...selectedApprover.value];
254
- nowAdd.value = 0;
255
- tempApprover.value = [];
256
- return;
257
- }
258
- if(selectedApprover.value.includes(data[0])) {
206
+ console.log(data, 195)
207
+ if (!data[0]) return;
208
+ if (selectedApprover.value.includes(data[0])) {
259
209
  let index = selectedApprover.value.indexOf(data[0]);
260
210
  selectedApprover.value.splice(index, 1);
261
211
  };
262
212
  selectedApprover.value = [...selectedApprover.value, data[0]];
263
- tempApprover.value = [];
213
+ console.log(selectedApprover.value, 200)
214
+ tempApprover.value = [];
264
215
  }
265
216
 
266
217
  // 处理抄送人选择
@@ -269,28 +220,19 @@ const handleCCSelect = (data: []) => {
269
220
  }
270
221
 
271
222
  // 移除人员
272
- const removeEmployee = (idOrInx: any, type: 'approver' | 'cc',isLimited=false) => {
223
+ const removeEmployee = (employee: Employee, type: 'approver' | 'cc') => {
273
224
  if (type === 'approver') {
274
- if(isLimited) {
275
- selectedApprover.value[idOrInx] = 0;
276
- selectedApprover.value = [...selectedApprover.value];
277
- return;
225
+ if (props.required && props.approverList.length <= 1) {
226
+ return
278
227
  }
279
- const newList = props.approverList.filter(id => id !== idOrInx);
228
+ const newList = props.approverList.filter(id => id !== employee.id);
280
229
  selectedApprover.value = newList;
281
230
  } else {
282
- const newList = props.ccList.filter(id => id !== idOrInx);
231
+ const newList = props.ccList.filter(id => id !== employee.id);
283
232
  selectedCC.value = newList;
284
233
  }
285
234
  }
286
235
 
287
- const nowAdd =ref(0);
288
-
289
- const addLimitedApprover = (inx:number) => {
290
- nowAdd.value = inx;
291
- showApproverSelector.value = true;
292
- }
293
-
294
236
  // 处理添加审批人
295
237
  const handleAddApprover = () => {
296
238
  showApproverSelector.value = true
@@ -342,6 +284,7 @@ watch([() => props.type, () => props.value, () => props.showRootOrg, () => props
342
284
 
343
285
  .approver-list,
344
286
  .cc-list {
287
+
345
288
  .approver-row,
346
289
  .cc-row {
347
290
  display: flex;
@@ -366,6 +309,7 @@ watch([() => props.type, () => props.value, () => props.showRootOrg, () => props
366
309
  gap: 8px;
367
310
  cursor: pointer;
368
311
  user-select: none;
312
+
369
313
  &.no-delete {
370
314
  margin-right: 0;
371
315
  }
@@ -387,4 +331,4 @@ watch([() => props.type, () => props.value, () => props.showRootOrg, () => props
387
331
  margin-top: 24px;
388
332
  }
389
333
  }
390
- </style>
334
+ </style>