提交
This commit is contained in:
1 parent
427bcb1551
commit
31b04575e2
247 files changed
+39284
-20367
No files matched your search
@@ -22,16 +22,21 @@
|
||||
<el-form-item label="下发对象">
|
||||
<el-select
|
||||
v-model="searchForm.issuedUserId"
|
||||
placeholder="全部"
|
||||
placeholder="输入姓名检索"
|
||||
filterable
|
||||
remote
|
||||
reserve-keyword
|
||||
clearable
|
||||
:loading="userOptionsLoading"
|
||||
:remote-method="remoteSearchUsers"
|
||||
style="width: 100%"
|
||||
@visible-change="onUserSelectVisible"
|
||||
>
|
||||
<el-option
|
||||
v-for="opt in userOptions"
|
||||
:key="opt.value"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
v-for="u in userOptions"
|
||||
:key="u.id"
|
||||
:label="formatUserOptionLabel(u)"
|
||||
:value="u.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -328,15 +333,21 @@
|
||||
<el-form-item label="下发用户" prop="issuedUserId">
|
||||
<el-select
|
||||
v-model="batchIssueForm.issuedUserId"
|
||||
placeholder="请选择用户"
|
||||
placeholder="输入姓名检索"
|
||||
filterable
|
||||
remote
|
||||
reserve-keyword
|
||||
clearable
|
||||
:loading="userOptionsLoading"
|
||||
:remote-method="remoteSearchUsers"
|
||||
style="width: 100%"
|
||||
@visible-change="onUserSelectVisible"
|
||||
>
|
||||
<el-option
|
||||
v-for="opt in userOptions"
|
||||
:key="opt.value"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
v-for="u in userOptions"
|
||||
:key="u.id"
|
||||
:label="formatUserOptionLabel(u)"
|
||||
:value="u.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -412,15 +423,21 @@
|
||||
<el-form-item v-if="formData.issued === 1" label="下发用户" prop="issuedUserId">
|
||||
<el-select
|
||||
v-model="formData.issuedUserId"
|
||||
placeholder="请选择用户"
|
||||
placeholder="输入姓名检索"
|
||||
filterable
|
||||
remote
|
||||
reserve-keyword
|
||||
clearable
|
||||
:loading="userOptionsLoading"
|
||||
:remote-method="remoteSearchUsers"
|
||||
style="width: 100%"
|
||||
@visible-change="onUserSelectVisible"
|
||||
>
|
||||
<el-option
|
||||
v-for="opt in userOptions"
|
||||
:key="opt.value"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
v-for="u in userOptions"
|
||||
:key="u.id"
|
||||
:label="formatUserOptionLabel(u)"
|
||||
:value="u.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -479,7 +496,7 @@
|
||||
fetchCreateSampleCode,
|
||||
fetchUpdateSampleCode,
|
||||
fetchDeleteSampleCode,
|
||||
fetchUserOptions,
|
||||
fetchUserList,
|
||||
fetchBatchGenerateSampleCodes,
|
||||
fetchBatchIssueSampleCodes,
|
||||
fetchBatchRevokeSampleCodes
|
||||
@@ -572,7 +589,35 @@
|
||||
const batchIssueRules = {
|
||||
issuedUserId: [{ required: true, message: '请选择下发用户', trigger: 'change' }]
|
||||
}
|
||||
const userOptions = ref<Array<{ label: string; value: string }>>([])
|
||||
const userOptions = ref<Api.User.UserItem[]>([])
|
||||
const userOptionsLoading = ref(false)
|
||||
|
||||
function formatUserOptionLabel(u: Api.User.UserItem) {
|
||||
const parts = [u.nickName || '']
|
||||
if (u.userNo) parts.push(u.userNo)
|
||||
return parts.filter(Boolean).join(' · ')
|
||||
}
|
||||
|
||||
async function remoteSearchUsers(query: string) {
|
||||
userOptionsLoading.value = true
|
||||
try {
|
||||
const res = await fetchUserList({
|
||||
page: 1,
|
||||
pageSize: 50,
|
||||
keyword: query?.trim() || undefined,
|
||||
status: '1'
|
||||
})
|
||||
userOptions.value = res.list || []
|
||||
} catch {
|
||||
userOptions.value = []
|
||||
} finally {
|
||||
userOptionsLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function onUserSelectVisible(visible: boolean) {
|
||||
if (visible) void remoteSearchUsers('')
|
||||
}
|
||||
|
||||
const formData = reactive({
|
||||
sampleCode: '',
|
||||
@@ -648,22 +693,13 @@
|
||||
editingId.value = null
|
||||
}
|
||||
|
||||
async function loadUserOptions() {
|
||||
if (userOptions.value.length) return
|
||||
try {
|
||||
userOptions.value = await fetchUserOptions()
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
async function handleAdd() {
|
||||
isEdit.value = false
|
||||
dialogTitle.value = '新增样本编码'
|
||||
resetForm()
|
||||
dialogVisible.value = true
|
||||
formRef.value?.clearValidate?.()
|
||||
await loadUserOptions()
|
||||
void remoteSearchUsers('')
|
||||
}
|
||||
|
||||
async function handleEdit(row: Api.BizSampleCode.SampleCodeItem) {
|
||||
@@ -680,7 +716,7 @@
|
||||
formData.remark = row.remark || ''
|
||||
dialogVisible.value = true
|
||||
formRef.value?.clearValidate?.()
|
||||
await loadUserOptions()
|
||||
void remoteSearchUsers('')
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
@@ -689,7 +725,7 @@
|
||||
try {
|
||||
const issueUserOpt =
|
||||
formData.issued === 1
|
||||
? userOptions.value.find((u) => u.value === formData.issuedUserId)
|
||||
? userOptions.value.find((u) => u.id === formData.issuedUserId)
|
||||
: undefined
|
||||
const payload = {
|
||||
sampleCode: formData.sampleCode.trim(),
|
||||
@@ -698,7 +734,7 @@
|
||||
issuedUserId: formData.issued === 1 ? formData.issuedUserId || undefined : null,
|
||||
issuedUserName:
|
||||
formData.issued === 1
|
||||
? (formData.issuedUserName || issueUserOpt?.label || '').trim() || undefined
|
||||
? (formData.issuedUserName || issueUserOpt?.nickName || '').trim() || undefined
|
||||
: null,
|
||||
issuedTime: formData.issuedTime || undefined,
|
||||
orderNum: formData.orderNum,
|
||||
@@ -799,7 +835,7 @@
|
||||
if (!selectedRows.value.length) return
|
||||
batchIssueForm.issuedUserId = ''
|
||||
batchIssueVisible.value = true
|
||||
await loadUserOptions()
|
||||
void remoteSearchUsers('')
|
||||
}
|
||||
|
||||
async function handleBatchIssue() {
|
||||
@@ -807,11 +843,11 @@
|
||||
batchIssueLoading.value = true
|
||||
try {
|
||||
const ids = selectedRows.value.map((r) => r.id)
|
||||
const userOpt = userOptions.value.find((u) => u.value === batchIssueForm.issuedUserId)
|
||||
const userOpt = userOptions.value.find((u) => u.id === batchIssueForm.issuedUserId)
|
||||
await fetchBatchIssueSampleCodes({
|
||||
ids,
|
||||
issuedUserId: batchIssueForm.issuedUserId,
|
||||
issuedUserName: userOpt?.label || undefined
|
||||
issuedUserName: userOpt?.nickName || undefined
|
||||
})
|
||||
batchIssueVisible.value = false
|
||||
selectedRows.value = []
|
||||
@@ -830,8 +866,7 @@
|
||||
{ debounce: 300, deep: true }
|
||||
)
|
||||
|
||||
onMounted(async () => {
|
||||
await loadUserOptions()
|
||||
onMounted(() => {
|
||||
loadData()
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -11,16 +11,21 @@
|
||||
<el-form-item label="下发对象">
|
||||
<el-select
|
||||
v-model="searchForm.issuedUserId"
|
||||
placeholder="全部"
|
||||
placeholder="输入姓名检索"
|
||||
filterable
|
||||
remote
|
||||
reserve-keyword
|
||||
clearable
|
||||
:loading="userOptionsLoading"
|
||||
:remote-method="remoteSearchUsers"
|
||||
style="width: 100%"
|
||||
@visible-change="onUserSelectVisible"
|
||||
>
|
||||
<el-option
|
||||
v-for="opt in userOptions"
|
||||
:key="opt.value"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
v-for="u in userOptions"
|
||||
:key="u.id"
|
||||
:label="formatUserOptionLabel(u)"
|
||||
:value="u.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -292,15 +297,21 @@
|
||||
<el-form-item label="下发用户" prop="issuedUserId">
|
||||
<el-select
|
||||
v-model="batchIssueForm.issuedUserId"
|
||||
placeholder="请选择用户"
|
||||
placeholder="输入姓名检索"
|
||||
filterable
|
||||
remote
|
||||
reserve-keyword
|
||||
clearable
|
||||
:loading="userOptionsLoading"
|
||||
:remote-method="remoteSearchUsers"
|
||||
style="width: 100%"
|
||||
@visible-change="onUserSelectVisible"
|
||||
>
|
||||
<el-option
|
||||
v-for="opt in userOptions"
|
||||
:key="opt.value"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
v-for="u in userOptions"
|
||||
:key="u.id"
|
||||
:label="formatUserOptionLabel(u)"
|
||||
:value="u.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -365,15 +376,21 @@
|
||||
<el-form-item v-if="formData.issued === 1" label="下发用户" prop="issuedUserId">
|
||||
<el-select
|
||||
v-model="formData.issuedUserId"
|
||||
placeholder="请选择用户"
|
||||
placeholder="输入姓名检索"
|
||||
filterable
|
||||
remote
|
||||
reserve-keyword
|
||||
clearable
|
||||
:loading="userOptionsLoading"
|
||||
:remote-method="remoteSearchUsers"
|
||||
style="width: 100%"
|
||||
@visible-change="onUserSelectVisible"
|
||||
>
|
||||
<el-option
|
||||
v-for="opt in userOptions"
|
||||
:key="opt.value"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
v-for="u in userOptions"
|
||||
:key="u.id"
|
||||
:label="formatUserOptionLabel(u)"
|
||||
:value="u.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -432,7 +449,7 @@
|
||||
fetchCreateCollectionProtocolNo,
|
||||
fetchUpdateCollectionProtocolNo,
|
||||
fetchDeleteCollectionProtocolNo,
|
||||
fetchUserOptions,
|
||||
fetchUserList,
|
||||
fetchBatchGenerateProtocolNos,
|
||||
fetchBatchIssueProtocolNos,
|
||||
fetchBatchRevokeProtocolNos
|
||||
@@ -520,15 +537,43 @@
|
||||
const batchIssueRules = {
|
||||
issuedUserId: [{ required: true, message: '请选择下发用户', trigger: 'change' }]
|
||||
}
|
||||
const userOptions = ref<Array<{ label: string; value: string }>>([])
|
||||
const userOptions = ref<Api.User.UserItem[]>([])
|
||||
const userOptionsLoading = ref(false)
|
||||
|
||||
function formatUserOptionLabel(u: Api.User.UserItem) {
|
||||
const parts = [u.nickName || '']
|
||||
if (u.userNo) parts.push(u.userNo)
|
||||
return parts.filter(Boolean).join(' · ')
|
||||
}
|
||||
|
||||
async function remoteSearchUsers(query: string) {
|
||||
userOptionsLoading.value = true
|
||||
try {
|
||||
const res = await fetchUserList({
|
||||
page: 1,
|
||||
pageSize: 50,
|
||||
keyword: query?.trim() || undefined,
|
||||
status: '1'
|
||||
})
|
||||
userOptions.value = res.list || []
|
||||
} catch {
|
||||
userOptions.value = []
|
||||
} finally {
|
||||
userOptionsLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function onUserSelectVisible(visible: boolean) {
|
||||
if (visible) void remoteSearchUsers('')
|
||||
}
|
||||
|
||||
function resolveIssuedUserName(row: Api.BizCollectionProtocolNo.ProtocolNoItem): string {
|
||||
const name = (row.issuedUserName || '').trim()
|
||||
if (name) return name
|
||||
const uid = (row.issuedUserId || '').trim()
|
||||
if (!uid) return '-'
|
||||
const opt = userOptions.value.find((u) => u.value === uid)
|
||||
return (opt?.label || '').trim() || '-'
|
||||
const opt = userOptions.value.find((u) => u.id === uid)
|
||||
return (opt?.nickName || '').trim() || '-'
|
||||
}
|
||||
|
||||
const formData = reactive({
|
||||
@@ -606,7 +651,7 @@
|
||||
resetForm()
|
||||
dialogVisible.value = true
|
||||
formRef.value?.clearValidate?.()
|
||||
await loadUserOptions()
|
||||
void remoteSearchUsers('')
|
||||
}
|
||||
|
||||
async function handleEdit(row: Api.BizCollectionProtocolNo.ProtocolNoItem) {
|
||||
@@ -622,7 +667,7 @@
|
||||
formData.remark = row.remark || ''
|
||||
dialogVisible.value = true
|
||||
formRef.value?.clearValidate?.()
|
||||
await loadUserOptions()
|
||||
void remoteSearchUsers('')
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
@@ -631,7 +676,7 @@
|
||||
try {
|
||||
const issueUserOpt =
|
||||
formData.issued === 1
|
||||
? userOptions.value.find((u) => u.value === formData.issuedUserId)
|
||||
? userOptions.value.find((u) => u.id === formData.issuedUserId)
|
||||
: undefined
|
||||
const payload = {
|
||||
protocolNo: formData.protocolNo.trim(),
|
||||
@@ -639,7 +684,7 @@
|
||||
issuedUserId: formData.issued === 1 ? formData.issuedUserId || undefined : null,
|
||||
issuedUserName:
|
||||
formData.issued === 1
|
||||
? (formData.issuedUserName || issueUserOpt?.label || '').trim() || undefined
|
||||
? (formData.issuedUserName || issueUserOpt?.nickName || '').trim() || undefined
|
||||
: null,
|
||||
issuedTime: formData.issuedTime || undefined,
|
||||
orderNum: formData.orderNum,
|
||||
@@ -740,7 +785,7 @@
|
||||
if (!selectedRows.value.length) return
|
||||
batchIssueForm.issuedUserId = ''
|
||||
batchIssueVisible.value = true
|
||||
await loadUserOptions()
|
||||
void remoteSearchUsers('')
|
||||
}
|
||||
|
||||
async function handleBatchIssue() {
|
||||
@@ -748,11 +793,11 @@
|
||||
batchIssueLoading.value = true
|
||||
try {
|
||||
const ids = selectedRows.value.map((r) => r.id)
|
||||
const userOpt = userOptions.value.find((u) => u.value === batchIssueForm.issuedUserId)
|
||||
const userOpt = userOptions.value.find((u) => u.id === batchIssueForm.issuedUserId)
|
||||
await fetchBatchIssueProtocolNos({
|
||||
ids,
|
||||
issuedUserId: batchIssueForm.issuedUserId,
|
||||
issuedUserName: userOpt?.label || undefined
|
||||
issuedUserName: userOpt?.nickName || undefined
|
||||
})
|
||||
batchIssueVisible.value = false
|
||||
selectedRows.value = []
|
||||
@@ -762,14 +807,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function loadUserOptions() {
|
||||
if (userOptions.value.length) return
|
||||
try {
|
||||
userOptions.value = await fetchUserOptions()
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
// 输入检索条件时自动搜索(防抖 300ms)
|
||||
watchDebounced(
|
||||
searchForm,
|
||||
@@ -780,8 +817,7 @@
|
||||
{ debounce: 300, deep: true }
|
||||
)
|
||||
|
||||
onMounted(async () => {
|
||||
await loadUserOptions()
|
||||
onMounted(() => {
|
||||
loadData()
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in new issue
Block a user