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
Lock Threads / action (push) Has been cancelled
Issue Close Require / close-issues (push) Has been cancelled
Close stale issues / stale (push) Has been cancelled
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
Lock Threads / action (push) Has been cancelled
Issue Close Require / close-issues (push) Has been cancelled
Close stale issues / stale (push) Has been cancelled
This commit is contained in:
@@ -37,6 +37,10 @@ interface Props {
|
||||
* 诊所ID
|
||||
*/
|
||||
storeId?: number;
|
||||
/**
|
||||
* 挂号ID(用于取价门店与毛利率权限)
|
||||
*/
|
||||
registerId?: number;
|
||||
/**
|
||||
* 是否禁用
|
||||
*/
|
||||
@@ -47,6 +51,7 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
type: 1,
|
||||
placeholder: '输入药品名称搜索',
|
||||
storeId: 2,
|
||||
registerId: undefined,
|
||||
disabled: false,
|
||||
});
|
||||
|
||||
@@ -120,6 +125,7 @@ const searchDrugs = debounce(async (keyword: string) => {
|
||||
name: keyword,
|
||||
type: props.type,
|
||||
store_id: props.storeId,
|
||||
...(props.registerId ? { register_id: props.registerId } : {}),
|
||||
});
|
||||
|
||||
// 处理返回数据
|
||||
|
||||
243
apps/web-antd/src/components/form/components/promoter-picker.vue
Normal file
243
apps/web-antd/src/components/form/components/promoter-picker.vue
Normal file
@@ -0,0 +1,243 @@
|
||||
<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 { getPromoterOptions } from '#/views/system/store-input/api';
|
||||
|
||||
defineOptions({
|
||||
name: 'PromoterPicker',
|
||||
inheritAttrs: false,
|
||||
});
|
||||
|
||||
const props = defineProps<{
|
||||
value?: string;
|
||||
disabled?: boolean;
|
||||
}>();
|
||||
|
||||
const emits = defineEmits<{
|
||||
'update:value': [value: string | undefined];
|
||||
}>();
|
||||
|
||||
const mValue = useVModel(props, 'value', emits, { passive: true });
|
||||
|
||||
type PromoterOption = {
|
||||
id: number;
|
||||
nick_name: string;
|
||||
avatar: string;
|
||||
code: string;
|
||||
role_id: number;
|
||||
role_name: string;
|
||||
};
|
||||
|
||||
const open = ref(false);
|
||||
const loading = ref(false);
|
||||
const searchKeyword = ref('');
|
||||
const options = ref<PromoterOption[]>([]);
|
||||
const triggerRef = ref<HTMLElement | null>(null);
|
||||
const searchInputRef = ref<InstanceType<typeof Input> | null>(null);
|
||||
|
||||
function filterPromoterOptions(keyword: string, list: PromoterOption[]) {
|
||||
const q = keyword.trim().toLowerCase();
|
||||
if (!q) return list;
|
||||
return list.filter((item) => {
|
||||
const name = (item.nick_name || '').toLowerCase();
|
||||
const code = (item.code || '').toLowerCase();
|
||||
const role = (item.role_name || '').toLowerCase();
|
||||
return name.includes(q) || code.includes(q) || role.includes(q);
|
||||
});
|
||||
}
|
||||
|
||||
const filteredOptions = computed(() =>
|
||||
filterPromoterOptions(searchKeyword.value, options.value),
|
||||
);
|
||||
|
||||
const selectedOption = computed(() =>
|
||||
options.value.find((item) => item.code === mValue.value),
|
||||
);
|
||||
|
||||
const displayText = computed(() => {
|
||||
const item = selectedOption.value;
|
||||
if (!item) return '';
|
||||
return `${item.nick_name || '-'} · ${item.code} · ${item.role_name || ''}`;
|
||||
});
|
||||
|
||||
async function loadOptions() {
|
||||
loading.value = true;
|
||||
try {
|
||||
options.value = (await getPromoterOptions()) || [];
|
||||
if (options.value.length === 1 && !mValue.value) {
|
||||
mValue.value = options.value[0].code;
|
||||
}
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function selectOption(item: PromoterOption) {
|
||||
mValue.value = item.code;
|
||||
open.value = false;
|
||||
searchKeyword.value = '';
|
||||
}
|
||||
|
||||
function clearSelection(e: Event) {
|
||||
e.stopPropagation();
|
||||
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="promoter-picker-popover"
|
||||
@open-change="onOpenChange"
|
||||
>
|
||||
<template #content>
|
||||
<div class="promoter-panel">
|
||||
<Input
|
||||
ref="searchInputRef"
|
||||
v-model:value="searchKeyword"
|
||||
allow-clear
|
||||
placeholder="搜索业务员姓名"
|
||||
class="promoter-search"
|
||||
/>
|
||||
<Spin :spinning="loading">
|
||||
<div v-if="filteredOptions.length" class="promoter-list">
|
||||
<button
|
||||
v-for="item in filteredOptions"
|
||||
:key="item.id"
|
||||
type="button"
|
||||
class="promoter-item"
|
||||
:class="{ active: item.code === mValue }"
|
||||
@click="selectOption(item)"
|
||||
>
|
||||
<Avatar :src="item.avatar" :size="32">
|
||||
{{ (item.nick_name || '?').charAt(0) }}
|
||||
</Avatar>
|
||||
<div class="promoter-meta">
|
||||
<div class="promoter-name">{{ item.nick_name || '-' }}</div>
|
||||
<div class="promoter-sub">{{ item.code }} · {{ item.role_name }}</div>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
<Empty v-else description="无匹配业务员" class="promoter-empty" />
|
||||
</Spin>
|
||||
</div>
|
||||
</template>
|
||||
<div
|
||||
ref="triggerRef"
|
||||
class="promoter-trigger"
|
||||
:class="{ disabled: disabled, placeholder: !displayText }"
|
||||
>
|
||||
<Input
|
||||
:value="displayText"
|
||||
readonly
|
||||
:disabled="disabled"
|
||||
placeholder="请选择业务员"
|
||||
class="promoter-trigger-input"
|
||||
>
|
||||
<template v-if="displayText && !disabled" #suffix>
|
||||
<span class="clear-btn" @click="clearSelection">×</span>
|
||||
</template>
|
||||
</Input>
|
||||
</div>
|
||||
</Popover>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.promoter-trigger {
|
||||
width: 100%;
|
||||
cursor: pointer;
|
||||
}
|
||||
.promoter-trigger.disabled {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.promoter-trigger-input {
|
||||
pointer-events: none;
|
||||
}
|
||||
.promoter-trigger:not(.disabled) :deep(.ant-input) {
|
||||
cursor: pointer;
|
||||
}
|
||||
.clear-btn {
|
||||
pointer-events: auto;
|
||||
cursor: pointer;
|
||||
color: #86909c;
|
||||
font-size: 16px;
|
||||
line-height: 1;
|
||||
padding: 0 4px;
|
||||
}
|
||||
.promoter-panel {
|
||||
width: 360px;
|
||||
max-width: 80vw;
|
||||
}
|
||||
.promoter-search {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.promoter-list {
|
||||
max-height: 280px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.promoter-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
width: 100%;
|
||||
padding: 8px 10px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.promoter-item:hover,
|
||||
.promoter-item.active {
|
||||
background: #f2f3f5;
|
||||
}
|
||||
.promoter-meta {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
.promoter-name {
|
||||
font-size: 14px;
|
||||
color: #1d2129;
|
||||
}
|
||||
.promoter-sub {
|
||||
font-size: 12px;
|
||||
color: #86909c;
|
||||
}
|
||||
.promoter-empty {
|
||||
margin: 12px 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style>
|
||||
.promoter-picker-popover .ant-popover-inner {
|
||||
padding: 12px;
|
||||
}
|
||||
</style>
|
||||
@@ -69,6 +69,12 @@ const adminRoleRoutes: RouteRecordRaw[] = [
|
||||
path: '/system/admin/pharmacist',
|
||||
component: () => import('#/views/system/admin/pharmacist/index.vue'),
|
||||
},
|
||||
{
|
||||
meta: { title: '诊所推广员' },
|
||||
name: 'SystemAdminClinicSalesperson',
|
||||
path: '/system/admin/clinic-salesperson',
|
||||
component: () => import('#/views/system/admin/clinic-salesperson/index.vue'),
|
||||
},
|
||||
];
|
||||
|
||||
const routes: RouteRecordRaw[] = [
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { computed, nextTick, ref } from 'vue';
|
||||
import { computed, nextTick, ref, watch } from 'vue';
|
||||
|
||||
import { message, notification } from 'ant-design-vue';
|
||||
import { debounce } from 'lodash-es';
|
||||
@@ -10,12 +10,18 @@ import { sendMessage } from '#/views/business/chat/utils/request';
|
||||
import {
|
||||
addWestPrescription,
|
||||
checkChineseMedicineConflictApi,
|
||||
getCurrentStoreTypeApi,
|
||||
getDrugUseList,
|
||||
getMyStoreListApi,
|
||||
getPatientItem,
|
||||
getProcessRuleList,
|
||||
getProductListDoctorReception,
|
||||
} from '#/views/doctor/doctor-reception/api';
|
||||
import {
|
||||
calcItemMarginPercent,
|
||||
calcTotalMarginPercent,
|
||||
isSeeRateEnabled,
|
||||
} from '#/utils/chinesePrescriptionMargin';
|
||||
import { getRegisterStoreInfo as getRegisterStoreInfoPharmacy } from '#/views/doctor/online-consultation/api';
|
||||
import { getRegisterStoreInfo as getRegisterStoreInfoClinic } from '#/views/doctor/online-consultation-clinic/api';
|
||||
import traditionalJson from '#/views/business/chat/config/traditional.json';
|
||||
@@ -89,6 +95,9 @@ export const usePrescriptionStore = defineStore('prescription', () => {
|
||||
// 存储前缀(用于区分在线复诊-药店和在线复诊-诊所)
|
||||
const storagePrefix = ref('onlineConsultation-'); // 默认前缀
|
||||
|
||||
/** 当前取价门店是否允许查看毛利率(0/1,来自 xk-api) */
|
||||
const seeRate = ref(0);
|
||||
|
||||
// 获取localStorage key(按类型分开存储)
|
||||
const getStorageKey = (category?: number) => {
|
||||
const cat = category ?? activeCategory.value;
|
||||
@@ -143,6 +152,56 @@ export const usePrescriptionStore = defineStore('prescription', () => {
|
||||
return totalProductCost.value + processingFee.value;
|
||||
});
|
||||
|
||||
const resolvePrescribingStoreId = () => {
|
||||
if (sendMode.value === 1 && selectedStoreId.value) {
|
||||
return selectedStoreId.value;
|
||||
}
|
||||
return myStoreId.value;
|
||||
};
|
||||
|
||||
const fetchStoreSeeRate = async () => {
|
||||
try {
|
||||
const params: { register_id?: number; store_id?: number } = {};
|
||||
const sid = resolvePrescribingStoreId();
|
||||
if (sid) {
|
||||
params.store_id = sid;
|
||||
}
|
||||
if (currentRegisterId.value) {
|
||||
params.register_id = Number(currentRegisterId.value);
|
||||
}
|
||||
const res = await getCurrentStoreTypeApi(params);
|
||||
seeRate.value = Number(res?.see_rate ?? 0);
|
||||
} catch (error) {
|
||||
console.error('获取毛利率权限失败:', error);
|
||||
}
|
||||
};
|
||||
|
||||
watch(
|
||||
[myStoreId, selectedStoreId, sendMode, currentRegisterId],
|
||||
() => {
|
||||
if (myStoreId.value) {
|
||||
fetchStoreSeeRate();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
const chineseGrossMarginPercent = computed(() => {
|
||||
if (!isSeeRateEnabled(seeRate.value) || activeCategory.value !== 1) {
|
||||
return null;
|
||||
}
|
||||
return calcTotalMarginPercent(currentDrugs.value, dosage.value);
|
||||
});
|
||||
|
||||
const getChineseItemMargin = (drug: {
|
||||
price?: number | string;
|
||||
buy_price?: number | string;
|
||||
}) => {
|
||||
if (!isSeeRateEnabled(seeRate.value)) {
|
||||
return null;
|
||||
}
|
||||
return calcItemMarginPercent(drug.price, drug.buy_price);
|
||||
};
|
||||
|
||||
// localStorage同步方法
|
||||
const syncToLocalStorage = () => {
|
||||
try {
|
||||
@@ -240,6 +299,8 @@ export const usePrescriptionStore = defineStore('prescription', () => {
|
||||
await initializeBasicData();
|
||||
}
|
||||
|
||||
await fetchStoreSeeRate();
|
||||
|
||||
// 获取患者信息(只在需要时调用,如 PrescriptionModal)
|
||||
if (shouldFetchPatientInfo) {
|
||||
if (
|
||||
@@ -377,6 +438,7 @@ export const usePrescriptionStore = defineStore('prescription', () => {
|
||||
sendMode.value = 1;
|
||||
}
|
||||
console.log('获取挂号诊所信息成功:', res);
|
||||
await fetchStoreSeeRate();
|
||||
} catch (error) {
|
||||
console.error('获取挂号诊所信息失败:', error);
|
||||
}
|
||||
@@ -435,6 +497,9 @@ export const usePrescriptionStore = defineStore('prescription', () => {
|
||||
store_id: myStoreId.value,
|
||||
type: activeCategory.value,
|
||||
name: searchText,
|
||||
...(currentRegisterId.value
|
||||
? { register_id: Number(currentRegisterId.value) }
|
||||
: {}),
|
||||
});
|
||||
|
||||
drugList.value = res.map((item) => {
|
||||
@@ -476,6 +541,7 @@ export const usePrescriptionStore = defineStore('prescription', () => {
|
||||
),
|
||||
unit: drugUnit.value.find((item) => item.id === data.drug.unit_id),
|
||||
price: data.price,
|
||||
buy_price: data.buy_price,
|
||||
way_id: data.drug?.way_id,
|
||||
use_ways: drugUseWay.value.find((item) => item.id === data.drug.way_id),
|
||||
time_id: data.drug.time_id,
|
||||
@@ -605,6 +671,7 @@ export const usePrescriptionStore = defineStore('prescription', () => {
|
||||
),
|
||||
unit: drugUnit.value.find((item) => item.id === data.drug.unit_id),
|
||||
price: data.price,
|
||||
buy_price: data.buy_price,
|
||||
way_id: data.drug?.way_id,
|
||||
use_ways: drugUseWay.value.find((item) => item.id === data.drug.way_id),
|
||||
time_id: data.drug.time_id,
|
||||
@@ -985,6 +1052,10 @@ export const usePrescriptionStore = defineStore('prescription', () => {
|
||||
totalProductCost,
|
||||
processingFee,
|
||||
totalCost,
|
||||
seeRate,
|
||||
chineseGrossMarginPercent,
|
||||
getChineseItemMargin,
|
||||
fetchStoreSeeRate,
|
||||
|
||||
// 方法
|
||||
initializePrescription,
|
||||
|
||||
60
apps/web-antd/src/utils/chinesePrescriptionMargin.ts
Normal file
60
apps/web-antd/src/utils/chinesePrescriptionMargin.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
|
||||
* 中药处方毛利率计算(仅商品计费,不含诊疗费/加工费)
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
export function isSeeRateEnabled(seeRate: unknown): boolean {
|
||||
|
||||
return Number(seeRate) === 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function isValidBuyPrice(value: unknown): boolean {
|
||||
|
||||
if (value === null || value === undefined || value === '') {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
const n = Number(value);
|
||||
|
||||
return !Number.isNaN(n);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
export function calcItemMarginPercent(
|
||||
|
||||
price: number | string | undefined,
|
||||
|
||||
buyPrice: number | string | undefined,
|
||||
|
||||
): string {
|
||||
|
||||
const p = Number(price);
|
||||
|
||||
if (!p || p <= 0 || !isValidBuyPrice(buyPrice)) {
|
||||
|
||||
return '--';
|
||||
|
||||
}
|
||||
|
||||
const b = Number(buyPrice);
|
||||
|
||||
return (((p - b) / p) * 100).toFixed(2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
export interface ChineseDrugMarginRow {
|
||||
|
||||
price?: number | string;
|
||||
|
||||
@@ -472,6 +472,7 @@ async function handleSelectCommonPrescription(data: any, type: number) {
|
||||
drug_name: recipe.drug_name || recipe.name,
|
||||
number: recipe.number || 1,
|
||||
price: recipe.price || 0,
|
||||
buy_price: recipe.buy_price,
|
||||
way_id: recipe.way_id || 0,
|
||||
select_number: 1,
|
||||
};
|
||||
@@ -976,6 +977,12 @@ const cancelSaveCommonPrescription = () => {
|
||||
</p>
|
||||
<p class="card-price">
|
||||
¥<span>{{ (drug.price * drug.number).toFixed(2) }}</span>
|
||||
<span
|
||||
v-if="prescriptionStore.getChineseItemMargin(drug) && prescriptionStore.getChineseItemMargin(drug) !== '--'"
|
||||
class="ml-2 text-gray-500 text-sm"
|
||||
>
|
||||
毛利率 {{ prescriptionStore.getChineseItemMargin(drug) }}%
|
||||
</span>
|
||||
</p>
|
||||
<Button
|
||||
class="card-delete"
|
||||
@@ -1201,7 +1208,8 @@ const cancelSaveCommonPrescription = () => {
|
||||
<div class="mb-5">
|
||||
<DrugSearchSelect
|
||||
:type="prescriptionStore.activeCategory"
|
||||
:store-id="prescriptionStore.storeId"
|
||||
:store-id="prescriptionStore.myStoreId"
|
||||
:register-id="Number(prescriptionStore.currentRegisterId) || undefined"
|
||||
:placeholder="`输入${categories.find(c => c.value === prescriptionStore.activeCategory)?.label || '商品'}名称搜索`"
|
||||
@select="handleSimpleProductSelect"
|
||||
/>
|
||||
@@ -1525,6 +1533,12 @@ const cancelSaveCommonPrescription = () => {
|
||||
</div>
|
||||
<div>
|
||||
商品价格:¥{{ prescriptionStore.totalProductCost.toFixed(2) }}
|
||||
<span
|
||||
v-if="prescriptionStore.chineseGrossMarginPercent !== null"
|
||||
class="ml-3 text-orange-600"
|
||||
>
|
||||
毛利率 {{ prescriptionStore.chineseGrossMarginPercent }}%
|
||||
</span>
|
||||
</div>
|
||||
<div class="text-red-500">
|
||||
总计:¥{{ prescriptionStore.totalCost.toFixed(2) }}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
const prefix = 'clinic-salesperson-self/';
|
||||
|
||||
export async function getSelfMyInfoApi() {
|
||||
return requestClient.get<any>(`${prefix}my-info`);
|
||||
}
|
||||
|
||||
export async function getSelfCommissionListApi(params: Record<string, any>) {
|
||||
return requestClient.get<any>(`${prefix}commission-list`, { params });
|
||||
}
|
||||
|
||||
export async function getSelfSettlementListApi(params: Record<string, any>) {
|
||||
return requestClient.get<any>(`${prefix}settlement-list`, { params });
|
||||
}
|
||||
|
||||
export async function getSelfSettlementDetailApi(params: { id: number }) {
|
||||
return requestClient.get<any>(`${prefix}settlement-detail`, { params });
|
||||
}
|
||||
|
||||
export async function getSelfUserBindListApi(params: Record<string, any>) {
|
||||
return requestClient.get<any>(`${prefix}user-bind-list`, { params });
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
|
||||
import { Empty, Input, Spin, Table } from 'ant-design-vue';
|
||||
|
||||
import { getSelfCommissionListApi } from '#/views/business/clinic-salesperson/api';
|
||||
|
||||
const loading = ref(true);
|
||||
const list = ref<any[]>([]);
|
||||
const total = ref(0);
|
||||
const page = ref(1);
|
||||
const pageSize = ref(20);
|
||||
const orderNo = ref('');
|
||||
|
||||
const columns = [
|
||||
{ title: '订单号', dataIndex: 'order_no', key: 'order_no', width: 180 },
|
||||
{ title: '明细', dataIndex: 'drug_info', key: 'drug_info', ellipsis: true },
|
||||
{ title: '分成金额', dataIndex: 'commission_amount', key: 'commission_amount', width: 100 },
|
||||
{ title: '状态', key: 'status', width: 90 },
|
||||
{ title: '支付时间', dataIndex: 'order_pay_at_text', key: 'order_pay_at_text', width: 170 },
|
||||
];
|
||||
|
||||
async function loadList() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await getSelfCommissionListApi({
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
order_no: orderNo.value,
|
||||
});
|
||||
list.value = (res?.items ?? []).map((row: any) => ({
|
||||
...row,
|
||||
drug_info: row.drug_info || `${row.drug_name} ×${row.qty}`,
|
||||
}));
|
||||
total.value = res?.total ?? 0;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadList);
|
||||
|
||||
function onPageChange(p: number, ps: number) {
|
||||
page.value = p;
|
||||
pageSize.value = ps;
|
||||
loadList();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height title="分成记录">
|
||||
<div class="mb-4">
|
||||
<Input
|
||||
v-model:value="orderNo"
|
||||
allow-clear
|
||||
class="w-60"
|
||||
placeholder="订单号"
|
||||
@press-enter="loadList"
|
||||
/>
|
||||
</div>
|
||||
<Spin :spinning="loading">
|
||||
<Empty v-if="!loading && !list.length" description="暂无分成记录" />
|
||||
<Table
|
||||
v-else
|
||||
:columns="columns"
|
||||
:data-source="list"
|
||||
:pagination="{
|
||||
current: page,
|
||||
pageSize,
|
||||
total,
|
||||
showSizeChanger: true,
|
||||
onChange: onPageChange,
|
||||
}"
|
||||
row-key="id"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'status'">
|
||||
{{ record.settlement_id > 0 ? '已结算' : '待结算' }}
|
||||
</template>
|
||||
</template>
|
||||
</Table>
|
||||
</Spin>
|
||||
</Page>
|
||||
</template>
|
||||
@@ -0,0 +1,92 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue';
|
||||
|
||||
import { Page, useVbenModal } from "@vben/common-ui";
|
||||
|
||||
import { Card, Col, Image, Row, Spin } from 'ant-design-vue';
|
||||
|
||||
import { getSelfMyInfoApi } from '#/views/business/clinic-salesperson/api';
|
||||
|
||||
import QrCodePreview from '#/views/business/store/settings/components/SalespersonQrCodePreview.vue';
|
||||
const [QrCodePreviewModal, QrCodePreviewApi] = useVbenModal({
|
||||
connectedComponent: QrCodePreview,
|
||||
});
|
||||
|
||||
const loading = ref(true);
|
||||
const info = ref<any>(null);
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
info.value = await getSelfMyInfoApi();
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function openQrCode(item: any) {
|
||||
QrCodePreviewApi.setData({ values: item });
|
||||
QrCodePreviewApi.open();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height title="我的收益">
|
||||
<QrCodePreviewModal />
|
||||
<Spin :spinning="loading">
|
||||
<template v-if="info">
|
||||
<Card class="mb-4" title="基本信息">
|
||||
<p>姓名:{{ info.salesperson?.nick_name }}</p>
|
||||
<p>手机:{{ info.salesperson?.phone }}</p>
|
||||
<p>所属诊所:{{ info.store?.name }}</p>
|
||||
<div v-if="info.qr_code" class="mt-3">
|
||||
<p class="mb-2">推广二维码</p>
|
||||
<Image :src="info.qr_code" :preview="false" :width="160" @click="openQrCode({
|
||||
qr_code: {
|
||||
qr_code: info.qr_code,
|
||||
store: info.store,
|
||||
},
|
||||
type: 'salesperson',
|
||||
nick_name: info.salesperson?.nick_name,
|
||||
})" />
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Row :gutter="16">
|
||||
<Col :span="6">
|
||||
<Card>
|
||||
<div class="text-gray-500">累计获客</div>
|
||||
<div class="text-2xl font-semibold text-blue-600">
|
||||
{{ info.stats?.user_number ?? 0 }}
|
||||
</div>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col :span="6">
|
||||
<Card>
|
||||
<div class="text-gray-500">累计分成</div>
|
||||
<div class="text-2xl font-semibold">
|
||||
¥{{ info.stats?.money ?? '0.00' }}
|
||||
</div>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col :span="6">
|
||||
<Card>
|
||||
<div class="text-gray-500">待结算</div>
|
||||
<div class="text-2xl font-semibold text-orange-600">
|
||||
¥{{ info.stats?.pending_amount ?? '0.00' }}
|
||||
</div>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col :span="6">
|
||||
<Card>
|
||||
<div class="text-gray-500">已结算</div>
|
||||
<div class="text-2xl font-semibold text-green-600">
|
||||
¥{{ info.stats?.settled_amount ?? '0.00' }}
|
||||
</div>
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
</template>
|
||||
</Spin>
|
||||
</Page>
|
||||
</template>
|
||||
235
apps/web-antd/src/views/business/clinic-salesperson/index.vue
Normal file
235
apps/web-antd/src/views/business/clinic-salesperson/index.vue
Normal file
@@ -0,0 +1,235 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
Empty,
|
||||
Input,
|
||||
Popover,
|
||||
Space,
|
||||
Tag,
|
||||
message,
|
||||
} from 'ant-design-vue';
|
||||
|
||||
import {
|
||||
getPlatformSalespersonListApi,
|
||||
openAdminAccountApi,
|
||||
} from '#/views/business/store/settings/api';
|
||||
import QrCodePreview from '#/views/business/store/settings/components/SalespersonQrCodePreview.vue';
|
||||
import SalespersonCommissionDrawer from '#/views/system/store/components/SalespersonCommissionDrawer.vue';
|
||||
import SalespersonCreateModal from '#/views/business/store/settings/components/SalespersonCreateModal.vue';
|
||||
import SalespersonUserBindDrawer from '#/views/business/store/settings/components/SalespersonUserBindDrawer.vue';
|
||||
|
||||
const listData = ref<{ total: number; items: any[] }>({ total: 0, items: [] });
|
||||
const loading = ref(false);
|
||||
const storeKeyword = ref('');
|
||||
const nickName = ref('');
|
||||
const phone = ref('');
|
||||
const page = ref(1);
|
||||
const pageSize = ref(20);
|
||||
const openingAccountId = ref(0);
|
||||
|
||||
const commissionDrawerRef = ref<InstanceType<typeof SalespersonCommissionDrawer>>();
|
||||
|
||||
const [QrCodePreviewModal, QrCodePreviewApi] = useVbenModal({
|
||||
connectedComponent: QrCodePreview,
|
||||
});
|
||||
|
||||
const [SalespersonCreateModalComponent, SalespersonCreateModalApi] = useVbenModal({
|
||||
connectedComponent: SalespersonCreateModal,
|
||||
});
|
||||
|
||||
async function getList() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await getPlatformSalespersonListApi({
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
store_keyword: storeKeyword.value,
|
||||
nick_name: nickName.value,
|
||||
phone: phone.value,
|
||||
});
|
||||
listData.value = {
|
||||
total: res?.total ?? 0,
|
||||
items: res?.items ?? [],
|
||||
};
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
getList();
|
||||
|
||||
function openCommission(item: any) {
|
||||
const sid = item.qr_code?.store_id;
|
||||
if (!sid) {
|
||||
message.warning('缺少门店信息');
|
||||
return;
|
||||
}
|
||||
commissionDrawerRef.value?.open({
|
||||
id: sid,
|
||||
name: item.store_name || '',
|
||||
salespersonId: item.id,
|
||||
});
|
||||
}
|
||||
|
||||
function openQrCode(item: any) {
|
||||
QrCodePreviewApi.setData({ values: item });
|
||||
QrCodePreviewApi.open();
|
||||
}
|
||||
|
||||
function openCreateModal() {
|
||||
SalespersonCreateModalApi.setData({
|
||||
getList,
|
||||
mode: 'platform',
|
||||
});
|
||||
SalespersonCreateModalApi.open();
|
||||
}
|
||||
|
||||
function openEditModal(item: any) {
|
||||
SalespersonCreateModalApi.setData({
|
||||
values: item,
|
||||
getList,
|
||||
update: true,
|
||||
});
|
||||
SalespersonCreateModalApi.open();
|
||||
}
|
||||
|
||||
async function handleOpenAdminAccount(item: any) {
|
||||
openingAccountId.value = item.id;
|
||||
try {
|
||||
await openAdminAccountApi({
|
||||
salesperson_id: item.id,
|
||||
store_id: item.qr_code?.store_id,
|
||||
});
|
||||
message.success('后台账号开通成功,默认密码 Xk123456@');
|
||||
getList();
|
||||
} finally {
|
||||
openingAccountId.value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
function splitTypeLabel(type: number) {
|
||||
return Number(type) === 1 ? '百分比' : '固定金额';
|
||||
}
|
||||
|
||||
function splitTypeColor(type: number) {
|
||||
return Number(type) === 1 ? 'blue' : 'orange';
|
||||
}
|
||||
|
||||
function tcmBaseLabel(type: number) {
|
||||
return Number(type) === 1 ? '处方总价' : '药店利润';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height title="推广员管理">
|
||||
<SalespersonCreateModalComponent />
|
||||
<SalespersonCommissionDrawer ref="commissionDrawerRef" />
|
||||
<QrCodePreviewModal />
|
||||
|
||||
<div class="mb-4 flex flex-wrap items-center gap-3">
|
||||
<Input
|
||||
v-model:value="storeKeyword"
|
||||
allow-clear
|
||||
class="w-52"
|
||||
placeholder="诊所名称/拼音首拼"
|
||||
/>
|
||||
<Input
|
||||
v-model:value="nickName"
|
||||
allow-clear
|
||||
class="w-40"
|
||||
placeholder="推广员名称"
|
||||
/>
|
||||
<Input
|
||||
v-model:value="phone"
|
||||
allow-clear
|
||||
class="w-40"
|
||||
placeholder="手机号"
|
||||
/>
|
||||
<Button type="primary" @click="getList">查询</Button>
|
||||
<Button type="primary" @click="openCreateModal">新增推广员</Button>
|
||||
</div>
|
||||
|
||||
<Empty v-if="!loading && !listData.items.length" description="暂无推广员" />
|
||||
|
||||
<div
|
||||
v-else
|
||||
class="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4"
|
||||
>
|
||||
<Card
|
||||
v-for="item in listData.items"
|
||||
:key="item.id"
|
||||
:loading="loading"
|
||||
class="rounded-lg shadow-sm"
|
||||
>
|
||||
<div class="mb-3 flex items-start justify-between gap-2">
|
||||
<div>
|
||||
<h3 class="text-lg font-semibold">{{ item.nick_name || '未知' }}</h3>
|
||||
<p class="text-sm text-gray-500">{{ item.store_name }}</p>
|
||||
</div>
|
||||
<Space direction="vertical" align="end" size="small">
|
||||
<Tag :color="splitTypeColor(item.split_type)">
|
||||
西药·{{ splitTypeLabel(item.split_type) }}
|
||||
<template v-if="Number(item.split_type) === 1">
|
||||
· {{ item.split }}%
|
||||
</template>
|
||||
</Tag>
|
||||
<Tag v-if="Number(item.tcm_split) > 0" color="green">
|
||||
中药·{{ item.tcm_split }}%·{{ tcmBaseLabel(item.tcm_base_type) }}
|
||||
</Tag>
|
||||
<Tag :color="item.has_admin_account ? 'success' : 'default'">
|
||||
{{ item.has_admin_account ? '已开通后台' : '未开通后台' }}
|
||||
</Tag>
|
||||
</Space>
|
||||
</div>
|
||||
|
||||
<div class="mb-3 space-y-1 text-sm text-gray-600">
|
||||
<div>{{ item.phone }}</div>
|
||||
<Popover trigger="click" title="获客记录">
|
||||
<template #content>
|
||||
<div class="w-[420px]">
|
||||
<SalespersonUserBindDrawer :open="true" :salesperson-id="item.id" />
|
||||
</div>
|
||||
</template>
|
||||
<div class="flex cursor-pointer justify-between hover:text-blue-500">
|
||||
<span>累计获客</span>
|
||||
<span class="font-medium text-blue-600">{{
|
||||
item.count?.user_number ?? 0
|
||||
}}</span>
|
||||
</div>
|
||||
</Popover>
|
||||
<div class="flex justify-between">
|
||||
<span>待结算</span>
|
||||
<span class="text-orange-600">¥{{ item.count?.pending_amount || '0.00' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Space wrap>
|
||||
<Button size="small" @click="openEditModal(item)">编辑</Button>
|
||||
<Button size="small" type="primary" @click="openCommission(item)">
|
||||
分成与结算
|
||||
</Button>
|
||||
<Button
|
||||
v-if="item.qr_code?.qr_code"
|
||||
size="small"
|
||||
@click="openQrCode(item)"
|
||||
>
|
||||
二维码
|
||||
</Button>
|
||||
<Button
|
||||
v-if="!item.has_admin_account"
|
||||
size="small"
|
||||
:loading="openingAccountId === item.id"
|
||||
@click="handleOpenAdminAccount(item)"
|
||||
>
|
||||
开通后台
|
||||
</Button>
|
||||
</Space>
|
||||
</Card>
|
||||
</div>
|
||||
</Page>
|
||||
</template>
|
||||
@@ -0,0 +1,64 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
|
||||
import { Empty, Spin, Table } from 'ant-design-vue';
|
||||
|
||||
import { getSelfUserBindListApi } from '#/views/business/clinic-salesperson/api';
|
||||
|
||||
const loading = ref(true);
|
||||
const list = ref<any[]>([]);
|
||||
const total = ref(0);
|
||||
const page = ref(1);
|
||||
const pageSize = ref(20);
|
||||
|
||||
const columns = [
|
||||
{ title: '用户昵称', dataIndex: 'user_nick_name', key: 'user_nick_name' },
|
||||
{ title: '手机号', dataIndex: 'user_phone', key: 'user_phone' },
|
||||
{ title: '绑定时间', dataIndex: 'bind_at_text', key: 'bind_at_text' },
|
||||
];
|
||||
|
||||
async function loadList() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await getSelfUserBindListApi({
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
});
|
||||
list.value = res?.items ?? [];
|
||||
total.value = res?.total ?? 0;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadList);
|
||||
|
||||
function onPageChange(p: number, ps: number) {
|
||||
page.value = p;
|
||||
pageSize.value = ps;
|
||||
loadList();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height title="获客记录">
|
||||
<Spin :spinning="loading">
|
||||
<Empty v-if="!loading && !list.length" description="暂无获客记录" />
|
||||
<Table
|
||||
v-else
|
||||
:columns="columns"
|
||||
:data-source="list"
|
||||
:pagination="{
|
||||
current: page,
|
||||
pageSize,
|
||||
total,
|
||||
showSizeChanger: true,
|
||||
onChange: onPageChange,
|
||||
}"
|
||||
row-key="id"
|
||||
/>
|
||||
</Spin>
|
||||
</Page>
|
||||
</template>
|
||||
@@ -0,0 +1,114 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
|
||||
import { Button, Drawer, Empty, Image, Spin, Table } from 'ant-design-vue';
|
||||
|
||||
import {
|
||||
getSelfSettlementDetailApi,
|
||||
getSelfSettlementListApi,
|
||||
} from '#/views/business/clinic-salesperson/api';
|
||||
|
||||
const loading = ref(true);
|
||||
const list = ref<any[]>([]);
|
||||
const total = ref(0);
|
||||
const page = ref(1);
|
||||
const pageSize = ref(20);
|
||||
const detailVisible = ref(false);
|
||||
const detailLoading = ref(false);
|
||||
const detail = ref<any>(null);
|
||||
|
||||
const columns = [
|
||||
{ title: '结算单号', dataIndex: 'settlement_no', key: 'settlement_no', width: 180 },
|
||||
{ title: '方式', dataIndex: 'settlement_type_text', key: 'settlement_type_text', width: 100 },
|
||||
{ title: '金额', dataIndex: 'amount', key: 'amount', width: 100 },
|
||||
{ title: '明细数', dataIndex: 'record_count', key: 'record_count', width: 80 },
|
||||
{ title: '时间', dataIndex: 'created_at_text', key: 'created_at_text', width: 170 },
|
||||
{ title: '操作', key: 'action', width: 80 },
|
||||
];
|
||||
|
||||
async function loadList() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await getSelfSettlementListApi({
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
});
|
||||
list.value = res?.items ?? [];
|
||||
total.value = res?.total ?? 0;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadList);
|
||||
|
||||
function onPageChange(p: number, ps: number) {
|
||||
page.value = p;
|
||||
pageSize.value = ps;
|
||||
loadList();
|
||||
}
|
||||
|
||||
async function openDetail(id: number) {
|
||||
detailVisible.value = true;
|
||||
detailLoading.value = true;
|
||||
try {
|
||||
detail.value = await getSelfSettlementDetailApi({ id });
|
||||
} finally {
|
||||
detailLoading.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height title="结算记录">
|
||||
<Spin :spinning="loading">
|
||||
<Empty v-if="!loading && !list.length" description="暂无结算记录" />
|
||||
<Table
|
||||
v-else
|
||||
:columns="columns"
|
||||
:data-source="list"
|
||||
:pagination="{
|
||||
current: page,
|
||||
pageSize,
|
||||
total,
|
||||
showSizeChanger: true,
|
||||
onChange: onPageChange,
|
||||
}"
|
||||
row-key="id"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'action'">
|
||||
<Button size="small" type="link" @click="openDetail(record.id)">
|
||||
详情
|
||||
</Button>
|
||||
</template>
|
||||
</template>
|
||||
</Table>
|
||||
</Spin>
|
||||
|
||||
<Drawer v-model:open="detailVisible" title="结算详情" width="640">
|
||||
<Spin :spinning="detailLoading">
|
||||
<template v-if="detail">
|
||||
<p>结算单号:{{ detail.settlement_no }}</p>
|
||||
<p>结算金额:¥{{ detail.amount }}</p>
|
||||
<p>明细条数:{{ detail.record_count }}</p>
|
||||
<p v-if="detail.remark">备注:{{ detail.remark }}</p>
|
||||
<div v-if="detail.proof_images?.length" class="mt-4">
|
||||
<p class="mb-2">结算凭证</p>
|
||||
<Image.PreviewGroup>
|
||||
<Image
|
||||
v-for="(img, idx) in detail.proof_images"
|
||||
:key="idx"
|
||||
:src="img"
|
||||
:width="100"
|
||||
class="mr-2"
|
||||
/>
|
||||
</Image.PreviewGroup>
|
||||
</div>
|
||||
</template>
|
||||
</Spin>
|
||||
</Drawer>
|
||||
</Page>
|
||||
</template>
|
||||
@@ -29,3 +29,31 @@ export async function getOrderReconciliationDetailApi(params: {
|
||||
}) {
|
||||
return requestClient.get<any>(`${prefix}reconciliation-detail`, { params });
|
||||
}
|
||||
|
||||
export async function getChinaErpSyncLogsApi(params: {
|
||||
order_id: number;
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
}) {
|
||||
return requestClient.get<{
|
||||
list: Array<{
|
||||
content: string;
|
||||
content_preview: string;
|
||||
created_at: string;
|
||||
id: number;
|
||||
is_success: number;
|
||||
order_id: number;
|
||||
}>;
|
||||
page: number;
|
||||
pageSize: number;
|
||||
total: number;
|
||||
}>(`${prefix}china-erp-sync-logs`, { params });
|
||||
}
|
||||
|
||||
export async function syncChinaOrderToErpApi(data: { order_id: number }) {
|
||||
return requestClient.post<any>(`${prefix}sync-china-erp`, data);
|
||||
}
|
||||
|
||||
export async function accrueSalespersonCommissionApi(data: { order_id: number }) {
|
||||
return requestClient.post<any>('salesperson/accrue-order', data);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,224 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useAccess } from '@vben/access';
|
||||
import { useVbenDrawer } from '@vben/common-ui';
|
||||
|
||||
import {
|
||||
Button,
|
||||
Descriptions,
|
||||
Modal as AntdModal,
|
||||
Space,
|
||||
Spin,
|
||||
Table,
|
||||
Tag,
|
||||
message,
|
||||
} from 'ant-design-vue';
|
||||
|
||||
import {
|
||||
getChinaErpSyncLogsApi,
|
||||
syncChinaOrderToErpApi,
|
||||
} from '#/views/business/order/api/order-ops';
|
||||
|
||||
defineOptions({ name: 'ChinaErpSyncLogDrawer' });
|
||||
|
||||
const emit = defineEmits<{
|
||||
synced: [];
|
||||
}>();
|
||||
|
||||
const { hasAccessByCodes } = useAccess();
|
||||
|
||||
const canSync = computed(() => hasAccessByCodes(['Super Admin']));
|
||||
|
||||
const loading = ref(false);
|
||||
const syncing = ref(false);
|
||||
const logs = ref<
|
||||
Array<{
|
||||
content: string;
|
||||
content_preview: string;
|
||||
created_at: string;
|
||||
id: number;
|
||||
is_success: number;
|
||||
order_id: number;
|
||||
}>
|
||||
>([]);
|
||||
const total = ref(0);
|
||||
const page = ref(1);
|
||||
const pageSize = ref(10);
|
||||
const orderId = ref(0);
|
||||
const orderNo = ref('');
|
||||
const isSyncErp = ref(0);
|
||||
|
||||
const showSyncButton = computed(
|
||||
() => canSync.value && isSyncErp.value !== 1,
|
||||
);
|
||||
|
||||
const columns = [
|
||||
{ title: 'ID', dataIndex: 'id', key: 'id', width: 70 },
|
||||
{ title: '同步时间', dataIndex: 'created_at', key: 'created_at', width: 180 },
|
||||
{ title: '结果', dataIndex: 'is_success', key: 'is_success', width: 90 },
|
||||
{ title: '内容摘要', dataIndex: 'content_preview', key: 'content_preview', ellipsis: true },
|
||||
{ title: '操作', key: 'action', width: 90 },
|
||||
];
|
||||
|
||||
const [Drawer, drawerApi] = useVbenDrawer({
|
||||
class: 'w-[70%]',
|
||||
placement: 'right',
|
||||
showConfirmButton: false,
|
||||
showCancelButton: false,
|
||||
destroyOnClose: true,
|
||||
onOpenChange(isOpen) {
|
||||
if (isOpen) {
|
||||
const data = drawerApi.getData<{
|
||||
is_sync_erp?: number;
|
||||
order_id: number;
|
||||
order_no?: string;
|
||||
}>();
|
||||
orderId.value = data?.order_id ?? 0;
|
||||
orderNo.value = data?.order_no ?? '';
|
||||
isSyncErp.value = data?.is_sync_erp ?? 0;
|
||||
page.value = 1;
|
||||
void loadLogs();
|
||||
} else {
|
||||
logs.value = [];
|
||||
total.value = 0;
|
||||
orderId.value = 0;
|
||||
orderNo.value = '';
|
||||
isSyncErp.value = 0;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
async function loadLogs() {
|
||||
if (!orderId.value) {
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
drawerApi.setState({ loading: true });
|
||||
try {
|
||||
const res = await getChinaErpSyncLogsApi({
|
||||
order_id: orderId.value,
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
});
|
||||
logs.value = res.list ?? [];
|
||||
total.value = res.total ?? 0;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
drawerApi.setState({ loading: false });
|
||||
}
|
||||
}
|
||||
|
||||
function onPageChange(p: number, ps: number) {
|
||||
page.value = p;
|
||||
pageSize.value = ps;
|
||||
void loadLogs();
|
||||
}
|
||||
|
||||
function showContentDetail(record: { content: string }) {
|
||||
let text = record.content;
|
||||
try {
|
||||
const parsed = JSON.parse(record.content);
|
||||
text = JSON.stringify(parsed, null, 2);
|
||||
} catch {
|
||||
// keep raw
|
||||
}
|
||||
AntdModal.info({
|
||||
title: '同步详情',
|
||||
width: 'min(800px, 96vw)',
|
||||
content: text,
|
||||
okText: '关闭',
|
||||
});
|
||||
}
|
||||
|
||||
function handleSync() {
|
||||
if (!orderId.value) {
|
||||
return;
|
||||
}
|
||||
AntdModal.confirm({
|
||||
title: '同步到 ERP',
|
||||
content: `确认将订单 ${orderNo.value || orderId.value} 同步到 MES?`,
|
||||
okText: '确认同步',
|
||||
cancelText: '取消',
|
||||
onOk: async () => {
|
||||
syncing.value = true;
|
||||
try {
|
||||
await syncChinaOrderToErpApi({ order_id: orderId.value });
|
||||
message.success('同步成功');
|
||||
isSyncErp.value = 1;
|
||||
emit('synced');
|
||||
page.value = 1;
|
||||
await loadLogs();
|
||||
} finally {
|
||||
syncing.value = false;
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Drawer title="中药 ERP 同步记录">
|
||||
<Spin :spinning="loading">
|
||||
<div class="flex flex-col gap-4">
|
||||
<Descriptions bordered :column="2" size="small">
|
||||
<Descriptions.Item label="订单号">
|
||||
{{ orderNo || '—' }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="ERP 状态">
|
||||
<Tag v-if="isSyncErp === 1" color="green">已同步</Tag>
|
||||
<Tag v-else color="red">未同步</Tag>
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
|
||||
<Space>
|
||||
<Button
|
||||
v-if="showSyncButton"
|
||||
:loading="syncing"
|
||||
type="primary"
|
||||
@click="handleSync"
|
||||
>
|
||||
同步到 ERP
|
||||
</Button>
|
||||
<Button :loading="loading" @click="loadLogs">刷新</Button>
|
||||
</Space>
|
||||
|
||||
<Table
|
||||
:columns="columns"
|
||||
:data-source="logs"
|
||||
:loading="loading"
|
||||
:pagination="{
|
||||
current: page,
|
||||
pageSize,
|
||||
total,
|
||||
showSizeChanger: true,
|
||||
showTotal: (t: number) => `共 ${t} 条`,
|
||||
onChange: onPageChange,
|
||||
}"
|
||||
row-key="id"
|
||||
size="small"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'is_success'">
|
||||
<Tag :color="record.is_success === 0 ? 'success' : 'error'">
|
||||
{{ record.is_success === 0 ? '成功' : '失败' }}
|
||||
</Tag>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'action'">
|
||||
<Button size="small" type="link" @click="showContentDetail(record)">
|
||||
详情
|
||||
</Button>
|
||||
</template>
|
||||
</template>
|
||||
</Table>
|
||||
|
||||
<div
|
||||
v-if="!loading && logs.length === 0"
|
||||
class="py-4 text-center text-gray-500"
|
||||
>
|
||||
暂无按订单关联的同步记录
|
||||
</div>
|
||||
</div>
|
||||
</Spin>
|
||||
</Drawer>
|
||||
</template>
|
||||
@@ -16,28 +16,26 @@ export const gridOptions: VxeGridProps<RowType> = {
|
||||
labelField: '',
|
||||
},
|
||||
columns: [
|
||||
// { type: 'checkbox', width: 60 },
|
||||
{ type: 'expand', width: 80, slots: { content: 'expand-content' } },
|
||||
{ field: 'id', align: 'left', title: 'ID', width: 100 },
|
||||
{ field: 'order_no', align: 'left', width: 200, title: '订单号' },
|
||||
{
|
||||
field: 'order_no',
|
||||
align: 'left',
|
||||
width: 220,
|
||||
title: '订单号/诊所',
|
||||
slots: { default: 'order-store' },
|
||||
},
|
||||
{
|
||||
field: 'user.avatarUrl',
|
||||
title: '下单用户信息',
|
||||
slots: { default: 'avatar' },
|
||||
width: 100,
|
||||
},
|
||||
{ field: 'store.name', title: '诊所名称', width: 240 },
|
||||
{
|
||||
field: 'address.name',
|
||||
title: '收货人姓名',
|
||||
width: 120,
|
||||
slots: { default: 'address-name' },
|
||||
},
|
||||
{
|
||||
field: 'address.mobile',
|
||||
title: '收货人联系方式',
|
||||
width: 120,
|
||||
slots: { default: 'address-mobile' },
|
||||
field: 'express_info',
|
||||
title: '收货信息',
|
||||
width: 200,
|
||||
slots: { default: 'express-info' },
|
||||
},
|
||||
{
|
||||
field: 'delivery_method',
|
||||
@@ -45,13 +43,17 @@ export const gridOptions: VxeGridProps<RowType> = {
|
||||
width: 120,
|
||||
slots: { default: 'delivery-method' },
|
||||
},
|
||||
{ field: 'items_price', width: 120, title: '药品总价' },
|
||||
{ field: 'total_pay_price', width: 120, title: '支付总价' },
|
||||
{
|
||||
field: 'register_price',
|
||||
title: '挂号金额',
|
||||
width: 110,
|
||||
slots: { default: 'register-fee' },
|
||||
field: 'price_info',
|
||||
title: '金额',
|
||||
width: 160,
|
||||
slots: { default: 'price-info' },
|
||||
},
|
||||
{
|
||||
field: 'salesperson',
|
||||
title: '推广员',
|
||||
width: 180,
|
||||
slots: { default: 'salesperson' },
|
||||
},
|
||||
{
|
||||
field: 'is_sync_erp',
|
||||
@@ -83,7 +85,7 @@ export const gridOptions: VxeGridProps<RowType> = {
|
||||
title: '操作',
|
||||
fixed: 'right',
|
||||
slots: { default: 'action' },
|
||||
width: 200,
|
||||
width: 300,
|
||||
},
|
||||
],
|
||||
keepSource: true,
|
||||
@@ -94,13 +96,8 @@ export const gridOptions: VxeGridProps<RowType> = {
|
||||
rowConfig: {
|
||||
useKey: true,
|
||||
},
|
||||
// scrollY: {
|
||||
// enabled: true,
|
||||
// gt: 0,
|
||||
// },
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
// 请求后端接口方法
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getOrderList({
|
||||
page: page.currentPage,
|
||||
@@ -110,27 +107,20 @@ export const gridOptions: VxeGridProps<RowType> = {
|
||||
},
|
||||
},
|
||||
},
|
||||
// height: 'auto',
|
||||
border: false,
|
||||
toolbarConfig: {
|
||||
// 是否显示搜索表单控制按钮
|
||||
// @ts-ignore 正式环境时有完整的类型声明
|
||||
search: true,
|
||||
refresh: true, // 刷新
|
||||
print: false, // 打印
|
||||
export: false, // 导出
|
||||
// custom: true, // 自定义列
|
||||
zoom: true, // 最大化最小化
|
||||
refresh: true,
|
||||
print: false,
|
||||
export: false,
|
||||
zoom: true,
|
||||
slots: {
|
||||
buttons: 'toolbar-buttons',
|
||||
},
|
||||
custom: {
|
||||
// 自定义列-图标
|
||||
icon: 'vxe-icon-menu',
|
||||
},
|
||||
},
|
||||
expandConfig: {
|
||||
// expandAll: true,
|
||||
},
|
||||
expandConfig: {},
|
||||
showOverflow: false,
|
||||
};
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
} from '@vben/common-ui';
|
||||
import { SvgCakeIcon } from '@vben/icons';
|
||||
|
||||
import { Button, Image, message, Modal as AntdModal, Space, Switch, Table, Tag } from 'ant-design-vue';
|
||||
import { Button, Image, message, Modal as AntdModal, Popover, Space, Switch, Table, Tag } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { TableAction } from '#/components/table-action';
|
||||
@@ -25,7 +25,8 @@ import {
|
||||
saleAmountApi,
|
||||
updateFreeShipping,
|
||||
} from '#/views/business/order/product-order/api';
|
||||
import { simulatePayApi } from '#/views/business/order/api/order-ops';
|
||||
import { simulatePayApi, accrueSalespersonCommissionApi } from '#/views/business/order/api/order-ops';
|
||||
import ChinaErpSyncLogDrawer from '#/views/business/order/components/china-erp-sync-log-drawer.vue';
|
||||
import OrderTraceDrawer from '#/views/business/order/components/order-trace-drawer.vue';
|
||||
import PrescriptionDetail from '#/views/doctor/doctor-reception/components/PrescriptionDetail.vue';
|
||||
|
||||
@@ -187,6 +188,19 @@ const [TraceDrawer, traceDrawerApi] = useVbenDrawer({
|
||||
connectedComponent: OrderTraceDrawer,
|
||||
});
|
||||
|
||||
const [ChinaErpSyncDrawer, chinaErpSyncDrawerApi] = useVbenDrawer({
|
||||
connectedComponent: ChinaErpSyncLogDrawer,
|
||||
});
|
||||
|
||||
function openChinaErpSyncLog(row: Record<string, any>) {
|
||||
chinaErpSyncDrawerApi.setData({
|
||||
order_id: row.id,
|
||||
order_no: row.order_no,
|
||||
is_sync_erp: row.is_sync_erp,
|
||||
});
|
||||
chinaErpSyncDrawerApi.open();
|
||||
}
|
||||
|
||||
function openOrderTrace(row: Record<string, any>) {
|
||||
traceDrawerApi.setData({
|
||||
scene: 'product',
|
||||
@@ -210,6 +224,49 @@ function handleSimulatePay(row: Record<string, any>) {
|
||||
});
|
||||
}
|
||||
|
||||
const accruingOrderIds = ref<number[]>([]);
|
||||
|
||||
async function handleAccrueSalesperson(row: Record<string, any>) {
|
||||
if (accruingOrderIds.value.includes(row.id)) {
|
||||
return;
|
||||
}
|
||||
accruingOrderIds.value.push(row.id);
|
||||
try {
|
||||
await accrueSalespersonCommissionApi({ order_id: row.id });
|
||||
message.success('分成成功');
|
||||
await gridApi.query();
|
||||
} catch (error: any) {
|
||||
message.error(error?.message || '分成失败');
|
||||
} finally {
|
||||
accruingOrderIds.value = accruingOrderIds.value.filter((id) => id !== row.id);
|
||||
}
|
||||
}
|
||||
|
||||
function formatExpressAddress(row: Record<string, any>) {
|
||||
if (Number(row.delivery_method) === 1) {
|
||||
return row.store?.position || row.store?.name || '到店自提';
|
||||
}
|
||||
const region = row.address?.region || row.express_region || '';
|
||||
const detail = row.address?.detail_address || row.express_address || '';
|
||||
return [region, detail].filter(Boolean).join(' ') || '—';
|
||||
}
|
||||
|
||||
function salespersonStatusColor(text: string) {
|
||||
if (text === '已分成') return 'success';
|
||||
if (text === '未分成') return 'warning';
|
||||
if (text === '未支付') return 'default';
|
||||
return 'default';
|
||||
}
|
||||
|
||||
function formatCommissionRecordDetail(record: Record<string, any>) {
|
||||
const path = record.commission_path_text || '—';
|
||||
const rule = record.commission_rule_text || '—';
|
||||
if (record.commission_mode_text === '比例分成') {
|
||||
return `${path} · ${rule}`;
|
||||
}
|
||||
return `${path} · ${record.commission_mode_text || '固定单价'} · ${rule}`;
|
||||
}
|
||||
|
||||
const openPrescriptionDetail = (values) => {
|
||||
// 打开西药处方模态框逻辑
|
||||
PrescriptionDetailModalApi.setData({
|
||||
@@ -351,6 +408,7 @@ const openOrderAmountVerify = () => {
|
||||
<RefundModal />
|
||||
<PrescriptionDetailModal />
|
||||
<TraceDrawer />
|
||||
<ChinaErpSyncDrawer @synced="() => gridApi.query()" />
|
||||
<AnalysisOverview :items="overviewItems" :my-card="false" />
|
||||
<Grid>
|
||||
<template #toolbar-buttons>
|
||||
@@ -397,36 +455,126 @@ const openOrderAmountVerify = () => {
|
||||
<Image :src="row.user.avatarurl || '/img/user-default-avatar.png'" />
|
||||
{{ row.user.nickname }}
|
||||
</template>
|
||||
<template #address-name="{ row }">
|
||||
{{
|
||||
row.address?.name ||
|
||||
row.express_name ||
|
||||
row.patient?.name ||
|
||||
row.cancel_remark
|
||||
}}
|
||||
<template #order-store="{ row }">
|
||||
<div class="leading-snug">
|
||||
<div class="font-medium">{{ row.order_no }}</div>
|
||||
<div class="text-xs text-gray-500">{{ row.store?.name || '—' }}</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #address-mobile="{ row }">
|
||||
{{ row.address?.mobile || row.patient_mobile }}
|
||||
<template #express-info="{ row }">
|
||||
<div class="space-y-0.5 text-sm leading-snug">
|
||||
<div>
|
||||
{{
|
||||
row.address?.name ||
|
||||
row.express_name ||
|
||||
row.patient ||
|
||||
row.cancel_remark ||
|
||||
'—'
|
||||
}}
|
||||
</div>
|
||||
<div class="text-gray-500">
|
||||
{{ row.address?.mobile || row.patient_mobile || '—' }}
|
||||
</div>
|
||||
<div class="text-xs text-gray-500">{{ formatExpressAddress(row) }}</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #price-info="{ row }">
|
||||
<div class="space-y-0.5 text-sm leading-snug">
|
||||
<div>药品:¥{{ row.items_price ?? '0.00' }}</div>
|
||||
<div>支付:¥{{ row.total_pay_price ?? '0.00' }}</div>
|
||||
<div>
|
||||
挂号:
|
||||
<Button
|
||||
v-if="row.register_order_no"
|
||||
class="!h-auto !px-0 !py-0"
|
||||
type="link"
|
||||
@click="goRegisterOrder(row)"
|
||||
>
|
||||
{{ formatRegisterAmount(row) }}
|
||||
</Button>
|
||||
<span v-else>{{ formatRegisterAmount(row) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #salesperson="{ row }">
|
||||
<div v-if="row.salesperson?.id" class="space-y-1 text-sm leading-snug">
|
||||
<!-- <Tag :color="salespersonStatusColor(row.salesperson.commission_status_text)">-->
|
||||
<!-- {{ row.salesperson.commission_status_text }}-->
|
||||
<!-- </Tag>-->
|
||||
<!-- <div v-if="row.is_pay === 1" class="text-orange-600">-->
|
||||
<!-- 分成:¥{{ row.salesperson.commission_amount || '0.00' }}-->
|
||||
<!-- </div>-->
|
||||
<Popover trigger="click" placement="topLeft">
|
||||
<template #content>
|
||||
<div class="max-w-xs space-y-2 text-sm">
|
||||
<div
|
||||
v-if="!(row.salesperson.commission_records?.length > 0)"
|
||||
class="text-gray-500"
|
||||
>
|
||||
暂无分成明细
|
||||
</div>
|
||||
<div
|
||||
v-for="(record, idx) in row.salesperson.commission_records || []"
|
||||
:key="idx"
|
||||
class="border-b border-gray-100 pb-2 last:border-0 last:pb-0"
|
||||
>
|
||||
<div class="font-medium">{{ record.drug_name || '—' }}</div>
|
||||
<div class="text-gray-500">
|
||||
{{ formatCommissionRecordDetail(record) }}
|
||||
</div>
|
||||
<div class="text-orange-600">¥{{ record.commission_amount }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div class="flex cursor-pointer items-center gap-2 hover:text-blue-600">
|
||||
<Image
|
||||
:src="row.salesperson.avatar || '/img/user-default-avatar.png'"
|
||||
:width="28"
|
||||
:height="28"
|
||||
class="rounded-full object-cover"
|
||||
/>
|
||||
<span>{{ row.salesperson.nick_name || '—' }}({{row.salesperson.commission_status_text}})</span>
|
||||
</div>
|
||||
</Popover>
|
||||
<Button
|
||||
v-if="
|
||||
row.is_pay === 1 &&
|
||||
row.salesperson_id > 0 &&
|
||||
!row.salesperson.has_commission
|
||||
"
|
||||
class="!h-auto !px-0 !py-0"
|
||||
type="link"
|
||||
size="small"
|
||||
:loading="accruingOrderIds.includes(row.id)"
|
||||
@click="handleAccrueSalesperson(row)"
|
||||
>
|
||||
立即分成
|
||||
</Button>
|
||||
</div>
|
||||
<span v-else class="text-sm text-gray-500">
|
||||
{{ row.salesperson?.commission_status_text || '无推广员' }}
|
||||
</span>
|
||||
</template>
|
||||
<template #pay-time="{ row }">
|
||||
{{ row?.pay_time || '未支付' }}
|
||||
</template>
|
||||
<template #register-fee="{ row }">
|
||||
<div class="flex flex-col items-start leading-snug">
|
||||
<Button
|
||||
v-if="row.register_order_no"
|
||||
class="!h-auto !px-0 !py-0"
|
||||
type="link"
|
||||
@click="goRegisterOrder(row)"
|
||||
>
|
||||
{{ formatRegisterAmount(row) }}
|
||||
</Button>
|
||||
<span v-else>{{ formatRegisterAmount(row) }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<template #is-sync-erp="{ row }">
|
||||
<Tag v-if="row.is_sync_erp === 1" color="green">已同步</Tag>
|
||||
<Tag v-else color="red">未同步</Tag>
|
||||
<template v-if="row.prescription_type === 1">
|
||||
<Tag v-if="row.is_sync_erp === 1" color="green">已同步</Tag>
|
||||
<Tag v-else color="red">未同步</Tag>
|
||||
<Button
|
||||
class="!h-auto !px-0 !py-0"
|
||||
size="small"
|
||||
type="link"
|
||||
@click="openChinaErpSyncLog(row)"
|
||||
>
|
||||
记录
|
||||
</Button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<Tag v-if="row.is_sync_erp === 1" color="green">已同步</Tag>
|
||||
<Tag v-else color="red">未同步</Tag>
|
||||
</template>
|
||||
</template>
|
||||
<template #is-free-shipping="{ row }">
|
||||
<Switch
|
||||
|
||||
@@ -133,6 +133,10 @@ export async function getCommissionListApi(params: Record<string, any>) {
|
||||
return requestClient.get<any>(`salesperson/commission-list`, { params });
|
||||
}
|
||||
|
||||
export async function getCommissionOrderListApi(params: Record<string, any>) {
|
||||
return requestClient.get<any>(`salesperson/commission-order-list`, { params });
|
||||
}
|
||||
|
||||
export async function getSettlementPreviewApi(params: Record<string, any>) {
|
||||
return requestClient.get<any>(`salesperson/settlement-preview`, { params });
|
||||
}
|
||||
@@ -148,3 +152,29 @@ export async function getSettlementListApi(params: Record<string, any>) {
|
||||
export async function getSettlementDetailApi(params: { id: number }) {
|
||||
return requestClient.get<any>(`salesperson/settlement-detail`, { params });
|
||||
}
|
||||
|
||||
export async function getUserBindListApi(params: Record<string, any>) {
|
||||
return requestClient.get<any>(`salesperson/user-bind-list`, { params });
|
||||
}
|
||||
|
||||
export async function openAdminAccountApi(data: {
|
||||
salesperson_id: number;
|
||||
store_id?: number;
|
||||
}) {
|
||||
return requestClient.post<any>(`salesperson/open-admin-account`, data);
|
||||
}
|
||||
|
||||
export async function getPlatformSalespersonListApi(params: Record<string, any>) {
|
||||
return requestClient.get<any>(`salesperson/platform-list`, { params });
|
||||
}
|
||||
|
||||
export async function getPlatformStoreOptionsApi(params: { keyword?: string }) {
|
||||
return requestClient.get<{ id: number; name: string; position: string }[]>(
|
||||
`salesperson/platform-store-options`,
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
export async function platformSalespersonCreateApi(data: Record<string, any>) {
|
||||
return requestClient.post<any>(`salesperson/platform-create`, data);
|
||||
}
|
||||
|
||||
@@ -3,18 +3,26 @@ import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Button, Card, Empty, Space, Tag } from 'ant-design-vue';
|
||||
import { Button, Card, Empty, Popover, Space, Tag, message } from 'ant-design-vue';
|
||||
|
||||
import { salespersonListApi } from '#/views/business/store/settings/api';
|
||||
import {
|
||||
openAdminAccountApi,
|
||||
salespersonListApi,
|
||||
} from '#/views/business/store/settings/api';
|
||||
import QrCodePreview from '#/views/business/store/settings/components/SalespersonQrCodePreview.vue';
|
||||
import SalespersonCommissionDrawer from '#/views/business/store/settings/components/SalespersonCommissionDrawer.vue';
|
||||
import SalespersonCreateModal from '#/views/business/store/settings/components/SalespersonCreateModal.vue';
|
||||
import SalespersonUserBindDrawer from '#/views/business/store/settings/components/SalespersonUserBindDrawer.vue';
|
||||
|
||||
const listData = ref<{ total: number; items: any[] }>({
|
||||
total: 0,
|
||||
items: [],
|
||||
});
|
||||
|
||||
const bindDrawerOpen = ref(false);
|
||||
const bindDrawerSalespersonId = ref(0);
|
||||
const openingAccountId = ref(0);
|
||||
|
||||
const getList = () => {
|
||||
salespersonListApi().then((res) => {
|
||||
listData.value = {
|
||||
@@ -62,6 +70,22 @@ function openEditModal(item: any) {
|
||||
SalespersonCreateModalApi.open();
|
||||
}
|
||||
|
||||
function openBindDrawer(item: any) {
|
||||
bindDrawerSalespersonId.value = item.id;
|
||||
bindDrawerOpen.value = true;
|
||||
}
|
||||
|
||||
async function handleOpenAdminAccount(item: any) {
|
||||
openingAccountId.value = item.id;
|
||||
try {
|
||||
await openAdminAccountApi({ salesperson_id: item.id });
|
||||
message.success('后台账号开通成功,默认密码 Xk123456@');
|
||||
getList();
|
||||
} finally {
|
||||
openingAccountId.value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
function splitTypeLabel(type: number) {
|
||||
return Number(type) === 1 ? '百分比' : '固定金额';
|
||||
}
|
||||
@@ -69,6 +93,10 @@ function splitTypeLabel(type: number) {
|
||||
function splitTypeColor(type: number) {
|
||||
return Number(type) === 1 ? 'blue' : 'orange';
|
||||
}
|
||||
|
||||
function tcmBaseLabel(type: number) {
|
||||
return Number(type) === 1 ? '处方总价' : '药店利润';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -93,66 +121,95 @@ function splitTypeColor(type: number) {
|
||||
<div
|
||||
class="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4"
|
||||
>
|
||||
<Card
|
||||
v-for="item in listData.items"
|
||||
:key="item.id"
|
||||
class="rounded-lg shadow-sm"
|
||||
>
|
||||
<div class="mb-3 flex items-start justify-between gap-2">
|
||||
<h3 class="text-lg font-semibold">{{ item.nick_name || '未知' }}</h3>
|
||||
<Tag :color="splitTypeColor(item.split_type)">
|
||||
{{ splitTypeLabel(item.split_type) }}
|
||||
<template v-if="Number(item.split_type) === 1">
|
||||
· {{ item.split }}%
|
||||
</template>
|
||||
</Tag>
|
||||
</div>
|
||||
<Card
|
||||
v-for="item in listData.items"
|
||||
:key="item.id"
|
||||
class="rounded-lg shadow-sm"
|
||||
>
|
||||
<div class="mb-3 flex items-start justify-between gap-2">
|
||||
<h3 class="text-lg font-semibold">{{ item.nick_name || '未知' }}</h3>
|
||||
<Space direction="vertical" align="end" size="small">
|
||||
<Tag :color="splitTypeColor(item.split_type)">
|
||||
西药·{{ splitTypeLabel(item.split_type) }}
|
||||
<template v-if="Number(item.split_type) === 1">
|
||||
· {{ item.split }}%
|
||||
</template>
|
||||
</Tag>
|
||||
<Tag v-if="Number(item.tcm_split) > 0" color="green">
|
||||
中药·{{ item.tcm_split }}%·{{ tcmBaseLabel(item.tcm_base_type) }}
|
||||
</Tag>
|
||||
<Tag :color="item.has_admin_account ? 'success' : 'default'">
|
||||
{{ item.has_admin_account ? '已开通后台' : '未开通后台' }}
|
||||
</Tag>
|
||||
</Space>
|
||||
</div>
|
||||
|
||||
<div class="mb-4 space-y-1.5 text-sm text-gray-600">
|
||||
<div>{{ item.phone }}</div>
|
||||
<div>加入:{{ item.created_at }}</div>
|
||||
<div class="flex justify-between pt-1">
|
||||
<span>累计获客</span>
|
||||
<span class="font-medium text-blue-600">{{
|
||||
item.count?.user_number ?? 0
|
||||
}}</span>
|
||||
<div class="mb-4 space-y-1.5 text-sm text-gray-600">
|
||||
<div>{{ item.phone }}</div>
|
||||
<div>加入:{{ item.created_at }}</div>
|
||||
<Popover trigger="click" title="获客记录">
|
||||
<template #content>
|
||||
<div class="w-[420px]">
|
||||
<SalespersonUserBindDrawer
|
||||
:open="true"
|
||||
:salesperson-id="item.id"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<div
|
||||
class="flex cursor-pointer justify-between pt-1 hover:text-blue-500"
|
||||
@click="openBindDrawer(item)"
|
||||
>
|
||||
<span>累计获客</span>
|
||||
<span class="font-medium text-blue-600">{{
|
||||
item.count?.user_number ?? 0
|
||||
}}</span>
|
||||
</div>
|
||||
</Popover>
|
||||
<div class="flex justify-between">
|
||||
<span>待结算</span>
|
||||
<span class="font-medium text-orange-600"
|
||||
>¥{{ item.count?.pending_amount || '0.00' }}</span
|
||||
>
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
<span>已结算</span>
|
||||
<span class="font-medium text-green-600"
|
||||
>¥{{ item.count?.settled_amount || '0.00' }}</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
<span>待结算</span>
|
||||
<span class="font-medium text-orange-600"
|
||||
>¥{{ item.count?.pending_amount || '0.00' }}</span
|
||||
>
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
<span>已结算</span>
|
||||
<span class="font-medium text-green-600"
|
||||
>¥{{ item.count?.settled_amount || '0.00' }}</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Space wrap class="w-full">
|
||||
<Button size="small" type="primary" @click="openCommissionDrawer(item)">
|
||||
分成与结算
|
||||
</Button>
|
||||
<Button size="small" @click="openEditModal(item)">编辑</Button>
|
||||
<Button
|
||||
v-if="Number(item.split_type) === 0"
|
||||
size="small"
|
||||
type="primary"
|
||||
@click="openEditModal(item)"
|
||||
>
|
||||
药品分成
|
||||
</Button>
|
||||
<Button
|
||||
v-if="item.qr_code?.qr_code"
|
||||
size="small"
|
||||
@click="openQrCode(item)"
|
||||
>
|
||||
二维码
|
||||
</Button>
|
||||
</Space>
|
||||
</Card>
|
||||
<Space wrap class="w-full">
|
||||
<Button size="small" type="primary" @click="openCommissionDrawer(item)">
|
||||
分成与结算
|
||||
</Button>
|
||||
<Button size="small" @click="openEditModal(item)">编辑</Button>
|
||||
<Button
|
||||
v-if="Number(item.split_type) === 0"
|
||||
size="small"
|
||||
type="primary"
|
||||
@click="openEditModal(item)"
|
||||
>
|
||||
药品分成
|
||||
</Button>
|
||||
<Button
|
||||
v-if="item.qr_code?.qr_code"
|
||||
size="small"
|
||||
@click="openQrCode(item)"
|
||||
>
|
||||
二维码
|
||||
</Button>
|
||||
<Button
|
||||
v-if="!item.has_admin_account"
|
||||
size="small"
|
||||
:loading="openingAccountId === item.id"
|
||||
@click="handleOpenAdminAccount(item)"
|
||||
>
|
||||
开通后台
|
||||
</Button>
|
||||
</Space>
|
||||
</Card>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
@@ -18,6 +18,7 @@ import SalespersonSettlementConfirmModal from '#/components/salesperson/Salesper
|
||||
import {
|
||||
confirmSettlementApi,
|
||||
getCommissionListApi,
|
||||
getCommissionOrderListApi,
|
||||
getSettlementDetailApi,
|
||||
getSettlementListApi,
|
||||
getSettlementPreviewApi,
|
||||
@@ -43,10 +44,28 @@ const selectedRowKeys = ref<number[]>([]);
|
||||
const settlementList = ref<any[]>([]);
|
||||
const settlementDetail = ref<any>(null);
|
||||
const detailVisible = ref(false);
|
||||
const orderDetailVisible = ref(false);
|
||||
const orderDetailLoading = ref(false);
|
||||
const orderDetailData = ref<any[]>([]);
|
||||
const currentOrder = ref<{ order_id: number; order_no: string } | null>(null);
|
||||
const periodRange = ref<any[]>([]);
|
||||
const settlementConfirmRef = ref<InstanceType<typeof SalespersonSettlementConfirmModal>>();
|
||||
|
||||
const commissionColumns = [
|
||||
const orderCommissionColumns = [
|
||||
{ title: '订单号', dataIndex: 'order_no', width: 160 },
|
||||
{ title: '明细数', dataIndex: 'item_count', width: 80 },
|
||||
{ title: '分成总额', dataIndex: 'commission_amount', width: 100 },
|
||||
{ title: '支付时间', dataIndex: 'order_pay_at_text', width: 170 },
|
||||
{ title: '操作', key: 'action', width: 90 },
|
||||
];
|
||||
|
||||
const commissionDetailColumns = [
|
||||
{ title: '药品信息', dataIndex: 'drug_info', ellipsis: true },
|
||||
{ title: '分成金额', dataIndex: 'commission_amount', width: 100 },
|
||||
{ title: '分成时间', dataIndex: 'order_pay_at_text', width: 170 },
|
||||
];
|
||||
|
||||
const settlementLineColumns = [
|
||||
{ title: '订单号', dataIndex: 'order_no', width: 160 },
|
||||
{ title: '药品信息', dataIndex: 'drug_info', ellipsis: true },
|
||||
{ title: '分成金额', dataIndex: 'commission_amount', width: 100 },
|
||||
@@ -70,9 +89,9 @@ const rowSelection = computed(() =>
|
||||
activeTab.value === 'pending'
|
||||
? {
|
||||
selectedRowKeys: selectedRowKeys.value,
|
||||
onChange: (keys: number[], rows: any[]) => {
|
||||
onChange: (keys: number[]) => {
|
||||
selectedRowKeys.value = keys as number[];
|
||||
selectedOrderIds.value = [...new Set(rows.map((r) => r.order_id))];
|
||||
selectedOrderIds.value = keys as number[];
|
||||
},
|
||||
getCheckboxProps: () => ({ disabled: false }),
|
||||
}
|
||||
@@ -113,7 +132,7 @@ async function loadCommission() {
|
||||
params.start_at = dayjs(dateRange.value[0]).startOf('day').unix();
|
||||
params.end_at = dayjs(dateRange.value[1]).endOf('day').unix();
|
||||
}
|
||||
const res = await getCommissionListApi(params);
|
||||
const res = await getCommissionOrderListApi(params);
|
||||
commissionData.value = res?.items || [];
|
||||
commissionTotal.value = res?.total || 0;
|
||||
} finally {
|
||||
@@ -121,6 +140,23 @@ async function loadCommission() {
|
||||
}
|
||||
}
|
||||
|
||||
async function showOrderDetail(record: { order_id: number; order_no: string }) {
|
||||
currentOrder.value = record;
|
||||
orderDetailVisible.value = true;
|
||||
orderDetailLoading.value = true;
|
||||
try {
|
||||
const res = await getCommissionListApi({
|
||||
salesperson_id: salespersonId.value,
|
||||
order_id: record.order_id,
|
||||
page: 1,
|
||||
pageSize: 100,
|
||||
});
|
||||
orderDetailData.value = res?.items || [];
|
||||
} finally {
|
||||
orderDetailLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadSettlements() {
|
||||
if (!salespersonId.value) return;
|
||||
const res = await getSettlementListApi({
|
||||
@@ -214,7 +250,7 @@ defineExpose({ open });
|
||||
</Button>
|
||||
</div>
|
||||
<Table
|
||||
:columns="commissionColumns"
|
||||
:columns="orderCommissionColumns"
|
||||
:data-source="commissionData"
|
||||
:loading="loading"
|
||||
:pagination="{
|
||||
@@ -223,14 +259,22 @@ defineExpose({ open });
|
||||
total: commissionTotal,
|
||||
onChange: onPageChange,
|
||||
}"
|
||||
:row-key="(r) => r.id"
|
||||
:row-key="(r) => r.order_id"
|
||||
:row-selection="rowSelection"
|
||||
size="small"
|
||||
/>
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'action'">
|
||||
<Button type="link" size="small" @click="showOrderDetail(record)">
|
||||
查看明细
|
||||
</Button>
|
||||
</template>
|
||||
</template>
|
||||
</Table>
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane key="settled" tab="已结算">
|
||||
<Table
|
||||
:columns="commissionColumns"
|
||||
:columns="orderCommissionColumns"
|
||||
:data-source="commissionData"
|
||||
:loading="loading"
|
||||
:pagination="{
|
||||
@@ -239,9 +283,17 @@ defineExpose({ open });
|
||||
total: commissionTotal,
|
||||
onChange: onPageChange,
|
||||
}"
|
||||
:row-key="(r) => r.id"
|
||||
:row-key="(r) => r.order_id"
|
||||
size="small"
|
||||
/>
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'action'">
|
||||
<Button type="link" size="small" @click="showOrderDetail(record)">
|
||||
查看明细
|
||||
</Button>
|
||||
</template>
|
||||
</template>
|
||||
</Table>
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane key="history" tab="结算记录">
|
||||
<Table
|
||||
@@ -267,6 +319,21 @@ defineExpose({ open });
|
||||
@success="onSettlementSuccess"
|
||||
/>
|
||||
|
||||
<Drawer
|
||||
v-model:open="orderDetailVisible"
|
||||
:title="`订单明细 - ${currentOrder?.order_no || ''}`"
|
||||
width="720"
|
||||
destroy-on-close
|
||||
>
|
||||
<Table
|
||||
:columns="commissionDetailColumns"
|
||||
:data-source="orderDetailData"
|
||||
:loading="orderDetailLoading"
|
||||
:row-key="(r) => r.id"
|
||||
size="small"
|
||||
/>
|
||||
</Drawer>
|
||||
|
||||
<Drawer v-model:open="detailVisible" title="结算单详情" width="720" destroy-on-close>
|
||||
<div v-if="settlementDetail" class="mb-3">
|
||||
<p>单号:{{ settlementDetail.settlement_no }}</p>
|
||||
@@ -289,7 +356,7 @@ defineExpose({ open });
|
||||
</div>
|
||||
</div>
|
||||
<Table
|
||||
:columns="commissionColumns"
|
||||
:columns="settlementLineColumns"
|
||||
:data-source="settlementDetail?.records || []"
|
||||
:row-key="(r) => r.id"
|
||||
size="small"
|
||||
|
||||
@@ -3,10 +3,12 @@ import { computed, nextTick, ref, watch } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
import { message, Select } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
getPlatformStoreOptionsApi,
|
||||
platformSalespersonCreateApi,
|
||||
salespersonCreateApi,
|
||||
salespersonUpdateApi,
|
||||
saveDrugCommissionApi,
|
||||
@@ -16,8 +18,13 @@ import SalespersonDrugCommissionEditor from '#/views/business/store/settings/com
|
||||
import { salespersonModalFormProps } from '../config/form';
|
||||
|
||||
const isUpdate = ref(false);
|
||||
const isPlatformMode = ref(false);
|
||||
const splitType = ref(0);
|
||||
const salespersonId = ref(0);
|
||||
const storeId = ref<number | undefined>();
|
||||
const storeOptions = ref<{ label: string; value: number }[]>([]);
|
||||
const storeLoading = ref(false);
|
||||
let storeSearchTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
const editorRef = ref<InstanceType<typeof SalespersonDrugCommissionEditor>>();
|
||||
|
||||
const isFixedAmount = computed(() => Number(splitType.value) === 0);
|
||||
@@ -42,6 +49,28 @@ const [Form, formApi] = useVbenForm({
|
||||
},
|
||||
});
|
||||
|
||||
async function fetchStoreOptions(keyword = '') {
|
||||
storeLoading.value = true;
|
||||
try {
|
||||
const res = await getPlatformStoreOptionsApi({ keyword });
|
||||
storeOptions.value = (res ?? []).map((item) => ({
|
||||
label: item.position ? `${item.name}(${item.position})` : item.name,
|
||||
value: item.id,
|
||||
}));
|
||||
} finally {
|
||||
storeLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function handleStoreSearch(keyword: string) {
|
||||
if (storeSearchTimer) {
|
||||
clearTimeout(storeSearchTimer);
|
||||
}
|
||||
storeSearchTimer = setTimeout(() => {
|
||||
fetchStoreOptions(keyword.trim());
|
||||
}, 300);
|
||||
}
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
fullscreenButton: false,
|
||||
draggable: true,
|
||||
@@ -52,20 +81,38 @@ const [Modal, modalApi] = useVbenModal({
|
||||
const e = await formApi.validate();
|
||||
if (!e.valid) return;
|
||||
|
||||
if (isPlatformMode.value && !isUpdate.value && !storeId.value) {
|
||||
message.warning('请选择诊所');
|
||||
return;
|
||||
}
|
||||
|
||||
const values = await formApi.getValues();
|
||||
const payload = { ...values };
|
||||
if (Number(payload.split_type) === 0) {
|
||||
payload.split = 0;
|
||||
}
|
||||
if (isPlatformMode.value && !isUpdate.value) {
|
||||
payload.store_id = storeId.value;
|
||||
}
|
||||
|
||||
modalApi.setState({ loading: true, confirmLoading: true });
|
||||
try {
|
||||
const submitApi = isUpdate.value ? salespersonUpdateApi : salespersonCreateApi;
|
||||
const submitApi = isUpdate.value
|
||||
? salespersonUpdateApi
|
||||
: isPlatformMode.value
|
||||
? platformSalespersonCreateApi
|
||||
: salespersonCreateApi;
|
||||
const res = await submitApi(payload);
|
||||
const spId = isUpdate.value
|
||||
? Number(payload.id)
|
||||
: Number(res?.id ?? res);
|
||||
|
||||
if (!isUpdate.value && res?.admin_account_created === false) {
|
||||
message.warning(
|
||||
'推广员已创建,后台账号开通失败,请手动点击开通后台',
|
||||
);
|
||||
}
|
||||
|
||||
if (Number(payload.split_type) === 0 && spId > 0) {
|
||||
const dirtyItems = editorRef.value?.getDirtyItems() ?? [];
|
||||
if (dirtyItems.length > 0) {
|
||||
@@ -86,10 +133,13 @@ const [Modal, modalApi] = useVbenModal({
|
||||
onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
editorRef.value?.resetDirty();
|
||||
storeId.value = undefined;
|
||||
storeOptions.value = [];
|
||||
return;
|
||||
}
|
||||
const { values, update } = modalApi.getData<Record<string, any>>() || {};
|
||||
const { values, update, mode } = modalApi.getData<Record<string, any>>() || {};
|
||||
isUpdate.value = !!update;
|
||||
isPlatformMode.value = mode === 'platform';
|
||||
if (values) {
|
||||
formApi.setValues(values);
|
||||
splitType.value = Number(values.split_type ?? 0);
|
||||
@@ -99,12 +149,29 @@ const [Modal, modalApi] = useVbenModal({
|
||||
splitType.value = 0;
|
||||
salespersonId.value = 0;
|
||||
}
|
||||
if (isPlatformMode.value && !isUpdate.value) {
|
||||
fetchStoreOptions('');
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="`${isUpdate ? '编辑' : '新增'}推广员`" :class="modalClass">
|
||||
<div v-if="isPlatformMode && !isUpdate" class="mb-4">
|
||||
<div class="mb-2 text-sm font-medium">所属诊所</div>
|
||||
<Select
|
||||
v-model:value="storeId"
|
||||
allow-clear
|
||||
class="w-full"
|
||||
:filter-option="false"
|
||||
:loading="storeLoading"
|
||||
:options="storeOptions"
|
||||
placeholder="搜索诊所名称/拼音首拼"
|
||||
show-search
|
||||
@search="handleStoreSearch"
|
||||
/>
|
||||
</div>
|
||||
<Form />
|
||||
<p
|
||||
v-if="isFixedAmount && !isUpdate"
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
import { Empty, Spin, Table } from 'ant-design-vue';
|
||||
|
||||
import { getUserBindListApi } from '#/views/business/store/settings/api';
|
||||
|
||||
const props = defineProps<{
|
||||
salespersonId: number;
|
||||
open: boolean;
|
||||
}>();
|
||||
|
||||
const loading = ref(false);
|
||||
const list = ref<any[]>([]);
|
||||
const total = ref(0);
|
||||
const page = ref(1);
|
||||
const pageSize = ref(10);
|
||||
|
||||
const columns = [
|
||||
{ title: '用户昵称', dataIndex: 'user_nick_name', key: 'user_nick_name' },
|
||||
{ title: '手机号', dataIndex: 'user_phone', key: 'user_phone' },
|
||||
{ title: '绑定时间', dataIndex: 'bind_at_text', key: 'bind_at_text' },
|
||||
];
|
||||
|
||||
async function loadList() {
|
||||
if (!props.salespersonId) return;
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await getUserBindListApi({
|
||||
salesperson_id: props.salespersonId,
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
});
|
||||
list.value = res?.items ?? [];
|
||||
total.value = res?.total ?? 0;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [props.open, props.salespersonId],
|
||||
([open]) => {
|
||||
if (open) {
|
||||
page.value = 1;
|
||||
loadList();
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
function onPageChange(p: number, ps: number) {
|
||||
page.value = p;
|
||||
pageSize.value = ps;
|
||||
loadList();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Spin :spinning="loading">
|
||||
<Empty v-if="!loading && !list.length" description="暂无获客记录" />
|
||||
<Table
|
||||
v-else
|
||||
:columns="columns"
|
||||
:data-source="list"
|
||||
:pagination="{
|
||||
current: page,
|
||||
pageSize,
|
||||
total,
|
||||
showSizeChanger: true,
|
||||
onChange: onPageChange,
|
||||
}"
|
||||
row-key="id"
|
||||
size="small"
|
||||
/>
|
||||
</Spin>
|
||||
</template>
|
||||
@@ -101,15 +101,43 @@ export const salespersonModalFormProps: VbenFormProps = {
|
||||
triggerFields: ['split_type'],
|
||||
},
|
||||
},
|
||||
// {
|
||||
// component: 'UploadImage',
|
||||
// fieldName: 'url',
|
||||
// label: '图片',
|
||||
// rules: 'required',
|
||||
// componentProps: {
|
||||
// maxCount: 5,
|
||||
// },
|
||||
// },
|
||||
{
|
||||
component: 'Divider',
|
||||
fieldName: 'tcm_divider',
|
||||
label: '中药推广分成',
|
||||
formItemClass: 'col-span-12',
|
||||
},
|
||||
{
|
||||
component: 'InputNumber',
|
||||
fieldName: 'tcm_split',
|
||||
label: '中药分成(%)',
|
||||
componentProps: {
|
||||
min: 0,
|
||||
max: 100,
|
||||
precision: 2,
|
||||
class: 'w-full',
|
||||
placeholder: '0 表示不分成',
|
||||
},
|
||||
defaultValue: 0,
|
||||
},
|
||||
{
|
||||
component: 'RadioGroup',
|
||||
fieldName: 'tcm_base_type',
|
||||
label: '中药分成基数',
|
||||
componentProps: {
|
||||
options: [
|
||||
{ label: '药店利润', value: 0 },
|
||||
{ label: '处方总价', value: 1 },
|
||||
],
|
||||
},
|
||||
defaultValue: 0,
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return Number(values?.tcm_split ?? 0) > 0;
|
||||
},
|
||||
triggerFields: ['tcm_split'],
|
||||
},
|
||||
},
|
||||
],
|
||||
showDefaultActions: false,
|
||||
};
|
||||
|
||||
@@ -734,7 +734,7 @@ const handleSwitchClinicType = () => {
|
||||
>
|
||||
<template #extra>
|
||||
<span class="text-sm text-gray-500"
|
||||
>固定金额需配置各药品每件佣金</span
|
||||
>西药固定金额需配置各药品每件佣金;中药按处方单分成</span
|
||||
>
|
||||
</template>
|
||||
<SalespersonCard />
|
||||
|
||||
@@ -75,8 +75,13 @@ export async function getMyStoreListApi() {
|
||||
/**
|
||||
* 获取当前诊所类型和委托诊所信息
|
||||
*/
|
||||
export async function getCurrentStoreTypeApi() {
|
||||
return requestClient.get<any>(`${prefix}get-current-store-type`);
|
||||
export async function getCurrentStoreTypeApi(params?: {
|
||||
register_id?: number;
|
||||
store_id?: number;
|
||||
}) {
|
||||
return requestClient.get<any>(`${prefix}get-current-store-type`, {
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -74,6 +74,11 @@ import {
|
||||
// 转诊相关
|
||||
import TransferPrescriptionCard from '#/views/doctor/online-consultation/components/TransferPrescriptionCard.vue';
|
||||
import { getTransferPrescriptionByRegisterApi } from '#/views/business/chat/api/transferPrescription';
|
||||
import {
|
||||
calcItemMarginPercent,
|
||||
calcTotalMarginPercent,
|
||||
isSeeRateEnabled,
|
||||
} from '#/utils/chinesePrescriptionMargin';
|
||||
|
||||
interface Patient {
|
||||
id: number;
|
||||
@@ -128,6 +133,50 @@ getMyStoreList();
|
||||
|
||||
const userStore = useUserStore();
|
||||
const myStoreId = ref(userStore.userInfo.store_id);
|
||||
/** 当前取价门店是否允许查看毛利率(0/1) */
|
||||
const seeRate = ref(0);
|
||||
|
||||
async function fetchStoreSeeRate() {
|
||||
try {
|
||||
const registerId = Number.parseInt(
|
||||
localStorage.getItem('doctorReception-id') || '0',
|
||||
10,
|
||||
);
|
||||
const params: { register_id?: number; store_id?: number } = {
|
||||
store_id: myStoreId.value,
|
||||
};
|
||||
if (registerId > 0) {
|
||||
params.register_id = registerId;
|
||||
}
|
||||
const res = await getCurrentStoreTypeApi(params);
|
||||
seeRate.value = Number(res?.see_rate ?? 0);
|
||||
} catch (error) {
|
||||
console.error('获取毛利率权限失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
watch(myStoreId, () => {
|
||||
fetchStoreSeeRate();
|
||||
});
|
||||
|
||||
const chineseGrossMarginPercent = computed(() => {
|
||||
if (!isSeeRateEnabled(seeRate.value) || activeCategory.value !== 1) {
|
||||
return null;
|
||||
}
|
||||
return calcTotalMarginPercent(currentDrugs.value, dosage.value);
|
||||
});
|
||||
|
||||
function getChineseItemMargin(drug: {
|
||||
price?: number | string;
|
||||
buy_price?: number | string;
|
||||
}) {
|
||||
if (!isSeeRateEnabled(seeRate.value)) {
|
||||
return null;
|
||||
}
|
||||
return calcItemMarginPercent(drug.price, drug.buy_price);
|
||||
}
|
||||
|
||||
fetchStoreSeeRate();
|
||||
// userStore.userInfo?.nick_name
|
||||
|
||||
/**
|
||||
@@ -782,6 +831,7 @@ async function handleSelectCommonPrescription(data: any, type: number) {
|
||||
drug_name: recipe.drug_name || recipe.name,
|
||||
number: recipe.number || 1,
|
||||
price: recipe.price || 0,
|
||||
buy_price: recipe.buy_price,
|
||||
way_id: recipe.way_id || 0,
|
||||
select_number: recipe.select_number ?? 1,
|
||||
};
|
||||
@@ -1027,7 +1077,14 @@ async function checkAndShowTransferTip() {
|
||||
}
|
||||
|
||||
// 调用新接口获取当前诊所类型和委托诊所信息
|
||||
const storeInfo = await getCurrentStoreTypeApi();
|
||||
const registerId = Number.parseInt(
|
||||
localStorage.getItem('doctorReception-id') || '0',
|
||||
10,
|
||||
);
|
||||
const storeInfo = await getCurrentStoreTypeApi({
|
||||
store_id: myStoreId.value,
|
||||
...(registerId > 0 ? { register_id: registerId } : {}),
|
||||
});
|
||||
// const storeInfo = res;
|
||||
|
||||
if (!storeInfo) {
|
||||
@@ -1498,10 +1555,15 @@ const getDrugListByWesternModal = debounce(async (searchText = '') => {
|
||||
getCurrentDrugs();
|
||||
|
||||
try {
|
||||
const registerId = Number.parseInt(
|
||||
localStorage.getItem('doctorReception-id') || '0',
|
||||
10,
|
||||
);
|
||||
const res = await getProductListDoctorReception({
|
||||
store_id: 2,
|
||||
store_id: myStoreId.value,
|
||||
type: activeCategory.value,
|
||||
name: searchText,
|
||||
...(registerId > 0 ? { register_id: registerId } : {}),
|
||||
});
|
||||
|
||||
drugList.value = res.map((item) => {
|
||||
@@ -1592,6 +1654,7 @@ function selectOldDrugInfo(id) {
|
||||
unit: drugUnit.value.find((item) => item.id === data.drug.unit_id),
|
||||
// 药品价格
|
||||
price: data.price,
|
||||
buy_price: data.buy_price,
|
||||
// 药品使用方式ID
|
||||
way_id: data.drug?.way_id,
|
||||
// 药品使用方式信息
|
||||
@@ -1730,6 +1793,7 @@ function addProducts(data) {
|
||||
unit: drugUnit.value.find((item) => item.id === data.drug.unit_id),
|
||||
// 药品价格
|
||||
price: data.price,
|
||||
buy_price: data.buy_price,
|
||||
// 药品使用方式ID
|
||||
way_id: data.drug?.way_id,
|
||||
// 药品使用方式信息
|
||||
@@ -2302,6 +2366,12 @@ watch(
|
||||
</span>
|
||||
<p class="card-price">
|
||||
¥<span>{{ (drug.price * drug.number).toFixed(2) }}</span>
|
||||
<span
|
||||
v-if="getChineseItemMargin(drug) && getChineseItemMargin(drug) !== '--'"
|
||||
class="ml-2 text-gray-500 text-sm"
|
||||
>
|
||||
毛利率 {{ getChineseItemMargin(drug) }}%
|
||||
</span>
|
||||
</p>
|
||||
<Button
|
||||
class="card-delete"
|
||||
@@ -2842,6 +2912,12 @@ watch(
|
||||
<div class="total-cost">加工费:¥{{ processingFee.toFixed(2) }}</div>
|
||||
<div class="total-cost">
|
||||
商品价格:¥{{ totalProductCost.toFixed(2) }}
|
||||
<span
|
||||
v-if="chineseGrossMarginPercent !== null"
|
||||
class="ml-3 text-orange-600"
|
||||
>
|
||||
毛利率 {{ chineseGrossMarginPercent }}%
|
||||
</span>
|
||||
</div>
|
||||
<div class="total-cost">总计:¥{{ totalCost.toFixed(2) }}</div>
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ const gridApi = ref();
|
||||
const [Form, formApi] = useVbenForm(infoModalFormProps);
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
closeOnClickModal: false,
|
||||
fullscreenButton: false,
|
||||
draggable: true,
|
||||
onCancel() {
|
||||
|
||||
@@ -26,6 +26,7 @@ export const ADMIN_ROLE_LIST: AdminRoleMeta[] = [
|
||||
{ id: 9, title: '诊所员工', slug: 'clinic-staff', formType: 'clinic' },
|
||||
{ id: 10, title: '医生', slug: 'doctor', formType: 'doctor' },
|
||||
{ id: 11, title: '药师', slug: 'pharmacist', formType: 'pharmacist' },
|
||||
{ id: 14, title: '诊所推广员', slug: 'clinic-salesperson', formType: 'clinic' },
|
||||
];
|
||||
|
||||
export const ROLE_CITY_MANAGER = 4;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<script lang="ts" setup>
|
||||
import AdminPage from '../_shared/admin-page.vue';
|
||||
</script>
|
||||
<template>
|
||||
<AdminPage :role-id="14" />
|
||||
</template>
|
||||
27
apps/web-antd/src/views/system/doctor-input/api/index.ts
Normal file
27
apps/web-antd/src/views/system/doctor-input/api/index.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
const prefix = 'doctor-input/';
|
||||
|
||||
export async function createDoctorInput(data: Record<string, any>) {
|
||||
return requestClient.post<any>(`${prefix}create`, data);
|
||||
}
|
||||
|
||||
export async function getDoctorInputList(data: any) {
|
||||
return requestClient.get<any>(`${prefix}list`, { params: data });
|
||||
}
|
||||
|
||||
export async function getDoctorInputDetail(id: number) {
|
||||
return requestClient.get<any>(`${prefix}detail`, { params: { id } });
|
||||
}
|
||||
|
||||
export async function updateDoctorInput(data: Record<string, any>) {
|
||||
return requestClient.post<any>(`${prefix}update`, data);
|
||||
}
|
||||
|
||||
export async function auditDoctorInput(data: {
|
||||
id: number;
|
||||
status: number;
|
||||
audit_remark?: string;
|
||||
}) {
|
||||
return requestClient.post<any>(`${prefix}audit`, data);
|
||||
}
|
||||
128
apps/web-antd/src/views/system/doctor-input/audit.vue
Normal file
128
apps/web-antd/src/views/system/doctor-input/audit.vue
Normal file
@@ -0,0 +1,128 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridListeners } from '#/adapter/vxe-table';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import { useUserStore } from '@vben/stores';
|
||||
|
||||
import { Tag } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { TableAction } from '#/components/table-action';
|
||||
|
||||
import AuditModal from './components/AuditModal.vue';
|
||||
import DetailModal from './components/DetailModal.vue';
|
||||
import { auditFormOptions } from './config/search';
|
||||
import { auditGridOptions } from './config/table';
|
||||
|
||||
const userStore = useUserStore();
|
||||
|
||||
const isPlatformAdmin = computed(() => {
|
||||
return userStore?.userInfo?.roles?.user_type === 2;
|
||||
});
|
||||
|
||||
const hasTopTableDropDownActions = ref(false);
|
||||
|
||||
const gridEvents: VxeGridListeners<any> = {
|
||||
checkboxChange() {
|
||||
const records = gridApi.grid.getCheckboxRecords();
|
||||
hasTopTableDropDownActions.value = records.length > 0;
|
||||
},
|
||||
checkboxAll() {
|
||||
const records = gridApi.grid.getCheckboxRecords();
|
||||
hasTopTableDropDownActions.value = records.length > 0;
|
||||
},
|
||||
};
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: auditFormOptions,
|
||||
gridOptions: auditGridOptions,
|
||||
gridEvents,
|
||||
});
|
||||
|
||||
const [DetailModalComponent, detailModalApi] = useVbenModal({
|
||||
connectedComponent: DetailModal,
|
||||
});
|
||||
|
||||
const [AuditModalComponent, auditModalApi] = useVbenModal({
|
||||
connectedComponent: AuditModal,
|
||||
});
|
||||
|
||||
const showDetail = (row: any) => {
|
||||
detailModalApi.setData({
|
||||
values: row,
|
||||
});
|
||||
detailModalApi.open();
|
||||
};
|
||||
|
||||
const showAudit = (row: any) => {
|
||||
auditModalApi.setData({
|
||||
values: row,
|
||||
gridApi,
|
||||
});
|
||||
auditModalApi.open();
|
||||
};
|
||||
|
||||
const getTypeText = (type: number) => {
|
||||
if (type === 1) return '中医医生';
|
||||
if (type === 2) return '西医医生';
|
||||
return '-';
|
||||
};
|
||||
|
||||
const getStatusColor = (status: number) => {
|
||||
if (status === 0) return 'orange';
|
||||
if (status === 1) return 'success';
|
||||
return 'error';
|
||||
};
|
||||
|
||||
const getStatusText = (status: number) => {
|
||||
if (status === 0) return '待审核';
|
||||
if (status === 1) return '审核通过';
|
||||
return '审核拒绝';
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height title="医生信息审核">
|
||||
<DetailModalComponent />
|
||||
<AuditModalComponent />
|
||||
<Grid>
|
||||
<template #type="{ row }">
|
||||
<Tag>{{ getTypeText(row.type) }}</Tag>
|
||||
</template>
|
||||
<template #status="{ row }">
|
||||
<Tag :color="getStatusColor(row.status)">
|
||||
{{ getStatusText(row.status) }}
|
||||
</Tag>
|
||||
</template>
|
||||
<template #audit_time="{ row }">
|
||||
<span v-if="row.audit_time">
|
||||
{{ new Date(row.audit_time * 1000).toLocaleString() }}
|
||||
</span>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
<template #action="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '查看详情',
|
||||
type: 'link',
|
||||
icon: 'uil:eye',
|
||||
size: 'small',
|
||||
onClick: showDetail.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '审核',
|
||||
type: 'link',
|
||||
icon: 'uil:check',
|
||||
size: 'small',
|
||||
ifShow: row.status === 0 && isPlatformAdmin,
|
||||
onClick: showAudit.bind(null, row),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
@@ -0,0 +1,86 @@
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message, Radio, RadioGroup, Textarea } from 'ant-design-vue';
|
||||
|
||||
import { auditDoctorInput } from '../api';
|
||||
|
||||
const [ModalComponent, modalApi] = useVbenModal({
|
||||
fullscreenButton: false,
|
||||
draggable: true,
|
||||
onCancel() {
|
||||
modalApi.close();
|
||||
},
|
||||
});
|
||||
|
||||
const auditStatus = ref<number>(1);
|
||||
const auditRemark = ref<string>('');
|
||||
const currentRow = ref<any>(null);
|
||||
const gridApi = ref<any>(null);
|
||||
const loading = ref(false);
|
||||
|
||||
const handleAudit = async () => {
|
||||
if (!currentRow.value) {
|
||||
message.error('数据错误');
|
||||
return;
|
||||
}
|
||||
|
||||
loading.value = true;
|
||||
try {
|
||||
await auditDoctorInput({
|
||||
id: currentRow.value.id,
|
||||
status: auditStatus.value,
|
||||
audit_remark: auditRemark.value,
|
||||
});
|
||||
message.success('审核成功');
|
||||
gridApi.value?.reload();
|
||||
modalApi.close();
|
||||
auditStatus.value = 1;
|
||||
auditRemark.value = '';
|
||||
} catch (error) {
|
||||
console.error('审核失败:', error);
|
||||
message.error('审核失败,请稍后重试');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
modalApi.onOpenChange = (isOpen: boolean) => {
|
||||
if (isOpen) {
|
||||
const { values, gridApi: api } = modalApi.getData<Record<string, any>>();
|
||||
currentRow.value = values;
|
||||
gridApi.value = api;
|
||||
auditStatus.value = 1;
|
||||
auditRemark.value = '';
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ModalComponent
|
||||
title="审核医生预填"
|
||||
class="w-[500px]"
|
||||
:confirm-loading="loading"
|
||||
@confirm="handleAudit"
|
||||
>
|
||||
<div class="space-y-4 p-4">
|
||||
<div>
|
||||
<div class="mb-2 font-semibold">审核结果:</div>
|
||||
<RadioGroup v-model:value="auditStatus">
|
||||
<Radio :value="1">审核通过</Radio>
|
||||
<Radio :value="2">审核拒绝</Radio>
|
||||
</RadioGroup>
|
||||
</div>
|
||||
<div>
|
||||
<div class="mb-2 font-semibold">审核备注:</div>
|
||||
<Textarea
|
||||
v-model:value="auditRemark"
|
||||
:rows="4"
|
||||
placeholder="请输入审核备注(可选)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</ModalComponent>
|
||||
</template>
|
||||
@@ -0,0 +1,146 @@
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Avatar, Descriptions, DescriptionsItem, Image, Spin, message } from 'ant-design-vue';
|
||||
|
||||
import { getDoctorInputDetail } from '../api';
|
||||
import {
|
||||
inputUserDisplayName,
|
||||
normalizeInputUser,
|
||||
resolveAvatarUrl,
|
||||
} from '../../store-input/utils/inputUser';
|
||||
|
||||
const detailData = ref<any>(null);
|
||||
const loading = ref(false);
|
||||
|
||||
const getTypeText = (type: number) => {
|
||||
if (type === 1) return '中医医生';
|
||||
if (type === 2) return '西医医生';
|
||||
return '-';
|
||||
};
|
||||
|
||||
const getSignTypeText = (signType: number) => {
|
||||
if (signType === 1) return '电子签名';
|
||||
if (signType === 2) return '手写签名';
|
||||
return '-';
|
||||
};
|
||||
|
||||
const loadDetail = async (id: number) => {
|
||||
loading.value = true;
|
||||
detailData.value = null;
|
||||
try {
|
||||
const res = await getDoctorInputDetail(id);
|
||||
detailData.value = res;
|
||||
normalizeInputUser(detailData.value);
|
||||
} catch (error) {
|
||||
console.error('获取详情失败:', error);
|
||||
message.error('获取详情失败');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
fullscreenButton: false,
|
||||
draggable: true,
|
||||
onCancel() {
|
||||
modalApi.close();
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
detailData.value = null;
|
||||
loading.value = false;
|
||||
return;
|
||||
}
|
||||
const { values } = modalApi.getData<Record<string, any>>();
|
||||
if (values?.id) {
|
||||
await loadDetail(values.id);
|
||||
} else {
|
||||
detailData.value = values || null;
|
||||
normalizeInputUser(detailData.value);
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal title="医生预填详情" class="w-[70%]">
|
||||
<Spin :spinning="loading">
|
||||
<div v-if="detailData" class="p-4">
|
||||
<Descriptions :column="2" bordered>
|
||||
<DescriptionsItem label="ID">{{ detailData.id }}</DescriptionsItem>
|
||||
<DescriptionsItem label="医生姓名">{{ detailData.name }}</DescriptionsItem>
|
||||
<DescriptionsItem label="手机号">{{ detailData.mobile }}</DescriptionsItem>
|
||||
<DescriptionsItem label="身份证">{{ detailData.idcard }}</DescriptionsItem>
|
||||
<DescriptionsItem label="身份">{{ getTypeText(detailData.type) }}</DescriptionsItem>
|
||||
<DescriptionsItem label="签名类型">{{ getSignTypeText(detailData.sign_type) }}</DescriptionsItem>
|
||||
<DescriptionsItem label="科室">{{ detailData.depart?.name || '-' }}</DescriptionsItem>
|
||||
<DescriptionsItem label="职称">{{ detailData.titleInfo?.name || '-' }}</DescriptionsItem>
|
||||
<DescriptionsItem label="擅长" :span="2">{{ detailData.good_at }}</DescriptionsItem>
|
||||
<DescriptionsItem label="简介" :span="2">{{ detailData.intro }}</DescriptionsItem>
|
||||
<DescriptionsItem label="录入人">
|
||||
<div class="flex items-center gap-2">
|
||||
<Avatar
|
||||
v-if="resolveAvatarUrl(detailData.inputUser?.avatar)"
|
||||
:src="resolveAvatarUrl(detailData.inputUser?.avatar)"
|
||||
:size="40"
|
||||
/>
|
||||
<Avatar v-else :size="40">{{ inputUserDisplayName(detailData.inputUser).charAt(0) }}</Avatar>
|
||||
<span>{{ inputUserDisplayName(detailData.inputUser) }}</span>
|
||||
</div>
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="审核状态">
|
||||
<span
|
||||
:class="{
|
||||
'text-orange-500': detailData.status === 0,
|
||||
'text-green-500': detailData.status === 1,
|
||||
'text-red-500': detailData.status === 2,
|
||||
}"
|
||||
>
|
||||
{{
|
||||
detailData.status === 0
|
||||
? '待审核'
|
||||
: detailData.status === 1
|
||||
? '审核通过'
|
||||
: '审核拒绝'
|
||||
}}
|
||||
</span>
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem v-if="detailData.auditAdmin" label="审核人">
|
||||
{{ detailData.auditAdmin.nick_name }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem v-if="detailData.audit_time" label="审核时间">
|
||||
{{ new Date(detailData.audit_time * 1000).toLocaleString() }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem v-if="detailData.audit_remark" label="审核备注" :span="2">
|
||||
{{ detailData.audit_remark }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem v-if="detailData.avatar" label="头像" :span="2">
|
||||
<Image :src="detailData.avatar" :width="100" :height="100" :preview="true" />
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem v-if="detailData.qualification" label="资格证书" :span="2">
|
||||
<Image :src="detailData.qualification" :width="100" :height="100" :preview="true" />
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem v-if="detailData.practicing" label="执业证书" :span="2">
|
||||
<Image :src="detailData.practicing" :width="100" :height="100" :preview="true" />
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem v-if="detailData.title" label="职称证书" :span="2">
|
||||
<Image :src="detailData.title" :width="100" :height="100" :preview="true" />
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem v-if="detailData.card_up" label="身份证正面" :span="2">
|
||||
<Image :src="detailData.card_up" :width="100" :height="100" :preview="true" />
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem v-if="detailData.card_down" label="身份证反面" :span="2">
|
||||
<Image :src="detailData.card_down" :width="100" :height="100" :preview="true" />
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem v-if="detailData.sign_image" label="签名图片" :span="2">
|
||||
<Image :src="detailData.sign_image" :width="100" :height="100" :preview="true" />
|
||||
</DescriptionsItem>
|
||||
</Descriptions>
|
||||
</div>
|
||||
<div v-else-if="!loading" class="p-8 text-center text-gray-400">暂无详情数据</div>
|
||||
</Spin>
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -0,0 +1,78 @@
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
|
||||
import {
|
||||
createDoctorInput,
|
||||
getDoctorInputDetail,
|
||||
updateDoctorInput,
|
||||
} from '../api';
|
||||
import { modalFormProps } from '../config/form';
|
||||
|
||||
const isUpdate = ref(false);
|
||||
const gridApi = ref();
|
||||
|
||||
const [Form, formApi] = useVbenForm(modalFormProps);
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
fullscreenButton: false,
|
||||
draggable: true,
|
||||
onCancel() {
|
||||
modalApi.close();
|
||||
},
|
||||
onConfirm: async () => {
|
||||
formApi.validate().then(async (e: any) => {
|
||||
if (e.valid) {
|
||||
const values = await formApi.getValues();
|
||||
modalApi.setState({ loading: true, confirmLoading: true });
|
||||
const submitApi = isUpdate.value ? updateDoctorInput : createDoctorInput;
|
||||
submitApi(values)
|
||||
.then(() => {
|
||||
message.success(isUpdate.value ? '更新成功' : '预填成功');
|
||||
gridApi.value?.reload();
|
||||
modalApi.close();
|
||||
})
|
||||
.finally(() => {
|
||||
modalApi.setState({ loading: false, confirmLoading: false });
|
||||
});
|
||||
}
|
||||
});
|
||||
await formApi.validateAndSubmitForm();
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
gridApi.value = isOpen ? modalApi.getData()?.gridApi : null;
|
||||
if (isOpen) {
|
||||
const { values, update } = modalApi.getData<Record<string, any>>();
|
||||
if (values?.id) {
|
||||
isUpdate.value = update;
|
||||
if (update) {
|
||||
const detail = await getDoctorInputDetail(values.id);
|
||||
formApi.setValues({
|
||||
...detail,
|
||||
stores: detail.store_ids || [],
|
||||
});
|
||||
} else {
|
||||
formApi.setValues({
|
||||
...values,
|
||||
stores: values.store_ids || [],
|
||||
});
|
||||
}
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
formApi.resetForm();
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="`${isUpdate ? '编辑' : '新增'}医生预填`" class="w-[60%]">
|
||||
<Form />
|
||||
</Modal>
|
||||
</template>
|
||||
228
apps/web-antd/src/views/system/doctor-input/config/form.ts
Normal file
228
apps/web-antd/src/views/system/doctor-input/config/form.ts
Normal file
@@ -0,0 +1,228 @@
|
||||
import type { VbenFormProps } from '#/adapter/form';
|
||||
|
||||
import { getDepartOptionApi } from '#/views/doctor/doctor/api';
|
||||
import { getDoctorTitleOptionApi } from '#/views/doctor/pharmacist/api';
|
||||
import { getStoreOption } from '#/views/system/store/api';
|
||||
|
||||
export const modalFormProps: VbenFormProps = {
|
||||
wrapperClass: 'grid-cols-12',
|
||||
commonConfig: {
|
||||
formItemClass: 'col-span-12',
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: [
|
||||
{
|
||||
component: 'VbenInput',
|
||||
fieldName: 'id',
|
||||
label: 'ID',
|
||||
formItemClass: 'col-span-6',
|
||||
dependencies: {
|
||||
show: false,
|
||||
triggerFields: ['id'],
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
filterOption: (input: string, option: any) =>
|
||||
option?.label.toLowerCase().indexOf(input.toLowerCase()) >= 0,
|
||||
showSearch: true,
|
||||
afterFetch: (data: { id: number; name: string }[]) =>
|
||||
data.map((item: any) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
})),
|
||||
api: getStoreOption,
|
||||
placeholder: '请选择诊所',
|
||||
mode: 'multiple',
|
||||
},
|
||||
fieldName: 'stores',
|
||||
formItemClass: 'col-span-12',
|
||||
label: '关联诊所',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'Avatar',
|
||||
componentProps: {
|
||||
placeholder: '请上传医生头像',
|
||||
},
|
||||
fieldName: 'avatar',
|
||||
formItemClass: 'col-span-12',
|
||||
label: '医生头像',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
afterFetch: (data: { id: number; name: string }[]) =>
|
||||
data.map((item: any) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
})),
|
||||
api: getDoctorTitleOptionApi,
|
||||
placeholder: '请选择职称',
|
||||
},
|
||||
fieldName: 'title_id',
|
||||
formItemClass: 'col-span-6',
|
||||
label: '职称',
|
||||
},
|
||||
{
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
afterFetch: (data: { id: number; name: string }[]) =>
|
||||
data.map((item: any) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
})),
|
||||
api: getDepartOptionApi,
|
||||
placeholder: '请选择科室',
|
||||
},
|
||||
fieldName: 'depart_id',
|
||||
formItemClass: 'col-span-6',
|
||||
label: '科室',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'VbenInput',
|
||||
componentProps: {
|
||||
placeholder: '请填写医生名称',
|
||||
},
|
||||
fieldName: 'name',
|
||||
formItemClass: 'col-span-6',
|
||||
label: '医生名称',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'VbenInput',
|
||||
componentProps: {
|
||||
placeholder: '请填写手机号码',
|
||||
},
|
||||
fieldName: 'mobile',
|
||||
formItemClass: 'col-span-6',
|
||||
label: '手机号码',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'VbenInput',
|
||||
componentProps: {
|
||||
placeholder: '请填写身份证',
|
||||
},
|
||||
fieldName: 'idcard',
|
||||
formItemClass: 'col-span-6',
|
||||
label: '身份证',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'VbenSelect',
|
||||
componentProps: {
|
||||
placeholder: '请选择身份',
|
||||
options: [
|
||||
{ label: '中医医生', value: 1 },
|
||||
{ label: '西医医生', value: 2 },
|
||||
],
|
||||
},
|
||||
fieldName: 'type',
|
||||
formItemClass: 'col-span-6',
|
||||
label: '身份',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'VbenSelect',
|
||||
componentProps: {
|
||||
placeholder: '请选择签名类型',
|
||||
options: [
|
||||
{ label: '电子签名', value: 1 },
|
||||
{ label: '手写签名', value: 2 },
|
||||
],
|
||||
},
|
||||
fieldName: 'sign_type',
|
||||
formItemClass: 'col-span-6',
|
||||
label: '签名类型',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'Textarea',
|
||||
componentProps: {
|
||||
placeholder: '请输入擅长',
|
||||
},
|
||||
fieldName: 'good_at',
|
||||
label: '擅长',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'Textarea',
|
||||
componentProps: {
|
||||
placeholder: '请输入简介',
|
||||
},
|
||||
fieldName: 'intro',
|
||||
label: '简介',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'Avatar',
|
||||
componentProps: {
|
||||
placeholder: '请上传资格证书',
|
||||
},
|
||||
fieldName: 'qualification',
|
||||
formItemClass: 'col-span-6',
|
||||
label: '资格证书',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'Avatar',
|
||||
componentProps: {
|
||||
placeholder: '请上传执业证书',
|
||||
},
|
||||
fieldName: 'practicing',
|
||||
formItemClass: 'col-span-6',
|
||||
label: '执业证书',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'Avatar',
|
||||
componentProps: {
|
||||
placeholder: '请上传职称证书',
|
||||
},
|
||||
fieldName: 'title',
|
||||
formItemClass: 'col-span-6',
|
||||
label: '职称证书',
|
||||
},
|
||||
{
|
||||
component: 'Avatar',
|
||||
componentProps: {
|
||||
placeholder: '请上传身份证正面',
|
||||
},
|
||||
fieldName: 'card_up',
|
||||
formItemClass: 'col-span-6',
|
||||
label: '身份证正面',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'Avatar',
|
||||
componentProps: {
|
||||
placeholder: '请上传身份证反面',
|
||||
},
|
||||
fieldName: 'card_down',
|
||||
formItemClass: 'col-span-6',
|
||||
label: '身份证反面',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'Avatar',
|
||||
componentProps: {
|
||||
placeholder: '请上传签名图片',
|
||||
},
|
||||
fieldName: 'sign_image',
|
||||
formItemClass: 'col-span-6',
|
||||
label: '签名图片',
|
||||
rules: 'required',
|
||||
},
|
||||
],
|
||||
showDefaultActions: false,
|
||||
};
|
||||
55
apps/web-antd/src/views/system/doctor-input/config/search.ts
Normal file
55
apps/web-antd/src/views/system/doctor-input/config/search.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import type { VbenFormProps } from '#/adapter/form';
|
||||
|
||||
export const formOptions: VbenFormProps = {
|
||||
wrapperClass: 'grid-cols-12',
|
||||
commonConfig: {
|
||||
formItemClass: 'col-span-12',
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: [
|
||||
{
|
||||
component: 'VbenInput',
|
||||
formItemClass: 'col-span-6',
|
||||
componentProps: {
|
||||
placeholder: '请输入医生姓名',
|
||||
},
|
||||
fieldName: 'name',
|
||||
label: '医生姓名',
|
||||
},
|
||||
{
|
||||
component: 'VbenInput',
|
||||
formItemClass: 'col-span-6',
|
||||
componentProps: {
|
||||
placeholder: '请输入手机号',
|
||||
},
|
||||
fieldName: 'mobile',
|
||||
label: '手机号',
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
formItemClass: 'col-span-6',
|
||||
componentProps: {
|
||||
placeholder: '请选择审核状态',
|
||||
options: [
|
||||
{ label: '待审核', value: 0 },
|
||||
{ label: '审核通过', value: 1 },
|
||||
{ label: '审核拒绝', value: 2 },
|
||||
],
|
||||
},
|
||||
fieldName: 'status',
|
||||
label: '审核状态',
|
||||
},
|
||||
],
|
||||
showDefaultActions: false,
|
||||
};
|
||||
|
||||
/** 审核列表:默认只看待审核 */
|
||||
export const auditFormOptions: VbenFormProps = {
|
||||
...formOptions,
|
||||
schema: formOptions.schema?.map((item) =>
|
||||
item.fieldName === 'status' ? { ...item, defaultValue: 0 } : item,
|
||||
),
|
||||
};
|
||||
170
apps/web-antd/src/views/system/doctor-input/config/table.ts
Normal file
170
apps/web-antd/src/views/system/doctor-input/config/table.ts
Normal file
@@ -0,0 +1,170 @@
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
|
||||
import { getDoctorInputList } from '../api';
|
||||
|
||||
interface RowType {
|
||||
id: number;
|
||||
name: string;
|
||||
mobile: string;
|
||||
type: number;
|
||||
status: number;
|
||||
input_user_id: number;
|
||||
inputUser: {
|
||||
nick_name: string;
|
||||
};
|
||||
auditAdmin: {
|
||||
nick_name: string;
|
||||
};
|
||||
depart: {
|
||||
name: string;
|
||||
};
|
||||
titleInfo: {
|
||||
name: string;
|
||||
};
|
||||
audit_time: number;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
// 录入列表表格配置
|
||||
export const inputGridOptions: VxeGridProps<RowType> = {
|
||||
checkboxConfig: {
|
||||
highlight: true,
|
||||
labelField: '',
|
||||
},
|
||||
columnConfig: {
|
||||
useKey: true,
|
||||
},
|
||||
rowConfig: {
|
||||
useKey: true,
|
||||
},
|
||||
columns: [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{ field: 'id', align: 'left', title: 'ID', width: 100 },
|
||||
{ field: 'name', align: 'left', title: '医生姓名' },
|
||||
{ field: 'mobile', title: '手机号', width: 140 },
|
||||
{
|
||||
field: 'type',
|
||||
align: 'left',
|
||||
title: '身份',
|
||||
width: 100,
|
||||
slots: { default: 'type' },
|
||||
},
|
||||
{ field: 'depart.name', title: '科室', width: 120 },
|
||||
{ field: 'titleInfo.name', title: '职称', width: 120 },
|
||||
{
|
||||
field: 'status',
|
||||
align: 'left',
|
||||
title: '审核状态',
|
||||
width: 120,
|
||||
slots: { default: 'status' },
|
||||
},
|
||||
{ field: 'created_at', title: '录入时间' },
|
||||
{
|
||||
type: 'html',
|
||||
title: '操作',
|
||||
fixed: 'right',
|
||||
width: 200,
|
||||
slots: { default: 'action' },
|
||||
},
|
||||
],
|
||||
keepSource: true,
|
||||
pagerConfig: {},
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getDoctorInputList({
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
height: 'auto',
|
||||
border: false,
|
||||
toolbarConfig: {
|
||||
search: true,
|
||||
refresh: true,
|
||||
print: false,
|
||||
export: false,
|
||||
zoom: true,
|
||||
slots: {
|
||||
buttons: 'toolbar-buttons',
|
||||
},
|
||||
},
|
||||
showOverflow: false,
|
||||
};
|
||||
|
||||
// 审核列表表格配置
|
||||
export const auditGridOptions: VxeGridProps<RowType> = {
|
||||
checkboxConfig: {
|
||||
highlight: true,
|
||||
labelField: '',
|
||||
},
|
||||
columnConfig: {
|
||||
useKey: true,
|
||||
},
|
||||
rowConfig: {
|
||||
useKey: true,
|
||||
},
|
||||
columns: [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{ field: 'id', align: 'left', title: 'ID', width: 100 },
|
||||
{ field: 'name', align: 'left', title: '医生姓名' },
|
||||
{ field: 'mobile', title: '手机号', width: 140 },
|
||||
{
|
||||
field: 'type',
|
||||
align: 'left',
|
||||
title: '身份',
|
||||
width: 100,
|
||||
slots: { default: 'type' },
|
||||
},
|
||||
{ field: 'depart.name', title: '科室', width: 120 },
|
||||
{ field: 'titleInfo.name', title: '职称', width: 120 },
|
||||
{
|
||||
field: 'status',
|
||||
align: 'left',
|
||||
title: '审核状态',
|
||||
width: 120,
|
||||
slots: { default: 'status' },
|
||||
},
|
||||
{
|
||||
field: 'inputUser',
|
||||
title: '录入人',
|
||||
minWidth: 140,
|
||||
slots: { default: 'inputUser' },
|
||||
},
|
||||
{ field: 'auditAdmin.nick_name', title: '审核人' },
|
||||
{ field: 'audit_time', title: '审核时间', slots: { default: 'audit_time' } },
|
||||
{ field: 'created_at', title: '录入时间' },
|
||||
{
|
||||
type: 'html',
|
||||
title: '操作',
|
||||
align: 'right',
|
||||
slots: { default: 'action' },
|
||||
},
|
||||
],
|
||||
keepSource: true,
|
||||
pagerConfig: {},
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getDoctorInputList({
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
height: 'auto',
|
||||
border: false,
|
||||
toolbarConfig: {
|
||||
search: true,
|
||||
refresh: true,
|
||||
print: false,
|
||||
export: false,
|
||||
zoom: true,
|
||||
},
|
||||
showOverflow: false,
|
||||
};
|
||||
145
apps/web-antd/src/views/system/doctor-input/index.vue
Normal file
145
apps/web-antd/src/views/system/doctor-input/index.vue
Normal file
@@ -0,0 +1,145 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridListeners } from '#/adapter/vxe-table';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Avatar, Tag } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { TableAction } from '#/components/table-action';
|
||||
|
||||
import DetailModal from './components/DetailModal.vue';
|
||||
import FormModalDemo from './components/modal.vue';
|
||||
import { formOptions } from './config/search';
|
||||
import { inputGridOptions } from './config/table';
|
||||
import {
|
||||
inputUserDisplayName,
|
||||
normalizeInputUser,
|
||||
resolveAvatarUrl,
|
||||
} from '../store-input/utils/inputUser';
|
||||
|
||||
const hasTopTableDropDownActions = ref(false);
|
||||
|
||||
const gridEvents: VxeGridListeners<any> = {
|
||||
checkboxChange() {
|
||||
const records = gridApi.grid.getCheckboxRecords();
|
||||
hasTopTableDropDownActions.value = records.length > 0;
|
||||
},
|
||||
checkboxAll() {
|
||||
const records = gridApi.grid.getCheckboxRecords();
|
||||
hasTopTableDropDownActions.value = records.length > 0;
|
||||
},
|
||||
};
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions,
|
||||
gridOptions: inputGridOptions,
|
||||
gridEvents,
|
||||
});
|
||||
|
||||
const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: FormModalDemo,
|
||||
});
|
||||
|
||||
const [DetailModalComponent, detailModalApi] = useVbenModal({
|
||||
connectedComponent: DetailModal,
|
||||
});
|
||||
|
||||
const showDetail = (row: any) => {
|
||||
detailModalApi.setData({
|
||||
values: row,
|
||||
});
|
||||
detailModalApi.open();
|
||||
};
|
||||
|
||||
const showModal = (data = {}, isUpdate = false) => {
|
||||
formModalApi.setData({
|
||||
values: data,
|
||||
update: isUpdate,
|
||||
gridApi,
|
||||
});
|
||||
formModalApi.open();
|
||||
};
|
||||
|
||||
const getTypeText = (type: number) => {
|
||||
if (type === 1) return '中医医生';
|
||||
if (type === 2) return '西医医生';
|
||||
return '-';
|
||||
};
|
||||
|
||||
const getStatusColor = (status: number) => {
|
||||
if (status === 0) return 'orange';
|
||||
if (status === 1) return 'success';
|
||||
return 'error';
|
||||
};
|
||||
|
||||
const getStatusText = (status: number) => {
|
||||
if (status === 0) return '待审核';
|
||||
if (status === 1) return '审核通过';
|
||||
return '审核拒绝';
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height title="医生信息预填">
|
||||
<FormModal />
|
||||
<DetailModalComponent />
|
||||
<Grid>
|
||||
<template #toolbar-buttons>
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '新增预填',
|
||||
type: 'primary',
|
||||
icon: 'ant-design:plus-outlined',
|
||||
onClick: showModal.bind(null, {}, false),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
<template #type="{ row }">
|
||||
<Tag>{{ getTypeText(row.type) }}</Tag>
|
||||
</template>
|
||||
<template #status="{ row }">
|
||||
<Tag :color="getStatusColor(row.status)">
|
||||
{{ getStatusText(row.status) }}
|
||||
</Tag>
|
||||
</template>
|
||||
<template #inputUser="{ row }">
|
||||
<div v-if="normalizeInputUser(row)" class="flex items-center gap-2">
|
||||
<Avatar
|
||||
v-if="resolveAvatarUrl(row.inputUser?.avatar)"
|
||||
:src="resolveAvatarUrl(row.inputUser?.avatar)"
|
||||
:size="28"
|
||||
/>
|
||||
<Avatar v-else :size="28">{{ inputUserDisplayName(row.inputUser).charAt(0) }}</Avatar>
|
||||
<span>{{ inputUserDisplayName(row.inputUser) }}</span>
|
||||
</div>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
<template #action="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '查看',
|
||||
type: 'link',
|
||||
icon: 'uil:eye',
|
||||
size: 'small',
|
||||
onClick: showDetail.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '编辑',
|
||||
type: 'link',
|
||||
icon: 'uil:edit',
|
||||
size: 'small',
|
||||
ifShow: row.status === 0,
|
||||
onClick: showModal.bind(null, row, true),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
@@ -23,6 +23,7 @@ const [Form, formApi] = useVbenForm(modalFormProps);
|
||||
|
||||
// 初始化弹窗
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
closeOnClickModal: false,
|
||||
fullscreenButton: false, // 不显示全屏按钮
|
||||
draggable: true, // 可拖拽
|
||||
// 取消按钮回调
|
||||
|
||||
@@ -57,6 +57,13 @@ export const gridOptions: VxeGridProps<RowType> = {
|
||||
slots: { default: 'subscribe_price_change' },
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
field: 'see_rate',
|
||||
align: 'left',
|
||||
title: '查看毛利率',
|
||||
slots: { default: 'see_rate' },
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
// 药店二维码列(已从"诊所二维码"改为"药店二维码")
|
||||
field: 'qr_code',
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
openPcWindowsApiByStore,
|
||||
openQrCodeApi,
|
||||
updateStoreShippingFree,
|
||||
updateStoreSeeRateStatus,
|
||||
updateStoreSubscribeStatus,
|
||||
} from '#/views/system/store/api';
|
||||
// 导入表单弹窗组件
|
||||
@@ -223,6 +224,16 @@ const updateSubscribe = (id: number) => {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 切换是否可查看毛利率
|
||||
*/
|
||||
const updateSeeRate = (id: number) => {
|
||||
updateStoreSeeRateStatus({ id }).then(() => {
|
||||
message.success('修改成功!');
|
||||
gridApi.query();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 批量同步总仓库药品
|
||||
*/
|
||||
@@ -387,6 +398,15 @@ const batchSyncDrugPrice = () => {
|
||||
{{ row.subscribe_price_change === 0 ? '订阅' : '不订阅' }}
|
||||
</Tag>
|
||||
</template>
|
||||
<template #see_rate="{ row }">
|
||||
<Tag
|
||||
:color="Number(row.see_rate) === 1 ? 'success' : 'default'"
|
||||
style="cursor: pointer"
|
||||
@click="updateSeeRate(row.id)"
|
||||
>
|
||||
{{ Number(row.see_rate) === 1 ? '可查看' : '不可查看' }}
|
||||
</Tag>
|
||||
</template>
|
||||
<template #start-time="{ row }">
|
||||
早:<Tag color="success">{{ row.start_time }}</Tag>
|
||||
<br />
|
||||
|
||||
@@ -9,13 +9,59 @@ import { useVbenForm } from '#/adapter/form';
|
||||
import { createProcess, updateProcess } from '#/views/system/process/api';
|
||||
import { modalFormProps } from '#/views/system/process/config/form';
|
||||
|
||||
|
||||
|
||||
const isUpdate = ref(false);
|
||||
const gridApi = ref();
|
||||
|
||||
const [Form, formApi] = useVbenForm(modalFormProps);
|
||||
|
||||
function buildSubmitPayload(values: Record<string, any>) {
|
||||
const formLevel = Number(values.formLevel);
|
||||
const payload: Record<string, any> = {
|
||||
id: values.id,
|
||||
};
|
||||
|
||||
if (formLevel === 3) {
|
||||
payload.node_type = 'note';
|
||||
payload.rule_id = values.rule_id;
|
||||
payload.note = values.note;
|
||||
if (values.real_id) {
|
||||
payload.real_id = values.real_id;
|
||||
}
|
||||
return payload;
|
||||
}
|
||||
|
||||
payload.node_type = 'rule';
|
||||
payload.name = values.name;
|
||||
payload.pid = formLevel === 1 ? 0 : values.pid;
|
||||
if (formLevel === 2) {
|
||||
payload.calc_method = values.calc_method;
|
||||
payload.price = values.price;
|
||||
payload.unit = values.unit;
|
||||
}
|
||||
|
||||
return payload;
|
||||
}
|
||||
|
||||
function validateFormValues(values: Record<string, any>) {
|
||||
const formLevel = Number(values.formLevel);
|
||||
if (formLevel === 3) {
|
||||
if (!String(values.note ?? '').trim()) {
|
||||
message.error('请输入备注名称');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (!String(values.name ?? '').trim()) {
|
||||
message.error('请输入名称');
|
||||
return false;
|
||||
}
|
||||
if (formLevel === 2 && !values.pid) {
|
||||
message.error('请选择父级制剂');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
fullscreenButton: false,
|
||||
draggable: true,
|
||||
@@ -23,31 +69,37 @@ const [Modal, modalApi] = useVbenModal({
|
||||
modalApi.close();
|
||||
},
|
||||
onConfirm: async () => {
|
||||
formApi.validate().then(async (e: any) => {
|
||||
if (e.valid) {
|
||||
const values = await formApi.getValues();
|
||||
modalApi.setState({ loading: true, confirmLoading: true });
|
||||
const submitApi = isUpdate.value ? updateProcess : createProcess;
|
||||
submitApi(values)
|
||||
.then(() => {
|
||||
message.success('保存成功');
|
||||
gridApi.value?.reload();
|
||||
modalApi.close();
|
||||
})
|
||||
.finally(() => {
|
||||
modalApi.setState({ loading: false, confirmLoading: false });
|
||||
});
|
||||
}
|
||||
});
|
||||
await formApi.validateAndSubmitForm();
|
||||
const values = await formApi.getValues();
|
||||
if (!validateFormValues(values)) {
|
||||
return;
|
||||
}
|
||||
const payload = buildSubmitPayload(values);
|
||||
modalApi.setState({ loading: true, confirmLoading: true });
|
||||
const submitApi = isUpdate.value ? updateProcess : createProcess;
|
||||
submitApi(payload)
|
||||
.then(() => {
|
||||
message.success('保存成功');
|
||||
gridApi.value?.reload();
|
||||
modalApi.close();
|
||||
})
|
||||
.finally(() => {
|
||||
modalApi.setState({ loading: false, confirmLoading: false });
|
||||
});
|
||||
},
|
||||
onOpenChange(isOpen: boolean) {
|
||||
gridApi.value = isOpen ? modalApi.getData()?.gridApi : null;
|
||||
if (isOpen) {
|
||||
const { values, update } = modalApi.getData<Record<string, any>>();
|
||||
const { values, update, formLevel } = modalApi.getData<Record<string, any>>();
|
||||
isUpdate.value = update;
|
||||
formApi.resetForm();
|
||||
if (values) {
|
||||
isUpdate.value = update;
|
||||
formApi.setValues(values);
|
||||
const formValues = {
|
||||
...values,
|
||||
formLevel,
|
||||
note: values.note ?? values.name,
|
||||
has_children: values.has_children ?? false,
|
||||
};
|
||||
formApi.setValues(formValues);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Form, FormItem, InputNumber, message } from 'ant-design-vue';
|
||||
|
||||
import { updateProcess } from '#/views/system/process/api';
|
||||
|
||||
const noteRow = ref<Record<string, any>>({});
|
||||
const volumeValue = ref<null | number>(null);
|
||||
const gridApiRef = ref<any>(null);
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
fullscreenButton: false,
|
||||
draggable: true,
|
||||
onCancel() {
|
||||
modalApi.close();
|
||||
},
|
||||
onConfirm: async () => {
|
||||
if (volumeValue.value === null || volumeValue.value === undefined) {
|
||||
message.error('请输入毫升');
|
||||
return;
|
||||
}
|
||||
modalApi.setState({ confirmLoading: true });
|
||||
try {
|
||||
const realId = noteRow.value.real_id ?? Math.abs(Number(noteRow.value.id));
|
||||
await updateProcess({
|
||||
id: noteRow.value.id,
|
||||
node_type: 'note',
|
||||
real_id: realId,
|
||||
note: noteRow.value.note ?? noteRow.value.name,
|
||||
volume: volumeValue.value,
|
||||
});
|
||||
message.success('保存成功');
|
||||
gridApiRef.value?.query?.();
|
||||
// gridApiRef.value?.reload?.();
|
||||
modalApi.close();
|
||||
} finally {
|
||||
modalApi.setState({ confirmLoading: false });
|
||||
}
|
||||
},
|
||||
onOpenChange(isOpen: boolean) {
|
||||
if (isOpen) {
|
||||
const data = modalApi.getData<{
|
||||
gridApi: any;
|
||||
row: Record<string, any>;
|
||||
}>();
|
||||
gridApiRef.value = data?.gridApi;
|
||||
noteRow.value = data?.row ?? {};
|
||||
const raw = noteRow.value.volume;
|
||||
volumeValue.value =
|
||||
raw !== null && raw !== undefined && raw !== '' ? Number(raw) : null;
|
||||
} else {
|
||||
noteRow.value = {};
|
||||
volumeValue.value = null;
|
||||
gridApiRef.value = null;
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal title="设置毫升" class="w-[400px]">
|
||||
<Form layout="vertical">
|
||||
<FormItem label="备注名称">
|
||||
<span>{{ noteRow.name ?? noteRow.note ?? '-' }}</span>
|
||||
</FormItem>
|
||||
<FormItem label="毫升" required>
|
||||
<InputNumber
|
||||
v-model:value="volumeValue"
|
||||
:min="1"
|
||||
class="w-full"
|
||||
placeholder="请输入毫升,用于传给 MES"
|
||||
/>
|
||||
</FormItem>
|
||||
</Form>
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -1,92 +1,127 @@
|
||||
import type { VbenFormProps } from '#/adapter/form';
|
||||
import {getProcessOptionPidApi} from "#/views/system/process/api";
|
||||
|
||||
import { getProcessOptionPidApi } from '#/views/system/process/api';
|
||||
|
||||
export const modalFormProps: VbenFormProps = {
|
||||
wrapperClass: 'grid-cols-12', // 24栅格,
|
||||
wrapperClass: 'grid-cols-12',
|
||||
commonConfig: {
|
||||
formItemClass: 'col-span-12',
|
||||
// 所有表单项
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
},
|
||||
// handleSubmit: onSubmit,
|
||||
layout: 'horizontal',
|
||||
schema: [
|
||||
// {
|
||||
// fieldName: 'baseinfo',
|
||||
// component: 'Divider',
|
||||
// label: '基础信息',
|
||||
// formItemClass: 'col-span-12',
|
||||
// componentProps: {},
|
||||
// hideLabel: true,
|
||||
// renderComponentContent: () => {
|
||||
// return {
|
||||
// default: () => {
|
||||
// return '基础信息';
|
||||
// },
|
||||
// };
|
||||
// },
|
||||
// },
|
||||
{
|
||||
component: 'VbenInput',
|
||||
fieldName: 'id',
|
||||
label: 'ID',
|
||||
formItemClass: 'col-span-6',
|
||||
dependencies: {
|
||||
show: false,
|
||||
triggerFields: ['id'],
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'VbenInput',
|
||||
fieldName: 'node_type',
|
||||
label: '节点类型',
|
||||
dependencies: {
|
||||
show: false,
|
||||
triggerFields: ['node_type'],
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'VbenInput',
|
||||
fieldName: 'formLevel',
|
||||
label: '表单层级',
|
||||
dependencies: {
|
||||
show: false,
|
||||
triggerFields: ['formLevel'],
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'VbenInput',
|
||||
fieldName: 'rule_id',
|
||||
label: '所属煎法',
|
||||
dependencies: {
|
||||
show: false,
|
||||
triggerFields: ['rule_id'],
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'VbenInput',
|
||||
fieldName: 'real_id',
|
||||
label: '真实ID',
|
||||
dependencies: {
|
||||
show: false,
|
||||
triggerFields: ['real_id'],
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'VbenInput',
|
||||
fieldName: 'has_children',
|
||||
label: '是否有子级',
|
||||
dependencies: {
|
||||
show: false,
|
||||
triggerFields: ['has_children'],
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'VbenInput',
|
||||
componentProps: {
|
||||
placeholder: '请输入加工费昵称',
|
||||
placeholder: '请输入名称',
|
||||
},
|
||||
fieldName: 'name',
|
||||
label: '加工费名称',
|
||||
rules: 'required',
|
||||
label: '名称',
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return Number(values.formLevel) !== 3;
|
||||
},
|
||||
triggerFields: ['formLevel'],
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'VbenInput',
|
||||
componentProps: {
|
||||
placeholder: '请输入备注名称',
|
||||
},
|
||||
fieldName: 'note',
|
||||
label: '备注名称',
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return Number(values.formLevel) === 3;
|
||||
},
|
||||
triggerFields: ['formLevel'],
|
||||
},
|
||||
},
|
||||
// calc_method '计算方式 1固定价格 2贴数 3克数',
|
||||
{
|
||||
component: 'VbenSelect',
|
||||
componentProps: {
|
||||
placeholder: '请选择计算方式',
|
||||
options: [
|
||||
{
|
||||
label: '固定价格',
|
||||
value: 1,
|
||||
},
|
||||
{
|
||||
label: '贴数',
|
||||
value: 2,
|
||||
},
|
||||
{
|
||||
label: '克数',
|
||||
value: 3,
|
||||
},
|
||||
{ label: '固定价格', value: 1 },
|
||||
{ label: '贴数', value: 2 },
|
||||
{ label: '克数', value: 3 },
|
||||
],
|
||||
},
|
||||
fieldName: 'calc_method',
|
||||
label: '计算方式',
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return Number(values.formLevel) === 2;
|
||||
},
|
||||
triggerFields: ['formLevel'],
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
placeholder: '请选择计算方式',
|
||||
placeholder: '请选择父级制剂',
|
||||
api: getProcessOptionPidApi,
|
||||
filterOption: (input: string, option: any) => {
|
||||
// 自定义过滤逻辑,确保可以根据 name 进行搜索
|
||||
return option?.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
|
||||
},
|
||||
filterOption: (input: string, option: any) =>
|
||||
option?.label.toLowerCase().indexOf(input.toLowerCase()) >= 0,
|
||||
showSearch: true,
|
||||
// 菜单接口转options格式
|
||||
afterFetch: (data: { id: number; name: string }[]) => {
|
||||
// 在开头插入value = 0 的选项
|
||||
data.unshift({
|
||||
name: '一级分类',
|
||||
id: 0,
|
||||
});
|
||||
return data.map((item: any) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
@@ -94,15 +129,28 @@ export const modalFormProps: VbenFormProps = {
|
||||
},
|
||||
},
|
||||
fieldName: 'pid',
|
||||
label: '父级',
|
||||
label: '父级制剂',
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return Number(values.formLevel) === 2;
|
||||
},
|
||||
triggerFields: ['formLevel'],
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
placeholder: '请输入计算价格',
|
||||
class: 'w-full',
|
||||
},
|
||||
fieldName: 'price',
|
||||
label: '计算价格',
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return Number(values.formLevel) === 2;
|
||||
},
|
||||
triggerFields: ['formLevel'],
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'VbenInput',
|
||||
@@ -111,6 +159,12 @@ export const modalFormProps: VbenFormProps = {
|
||||
},
|
||||
fieldName: 'unit',
|
||||
label: '计算单位',
|
||||
dependencies: {
|
||||
show(values) {
|
||||
return Number(values.formLevel) === 2;
|
||||
},
|
||||
triggerFields: ['formLevel'],
|
||||
},
|
||||
},
|
||||
],
|
||||
showDefaultActions: false,
|
||||
|
||||
@@ -2,6 +2,22 @@ import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
|
||||
import { getProcessList } from '#/views/system/process/api';
|
||||
|
||||
const calcMethodMap: Record<number, string> = {
|
||||
1: '固定价格',
|
||||
2: '贴数',
|
||||
3: '克数',
|
||||
};
|
||||
|
||||
function getLevelLabel(row: Record<string, any>) {
|
||||
if (row.node_type === 'note') {
|
||||
return '备注';
|
||||
}
|
||||
if (Number(row.pid) === 0) {
|
||||
return '制剂';
|
||||
}
|
||||
return '煎法';
|
||||
}
|
||||
|
||||
export const gridOptions: VxeGridProps = {
|
||||
checkboxConfig: {
|
||||
highlight: true,
|
||||
@@ -17,18 +33,48 @@ export const gridOptions: VxeGridProps = {
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{ width: 60, treeNode: true },
|
||||
{ field: 'id', align: 'left', title: 'ID', width: 100 },
|
||||
{ field: 'name', title: '加工费名称' },
|
||||
{ field: 'calc_method', title: '计算方式' },
|
||||
{ field: 'price', title: '计算价格' },
|
||||
{ field: 'unit', title: '计算单位' },
|
||||
{
|
||||
field: 'level',
|
||||
title: '级别',
|
||||
width: 90,
|
||||
formatter: ({ row }) => getLevelLabel(row),
|
||||
},
|
||||
{ field: 'name', title: '名称' },
|
||||
{
|
||||
field: 'calc_method',
|
||||
title: '计算方式',
|
||||
formatter: ({ row, cellValue }) => {
|
||||
if (row.node_type === 'note') {
|
||||
return '-';
|
||||
}
|
||||
return calcMethodMap[Number(cellValue)] || cellValue || '-';
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'price',
|
||||
title: '计算价格',
|
||||
formatter: ({ row, cellValue }) =>
|
||||
row.node_type === 'note' ? '-' : (cellValue ?? '-'),
|
||||
},
|
||||
{
|
||||
field: 'unit',
|
||||
title: '计算单位',
|
||||
formatter: ({ row, cellValue }) =>
|
||||
row.node_type === 'note' ? '-' : (cellValue ?? '-'),
|
||||
},
|
||||
{
|
||||
field: 'volume',
|
||||
title: '毫升',
|
||||
width: 100,
|
||||
slots: { default: 'volume' },
|
||||
},
|
||||
{ field: 'created_at', title: '创建时间' },
|
||||
{ type: 'html', title: '操作', slots: { default: 'action' } },
|
||||
{ type: 'html', title: '操作', slots: { default: 'action' }, width: 220 },
|
||||
],
|
||||
keepSource: true,
|
||||
pagerConfig: {},
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
// 请求后端接口方法
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getProcessList({
|
||||
page: page.currentPage,
|
||||
@@ -47,21 +93,27 @@ export const gridOptions: VxeGridProps = {
|
||||
height: 'auto',
|
||||
border: false,
|
||||
toolbarConfig: {
|
||||
// 是否显示搜索表单控制按钮
|
||||
// @ts-ignore 正式环境时有完整的类型声明
|
||||
search: true,
|
||||
refresh: true, // 刷新
|
||||
print: false, // 打印
|
||||
export: false, // 导出
|
||||
// custom: true, // 自定义列
|
||||
zoom: true, // 最大化最小化
|
||||
refresh: true,
|
||||
print: false,
|
||||
export: false,
|
||||
zoom: true,
|
||||
slots: {
|
||||
buttons: 'toolbar-buttons',
|
||||
},
|
||||
custom: {
|
||||
// 自定义列-图标
|
||||
icon: 'vxe-icon-menu',
|
||||
},
|
||||
},
|
||||
showOverflow: false,
|
||||
};
|
||||
|
||||
export function getProcessNodeLevel(row: Record<string, any>) {
|
||||
if (row.node_type === 'note') {
|
||||
return 3;
|
||||
}
|
||||
if (Number(row.pid) === 0) {
|
||||
return 1;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
@@ -5,26 +5,25 @@ import { ref } from 'vue';
|
||||
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Button, Image, message } from 'ant-design-vue';
|
||||
import { Button, message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { TableAction } from '#/components/table-action';
|
||||
|
||||
import { deleteProcess } from './api';
|
||||
import FormModalDemo from './components/modal.vue';
|
||||
import VolumeModal from './components/volume-modal.vue';
|
||||
import { formOptions } from './config/search';
|
||||
import { gridOptions } from './config/table';
|
||||
import { getProcessNodeLevel, gridOptions } from './config/table';
|
||||
|
||||
const hasTopTableDropDownActions = ref(false);
|
||||
|
||||
const gridEvents: VxeGridListeners<any> = {
|
||||
checkboxChange() {
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
const records = gridApi.grid.getCheckboxRecords();
|
||||
hasTopTableDropDownActions.value = records.length > 0;
|
||||
},
|
||||
checkboxAll() {
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
const records = gridApi.grid.getCheckboxRecords();
|
||||
hasTopTableDropDownActions.value = records.length > 0;
|
||||
},
|
||||
@@ -40,28 +39,113 @@ const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: FormModalDemo,
|
||||
});
|
||||
|
||||
const showModal = (data = {}, isUpdate = false) => {
|
||||
const [VolumeModalComponent, volumeModalApi] = useVbenModal({
|
||||
connectedComponent: VolumeModal,
|
||||
});
|
||||
|
||||
function showVolumeModal(row: Record<string, any>) {
|
||||
volumeModalApi.setData({
|
||||
row,
|
||||
gridApi,
|
||||
});
|
||||
volumeModalApi.open();
|
||||
}
|
||||
|
||||
function getVolumeLinkLabel(row: Record<string, any>) {
|
||||
const volume = row.volume;
|
||||
if (volume !== null && volume !== undefined && volume !== '') {
|
||||
return `${volume}ml`;
|
||||
}
|
||||
return '设置';
|
||||
}
|
||||
|
||||
function openModal(options: {
|
||||
formLevel: number;
|
||||
isUpdate?: boolean;
|
||||
parentRow?: Record<string, any>;
|
||||
values?: Record<string, any>;
|
||||
}) {
|
||||
const { formLevel, isUpdate = false, parentRow, values = {} } = options;
|
||||
let formValues: Record<string, any> = { ...values, formLevel };
|
||||
|
||||
if (!isUpdate) {
|
||||
if (formLevel === 1) {
|
||||
formValues = {
|
||||
node_type: 'rule',
|
||||
pid: 0,
|
||||
formLevel: 1,
|
||||
};
|
||||
} else if (formLevel === 2 && parentRow) {
|
||||
formValues = {
|
||||
node_type: 'rule',
|
||||
pid: parentRow.id,
|
||||
formLevel: 2,
|
||||
};
|
||||
} else if (formLevel === 3 && parentRow) {
|
||||
formValues = {
|
||||
node_type: 'note',
|
||||
rule_id: parentRow.id,
|
||||
formLevel: 3,
|
||||
};
|
||||
}
|
||||
} else if (formLevel === 3) {
|
||||
formValues = {
|
||||
...values,
|
||||
formLevel: 3,
|
||||
note: values.note ?? values.name,
|
||||
rule_id: values.pid,
|
||||
real_id: values.real_id ?? Math.abs(Number(values.id)),
|
||||
};
|
||||
} else {
|
||||
formValues = {
|
||||
...values,
|
||||
formLevel,
|
||||
has_children: values.has_children ?? false,
|
||||
};
|
||||
}
|
||||
|
||||
formModalApi.setData({
|
||||
// 表单值
|
||||
values: data,
|
||||
values: formValues,
|
||||
update: isUpdate,
|
||||
formLevel,
|
||||
gridApi,
|
||||
});
|
||||
formModalApi.open();
|
||||
}
|
||||
|
||||
const showCreateLevel1 = () => {
|
||||
openModal({ formLevel: 1 });
|
||||
};
|
||||
|
||||
const deleteApi = (row: any) => {
|
||||
let ids = [];
|
||||
if (row) {
|
||||
ids.push(row);
|
||||
} else {
|
||||
ids = gridApi.grid.getCheckboxRecords().map((item) => item.id);
|
||||
}
|
||||
deleteProcess({ ids }).then(() => {
|
||||
const showEditModal = (row: Record<string, any>) => {
|
||||
openModal({
|
||||
formLevel: getProcessNodeLevel(row),
|
||||
isUpdate: true,
|
||||
values: row,
|
||||
});
|
||||
};
|
||||
|
||||
const showCreateChildRule = (row: Record<string, any>) => {
|
||||
openModal({
|
||||
formLevel: 2,
|
||||
parentRow: row,
|
||||
});
|
||||
};
|
||||
|
||||
const showCreateChildNote = (row: Record<string, any>) => {
|
||||
openModal({
|
||||
formLevel: 3,
|
||||
parentRow: row,
|
||||
});
|
||||
};
|
||||
|
||||
const deleteRow = (row: Record<string, any>) => {
|
||||
deleteProcess({ ids: [row.id] }).then(() => {
|
||||
message.success('删除成功!');
|
||||
gridApi.query();
|
||||
});
|
||||
};
|
||||
|
||||
const expandAll = () => {
|
||||
gridApi.grid?.setAllTreeExpand(true);
|
||||
};
|
||||
@@ -74,42 +158,29 @@ const collapseAll = () => {
|
||||
<template>
|
||||
<Page auto-content-height title="加工费管理">
|
||||
<FormModal />
|
||||
<VolumeModalComponent />
|
||||
<Grid>
|
||||
<template #toolbar-buttons>
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '新增',
|
||||
label: '新增制剂',
|
||||
type: 'primary',
|
||||
icon: 'ant-design:plus-outlined',
|
||||
// auth: ['超级加工费', 'sys:user:save'],
|
||||
onClick: showModal.bind(null),
|
||||
onClick: showCreateLevel1,
|
||||
},
|
||||
{
|
||||
label: '展开全部',
|
||||
type: 'primary',
|
||||
// auth: ['超级菜单', 'sys:user:save'],
|
||||
onClick: expandAll.bind(null),
|
||||
onClick: expandAll,
|
||||
},
|
||||
{
|
||||
label: '收起全部',
|
||||
type: 'primary',
|
||||
// auth: ['超级菜单', 'sys:user:save'],
|
||||
onClick: collapseAll.bind(null),
|
||||
onClick: collapseAll,
|
||||
},
|
||||
]"
|
||||
:drop-down-actions="[
|
||||
// {
|
||||
// label: '删除',
|
||||
// icon: 'ant-design:delete-outlined',
|
||||
// ifShow: hasTopTableDropDownActions,
|
||||
// // auth: ['超级加工费', 'sys:user:save'],
|
||||
// popConfirm: {
|
||||
// title: '确定删除吗?',
|
||||
// confirm: deleteApi.bind(null, false),
|
||||
// },
|
||||
// },
|
||||
]"
|
||||
:drop-down-actions="[]"
|
||||
>
|
||||
<template #more>
|
||||
<Button style="margin-left: 16px">
|
||||
@@ -119,66 +190,62 @@ const collapseAll = () => {
|
||||
</template>
|
||||
</TableAction>
|
||||
</template>
|
||||
<template #logo="{ row }">
|
||||
<Image :src="row.logo" height="30" width="30" />
|
||||
<template #volume="{ row }">
|
||||
<Button
|
||||
v-if="row.node_type === 'note'"
|
||||
class="h-auto p-0"
|
||||
size="small"
|
||||
type="link"
|
||||
@click="showVolumeModal(row)"
|
||||
>
|
||||
{{ getVolumeLinkLabel(row) }}
|
||||
</Button>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
<template #open_business_license="{ row }">
|
||||
<Image :src="row.open_business_license" height="30" width="30" />
|
||||
</template>
|
||||
<template #business_license="{ row }">
|
||||
<Image :src="row.business_license" height="30" width="30" />
|
||||
</template>
|
||||
<template #product_registration_certificate="{ row }">
|
||||
<Image
|
||||
:src="row.product_registration_certificate"
|
||||
height="30"
|
||||
width="30"
|
||||
/>
|
||||
</template>
|
||||
<template #toolbar-tools></template>
|
||||
<template #action="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
...(getProcessNodeLevel(row) === 1
|
||||
? [
|
||||
{
|
||||
label: '新增煎法',
|
||||
type: 'link',
|
||||
size: 'small',
|
||||
onClick: () => showCreateChildRule(row),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(getProcessNodeLevel(row) === 2
|
||||
? [
|
||||
{
|
||||
label: '新增备注',
|
||||
type: 'link',
|
||||
size: 'small',
|
||||
onClick: () => showCreateChildNote(row),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
label: '编辑',
|
||||
type: 'link',
|
||||
icon: 'uil:edit',
|
||||
size: 'small',
|
||||
// auth: ['process', 'sys:role:detail'],
|
||||
onClick: showModal.bind(null, row, true),
|
||||
onClick: () => showEditModal(row),
|
||||
},
|
||||
// {
|
||||
// label: '删除',
|
||||
// type: 'link',
|
||||
// icon: 'ant-design:delete-outlined',
|
||||
// size: 'small',
|
||||
// // auth: ['process', 'sys:role:detail'],
|
||||
// popConfirm: {
|
||||
// title: '确定删除吗?',
|
||||
// confirm: deleteApi.bind(null, row.id),
|
||||
// },
|
||||
// },
|
||||
]"
|
||||
:drop-down-actions="[
|
||||
// {
|
||||
// label: '编辑',
|
||||
// type: 'link',
|
||||
// icon: 'ant-design:delete-outlined',
|
||||
// size: 'small',
|
||||
// // auth: ['process', 'sys:role:detail'],
|
||||
// onClick: showModal.bind(null, row, true),
|
||||
// },
|
||||
// {
|
||||
// label: '删除',
|
||||
// type: 'link',
|
||||
// icon: 'ant-design:delete-outlined',
|
||||
// size: 'small',
|
||||
// // auth: ['process', 'sys:role:detail'],
|
||||
// popConfirm: {
|
||||
// title: '确定删除吗?',
|
||||
// confirm: deleteApi.bind(null, row.id),
|
||||
// },
|
||||
// },
|
||||
...(getProcessNodeLevel(row) === 3
|
||||
? [
|
||||
{
|
||||
label: '删除',
|
||||
type: 'link',
|
||||
icon: 'ant-design:delete-outlined',
|
||||
size: 'small',
|
||||
popConfirm: {
|
||||
title: '确定删除该备注吗?',
|
||||
confirm: () => deleteRow(row),
|
||||
},
|
||||
},
|
||||
]
|
||||
: []),
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
|
||||
@@ -38,10 +38,25 @@ export async function updateStoreInput(data: Record<string, any>) {
|
||||
* 审核录入
|
||||
* @param data
|
||||
*/
|
||||
export async function getPromoterOptions() {
|
||||
return requestClient.get<{
|
||||
id: number;
|
||||
nick_name: string;
|
||||
avatar: string;
|
||||
code: string;
|
||||
role_id: number;
|
||||
role_name: string;
|
||||
}[]>(`${prefix}promoter-options`);
|
||||
}
|
||||
|
||||
export async function auditStoreInput(data: {
|
||||
id: number;
|
||||
status: number; // 1=审核通过,2=审核拒绝
|
||||
audit_remark?: string;
|
||||
erp_id?: number | string;
|
||||
mes_id?: number | string;
|
||||
/** 门店审核通过时一并审核的医生预填 ID */
|
||||
doctor_input_ids?: number[];
|
||||
}) {
|
||||
return requestClient.post<any>(`${prefix}audit`, data);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { computed, ref } from 'vue';
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import { useUserStore } from '@vben/stores';
|
||||
|
||||
import { Button, message, Modal, Tag, Textarea } from 'ant-design-vue';
|
||||
import { Avatar, Button, message, Modal, Tag, Textarea } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { TableAction } from '#/components/table-action';
|
||||
@@ -14,8 +14,13 @@ import { TableAction } from '#/components/table-action';
|
||||
import { auditStoreInput, getStoreInputDetail } from './api';
|
||||
import AuditModal from './components/AuditModal.vue';
|
||||
import DetailModal from './components/DetailModal.vue';
|
||||
import { formOptions } from './config/search';
|
||||
import { auditFormOptions } from './config/search';
|
||||
import { auditGridOptions } from './config/table';
|
||||
import {
|
||||
inputUserDisplayName,
|
||||
normalizeInputUser,
|
||||
resolveAvatarUrl,
|
||||
} from './utils/inputUser';
|
||||
|
||||
const userStore = useUserStore();
|
||||
|
||||
@@ -38,7 +43,7 @@ const gridEvents: VxeGridListeners<any> = {
|
||||
};
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions,
|
||||
formOptions: auditFormOptions,
|
||||
gridOptions: auditGridOptions,
|
||||
gridEvents,
|
||||
});
|
||||
@@ -96,7 +101,7 @@ const getStatusText = (status: number) => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height title="诊所|药店信息审核">
|
||||
<Page auto-content-height title="门店信息审核">
|
||||
<DetailModalComponent />
|
||||
<AuditModalComponent />
|
||||
<Grid>
|
||||
@@ -115,6 +120,18 @@ const getStatusText = (status: number) => {
|
||||
{{ getStatusText(row.status) }}
|
||||
</Tag>
|
||||
</template>
|
||||
<template #inputUser="{ row }">
|
||||
<div v-if="normalizeInputUser(row)" class="flex items-center gap-2">
|
||||
<Avatar
|
||||
v-if="resolveAvatarUrl(row.inputUser?.avatar)"
|
||||
:src="resolveAvatarUrl(row.inputUser?.avatar)"
|
||||
:size="28"
|
||||
/>
|
||||
<Avatar v-else :size="28">{{ inputUserDisplayName(row.inputUser).charAt(0) }}</Avatar>
|
||||
<span>{{ inputUserDisplayName(row.inputUser) }}</span>
|
||||
</div>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
<template #audit_time="{ row }">
|
||||
<span v-if="row.audit_time">
|
||||
{{ new Date(row.audit_time * 1000).toLocaleString() }}
|
||||
|
||||
@@ -1,25 +1,58 @@
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Button, message, Modal, Radio, RadioGroup, Textarea } from 'ant-design-vue';
|
||||
import { Button, Input, message, Radio, RadioGroup, Textarea } from 'ant-design-vue';
|
||||
|
||||
import { auditStoreInput } from '../api';
|
||||
|
||||
const [ModalComponent, modalApi] = useVbenModal({
|
||||
fullscreenButton: false,
|
||||
draggable: true,
|
||||
onCancel() {
|
||||
modalApi.close();
|
||||
},
|
||||
});
|
||||
import { auditStoreInput, getStoreInputDetail } from '../api';
|
||||
import DoctorInputCardGrid from './DoctorInputCardGrid.vue';
|
||||
import { getLinkedDoctors, isDoctorPending } from '../utils/doctorInputDisplay';
|
||||
|
||||
const auditStatus = ref<number>(1);
|
||||
const auditRemark = ref<string>('');
|
||||
const erpId = ref<string>('');
|
||||
const mesId = ref<string>('');
|
||||
const currentRow = ref<any>(null);
|
||||
const gridApi = ref<any>(null);
|
||||
const loading = ref(false);
|
||||
const detailLoading = ref(false);
|
||||
const allDoctors = ref<any[]>([]);
|
||||
const selectedDoctorIds = ref<number[]>([]);
|
||||
|
||||
const pendingDoctorIds = computed(() =>
|
||||
allDoctors.value
|
||||
.filter((d) => isDoctorPending(d))
|
||||
.map((d) => Number(d.id))
|
||||
.filter((id) => id > 0),
|
||||
);
|
||||
|
||||
const loadLinkedDoctors = async (storeInputId: number) => {
|
||||
detailLoading.value = true;
|
||||
allDoctors.value = [];
|
||||
selectedDoctorIds.value = [];
|
||||
try {
|
||||
const res = await getStoreInputDetail(storeInputId);
|
||||
allDoctors.value = getLinkedDoctors(res);
|
||||
selectedDoctorIds.value = allDoctors.value
|
||||
.filter((d) => isDoctorPending(d))
|
||||
.map((d) => Number(d.id))
|
||||
.filter((id) => id > 0);
|
||||
} catch (error) {
|
||||
console.error('加载关联医生失败:', error);
|
||||
message.error('加载关联医生失败');
|
||||
} finally {
|
||||
detailLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const selectAllPending = () => {
|
||||
selectedDoctorIds.value = [...pendingDoctorIds.value];
|
||||
};
|
||||
|
||||
const clearSelection = () => {
|
||||
selectedDoctorIds.value = [];
|
||||
};
|
||||
|
||||
const handleAudit = async () => {
|
||||
if (!currentRow.value) {
|
||||
@@ -27,46 +60,96 @@ const handleAudit = async () => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (auditStatus.value === 1 && !erpId.value.trim()) {
|
||||
message.error('审核通过时请填写 ERP ID');
|
||||
return;
|
||||
}
|
||||
|
||||
loading.value = true;
|
||||
modalApi.setState({ confirmLoading: true });
|
||||
try {
|
||||
await auditStoreInput({
|
||||
const payload: Parameters<typeof auditStoreInput>[0] = {
|
||||
id: currentRow.value.id,
|
||||
status: auditStatus.value,
|
||||
audit_remark: auditRemark.value,
|
||||
});
|
||||
message.success('审核成功');
|
||||
erp_id: auditStatus.value === 1 ? erpId.value.trim() : undefined,
|
||||
mes_id:
|
||||
auditStatus.value === 1 && mesId.value.trim()
|
||||
? mesId.value.trim()
|
||||
: undefined,
|
||||
};
|
||||
if (auditStatus.value === 1 && selectedDoctorIds.value.length > 0) {
|
||||
payload.doctor_input_ids = [...selectedDoctorIds.value];
|
||||
}
|
||||
await auditStoreInput(payload);
|
||||
const doctorCount =
|
||||
auditStatus.value === 1 ? selectedDoctorIds.value.length : 0;
|
||||
message.success(
|
||||
doctorCount > 0
|
||||
? `审核成功,已一并通过 ${doctorCount} 位医生预填`
|
||||
: '审核成功',
|
||||
);
|
||||
gridApi.value?.reload();
|
||||
modalApi.close();
|
||||
// 重置表单
|
||||
auditStatus.value = 1;
|
||||
auditRemark.value = '';
|
||||
erpId.value = '';
|
||||
mesId.value = '';
|
||||
allDoctors.value = [];
|
||||
selectedDoctorIds.value = [];
|
||||
} catch (error) {
|
||||
console.error('审核失败:', error);
|
||||
message.error('审核失败,请稍后重试');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
modalApi.setState({ confirmLoading: false });
|
||||
}
|
||||
};
|
||||
|
||||
modalApi.onOpenChange = (isOpen: boolean) => {
|
||||
if (isOpen) {
|
||||
const { values, gridApi: api } = modalApi.getData<Record<string, any>>();
|
||||
currentRow.value = values;
|
||||
gridApi.value = api;
|
||||
auditStatus.value = 1;
|
||||
auditRemark.value = '';
|
||||
const [ModalComponent, modalApi] = useVbenModal({
|
||||
fullscreenButton: false,
|
||||
draggable: true,
|
||||
onCancel() {
|
||||
modalApi.close();
|
||||
},
|
||||
onConfirm: handleAudit,
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (isOpen) {
|
||||
const { values, gridApi: api } = modalApi.getData<Record<string, any>>();
|
||||
currentRow.value = values;
|
||||
gridApi.value = api;
|
||||
auditStatus.value = 1;
|
||||
auditRemark.value = '';
|
||||
erpId.value = values?.erp_id != null ? String(values.erp_id) : '';
|
||||
mesId.value = values?.mes_id != null ? String(values.mes_id) : '';
|
||||
if (values?.id) {
|
||||
await loadLinkedDoctors(Number(values.id));
|
||||
} else {
|
||||
message.warning('门店数据异常,无法加载关联医生');
|
||||
}
|
||||
} else {
|
||||
allDoctors.value = [];
|
||||
selectedDoctorIds.value = [];
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
watch(auditStatus, (v) => {
|
||||
if (v !== 1) {
|
||||
selectedDoctorIds.value = [];
|
||||
} else if (currentRow.value?.id && pendingDoctorIds.value.length) {
|
||||
selectedDoctorIds.value = [...pendingDoctorIds.value];
|
||||
}
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ModalComponent
|
||||
title="审核录入信息"
|
||||
class="w-[500px]"
|
||||
class="w-[720px]"
|
||||
:confirm-loading="loading"
|
||||
@confirm="handleAudit"
|
||||
>
|
||||
<div class="p-4 space-y-4">
|
||||
<div class="space-y-4 p-4">
|
||||
<div>
|
||||
<div class="mb-2 font-semibold">审核结果:</div>
|
||||
<RadioGroup v-model:value="auditStatus">
|
||||
@@ -74,6 +157,37 @@ modalApi.onOpenChange = (isOpen: boolean) => {
|
||||
<Radio :value="2">审核拒绝</Radio>
|
||||
</RadioGroup>
|
||||
</div>
|
||||
<div v-if="auditStatus === 1">
|
||||
<div class="mb-2 font-semibold">ERP ID:</div>
|
||||
<Input v-model:value="erpId" placeholder="审核通过时必填" />
|
||||
</div>
|
||||
<div v-if="auditStatus === 1">
|
||||
<div class="mb-2 font-semibold">MES ID:</div>
|
||||
<Input v-model:value="mesId" placeholder="可选,煎药中心编码" />
|
||||
</div>
|
||||
<div v-if="auditStatus === 1">
|
||||
<div class="mb-2 flex flex-wrap items-center justify-between gap-2">
|
||||
<div>
|
||||
<div class="font-semibold">一并审核关联医生(可选)</div>
|
||||
<div class="text-xs text-gray-500">点击卡片选中/取消,悬停查看详情</div>
|
||||
</div>
|
||||
<div v-if="pendingDoctorIds.length > 0" class="flex gap-2">
|
||||
<Button size="small" type="link" @click="selectAllPending">全选</Button>
|
||||
<Button size="small" type="link" @click="clearSelection">取消全选</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="detailLoading" class="text-sm text-gray-400">加载中...</div>
|
||||
<div v-else-if="allDoctors.length === 0" class="text-sm text-gray-400">
|
||||
暂无关联医生预填
|
||||
</div>
|
||||
<DoctorInputCardGrid
|
||||
v-else
|
||||
v-model:selected-ids="selectedDoctorIds"
|
||||
:doctors="allDoctors"
|
||||
selectable
|
||||
only-pending-selectable
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<div class="mb-2 font-semibold">审核备注:</div>
|
||||
<Textarea
|
||||
|
||||
@@ -1,11 +1,47 @@
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Descriptions, DescriptionsItem, Image } from 'ant-design-vue';
|
||||
import {
|
||||
Avatar,
|
||||
Descriptions,
|
||||
DescriptionsItem,
|
||||
Image,
|
||||
Spin,
|
||||
message,
|
||||
} from 'ant-design-vue';
|
||||
|
||||
import { getStoreInputDetail } from '../api';
|
||||
import DoctorInputCardGrid from './DoctorInputCardGrid.vue';
|
||||
import { getLinkedDoctors } from '../utils/doctorInputDisplay';
|
||||
import {
|
||||
inputUserDisplayName,
|
||||
normalizeInputUser,
|
||||
resolveAvatarUrl,
|
||||
} from '../utils/inputUser';
|
||||
|
||||
const detailData = ref<any>(null);
|
||||
const loading = ref(false);
|
||||
|
||||
const linkedDoctorList = computed(() =>
|
||||
detailData.value ? getLinkedDoctors(detailData.value) : [],
|
||||
);
|
||||
|
||||
const loadDetail = async (id: number) => {
|
||||
loading.value = true;
|
||||
detailData.value = null;
|
||||
try {
|
||||
const res = await getStoreInputDetail(id);
|
||||
detailData.value = res;
|
||||
normalizeInputUser(detailData.value);
|
||||
} catch (error) {
|
||||
console.error('获取详情失败:', error);
|
||||
message.error('获取详情失败');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
fullscreenButton: false,
|
||||
@@ -13,98 +49,143 @@ const [Modal, modalApi] = useVbenModal({
|
||||
onCancel() {
|
||||
modalApi.close();
|
||||
},
|
||||
});
|
||||
|
||||
const detailData = ref<any>(null);
|
||||
const loading = ref(false);
|
||||
|
||||
const loadDetail = async (id: number) => {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await getStoreInputDetail(id);
|
||||
detailData.value = res;
|
||||
} catch (error) {
|
||||
console.error('获取详情失败:', error);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
modalApi.onOpenChange = async (isOpen: boolean) => {
|
||||
if (isOpen) {
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
detailData.value = null;
|
||||
loading.value = false;
|
||||
return;
|
||||
}
|
||||
const { values } = modalApi.getData<Record<string, any>>();
|
||||
if (values?.id) {
|
||||
await loadDetail(values.id);
|
||||
} else {
|
||||
detailData.value = values;
|
||||
detailData.value = values || null;
|
||||
normalizeInputUser(detailData.value);
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal title="录入详情" class="w-[70%]">
|
||||
<div v-if="detailData" class="p-4">
|
||||
<Descriptions :column="2" bordered>
|
||||
<DescriptionsItem label="ID">{{ detailData.id }}</DescriptionsItem>
|
||||
<DescriptionsItem label="名称">{{ detailData.name }}</DescriptionsItem>
|
||||
<DescriptionsItem label="类型">
|
||||
{{ detailData.type === 0 ? '诊所' : '药店' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="诊所类型">
|
||||
{{ detailData.clinic_type === 1 ? '西医诊所' : detailData.clinic_type === 2 ? '中医诊所' : '未设置' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="联系人">{{ detailData.contact }}</DescriptionsItem>
|
||||
<DescriptionsItem label="联系电话">{{ detailData.mobile }}</DescriptionsItem>
|
||||
<DescriptionsItem label="省市区">
|
||||
{{ detailData.province?.name }} {{ detailData.city?.name }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="详细地址">{{ detailData.position }}</DescriptionsItem>
|
||||
<DescriptionsItem label="录入人">{{ detailData.inputUser?.nick_name }}</DescriptionsItem>
|
||||
<DescriptionsItem label="审核状态">
|
||||
<span :class="{
|
||||
'text-orange-500': detailData.status === 0,
|
||||
'text-green-500': detailData.status === 1,
|
||||
'text-red-500': detailData.status === 2,
|
||||
}">
|
||||
{{ detailData.status === 0 ? '待审核' : detailData.status === 1 ? '审核通过' : '审核拒绝' }}
|
||||
</span>
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="审核人" v-if="detailData.auditAdmin">
|
||||
{{ detailData.auditAdmin.nick_name }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="审核时间" v-if="detailData.audit_time">
|
||||
{{ new Date(detailData.audit_time * 1000).toLocaleString() }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="审核备注" v-if="detailData.audit_remark" :span="2">
|
||||
{{ detailData.audit_remark }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="轮播图" v-if="detailData.url && detailData.url.length > 0" :span="2">
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<Spin :spinning="loading">
|
||||
<div v-if="detailData" class="p-4">
|
||||
<Descriptions :column="2" bordered>
|
||||
<DescriptionsItem label="ID">{{ detailData.id }}</DescriptionsItem>
|
||||
<DescriptionsItem label="名称">{{ detailData.name }}</DescriptionsItem>
|
||||
<DescriptionsItem label="类型">
|
||||
{{ detailData.type === 0 ? '诊所' : '药店' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="诊所类型">
|
||||
{{
|
||||
detailData.clinic_type === 1
|
||||
? '西医诊所'
|
||||
: detailData.clinic_type === 2
|
||||
? '中医诊所'
|
||||
: '未设置'
|
||||
}}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="联系人">{{ detailData.contact }}</DescriptionsItem>
|
||||
<DescriptionsItem label="联系电话">{{ detailData.mobile }}</DescriptionsItem>
|
||||
<DescriptionsItem label="省市区">
|
||||
{{ detailData.province?.name }} {{ detailData.city?.name }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="详细地址">{{ detailData.position }}</DescriptionsItem>
|
||||
<DescriptionsItem label="录入人">
|
||||
<div class="flex items-center gap-2">
|
||||
<Avatar
|
||||
v-if="resolveAvatarUrl(detailData.inputUser?.avatar)"
|
||||
:src="resolveAvatarUrl(detailData.inputUser?.avatar)"
|
||||
:size="40"
|
||||
/>
|
||||
<Avatar v-else :size="40">
|
||||
{{ inputUserDisplayName(detailData.inputUser).charAt(0) }}
|
||||
</Avatar>
|
||||
<span>{{ inputUserDisplayName(detailData.inputUser) }}</span>
|
||||
</div>
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="审核状态">
|
||||
<span
|
||||
:class="{
|
||||
'text-orange-500': detailData.status === 0,
|
||||
'text-green-500': detailData.status === 1,
|
||||
'text-red-500': detailData.status === 2,
|
||||
}"
|
||||
>
|
||||
{{
|
||||
detailData.status === 0
|
||||
? '待审核'
|
||||
: detailData.status === 1
|
||||
? '审核通过'
|
||||
: '审核拒绝'
|
||||
}}
|
||||
</span>
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem v-if="detailData.auditAdmin" label="审核人">
|
||||
{{ detailData.auditAdmin.nick_name }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem v-if="detailData.audit_time" label="审核时间">
|
||||
{{ new Date(detailData.audit_time * 1000).toLocaleString() }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem
|
||||
v-if="detailData.audit_remark"
|
||||
label="审核备注"
|
||||
:span="2"
|
||||
>
|
||||
{{ detailData.audit_remark }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem v-if="detailData.see_rate" label="公章" :span="2">
|
||||
<Image
|
||||
v-for="(url, index) in detailData.url"
|
||||
:key="index"
|
||||
:src="url"
|
||||
:src="detailData.see_rate"
|
||||
:width="100"
|
||||
:height="100"
|
||||
:preview="true"
|
||||
/>
|
||||
</div>
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="合同文件" v-if="detailData.contract_files && detailData.contract_files.length > 0" :span="2">
|
||||
<div class="flex flex-col gap-2">
|
||||
<a
|
||||
v-for="(file, index) in detailData.contract_files"
|
||||
:key="index"
|
||||
:href="file.file_url"
|
||||
target="_blank"
|
||||
class="text-blue-500 hover:underline"
|
||||
>
|
||||
{{ file.file_name || '合同文件' }}
|
||||
</a>
|
||||
</div>
|
||||
</DescriptionsItem>
|
||||
</Descriptions>
|
||||
</div>
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem
|
||||
v-if="detailData.url && detailData.url.length > 0"
|
||||
label="轮播图"
|
||||
:span="2"
|
||||
>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<Image
|
||||
v-for="(url, index) in detailData.url"
|
||||
:key="index"
|
||||
:src="url"
|
||||
:width="100"
|
||||
:height="100"
|
||||
:preview="true"
|
||||
/>
|
||||
</div>
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem
|
||||
v-if="detailData.contract_files && detailData.contract_files.length > 0"
|
||||
label="合同文件"
|
||||
:span="2"
|
||||
>
|
||||
<div class="flex flex-col gap-2">
|
||||
<a
|
||||
v-for="(file, index) in detailData.contract_files"
|
||||
:key="index"
|
||||
:href="file.file_url"
|
||||
target="_blank"
|
||||
class="text-blue-500 hover:underline"
|
||||
>
|
||||
{{ file.file_name || '合同文件' }}
|
||||
</a>
|
||||
</div>
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="关联医生" :span="2">
|
||||
<div v-if="linkedDoctorList.length === 0" class="text-gray-400">
|
||||
暂无关联医生预填
|
||||
</div>
|
||||
<DoctorInputCardGrid v-else :doctors="linkedDoctorList" />
|
||||
</DescriptionsItem>
|
||||
</Descriptions>
|
||||
</div>
|
||||
<div v-else-if="!loading" class="p-8 text-center text-gray-400">
|
||||
暂无详情数据
|
||||
</div>
|
||||
</Spin>
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue';
|
||||
|
||||
import {
|
||||
Avatar,
|
||||
Descriptions,
|
||||
DescriptionsItem,
|
||||
Image,
|
||||
Popover,
|
||||
} from 'ant-design-vue';
|
||||
|
||||
import { resolveAvatarUrl } from '../utils/inputUser';
|
||||
import {
|
||||
doctorCertImages,
|
||||
doctorDepartName,
|
||||
doctorTitleName,
|
||||
getAuditStatusText,
|
||||
getDoctorTypeText,
|
||||
getSignTypeText,
|
||||
isDoctorPending,
|
||||
normalizeDoctorRecord,
|
||||
} from '../utils/doctorInputDisplay';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
doctors: Record<string, any>[];
|
||||
selectedIds?: number[];
|
||||
selectable?: boolean;
|
||||
onlyPendingSelectable?: boolean;
|
||||
}>(),
|
||||
{
|
||||
selectedIds: () => [],
|
||||
selectable: false,
|
||||
onlyPendingSelectable: true,
|
||||
},
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:selectedIds': [ids: number[]];
|
||||
}>();
|
||||
|
||||
const normalizedDoctors = computed(() =>
|
||||
(props.doctors || []).map((d) => normalizeDoctorRecord({ ...d })),
|
||||
);
|
||||
|
||||
function doctorId(doc: Record<string, any>) {
|
||||
return Number(doc.id) || 0;
|
||||
}
|
||||
|
||||
function isSelected(doc: Record<string, any>) {
|
||||
return props.selectedIds.includes(doctorId(doc));
|
||||
}
|
||||
|
||||
function canToggle(doc: Record<string, any>) {
|
||||
if (!props.selectable) return false;
|
||||
if (props.onlyPendingSelectable && !isDoctorPending(doc)) return false;
|
||||
return doctorId(doc) > 0;
|
||||
}
|
||||
|
||||
function toggleSelect(doc: Record<string, any>) {
|
||||
if (!canToggle(doc)) return;
|
||||
const id = doctorId(doc);
|
||||
const next = [...props.selectedIds];
|
||||
const idx = next.indexOf(id);
|
||||
if (idx >= 0) {
|
||||
next.splice(idx, 1);
|
||||
} else {
|
||||
next.push(id);
|
||||
}
|
||||
emit('update:selectedIds', next);
|
||||
}
|
||||
|
||||
function cardClass(doc: Record<string, any>) {
|
||||
const base =
|
||||
'flex h-full flex-col rounded border p-3 transition-colors';
|
||||
if (!props.selectable) {
|
||||
return `${base} cursor-default border-gray-100`;
|
||||
}
|
||||
if (!canToggle(doc)) {
|
||||
return `${base} cursor-not-allowed border-gray-100 bg-gray-50 opacity-75`;
|
||||
}
|
||||
if (isSelected(doc)) {
|
||||
return `${base} cursor-pointer border-primary ring-2 ring-primary ring-offset-1`;
|
||||
}
|
||||
return `${base} cursor-pointer border-gray-200 hover:border-primary/50`;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="grid grid-cols-2 gap-3 md:grid-cols-3">
|
||||
<Popover
|
||||
v-for="doc in normalizedDoctors"
|
||||
:key="doc.id"
|
||||
trigger="hover"
|
||||
placement="right"
|
||||
>
|
||||
<template #content>
|
||||
<Descriptions :column="1" size="small" class="max-w-[480px]">
|
||||
<DescriptionsItem label="ID">{{ doc.id }}</DescriptionsItem>
|
||||
<DescriptionsItem label="姓名">{{ doc.name }}</DescriptionsItem>
|
||||
<DescriptionsItem label="手机号">{{ doc.mobile || '-' }}</DescriptionsItem>
|
||||
<DescriptionsItem label="身份证">{{ doc.idcard || '-' }}</DescriptionsItem>
|
||||
<DescriptionsItem label="身份">{{ getDoctorTypeText(doc.type) }}</DescriptionsItem>
|
||||
<DescriptionsItem label="签名类型">
|
||||
{{ getSignTypeText(doc.sign_type) }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="科室">{{ doctorDepartName(doc) }}</DescriptionsItem>
|
||||
<DescriptionsItem label="职称">{{ doctorTitleName(doc) }}</DescriptionsItem>
|
||||
<DescriptionsItem label="擅长">{{ doc.good_at || '-' }}</DescriptionsItem>
|
||||
<DescriptionsItem label="简介">{{ doc.intro || '-' }}</DescriptionsItem>
|
||||
<DescriptionsItem label="审核状态">
|
||||
{{ getAuditStatusText(doc.status) }}
|
||||
</DescriptionsItem>
|
||||
</Descriptions>
|
||||
<div
|
||||
v-if="doctorCertImages(doc).length"
|
||||
class="mt-3 flex flex-wrap gap-2 border-t border-gray-100 pt-3"
|
||||
>
|
||||
<div
|
||||
v-for="(cert, idx) in doctorCertImages(doc)"
|
||||
:key="idx"
|
||||
class="text-center"
|
||||
>
|
||||
<Image
|
||||
:src="cert.url"
|
||||
:width="72"
|
||||
:height="72"
|
||||
:preview="true"
|
||||
class="rounded border border-gray-100"
|
||||
/>
|
||||
<div class="mt-1 text-xs text-gray-500">{{ cert.label }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div :class="cardClass(doc)" @click="toggleSelect(doc)">
|
||||
<div
|
||||
v-if="selectable && canToggle(doc) && isSelected(doc)"
|
||||
class="mb-1 text-right text-xs font-medium text-primary"
|
||||
>
|
||||
已选
|
||||
</div>
|
||||
<div
|
||||
v-else-if="selectable && onlyPendingSelectable && !isDoctorPending(doc)"
|
||||
class="mb-1 text-right text-xs text-gray-400"
|
||||
>
|
||||
{{ getAuditStatusText(doc.status) }}
|
||||
</div>
|
||||
<div class="mb-2 flex items-center gap-2">
|
||||
<Avatar
|
||||
v-if="resolveAvatarUrl(doc.avatar)"
|
||||
:src="resolveAvatarUrl(doc.avatar)"
|
||||
:size="40"
|
||||
/>
|
||||
<Avatar v-else :size="40">{{ (doc.name || '?').charAt(0) }}</Avatar>
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="truncate font-medium">{{ doc.name || '-' }}</div>
|
||||
<div class="truncate text-xs text-gray-500">
|
||||
{{ doctorDepartName(doc) }} · {{ doctorTitleName(doc) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="!selectable"
|
||||
class="text-xs"
|
||||
:class="{
|
||||
'text-orange-500': doc.status === 0,
|
||||
'text-green-500': doc.status === 1,
|
||||
'text-red-500': doc.status === 2,
|
||||
}"
|
||||
>
|
||||
{{ getAuditStatusText(doc.status) }}
|
||||
</div>
|
||||
<div
|
||||
v-if="doctorCertImages(doc).length"
|
||||
class="mt-2 flex flex-wrap gap-1"
|
||||
>
|
||||
<Image
|
||||
v-for="(cert, cidx) in doctorCertImages(doc).slice(0, 4)"
|
||||
:key="cidx"
|
||||
:src="cert.url"
|
||||
:width="48"
|
||||
:height="48"
|
||||
:preview="true"
|
||||
class="rounded border border-gray-100 object-cover"
|
||||
/>
|
||||
<span
|
||||
v-if="doctorCertImages(doc).length > 4"
|
||||
class="flex h-12 w-12 items-center justify-center rounded bg-gray-50 text-xs text-gray-400"
|
||||
>
|
||||
+{{ doctorCertImages(doc).length - 4 }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</Popover>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { VbenFormProps } from '#/adapter/form';
|
||||
|
||||
|
||||
// 诊所|药店信息录入表单配置
|
||||
// 门店信息录入表单配置
|
||||
export const modalFormProps: VbenFormProps = {
|
||||
wrapperClass: 'grid-cols-12',
|
||||
commonConfig: {
|
||||
@@ -46,10 +46,10 @@ export const modalFormProps: VbenFormProps = {
|
||||
component: 'VbenInput',
|
||||
formItemClass: 'col-span-6',
|
||||
componentProps: {
|
||||
placeholder: '请输入诊所/药店名称',
|
||||
placeholder: '请输入门店名称',
|
||||
},
|
||||
fieldName: 'name',
|
||||
label: '诊所/药店名称',
|
||||
label: '门店名称',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
@@ -60,15 +60,19 @@ export const modalFormProps: VbenFormProps = {
|
||||
},
|
||||
fieldName: 'erp_id',
|
||||
label: 'ERP ID',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'type',
|
||||
dependencies: {
|
||||
show: false,
|
||||
triggerFields: ['id'],
|
||||
component: 'RadioGroup',
|
||||
formItemClass: 'col-span-6',
|
||||
componentProps: {
|
||||
options: [
|
||||
{ label: '诊所', value: 0 },
|
||||
{ label: '药店', value: 1 },
|
||||
],
|
||||
},
|
||||
fieldName: 'type',
|
||||
label: '门店类型',
|
||||
rules: 'required',
|
||||
defaultValue: 0,
|
||||
},
|
||||
{
|
||||
@@ -136,13 +140,10 @@ export const modalFormProps: VbenFormProps = {
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'VbenInput',
|
||||
component: 'PromoterPicker',
|
||||
formItemClass: 'col-span-6',
|
||||
componentProps: {
|
||||
placeholder: '请输入业务码',
|
||||
},
|
||||
fieldName: 'code',
|
||||
label: '业务码',
|
||||
label: '业务员',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
|
||||
@@ -14,10 +14,10 @@ export const formOptions: VbenFormProps = {
|
||||
component: 'VbenInput',
|
||||
formItemClass: 'col-span-6',
|
||||
componentProps: {
|
||||
placeholder: '请输入诊所/药店名称',
|
||||
placeholder: '请输入门店名称',
|
||||
},
|
||||
fieldName: 'name',
|
||||
label: '诊所/药店名称',
|
||||
label: '门店名称',
|
||||
},
|
||||
{
|
||||
component: 'VbenInput',
|
||||
@@ -45,3 +45,11 @@ export const formOptions: VbenFormProps = {
|
||||
],
|
||||
showDefaultActions: false,
|
||||
};
|
||||
|
||||
/** 审核列表:默认只看待审核 */
|
||||
export const auditFormOptions: VbenFormProps = {
|
||||
...formOptions,
|
||||
schema: formOptions.schema?.map((item) =>
|
||||
item.fieldName === 'status' ? { ...item, defaultValue: 0 } : item,
|
||||
),
|
||||
};
|
||||
|
||||
@@ -34,7 +34,7 @@ export const inputGridOptions: VxeGridProps<RowType> = {
|
||||
columns: [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{ field: 'id', align: 'left', title: 'ID', width: 100 },
|
||||
{ field: 'name', align: 'left', title: '诊所/药店名称' },
|
||||
{ field: 'name', align: 'left', title: '门店名称' },
|
||||
{
|
||||
field: 'type',
|
||||
align: 'left',
|
||||
@@ -60,6 +60,12 @@ export const inputGridOptions: VxeGridProps<RowType> = {
|
||||
{ field: 'mobile', title: '联系电话' },
|
||||
{ field: 'position', title: '详细地址' },
|
||||
{ field: 'created_at', title: '录入时间' },
|
||||
{
|
||||
field: 'inputUser',
|
||||
title: '录入人',
|
||||
minWidth: 140,
|
||||
slots: { default: 'inputUser' },
|
||||
},
|
||||
{
|
||||
type: 'html',
|
||||
title: '操作',
|
||||
@@ -110,7 +116,7 @@ export const auditGridOptions: VxeGridProps<RowType> = {
|
||||
columns: [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{ field: 'id', align: 'left', title: 'ID', width: 100 },
|
||||
{ field: 'name', align: 'left', title: '诊所/药店名称' },
|
||||
{ field: 'name', align: 'left', title: '门店名称' },
|
||||
{
|
||||
field: 'type',
|
||||
align: 'left',
|
||||
@@ -132,7 +138,12 @@ export const auditGridOptions: VxeGridProps<RowType> = {
|
||||
width: 120,
|
||||
slots: { default: 'status' },
|
||||
},
|
||||
{ field: 'inputUser.nick_name', title: '录入人' },
|
||||
{
|
||||
field: 'inputUser',
|
||||
title: '录入人',
|
||||
minWidth: 140,
|
||||
slots: { default: 'inputUser' },
|
||||
},
|
||||
{ field: 'auditAdmin.nick_name', title: '审核人' },
|
||||
{ field: 'audit_time', title: '审核时间', slots: { default: 'audit_time' } },
|
||||
{ field: 'contact', title: '联系人' },
|
||||
@@ -142,7 +153,8 @@ export const auditGridOptions: VxeGridProps<RowType> = {
|
||||
{
|
||||
type: 'html',
|
||||
title: '操作',
|
||||
align: 'right',
|
||||
fixed: 'right',
|
||||
width: 200,
|
||||
slots: { default: 'action' },
|
||||
},
|
||||
],
|
||||
|
||||
@@ -6,7 +6,7 @@ import { computed, ref } from 'vue';
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import { useUserStore } from '@vben/stores';
|
||||
|
||||
import { Button, message, Tag } from 'ant-design-vue';
|
||||
import { Avatar, Button, message, Tag } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { TableAction } from '#/components/table-action';
|
||||
@@ -16,9 +16,15 @@ import {
|
||||
getStoreInputDetail,
|
||||
updateStoreInput,
|
||||
} from './api';
|
||||
import DetailModal from './components/DetailModal.vue';
|
||||
import FormModalDemo from './components/modal.vue';
|
||||
import { formOptions } from './config/search';
|
||||
import { inputGridOptions } from './config/table';
|
||||
import {
|
||||
inputUserDisplayName,
|
||||
normalizeInputUser,
|
||||
resolveAvatarUrl,
|
||||
} from './utils/inputUser';
|
||||
|
||||
const userStore = useUserStore();
|
||||
|
||||
@@ -45,6 +51,17 @@ const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: FormModalDemo,
|
||||
});
|
||||
|
||||
const [DetailModalComponent, detailModalApi] = useVbenModal({
|
||||
connectedComponent: DetailModal,
|
||||
});
|
||||
|
||||
const showDetail = (row: any) => {
|
||||
detailModalApi.setData({
|
||||
values: row,
|
||||
});
|
||||
detailModalApi.open();
|
||||
};
|
||||
|
||||
const showModal = (data = {}, isUpdate = false) => {
|
||||
formModalApi.setData({
|
||||
values: data,
|
||||
@@ -94,8 +111,9 @@ const getStatusText = (status: number) => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height title="诊所|药店信息录入">
|
||||
<Page auto-content-height title="门店信息录入">
|
||||
<FormModal />
|
||||
<DetailModalComponent />
|
||||
<Grid>
|
||||
<template #toolbar-buttons>
|
||||
<TableAction
|
||||
@@ -124,6 +142,18 @@ const getStatusText = (status: number) => {
|
||||
{{ getStatusText(row.status) }}
|
||||
</Tag>
|
||||
</template>
|
||||
<template #inputUser="{ row }">
|
||||
<div v-if="normalizeInputUser(row)" class="flex items-center gap-2">
|
||||
<Avatar
|
||||
v-if="resolveAvatarUrl(row.inputUser?.avatar)"
|
||||
:src="resolveAvatarUrl(row.inputUser?.avatar)"
|
||||
:size="28"
|
||||
/>
|
||||
<Avatar v-else :size="28">{{ inputUserDisplayName(row.inputUser).charAt(0) }}</Avatar>
|
||||
<span>{{ inputUserDisplayName(row.inputUser) }}</span>
|
||||
</div>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
<template #action="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
@@ -132,7 +162,7 @@ const getStatusText = (status: number) => {
|
||||
type: 'link',
|
||||
icon: 'uil:eye',
|
||||
size: 'small',
|
||||
onClick: showModal.bind(null, row, false),
|
||||
onClick: showDetail.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '编辑',
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
export type DoctorCertImage = { label: string; url: string };
|
||||
|
||||
export function normalizeDoctorRecord(doc: Record<string, any>) {
|
||||
if (!doc) return doc;
|
||||
if (!doc.titleInfo && doc.title_info) {
|
||||
doc.titleInfo = doc.title_info;
|
||||
}
|
||||
if (!doc.depart && doc.department) {
|
||||
doc.depart = doc.department;
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
|
||||
export function unwrapStoreInputDetail(res: unknown): Record<string, any> | null | undefined {
|
||||
if (res == null || typeof res !== 'object') {
|
||||
return res as Record<string, any> | null | undefined;
|
||||
}
|
||||
const obj = res as Record<string, any>;
|
||||
if (obj.doctor_inputs != null || obj.doctorInputs != null || obj.id != null) {
|
||||
return obj;
|
||||
}
|
||||
const inner = obj.data ?? obj.result;
|
||||
if (inner != null && typeof inner === 'object') {
|
||||
return inner as Record<string, any>;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
export function getLinkedDoctors(data: Record<string, any> | null | undefined) {
|
||||
const detail = unwrapStoreInputDetail(data) ?? data;
|
||||
const list = detail?.doctor_inputs ?? detail?.doctorInputs ?? [];
|
||||
const arr = Array.isArray(list) ? list : [];
|
||||
return arr.map((d) => normalizeDoctorRecord(d));
|
||||
}
|
||||
|
||||
export function doctorDepartName(doc: Record<string, any> | null | undefined) {
|
||||
if (!doc) return '-';
|
||||
const d = normalizeDoctorRecord(doc);
|
||||
return d.depart?.name ?? d.depart_name ?? '-';
|
||||
}
|
||||
|
||||
export function doctorTitleName(doc: Record<string, any> | null | undefined) {
|
||||
if (!doc) return '-';
|
||||
const d = normalizeDoctorRecord(doc);
|
||||
return d.titleInfo?.name ?? d.title_info?.name ?? '-';
|
||||
}
|
||||
|
||||
export function getDoctorTypeText(type: number) {
|
||||
if (type === 1) return '中医医生';
|
||||
if (type === 2) return '西医医生';
|
||||
return '-';
|
||||
}
|
||||
|
||||
export function getSignTypeText(signType: number) {
|
||||
if (signType === 1) return '电子签名';
|
||||
if (signType === 2) return '手写签名';
|
||||
return '-';
|
||||
}
|
||||
|
||||
export function getAuditStatusText(status: number) {
|
||||
if (status === 0) return '待审核';
|
||||
if (status === 1) return '审核通过';
|
||||
if (status === 2) return '审核拒绝';
|
||||
return '-';
|
||||
}
|
||||
|
||||
export function doctorCertImages(doc: Record<string, any> | null | undefined): DoctorCertImage[] {
|
||||
if (!doc) return [];
|
||||
const items: DoctorCertImage[] = [
|
||||
{ label: '头像', url: doc.avatar },
|
||||
{ label: '资格证书', url: doc.qualification },
|
||||
{ label: '执业证书', url: doc.practicing },
|
||||
{ label: '职称证书', url: doc.title },
|
||||
{ label: '身份证正面', url: doc.card_up },
|
||||
{ label: '身份证反面', url: doc.card_down },
|
||||
{ label: '签名', url: doc.sign_image },
|
||||
];
|
||||
return items.filter((item) => !!item.url);
|
||||
}
|
||||
|
||||
export function isDoctorPending(doc: Record<string, any>) {
|
||||
return Number(doc?.status) === 0;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
const OSS_PREFIX = 'https://xiaokang88.oss-cn-hangzhou.aliyuncs.com/';
|
||||
|
||||
export type InputUserLike = {
|
||||
avatar?: string;
|
||||
nick_name?: string;
|
||||
};
|
||||
|
||||
export function normalizeInputUser(
|
||||
row: Record<string, any> | null | undefined,
|
||||
): InputUserLike | null {
|
||||
if (!row) return null;
|
||||
const u = row.input_user ?? row.inputUser;
|
||||
if (!u) return null;
|
||||
if (!row.inputUser) {
|
||||
row.inputUser = u;
|
||||
}
|
||||
return u;
|
||||
}
|
||||
|
||||
export function resolveAvatarUrl(url?: string | null): string {
|
||||
if (!url) return '';
|
||||
const s = String(url).trim();
|
||||
if (!s) return '';
|
||||
if (/^https?:\/\//i.test(s)) return s;
|
||||
if (s.startsWith('//')) return `https:${s}`;
|
||||
return `${OSS_PREFIX}${s.replace(/^\//, '')}`;
|
||||
}
|
||||
|
||||
export function inputUserDisplayName(u: InputUserLike | null | undefined): string {
|
||||
return u?.nick_name?.trim() || '-';
|
||||
}
|
||||
@@ -114,6 +114,14 @@ export async function updateStoreSubscribeStatus(data: { id: number }) {
|
||||
return requestClient.post<any>(`${prefix}update-subscribe-status`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换门店是否可查看毛利率
|
||||
* @param data
|
||||
*/
|
||||
export async function updateStoreSeeRateStatus(data: { id: number }) {
|
||||
return requestClient.post<any>(`${prefix}update-see-rate`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取诊所药品列表(按类型)
|
||||
* @param storeId 诊所ID
|
||||
|
||||
@@ -10,6 +10,10 @@ export function getCommissionList(params: Record<string, any>) {
|
||||
return requestClient.get(`${prefix}commission-list`, { params });
|
||||
}
|
||||
|
||||
export function getCommissionOrderList(params: Record<string, any>) {
|
||||
return requestClient.get(`${prefix}commission-order-list`, { params });
|
||||
}
|
||||
|
||||
export function getSettlementPreview(params: Record<string, any>) {
|
||||
return requestClient.get(`${prefix}settlement-preview`, { params });
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import SalespersonSettlementConfirmModal from '#/components/salesperson/Salesper
|
||||
import {
|
||||
confirmSettlement,
|
||||
getCommissionList,
|
||||
getCommissionOrderList,
|
||||
getSalespersonList,
|
||||
getSettlementDetail,
|
||||
getSettlementList,
|
||||
@@ -42,10 +43,28 @@ const selectedRowKeys = ref<number[]>([]);
|
||||
const settlementList = ref<any[]>([]);
|
||||
const settlementDetail = ref<any>(null);
|
||||
const detailVisible = ref(false);
|
||||
const orderDetailVisible = ref(false);
|
||||
const orderDetailLoading = ref(false);
|
||||
const orderDetailData = ref<any[]>([]);
|
||||
const currentOrder = ref<{ order_id: number; order_no: string } | null>(null);
|
||||
const periodRange = ref<any[]>([]);
|
||||
const settlementConfirmRef = ref<InstanceType<typeof SalespersonSettlementConfirmModal>>();
|
||||
|
||||
const commissionColumns = [
|
||||
const orderCommissionColumns = [
|
||||
{ title: '订单号', dataIndex: 'order_no', width: 160 },
|
||||
{ title: '明细数', dataIndex: 'item_count', width: 80 },
|
||||
{ title: '分成总额', dataIndex: 'commission_amount', width: 100 },
|
||||
{ title: '支付时间', dataIndex: 'order_pay_at_text', width: 170 },
|
||||
{ title: '操作', key: 'action', width: 90 },
|
||||
];
|
||||
|
||||
const commissionDetailColumns = [
|
||||
{ title: '药品信息', dataIndex: 'drug_info', ellipsis: true },
|
||||
{ title: '分成金额', dataIndex: 'commission_amount', width: 100 },
|
||||
{ title: '分成时间', dataIndex: 'order_pay_at_text', width: 170 },
|
||||
];
|
||||
|
||||
const settlementLineColumns = [
|
||||
{ title: '订单号', dataIndex: 'order_no', width: 160 },
|
||||
{ title: '药品信息', dataIndex: 'drug_info', ellipsis: true },
|
||||
{ title: '分成金额', dataIndex: 'commission_amount', width: 100 },
|
||||
@@ -67,19 +86,19 @@ const rowSelection = computed(() =>
|
||||
activeTab.value === 'pending'
|
||||
? {
|
||||
selectedRowKeys: selectedRowKeys.value,
|
||||
onChange: (keys: number[], rows: any[]) => {
|
||||
onChange: (keys: number[]) => {
|
||||
selectedRowKeys.value = keys as number[];
|
||||
selectedOrderIds.value = [...new Set(rows.map((r) => r.order_id))];
|
||||
selectedOrderIds.value = keys as number[];
|
||||
},
|
||||
getCheckboxProps: () => ({ disabled: false }),
|
||||
}
|
||||
: undefined,
|
||||
);
|
||||
|
||||
function open(row: { id: number; name: string }) {
|
||||
function open(row: { id: number; name: string; salespersonId?: number }) {
|
||||
storeId.value = row.id;
|
||||
storeName.value = row.name;
|
||||
salespersonId.value = undefined;
|
||||
salespersonId.value = row.salespersonId;
|
||||
selectedOrderIds.value = [];
|
||||
selectedRowKeys.value = [];
|
||||
visible.value = true;
|
||||
@@ -117,7 +136,7 @@ async function loadCommission() {
|
||||
params.start_at = dayjs(dateRange.value[0]).startOf('day').unix();
|
||||
params.end_at = dayjs(dateRange.value[1]).endOf('day').unix();
|
||||
}
|
||||
const res = await getCommissionList(params);
|
||||
const res = await getCommissionOrderList(params);
|
||||
commissionData.value = res?.items || [];
|
||||
commissionTotal.value = res?.total || 0;
|
||||
} finally {
|
||||
@@ -125,6 +144,24 @@ async function loadCommission() {
|
||||
}
|
||||
}
|
||||
|
||||
async function showOrderDetail(record: { order_id: number; order_no: string }) {
|
||||
currentOrder.value = record;
|
||||
orderDetailVisible.value = true;
|
||||
orderDetailLoading.value = true;
|
||||
try {
|
||||
const res = await getCommissionList({
|
||||
store_id: storeId.value,
|
||||
salesperson_id: salespersonId.value,
|
||||
order_id: record.order_id,
|
||||
page: 1,
|
||||
pageSize: 100,
|
||||
});
|
||||
orderDetailData.value = res?.items || [];
|
||||
} finally {
|
||||
orderDetailLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadSettlements() {
|
||||
if (!storeId.value || !salespersonId.value) return;
|
||||
const res = await getSettlementList({
|
||||
@@ -216,24 +253,36 @@ defineExpose({ open });
|
||||
<Button type="primary" ghost @click="handleSettleByOrders">结算选中订单</Button>
|
||||
</div>
|
||||
<Table
|
||||
:columns="commissionColumns"
|
||||
:columns="orderCommissionColumns"
|
||||
:data-source="commissionData"
|
||||
:loading="loading"
|
||||
:pagination="{ current: page, pageSize, total: commissionTotal, onChange: onPageChange }"
|
||||
:row-key="(r) => r.id"
|
||||
:row-key="(r) => r.order_id"
|
||||
:row-selection="rowSelection"
|
||||
size="small"
|
||||
/>
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'action'">
|
||||
<Button type="link" size="small" @click="showOrderDetail(record)">查看明细</Button>
|
||||
</template>
|
||||
</template>
|
||||
</Table>
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane key="settled" tab="已结算">
|
||||
<Table
|
||||
:columns="commissionColumns"
|
||||
:columns="orderCommissionColumns"
|
||||
:data-source="commissionData"
|
||||
:loading="loading"
|
||||
:pagination="{ current: page, pageSize, total: commissionTotal, onChange: onPageChange }"
|
||||
:row-key="(r) => r.id"
|
||||
:row-key="(r) => r.order_id"
|
||||
size="small"
|
||||
/>
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'action'">
|
||||
<Button type="link" size="small" @click="showOrderDetail(record)">查看明细</Button>
|
||||
</template>
|
||||
</template>
|
||||
</Table>
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane key="history" tab="结算记录">
|
||||
<Table :columns="settlementColumns" :data-source="settlementList" :row-key="(r) => r.id" size="small">
|
||||
@@ -252,6 +301,21 @@ defineExpose({ open });
|
||||
@success="onSettlementSuccess"
|
||||
/>
|
||||
|
||||
<Drawer
|
||||
v-model:open="orderDetailVisible"
|
||||
:title="`订单明细 - ${currentOrder?.order_no || ''}`"
|
||||
width="720"
|
||||
destroy-on-close
|
||||
>
|
||||
<Table
|
||||
:columns="commissionDetailColumns"
|
||||
:data-source="orderDetailData"
|
||||
:loading="orderDetailLoading"
|
||||
:row-key="(r) => r.id"
|
||||
size="small"
|
||||
/>
|
||||
</Drawer>
|
||||
|
||||
<Drawer v-model:open="detailVisible" title="结算单详情" width="720" destroy-on-close>
|
||||
<div v-if="settlementDetail" class="mb-3">
|
||||
<p>单号:{{ settlementDetail.settlement_no }}</p>
|
||||
@@ -272,7 +336,7 @@ defineExpose({ open });
|
||||
</div>
|
||||
</div>
|
||||
<Table
|
||||
:columns="commissionColumns"
|
||||
:columns="settlementLineColumns"
|
||||
:data-source="settlementDetail?.records || []"
|
||||
:row-key="(r) => r.id"
|
||||
size="small"
|
||||
|
||||
@@ -17,6 +17,7 @@ const gridApi = ref();
|
||||
const [Form, formApi] = useVbenForm(modalFormProps);
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
closeOnClickModal: false,
|
||||
fullscreenButton: false,
|
||||
draggable: true,
|
||||
onCancel() {
|
||||
|
||||
@@ -54,6 +54,13 @@ export const gridOptions: VxeGridProps<RowType> = {
|
||||
slots: { default: 'subscribe_price_change' },
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
field: 'see_rate',
|
||||
align: 'left',
|
||||
title: '查看毛利率',
|
||||
slots: { default: 'see_rate' },
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
field: 'qr_code',
|
||||
align: 'left',
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
openQrCodeApi,
|
||||
updateClinicTypeApi,
|
||||
updateStoreShippingFree,
|
||||
updateStoreSeeRateStatus,
|
||||
updateStoreSubscribeStatus,
|
||||
} from './api';
|
||||
import FormModalDemo from './components/modal.vue';
|
||||
@@ -204,6 +205,16 @@ const updateSubscribe = (id: number) => {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 切换是否可查看毛利率
|
||||
*/
|
||||
const updateSeeRate = (id: number) => {
|
||||
updateStoreSeeRateStatus({ id }).then(() => {
|
||||
message.success('修改成功!');
|
||||
gridApi.query();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 批量同步总仓库药品
|
||||
*/
|
||||
@@ -420,6 +431,15 @@ const handleSwitchClinicType = (row: any) => {
|
||||
{{ row.subscribe_price_change === 0 ? '订阅' : '不订阅' }}
|
||||
</Tag>
|
||||
</template>
|
||||
<template #see_rate="{ row }">
|
||||
<Tag
|
||||
:color="Number(row.see_rate) === 1 ? 'success' : 'default'"
|
||||
style="cursor: pointer"
|
||||
@click="updateSeeRate(row.id)"
|
||||
>
|
||||
{{ Number(row.see_rate) === 1 ? '可查看' : '不可查看' }}
|
||||
</Tag>
|
||||
</template>
|
||||
<template #start-time="{ row }">
|
||||
早:<Tag color="success">{{ row.start_time }}</Tag>
|
||||
<br />
|
||||
|
||||
Reference in New Issue
Block a user