提交 1134229d authored 作者: leon's avatar leon

收货人管理 ,经销商id fix

上级 598901dd
...@@ -141,3 +141,14 @@ export type ReceiverPageResult = PageResult<Receiver>; ...@@ -141,3 +141,14 @@ export type ReceiverPageResult = PageResult<Receiver>;
export type ReceiverPageResponse = ApiResponse<ReceiverPageResult>; export type ReceiverPageResponse = ApiResponse<ReceiverPageResult>;
export type ReceiverResponse = ApiResponse<Receiver>; export type ReceiverResponse = ApiResponse<Receiver>;
export interface BatchVerifyParams {
/**
* id数组
*/
idList: Array<number | string>;
/**
* 状态
*/
status: string;
}
...@@ -13,26 +13,24 @@ import { ...@@ -13,26 +13,24 @@ import {
ReceiverPageResponse, ReceiverPageResponse,
ReceiverResponse, ReceiverResponse,
} from '../model/receiver'; } from '../model/receiver';
import { BatchVerifyParams } from '/@/api/model/receiver';
const baseApi = '/v1/system/receiver'; const baseApi = '/v1/system/receiver';
/** /**
* 新增 * 新增
*/ */
export const add = (entity: Receiver) => export const add = (entity: Receiver) => defHttp.post<Receiver>({ url: `${baseApi}/`, data: entity });
defHttp.post<Receiver>({ url: `${baseApi}/`, data: entity });
/** /**
* 更新 * 更新
*/ */
export const update = (entity: Receiver) => export const update = (entity: Receiver) => defHttp.put<Receiver>({ url: `${baseApi}/`, data: entity });
defHttp.put<Receiver>({ url: `${baseApi}/`, data: entity });
/** /**
* 删除 * 删除
*/ */
export const remove = (id: any) => export const remove = (id: any) => defHttp.delete<Number>({ url: `${baseApi}/${id}` });
defHttp.delete<Number>({ url: `${baseApi}/${id}` });
/** /**
* 分页查询 * 分页查询
...@@ -43,20 +41,17 @@ export const search = (params?: ReceiverParams) => ...@@ -43,20 +41,17 @@ export const search = (params?: ReceiverParams) =>
/** /**
* 列表查询 * 列表查询
*/ */
export const all = (params?: ReceiverParams) => export const all = (params?: ReceiverParams) => defHttp.get<ReceiverPageResult>({ url: `${baseApi}/all`, params });
defHttp.get<ReceiverPageResult>({ url: `${baseApi}/all`, params });
/** /**
* 通过主键查询 * 通过主键查询
*/ */
export const getById = (id: any) => export const getById = (id: any) => defHttp.get<Receiver>({ url: `${baseApi}/${id}` });
defHttp.get<Receiver>({ url: `${baseApi}/${id}` });
/** /**
* 单个查询 * 单个查询
*/ */
export const getOne = (params?: ReceiverParams) => export const getOne = (params?: ReceiverParams) => defHttp.get<Receiver>({ url: `${baseApi}/one`, params });
defHttp.get<Receiver>({ url: `${baseApi}/one`, params });
/** /**
* 批量删除 * 批量删除
...@@ -79,7 +74,10 @@ export const batchUpdate = (entityList: Array<Receiver>) => ...@@ -79,7 +74,10 @@ export const batchUpdate = (entityList: Array<Receiver>) =>
/** /**
* 查询数量 * 查询数量
*/ */
export const count = (params?: ReceiverParams) => export const count = (params?: ReceiverParams) => defHttp.get<Number>({ url: `${baseApi}/count`, params });
defHttp.get<Number>({ url: `${baseApi}/count`, params });
/**
* @description 批量审核,
*/
export const batchVerify = (params: BatchVerifyParams) =>
defHttp.post<boolean>({ url: `${baseApi}/batch/verify`, data: params });
...@@ -64,8 +64,8 @@ export const useUserStore = defineStore({ ...@@ -64,8 +64,8 @@ export const useUserStore = defineStore({
/** /**
* @description 经销商id 华润是0 其他不是 * @description 经销商id 华润是0 其他不是
*/ */
getDistributorId(): number | null { getDistributorId(): number {
return this.userInfo?.distributorId || getAuthCache<User>(USER_INFO_KEY)?.distributorId || null; return this.userInfo?.distributorId as number;
}, },
}, },
actions: { actions: {
......
...@@ -11,6 +11,8 @@ import { FormSchema } from '/@/components/Table'; ...@@ -11,6 +11,8 @@ import { FormSchema } from '/@/components/Table';
import { getDistributorId, getHospitalId } from '/@/commonSchemaProperty'; import { getDistributorId, getHospitalId } from '/@/commonSchemaProperty';
import { usePermission } from '/@/hooks/web/usePermission'; import { usePermission } from '/@/hooks/web/usePermission';
import { BatchVerifyParams } from '/@/api/model/doctor'; import { BatchVerifyParams } from '/@/api/model/doctor';
import { useUserStore } from '/@/store/modules/user';
const userStore = useUserStore();
const { hasPermission } = usePermission(); const { hasPermission } = usePermission();
export enum SexEnum { export enum SexEnum {
MALE = '男', MALE = '男',
...@@ -149,7 +151,7 @@ export const schema = { ...@@ -149,7 +151,7 @@ export const schema = {
}, },
colProps, colProps,
component: 'Input', component: 'Input',
rules: [{ required: false, message: '请输入手机号!' }], rules: [{ pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!', trigger: 'blur' }],
}, },
table: {}, table: {},
}, },
...@@ -335,7 +337,13 @@ const descriptionFields = [ ...@@ -335,7 +337,13 @@ const descriptionFields = [
]; ];
export const searchFormSchema: FormSchema[] = schema.properties export const searchFormSchema: FormSchema[] = schema.properties
.filter((item) => queryFields.includes(item.field)) .filter((item) => {
if (item.field === 'distributorId') {
return queryFields.includes(item.field) && userStore.getDistributorId === 0;
} else {
return queryFields.includes(item.field);
}
})
.map( .map(
({ field, label, form: { rules = [], ...formProps } }) => ({ field, label, form: { rules = [], ...formProps } }) =>
({ ({
......
...@@ -16,6 +16,15 @@ ...@@ -16,6 +16,15 @@
> >
<a href="#" class="text-red-500">删除</a> <a href="#" class="text-red-500">删除</a>
</a-popconfirm> </a-popconfirm>
<a-popconfirm
class="ml-4"
title="确定要全部通过审核吗?"
ok-text="是"
cancel-text="否"
@confirm="handleBatchPassed"
>
<a href="#" class="text-green-500">审核通过</a>
</a-popconfirm>
</template> </template>
<template v-else> <template v-else>
<span>未选中任何项目</span> <span>未选中任何项目</span>
...@@ -36,11 +45,47 @@ ...@@ -36,11 +45,47 @@
<template v-if="column.dataIndex === 'action'"> <template v-if="column.dataIndex === 'action'">
<TableAction <TableAction
:actions="[ :actions="[
//待审核 才能 通过
{
label: '通过',
color: 'success',
popConfirm: {
title: '是否确认通过',
confirm: handleVerify.bind(null, record, StatusValEnum.PASSED),
},
ifShow: isShowHandlePassed(record.status),
},
//待审核 才能 拒绝
{
label: '拒绝',
color: 'error',
popConfirm: {
title: '是否确认拒绝',
confirm: handleVerify.bind(null, record, StatusValEnum.REJECT),
},
ifShow: isShowHandleReject(record.status),
},
//已通过才能禁用
{
label: '禁用',
color: 'error',
popConfirm: {
title: '是否确认禁用',
confirm: handleVerify.bind(null, record, StatusValEnum.FORBIDDEN),
},
ifShow: isShowHandleForbidden(record.status),
},
//禁用后不能再编辑
{ {
tooltip: '编辑', tooltip: '编辑',
icon: 'clarity:note-edit-line', icon: 'clarity:note-edit-line',
onClick: handleEdit.bind(null, record), onClick: handleEdit.bind(null, record),
ifShow: hasPermission('AUTH_SYSTEM_RECEIVER:EDIT'), ifShow: isShowHandleEdit(record.status),
},
{
tooltip: '详情',
icon: 'ant-design:eye-outlined',
onClick: handleView.bind(null, record),
}, },
{ {
tooltip: '删除', tooltip: '删除',
...@@ -50,7 +95,7 @@ ...@@ -50,7 +95,7 @@
title: '是否确认删除', title: '是否确认删除',
confirm: handleDelete.bind(null, record), confirm: handleDelete.bind(null, record),
}, },
ifShow: hasPermission('AUTH_SYSTEM_RECEIVER:DELETE'), ifShow: isShowHandleDelete(),
}, },
]" ]"
/> />
...@@ -72,11 +117,20 @@ ...@@ -72,11 +117,20 @@
import componentSetting from '/@/settings/componentSetting'; import componentSetting from '/@/settings/componentSetting';
import ReceiverDrawer from './drawer.vue'; import ReceiverDrawer from './drawer.vue';
import { columns, searchFormSchema } from './schema'; import { columns, searchFormSchema } from './schema';
import {
const { hasPermission } = usePermission(); isShowHandleEdit,
isShowHandlePassed,
isShowHandleForbidden,
isShowHandleReject,
isShowHandleDelete,
getVerifyParams,
StatusValEnum,
} from './schema';
import { BatchVerifyParams } from '/@/api/model/doctor';
import { useUserStore } from '/@/store/modules/user';
const go = useGo(); const go = useGo();
const { formConfig, showTableSetting, bordered, showIndexColumn } = componentSetting.table; const { formConfig, showTableSetting, bordered, showIndexColumn } = componentSetting.table;
const userStore = useUserStore();
const checkedKeys = ref<Array<string | number>>([]); const checkedKeys = ref<Array<string | number>>([]);
const onSelectChange = (selectedRowKeys: (string | number)[]) => { const onSelectChange = (selectedRowKeys: (string | number)[]) => {
checkedKeys.value = selectedRowKeys; checkedKeys.value = selectedRowKeys;
...@@ -104,7 +158,7 @@ ...@@ -104,7 +158,7 @@
canResize: false, canResize: false,
rowKey: (record: any) => record.id, rowKey: (record: any) => record.id,
actionColumn: { actionColumn: {
width: 80, width: 210,
title: '操作', title: '操作',
dataIndex: 'action', dataIndex: 'action',
...@@ -133,9 +187,31 @@ ...@@ -133,9 +187,31 @@
} }
} }
}); });
// 如果是经销商,只能看到自己的数据
if (userStore.getDistributorId !== 0) {
handledParams.distributorId = userStore.getDistributorId;
} else if (userStore.getDistributorId == null) {
handledParams.distributorId = -1;
}
return handledParams; return handledParams;
}; };
const handleVerify = (record: Recordable, status: string) => {
ReceiverApi.batchVerify(getVerifyParams(record, status)).then((_) => {
reload();
});
};
const handleBatchPassed = () => {
const params: BatchVerifyParams = {
idList: checkedKeys.value,
status: StatusValEnum.PASSED,
};
ReceiverApi.batchVerify(params).then((_) => {
reload();
});
};
const handleCreate = () => { const handleCreate = () => {
openDrawer(true, { openDrawer(true, {
isUpdate: false, isUpdate: false,
......
...@@ -8,7 +8,13 @@ ...@@ -8,7 +8,13 @@
import { BasicColumn } from '/@/components/Table'; import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table'; import { FormSchema } from '/@/components/Table';
import { SexEnum, StatusEnumOptions } from '/@/views/system/doctor/schema';
import { getDistributorId } from '/@/commonSchemaProperty';
import { usePermission } from '/@/hooks/web/usePermission';
import { BatchVerifyParams } from '/@/api/model/receiver';
import { useUserStore } from '/@/store/modules/user';
const { hasPermission } = usePermission();
const userStore = useUserStore();
export enum YesNoEnum { export enum YesNoEnum {
YES = '是', YES = '是',
NO = '否', NO = '否',
...@@ -21,6 +27,61 @@ for (const key in YesNoEnum) { ...@@ -21,6 +27,61 @@ for (const key in YesNoEnum) {
}); });
} }
export enum StatusEnum {
PENDING_REVIEW = '待审核',
PASSED = '已通过',
REJECT = '已拒绝',
FORBIDDEN = '禁用',
}
export enum StatusColorEnum {
PENDING_REVIEW = 'processing',
PASSED = 'success',
REJECT = 'error',
FORBIDDEN = 'default',
}
export enum StatusValEnum {
PENDING_REVIEW = 'PENDING_REVIEW',
PASSED = 'PASSED',
REJECT = 'REJECT',
FORBIDDEN = 'FORBIDDEN',
}
export const StatusOptions: any[] = [];
for (const key in StatusEnum) {
StatusOptions.push({
value: key,
label: SexEnum[key],
});
}
export const isShowHandlePassed = (status: string): boolean => {
return hasPermission('AUTH_SYSTEM_RECEIVER:PASSED') && status === 'PENDING_REVIEW';
};
export const isShowHandleReject = (status: string): boolean => {
return hasPermission('AUTH_SYSTEM_RECEIVER:REJECT') && status === 'PENDING_REVIEW';
};
export const isShowHandleForbidden = (status: string): boolean => {
return hasPermission('AUTH_SYSTEM_RECEIVER:FORBIDDEN') && status === 'PASSED';
};
export const isShowHandleEdit = (status: string): boolean => {
return hasPermission('AUTH_SYSTEM_RECEIVER:EDIT') && status !== 'FORBIDDEN';
};
export const isShowHandleDelete = (): boolean => {
return hasPermission('AUTH_SYSTEM_RECEIVER:DELETE');
};
/**
* @description: 返回审核所需参数
* @param record
* @param status
*/
export const getVerifyParams = (record: Recordable, status: string): BatchVerifyParams => {
const params: BatchVerifyParams = {
idList: [record.id],
status,
};
return params;
};
const colProps = { xs: { span: 24 }, sm: { span: 24 }, lg: { span: 8 } }; const colProps = { xs: { span: 24 }, sm: { span: 24 }, lg: { span: 8 } };
const colPropsInDrawer = { span: 24 }; const colPropsInDrawer = { span: 24 };
...@@ -43,21 +104,7 @@ export const schema = { ...@@ -43,21 +104,7 @@ export const schema = {
}, },
table: {}, table: {},
}, },
{ getDistributorId({ colProps }),
field: 'distributorId',
label: '经销商id',
defaultValue: undefined,
form: {
componentProps: {
allowClear: false,
placeholder: '经销商id',
},
colProps,
component: 'InputNumber',
rules: [{ required: true, message: '请输入经销商id!' }],
},
table: {},
},
{ {
field: 'logisticsMode', field: 'logisticsMode',
label: '物流方式', label: '物流方式',
...@@ -74,13 +121,14 @@ export const schema = { ...@@ -74,13 +121,14 @@ export const schema = {
}, },
{ {
field: 'receiveName', field: 'receiveName',
label: '接收人姓名', label: '姓名',
defaultValue: undefined, defaultValue: undefined,
form: { form: {
componentProps: { componentProps: {
allowClear: true, allowClear: true,
placeholder: '接收人姓名', placeholder: '姓名',
}, },
rules: [{ required: true, message: '请输入姓名!' }],
colProps, colProps,
component: 'Input', component: 'Input',
}, },
...@@ -88,15 +136,19 @@ export const schema = { ...@@ -88,15 +136,19 @@ export const schema = {
}, },
{ {
field: 'receivePhone', field: 'receivePhone',
label: '接收人电话', label: '电话',
defaultValue: undefined, defaultValue: undefined,
form: { form: {
componentProps: { componentProps: {
allowClear: true, allowClear: true,
placeholder: '接收人电话', placeholder: '电话',
}, },
colProps, colProps,
component: 'Input', component: 'Input',
rules: [
{ required: true, message: '请输入电话!' },
{ pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!', trigger: 'blur' },
],
}, },
table: {}, table: {},
}, },
...@@ -111,11 +163,12 @@ export const schema = { ...@@ -111,11 +163,12 @@ export const schema = {
}, },
component: 'InputTextArea', component: 'InputTextArea',
colProps: { span: 24 }, colProps: { span: 24 },
required: true,
}, },
table: {}, table: {},
}, },
{ {
field: 'status', field: 'isDefault',
label: '是否默认', label: '是否默认',
defaultValue: 'NO', defaultValue: 'NO',
form: { form: {
...@@ -134,6 +187,45 @@ export const schema = { ...@@ -134,6 +187,45 @@ export const schema = {
}, },
}, },
}, },
{
field: 'status',
label: '状态',
defaultValue: 'PENDING_REVIEW',
form: {
componentProps: {
allowClear: false,
placeholder: '状态',
options: StatusEnumOptions,
},
colProps,
component: 'Select',
rules: [{ required: true, message: '请输入状态!' }],
},
table: {
fixed: 'right',
customRender: ({ text }) => {
const option = StatusEnumOptions.find((item) => item.value === text);
return option ? option.label : text;
},
},
},
{
field: 'attachment',
label: '照片',
defaultValue: undefined,
form: {
componentProps: {
allowClear: true,
placeholder: '照片',
maxNumber: 1,
multiple: false,
},
colProps,
component: 'Upload',
rules: [{ required: true, message: '请上传' }],
},
table: {},
},
{ {
field: 'remark', field: 'remark',
label: '备注', label: '备注',
...@@ -216,29 +308,27 @@ export const schema = { ...@@ -216,29 +308,27 @@ export const schema = {
}; };
const queryFields = [ const queryFields = [
'id', // 'id',
'distributorId', 'distributorId',
'logisticsMode',
'receiveName', 'receiveName',
'receivePhone', 'receivePhone',
'status', 'status',
'remark', 'remark',
'editorId', // 'editorId',
'editorName', 'editorName',
'createTime', 'createTime',
'updateTime', 'updateTime',
]; ];
const editFields = ['distributorId', 'logisticsMode', 'receiveName', 'receivePhone', 'address', 'status', 'remark']; const editFields = ['receiveName', 'receivePhone', 'address', 'remark'];
const tableFields = [ const tableFields = [
'id', 'id',
'distributorId', 'distributorId',
'logisticsMode',
'receiveName', 'receiveName',
'receivePhone', 'receivePhone',
'address', 'address',
'status', 'status',
'remark', 'remark',
'editorId', // 'editorId',
'editorName', 'editorName',
'createTime', 'createTime',
'updateTime', 'updateTime',
...@@ -246,7 +336,6 @@ const tableFields = [ ...@@ -246,7 +336,6 @@ const tableFields = [
const descriptionFields = [ const descriptionFields = [
'id', 'id',
'distributorId', 'distributorId',
'logisticsMode',
'receiveName', 'receiveName',
'receivePhone', 'receivePhone',
'address', 'address',
...@@ -259,7 +348,13 @@ const descriptionFields = [ ...@@ -259,7 +348,13 @@ const descriptionFields = [
]; ];
export const searchFormSchema: FormSchema[] = schema.properties export const searchFormSchema: FormSchema[] = schema.properties
.filter((item) => queryFields.includes(item.field)) .filter((item) => {
if (item.field === 'distributorId') {
return queryFields.includes(item.field) && userStore.getDistributorId === 0;
} else {
return queryFields.includes(item.field);
}
})
.map( .map(
({ field, label, form: { rules = [], ...formProps } }) => ({ field, label, form: { rules = [], ...formProps } }) =>
({ ({
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论