1. 优化医生、诊所的设置
Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CI / CI OK (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled

This commit is contained in:
李琦
2026-07-03 10:41:52 +08:00
parent 949167217f
commit 92e145f366
25 changed files with 1616 additions and 105 deletions

View File

@@ -0,0 +1,335 @@
<script setup lang="ts">
import { computed, nextTick, ref, watch } from 'vue';
import { useVModel } from '@vueuse/core';
import { Avatar, Empty, Input, Popover, Spin } from 'ant-design-vue';
import { getDoctorOptionApi } from '#/views/system/store/api';
import { resolveAvatarUrl } from '#/views/system/store-input/utils/inputUser';
defineOptions({
name: 'DoctorPicker',
inheritAttrs: false,
});
const props = defineProps<{
value?: number;
storeId?: number;
disabled?: boolean;
}>();
const emits = defineEmits<{
'update:value': [value: number | undefined];
}>();
const mValue = useVModel(props, 'value', emits, { passive: true });
type DoctorOption = {
id: number;
name: string;
avatar?: string;
mobile?: string;
depart_name?: string;
};
const open = ref(false);
const loading = ref(false);
const searchKeyword = ref('');
const options = ref<DoctorOption[]>([]);
const searchInputRef = ref<InstanceType<typeof Input> | null>(null);
const isDisabled = computed(() => props.disabled || !props.storeId);
/** 按关键词过滤医生列表 */
function filterDoctorOptions(keyword: string, list: DoctorOption[]) {
const q = keyword.trim().toLowerCase();
if (!q) return list;
return list.filter((item) => {
const name = (item.name || '').toLowerCase();
const mobile = (item.mobile || '').toLowerCase();
const depart = (item.depart_name || '').toLowerCase();
const idText = String(item.id);
return (
name.includes(q) ||
mobile.includes(q) ||
depart.includes(q) ||
idText.includes(q)
);
});
}
const filteredOptions = computed(() =>
filterDoctorOptions(searchKeyword.value, options.value),
);
const selectedOption = computed(() =>
options.value.find((item) => item.id === mValue.value),
);
/** 按诊所加载医生选项id 为 su_id */
async function loadOptions() {
if (!props.storeId) {
options.value = [];
return;
}
loading.value = true;
try {
options.value = (await getDoctorOptionApi(props.storeId)) || [];
} finally {
loading.value = false;
}
}
function selectOption(item: DoctorOption) {
mValue.value = item.id;
open.value = false;
searchKeyword.value = '';
}
function clearSelection() {
mValue.value = undefined;
}
function onOpenChange(next: boolean) {
if (isDisabled.value) return;
open.value = next;
if (next) {
searchKeyword.value = '';
loadOptions();
nextTick(() => searchInputRef.value?.focus?.());
}
}
/** 诊所变更时重载列表,并清除不在新诊所下的选中项 */
watch(
() => props.storeId,
async (storeId, prevStoreId) => {
if (storeId === prevStoreId) return;
await loadOptions();
if (!mValue.value) return;
const stillValid = options.value.some((item) => item.id === mValue.value);
if (!stillValid) {
mValue.value = undefined;
}
},
{ immediate: true },
);
watch(
() => props.disabled,
(disabled) => {
if (disabled) open.value = false;
},
);
</script>
<template>
<Popover
:open="open"
trigger="click"
placement="bottomLeft"
overlay-class-name="doctor-picker-popover"
@open-change="onOpenChange"
>
<template #content>
<div class="doctor-panel">
<Input
ref="searchInputRef"
v-model:value="searchKeyword"
allow-clear
placeholder="搜索医生姓名、手机号、科室"
class="doctor-search"
/>
<Spin :spinning="loading">
<div v-if="filteredOptions.length" class="doctor-grid">
<button
v-for="item in filteredOptions"
:key="item.id"
type="button"
class="doctor-card"
:class="{ active: item.id === mValue }"
@click="selectOption(item)"
>
<Avatar :src="resolveAvatarUrl(item.avatar)" :size="36">
{{ (item.name || '?').charAt(0) }}
</Avatar>
<div class="doctor-card-name" :title="item.name">
{{ item.name || '-' }}
</div>
<div v-if="item.mobile" class="doctor-card-sub">{{ item.mobile }}</div>
<div v-if="item.depart_name" class="doctor-card-sub">
{{ item.depart_name }}
</div>
</button>
</div>
<Empty v-else description="该诊所下无匹配医生" class="doctor-empty" />
</Spin>
</div>
</template>
<div class="doctor-trigger" :class="{ disabled: isDisabled }">
<div v-if="selectedOption" class="doctor-selected-card">
<Avatar :src="resolveAvatarUrl(selectedOption.avatar)" :size="36">
{{ (selectedOption.name || '?').charAt(0) }}
</Avatar>
<div class="doctor-selected-info">
<div class="doctor-selected-name">{{ selectedOption.name }}</div>
<div class="doctor-selected-sub">
{{ selectedOption.mobile || `su_id: ${selectedOption.id}` }}
</div>
</div>
<span
v-if="!isDisabled"
class="doctor-clear-btn"
title="清除"
@click.stop="clearSelection"
>
×
</span>
</div>
<div v-else-if="mValue" class="doctor-selected-card">
<div class="doctor-selected-info">
<div class="doctor-selected-name">医生 su_id: {{ mValue }}</div>
</div>
<span
v-if="!isDisabled"
class="doctor-clear-btn"
title="清除"
@click.stop="clearSelection"
>
×
</span>
</div>
<div v-else class="doctor-trigger-placeholder">
{{ storeId ? '请选择关联医生(可选)' : '请先选择所属诊所' }}
</div>
</div>
</Popover>
</template>
<style scoped lang="scss">
@use './picker-card-theme.scss' as theme;
.doctor-trigger {
width: 100%;
}
.doctor-trigger.disabled {
cursor: not-allowed;
opacity: 0.65;
}
.doctor-trigger:not(.disabled) {
cursor: pointer;
}
.doctor-selected-card {
@include theme.picker-selected-card;
}
.doctor-selected-info {
flex: 1;
min-width: 0;
}
.doctor-selected-name {
font-size: 14px;
color: #1d2129;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.doctor-selected-sub {
font-size: 12px;
color: #86909c;
margin-top: 2px;
}
.doctor-clear-btn {
@include theme.picker-clear-btn;
}
.doctor-trigger-placeholder {
@include theme.picker-trigger-placeholder;
}
.dark {
.doctor-selected-card {
@include theme.picker-selected-card-dark-props;
}
.doctor-selected-name {
@include theme.picker-text-primary-dark;
}
.doctor-selected-sub {
@include theme.picker-text-secondary-dark;
}
.doctor-clear-btn {
@include theme.picker-clear-dark-props;
}
.doctor-trigger-placeholder {
@include theme.picker-placeholder-dark-props;
}
}
</style>
<style lang="scss">
@use './picker-card-theme.scss' as theme;
.doctor-picker-popover {
.ant-popover-inner {
padding: 12px;
}
.doctor-panel {
width: 540px;
max-width: 86vw;
}
.doctor-search {
margin-bottom: 10px;
}
.doctor-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
gap: 8px;
max-height: 300px;
overflow-y: auto;
padding: 2px;
}
.doctor-card {
@include theme.picker-card-base;
}
.doctor-card-name {
@include theme.picker-card-name;
}
.doctor-card-sub {
@include theme.picker-card-sub;
}
.doctor-empty {
margin: 16px 0;
}
}
.dark .doctor-picker-popover {
.doctor-card {
@include theme.picker-card-dark-props;
}
.doctor-card-name {
@include theme.picker-text-primary-dark;
}
.doctor-card-sub {
@include theme.picker-text-secondary-dark;
}
}
</style>

View File

@@ -0,0 +1,308 @@
<script setup lang="ts">
import { computed, nextTick, onMounted, ref, watch } from 'vue';
import { useVModel } from '@vueuse/core';
import { Avatar, Empty, Input, Popover, Spin } from 'ant-design-vue';
import { getStoreOption } from '#/views/system/store/api';
import { resolveAvatarUrl } from '#/views/system/store-input/utils/inputUser';
defineOptions({
name: 'StorePicker',
inheritAttrs: false,
});
const props = defineProps<{
value?: number;
disabled?: boolean;
}>();
const emits = defineEmits<{
'update:value': [value: number | undefined];
}>();
const mValue = useVModel(props, 'value', emits, { passive: true });
type StoreOption = {
id: number;
name: string;
pic?: string;
mobile?: string;
};
const open = ref(false);
const loading = ref(false);
const searchKeyword = ref('');
const options = ref<StoreOption[]>([]);
const searchInputRef = ref<InstanceType<typeof Input> | null>(null);
/** 按关键词过滤诊所列表 */
function filterStoreOptions(keyword: string, list: StoreOption[]) {
const q = keyword.trim().toLowerCase();
if (!q) return list;
return list.filter((item) => {
const name = (item.name || '').toLowerCase();
const mobile = (item.mobile || '').toLowerCase();
const idText = String(item.id);
return name.includes(q) || mobile.includes(q) || idText.includes(q);
});
}
const filteredOptions = computed(() =>
filterStoreOptions(searchKeyword.value, options.value),
);
const selectedOption = computed(() =>
options.value.find((item) => item.id === mValue.value),
);
/** 加载诊所选项(含 pic、mobile 供卡片展示) */
async function loadOptions() {
loading.value = true;
try {
options.value = (await getStoreOption({})) || [];
} finally {
loading.value = false;
}
}
function selectOption(item: StoreOption) {
mValue.value = item.id;
open.value = false;
searchKeyword.value = '';
}
function clearSelection() {
mValue.value = undefined;
}
function onOpenChange(next: boolean) {
if (props.disabled) return;
open.value = next;
if (next) {
searchKeyword.value = '';
if (!options.value.length) {
loadOptions();
}
nextTick(() => searchInputRef.value?.focus?.());
}
}
watch(
() => props.disabled,
(disabled) => {
if (disabled) open.value = false;
},
);
onMounted(() => {
loadOptions();
});
</script>
<template>
<Popover
:open="open"
trigger="click"
placement="bottomLeft"
overlay-class-name="store-picker-popover"
@open-change="onOpenChange"
>
<template #content>
<div class="store-panel">
<Input
ref="searchInputRef"
v-model:value="searchKeyword"
allow-clear
placeholder="搜索诊所名称、电话、ID"
class="store-search"
/>
<Spin :spinning="loading">
<div v-if="filteredOptions.length" class="store-grid">
<button
v-for="item in filteredOptions"
:key="item.id"
type="button"
class="store-card"
:class="{ active: item.id === mValue }"
@click="selectOption(item)"
>
<Avatar :src="resolveAvatarUrl(item.pic)" :size="36" shape="square">
{{ (item.name || '?').charAt(0) }}
</Avatar>
<div class="store-card-name" :title="item.name">
{{ item.name || '-' }}
</div>
<div v-if="item.mobile" class="store-card-sub">{{ item.mobile }}</div>
<div class="store-card-sub">ID: {{ item.id }}</div>
</button>
</div>
<Empty v-else description="无匹配诊所" class="store-empty" />
</Spin>
</div>
</template>
<div class="store-trigger" :class="{ disabled: disabled }">
<div v-if="selectedOption" class="store-selected-card">
<Avatar :src="resolveAvatarUrl(selectedOption.pic)" :size="36" shape="square">
{{ (selectedOption.name || '?').charAt(0) }}
</Avatar>
<div class="store-selected-info">
<div class="store-selected-name">{{ selectedOption.name }}</div>
<div class="store-selected-sub">
{{ selectedOption.mobile || `ID: ${selectedOption.id}` }}
</div>
</div>
<span
v-if="!disabled"
class="store-clear-btn"
title="清除"
@click.stop="clearSelection"
>
×
</span>
</div>
<div v-else-if="mValue" class="store-selected-card">
<div class="store-selected-info">
<div class="store-selected-name">诊所 #{{ mValue }}</div>
</div>
<span
v-if="!disabled"
class="store-clear-btn"
title="清除"
@click.stop="clearSelection"
>
×
</span>
</div>
<div v-else class="store-trigger-placeholder">请选择诊所</div>
</div>
</Popover>
</template>
<style scoped lang="scss">
@use './picker-card-theme.scss' as theme;
.store-trigger {
width: 100%;
}
.store-trigger.disabled {
cursor: not-allowed;
opacity: 0.65;
}
.store-trigger:not(.disabled) {
cursor: pointer;
}
.store-selected-card {
@include theme.picker-selected-card;
}
.store-selected-info {
flex: 1;
min-width: 0;
}
.store-selected-name {
font-size: 14px;
color: #1d2129;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.store-selected-sub {
font-size: 12px;
color: #86909c;
margin-top: 2px;
}
.store-clear-btn {
@include theme.picker-clear-btn;
}
.store-trigger-placeholder {
@include theme.picker-trigger-placeholder;
}
.dark {
.store-selected-card {
@include theme.picker-selected-card-dark-props;
}
.store-selected-name {
@include theme.picker-text-primary-dark;
}
.store-selected-sub {
@include theme.picker-text-secondary-dark;
}
.store-clear-btn {
@include theme.picker-clear-dark-props;
}
.store-trigger-placeholder {
@include theme.picker-placeholder-dark-props;
}
}
</style>
<style lang="scss">
@use './picker-card-theme.scss' as theme;
.store-picker-popover {
.ant-popover-inner {
padding: 12px;
}
.store-panel {
width: 540px;
max-width: 86vw;
}
.store-search {
margin-bottom: 10px;
}
.store-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
gap: 8px;
max-height: 300px;
overflow-y: auto;
padding: 2px;
}
.store-card {
@include theme.picker-card-base;
}
.store-card-name {
@include theme.picker-card-name;
}
.store-card-sub {
@include theme.picker-card-sub;
}
.store-empty {
margin: 16px 0;
}
}
.dark .store-picker-popover {
.store-card {
@include theme.picker-card-dark-props;
}
.store-card-name {
@include theme.picker-text-primary-dark;
}
.store-card-sub {
@include theme.picker-text-secondary-dark;
}
}
</style>

View File

@@ -0,0 +1,68 @@
/**
* 与后端 format_price / PrescriptionService 中药计价口径一致
*/
export function parsePriceValue(value: unknown): number {
if (value === null || value === undefined || value === '') {
return 0;
}
const num = Number(value);
return Number.isFinite(num) ? num : 0;
}
/**
* 与后端 format_price 一致:第三位小数非 0 则分位进 1再保留两位小数
*/
export function formatPriceLikeBackend(value: unknown): number {
const price = parsePriceValue(value);
let milli = Math.round(price * 1000);
if (milli % 10 > 0) {
milli += 10;
}
milli -= milli % 10;
return Math.round((milli / 1000) * 100) / 100;
}
/** 模拟 PHP bcmul 在指定 scale 下向零截断 */
function bcmulScale(a: unknown, b: unknown, scale: number): number {
const product = parsePriceValue(a) * parsePriceValue(b);
const factor = 10 ** scale;
return Math.trunc(product * factor) / factor;
}
/** 模拟 PHP bcadd 在指定 scale 下向零截断 */
function bcaddScale(a: number, b: number, scale: number): number {
const sum = a + b;
const factor = 10 ** scale;
return Math.trunc(sum * factor) / factor;
}
type ChineseDrugLine = {
number?: number | string;
price?: number | string;
};
/**
* 中药商品总价(与 PrescriptionService::createChineseReprice 一致)
* 每行bcmul(dosage, bcmul(price, number, 3), 3),累加后 format_price
*/
export function calculateChineseProductPriceLikeBackend(
drugs: ChineseDrugLine[],
dosage = 7,
): number {
if (!drugs?.length) {
return 0;
}
const dose = parsePriceValue(dosage);
let total = 0;
for (const drug of drugs) {
const linePerDose = bcmulScale(drug.price, drug.number ?? 1, 3);
const lineTotal = bcmulScale(dose, linePerDose, 3);
total = bcaddScale(total, lineTotal, 3);
}
return formatPriceLikeBackend(total);
}
export function formatPriceDisplay(value: unknown): string {
return formatPriceLikeBackend(value).toFixed(2);
}

View File

@@ -18,6 +18,14 @@ export async function updateSpecialPrescription(data: Record<string, any>) {
return requestClient.post<any>(`${prefix}update`, data);
}
/** 上下架状态切换(列表 Tag 点击) */
export async function updateSpecialPrescriptionStatus(data: {
id: number;
status: number;
}) {
return requestClient.post<any>(`${prefix}update-status`, data);
}
export async function deleteSpecialPrescription(data: Record<string, any>) {
return requestClient.post<any>(`${prefix}delete`, data);
}

View File

@@ -0,0 +1,104 @@
<script lang="ts" setup>
import { ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { Alert, message } from 'ant-design-vue';
import {
getSpecialPrescriptionInfo,
updateSpecialPrescription,
} from '../api';
import { buildSpecialPrescriptionPayload } from '../utils/buildPayload';
import ChineseDrugEditor from './ChineseDrugEditor.vue';
const gridApi = ref<any>();
const detailRes = ref<Record<string, any> | null>(null);
const prescriptionType = ref<'chinese' | 'west' | 'granular'>('chinese');
const chineseDrugEditorRef = ref<InstanceType<typeof ChineseDrugEditor>>();
const dosage = ref(7);
const dayDosage = ref(2);
const [Modal, modalApi] = useVbenModal({
fullscreenButton: true,
draggable: true,
onCancel() {
modalApi.close();
},
onConfirm: async () => {
if (!detailRes.value) {
return;
}
if (prescriptionType.value !== 'chinese') {
message.warning('当前仅支持编辑中药类型药方');
return;
}
const drugs = chineseDrugEditorRef.value?.getDrugsPayload() || [];
if (drugs.length === 0) {
message.warning('请至少添加一种中药');
return;
}
const payload = buildSpecialPrescriptionPayload(detailRes.value, {
drugs,
dosage: dosage.value,
day_dosage: dayDosage.value,
rule_type: 1,
package_method_id: 2,
});
modalApi.setState({ loading: true, confirmLoading: true });
updateSpecialPrescription(payload)
.then(() => {
message.success('药方保存成功');
gridApi.value?.reload();
modalApi.close();
})
.finally(() => {
modalApi.setState({ loading: false, confirmLoading: false });
});
},
onOpenChange(isOpen: boolean) {
if (isOpen) {
const { values, gridApi: grid } = modalApi.getData<Record<string, any>>();
gridApi.value = grid;
detailRes.value = null;
getSpecialPrescriptionInfo(values.id).then((res: any) => {
if (!res) return;
detailRes.value = res;
prescriptionType.value = res.prescription_type || 'chinese';
if (res.prescription_type === 'chinese' && res.prescription_detail?.length) {
const first = res.prescription_detail[0];
chineseDrugEditorRef.value?.loadDrugs(
res.prescription_detail,
first?.dosage ?? 7,
first?.consumption ?? 2,
);
dosage.value = first?.dosage ?? 7;
dayDosage.value = first?.consumption ?? 2;
} else {
chineseDrugEditorRef.value?.loadDrugs([], 7, 2);
}
});
} else {
detailRes.value = null;
}
},
});
</script>
<template>
<Modal title="编辑药方" class="w-[80%]">
<div v-if="prescriptionType === 'chinese'">
<ChineseDrugEditor
ref="chineseDrugEditorRef"
v-model:dosage="dosage"
v-model:day-dosage="dayDosage"
/>
</div>
<Alert
v-else
type="info"
show-icon
message="当前特色方为西药/颗粒药类型,后台暂不支持单独编辑药方。"
/>
</Modal>
</template>

View File

@@ -66,9 +66,15 @@ export const gridOptions: VxeGridProps<RowType> = {
{ field: 'price_per_dose', align: 'left', title: '每剂价格', width: 100 },
{ field: 'sales_count', align: 'left', title: '销量', width: 80 },
{ field: 'sort', align: 'left', title: '排序', width: 80 },
{ field: 'status_txt', align: 'left', title: '状态', width: 80 },
{
field: 'status',
align: 'left',
title: '状态',
width: 90,
slots: { default: 'status' },
},
{ field: 'created_at', title: '创建时间', width: 180 },
{ type: 'html', title: '操作', slots: { default: 'action' }, width: 160 },
{ type: 'html', title: '操作', slots: { default: 'action' }, width: 220 },
],
keepSource: true,
pagerConfig: {},

View File

@@ -10,12 +10,17 @@ import { Button, Image, message, Tag } from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { TableAction } from '#/components/table-action';
import { deleteSpecialPrescription } from './api';
import {
deleteSpecialPrescription,
updateSpecialPrescriptionStatus,
} from './api';
import EditPrescriptionModal from './components/EditPrescriptionModal.vue';
import SpecialPrescriptionModal from './components/modal.vue';
import { formOptions as searchFormOptions } from './config/search';
import { gridOptions } from './config/table';
const hasTopTableDropDownActions = ref(false);
const statusLoadingId = ref<number | null>(null);
const gridEvents: VxeGridListeners<any> = {
checkboxChange() {
@@ -38,6 +43,10 @@ const [FormModal, formModalApi] = useVbenModal({
connectedComponent: SpecialPrescriptionModal,
});
const [EditPrescriptionModalComp, editPrescriptionModalApi] = useVbenModal({
connectedComponent: EditPrescriptionModal,
});
const showModal = (data = {}, isUpdate = false) => {
formModalApi.setData({
values: data,
@@ -47,6 +56,30 @@ const showModal = (data = {}, isUpdate = false) => {
formModalApi.open();
};
const showEditPrescriptionModal = (row: any) => {
editPrescriptionModalApi.setData({
values: row,
gridApi,
});
editPrescriptionModalApi.open();
};
/** 点击状态 Tag 切换上下架 */
const toggleStatus = async (row: any) => {
if (statusLoadingId.value === row.id) {
return;
}
const newStatus = row.status === 1 ? 0 : 1;
statusLoadingId.value = row.id;
try {
await updateSpecialPrescriptionStatus({ id: row.id, status: newStatus });
message.success(newStatus === 1 ? '已上架' : '已下架');
gridApi.query();
} finally {
statusLoadingId.value = null;
}
};
const deleteApi = (row: any) => {
let ids: (string | number)[] = [];
if (row) {
@@ -64,6 +97,7 @@ const deleteApi = (row: any) => {
<template>
<Page auto-content-height title="特色方管理">
<FormModal />
<EditPrescriptionModalComp />
<div class="p-4">
<TableAction
@@ -94,6 +128,16 @@ const deleteApi = (row: any) => {
</Tag>
</template>
<template #status="{ row }">
<Tag
:color="row.status === 1 ? 'success' : 'default'"
class="cursor-pointer select-none"
@click="toggleStatus(row)"
>
{{ row.status === 1 ? '上架' : '下架' }}
</Tag>
</template>
<template #toolbar-buttons>
<Button
v-if="hasTopTableDropDownActions"
@@ -112,6 +156,11 @@ const deleteApi = (row: any) => {
label: '编辑',
onClick: () => showModal(row, true),
},
{
label: '编辑药方',
ifShow: row.prescription_sub_type === 1,
onClick: () => showEditPrescriptionModal(row),
},
{
label: '删除',
color: 'error',

View File

@@ -0,0 +1,35 @@
/**
* 组装特色方提交 payload编辑药方时需原样带回 meta 字段,避免清空介绍图等
*/
export function buildSpecialPrescriptionPayload(
detail: Record<string, any>,
drugOverrides?: {
drugs?: any[];
dosage?: number;
day_dosage?: number;
rule_type?: number;
package_method_id?: number;
},
) {
const payload: Record<string, any> = {
id: detail.id,
name: detail.name || '',
category_id: detail.category_id,
cover_image: detail.cover_image || '',
tags: Array.isArray(detail.tags) ? detail.tags : [],
price_per_dose: detail.price_per_dose ?? 0,
sales_count: detail.sales_count ?? 0,
status: detail.status ?? 1,
prescription_type: detail.prescription_type || 'chinese',
intro_text: detail.intro_text || '',
introduction_images: detail.introduction_images || [],
};
if (drugOverrides?.drugs?.length) {
payload.drugs = drugOverrides.drugs;
payload.dosage = drugOverrides.dosage ?? 7;
payload.day_dosage = drugOverrides.day_dosage ?? 2;
payload.rule_type = drugOverrides.rule_type ?? 1;
payload.package_method_id = drugOverrides.package_method_id ?? 2;
}
return payload;
}

View File

@@ -89,6 +89,7 @@ import {
formatPriceDiscountLabel,
normalizeQuickOptions,
} from '#/utils/pricePercentAdjust';
import { calculateChineseProductPriceLikeBackend } from '#/utils/formatPrice';
interface Patient {
id: number;
@@ -419,11 +420,11 @@ const totalProductCost = computed(() => {
if (currentDrugs.value.length === 0) {
return 0;
}
// 如果是中药的时候,计算总价格
// 中药:与后端 PrescriptionService / format_price 口径一致
if (activeCategory.value === 1) {
return currentDrugs.value.reduce(
(sum, drug) => sum + drug.price * (drug.number || 1) * dosage.value,
0,
return calculateChineseProductPriceLikeBackend(
currentDrugs.value,
dosage.value,
);
}
return currentDrugs.value.reduce(
@@ -2186,34 +2187,39 @@ watch(
<RadioButton :value="2" class="w-1/2">历史</RadioButton>
</RadioGroup>
<div
v-for="patient in patients"
:key="patient.user_patient.id"
:class="{ active: selectPatientId === patient.id }"
class="patient-card"
@click="selectPatient(patient)"
v-for="(patient, index) in patients"
:key="index"
>
<div class="patient-info">
<h3 class="flex flex-wrap items-center gap-2">
{{ patient.user_patient.name }}
<Tag
v-if="patient.special_prescription_patient_record"
:color="patient.special_prescription_patient_record.status === 0 ? 'orange' : 'default'"
>
特色方{{
patient.special_prescription_patient_record.status === 0
? '·待导入'
: ''
}}
</Tag>
</h3>
<p class="phone">{{ patient.user_patient.mobile }}</p>
<p class="text-sm text-gray-500">
推广员{{ patient.salesperson?.nick_name || '无' }}
</p>
<span :class="getRegisterStatus(patient.status)" class="status">{{
getRegisterStatus(patient.status)
}}</span>
{{ patient.updated_at }}
<div
v-if="patient.user_patient"
:class="{ active: selectPatientId === patient.id }"
class="patient-card"
@click="selectPatient(patient)"
>
<div class="patient-info">
<h3 class="flex flex-wrap items-center gap-2">
{{ patient.user_patient.name }}
<Tag
v-if="patient.special_prescription_patient_record"
:color="patient.special_prescription_patient_record.status === 0 ? 'orange' : 'default'"
>
特色方{{
patient.special_prescription_patient_record.status === 0
? '·待导入'
: ''
}}
</Tag>
</h3>
<p class="phone">{{ patient.user_patient.mobile }}</p>
<p class="text-sm text-gray-500">
推广员{{ patient.salesperson?.nick_name || '无' }}
</p>
<span :class="getRegisterStatus(patient.status)" class="status">{{
getRegisterStatus(patient.status)
}}</span>
{{ patient.updated_at }}
</div>
</div>
</div>
</div>

View File

@@ -71,3 +71,13 @@ export async function updateDoctorCredentialsApi(data: Record<string, any>) {
export async function updateDoctorSignatureByAdminApi(data: Record<string, any>) {
return requestClient.post<any>(`${prefix}update-signature-by-admin`, data);
}
/** 超管/系统管理员更新医生 service_user 账号资料 */
export async function updateDoctorServiceUserApi(data: {
su_id: number;
mobile?: string;
nickname?: string;
avatar?: string;
}) {
return requestClient.post<any>(`${prefix}update-service-user`, data);
}

View File

@@ -1,6 +1,7 @@
<script lang="ts" setup>
import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { useUserStore } from '@vben/stores';
import {
Alert,
Avatar,
@@ -33,8 +34,11 @@ import {
getDoctorCardPatientsApi,
getDoctorCardPrescriptionsApi,
updateDoctorCredentialsApi,
updateDoctorServiceUserApi,
updateDoctorSignatureByAdminApi,
} from '../api/card';
import { canEditDoctorServiceUser } from '#/views/system/admin/_shared/platform-admin-role';
import { resolveAvatarUrl } from '#/views/system/store-input/utils/inputUser';
const gridApi = ref<any>();
const doctorId = ref(0);
@@ -52,6 +56,19 @@ const overviewForm = ref({
intro: '',
});
const serviceUserForm = ref({
avatar: '',
mobile: '',
nickname: '',
});
const userStore = useUserStore();
const canEditProfile = computed(() =>
canEditDoctorServiceUser(userStore.userInfo),
);
const savingServiceUser = ref(false);
const credentialsForm = ref({
card_up: '',
card_down: '',
@@ -82,6 +99,27 @@ const orderTotal = ref(0);
const stats = computed(() => cardData.value?.stats_summary ?? {});
function serviceUserStatusText(status?: number) {
const map: Record<number, string> = {
[-1]: '已停用',
0: '待激活',
1: '待审核',
2: '已认证',
3: '已拒绝',
};
return map[Number(status)] ?? '未知';
}
function serviceUserRoleText(role?: number) {
const map: Record<number, string> = {
1: '医生',
2: '药师',
3: '导医',
4: '客服',
};
return map[Number(role)] ?? '-';
}
const [QrCodeModal, QrCodeModalApi] = useVbenModal({
connectedComponent: DoctorQrCodePreview,
});
@@ -118,6 +156,11 @@ async function loadCard() {
good_at: res?.doctor_info?.good_at ?? '',
intro: res?.doctor_info?.intro ?? '',
};
serviceUserForm.value = {
avatar: res?.doctor_info?.avatar ?? '',
mobile: res?.service_user?.mobile ?? '',
nickname: res?.service_user?.nickname ?? '',
};
credentialsForm.value = {
card_up: res?.identity?.card_up ?? '',
card_down: res?.identity?.card_down ?? '',
@@ -133,6 +176,7 @@ async function loadCard() {
}
async function saveOverview() {
if (!canEditProfile.value) return;
savingOverview.value = true;
try {
const res = await updateDoctor({
@@ -152,7 +196,30 @@ async function saveOverview() {
}
}
async function saveServiceUser() {
if (!canEditProfile.value || !suId.value) return;
savingServiceUser.value = true;
try {
const res = await updateDoctorServiceUserApi({
su_id: suId.value,
mobile: serviceUserForm.value.mobile,
nickname: serviceUserForm.value.nickname,
avatar: serviceUserForm.value.avatar,
});
if (res?.sync && !res.sync.admin_found) {
message.warning('账号资料已保存,但该医生未开通 PC 后台,管理员头像未同步');
} else {
message.success('微信平台账号保存成功');
}
await loadCard();
gridApi.value?.reload?.();
} finally {
savingServiceUser.value = false;
}
}
async function saveCredentials() {
if (!canEditProfile.value) return;
savingCredentials.value = true;
try {
await updateDoctorCredentialsApi({
@@ -391,23 +458,28 @@ const [Modal, modalApi] = useVbenModal({
<Row :gutter="32">
<Col :span="6" class="flex flex-col items-center border-r border-gray-200 dark:border-slate-700">
<div class="text-gray-500 dark:text-slate-400 mb-3 text-sm">医生头像</div>
<AvatarUpload v-model:value="overviewForm.avatar" class="shadow-sm rounded-full overflow-hidden" />
<AvatarUpload
v-if="canEditProfile"
v-model:value="overviewForm.avatar"
class="shadow-sm rounded-full overflow-hidden"
/>
<Avatar v-else :src="resolveAvatarUrl(overviewForm.avatar)" :size="80" />
</Col>
<Col :span="18">
<Form layout="vertical" class="grid grid-cols-2 gap-x-6">
<Form.Item label="医生姓名" class="mb-4">
<Input v-model:value="overviewForm.name" placeholder="请输入姓名" size="large" />
<Input v-model:value="overviewForm.name" :disabled="!canEditProfile" placeholder="请输入姓名" size="large" />
</Form.Item>
<Form.Item label="手机号码" class="mb-4">
<Input v-model:value="overviewForm.mobile" placeholder="请输入手机号码" size="large" />
<Input v-model:value="overviewForm.mobile" :disabled="!canEditProfile" placeholder="请输入手机号码" size="large" />
</Form.Item>
<Form.Item label="专业擅长" class="col-span-2 mb-4">
<Input.TextArea v-model:value="overviewForm.good_at" :rows="2" placeholder="填写医生擅长的领域..." />
<Input.TextArea v-model:value="overviewForm.good_at" :disabled="!canEditProfile" :rows="2" placeholder="填写医生擅长的领域..." />
</Form.Item>
<Form.Item label="个人简介" class="col-span-2 mb-4">
<Input.TextArea v-model:value="overviewForm.intro" :rows="3" placeholder="填写医生简介..." />
<Input.TextArea v-model:value="overviewForm.intro" :disabled="!canEditProfile" :rows="3" placeholder="填写医生简介..." />
</Form.Item>
<div class="col-span-2 text-right mt-2">
<div v-if="canEditProfile" class="col-span-2 text-right mt-2">
<Button type="primary" size="large" :loading="savingOverview" @click="saveOverview">
保存基本信息
</Button>
@@ -417,6 +489,59 @@ const [Modal, modalApi] = useVbenModal({
</Row>
</div>
<h3 class="text-base font-semibold text-gray-800 dark:text-slate-200 mb-4 mt-8">
微信平台账号 (service_user)
</h3>
<div class="bg-gray-50 dark:bg-[#1f242e] p-5 rounded-lg border border-gray-100 dark:border-slate-700 mb-6 transition-colors">
<Row :gutter="32">
<Col :span="6" class="flex flex-col items-center border-r border-gray-200 dark:border-slate-700">
<div class="text-gray-500 dark:text-slate-400 mb-3 text-sm">账号头像</div>
<AvatarUpload
v-if="canEditProfile"
v-model:value="serviceUserForm.avatar"
class="shadow-sm rounded-full overflow-hidden"
/>
<Avatar v-else :src="resolveAvatarUrl(serviceUserForm.avatar)" :size="80" />
</Col>
<Col :span="18">
<Form v-if="canEditProfile" layout="vertical" class="grid grid-cols-2 gap-x-6">
<Form.Item label="登录手机号" class="mb-4">
<Input v-model:value="serviceUserForm.mobile" placeholder="service_user.mobile" size="large" />
</Form.Item>
<Form.Item label="昵称" class="mb-4">
<Input v-model:value="serviceUserForm.nickname" placeholder="service_user.nickname" size="large" />
</Form.Item>
<Form.Item label="账号状态" class="mb-4">
<Tag :color="cardData?.service_user?.status === 2 ? 'success' : 'default'">
{{ serviceUserStatusText(cardData?.service_user?.status) }}
</Tag>
</Form.Item>
<Form.Item label="账号角色" class="mb-4">
<span>{{ serviceUserRoleText(cardData?.service_user?.role) }}</span>
</Form.Item>
<div class="col-span-2 text-right mt-2">
<Button type="primary" size="large" :loading="savingServiceUser" @click="saveServiceUser">
保存微信平台账号
</Button>
</div>
</Form>
<Descriptions v-else bordered :column="2" size="middle">
<Descriptions.Item label="登录手机号">{{ serviceUserForm.mobile || '-' }}</Descriptions.Item>
<Descriptions.Item label="昵称">{{ serviceUserForm.nickname || '-' }}</Descriptions.Item>
<Descriptions.Item label="账号状态">
<Tag :color="cardData?.service_user?.status === 2 ? 'success' : 'default'">
{{ serviceUserStatusText(cardData?.service_user?.status) }}
</Tag>
</Descriptions.Item>
<Descriptions.Item label="账号角色">
{{ serviceUserRoleText(cardData?.service_user?.role) }}
</Descriptions.Item>
<Descriptions.Item label="su_id">{{ cardData?.service_user?.id ?? suId }}</Descriptions.Item>
</Descriptions>
</Col>
</Row>
</div>
<h3 class="text-base font-semibold text-gray-800 dark:text-slate-200 mb-4 mt-8">系统档案 (只读)</h3>
<Descriptions bordered :column="3" size="middle" class="bg-white dark:bg-[#18181c] shadow-sm rounded-lg overflow-hidden border-gray-200 dark:border-slate-700">
<Descriptions.Item label="医生ID">{{ cardData?.doctor_info?.id }}</Descriptions.Item>
@@ -439,7 +564,7 @@ const [Modal, modalApi] = useVbenModal({
<h3 class="text-base font-semibold text-gray-800 dark:text-slate-200">资质证书管理</h3>
<p class="text-sm text-gray-500 dark:text-slate-400 mt-1">请上传清晰无遮挡的证件扫描件或照片</p>
</div>
<Button type="primary" :loading="savingCredentials" @click="saveCredentials">
<Button v-if="canEditProfile" type="primary" :loading="savingCredentials" @click="saveCredentials">
保存全部资质
</Button>
</div>

View File

@@ -5,7 +5,7 @@ import { computed, ref } from 'vue';
import { Page, useVbenModal } from '@vben/common-ui';
import { Button, Image, message } from 'ant-design-vue';
import { Button, Image, message, Avatar } from 'ant-design-vue';
import { useVbenForm } from '#/adapter/form';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
@@ -26,6 +26,7 @@ import { formatAddressDisplay } from '#/util/address-index';
import { createAdminGridOptions } from './table-config';
import { getRoleMeta } from './role-meta';
import DoctorCardModal from '#/views/doctor/doctor/components/DoctorCardModal.vue';
import { resolveAvatarUrl } from '#/views/system/store-input/utils/inputUser';
function formatAdminRegion(row: {
province_id?: number;
@@ -255,6 +256,50 @@ const copyToClipboard = async (text: string) => {
<template #region="{ row }">
{{ formatAdminRegion(row) }}
</template>
<template #store_name="{ row }">
<div v-if="row.store?.name" class="flex items-center gap-2">
<Avatar
:src="resolveAvatarUrl(row.store?.pic)"
:size="28"
shape="square"
>
{{ (row.store.name || '?').charAt(0) }}
</Avatar>
<div class="min-w-0">
<div class="truncate">{{ row.store.name }}</div>
<div class="text-xs text-gray-400">ID: {{ row.store_id }}</div>
</div>
</div>
<span v-else-if="row.store_id">诊所 #{{ row.store_id }}</span>
<span v-else>-</span>
</template>
<template #doctor_profile="{ row }">
<Button
v-if="row.doctor_profile?.name || row.doctor_id"
type="link"
size="small"
class="!h-auto !p-0"
@click="openDoctorCard(row)"
>
<div class="flex items-center gap-2 text-left">
<Avatar
:src="resolveAvatarUrl(row.doctor_profile?.avatar)"
:size="28"
>
{{ (row.doctor_profile?.name || '?').charAt(0) }}
</Avatar>
<div class="min-w-0">
<div class="truncate text-[#1677ff]">
{{ row.doctor_profile?.name || `su_id: ${row.doctor_id}` }}
</div>
<div v-if="row.doctor_profile?.mobile" class="text-xs text-gray-400">
{{ row.doctor_profile.mobile }}
</div>
</div>
</div>
</Button>
<span v-else>-</span>
</template>
<template #login_account="{ row }">
<span v-if="row.login_account">
<Button

View File

@@ -3,7 +3,6 @@ import type { VbenFormProps } from '#/adapter/form';
import { useUserStore } from '@vben/stores';
import { z } from '#/adapter/form';
import { getStoreOption } from '#/views/system/store/api';
import { getSupplierOption } from '#/views/system/supplier/api';
import type { AdminFormType } from './role-meta';
@@ -180,21 +179,7 @@ export function createAdminModalFormProps(
if (formType === 'clinic' || formType === 'doctor' || formType === 'pharmacist') {
schema.push({
component: 'ApiSelect',
componentProps: {
allowClear: true,
filterOption: (input: string, option: { label?: string }) =>
(option?.label ?? '').toLowerCase().includes(input.toLowerCase()),
showSearch: true,
afterFetch: (data: { id: number; name: string }[]) => {
return data.map((item) => ({
label: item.name,
value: item.id,
}));
},
api: getStoreOption,
placeholder: '请选择诊所',
},
component: 'StorePicker',
fieldName: 'store_id',
formItemClass: 'col-span-6',
label: '所属诊所',
@@ -204,12 +189,18 @@ export function createAdminModalFormProps(
if (formType === 'doctor') {
schema.push({
component: 'VbenInput',
componentProps: {
placeholder: '关联医生档案 ID可选建议在医生管理中创建',
component: 'DoctorPicker',
componentProps: (values: { store_id?: number }) => ({
storeId: values.store_id,
}),
dependencies: {
triggerFields: ['store_id'],
componentProps: (values: { store_id?: number }) => ({
storeId: values.store_id,
}),
},
fieldName: 'doctor_id',
label: '医生ID',
label: '关联医生',
formItemClass: 'col-span-6',
});
}

View File

@@ -0,0 +1,20 @@
export type PlatformAdminUserInfo = {
role_id?: number;
roles?: { id?: number };
} | null | undefined;
/** 超级管理员、系统管理员role_id 1/2 */
export function isPlatformSuperAdmin(userInfo: PlatformAdminUserInfo): boolean {
const roleId = Number(userInfo?.role_id ?? userInfo?.roles?.id);
return roleId === 1 || roleId === 2;
}
/** 是否可编辑医生卡片中的 service_user 及资料写操作 */
export function canEditDoctorServiceUser(userInfo: PlatformAdminUserInfo): boolean {
return isPlatformSuperAdmin(userInfo);
}
/** 是否可管理诊所银行卡报备入口 */
export function canManageStoreBankCard(userInfo: PlatformAdminUserInfo): boolean {
return isPlatformSuperAdmin(userInfo);
}

View File

@@ -18,6 +18,13 @@ interface RowType {
store_id?: number;
doctor_id?: number;
pharmacist_id?: number;
store?: { id?: number; name?: string; pic?: string; mobile?: string };
doctor_profile?: {
su_id?: number;
name?: string;
avatar?: string;
mobile?: string;
} | null;
province_id?: number;
city_id?: number;
}
@@ -55,11 +62,21 @@ function buildColumns(formType: AdminFormType) {
}
if (formType === 'clinic' || formType === 'doctor' || formType === 'pharmacist') {
cols.push({ field: 'store_id', title: '诊所ID', width: 100 });
cols.push({
field: 'store_id',
title: '所属诊所',
minWidth: 180,
slots: { default: 'store_name' },
});
}
if (formType === 'doctor') {
cols.push({ field: 'doctor_id', title: '医生ID', width: 100 });
cols.push({
field: 'doctor_id',
title: '关联医生',
minWidth: 180,
slots: { default: 'doctor_profile' },
});
}
if (formType === 'pharmacist') {

View File

@@ -38,11 +38,13 @@ import DrugPriceModal from '#/views/system/store/components/DrugPriceModal.vue';
import StoreExternalFieldModal from '#/views/system/store/components/StoreExternalFieldModal.vue';
import BankCardReportModal from '#/views/system/store-bank-card/components/BankCardReportModal.vue';
import BankCardStatusModal from '#/views/system/store-bank-card/components/BankCardStatusModal.vue';
import BankCardStoreEditModal from '#/views/system/store-bank-card/components/BankCardStoreEditModal.vue';
import { getStoreBankCardReportDetail } from '#/views/system/store-bank-card/api';
// 导入搜索表单配置
import { formOptions } from './config/search';
// 导入表格配置
import { gridOptions } from './config/table';
import { canManageStoreBankCard } from '#/views/system/admin/_shared/platform-admin-role';
const userStore = useUserStore();
const router = useRouter();
@@ -52,6 +54,10 @@ const isPlatformAdmin = computed(() => {
return userStore?.userInfo?.roles?.user_type === 2;
});
const canManageBankCard = computed(() =>
canManageStoreBankCard(userStore.userInfo),
);
// 跳转到审核页面
const goToAudit = () => {
router.push('/system/store-input/audit');
@@ -126,6 +132,19 @@ const [BankCardStatusModalComponent, bankCardStatusModalApi] = useVbenModal({
connectedComponent: BankCardStatusModal,
});
const [BankCardStoreEditModalComponent, bankCardStoreEditModalApi] = useVbenModal({
connectedComponent: BankCardStoreEditModal,
});
const openBankCardStoreEdit = (row: any) => {
bankCardStoreEditModalApi.setData({
storeId: row.id,
storeName: row.name,
gridApi,
});
bankCardStoreEditModalApi.open();
};
const openBankCardReport = async (row: any, update = false) => {
let report = null;
try {
@@ -175,6 +194,7 @@ function getBankCardReportTagText(row: any) {
}
function handleBankCardReportColumnClick(row: any) {
if (!canManageBankCard.value) return;
const status = Number(row.bank_card_report_status ?? 0);
if (status === 1 || status === 2) {
openBankCardStatus(row);
@@ -354,6 +374,7 @@ const batchSyncDrugPrice = () => {
<FormModal />
<BankCardReportModalComponent />
<BankCardStatusModalComponent />
<BankCardStoreEditModalComponent />
<QrCodePreviewModal />
<DrugPriceModalComponent />
<BindConsultationModalComponent />
@@ -420,6 +441,7 @@ const batchSyncDrugPrice = () => {
<StoreConfigTogglesCell
:row="row"
section="switches"
:can-manage-bank-card="canManageBankCard"
:get-bank-card-report-tag-color="getBankCardReportTagColor"
:get-bank-card-report-tag-text="getBankCardReportTagText"
:on-shipping-free="updateShippingFree"
@@ -435,6 +457,7 @@ const batchSyncDrugPrice = () => {
section="business"
show-insurance
show-salesperson-see-price
:can-manage-bank-card="canManageBankCard"
:get-bank-card-report-tag-color="getBankCardReportTagColor"
:get-bank-card-report-tag-text="getBankCardReportTagText"
:on-shipping-free="updateShippingFree"
@@ -579,6 +602,14 @@ const batchSyncDrugPrice = () => {
icon: 'ant-design:credit-card-outlined',
size: 'small',
auth: ['Super Admin', 'Admin'],
onClick: () => openBankCardStoreEdit(row),
},
{
label: '修改报备银行卡',
type: 'link',
icon: 'ant-design:file-protect-outlined',
size: 'small',
auth: ['Super Admin', 'Admin'],
onClick: () => openBankCardReport(row, true),
},
]"

View File

@@ -13,7 +13,10 @@ import {
reportStoreBankCard,
updateStoreBankCard,
} from '../api';
import { USE_TYPE_TRANSFER } from '../config/constants';
import {
LABEL_UPDATE_REPORT_BANK_CARD,
USE_TYPE_TRANSFER,
} from '../config/constants';
import { bankCardReportFormProps } from '../config/form';
const mode = ref<'report' | 'update'>('report');
@@ -115,7 +118,9 @@ const [Modal, modalApi] = useVbenModal({
use_type: USE_TYPE_TRANSFER,
});
message.success(
isRejectedResubmit.value ? '银行卡报备已重新提交' : '银行卡修改已提交',
isRejectedResubmit.value
? '银行卡报备已重新提交'
: '报备银行卡修改已提交',
);
} else {
await reportStoreBankCard({
@@ -174,7 +179,8 @@ const [Modal, modalApi] = useVbenModal({
});
const modalTitle = computed(() => {
const prefix = mode.value === 'report' ? '银行卡报备' : '修改银行卡';
const prefix =
mode.value === 'report' ? '银行卡报备' : LABEL_UPDATE_REPORT_BANK_CARD;
return storeName.value ? `${prefix} - ${storeName.value}` : prefix;
});

View File

@@ -0,0 +1,226 @@
<script lang="ts" setup>
import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { Alert, Form, FormItem, Input, message, Select, Spin } from 'ant-design-vue';
import {
getSelectableBankCards,
getStoreBankCardReportDetail,
} from '../api';
import {
LABEL_UPDATE_STORE_BANK_CARD,
STORE_BANK_ACCOUNT_TYPE_OPTIONS,
} from '../config/constants';
import {
buildCurrentStoreReportOption,
mapReportPayloadToStoreBankForm,
mergeSelectableBankCardOptions,
type BankCardSelectableOption,
} from '../utils/bankCardImport';
import { getStoreInfo, updateStoreBankInfoApi } from '#/views/system/store/api';
const storeId = ref(0);
const storeName = ref('');
const loading = ref(false);
const saving = ref(false);
const gridApiRef = ref<any>(null);
const selectableOptions = ref<BankCardSelectableOption[]>([]);
const selectedCardKey = ref<string | undefined>();
const importedFromReport = ref(false);
const formState = ref({
bank_user_name: '',
bank_card: '',
bank_name: '',
bank_account_type: 2,
bank_no: '',
});
const modalTitle = computed(() =>
storeName.value
? `${LABEL_UPDATE_STORE_BANK_CARD} - ${storeName.value}`
: LABEL_UPDATE_STORE_BANK_CARD,
);
/** 下拉搜索过滤 */
function filterSelectableOption(input: string, option: { label?: string }) {
return (option?.label ?? '').toLowerCase().includes(input.toLowerCase());
}
/** 加载可导入的已报备银行卡列表 */
async function loadSelectableCards() {
if (!storeId.value) {
selectableOptions.value = [];
return;
}
try {
const [selectableRes, detailRes] = await Promise.all([
getSelectableBankCards(storeId.value),
getStoreBankCardReportDetail(storeId.value).catch(() => null),
]);
const currentOption = buildCurrentStoreReportOption(detailRes);
selectableOptions.value = mergeSelectableBankCardOptions(
currentOption,
selectableRes?.options ?? [],
);
} catch {
selectableOptions.value = [];
}
}
/** 加载门店当前银行卡信息 */
async function loadStoreBankInfo() {
if (!storeId.value) return;
loading.value = true;
try {
const info = await getStoreInfo(storeId.value);
formState.value = {
bank_user_name: info?.bank_user_name ?? '',
bank_card: info?.bank_card ?? '',
bank_name: info?.bank_name ?? '',
bank_account_type: Number(info?.bank_account_type ?? 2) || 2,
bank_no: info?.bank_no ?? '',
};
} catch {
message.error('加载门店银行卡信息失败');
} finally {
loading.value = false;
}
}
/** 选择已报备记录后填充表单 */
function handleSelectExistingCard(value: string | undefined) {
if (!value) {
importedFromReport.value = false;
return;
}
const option = selectableOptions.value.find((item) => item.value === value);
if (!option) {
importedFromReport.value = false;
return;
}
formState.value = mapReportPayloadToStoreBankForm(option.payload);
importedFromReport.value = true;
}
function resetImportState() {
selectedCardKey.value = undefined;
selectableOptions.value = [];
importedFromReport.value = false;
}
const [Modal, modalApi] = useVbenModal({
fullscreenButton: false,
draggable: true,
onCancel() {
modalApi.close();
},
onConfirm: async () => {
if (!storeId.value) return;
saving.value = true;
try {
await updateStoreBankInfoApi({
id: storeId.value,
...formState.value,
});
message.success('门店银行卡信息已保存');
gridApiRef.value?.query?.();
gridApiRef.value?.reload?.();
modalApi.close();
} finally {
saving.value = false;
}
},
onOpenChange(isOpen: boolean) {
if (isOpen) {
const data = modalApi.getData<{
storeId: number;
storeName?: string;
gridApi?: any;
}>();
storeId.value = data?.storeId ?? 0;
storeName.value = data?.storeName ?? '';
gridApiRef.value = data?.gridApi ?? null;
resetImportState();
loadStoreBankInfo();
loadSelectableCards();
return;
}
storeId.value = 0;
storeName.value = '';
gridApiRef.value = null;
resetImportState();
formState.value = {
bank_user_name: '',
bank_card: '',
bank_name: '',
bank_account_type: 2,
bank_no: '',
};
},
});
</script>
<template>
<Modal :title="modalTitle" class="w-[520px]" :confirm-loading="saving">
<Alert
type="info"
show-icon
class="mb-4"
message="仅修改系统门店银行卡信息,不会提交易票联报备。"
/>
<div v-if="selectableOptions.length > 0" class="mb-4">
<div class="mb-2 text-sm text-gray-600 dark:text-gray-400">
从已报备银行卡导入
</div>
<Select
v-model:value="selectedCardKey"
allow-clear
show-search
class="w-full"
:filter-option="filterSelectableOption"
:options="selectableOptions"
placeholder="选择历史报备记录(可跨门店)"
@change="handleSelectExistingCard"
/>
</div>
<Alert
v-if="importedFromReport"
type="success"
show-icon
class="mb-4"
message="已从报备记录导入卡信息,确认后仅写入系统门店,不会提交易票联报备。"
/>
<Spin :spinning="loading">
<Form layout="vertical">
<FormItem label="开户人姓名" required>
<Input
v-model:value="formState.bank_user_name"
placeholder="请输入开户人姓名"
/>
</FormItem>
<FormItem label="银行卡号" required>
<Input v-model:value="formState.bank_card" placeholder="请输入银行卡号" />
</FormItem>
<FormItem label="开户银行名称" required>
<Input v-model:value="formState.bank_name" placeholder="请输入开户银行名称" />
</FormItem>
<FormItem label="银行账户类型" required>
<Select
v-model:value="formState.bank_account_type"
:options="STORE_BANK_ACCOUNT_TYPE_OPTIONS"
placeholder="请选择银行账户类型"
/>
</FormItem>
<FormItem label="银行联行号">
<Input
v-model:value="formState.bank_no"
placeholder="对公/存折或非62开头卡号时必填"
/>
</FormItem>
</Form>
</Spin>
</Modal>
</template>

View File

@@ -8,3 +8,16 @@ export const EPL_TRANSFER_ACCOUNT_TYPE_OPTIONS = [
export const USE_TYPE_TRANSFER = '2';
export const USE_TYPE_TRANSFER_TEXT = '转账卡';
/** 易票联报备修改入口文案 */
export const LABEL_UPDATE_REPORT_BANK_CARD = '修改报备银行卡';
/** 系统门店银行卡字段编辑入口文案 */
export const LABEL_UPDATE_STORE_BANK_CARD = '修改银行卡';
/** yii_store 银行账户类型选项 */
export const STORE_BANK_ACCOUNT_TYPE_OPTIONS = [
{ label: '对公', value: 1 },
{ label: '对私', value: 2 },
{ label: '存折', value: 5 },
];

View File

@@ -0,0 +1,64 @@
/** 门店银行卡表单字段yii_store */
export type StoreBankFormState = {
bank_user_name: string;
bank_card: string;
bank_name: string;
bank_account_type: number;
bank_no: string;
};
export type BankCardSelectableOption = {
value: string;
label: string;
payload: Record<string, any>;
};
/** 卡号脱敏展示(与后端 mask 规则一致) */
export function maskBankCardForDisplay(bankCard?: string | null): string {
const card = String(bankCard ?? '').trim();
if (!card) return '';
if (card.length <= 8) return card;
return `${card.slice(0, 4)}${'*'.repeat(Math.max(0, card.length - 8))}${card.slice(-4)}`;
}
/** 报备 payload 映射为门店银行卡表单字段 */
export function mapReportPayloadToStoreBankForm(
payload: Record<string, any>,
): StoreBankFormState {
return {
bank_user_name: String(payload.bank_user_name ?? ''),
bank_card: String(payload.bank_card ?? ''),
bank_name: String(payload.bank_name ?? ''),
bank_account_type: Number(payload.bank_account_type ?? 2) || 2,
bank_no: String(payload.bank_no ?? ''),
};
}
/** 从报备详情构建本门店导入选项 */
export function buildCurrentStoreReportOption(
detail: Record<string, any> | null | undefined,
): BankCardSelectableOption | null {
if (!detail?.id) return null;
const bankCard = String(detail.bank_card ?? '').trim();
const bankUserName = String(detail.bank_user_name ?? '').trim();
if (!bankCard || !bankUserName) return null;
const masked =
detail.bank_card_masked || maskBankCardForDisplay(bankCard);
return {
value: `current_report_${detail.id}`,
label: `本门店报备 #${detail.id}${masked}`,
payload: mapReportPayloadToStoreBankForm(detail),
};
}
/** 合并本店报备与跨店历史报备选项(本店置顶) */
export function mergeSelectableBankCardOptions(
currentOption: BankCardSelectableOption | null,
remoteOptions: BankCardSelectableOption[] = [],
): BankCardSelectableOption[] {
if (!currentOption) return remoteOptions;
const rest = remoteOptions.filter((item) => item.value !== currentOption.value);
return [currentOption, ...rest];
}

View File

@@ -198,3 +198,17 @@ export async function updateStoreExternalFieldApi(data: {
}) {
return requestClient.post<any>(`${prefix}update-store-external-field`, data);
}
/**
* 仅更新系统门店银行卡字段(不触发易票联报备)
*/
export async function updateStoreBankInfoApi(data: {
id: number;
bank_user_name: string;
bank_card: string;
bank_name: string;
bank_account_type: number;
bank_no?: string;
}) {
return requestClient.post<any>(`${prefix}update-store-bank-info`, data);
}

View File

@@ -3,32 +3,18 @@ import { ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { Form, FormItem, message, Select } from 'ant-design-vue';
import { Form, FormItem, message } from 'ant-design-vue';
import { getDoctorOptionApi, updateSpecialPrescriptionDoctorApi } from '../api';
import DoctorPicker from '#/components/form/components/doctor-picker.vue';
import { updateSpecialPrescriptionDoctorApi } from '../api';
const formState = ref({
id: undefined as number | undefined,
special_prescription_doctor_id: undefined as number | undefined,
});
const doctorOptions = ref<Array<{ id: number; name: string }>>([]);
const gridApiRef = ref<any>(null);
const loading = ref(false);
async function loadDoctorOptions(storeId?: number) {
if (!storeId) {
doctorOptions.value = [];
return;
}
try {
const doctors = await getDoctorOptionApi(storeId);
doctorOptions.value = doctors || [];
} catch (error) {
console.error('获取医生列表失败:', error);
doctorOptions.value = [];
}
}
const [Modal, modalApi] = useVbenModal({
fullscreenButton: false,
@@ -37,7 +23,6 @@ const [Modal, modalApi] = useVbenModal({
modalApi.close();
},
onConfirm: async () => {
loading.value = true;
modalApi.setState({ confirmLoading: true });
try {
await updateSpecialPrescriptionDoctorApi({
@@ -50,11 +35,10 @@ const [Modal, modalApi] = useVbenModal({
} catch {
message.error('绑定失败');
} finally {
loading.value = false;
modalApi.setState({ confirmLoading: false });
}
},
async onOpenChange(isOpen: boolean) {
onOpenChange(isOpen: boolean) {
if (isOpen) {
const { values, gridApi } = modalApi.getData<Record<string, any>>();
gridApiRef.value = gridApi;
@@ -62,24 +46,18 @@ const [Modal, modalApi] = useVbenModal({
id: values?.id,
special_prescription_doctor_id: values?.special_prescription_doctor_id || undefined,
};
await loadDoctorOptions(formState.value.id);
}
},
});
</script>
<template>
<Modal title="绑特色方默认医生" class="w-[500px]">
<Modal title="绑特色方默认医生" class="w-[500px]">
<Form :model="formState" layout="vertical">
<FormItem label="特色方默认挂号医生">
<Select
<DoctorPicker
v-model:value="formState.special_prescription_doctor_id"
:options="doctorOptions"
:field-names="{ label: 'name', value: 'id' }"
placeholder="请选择特色方默认挂号医生"
allow-clear
show-search
:filter-option="(input: string, option: any) => option.name.toLowerCase().includes(input.toLowerCase())"
:store-id="formState.id"
/>
</FormItem>
</Form>

View File

@@ -7,6 +7,8 @@ defineProps<{
showClinicType?: boolean;
showInsurance?: boolean;
showSalespersonSeePrice?: boolean;
/** 是否可点击银行卡报备 Tag超管/系统管理员) */
canManageBankCard?: boolean;
getBankCardReportTagColor: (status: number) => string;
getBankCardReportTagText: (row: Record<string, any>) => string;
onShippingFree: (id: number) => void;
@@ -18,6 +20,15 @@ defineProps<{
onAllowInsurance?: (id: number) => void;
onSalespersonSeePrice?: (id: number) => void;
}>();
function handleBankCardTagClick(
row: Record<string, any>,
canManageBankCard: boolean | undefined,
onBankCardReport: (row: Record<string, any>) => void,
) {
if (!canManageBankCard) return;
onBankCardReport(row);
}
</script>
<template>
@@ -93,8 +104,8 @@ defineProps<{
<div class="config-item__control">
<Tag
:color="getBankCardReportTagColor(row.bank_card_report_status)"
class="config-item__tag"
@click="onBankCardReport(row)"
:class="['config-item__tag', { 'config-item__tag--readonly': !canManageBankCard }]"
@click="handleBankCardTagClick(row, canManageBankCard, onBankCardReport)"
>
{{ getBankCardReportTagText(row) }}
</Tag>
@@ -146,8 +157,8 @@ defineProps<{
<div class="config-item__control">
<Tag
:color="getBankCardReportTagColor(row.bank_card_report_status)"
class="config-item__tag"
@click="onBankCardReport(row)"
:class="['config-item__tag', { 'config-item__tag--readonly': !canManageBankCard }]"
@click="handleBankCardTagClick(row, canManageBankCard, onBankCardReport)"
>
{{ getBankCardReportTagText(row) }}
</Tag>
@@ -228,6 +239,11 @@ defineProps<{
text-overflow: ellipsis;
}
.config-item__tag--readonly {
cursor: default;
opacity: 0.85;
}
.clinic-type-tag {
transition: all 0.2s ease;
user-select: none;

View File

@@ -41,7 +41,7 @@ export const gridOptions: VxeGridProps<RowType> = {
field: 'special_prescription_config',
align: 'left',
title: '特色方配置',
width: 140,
width: 180,
slots: { default: 'special_prescription_config' },
},
{

View File

@@ -8,13 +8,14 @@ import { Page, useVbenModal } from '@vben/common-ui';
import { useUserStore } from '@vben/stores';
import { useClipboard } from '@vueuse/core';
import { Button, Image, message, Modal, Tag } from 'ant-design-vue';
import { Button, Image, message, Modal, Tag, Avatar } from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { Icon } from '#/components/icon';
import QrCodePreview from '#/components/modal/QrCodePreview.vue';
import PromoterInfoCard from '#/components/promoter/PromoterInfoCard.vue';
import { TableAction } from '#/components/table-action';
import { resolveAvatarUrl } from '#/views/system/store-input/utils/inputUser';
import {
batchSyncDrugPriceApi,
@@ -39,9 +40,11 @@ import StoreExternalFieldModal from './components/StoreExternalFieldModal.vue';
import SalespersonCommissionDrawer from './components/SalespersonCommissionDrawer.vue';
import BankCardReportModal from '#/views/system/store-bank-card/components/BankCardReportModal.vue';
import BankCardStatusModal from '#/views/system/store-bank-card/components/BankCardStatusModal.vue';
import BankCardStoreEditModal from '#/views/system/store-bank-card/components/BankCardStoreEditModal.vue';
import { getStoreBankCardReportDetail } from '#/views/system/store-bank-card/api';
import { formOptions } from './config/search';
import { gridOptions } from './config/table';
import { canManageStoreBankCard } from '#/views/system/admin/_shared/platform-admin-role';
const userStore = useUserStore();
const router = useRouter();
@@ -51,6 +54,10 @@ const isPlatformAdmin = computed(() => {
return userStore?.userInfo?.roles?.user_type === 2;
});
const canManageBankCard = computed(() =>
canManageStoreBankCard(userStore.userInfo),
);
// 跳转到审核页面
const goToAudit = () => {
router.push('/system/store-input/audit');
@@ -120,6 +127,19 @@ const [BankCardStatusModalComponent, bankCardStatusModalApi] = useVbenModal({
connectedComponent: BankCardStatusModal,
});
const [BankCardStoreEditModalComponent, bankCardStoreEditModalApi] = useVbenModal({
connectedComponent: BankCardStoreEditModal,
});
const openBankCardStoreEdit = (row: any) => {
bankCardStoreEditModalApi.setData({
storeId: row.id,
storeName: row.name,
gridApi,
});
bankCardStoreEditModalApi.open();
};
const openBankCardReport = async (row: any, update = false) => {
let report = null;
try {
@@ -169,6 +189,7 @@ function getBankCardReportTagText(row: any) {
}
function handleBankCardReportColumnClick(row: any) {
if (!canManageBankCard.value) return;
const status = Number(row.bank_card_report_status ?? 0);
if (status === 1 || status === 2) {
openBankCardStatus(row);
@@ -380,6 +401,7 @@ const handleSwitchClinicType = (row: any) => {
<FormModal />
<BankCardReportModalComponent />
<BankCardStatusModalComponent />
<BankCardStoreEditModalComponent />
<QrCodePreviewModal />
<DrugPriceModalComponent />
<BindConsultationModalComponent />
@@ -449,6 +471,7 @@ const handleSwitchClinicType = (row: any) => {
<StoreConfigTogglesCell
:row="row"
section="switches"
:can-manage-bank-card="canManageBankCard"
:get-bank-card-report-tag-color="getBankCardReportTagColor"
:get-bank-card-report-tag-text="getBankCardReportTagText"
:on-shipping-free="updateShippingFree"
@@ -465,6 +488,7 @@ const handleSwitchClinicType = (row: any) => {
show-clinic-type
show-insurance
show-salesperson-see-price
:can-manage-bank-card="canManageBankCard"
:get-bank-card-report-tag-color="getBankCardReportTagColor"
:get-bank-card-report-tag-text="getBankCardReportTagText"
:on-shipping-free="updateShippingFree"
@@ -530,10 +554,14 @@ const handleSwitchClinicType = (row: any) => {
<template #special_prescription_config="{ row }">
<div
v-if="row.special_prescription_doctor_id"
class="cursor-pointer hover:text-blue-500"
class="flex cursor-pointer items-center gap-2 hover:text-blue-500"
@click="showBindSpecialPrescriptionDoctorModal(row)"
>
<div>医生ID{{ row.special_prescription_doctor_id }}</div>
<Avatar
:size="32"
:src="resolveAvatarUrl(row.special_prescription_doctor_avatar)"
/>
<span>{{ row.special_prescription_doctor_name || '未知医生' }}</span>
</div>
<Button
v-else
@@ -657,6 +685,14 @@ const handleSwitchClinicType = (row: any) => {
icon: 'ant-design:credit-card-outlined',
size: 'small',
auth: ['Super Admin', 'Admin'],
onClick: () => openBankCardStoreEdit(row),
},
{
label: '修改报备银行卡',
type: 'link',
icon: 'ant-design:file-protect-outlined',
size: 'small',
auth: ['Super Admin', 'Admin'],
onClick: () => openBankCardReport(row, true),
},
// {