|
|
<template> <div class="box" style="width: 100%"> <div style="width: 90%"> <el-table :data="tableData" border style="width: 100%" class="el-table__body-wrapper tbody" :height="window.pageHeight < 600 ? 260 : window.pageHeight - 340" @row-click="rowick" highlight-current-row > <el-table-column prop="forSexId" label="性别"> <template slot-scope="scope"> <div> {{ ldddw(forSexId, "id", scope.row.forSexId, "displayName") }} </div> </template> </el-table-column> <el-table-column prop="ageLowerLimit" label="年龄上限" /> <el-table-column prop="ageUpperLimit" label="年龄下限" /> <el-table-column prop="referenceRangeValue" label="参考范围" /> <el-table-column prop="criticalRangeValue" label="警告范围" /> <el-table-column prop="lowerDiagnosisId" label="偏低诊断"> <template slot-scope="scope"> <div> {{ ldddw( diagnosis, "id", scope.row.lowerDiagnosisId, "displayName" ) }} </div> </template> </el-table-column> <el-table-column prop="upperDiagnosisId" label="偏高诊断"> <template slot-scope="scope"> <div> {{ ldddw( diagnosis, "id", scope.row.upperDiagnosisId, "displayName" ) }} </div> </template> </el-table-column> <!-- <el-table-column label="操作"> <template> <el-tag class="move" style="cursor: move; margin-left: 15px" draggable="true" > <i class="el-icon-d-caret" style="width: 1rem; height: 1rem"></i> </el-tag> </template> </el-table-column> --> </el-table> </div> <!-- 按钮区域 --> <div style="margin-left: 10px; width: 10%" class="editButton"> <div style="width:100%;"> <el-button type="success" @click="add">新增</el-button> </div> <div style="margin-top: 5px;width:100%;"> <el-button type="primary" @click="edit">编辑</el-button> </div> <div style="margin-top: 5px;width:100%;"> <el-button type="danger" @click="del">删除</el-button> </div> </div>
<!-- 新增或者编辑弹框 --> <el-dialog :title="id ? '编辑' : '新增'" :visible.sync="dialogVisible" width="70%" :append-to-body="true" > <el-form ref="form" :model="form" label-width="100px" :rules="rules"> <el-row> <el-col :span="8"> <el-form-item label="性别" prop="forSexId"> <el-select v-model="form.forSexId" placeholder="请选择"> <el-option v-for="item in forSexId" :key="item.id" :label="item.displayName" :value="item.id" > </el-option> </el-select> </el-form-item> </el-col> <el-col :span="8"> <el-form-item label="年龄下限" prop="ageLowerLimit"> <el-input v-model="form.ageLowerLimit" style="width: 100%" ></el-input> </el-form-item ></el-col> <el-col :span="8"> <el-form-item label="年龄上限" prop="ageUpperLimit"> <el-input v-model="form.ageUpperLimit" style="width: 85%" ></el-input> </el-form-item ></el-col> <el-col :span="8"> <el-form-item label="参考范围" prop="referenceRangeValue"> <el-input v-model="form.referenceRangeValue" style="width: 85%" ></el-input> </el-form-item ></el-col> <el-col :span="8"> <el-form-item label="警告范围" prop=""> <el-input v-model="form.criticalRangeValue" style="width: 100%" ></el-input> </el-form-item ></el-col> <el-col :span="8"> <el-form-item label="偏低诊断" prop="lowerDiagnosisId"> <el-select v-model="form.lowerDiagnosisId" placeholder="请选择" filterable :filter-method="remoteMethods" default-first-option clearable @change="quckEditdigoisce"> <el-option v-for="item in diagnosis" :key="item.id" :label="item.displayName" :value="item.id" > </el-option> </el-select> </el-form-item ></el-col> <el-col :span="8"> <el-form-item label="偏高诊断" prop="upperDiagnosisId"> <el-select v-model="form.upperDiagnosisId" placeholder="请选择" filterable :filter-method="remoteMethodes" default-first-option clearable @change="quckEditdigoisces"> <el-option v-for="item in diagnosies" :key="item.id" :label="item.displayName" :value="item.id" > </el-option> </el-select> </el-form-item ></el-col> </el-row> </el-form> <span slot="footer" class="dialog-footer"> <el-button @click="dialogVisible = false,id=curRowes.id">取 消</el-button> <el-button type="primary" @click="onsbmint">确 定</el-button> </span> </el-dialog> </div></template>
<script>import { mapState } from "vuex";import { getapi, postapi, putapi, deletapi } from "@/api/api";import { examinationgender } from "@/request/systemapi";import { dddw } from "../../utlis/proFunc";// import
export default { props: ["itemId", "ReferenceRangeTypeFlag"], data() { return { rules: { itemId: [{ required: true, message: "请选择项目", trigger: "blur" }], forSexId: [{ required: true, message: "请选择性别", trigger: "blur" }], ageLowerLimit: [ { required: true, message: "请输入年龄下限", trigger: "blur" }, ], ageUpperLimit: [ { required: true, message: "请输入年龄上限", trigger: "blur" }, ], referenceRangeValue: [ { required: true, message: "请输入参考范围", trigger: "blur"}, ], criticalRangeValue: [ { required: true, message: "请输入临界范围", trigger: "blur" }, ], lowerDiagnosisId: [ { required: true, message: "请选择偏低诊断", trigger: "blur" }, ], upperDiagnosisId: [ { required: true, message: "请选择偏高诊断", trigger: "blur" }, ], }, pages: { SkipCount: 0, MaxResultCount: 100, // Sorting: "displayOrder desc",
}, dialogVisible: false, form: { itemId: "", forSexId: "", ageLowerLimit: "", ageUpperLimit: "", referenceRangeValue: "", criticalRangeValue: "", lowerDiagnosisId: "", upperDiagnosisId: "", referenceRangeTypeFlag: "1", }, id: "", //新增/编辑 或删除的记录 id
forSexId: [], //性别
diagnosis: [], //偏低诊断
diagnosies:[],//偏高诊断
tableData: [], curRowes:{}, diagnosisId:"" }; },
created() {},
mounted() { //console.log('@子节点', this.itemId, this.ReferenceRangeTypeFlag)
this.addtoedit();
this.getlist(this.itemId, this.ReferenceRangeTypeFlag); }, computed: { ...mapState(["itemSet","window"]), }, methods: { getlist(itemId, ReferenceRangeTypeFlag) { getapi( `/api/app/reference-range/in-type/${itemId}?ReferenceRangeTypeFlag=${ReferenceRangeTypeFlag}` ).then((res) => { this.tableData = res.data; }); },
remoteMethods(keyWords){ if (keyWords) { this.diagnosis = []; this.diagnosisId.forEach(item => { if (item.displayName.toLowerCase().indexOf(keyWords.toLowerCase()) > - 1 || item.simpleCode.toLowerCase().indexOf(keyWords.toLowerCase()) > - 1 // || item.shortName.toLowerCase().indexOf(keyWords.toLowerCase()) > - 1
) { this.diagnosis.push(item); } }); } else { this.quckeDitd = deepCopy(this.diagnosis); } }, remoteMethodes(keyWords){ if (keyWords) { this.diagnosies = []; this.diagnosisId.forEach(item => { if (item.displayName.toLowerCase().indexOf(keyWords.toLowerCase()) > - 1 || item.simpleCode.toLowerCase().indexOf(keyWords.toLowerCase()) > - 1 // || item.shortName.toLowerCase().indexOf(keyWords.toLowerCase()) > - 1
) { this.diagnosies.push(item); } }); } else { this.quckeDitd = deepCopy(this.diagnosies); } }, rowick(row) { getapi(`/api/app/reference-range/${row.id}`).then((res) => { this.curRowes = res.data; this.id = res.data.id; }); }, quckEditdigoisce(e){ if(!e){ this.remoteMethods() } }, quckEditdigoisces(e){ if(!e){ this.remoteMethodes() } }, //ldddw(forSexId, 'id', scope.row.forSexId, 'displayName')
ldddw(arrayData, key, value, display) { return dddw(arrayData, key, value, display); },
// 新增或者编辑需要的类别
addtoedit() { //性别
getapi("/api/app/sex").then((res) => { this.forSexId = res.data; }); //诊断
postapi("/api/app/diagnosis/getlistinsuggestion").then((res) => { this.diagnosis = res.data; this.diagnosies=res.data this.diagnosisId=res.data }); },
add() { this.addtoedit() this.id = ""; this.dialogVisible = true; if (this.$refs.form !== undefined){ this.$refs.form.resetFields() } Object.assign(this.$data.form, this.$options.data().form) this.form = { itemId: this.itemId, referenceRangeTypeFlag: this.ReferenceRangeTypeFlag, }; },
//编辑弹框
edit() { if (!this.id) { this.$message.warning("请先选中要编辑的记录"); return; } this.dialogVisible = true; if (this.$refs.form !== undefined){ this.$refs.form.resetFields() } this.form={...this.curRowes} this.addtoedit() },
del() { //this.$message.success("删除操作");
if (!this.id) { this.$message.warning("请先选中要删除的记录"); return; } this.$confirm("此操作将永久删除该记录, 是否继续?", "提示", { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning", }) .then(() => { return deletapi(`/api/app/reference-range/${this.id}`, this.form); }) .then((res) => { if(res.code!=-1){ this.$message.success("删除成功"); this.getlist(this.itemId, this.ReferenceRangeTypeFlag); this.id = ""; } }) .catch(() => { this.$message({ type: "info", message: "已取消删除", }); }); }, confirmationRequest(){ if (!this.id) { postapi("/api/app/reference-range", this.form).then((res) => { if(res.code!=-1){ this.$message.success("新增成功"); this.getlist(this.itemId, this.ReferenceRangeTypeFlag); this.id = this.curRowes.id; this.dialogVisible=false } }); } else { putapi(`/api/app/reference-range/${this.id}`, this.form).then( (res) => { if(res.code!=-1){ this.$message.success("修改成功"); this.dialogVisible=false this.getlist(this.itemId, this.ReferenceRangeTypeFlag); } } ); } }, //确定新增或者编辑
onsbmint() { this.$refs["form"].validate((v) => { let that=this if (v) { if(that.form.referenceRangeValue.includes('-')){ let before=/^\d+\.?\d?$/.test(that.form.referenceRangeValue.match(/(\S*)-/)[1]) let after=/^\d+\.?\d?$/.test(that.form.referenceRangeValue.match(/-(\S*)/)[1]) if(before && after){ console.log(that.form) if(that.form.criticalRangeValue!="" && that.form.criticalRangeValue!=undefined){ if(that.form.criticalRangeValue.includes('-')){ let criticalBefore=/^\d+\.?\d?$/.test(that.form.criticalRangeValue.match(/(\S*)-/)[1]) let criticalAfter=/^\d+\.?\d?$/.test(that.form.criticalRangeValue.match(/-(\S*)/)[1]) if(criticalBefore && criticalAfter){ that.confirmationRequest() }else{ return that.$message.warning("警告范围值-符号前后必须是数字"); } }else{ return that.$message.warning("警告范围值必须以-符号隔开"); } }else{ that.confirmationRequest() } }else{ return that.$message.warning("参考范围值-符号前后必须是数字"); } }else{ return that.$message.warning("参考范围值必须以-符号隔开"); } } }); }, },
//监听事件
watch: { //itemId','ReferenceRangeTypeFlag'
itemId(newVal, oldVal) { if (newVal != oldVal && newVal != "") { this.getlist(this.itemId, this.ReferenceRangeTypeFlag); } }, ReferenceRangeTypeFlag(newVal, oldVal) { if (newVal != oldVal && newVal != "") { this.getlist(this.itemId, this.ReferenceRangeTypeFlag); } }, },};</script><style scoped>.box { display: flex; margin-top: 15px;}:deep .editButton .el-button{ width: 100%;}</style>
|