<template>
|
<div class="generateConfig-management">
|
<div class="main-content">
|
<el-row :gutter="20">
|
<el-col :span="24" :xs="24">
|
<!-- 查询条件 -->
|
<el-form
|
:model="queryParams"
|
ref="queryForm"
|
size="small"
|
:inline="true"
|
v-show="showSearch"
|
label-width="88px"
|
>
|
<el-form-item label="部门类型" prop="deptType">
|
<el-select
|
v-model="queryParams.deptType"
|
placeholder="请选择部门类型"
|
clearable
|
style="width: 160px"
|
>
|
<el-option
|
v-for="item in DEPT_TYPE_OPTIONS"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
|
<el-form-item label="部门分类" prop="deptCategory">
|
<el-select
|
v-model="queryParams.deptCategory"
|
placeholder="请选择部门分类"
|
clearable
|
style="width: 160px"
|
>
|
<el-option
|
v-for="item in DEPT_CATEGORY_OPTIONS"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
|
<el-form-item label="档案类型" prop="archiveType">
|
<el-select
|
v-model="queryParams.archiveType"
|
placeholder="请选择档案类型"
|
clearable
|
style="width: 160px"
|
>
|
<el-option
|
v-for="item in queryArchiveTypeOptions"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
|
<el-form-item label="创建时间">
|
<el-date-picker
|
v-model="dateRange"
|
type="daterange"
|
value-format="yyyy-MM-dd"
|
range-separator="至"
|
start-placeholder="开始日期"
|
end-placeholder="结束日期"
|
style="width: 240px"
|
/>
|
</el-form-item>
|
|
<el-form-item>
|
<el-button
|
type="primary"
|
icon="el-icon-search"
|
size="medium"
|
@click="handleQuery"
|
>搜索</el-button
|
>
|
<el-button
|
icon="el-icon-refresh"
|
size="medium"
|
@click="resetQuery"
|
>重置</el-button
|
>
|
</el-form-item>
|
</el-form>
|
|
<el-divider></el-divider>
|
|
<el-row :gutter="10" class="mb8">
|
<el-col :span="1.5">
|
<el-button
|
type="primary"
|
plain
|
icon="el-icon-plus"
|
size="medium"
|
@click="handleAdd"
|
>新增</el-button
|
>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button
|
type="danger"
|
plain
|
icon="el-icon-delete"
|
size="medium"
|
:disabled="multiple"
|
@click="handleDelete"
|
>删除</el-button
|
>
|
</el-col>
|
</el-row>
|
|
<el-table
|
v-loading="loading"
|
:data="configList"
|
:border="true"
|
@selection-change="handleSelectionChange"
|
>
|
<el-table-column type="selection" width="50" align="center" />
|
|
<el-table-column label="部门类型" align="center" width="100">
|
<template slot-scope="scope">
|
<el-tag
|
:type="scope.row.deptType === '1' ? 'primary' : 'warning'"
|
size="small"
|
>
|
{{ deptTypeLabel(scope.row.deptType) }}
|
</el-tag>
|
</template>
|
</el-table-column>
|
|
<el-table-column label="部门分类" align="center" width="100">
|
<template slot-scope="scope">
|
<el-tag size="small">
|
{{ deptCategoryLabel(scope.row.deptCategory) }}
|
</el-tag>
|
</template>
|
</el-table-column>
|
|
<el-table-column
|
label="档案类型"
|
align="center"
|
width="140"
|
:show-overflow-tooltip="true"
|
>
|
<template slot-scope="scope">
|
{{ archiveTypeLabel(scope.row) }}
|
</template>
|
</el-table-column>
|
|
<el-table-column
|
label="科室/病区"
|
align="center"
|
min-width="180"
|
:show-overflow-tooltip="true"
|
>
|
<template slot-scope="scope">
|
<span v-if="formatDeptCodes(scope.row)">
|
{{ formatDeptCodes(scope.row) }}
|
</span>
|
<span v-else style="color: #c0c4cc">—</span>
|
</template>
|
</el-table-column>
|
|
<el-table-column
|
label="诊断编码"
|
align="center"
|
min-width="160"
|
:show-overflow-tooltip="true"
|
>
|
<template slot-scope="scope">
|
<span v-if="formatIcd10Codes(scope.row)">
|
{{ formatIcd10Codes(scope.row) }}
|
</span>
|
<span v-else style="color: #c0c4cc">—</span>
|
</template>
|
</el-table-column>
|
|
<el-table-column
|
label="备注"
|
align="center"
|
prop="remark"
|
min-width="160"
|
:show-overflow-tooltip="true"
|
/>
|
|
<el-table-column
|
label="创建时间"
|
align="center"
|
prop="createTime"
|
width="160"
|
/>
|
|
<el-table-column
|
label="操作"
|
fixed="right"
|
align="center"
|
width="160"
|
class-name="small-padding fixed-width"
|
>
|
<template slot-scope="scope">
|
<el-button
|
size="medium"
|
type="text"
|
@click="handleUpdate(scope.row)"
|
>
|
<span class="button-textxg">
|
<i class="el-icon-edit"></i>修改
|
</span>
|
</el-button>
|
<el-button
|
size="medium"
|
type="text"
|
@click="handleDelete(scope.row)"
|
>
|
<span class="button-textsc">
|
<i class="el-icon-delete"></i>删除
|
</span>
|
</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
|
<pagination
|
v-show="total > 0"
|
:total="total"
|
:page.sync="queryParams.pageNum"
|
:limit.sync="queryParams.pageSize"
|
@pagination="getList"
|
/>
|
</el-col>
|
</el-row>
|
</div>
|
|
<!-- 添加/修改配置弹框 -->
|
<el-dialog
|
:title="dialogTitle"
|
:visible.sync="dialogVisible"
|
width="45%"
|
:close-on-click-modal="false"
|
@close="cancelForm"
|
>
|
<el-form
|
:model="form"
|
:rules="rules"
|
ref="formRef"
|
label-width="100px"
|
size="medium"
|
>
|
<el-form-item label="部门类型" prop="deptType">
|
<el-radio-group v-model="form.deptType" @change="handleDeptTypeChange">
|
<el-radio
|
v-for="item in DEPT_TYPE_OPTIONS"
|
:key="item.value"
|
:label="item.value"
|
>
|
{{ item.label }}
|
</el-radio>
|
</el-radio-group>
|
</el-form-item>
|
|
<el-form-item label="部门分类" prop="deptCategory">
|
<el-select
|
v-model="form.deptCategory"
|
placeholder="请选择部门分类"
|
clearable
|
style="width: 100%"
|
@change="handleDeptCategoryChange"
|
>
|
<el-option
|
v-for="item in DEPT_CATEGORY_OPTIONS"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
|
<el-form-item label="档案类型" prop="archiveType">
|
<el-select
|
v-model="form.archiveType"
|
placeholder="请先选择部门分类"
|
clearable
|
style="width: 100%"
|
>
|
<el-option
|
v-for="item in currentArchiveTypeOptions"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
|
<el-form-item label="科室/病区" prop="deptCodes">
|
<el-select
|
v-model="form.deptCodes"
|
multiple
|
filterable
|
clearable
|
:placeholder="
|
form.deptType === '2' ? '请选择病区' : '请选择科室'
|
"
|
style="width: 100%"
|
>
|
<el-option
|
v-for="item in currentDeptOptions"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
<div class="form-tip">按所选部门类型自动切换科室 / 病区选项</div>
|
</el-form-item>
|
|
<el-form-item label="诊断编码" prop="icdList">
|
<div style="margin-bottom: 8px">
|
<el-button type="warning" size="small" @click="openIcdDialog"
|
>添加疾病诊断</el-button
|
>
|
</div>
|
<el-tag
|
v-for="item in form.icdList"
|
:key="item.icdid"
|
type="warning"
|
closable
|
:disable-transitions="false"
|
@close="removeIcd(item)"
|
>
|
{{ item.icdname }}
|
</el-tag>
|
<div class="form-tip">从疾病诊断表中选择,按 ICD10 编码匹配患者</div>
|
</el-form-item>
|
|
<el-form-item label="备注" prop="remark">
|
<el-input
|
v-model="form.remark"
|
type="textarea"
|
:rows="3"
|
placeholder="请输入备注"
|
maxlength="500"
|
show-word-limit
|
/>
|
</el-form-item>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button @click="cancelForm">取 消</el-button>
|
<el-button type="primary" @click="submitForm" :loading="submitLoading"
|
>确 定</el-button
|
>
|
</div>
|
</el-dialog>
|
|
<!-- 疾病诊断表选择弹框(与任务配置「适用疾病选择」一致) -->
|
<Optional-Form
|
ref="icdDialog"
|
:dialogVisiblepatient="icdDialogVisible"
|
:overallCase="form.icdList"
|
@addoption="icdDialogVisible = false"
|
@kkoption="icdDialogVisible = true"
|
/>
|
</div>
|
</template>
|
|
<script>
|
import {
|
listSpecificArchiveGenerateConfig,
|
saveSpecificArchiveGenerateConfig,
|
batchDeleteSpecificArchiveGenerateConfig,
|
} from "@/api/smartor/specificArchiveGenerateConfig";
|
import { getillnesslist } from "@/api/AiCentre/index";
|
import OptionalForm from "@/components/OptionalForm";
|
|
// 部门类型:1 科室,2 病区
|
const DEPT_TYPE_OPTIONS = [
|
{ value: "1", label: "科室" },
|
{ value: "2", label: "病区" },
|
];
|
|
// 部门分类:1 妇科,2 儿科
|
const DEPT_CATEGORY_OPTIONS = [
|
{ value: "1", label: "妇科" },
|
{ value: "2", label: "儿科" },
|
];
|
|
// 档案类型(按部门分类区分,妇科与儿科各自从 1 开始编号)
|
const ARCHIVE_TYPE_OPTIONS = {
|
"1": [
|
{ value: "1", label: "早孕关爱" },
|
{ value: "2", label: "围绝经期MHI" },
|
],
|
"2": [
|
{ value: "1", label: "营养性疾病" },
|
{ value: "2", label: "学习困难" },
|
{ value: "3", label: "高危儿专案" },
|
],
|
};
|
|
export default {
|
name: "GenerateConfig",
|
components: { OptionalForm },
|
data() {
|
// 科室/病区编码 与 诊断编码 至少填写一项,否则该规则无法匹配任何患者
|
const validateDeptOrIcd = (rule, value, callback) => {
|
const codes = (this.form.deptCodes || []).length;
|
const icd = (this.form.icdList || []).length;
|
if (!codes && !icd) {
|
callback(new Error("科室/病区和诊断编码至少填写一项"));
|
} else {
|
callback();
|
}
|
};
|
|
return {
|
// 常量
|
DEPT_TYPE_OPTIONS,
|
DEPT_CATEGORY_OPTIONS,
|
|
// 遮罩层
|
loading: false,
|
// 提交按钮 loading
|
submitLoading: false,
|
// 选中数组
|
ids: [],
|
// 非多个禁用
|
multiple: true,
|
// 显示搜索条件
|
showSearch: true,
|
// 总条数
|
total: 0,
|
// 表格数据
|
configList: [],
|
// 弹框标题
|
dialogTitle: "",
|
// 弹框可见性
|
dialogVisible: false,
|
// 创建时间范围
|
dateRange: [],
|
// 诊断编码选择弹框
|
icdDialogVisible: false,
|
// ICD10 编码 -> 名称映射(用于回显与列表名称展示)
|
icdCodeMap: {},
|
// 查询参数
|
queryParams: {
|
pageNum: 1,
|
pageSize: 10,
|
deptType: "",
|
deptCategory: "",
|
archiveType: "",
|
},
|
// 表单
|
form: {
|
id: "",
|
deptType: "1",
|
deptCategory: "",
|
archiveType: "",
|
deptCodes: [],
|
icdList: [],
|
remark: "",
|
},
|
// 表单校验
|
rules: {
|
deptType: [
|
{ required: true, message: "请选择部门类型", trigger: "change" },
|
],
|
deptCategory: [
|
{ required: true, message: "请选择部门分类", trigger: "change" },
|
],
|
archiveType: [
|
{ required: true, message: "请选择档案类型", trigger: "change" },
|
],
|
deptCodes: [{ validator: validateDeptOrIcd, trigger: "change" }],
|
icdList: [{ validator: validateDeptOrIcd, trigger: "change" }],
|
},
|
};
|
},
|
computed: {
|
// 科室选项(从 store getters 获取)
|
departmentOptions() {
|
return (this.$store.getters.belongDepts || []).map((dept) => ({
|
label: dept.deptName,
|
value: dept.deptCode,
|
}));
|
},
|
// 病区选项(从 store getters 获取)
|
wardOptions() {
|
console.log(this.$store.getters.belongWards);
|
|
return (this.$store.getters.belongWards || []).map((ward) => ({
|
label: ward.districtName,
|
value: ward.districtCode,
|
}));
|
},
|
// 表单里按部门类型切换的科室/病区选项
|
currentDeptOptions() {
|
console.log(this.wardOptions);
|
console.log(this.departmentOptions);
|
|
return this.form.deptType == "2" ? this.wardOptions : this.departmentOptions;
|
},
|
// 表单里按部门分类切换的档案类型选项
|
currentArchiveTypeOptions() {
|
return ARCHIVE_TYPE_OPTIONS[this.form.deptCategory] || [];
|
},
|
// 查询条件里的档案类型选项(不区分分类,全量合并去重)
|
queryArchiveTypeOptions() {
|
const all = Object.keys(ARCHIVE_TYPE_OPTIONS).reduce((acc, k) => {
|
return acc.concat(ARCHIVE_TYPE_OPTIONS[k]);
|
}, []);
|
const seen = {};
|
return all.filter((item) => {
|
if (seen[item.value]) return false;
|
seen[item.value] = true;
|
return true;
|
});
|
},
|
},
|
created() {
|
this.getList();
|
this.loadIcdList();
|
},
|
methods: {
|
/** 查询列表 */
|
getList() {
|
this.loading = true;
|
const query = { ...this.queryParams };
|
if (this.dateRange && this.dateRange.length === 2) {
|
query.params = {
|
beginTime: this.dateRange[0],
|
endTime: this.dateRange[1],
|
};
|
}
|
listSpecificArchiveGenerateConfig(query)
|
.then((response) => {
|
this.configList = response.rows;
|
this.total = response.total;
|
})
|
.finally(() => {
|
this.loading = false;
|
});
|
},
|
|
/** 搜索按钮操作 */
|
handleQuery() {
|
this.queryParams.pageNum = 1;
|
this.getList();
|
},
|
|
/** 重置按钮操作 */
|
resetQuery() {
|
this.resetForm("queryForm");
|
this.dateRange = [];
|
this.handleQuery();
|
},
|
|
// 多选框选中数据
|
handleSelectionChange(selection) {
|
this.ids = selection.map((item) => item.id);
|
this.multiple = !selection.length;
|
},
|
|
/** 新增按钮操作 */
|
handleAdd() {
|
this.resetFormData();
|
this.dialogTitle = "新增专科档案生成配置";
|
this.dialogVisible = true;
|
},
|
|
/** 修改按钮操作 */
|
handleUpdate(row) {
|
this.resetFormData();
|
this.dialogTitle = "修改专科档案生成配置";
|
this.dialogVisible = true;
|
this.form = {
|
id: row.id,
|
deptType: row.deptType || "1",
|
deptCategory: row.deptCategory || "",
|
archiveType: row.archiveType || "",
|
deptCodes: this.parseJsonArray(row.deptCodes),
|
icdList: this.resolveIcdCodes(row.icd10Codes),
|
remark: row.remark || "",
|
};
|
},
|
|
/** 部门类型变化:切换科室/病区选项,清空已选编码 */
|
handleDeptTypeChange() {
|
this.form.deptCodes = [];
|
},
|
|
/** 部门分类变化:切换档案类型选项,清空已选档案类型 */
|
handleDeptCategoryChange() {
|
this.form.archiveType = "";
|
},
|
|
/** 加载 ICD10 字典,用于诊断编码回显与列表名称展示 */
|
loadIcdList() {
|
getillnesslist({ pageNum: 1, pageSize: 1000 }).then((res) => {
|
const map = {};
|
(res.rows || []).forEach((item) => {
|
map[item.icdcode] = {
|
icdid: item.icdid,
|
icdname: item.icdname,
|
icdcode: item.icdcode,
|
};
|
});
|
this.icdCodeMap = map;
|
});
|
},
|
|
/** 打开疾病诊断表选择弹框 */
|
openIcdDialog() {
|
this.$refs.icdDialog && this.$refs.icdDialog.handleAddpatient();
|
},
|
|
/** 移除已选诊断 */
|
removeIcd(item) {
|
this.form.icdList = this.form.icdList.filter(
|
(d) => d.icdid !== item.icdid
|
);
|
},
|
|
/** 后端 JSON 编码数组 -> 诊断对象数组(用于回显) */
|
resolveIcdCodes(val) {
|
const codes = this.parseJsonArray(val);
|
return codes.map((code) =>
|
this.icdCodeMap[code]
|
? { ...this.icdCodeMap[code] }
|
: { icdid: code, icdname: code, icdcode: code }
|
);
|
},
|
|
/** 提交表单 */
|
submitForm() {
|
this.$refs.formRef.validate((valid) => {
|
if (!valid) return;
|
this.submitLoading = true;
|
const data = {
|
id: this.form.id || undefined,
|
deptType: this.form.deptType,
|
deptCategory: this.form.deptCategory,
|
archiveType: this.form.archiveType,
|
remark: this.form.remark || "",
|
};
|
// 后端要求 deptCodes / icd10Codes 传转义后的 JSON 字符串;
|
// 注意:更新时传 null 的字段不参与更新(保持原值),
|
// 因此清空时须传空 JSON 数组 "[]" 才能真正清掉。
|
data.deptCodes =
|
this.form.deptCodes && this.form.deptCodes.length
|
? JSON.stringify(this.form.deptCodes)
|
: "[]";
|
data.icd10Codes =
|
this.form.icdList && this.form.icdList.length
|
? JSON.stringify(this.form.icdList.map((d) => d.icdcode))
|
: "[]";
|
|
saveSpecificArchiveGenerateConfig(data)
|
.then((response) => {
|
if (response.code === 200) {
|
this.$modal.msgSuccess("操作成功");
|
this.dialogVisible = false;
|
this.getList();
|
} else {
|
this.$modal.msgError(response.msg || "操作失败");
|
}
|
})
|
.finally(() => {
|
this.submitLoading = false;
|
});
|
});
|
},
|
|
/** 取消表单 */
|
cancelForm() {
|
this.dialogVisible = false;
|
this.resetFormData();
|
this.$nextTick(() => {
|
if (this.$refs.formRef) {
|
this.$refs.formRef.clearValidate();
|
}
|
});
|
},
|
|
/** 重置表单数据 */
|
resetFormData() {
|
this.form = {
|
id: "",
|
deptType: "1",
|
deptCategory: "",
|
archiveType: "",
|
deptCodes: [],
|
icdList: [],
|
remark: "",
|
};
|
},
|
|
/** 删除按钮操作 */
|
handleDelete(row) {
|
const ids = row && row.id != null ? [row.id] : this.ids;
|
if (!ids.length) return;
|
this.$modal
|
.confirm("是否确认删除选中的专科档案生成配置数据项?")
|
.then(() => {
|
return batchDeleteSpecificArchiveGenerateConfig(ids);
|
})
|
.then((response) => {
|
if (response.code === 200) {
|
this.getList();
|
this.$modal.msgSuccess("删除成功");
|
} else {
|
this.$modal.msgError(response.msg || "删除失败");
|
}
|
})
|
.catch(() => {});
|
},
|
|
/** 部门类型 label */
|
deptTypeLabel(val) {
|
const item = DEPT_TYPE_OPTIONS.find((o) => o.value === String(val));
|
return item ? item.label : val || "—";
|
},
|
|
/** 部门分类 label */
|
deptCategoryLabel(val) {
|
const item = DEPT_CATEGORY_OPTIONS.find((o) => o.value === String(val));
|
return item ? item.label : val || "—";
|
},
|
|
/** 档案类型 label(依赖部门分类) */
|
archiveTypeLabel(row) {
|
const opts = ARCHIVE_TYPE_OPTIONS[String(row.deptCategory)] || [];
|
const item = opts.find((o) => o.value === String(row.archiveType));
|
return item ? item.label : row.archiveType || "—";
|
},
|
|
/** 科室/病区编码 -> 名称 */
|
formatDeptCodes(row) {
|
const codes = this.parseJsonArray(row.deptCodes);
|
if (!codes.length) return "";
|
const source =
|
String(row.deptType) === "2" ? this.wardOptions : this.departmentOptions;
|
const map = {};
|
source.forEach((o) => (map[o.value] = o.label));
|
return codes.map((c) => map[c] || c).join("、");
|
},
|
|
/** 诊断编码 -> 名称拼接(字典缺失时回退显示编码) */
|
formatIcd10Codes(row) {
|
const codes = this.parseJsonArray(row.icd10Codes);
|
return codes
|
.map((c) => {
|
const item = this.icdCodeMap[c];
|
return item ? item.icdname : c;
|
})
|
.join("、");
|
},
|
|
/** 解析后端返回的 JSON 字符串(deptCodes / icd10Codes) */
|
parseJsonArray(val) {
|
if (!val) return [];
|
if (Array.isArray(val)) return val;
|
try {
|
const arr = JSON.parse(val);
|
return Array.isArray(arr) ? arr : [];
|
} catch (e) {
|
return [];
|
}
|
},
|
},
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
.generateConfig-management {
|
padding: 20px;
|
}
|
|
.main-content {
|
padding: 30px;
|
background: #fff;
|
border: 1px solid #dcdfe6;
|
-webkit-box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.12),
|
0 0 6px 0 rgba(0, 0, 0, 0.04);
|
}
|
|
.mb8 {
|
margin-bottom: 8px;
|
}
|
|
.form-tip {
|
width: 100%;
|
font-size: 12px;
|
color: #909399;
|
line-height: 1.5;
|
margin-top: 4px;
|
}
|
|
.dialog-footer {
|
text-align: right;
|
}
|
|
// 按钮文字颜色
|
.button-textxg {
|
color: rgb(35, 81, 233);
|
}
|
|
.button-textsc {
|
color: rgb(235, 23, 23);
|
}
|
</style>
|