This commit is contained in:
@@ -47,17 +47,25 @@
|
||||
</div>
|
||||
</ElFormItem>
|
||||
|
||||
<ElFormItem label="密码" prop="password">
|
||||
<ElFormItem label="密码" prop="password" class="password-form-item">
|
||||
<ElInput
|
||||
v-model="form.password"
|
||||
type="password"
|
||||
show-password
|
||||
placeholder="请输入密码(8-32 位)"
|
||||
maxlength="32"
|
||||
placeholder="请输入密码(8~12位)"
|
||||
maxlength="12"
|
||||
autocomplete="new-password"
|
||||
aria-describedby="registration-password-rule"
|
||||
/>
|
||||
<div class="strength-bar" :class="strengthClass">
|
||||
<p id="registration-password-rule" class="password-hint">
|
||||
{{ NEW_LOGIN_PASSWORD_HINT }}
|
||||
</p>
|
||||
<div class="strength-bar" :class="strengthClass" aria-hidden="true">
|
||||
<i v-for="n in 3" :key="n" :class="{ active: passwordStrength >= n }" />
|
||||
</div>
|
||||
<span v-if="form.password" class="password-status" aria-live="polite">
|
||||
{{ passwordStrength === 3 ? '密码符合规则' : '密码尚未符合规则' }}
|
||||
</span>
|
||||
</ElFormItem>
|
||||
|
||||
<div class="form-grid">
|
||||
@@ -129,6 +137,12 @@
|
||||
type AgentDistributionRegistrationParams
|
||||
} from '@/api/modules/agentDistribution'
|
||||
import { regionData } from '@/utils/constants/regionData'
|
||||
import { getAgentRegistrationFailureMessage } from '@/utils/business/agentRegistrationError'
|
||||
import {
|
||||
createNewLoginPasswordRule,
|
||||
getNewLoginPasswordError,
|
||||
NEW_LOGIN_PASSWORD_HINT
|
||||
} from '@/utils/validation/loginPassword'
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
@@ -180,7 +194,7 @@
|
||||
code: [{ required: true, message: '请输入短信验证码', trigger: 'blur' }],
|
||||
password: [
|
||||
{ required: true, message: '请输入密码', trigger: 'blur' },
|
||||
{ min: 8, max: 32, message: '密码长度为 8-32 位', trigger: 'blur' }
|
||||
createNewLoginPasswordRule()
|
||||
],
|
||||
shop_name: [{ required: true, message: '请输入店铺名称', trigger: 'blur' }],
|
||||
username: [
|
||||
@@ -234,14 +248,7 @@
|
||||
const passwordStrength = computed(() => {
|
||||
const pwd = form.password
|
||||
if (!pwd) return 0
|
||||
let score = 0
|
||||
if (pwd.length >= 8) score += 1
|
||||
if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score += 1
|
||||
if (/\d/.test(pwd)) score += 1
|
||||
if (/[^A-Za-z0-9]/.test(pwd)) score += 1
|
||||
if (score >= 4) return 3
|
||||
if (score >= 2) return 2
|
||||
return 1
|
||||
return getNewLoginPasswordError(pwd) ? 1 : 3
|
||||
})
|
||||
|
||||
const strengthClass = computed(() => {
|
||||
@@ -267,9 +274,9 @@
|
||||
}
|
||||
|
||||
const handleSubmit = () => {
|
||||
if (!formRef.value) return
|
||||
if (!formRef.value || submitting.value) return
|
||||
formRef.value.validate(async (valid) => {
|
||||
if (!valid) return
|
||||
if (!valid || submitting.value) return
|
||||
submitting.value = true
|
||||
try {
|
||||
const params: AgentDistributionRegistrationParams = {
|
||||
@@ -291,10 +298,10 @@
|
||||
if (res.code === 0) {
|
||||
submitted.value = true
|
||||
} else {
|
||||
ElMessage.error('分销码不可用')
|
||||
ElMessage.error(getAgentRegistrationFailureMessage(res))
|
||||
}
|
||||
} catch {
|
||||
ElMessage.error('分销码不可用')
|
||||
} catch (error) {
|
||||
ElMessage.error(getAgentRegistrationFailureMessage(error))
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
@@ -315,19 +322,19 @@
|
||||
|
||||
<style scoped lang="scss">
|
||||
.agent-registration-page {
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
min-height: 100vh;
|
||||
padding: 48px 16px 64px;
|
||||
box-sizing: border-box;
|
||||
background: linear-gradient(160deg, #eef3fb 0%, #f7f9fd 40%, #eef3fb 100%);
|
||||
|
||||
.register-card {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
max-width: 520px;
|
||||
padding: 36px 36px 28px;
|
||||
box-sizing: border-box;
|
||||
background: #fff;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 8px 30px rgb(93 135 255 / 12%);
|
||||
@@ -375,13 +382,14 @@
|
||||
.strength-bar {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
width: 100%;
|
||||
margin-top: 8px;
|
||||
|
||||
i {
|
||||
flex: 1;
|
||||
height: 4px;
|
||||
border-radius: 2px;
|
||||
background: var(--el-border-color-lighter);
|
||||
border-radius: 2px;
|
||||
transition: background-color 0.2s ease;
|
||||
|
||||
&.active {
|
||||
@@ -398,6 +406,21 @@
|
||||
}
|
||||
}
|
||||
|
||||
.password-hint,
|
||||
.password-status {
|
||||
width: 100%;
|
||||
margin: 8px 0 0;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
color: var(--el-text-color-regular);
|
||||
}
|
||||
|
||||
.password-form-item :deep(.el-form-item__error) {
|
||||
position: static;
|
||||
width: 100%;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.region-cascader {
|
||||
width: 100%;
|
||||
}
|
||||
@@ -411,7 +434,7 @@
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
@media (width <= 768px) {
|
||||
padding: 24px 12px 40px;
|
||||
|
||||
.register-card {
|
||||
@@ -429,7 +452,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
@media (width <= 600px) {
|
||||
:global(.agent-registration-cascader-popper) {
|
||||
width: calc(100vw - 24px) !important;
|
||||
max-width: calc(100vw - 24px) !important;
|
||||
@@ -441,10 +464,10 @@
|
||||
}
|
||||
|
||||
:global(.agent-registration-cascader-popper .el-cascader-menu) {
|
||||
box-sizing: border-box;
|
||||
flex: 1 1 0;
|
||||
width: 0;
|
||||
min-width: 0 !important;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
:global(.agent-registration-cascader-popper .el-cascader-node__label) {
|
||||
|
||||
@@ -315,6 +315,7 @@
|
||||
import { fenToYuan, yuanToFen } from '@/utils/business/format'
|
||||
import { getErrorMessage, toVoucherKeyList } from '@/utils/business'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { requiresEmployeeCollectionActingReason } from '@/utils/business/employeeCollectionActing'
|
||||
import VoucherUpload from '@/components/business/VoucherUpload.vue'
|
||||
import {
|
||||
BILL_SOURCE_OPTIONS,
|
||||
@@ -404,28 +405,34 @@
|
||||
const dialogTitle = computed(() => (isResubmit.value ? '修改并重新提交核销申请' : '创建核销申请'))
|
||||
const voucherKeys = computed(() => toVoucherKeyList(form.payment_voucher_keys))
|
||||
|
||||
const currentAccountId = computed(() => userStore.info?.id)
|
||||
|
||||
const findBillOption = (billId: number): BillOption | undefined =>
|
||||
selectedBillOptions.value[billId] || candidateBills.value.find((bill) => bill.id === billId)
|
||||
const findBillOption = (billId: number): BillOption | undefined => {
|
||||
const selected = selectedBillOptions.value[billId]
|
||||
const candidate = candidateBills.value.find((bill) => bill.id === billId)
|
||||
if (!selected) return candidate
|
||||
return {
|
||||
...selected,
|
||||
debtor_account_id: candidate?.debtor_account_id ?? selected.debtor_account_id,
|
||||
debtor_snapshot: candidate?.debtor_snapshot ?? selected.debtor_snapshot
|
||||
}
|
||||
}
|
||||
|
||||
const getBillAssetIdentifier = (bill: BillOption): string => {
|
||||
const source = candidateBills.value.find((item) => item.id === bill.id) || bill
|
||||
return source.customer_snapshot?.asset_identifier || source.asset_identifier || '-'
|
||||
}
|
||||
|
||||
const getBillDebtorAccountId = (billId: number): number | null => {
|
||||
const option = findBillOption(billId)
|
||||
return option?.debtor_account_id ?? option?.debtor_snapshot?.account_id ?? null
|
||||
}
|
||||
const isActing = computed(() =>
|
||||
requiresEmployeeCollectionActingReason(
|
||||
selectedBillIds.value.map(findBillOption),
|
||||
userStore.info ?? {}
|
||||
)
|
||||
)
|
||||
|
||||
const isActing = computed(() => {
|
||||
if (!userStore.isSuperAdmin) return false
|
||||
if (!selectedBillIds.value.length) return true
|
||||
return selectedBillIds.value.some((billId) => {
|
||||
const debtorAccountId = getBillDebtorAccountId(billId)
|
||||
return debtorAccountId === null || debtorAccountId !== currentAccountId.value
|
||||
})
|
||||
watch(isActing, (acting) => {
|
||||
if (!acting) {
|
||||
form.acting_reason = ''
|
||||
formRef.value?.clearValidate('acting_reason')
|
||||
}
|
||||
})
|
||||
|
||||
const displayBills = computed<BillOption[]>(() => {
|
||||
@@ -703,8 +710,22 @@
|
||||
form.acting_reason = application.acting_reason || ''
|
||||
|
||||
const allocations = await fetchApplicationAllocations(application.id)
|
||||
allocations.forEach((allocation) => {
|
||||
const allocationBills = await Promise.all(
|
||||
allocations.map(async (allocation) => {
|
||||
const candidate = candidateBills.value.find((bill) => bill.id === allocation.bill_id)
|
||||
if (candidate) return candidate
|
||||
try {
|
||||
const res = await EmployeeCollectionService.getBillById(allocation.bill_id)
|
||||
return res.code === 0 && res.data?.bill ? toBillOption(res.data.bill) : undefined
|
||||
} catch {
|
||||
// 无法取得责任员工信息时保持原保守代办规则,不猜测为本人。
|
||||
return undefined
|
||||
}
|
||||
})
|
||||
)
|
||||
allocations.forEach((allocation, index) => {
|
||||
const option: BillOption = {
|
||||
...allocationBills[index],
|
||||
id: allocation.bill_id,
|
||||
source_no: allocation.bill_source_no,
|
||||
remaining_amount: Math.max(
|
||||
@@ -846,9 +867,9 @@
|
||||
external_transaction_no: form.external_transaction_no.trim(),
|
||||
payment_voucher_keys: toVoucherKeyList(form.payment_voucher_keys),
|
||||
remark: form.remark.trim() || undefined,
|
||||
allocations,
|
||||
acting_reason: isActing.value ? form.acting_reason.trim() : undefined
|
||||
allocations
|
||||
}
|
||||
if (isActing.value) payload.acting_reason = form.acting_reason.trim()
|
||||
|
||||
submitting.value = true
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user