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