adtec-core-package 0.7.0 → 0.7.2
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
|
@@ -51,11 +51,24 @@
|
|
|
51
51
|
</el-form>
|
|
52
52
|
</el-search>
|
|
53
53
|
<el-title class="border" style="border-bottom: var(--border)" title="人员列表"></el-title>
|
|
54
|
+
<div style="padding-top: 4px">
|
|
55
|
+
<el-tag
|
|
56
|
+
v-for="user in selectUserList"
|
|
57
|
+
:key="user.code"
|
|
58
|
+
closable
|
|
59
|
+
style="margin: 2px"
|
|
60
|
+
@close="handleCloseTag(user)"
|
|
61
|
+
>
|
|
62
|
+
{{ user.name }}
|
|
63
|
+
</el-tag>
|
|
64
|
+
</div>
|
|
54
65
|
<el-table
|
|
55
66
|
ref="ref_table"
|
|
56
67
|
:data="userList?.records"
|
|
57
68
|
border
|
|
58
69
|
height="100%"
|
|
70
|
+
@select="selectRows"
|
|
71
|
+
@select-all="selectRows"
|
|
59
72
|
style="margin-top: 8px"
|
|
60
73
|
>
|
|
61
74
|
<el-table-column align="center" type="selection" width="40" />
|
|
@@ -93,7 +106,7 @@
|
|
|
93
106
|
<script lang="ts" setup>
|
|
94
107
|
import { useVModel } from '@vueuse/core'
|
|
95
108
|
import type { IMdmEmployeeQuery } from '../../interface/IMdmEmployeeQuery'
|
|
96
|
-
import {
|
|
109
|
+
import { nextTick, onMounted, ref, watch } from 'vue'
|
|
97
110
|
import type { IpageDataQuery, PageData } from '../../interface//PageData'
|
|
98
111
|
import type { IMdmEmployee } from '../../interface/IMdmEmployee'
|
|
99
112
|
import { ElMessage, ElTooltip, type TableInstance, type TreeNode } from 'element-plus'
|
|
@@ -107,41 +120,45 @@ interface Props<T extends IpageDataQuery, E extends IMdmEmployee> {
|
|
|
107
120
|
modelValue: boolean
|
|
108
121
|
title?: string
|
|
109
122
|
fetchData?: (data: T) => Promise<PageData<E>>
|
|
123
|
+
defalutQueryParam?: any
|
|
124
|
+
diagLogLoading?: boolean
|
|
110
125
|
}
|
|
111
126
|
|
|
112
127
|
const props = withDefaults(defineProps<Props<IMdmEmployeeQuery, IMdmEmployee>>(), {
|
|
113
128
|
title: '选择人员',
|
|
114
129
|
fetchData: EmployeeInfoApi.getMdmEmployeeListByIds,
|
|
130
|
+
defalutQueryParam: {},
|
|
131
|
+
diagLogLoading: false,
|
|
115
132
|
})
|
|
116
133
|
const [queryParam, resetQueryParam] = useResetRefHooks<IMdmEmployeeQuery>({
|
|
117
134
|
postIds: [],
|
|
135
|
+
orgIds: [],
|
|
136
|
+
deptIds: [],
|
|
118
137
|
emplyeeCode: '',
|
|
119
138
|
emplyeeName: '',
|
|
120
139
|
codeorname: '',
|
|
121
|
-
size:
|
|
140
|
+
size: 25,
|
|
122
141
|
current: 1,
|
|
123
142
|
})
|
|
124
143
|
watch(
|
|
125
144
|
() => props.modelValue,
|
|
126
145
|
(value) => {
|
|
146
|
+
resetSelectUserList()
|
|
147
|
+
resetUserList()
|
|
127
148
|
if (value) {
|
|
128
|
-
|
|
129
|
-
resetQueryParam()
|
|
130
|
-
handleQuery()
|
|
149
|
+
resetQuery()
|
|
131
150
|
}
|
|
132
151
|
},
|
|
133
152
|
)
|
|
134
|
-
const emit = defineEmits(['update:modelValue', 'success'])
|
|
153
|
+
const emit = defineEmits(['update:modelValue', 'update:diagLogLoading', 'success'])
|
|
135
154
|
const orgDeptTree = ref<IOrgDeptInfo[]>([])
|
|
136
155
|
const dialogVisible = useVModel(props, 'modelValue', emit)
|
|
137
|
-
const loading =
|
|
156
|
+
const loading = useVModel(props, 'diagLogLoading', emit)
|
|
138
157
|
const queryRef = ref()
|
|
139
158
|
const ref_table = ref<TableInstance>()
|
|
140
159
|
|
|
141
160
|
const ref_tree = ref()
|
|
142
|
-
const
|
|
143
|
-
return ref_table.value?.getSelectionRows()
|
|
144
|
-
})
|
|
161
|
+
const [selectUserList, resetSelectUserList] = useResetRefHooks<IMdmEmployee[]>([])
|
|
145
162
|
const [userList, resetUserList] = useResetRefHooks<PageData<IMdmEmployee>>({
|
|
146
163
|
records: [],
|
|
147
164
|
total: 0,
|
|
@@ -164,20 +181,49 @@ const renderTreeNode = (
|
|
|
164
181
|
ElTooltip,
|
|
165
182
|
{
|
|
166
183
|
content: data.name,
|
|
167
|
-
placement: 'top,
|
|
184
|
+
placement: 'top',
|
|
168
185
|
},
|
|
169
|
-
() => [h('span', {}, data.name)]
|
|
186
|
+
() => [h('span', {}, data.name)],
|
|
170
187
|
),
|
|
171
188
|
]
|
|
172
189
|
}
|
|
190
|
+
const selectRows = (selects: IMdmEmployee[], row?: IMdmEmployee) => {
|
|
191
|
+
if (row) {
|
|
192
|
+
//此时要先判断是选中还是取消选中
|
|
193
|
+
if (!judgeIsSel(selects, row)) {
|
|
194
|
+
selectUserList.value = selectUserList.value.filter((item) => item.code !== row.code)
|
|
195
|
+
} else {
|
|
196
|
+
selectUserList.value.push(row)
|
|
197
|
+
}
|
|
198
|
+
} else {
|
|
199
|
+
//此时是全选中或全取消
|
|
200
|
+
if (selects.length) {
|
|
201
|
+
const selCodes = selectUserList.value.map((item: IMdmEmployee) => item.code)
|
|
202
|
+
selects.forEach((item: IMdmEmployee) => {
|
|
203
|
+
if (!selCodes.includes(item.code)) {
|
|
204
|
+
selectUserList.value.push(item)
|
|
205
|
+
}
|
|
206
|
+
})
|
|
207
|
+
} else {
|
|
208
|
+
const delCodes = userList.value?.records.map((item: IMdmEmployee) => item.code)
|
|
209
|
+
selectUserList.value = selectUserList.value.filter((item) => !delCodes?.includes(item.code))
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
const judgeIsSel = (selects: IMdmEmployee[], row: IMdmEmployee) => {
|
|
214
|
+
return selects.some((item) => item.code === row.code)
|
|
215
|
+
}
|
|
173
216
|
const resetQuery = () => {
|
|
217
|
+
queryRef.value?.resetFields()
|
|
218
|
+
ref_tree.value?.setCheckedKeys([])
|
|
174
219
|
resetQueryParam()
|
|
175
|
-
|
|
220
|
+
nextTick(() => {
|
|
221
|
+
handleQuery()
|
|
222
|
+
})
|
|
176
223
|
}
|
|
177
224
|
const handleQuery = async () => {
|
|
178
225
|
try {
|
|
179
226
|
loading.value = true
|
|
180
|
-
resetUserList()
|
|
181
227
|
const deptIds = [] as string[]
|
|
182
228
|
const orgIds = [] as string[]
|
|
183
229
|
const select: IOrgDeptInfo[] = ref_tree.value?.getCheckedNodes()
|
|
@@ -191,22 +237,37 @@ const handleQuery = async () => {
|
|
|
191
237
|
item.mdmOrgId && !orgIds.includes(item.mdmOrgId) && deptIds.push(item.id!)
|
|
192
238
|
})
|
|
193
239
|
}
|
|
194
|
-
|
|
240
|
+
let params = JSON.parse(JSON.stringify(queryParam.value))
|
|
195
241
|
params.deptIds = deptIds
|
|
196
242
|
params.orgIds = orgIds
|
|
243
|
+
//需要合并默认参数
|
|
244
|
+
params = { ...props.defalutQueryParam, ...params }
|
|
197
245
|
userList.value = await props.fetchData(params)
|
|
246
|
+
//设置选中
|
|
247
|
+
const selCodes = selectUserList.value.map((item: IMdmEmployee) => item.code)
|
|
248
|
+
nextTick(() => {
|
|
249
|
+
userList.value.records.forEach((item: IMdmEmployee) => {
|
|
250
|
+
selCodes.includes(item.code) && ref_table.value?.toggleRowSelection(item, true)
|
|
251
|
+
})
|
|
252
|
+
})
|
|
253
|
+
queryParam.value.current = userList.value.current
|
|
198
254
|
} catch (error: any) {
|
|
199
255
|
ElMessage.error(error.msg || error.message)
|
|
200
256
|
} finally {
|
|
201
257
|
loading.value = false
|
|
202
258
|
}
|
|
203
259
|
}
|
|
260
|
+
const handleCloseTag = (row: IMdmEmployee) => {
|
|
261
|
+
selectUserList.value = selectUserList.value.filter((item) => item.code !== row.code)
|
|
262
|
+
//同时去除表格选中
|
|
263
|
+
const find = userList.value.records.find((item) => item.code === row.code)
|
|
264
|
+
find && ref_table.value?.toggleRowSelection(find, false)
|
|
265
|
+
}
|
|
204
266
|
const confirm = async () => {
|
|
205
|
-
if (!
|
|
267
|
+
if (!selectUserList.value.length) {
|
|
206
268
|
ElMessage.warning('未选择需要新增的人员!')
|
|
207
269
|
} else {
|
|
208
|
-
emit('success',
|
|
209
|
-
dialogVisible.value = false
|
|
270
|
+
emit('success', selectUserList.value)
|
|
210
271
|
}
|
|
211
272
|
}
|
|
212
273
|
onMounted(() => {
|