feat:页面调整
This commit is contained in:
parent
0b84a35b4e
commit
d4fc01f42c
@ -133,6 +133,14 @@ export async function addCorpDisease({ disease, oldDisease }) {
|
||||
return res;
|
||||
}
|
||||
|
||||
export async function getCorpDiseaseList() {
|
||||
const res = await useCorp({
|
||||
type: "getCorpDiseaseList",
|
||||
corpId: sessionStorage.getItem("corpId"),
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
export async function getTeamByMainLeaderUserId(params) {
|
||||
const res = await useCorp({
|
||||
type: "getTeamByMainLeaderUserId",
|
||||
|
||||
@ -181,19 +181,19 @@ const diagnosisText = computed(() => diagnosisList.value
|
||||
|
||||
async function loadDiagnoses() {
|
||||
const requestId = ++diagnosisRequestId;
|
||||
const ids = Array.isArray(props.data.applicableDiagnosisIds)
|
||||
? props.data.applicableDiagnosisIds.map(id => String(id))
|
||||
const codes = Array.isArray(props.data.applicableDiagnosisCodes)
|
||||
? props.data.applicableDiagnosisCodes.map(code => String(code))
|
||||
: [];
|
||||
diagnosisList.value = [];
|
||||
if (!ids.length) return;
|
||||
if (!codes.length) return;
|
||||
diagnosisLoading.value = true;
|
||||
const res = await getHlwDiagnosisList({ ids, page: 1, pageSize: Math.max(30, ids.length) });
|
||||
const res = await getHlwDiagnosisList({ codes, page: 1, pageSize: Math.max(30, codes.length) });
|
||||
if (requestId !== diagnosisRequestId) return;
|
||||
diagnosisLoading.value = false;
|
||||
if (res.success) {
|
||||
const list = res.data && Array.isArray(res.data.data) ? res.data.data : [];
|
||||
const diagnosisMap = new Map(list.map(item => [String(item._id), item]));
|
||||
diagnosisList.value = ids.map(id => diagnosisMap.get(id)).filter(Boolean);
|
||||
const diagnosisMap = new Map(list.map(item => [String(item.code), item]));
|
||||
diagnosisList.value = codes.map(code => diagnosisMap.get(code)).filter(Boolean);
|
||||
} else {
|
||||
ElMessage.error(res.message || '适应诊断加载失败');
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="适应诊断" prop="applicableDiagnosisIds">
|
||||
<el-form-item label="适应诊断" prop="applicableDiagnosisCodes">
|
||||
<div class="w-full">
|
||||
<el-popover v-model:visible="diagnosisPopoverVisible" placement="bottom-start" trigger="click"
|
||||
:width="600">
|
||||
@ -55,17 +55,17 @@
|
||||
</template>
|
||||
<div v-loading="diagnosisLoading" class="diagnosis-dropdown">
|
||||
<div v-for="item in diagnosisOptions" :key="item._id" class="diagnosis-option"
|
||||
:class="{ 'diagnosis-option--selected': isDiagnosisSelected(item._id) }"
|
||||
:class="{ 'diagnosis-option--selected': isDiagnosisSelected(item.code) }"
|
||||
@click="toggleDiagnosis(item)">
|
||||
<span class="diagnosis-option-label">{{ diagnosisLabel(item) }}</span>
|
||||
<span v-if="isDiagnosisSelected(item._id)" class="diagnosis-option-check">√</span>
|
||||
<span v-if="isDiagnosisSelected(item.code)" class="diagnosis-option-check">√</span>
|
||||
</div>
|
||||
<el-empty v-if="!diagnosisLoading && !diagnosisOptions.length" :image-size="60"
|
||||
description="暂无诊断" />
|
||||
</div>
|
||||
</el-popover>
|
||||
<div v-if="selectedDiagnosisOptions.length" class="selected-diagnoses">
|
||||
<el-tag v-for="item in selectedDiagnosisOptions" :key="item._id" closable
|
||||
<el-tag v-for="item in selectedDiagnosisOptions" :key="item.code" closable
|
||||
@close="toggleDiagnosis(item)">
|
||||
{{ diagnosisLabel(item) }}
|
||||
</el-tag>
|
||||
@ -225,24 +225,24 @@ function diagnosisLabel(item) {
|
||||
}
|
||||
|
||||
const selectedDiagnosisOptions = computed(() => {
|
||||
const optionMap = new Map(diagnosisOptions.value.map(item => [String(item._id), item]));
|
||||
const defaultOptionMap = new Map(diagnosisDefaultOptions.value.map(item => [String(item._id), item]));
|
||||
return (form.value.applicableDiagnosisIds || [])
|
||||
.map(id => optionMap.get(String(id)) || defaultOptionMap.get(String(id)))
|
||||
const optionMap = new Map(diagnosisOptions.value.map(item => [String(item.code), item]));
|
||||
const defaultOptionMap = new Map(diagnosisDefaultOptions.value.map(item => [String(item.code), item]));
|
||||
return (form.value.applicableDiagnosisCodes || [])
|
||||
.map(code => optionMap.get(String(code)) || defaultOptionMap.get(String(code)))
|
||||
.filter(Boolean);
|
||||
})
|
||||
|
||||
function isDiagnosisSelected(id) {
|
||||
return (form.value.applicableDiagnosisIds || []).some(item => String(item) === String(id));
|
||||
function isDiagnosisSelected(code) {
|
||||
return (form.value.applicableDiagnosisCodes || []).some(item => String(item) === String(code));
|
||||
}
|
||||
|
||||
function toggleDiagnosis(item) {
|
||||
const id = String(item._id);
|
||||
const selectedIds = (form.value.applicableDiagnosisIds || []).map(itemId => String(itemId));
|
||||
const nextIds = selectedIds.includes(id)
|
||||
? selectedIds.filter(itemId => itemId !== id)
|
||||
: [...selectedIds, id];
|
||||
changeValue(nextIds, 'applicableDiagnosisIds');
|
||||
const code = String(item.code);
|
||||
const selectedCodes = (form.value.applicableDiagnosisCodes || []).map(itemCode => String(itemCode));
|
||||
const nextCodes = selectedCodes.includes(code)
|
||||
? selectedCodes.filter(itemCode => itemCode !== code)
|
||||
: [...selectedCodes, code];
|
||||
changeValue(nextCodes, 'applicableDiagnosisCodes');
|
||||
}
|
||||
|
||||
function mergeDiagnosisOptions(items = []) {
|
||||
@ -252,8 +252,8 @@ function mergeDiagnosisOptions(items = []) {
|
||||
}
|
||||
|
||||
function replaceDiagnosisOptions(items = []) {
|
||||
const selectedIds = new Set((form.value.applicableDiagnosisIds || []).map(id => String(id)));
|
||||
const selectedOptions = diagnosisOptions.value.filter(item => selectedIds.has(String(item._id)));
|
||||
const selectedCodes = new Set((form.value.applicableDiagnosisCodes || []).map(code => String(code)));
|
||||
const selectedOptions = diagnosisOptions.value.filter(item => selectedCodes.has(String(item.code)));
|
||||
const optionMap = new Map(selectedOptions.map(item => [String(item._id), item]));
|
||||
items.forEach(item => optionMap.set(String(item._id), item));
|
||||
diagnosisOptions.value = [...optionMap.values()];
|
||||
@ -296,14 +296,14 @@ function searchDiagnoses(keyword = '') {
|
||||
|
||||
async function initializeDiagnoses() {
|
||||
diagnosisOptions.value = [];
|
||||
const selectedIds = Array.isArray(props.data.applicableDiagnosisIds)
|
||||
? props.data.applicableDiagnosisIds.map(id => String(id))
|
||||
const selectedCodes = Array.isArray(props.data.applicableDiagnosisCodes)
|
||||
? props.data.applicableDiagnosisCodes.map(code => String(code))
|
||||
: [];
|
||||
const requestId = ++diagnosisRequestId;
|
||||
diagnosisLoading.value = true;
|
||||
const requests = [fetchDiagnoses({}, requestId)];
|
||||
if (selectedIds.length) {
|
||||
requests.push(fetchDiagnoses({ ids: selectedIds, pageSize: Math.max(30, selectedIds.length) }, requestId));
|
||||
if (selectedCodes.length) {
|
||||
requests.push(fetchDiagnoses({ codes: selectedCodes, pageSize: Math.max(30, selectedCodes.length) }, requestId));
|
||||
}
|
||||
await Promise.all(requests);
|
||||
diagnosisDefaultOptions.value = [...diagnosisOptions.value];
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
</div>
|
||||
</layout-item>
|
||||
<layout-main :scroll="false">
|
||||
<el-table stripe height="100%" :data="list" :header-cell-style="{ background: '#ecf4ff' }">
|
||||
<el-table v-loading="listLoading" stripe height="100%" :data="list" :header-cell-style="{ background: '#ecf4ff' }">
|
||||
<el-table-column property="index" label="序号" />
|
||||
<el-table-column property="name" label="诊断名称"></el-table-column>
|
||||
<el-table-column fixed="right" class-name="el-table-fixed-column--shadow" label="操作" width="120">
|
||||
@ -22,10 +22,6 @@
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</layout-main>
|
||||
<layout-item>
|
||||
<pagination :totalRow="total" :pageSize="pageSize" :currentPage="currentPage" @handle-size-change="onSizeChange"
|
||||
@handle-current-change="onCurrentChange" />
|
||||
</layout-item>
|
||||
</my-layout>
|
||||
<el-dialog :title="oldName ? '编辑诊断' : '新增诊断'" v-model="visible" width="500">
|
||||
<div p-15>
|
||||
@ -44,54 +40,36 @@
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup>
|
||||
import { computed, ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
import { watchDebounced } from "@vueuse/core";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { debounce } from "@/utils/common";
|
||||
import { memberStore } from "@/store/member";
|
||||
import MyLayout, { LayoutMain, LayoutItem } from "@/components/layout";
|
||||
import pagination from "@/components/pagination/pagination.vue";
|
||||
import { ElMessageBox } from "element-plus";
|
||||
import { updateCorpInfo, addCorpDisease } from "@/api/corp";
|
||||
import { updateCorpInfo, addCorpDisease, getCorpDiseaseList } from "@/api/corp";
|
||||
import { updateDiagnosisCategory } from '@/api/hlw';
|
||||
import { getDisease } from "@/api/knowledgeBase";
|
||||
|
||||
const { corpInfo } = memberStore();
|
||||
const corpDisease = ref(corpInfo.diseases || []);
|
||||
const diseases = ref(corpInfo.diseases || []);
|
||||
const diseases = ref([]);
|
||||
const searchName = ref("");
|
||||
const appliedSearchName = ref("");
|
||||
const diseaseList = ref([]);
|
||||
const pageSize = ref(10);
|
||||
const currentPage = ref(1);
|
||||
const visible = ref(false);
|
||||
const searchDiseases = ref("");
|
||||
const listLoading = ref(false);
|
||||
const list = computed(() => {
|
||||
let arr = diseases.value.map((item, index) => {
|
||||
const keyword = appliedSearchName.value.toLowerCase();
|
||||
return diseases.value
|
||||
.filter(item => !keyword || item.toLowerCase().includes(keyword))
|
||||
.map((item, index) => {
|
||||
return {
|
||||
name: item,
|
||||
index: index + 1,
|
||||
};
|
||||
});
|
||||
return arr.slice((currentPage.value - 1) * pageSize.value, currentPage.value * pageSize.value);
|
||||
});
|
||||
const total = computed(() => {
|
||||
return diseases.value.length;
|
||||
});
|
||||
function onSizeChange(e) {
|
||||
currentPage.value = 1;
|
||||
pageSize.value = e;
|
||||
}
|
||||
function onCurrentChange(e) {
|
||||
currentPage.value = e;
|
||||
}
|
||||
function search() {
|
||||
if (!searchName.value) {
|
||||
return;
|
||||
}
|
||||
currentPage.value = 1;
|
||||
let pattern = new RegExp(searchName.value, "i");
|
||||
diseases.value = corpDisease.value.filter((item) => pattern.test(item));
|
||||
async function search() {
|
||||
appliedSearchName.value = searchName.value.trim();
|
||||
await getList();
|
||||
}
|
||||
|
||||
function add() {
|
||||
@ -99,9 +77,10 @@ function add() {
|
||||
oldName.value = "";
|
||||
visible.value = true;
|
||||
}
|
||||
function inputChange(e) {
|
||||
async function inputChange(e) {
|
||||
if (!e) {
|
||||
diseases.value = corpInfo.diseases;
|
||||
appliedSearchName.value = "";
|
||||
await getList();
|
||||
}
|
||||
}
|
||||
const oldName = ref("");
|
||||
@ -112,19 +91,17 @@ function edit({ name }) {
|
||||
}
|
||||
async function remove({ name }) {
|
||||
await ElMessageBox.confirm("是否删除常用诊断?", { type: "warning" })
|
||||
let index = diseases.value.findIndex((i) => i === name && name);
|
||||
if (index >= 0) {
|
||||
await asyncCategory(name, '');
|
||||
await updateCorp();
|
||||
diseases.value.splice(index, 1);
|
||||
visible.value = false;
|
||||
ElMessage.success("删除成功!");
|
||||
if (!diseases.value.includes(name)) return;
|
||||
const categoryUpdated = await asyncCategory(name, '');
|
||||
if (!categoryUpdated) return;
|
||||
const res = await updateCorpInfo({ diseases: diseases.value.filter(item => item !== name) });
|
||||
if (!res.success) {
|
||||
ElMessage.error(res.message || "删除失败");
|
||||
return;
|
||||
}
|
||||
}
|
||||
// 更新corp表, 更新常用诊断
|
||||
async function updateCorp() {
|
||||
const res = await updateCorpInfo({ diseases: diseases.value });
|
||||
|
||||
visible.value = false;
|
||||
await getList();
|
||||
ElMessage.success("删除成功!");
|
||||
}
|
||||
|
||||
function onClose() {
|
||||
@ -133,7 +110,7 @@ function onClose() {
|
||||
|
||||
async function saveDiagnosis() {
|
||||
const name = searchDiseases.value.trim();
|
||||
if (diseases.value.indexOf(name) !== -1) {
|
||||
if (diseases.value.some(item => item === name && item !== oldName.value)) {
|
||||
ElMessage.error("该病种已添加!");
|
||||
return;
|
||||
}
|
||||
@ -141,15 +118,38 @@ async function saveDiagnosis() {
|
||||
ElMessage.error("请填写诊断!");
|
||||
return;
|
||||
}
|
||||
await addCorpDisease({ disease: name, oldDisease: oldName.value });
|
||||
await asyncCategory(oldName.value, name);
|
||||
if (oldName.value) {
|
||||
const index = diseases.value.findIndex((i) => i == oldName.value);
|
||||
diseases.value.splice(index, 1, name);
|
||||
} else {
|
||||
diseases.value.unshift(name);
|
||||
const res = await addCorpDisease({ disease: name, oldDisease: oldName.value });
|
||||
if (!res.success) {
|
||||
ElMessage.error(res.message || "保存失败");
|
||||
return;
|
||||
}
|
||||
const categoryUpdated = await asyncCategory(oldName.value, name);
|
||||
if (!categoryUpdated) {
|
||||
await getList();
|
||||
return;
|
||||
}
|
||||
visible.value = false;
|
||||
await getList();
|
||||
ElMessage.success(res.message || "保存成功");
|
||||
}
|
||||
|
||||
async function getList() {
|
||||
listLoading.value = true;
|
||||
try {
|
||||
const res = await getCorpDiseaseList();
|
||||
if (res.success) {
|
||||
const data = res.data && Array.isArray(res.data.data) ? res.data.data : [];
|
||||
diseases.value = data.filter(item => typeof item === "string");
|
||||
} else {
|
||||
diseases.value = [];
|
||||
ElMessage.error(res.message || "常用诊断加载失败");
|
||||
}
|
||||
} catch (error) {
|
||||
diseases.value = [];
|
||||
ElMessage.error(error.message || "常用诊断加载失败");
|
||||
} finally {
|
||||
listLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
const loading = ref(false);
|
||||
@ -175,7 +175,7 @@ async function getDieaseList(diseaseName) {
|
||||
}
|
||||
|
||||
async function asyncCategory(oldCategory, newCategory) {
|
||||
if (!oldCategory) return
|
||||
if (!oldCategory) return true
|
||||
const { success, message } = await updateDiagnosisCategory({ oldCategory, newCategory })
|
||||
if (!success) {
|
||||
ElMessage.error(message);
|
||||
@ -184,6 +184,8 @@ async function asyncCategory(oldCategory, newCategory) {
|
||||
return true
|
||||
}
|
||||
|
||||
onMounted(getList);
|
||||
|
||||
watchDebounced(
|
||||
searchText,
|
||||
async () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user