|
|
@@ -142,6 +142,32 @@
|
|
|
class="w-full"
|
|
|
/>
|
|
|
</div>
|
|
|
+
|
|
|
+ <div v-if="!isEdit" class="field mt-4">
|
|
|
+ <label for="edit-password" class="font-medium text-sm mb-2 block">密码</label>
|
|
|
+ <Password
|
|
|
+ id="edit-password"
|
|
|
+ v-model="editForm.password"
|
|
|
+ :feedback="false"
|
|
|
+ toggleMask
|
|
|
+ class="w-full"
|
|
|
+ placeholder="请输入密码"
|
|
|
+ inputClass="w-full"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div v-if="!isEdit" class="field mt-4">
|
|
|
+ <label for="edit-confirmPassword" class="font-medium text-sm mb-2 block">确认密码</label>
|
|
|
+ <Password
|
|
|
+ id="edit-confirmPassword"
|
|
|
+ v-model="editForm.confirmPassword"
|
|
|
+ :feedback="false"
|
|
|
+ toggleMask
|
|
|
+ class="w-full"
|
|
|
+ placeholder="请再次输入密码"
|
|
|
+ inputClass="w-full"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
</div>
|
|
|
|
|
|
<template #footer>
|
|
|
@@ -163,6 +189,7 @@ import DataTable from 'primevue/datatable'
|
|
|
import Dialog from 'primevue/dialog'
|
|
|
import InputText from 'primevue/inputtext'
|
|
|
import InputNumber from 'primevue/inputnumber'
|
|
|
+import Password from 'primevue/password'
|
|
|
import { useConfirm } from 'primevue/useconfirm'
|
|
|
import { useToast } from 'primevue/usetoast'
|
|
|
import { listTeams, createTeam, updateTeam, deleteTeam } from '@/services/api'
|
|
|
@@ -190,7 +217,9 @@ const isEdit = ref(false)
|
|
|
const editForm = ref({
|
|
|
id: null,
|
|
|
name: null,
|
|
|
- commissionRate: null
|
|
|
+ commissionRate: null,
|
|
|
+ password: null,
|
|
|
+ confirmPassword: null
|
|
|
})
|
|
|
|
|
|
// 搜索表单
|
|
|
@@ -316,7 +345,9 @@ const openAddDialog = () => {
|
|
|
editForm.value = {
|
|
|
id: null,
|
|
|
name: null,
|
|
|
- commissionRate: null
|
|
|
+ commissionRate: null,
|
|
|
+ password: null,
|
|
|
+ confirmPassword: null
|
|
|
}
|
|
|
editDialog.value = true
|
|
|
}
|
|
|
@@ -327,13 +358,37 @@ const openEditDialog = (team) => {
|
|
|
editForm.value = {
|
|
|
id: team.id,
|
|
|
name: team.name || null,
|
|
|
- commissionRate: team.commissionRate || null
|
|
|
+ commissionRate: team.commissionRate || null,
|
|
|
+ password: null,
|
|
|
+ confirmPassword: null
|
|
|
}
|
|
|
editDialog.value = true
|
|
|
}
|
|
|
|
|
|
// 保存编辑
|
|
|
const saveEdit = async () => {
|
|
|
+ // 如果是新增且密码不匹配,显示错误
|
|
|
+ if (!isEdit.value && editForm.value.password !== editForm.value.confirmPassword) {
|
|
|
+ toast.add({
|
|
|
+ severity: 'error',
|
|
|
+ summary: '错误',
|
|
|
+ detail: '两次输入的密码不一致',
|
|
|
+ life: 3000
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果是新增且密码为空,显示错误
|
|
|
+ if (!isEdit.value && (!editForm.value.password || editForm.value.password.trim() === '')) {
|
|
|
+ toast.add({
|
|
|
+ severity: 'error',
|
|
|
+ summary: '错误',
|
|
|
+ detail: '密码不能为空',
|
|
|
+ life: 3000
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
editLoading.value = true
|
|
|
try {
|
|
|
// 过滤掉空值参数
|
|
|
@@ -344,6 +399,10 @@ const saveEdit = async () => {
|
|
|
if (editForm.value.commissionRate !== null && editForm.value.commissionRate !== '') {
|
|
|
formData.commissionRate = editForm.value.commissionRate
|
|
|
}
|
|
|
+ // 新增时添加密码字段
|
|
|
+ if (!isEdit.value && editForm.value.password) {
|
|
|
+ formData.password = editForm.value.password
|
|
|
+ }
|
|
|
|
|
|
if (isEdit.value) {
|
|
|
await updateTeam(editForm.value.id, formData)
|
|
|
@@ -448,4 +507,17 @@ onMounted(() => {
|
|
|
background-color: #d1d5db;
|
|
|
transform: scale(0.98);
|
|
|
}
|
|
|
+
|
|
|
+/* Password组件样式修复 */
|
|
|
+.p-password {
|
|
|
+ width: 100%;
|
|
|
+}
|
|
|
+
|
|
|
+.p-password .p-inputtext {
|
|
|
+ width: 100%;
|
|
|
+}
|
|
|
+
|
|
|
+.p-password .p-password-input {
|
|
|
+ width: 100%;
|
|
|
+}
|
|
|
</style>
|