升级
This commit is contained in:
@@ -113,6 +113,7 @@ function resetForm(row?: any) {
|
||||
phone: '',
|
||||
email: '',
|
||||
notes: '',
|
||||
initialPassword: '',
|
||||
}, row ?? {})
|
||||
} else {
|
||||
const currentYear = new Date().getFullYear()
|
||||
@@ -128,6 +129,7 @@ function resetForm(row?: any) {
|
||||
phone: '',
|
||||
email: '',
|
||||
notes: '',
|
||||
initialPassword: '',
|
||||
}, row ?? {})
|
||||
}
|
||||
}
|
||||
@@ -266,11 +268,22 @@ async function save() {
|
||||
ElMessage.warning(`请填写${numberLabel.value}和姓名。`)
|
||||
return
|
||||
}
|
||||
if ((!editingId.value || !form.userId) && String(form.initialPassword ?? '').length < 8) {
|
||||
ElMessage.warning('请设置至少 8 位初始密码,系统会同时创建同号登录账号。')
|
||||
return
|
||||
}
|
||||
try {
|
||||
const path = `/personnel/${active.value}`
|
||||
if (editingId.value) await http.put(`${path}/${editingId.value}`, form)
|
||||
else await http.post(path, form)
|
||||
ElMessage.success(editingId.value ? '档案已更新' : '档案已建立')
|
||||
const payload = { ...form }
|
||||
if (editingId.value && form.userId) {
|
||||
delete payload.initialPassword
|
||||
}
|
||||
if (editingId.value) {
|
||||
await http.put(`${path}/${editingId.value}`, payload)
|
||||
} else {
|
||||
await http.post(path, payload)
|
||||
}
|
||||
ElMessage.success(editingId.value ? '档案与登录账号已同步' : '档案和同号登录账号已建立')
|
||||
dialogVisible.value = false
|
||||
await load()
|
||||
} catch (error) {
|
||||
@@ -407,6 +420,13 @@ watch(active, async () => {
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="登录账号" width="105">
|
||||
<template #default="{ row }">
|
||||
<span class="table-status" :class="{ off: !row.userId }">
|
||||
{{ row.userId ? '已开通' : '未开通' }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="联系方式" min-width="170">
|
||||
<template #default="{ row }">{{ row.phone || row.email || '—' }}</template>
|
||||
</el-table-column>
|
||||
@@ -501,6 +521,23 @@ watch(active, async () => {
|
||||
<el-form-item label="电子邮箱"><el-input v-model="form.email" /></el-form-item>
|
||||
</div>
|
||||
<el-form-item label="备注"><el-input v-model="form.notes" type="textarea" :rows="3" /></el-form-item>
|
||||
<el-alert
|
||||
v-if="!editingId || !form.userId"
|
||||
type="info"
|
||||
:closable="false"
|
||||
:title="editingId
|
||||
? '该历史档案尚未开通账号,本次保存会以工号或学号补建登录账号。'
|
||||
: '保存档案后,系统会以工号或学号作为登录账号,并自动分配对应角色。'"
|
||||
/>
|
||||
<el-form-item v-if="!editingId || !form.userId" label="初始密码" required>
|
||||
<el-input
|
||||
v-model="form.initialPassword"
|
||||
type="password"
|
||||
show-password
|
||||
autocomplete="new-password"
|
||||
placeholder="至少 8 位,仅用于创建密码哈希"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
|
||||
Reference in New Issue
Block a user