|
|
@@ -277,6 +277,7 @@ export function updateReviewCostLimitMethod(dictValue: string) {
|
|
|
}
|
|
|
|
|
|
const COMMENT_CATEGORY_BASE = '/manager/tcmp-pc/commentCategory';
|
|
|
+const COMMENT_ITEMS_BASE = '/manager/tcmp-pc/commentItems';
|
|
|
|
|
|
function toCommentCategoryRecordId(id?: unknown): string {
|
|
|
if (id === undefined || id === null) return '';
|
|
|
@@ -297,7 +298,7 @@ function normalizeCommentList(data: unknown): TransformData[] {
|
|
|
|
|
|
function fromCommentIndicator(
|
|
|
data: TransformData,
|
|
|
- categoryId: string,
|
|
|
+ categoryId = '',
|
|
|
categoryName = '',
|
|
|
): PrescriptionReviewModel.ReviewIndicator {
|
|
|
const id = toCommentCategoryRecordId(data?.id);
|
|
|
@@ -305,11 +306,15 @@ function fromCommentIndicator(
|
|
|
const statusValue = data?.status;
|
|
|
return {
|
|
|
id,
|
|
|
- categoryId,
|
|
|
- categoryName,
|
|
|
- name: String(data?.classifyName ?? data?.commentName ?? data?.name ?? ''),
|
|
|
+ categoryId: toCommentCategoryRecordId(data?.categoryId ?? categoryId),
|
|
|
+ categoryName: String(data?.categoryName ?? categoryName),
|
|
|
+ name: String(
|
|
|
+ data?.itemName ?? data?.classifyName ?? data?.commentName ?? data?.name ?? '',
|
|
|
+ ),
|
|
|
source: isSystem === '0' ? 'system' : 'custom',
|
|
|
- associatedChineseMedicine: String(data?.associatedChineseMedicine ?? '0') === '1',
|
|
|
+ associatedChineseMedicine:
|
|
|
+ String(data?.correlationMedicine ?? data?.associatedChineseMedicine ?? '0') ===
|
|
|
+ '1',
|
|
|
remark: data?.remark ?? undefined,
|
|
|
status:
|
|
|
statusValue === undefined || statusValue === null
|
|
|
@@ -603,6 +608,29 @@ function toCommentCategoryUpdatePayload(
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+function toCommentIndicatorPayload(
|
|
|
+ data: Pick<
|
|
|
+ PrescriptionReviewModel.ReviewIndicator,
|
|
|
+ 'categoryId' | 'name' | 'associatedChineseMedicine' | 'remark' | 'status'
|
|
|
+ > & {
|
|
|
+ source?: PrescriptionReviewModel.ReviewIndicatorSource;
|
|
|
+ sortNo?: number;
|
|
|
+ },
|
|
|
+ id?: string,
|
|
|
+): TransformData {
|
|
|
+ return {
|
|
|
+ ...(id ? { id: toCommentCategoryRecordId(id) } : {}),
|
|
|
+ categoryId: toCommentCategoryRecordId(data.categoryId),
|
|
|
+ itemName: data.name.trim(),
|
|
|
+ isSystem: (data.source ?? 'custom') === 'system' ? '0' : '1',
|
|
|
+ correlationMedicine: data.associatedChineseMedicine ? '1' : '0',
|
|
|
+ sortNo: data.sortNo ?? 0,
|
|
|
+ status: String(data.status ?? 0),
|
|
|
+ del: '0',
|
|
|
+ remark: String(data.remark ?? ''),
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
function syncIndicatorCategoryName(
|
|
|
indicator: PrescriptionReviewModel.ReviewIndicator,
|
|
|
) {
|
|
|
@@ -778,55 +806,76 @@ export function sortReviewIndicatorsMethod(
|
|
|
return Promise.resolve(sorted);
|
|
|
}
|
|
|
|
|
|
-/** 点评指标列表(当前为本地 mock,后期对接后端分页接口) */
|
|
|
+/** 点评指标分页列表 */
|
|
|
export function listReviewIndicatorsMethod(
|
|
|
page = 1,
|
|
|
size = 10,
|
|
|
query?: Partial<
|
|
|
- PrescriptionReviewModel.ReviewIndicator & { categoryId?: string }
|
|
|
+ PrescriptionReviewModel.ReviewIndicator & { categoryId?: string; name?: string }
|
|
|
>,
|
|
|
): Promise<TransformList<PrescriptionReviewModel.ReviewIndicator>> {
|
|
|
- const filtered = filterIndicators(MOCK_INDICATORS, query);
|
|
|
- const start = (page - 1) * size;
|
|
|
- const items = filtered.slice(start, start + size);
|
|
|
- return Promise.resolve({
|
|
|
- items,
|
|
|
- total: filtered.length,
|
|
|
- data: { page, size, total: filtered.length },
|
|
|
+ const params: TransformData = {
|
|
|
+ pageNum: page,
|
|
|
+ pageSize: size,
|
|
|
+ };
|
|
|
+ if (query?.categoryId) {
|
|
|
+ params.categoryId = toCommentCategoryRecordId(query.categoryId);
|
|
|
+ }
|
|
|
+ if (query?.name?.trim()) {
|
|
|
+ params.itemName = query.name.trim();
|
|
|
+ }
|
|
|
+ return http.get<
|
|
|
+ TransformList<PrescriptionReviewModel.ReviewIndicator>,
|
|
|
+ TransformList
|
|
|
+ >(`${COMMENT_ITEMS_BASE}/pageList`, {
|
|
|
+ params,
|
|
|
+ cacheFor: 0,
|
|
|
+ transform({ items, ...data }) {
|
|
|
+ const rows = items ?? [];
|
|
|
+ return {
|
|
|
+ ...data,
|
|
|
+ items: rows.map((item) => fromCommentIndicator(item)),
|
|
|
+ };
|
|
|
+ },
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-/** 新增点评指标(当前为本地 mock) */
|
|
|
-export function createReviewIndicatorMethod(
|
|
|
+/** 新增点评指标 */
|
|
|
+export async function createReviewIndicatorMethod(
|
|
|
data: Pick<
|
|
|
PrescriptionReviewModel.ReviewIndicator,
|
|
|
'categoryId' | 'name' | 'associatedChineseMedicine' | 'remark' | 'status'
|
|
|
>,
|
|
|
) {
|
|
|
- const category = MOCK_INDICATOR_CATEGORIES.find(
|
|
|
- (item) => item.id === data.categoryId,
|
|
|
- );
|
|
|
- if (!category) {
|
|
|
- return Promise.reject(new Error('点评项分类不存在'));
|
|
|
+ const trimmed = data.name?.trim();
|
|
|
+ if (!trimmed) {
|
|
|
+ throw new Error('点评项名称不能为空');
|
|
|
+ }
|
|
|
+ if (!data.categoryId) {
|
|
|
+ throw new Error('请选择点评项分类');
|
|
|
}
|
|
|
- const indicator: PrescriptionReviewModel.ReviewIndicator = {
|
|
|
- id: `ind-${Date.now()}`,
|
|
|
+ const payload = toCommentIndicatorPayload({
|
|
|
categoryId: data.categoryId,
|
|
|
- categoryName: category.name,
|
|
|
- name: data.name.trim(),
|
|
|
- source: 'custom',
|
|
|
+ name: trimmed,
|
|
|
associatedChineseMedicine: data.associatedChineseMedicine,
|
|
|
remark: data.remark,
|
|
|
status: data.status ?? 0,
|
|
|
- createUser: '陆长林',
|
|
|
- createTime: new Date().toISOString().slice(0, 19).replace('T', ' '),
|
|
|
- };
|
|
|
- MOCK_INDICATORS.push(indicator);
|
|
|
- return Promise.resolve(indicator);
|
|
|
+ source: 'custom',
|
|
|
+ });
|
|
|
+ const result = await http.post<TransformData, TransformData>(
|
|
|
+ `${COMMENT_ITEMS_BASE}/add`,
|
|
|
+ payload,
|
|
|
+ { cacheFor: 0 },
|
|
|
+ );
|
|
|
+ return fromCommentIndicator({
|
|
|
+ ...payload,
|
|
|
+ ...(result ?? {}),
|
|
|
+ itemName: trimmed,
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
-/** 编辑点评指标(当前为本地 mock,系统内置仅可改部分字段) */
|
|
|
-export function updateReviewIndicatorMethod(
|
|
|
+/** 编辑点评指标 */
|
|
|
+export async function updateReviewIndicatorMethod(
|
|
|
indicatorId: string,
|
|
|
data: Partial<
|
|
|
Pick<
|
|
|
@@ -836,54 +885,68 @@ export function updateReviewIndicatorMethod(
|
|
|
| 'associatedChineseMedicine'
|
|
|
| 'remark'
|
|
|
| 'status'
|
|
|
+ | 'source'
|
|
|
>
|
|
|
- >,
|
|
|
+ > & { sortNo?: number },
|
|
|
) {
|
|
|
- const indicator = MOCK_INDICATORS.find((item) => item.id === indicatorId);
|
|
|
- if (!indicator) {
|
|
|
- return Promise.reject(new Error('点评项不存在'));
|
|
|
+ if (!indicatorId) {
|
|
|
+ throw new Error('点评项不存在');
|
|
|
+ }
|
|
|
+ const trimmed = data.name?.trim();
|
|
|
+ if (!trimmed) {
|
|
|
+ throw new Error('点评项名称不能为空');
|
|
|
}
|
|
|
- if (data.categoryId) {
|
|
|
- indicator.categoryId = data.categoryId;
|
|
|
- syncIndicatorCategoryName(indicator);
|
|
|
+ if (!data.categoryId) {
|
|
|
+ throw new Error('请选择点评项分类');
|
|
|
}
|
|
|
- if (data.name !== undefined) indicator.name = data.name.trim();
|
|
|
- if (data.associatedChineseMedicine !== undefined) {
|
|
|
- indicator.associatedChineseMedicine = data.associatedChineseMedicine;
|
|
|
+ if (data.associatedChineseMedicine === undefined) {
|
|
|
+ throw new Error('请选择是否关联中药');
|
|
|
}
|
|
|
- if (data.remark !== undefined) indicator.remark = data.remark;
|
|
|
- if (data.status !== undefined) indicator.status = data.status;
|
|
|
- return Promise.resolve(indicator);
|
|
|
+ const payload = toCommentIndicatorPayload(
|
|
|
+ {
|
|
|
+ categoryId: data.categoryId,
|
|
|
+ name: trimmed,
|
|
|
+ associatedChineseMedicine: data.associatedChineseMedicine,
|
|
|
+ remark: data.remark,
|
|
|
+ status: data.status ?? 0,
|
|
|
+ source: data.source ?? 'custom',
|
|
|
+ sortNo: data.sortNo,
|
|
|
+ },
|
|
|
+ indicatorId,
|
|
|
+ );
|
|
|
+ const result = await http.post<TransformData, TransformData>(
|
|
|
+ `${COMMENT_ITEMS_BASE}/update`,
|
|
|
+ payload,
|
|
|
+ { cacheFor: 0 },
|
|
|
+ );
|
|
|
+ return fromCommentIndicator({
|
|
|
+ ...payload,
|
|
|
+ ...(result ?? {}),
|
|
|
+ itemName: trimmed,
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
-/** 删除点评指标(当前为本地 mock,系统内置不可删) */
|
|
|
+/** 删除点评指标 */
|
|
|
export function deleteReviewIndicatorMethod(indicatorId: string) {
|
|
|
- const index = MOCK_INDICATORS.findIndex((item) => item.id === indicatorId);
|
|
|
- if (index === -1) {
|
|
|
- return Promise.reject(new Error('点评项不存在'));
|
|
|
- }
|
|
|
- const indicator = MOCK_INDICATORS[index];
|
|
|
- if (!indicator) {
|
|
|
- return Promise.reject(new Error('点评项不存在'));
|
|
|
- }
|
|
|
- if (indicator.source === 'system') {
|
|
|
- return Promise.reject(new Error('系统内置点评项不可删除'));
|
|
|
- }
|
|
|
- MOCK_INDICATORS.splice(index, 1);
|
|
|
- return Promise.resolve(true);
|
|
|
+ return http.post<void, unknown>(`${COMMENT_ITEMS_BASE}/delete`, void 0, {
|
|
|
+ params: { id: toCommentCategoryRecordId(indicatorId) },
|
|
|
+ cacheFor: 0,
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
-/** 点评指标状态更改(当前为本地 mock,后期对接后端接口) */
|
|
|
+/** 点评指标状态更改 */
|
|
|
export function updateReviewIndicatorStatusMethod(
|
|
|
indicatorId: string,
|
|
|
{ status }: { status: 0 | 1 },
|
|
|
) {
|
|
|
- const indicator = MOCK_INDICATORS.find((item) => item.id === indicatorId);
|
|
|
- if (!indicator) {
|
|
|
- return Promise.reject(new Error('点评项不存在'));
|
|
|
- }
|
|
|
- indicator.status = status;
|
|
|
- return Promise.resolve(true);
|
|
|
+ return http.post<void, unknown>(
|
|
|
+ `${COMMENT_ITEMS_BASE}/updateStatus`,
|
|
|
+ {
|
|
|
+ id: toCommentCategoryRecordId(indicatorId),
|
|
|
+ status: String(status),
|
|
|
+ },
|
|
|
+ { cacheFor: 0 },
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
const REVIEW_TASK_STATUS_LABEL: Record<
|