1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090 |
- <style lang="less" scoped>
- // @import "../../less/admin.less";
- #AddRuleContent {
- width: 100%;
- min-width: 1000px;
- padding: 20px;
- padding-top: 50px;
- padding-bottom: 0;
- box-sizing: border-box;
- .table_form {
- width: 100%;
- box-sizing: border-box;
- background: #fff;
- padding: 20px;
- padding-bottom: 0;
- display: flex;
- flex-wrap: wrap;
- .table_cell {
- flex: 1;
- min-width: 25%;
- }
- }
- /deep/ .el-input--mini .el-input__inner,
- .el-select {
- width: 100%;
- font-size: 14px;
- }
- .tip_text {
- // margin-top: -8px;
- font-size: 12px;
- color: red;
- line-height: 16px;
- // transform: scale(.8, .8);
- }
- .form_btn {
- width: 100%;
- background: #fff;
- padding-bottom: 20px;
- text-align: center;
- }
- /deep/ .el-form-item.is-success .el-input__inner,
- .el-form-item.is-success .el-textarea__inner {
- border-color: #c9c9c9 !important;
- }
- /deep/ .el-form-item.is-success .el-textarea__inner {
- border-color: #c9c9c9 !important;
- }
- /deep/ .el-form-item.is-success .el-textarea__inner {
- border-color: #c9c9c9 !important;
- }
- .my_error {
- position: absolute;
- top: 0;
- left: -16px;
- img {
- width: 12px;
- height: 12px;
- cursor: pointer;
- }
- }
- }
- </style>
- <style lang="less">
- .popper_class {
- // background: #fff !important;
- border: 1px solid #ffa0a0 !important;
- color: #999999 !important;
- padding: 3px 50px 3px 10px !important;
- margin-left: -10px;
- }
- .popper__arrow {
- border-top-color: #ffa0a0 !important;
- }
- </style>
- <template>
- <div>
- <crumbs :title="title" :param="$route.params" linkTo="ZskRuleManager"></crumbs>
- <div id="AddRuleContent">
- <el-form size="mini" :model="form" ref="ruleForm">
- <div class="table_form">
- <div class="table_cell">
- <!-- 规则名称 -->
- <el-form-item
- label-width="130px"
- label="规则名称:"
- :rules="rules.parDescription"
- prop="parDescription"
- >
- <el-input style="width: 100%" v-model.trim="form.parDescription" />
- </el-form-item>
- </div>
- <div class="table_cell">
- <!-- 规则类型 -->
- <el-form-item
- label-width="130px"
- label="规则类型:"
- :rules="rules.parRuleType"
- prop="parRuleType"
- >
- <el-select v-model="form.parRuleType" placeholder="请选择" @change="ruleTypeChange">
- <el-option
- v-for="item in ruleTypeList"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- ></el-option>
- </el-select>
- <template slot="error" slot-scope="scope">
- <div class="my_error">
- <el-tooltip
- class="item"
- effect="light"
- :content="scope.error"
- placement="top-start"
- popper-class="popper_class"
- >
- <img src="../../images/exclamationpoint.png" alt />
- </el-tooltip>
- </div>
- </template>
- <div class="tip_text">注:更改规则类型,将会清空已填写的规则内容~</div>
- </el-form-item>
- </div>
- <div class="table_cell">
- <!-- 规则术语类型: -->
- <el-form-item
- label-width="130px"
- label="规则术语类型:"
- :rules="rules.parLenCode"
- prop="parLenCode"
- >
- <template slot="error" slot-scope="scope">
- <div class="my_error">
- <el-tooltip
- class="item"
- effect="light"
- :content="scope.error"
- placement="top-start"
- popper-class="popper_class"
- >
- <img src="../../images/exclamationpoint.png" alt />
- </el-tooltip>
- </div>
- </template>
- <el-select v-model="form.parLenCode" placeholder="请选择" @change="ruleTermChange">
- <el-option
- v-for="item in ruleTermTypeList"
- :key="item.id"
- :label="item.name"
- :value="item.code"
- ></el-option>
- </el-select>
- <div class="tip_text">注:更改规则术语类型,将会清空已填写的规则内容~</div>
- </el-form-item>
- </div>
- <div class="table_cell">
- <el-form-item
- label-width="130px"
- label="医学标准术语:"
- :style="{ height: '100%' }"
- :rules="rules.parConceptId"
- prop="parConceptId"
- >
- <el-select
- clearable
- filterable
- remote
- :remote-method="searchConcept"
- v-model.trim="form.parConceptId"
- @change="parConceptIdChange"
- >
- <el-option
- v-for="item in conceptList"
- :key="item.conceptId"
- :label="item.conceptName"
- :value="item.conceptId"
- :title="item.conceptName"
- ></el-option>
- </el-select>
- </el-form-item>
- </div>
- <div class="table_cell" v-if="showHasSub" style="max-width: 25%">
- <el-form-item
- label-width="130px"
- label="有无子条件:"
- :rules="rules.parHasSub"
- prop="parHasSub"
- >
- <el-select v-model="form.parHasSub" placeholder="请选择" @change="hasSubChange">
- <el-option label="有" :value="1"></el-option>
- <el-option label="无" :value="0"></el-option>
- </el-select>
- </el-form-item>
- </div>
- <!-- <div
- class="table_cell"
- style="flex: 3; max-width: 50%"
- v-if="showMsg"
- >
-
- <el-form-item
- label-width="130px"
- label="附加信息:"
- :rules="rules.parMsg"
- prop="parMsg"
- >
- <el-input
- type="textarea"
- :rows="1"
- placeholder="请输入附加信息"
- v-model.trim="form.parMsg"
- ></el-input>
- </el-form-item>
- </div>-->
- </div>
- <!-- 表格 -->
- <AddNewRuleTable
- ref="tableView"
- v-if="form.parHasSub && tableShow"
- :klRuleByIdSub="form.klRuleByIdSub"
- :maxNum="subRuleMaxNum"
- :showMsg="showMsg"
- :showMsg2="showMsg2"
- :ruleTermCodeStr="ruleTermCodeStr"
- @subTypeChange="subTypeChange"
- @searchConcept="searchConcept"
- @addGroup="addGroup"
- @delGroup="delGroup"
- @delGroupChild="delGroupChild"
- @setFormData="setFormData"
- @editKlRuleByIdSub="editKlRuleByIdSub"
- @clearValidate="clearValidate"
- @childClearConcept="childClearConcept"
- @childClearNumText="childClearNumText"
- @ChildDataTypeChange="ChildDataTypeChange"
- @childSubCodeChange="childSubCodeChange"
- />
- <el-form-item>
- <div class="form_btn">
- <el-button type="primary" size="medium " @click="submitForm('ruleForm')">确定</el-button>
- </div>
- </el-form-item>
- </el-form>
- </div>
- </div>
- </template>
- <script type="text/javascript">
- import api from '@api/knowledgeLib.js';
- import { formRules } from './rules';
- import AddNewRuleTable from './AddNewRuleTable';
- export default {
- name: 'AddRule',
- data() {
- return {
- title: '规则维护-添加规则',
- ruleTypeList: [], //规则类型列表 1
- ruleTermTypeList: [], //规则术语类型列表 2
- conceptList: [], //医学标准术语列表 3
- baseTypeList: [], //基础规则类型列表 4
- baseTermTypeList: [], //基础规则术语类型 5
- subRuleMaxNum: null, //规则内容中规则的限制个数
- isCopy: false,
- parId: null,
- msgDict: '', //显示附加信息的类型
- firstPlace: null,
- tableShow: true,
- form: {
- parDescription: '',
- parRuleType: '',
- parConceptId: '',
- parlibName: '',
- parLenName: '',
- parHasSub: undefined,
- parLenCode: '',
- klRuleByIdSub: []
- },
- rules: formRules,
- dragVal: null,
- dragArr: null
- };
- },
- created() {
- this.getTypeList();
- this.setDict();
- const param = this.$route.params;
- let info = param.data;
- if (info) {
- this.parId = info.parId;
- this.isCopy = param.copy;
- this.title = '规则维护-' + (this.isCopy ? '复制' : '修改') + '规则';
- this.form = JSON.parse(JSON.stringify(info));
- // 编辑初始化选择框
- this.initEdidData();
- }
- },
- methods: {
- clearValidate(data) {
- this.$refs.ruleForm.clearValidate(data);
- },
- // 编辑初始化
- async initEdidData() {
- // 规则术语类型初始化
- const newruleTermTypeList = await this.ruleTypeList.find(
- it => it.id == this.form.parRuleType
- );
- this.ruleTermTypeList = await newruleTermTypeList.subMenuList;
- // 基础规则类型初始化
- const obj = await this.ruleTermTypeList.find(
- it1 => it1.code == this.form.parLenCode
- );
- this.baseTypeList = obj.subMenuList;
- this.subRuleMaxNum = obj.number;
- this.conceptList = [
- { conceptName: this.form.parlibName, conceptId: this.form.parConceptId }
- ];
- if (this.form.parConceptId && this.checkFirstPlace && this.conceptList) {
- this.firstPlace = this.conceptList.find(
- it => it.conceptId === this.form.parConceptId
- );
- if (this.firstPlace) {
- this.firstPlace['checkedType'] = this.ruleTermCodeStrs;
- }
- } else if (!this.form.parConceptId) {
- this.setInitGroupData();
- this.firstPlace = null;
- } else {
- this.firstPlace = null;
- }
- await this.form.klRuleByIdSub.forEach((item, i, arr) => {
- item.groupId = 'groupId' + item.groupType;
- item.groupChildId = 'child' + item.subId;
- //TODO => 赋值时一定要注意set更新页面
- this.$set(item, 'baseTypes', [...this.baseTypeList]);
- this.$set(
- item,
- 'baseTermTypeList',
- item.baseTypes.find(it2 => it2.type === item.subType).subMenuList
- );
- this.$set(item, 'conceptList', [
- {
- conceptName: item.subLibName || item.subConceptName,
- conceptId: item.subConceptId
- }
- ]);
- if (item.subMaxOperator || item.subMinOperator) {
- item.dataType = '1';
- } else if (item.subEqValue) {
- item.dataType = '2';
- }
- // disable
- if (this.form.parHasSub && this.firstPlace) {
- const del =
- localStorage
- .getItem('zskDelDict')
- .match(
- new RegExp(this.firstPlace.checkedType + '-\\d+' + '-\\d+', 'g')
- ) || [];
- if (arr[i - 1] && arr[i - 1].groupId == item.groupId) {
- this.$set(item, 'disabled', false);
- if (del.length > 0 && item.subType == del[0].split('-')[2]) {
- const delType = del[0].split('-');
- const types = del[0].split('-');
- let baseTypeList = JSON.parse(JSON.stringify(this.baseTypeList));
- const subobj = this.baseTypeList.find(it => it.type == types[2]);
- const screenArr = subobj.subMenuList.filter(item => {
- return !types[3].includes(item.code);
- });
- this.$set(item, 'baseTermTypeList', screenArr);
- }
- } else {
- this.$set(item, 'disabled', true);
- }
- }
- const dragDel =
- localStorage
- .getItem('zskDragDict')
- .match(new RegExp(this.ruleTermCodeStrs, 'g')) || [];
- //药品开单合理判断
- if (dragDel.length > 0) {
- const obj = this.baseTypeList.find(it => it.type === 1);
- if (arr[i - 1] && arr[i - 1].groupId == item.groupId) {
- let klRuleByIdSub = this.form.klRuleByIdSub;
- klRuleByIdSub.forEach((item, i, arr) => {
- if (arr[0].subType == 1) {
- const arr = this.baseTypeList.filter(it => {
- return it.type == 1;
- });
- if (i > 0) {
- this.$set(item, 'baseTypes', arr);
- }
- }
- });
- if (i == 2) {
- //获取互斥项code
- const list = obj.subMenuList.filter(it => {
- return (
- it.code == arr[i - 1].subLenCode &&
- it.remark.split('|')[0] == 3
- );
- });
- const dragArr = list[0].remark.split('|')[1].split(',');
- this.dragArr = dragArr;
- this.dragVal = item.subLenCode;
- //取出互斥项
- const screenArr = obj.subMenuList.filter(item =>
- dragArr.some(
- ele => ele === item.code && item.remark.split('|')[0] == 3
- )
- );
- this.$set(item, 'baseTermTypeList', screenArr);
- } else {
- const screenArr = obj.subMenuList.filter(item => {
- if (item.remark == '') {
- return item;
- } else {
- return item.remark.split('|')[0] == i + 1;
- }
- });
- this.$set(item, 'baseTermTypeList', screenArr);
- }
- }
- }
- });
- },
- // 提交
- submitForm(formName) {
- this.$refs[formName].validate(valid => {
- if (valid) {
- let params = JSON.parse(JSON.stringify(this.form));
- params.klRuleInfoSaveSub = params.klRuleByIdSub;
- delete params.klRuleByIdSub;
- params.klRuleInfoSaveSub.forEach((item, i, arr) => {
- if (i === 0) {
- item.groupType = 1;
- } else {
- if (item.groupId == arr[i - 1].groupId) {
- item.groupType = arr[i - 1].groupType;
- item.subMsg = arr[i - 1].subMsg;
- } else {
- item.groupType = arr[i - 1].groupType + 1;
- }
- }
- });
- params.klRuleInfoSaveSub.forEach(ite => {
- delete ite.groupId;
- delete ite.groupChildId;
- delete ite.rowIndex;
- delete ite.baseTypes;
- delete ite.baseTermTypeList;
- delete ite.conceptList;
- });
- if (this.parId) {
- params.parId = this.isCopy ? undefined : this.parId;
- params.parStatus = this.isCopy ? 1 : this.form.parStatus;
- }
- this.saveRule(params);
- } else {
- return false;
- }
- });
- },
- // 子集修改父级的数组
- setFormData(index, data) {
- this.$set(this.form.klRuleByIdSub[index], 'conceptList', data);
- },
- // table_form 规则类型选中
- ruleTypeChange(val) {
- this.form.parLenCode = '';
- const obj = this.ruleTypeList.find(it => it.id === val);
- this.ruleTermTypeList = obj.subMenuList;
- this.subRuleMaxNum = undefined;
- this.setInitGroupData();
- },
- // table_form 规则术语类型选中
- ruleTermChange(val) {
- const obj = this.ruleTermTypeList.find(it => it.code === val);
- this.form.parLenName = obj.name;
- this.baseTypeList = obj.subMenuList;
- this.subRuleMaxNum = obj.number;
- this.form.parHasSub = obj.subMenuList.length ? 1 : 0;
- this.setInitGroupData();
- },
- // 医学标准术语
- parConceptIdChange(val) {
- this.$nextTick(() => {
- if (val && this.checkFirstPlace && this.conceptList) {
- this.firstPlace = this.conceptList.find(it => it.conceptId === val);
- if (this.firstPlace) {
- this.firstPlace['checkedType'] = this.ruleTermCodeStrs;
- }
- } else if (!val) {
- this.setInitGroupData();
- this.firstPlace = null;
- } else {
- this.firstPlace = null;
- }
- if (this.form.parHasSub && this.firstPlace) {
- const dict =
- localStorage
- .getItem('zskDicts')
- .match(new RegExp(this.firstPlace.checkedType + '-\\d+', 'g')) ||
- [];
- const del =
- localStorage
- .getItem('zskDelDict')
- .match(
- new RegExp(this.firstPlace.checkedType + '-\\d+' + '-\\d+', 'g')
- ) || [];
- const types = dict[0].split('-');
- let obj = this.form.klRuleByIdSub;
- obj.forEach((item, i, arr) => {
- if (arr[i - 1] && arr[i - 1].groupId == item.groupId) {
- this.$set(item, 'disabled', false);
- if (del.length > 0) {
- const delType = del[0].split('-');
- if (
- item.subType == delType[2] ||
- item.subLenCode == delType[3]
- ) {
- this.$set(this.form.klRuleByIdSub, i, {
- groupId: item.groupId,
- groupChildId: 'child' + new Date().valueOf(),
- baseTypes: this.baseTypeList,
- baseTermTypeList: [],
- conceptList: [],
- subDescription: '',
- parRuleType: '',
- subConceptId: '',
- subType: '',
- subMaxOperator: '',
- subMaxUnit: '',
- subMaxValue: '',
- subMinOperator: '',
- subMinUnit: '',
- subMinValue: '',
- subEqValue: '',
- subLenCode: '',
- dataType: ''
- });
- }
- }
- } else {
- this.$set(item, 'disabled', true);
- this.$set(item, 'subType', parseInt(types[2]));
- const subobj = this.baseTypeList.find(it => it.type == types[2]);
- this.$set(item, 'baseTermTypeList', subobj.subMenuList);
- this.$set(item, 'subLenCode', types[1]);
- this.$set(item, 'subDescription', this.firstPlace.conceptName);
- this.$set(item, 'subConceptId', this.firstPlace.conceptId);
- this.$set(item, 'subConceptName', this.firstPlace.conceptName);
- this.$set(item, 'conceptList', [this.firstPlace]);
- }
- });
- this.$set(this.form, 'klRuleByIdSub', obj);
- }
- });
- },
- // 初始化表格
- setInitGroupData(init) {
- this.tableShow = false;
- const date = new Date().valueOf();
- this.$nextTick(() => {
- if (this.form.parHasSub && this.form.parHasSub != 0) {
- this.$set(this.form, 'klRuleByIdSub', [
- {
- groupId: date,
- groupChildId: 'child' + new Date().valueOf(),
- baseTypes: this.baseTypeList,
- baseTermTypeList: [],
- conceptList: [],
- subDescription: '',
- parRuleType: '',
- subConceptId: '',
- subType: '',
- subMaxOperator: '',
- subMaxUnit: '',
- subMaxValue: '',
- subMinOperator: '',
- subMinUnit: '',
- subMinValue: '',
- subEqValue: '',
- subLenCode: '',
- dataType: ''
- }
- ]);
- } else {
- this.$set(this.form, 'klRuleByIdSub', []);
- }
- if (!init) {
- this.form.parConceptId = ''; //医学标准术语清空
- this.conceptList = []; //下拉列表清空
- this.firstPlace = null;
- }
- this.tableShow = true;
- });
- },
- // 有无子条件切换
- hasSubChange(val) {
- if (val) {
- this.setInitGroupData(true);
- } else {
- this.form.klRuleByIdSub = [];
- }
- },
- // 基础规则类型切换
- subTypeChange(val, index) {
- // index
- const dragDel =
- localStorage
- .getItem('zskDragDict')
- .match(new RegExp(this.ruleTermCodeStrs, 'g')) || [];
- const obj = this.baseTypeList.find(it => it.type === val);
- let dragType = false;
- let isDel = false;
- let screenArr;
- //药品开单合理判断
- if (dragDel.length > 0) {
- dragType = true;
- const types = dragDel[0].split('-');
- if (this.dragArr && index > 0) {
- //获取互斥项code
- const list = obj.subMenuList.filter(it => {
- return it.code == this.dragVal && it.remark.split('|')[0] == 3;
- });
- const dragArr = list[0].remark.split('|')[1].split(',');
- this.dragArr = dragArr;
- //取出互斥项
- screenArr = obj.subMenuList.filter(item =>
- dragArr.some(
- ele => ele === item.code && item.remark.split('|')[0] == 3
- )
- );
- } else {
- screenArr = obj.subMenuList.filter(item => {
- if (item.remark == '') {
- return item;
- } else {
- return item.remark.split('|')[0] == index + 1;
- }
- });
- }
- let klRuleByIdSub = this.form.klRuleByIdSub;
- klRuleByIdSub.forEach((item, i, arr) => {
- if (arr[0].subType == 1) {
- const arr = this.baseTypeList.filter(it => {
- return it.type == 1;
- });
- if (i > 0) {
- this.$set(item, 'baseTypes', arr);
- }
- }
- });
- }
- //危急值实验室子项目已选医学标准术语判断
- if (this.form.parHasSub && this.firstPlace) {
- const del =
- localStorage
- .getItem('zskDelDict')
- .match(
- new RegExp(this.firstPlace.checkedType + '-\\d+' + '-\\d+', 'g')
- ) || [];
- if (del.length > 0) {
- isDel = true;
- const types = del[0].split('-');
- let baseTypeList = JSON.parse(JSON.stringify(this.baseTypeList));
- const subobj = this.baseTypeList.find(it => it.type == types[2]);
- screenArr = subobj.subMenuList.filter(item => {
- return !types[3].includes(item.code);
- });
- }
- }
- this.$set(
- this.form.klRuleByIdSub[index],
- 'baseTermTypeList',
- (isDel && val == 2) || dragType ? screenArr : obj.subMenuList
- );
- this.$set(this.form.klRuleByIdSub[index], 'subLenCode', '');
- this.$set(this.form.klRuleByIdSub[index], 'dataType', '');
- this.clearConcept(index);
- this.clearNumText(index);
- },
- clearConcept(index) {
- this.$set(this.form.klRuleByIdSub[index], 'subConceptId', '');
- this.conceptList = [];
- },
- clearNumText(index) {
- this.$set(this.form.klRuleByIdSub[index], 'subMaxOperator', '');
- this.$set(this.form.klRuleByIdSub[index], 'subMaxValue', '');
- this.$set(this.form.klRuleByIdSub[index], 'subMaxUnit', '');
- this.$set(this.form.klRuleByIdSub[index], 'subMinOperator', '');
- this.$set(this.form.klRuleByIdSub[index], 'subMinValue', '');
- this.$set(this.form.klRuleByIdSub[index], 'subMinUnit', '');
- this.$set(this.form.klRuleByIdSub[index], 'subEqValue', '');
- this.$set(this.form.klRuleByIdSub[index], 'subEqOperator', '');
- },
- editKlRuleByIdSub(data) {
- this.$set(this.form, 'klRuleByIdSub', data);
- // this.form.klRuleByIdSub = data;
- },
- // 添加分组 || 规则
- addGroup(date, arg = { index: null, groupId: null }) {
- /**
- * @params
- * date:存在则添加规则 不存在则添加分组
- * arg:{index:添加规则用索引,groupId:添加分组用确切id}
- */
- !date && (date = new Date().valueOf());
- const obj = {
- groupId: date,
- groupChildId: 'child' + new Date().valueOf(),
- baseTypes: this.baseTypeList,
- baseTermTypeList: [],
- conceptList: [],
- subDescription: '',
- parRuleType: '',
- subConceptId: '',
- subType: '',
- subMaxOperator: '',
- subMaxUnit: '',
- subMaxValue: '',
- subMinOperator: '',
- subMinUnit: '',
- subMinValue: '',
- subEqValue: '',
- subLenCode: '',
- dataType: ''
- };
- if (typeof arg.index == 'number') {
- // 添加规则 直接在当前位置之后添加
- this.form.klRuleByIdSub.splice(arg.index + 1, 0, obj);
- const dragDel =
- localStorage
- .getItem('zskDragDict')
- .match(new RegExp(this.ruleTermCodeStrs, 'g')) || [];
- if (dragDel.length > 0) {
- let obj = this.form.klRuleByIdSub;
- obj.forEach((item, i, arr) => {
- if (arr[0].subType == 1) {
- const arr = this.baseTypeList.filter(it => {
- return it.type == 1;
- });
- if (i > 0) {
- this.$set(item, 'baseTypes', arr);
- }
- }
- });
- }
- } else {
- // 添加分组 在列表中相同groupId之后添加
- // 添加分组时判断是否需要加disabled和添加默认值
- if (this.form.parHasSub && this.firstPlace) {
- obj.disabled = true;
- const dict =
- localStorage
- .getItem('zskDicts')
- .match(new RegExp(this.firstPlace.checkedType + '-\\d+', 'g')) ||
- [];
- const types = dict[0].split('-');
- this.$set(obj, 'disabled', true);
- this.$set(obj, 'subType', parseInt(types[2]));
- const subobj = this.baseTypeList.find(it => it.type == types[2]);
- this.$set(obj, 'baseTermTypeList', subobj.subMenuList);
- this.$set(obj, 'subLenCode', types[1]);
- this.$set(obj, 'subDescription', this.firstPlace.conceptName);
- this.$set(obj, 'subConceptId', this.firstPlace.conceptId);
- this.$set(obj, 'subConceptName', this.firstPlace.conceptName);
- this.$set(obj, 'conceptList', [this.firstPlace]);
- }
- var i = -1;
- this.form.klRuleByIdSub.forEach((item, inx) => {
- if (item.groupId === arg.groupId) {
- i = inx;
- }
- });
- this.form.klRuleByIdSub.splice(i + 1, 0, obj);
- }
- this.$nextTick(() => {
- this.$refs.tableView.scrollFun();
- });
- },
- // 删除分组
- delGroup(groupId) {
- const list = this.form.klRuleByIdSub.filter(
- item => item.groupId != groupId
- );
- this.form.klRuleByIdSub = list;
- },
- // 删除规则
- delGroupChild(groupChildId, index) {
- let newGroupList;
- const dragDel =
- localStorage
- .getItem('zskDragDict')
- .match(new RegExp(this.ruleTermCodeStrs, 'g')) || [];
- let list;
- if (dragDel.length > 0) {
- if (index == 0) {
- const date = new Date().valueOf();
- newGroupList = [
- {
- groupId: date,
- groupChildId: 'child' + new Date().valueOf(),
- baseTypes: this.baseTypeList,
- baseTermTypeList: [],
- conceptList: [],
- subDescription: '',
- parRuleType: '',
- subConceptId: '',
- subType: '',
- subMaxOperator: '',
- subMaxUnit: '',
- subMaxValue: '',
- subMinOperator: '',
- subMinUnit: '',
- subMinValue: '',
- subEqValue: '',
- subLenCode: '',
- dataType: ''
- }
- ];
- } else if (index == 0 || index == 1) {
- newGroupList = this.form.klRuleByIdSub.filter((item, i) => {
- return i == 0;
- });
- } else {
- newGroupList = this.form.klRuleByIdSub.filter(
- item => item.groupChildId != groupChildId
- );
- }
- } else {
- newGroupList = this.form.klRuleByIdSub.filter(
- item => item.groupChildId != groupChildId
- );
- }
- this.form.klRuleByIdSub = newGroupList;
- },
- setDict() {
- this.dict = localStorage.getItem('zskDicts');
- this.msgDict = localStorage.getItem('zskMsgDict');
- this.subDict = localStorage.getItem('zskSubDict');
- },
- showConfirmDialog(msg, resolve) {
- this.$alert(msg, '提示', {
- confirmButtonText: '确定',
- type: 'warning'
- })
- .then(() => {
- resolve();
- })
- .catch(() => {});
- },
- searchConcept(val) {
- const param = {
- excludedConceptIds: [this.form.parRuleType],
- libType: this.form.parLenCode,
- name: val
- };
- api
- .searchConcept(param)
- .then(res => {
- if (res.data.code == '0') {
- const data = res.data.data;
- this.conceptList = data;
- }
- })
- .catch(error => {
- console.log(error);
- });
- },
- getTypeList() {
- this.ruleTypeList = JSON.parse(localStorage.getItem('zskTypesList'));
- },
- saveRule(params) {
- api.saveRule(params).then(res => {
- if (res.data.code == 0) {
- this.$message({
- message: '操作成功',
- type: 'success'
- });
- this.$router.push({
- name: 'ZskRuleManager',
- params: Object.assign({}, this.$route.params, { currentPage: 1 })
- });
- } else {
- this.$message({
- message: res.data.msg,
- type: 'warning'
- });
- }
- });
- },
- /**
- * 子组件调用方法
- */
- childClearConcept(index) {
- this.$set(this.form.klRuleByIdSub[index], 'subConceptId', '');
- this.$set(this.form.klRuleByIdSub[index], 'conceptList', []);
- },
- childClearNumText(index) {
- let obj = JSON.parse(JSON.stringify(this.form.klRuleByIdSub));
- obj[index].subMaxOperator = '';
- obj[index].subMaxValue = '';
- obj[index].subMaxUnit = '';
- obj[index].subMinOperator = '';
- obj[index].subMinValue = '';
- obj[index].subMinUnit = '';
- obj[index].subEqValue = '';
- // this.$set(obj[index], "subEqValue", "");
- obj[index].subEqOperator = '';
- // this.klRuleByIdSub = obj;
- // this.$emit("editKlRuleByIdSub", obj);
- this.editKlRuleByIdSub(obj);
- },
- ChildDataTypeChange(val, index) {
- this.form.klRuleByIdSub[index].subEqOperator = val === '2' ? '=' : '';
- this.$set(
- this.form.klRuleByIdSub[index],
- 'subEqOperator',
- val === '2' ? '=' : ''
- );
- this.childClearNumText(index);
- // TODO 新增的内容追踪不到
- this.form.klRuleByIdSub.forEach((item, i) => {
- if (index === i) {
- this.$set(item, 'dataType', val);
- }
- });
- },
- childSubCodeChange(val, index, numTypes) {
- const dragDel =
- localStorage
- .getItem('zskDragDict')
- .match(new RegExp(this.ruleTermCodeStrs, 'g')) || [];
- const inx = index == 1 ? index + 1 : index == 2 ? index - 1 : index;
- const subobj = this.baseTypeList.find(it => it.type == 1);
- let obj = this.form.klRuleByIdSub;
- const mutex = obj.some((item, i, arr) => {
- return item.subLenCode == '';
- });
- //判断药品合理性总条数是否大于1条,是否存在第二条或第三条类型为1,存在触发互斥
- if (
- //判断3条规则是否都已选中
- dragDel.length > 0 &&
- index > 0 &&
- this.form.klRuleByIdSub.length > 1 &&
- this.form.klRuleByIdSub[0].subType == 1
- ) {
- if (this.form.klRuleByIdSub.length == 3 && !mutex) {
- //判断是否存在符合互斥条件的两条出具,若存在,置空另一条出具
- if (this.dragArr.indexOf(this.dragVal) > -1) {
- //剂型给药途径互斥判断
- const arr = this.baseTypeList.filter(it => {
- return it.type == 1;
- });
- this.$set(this.form.klRuleByIdSub, inx, {
- groupId: this.form.klRuleByIdSub[inx].groupId,
- groupChildId: 'child' + new Date().valueOf(),
- baseTypes: arr,
- baseTermTypeList: [],
- conceptList: [],
- subDescription: '',
- parRuleType: '',
- subConceptId: '',
- subType: '',
- subMaxOperator: '',
- subMaxUnit: '',
- subMaxValue: '',
- subMinOperator: '',
- subMinUnit: '',
- subMinValue: '',
- subEqValue: '',
- subLenCode: '',
- dataType: ''
- });
- }
- } else {
- const list = subobj.subMenuList.filter(it => {
- return it.code == val && it.remark.split('|')[0] == 3;
- });
- //获取互斥项code
- const dragArr = list[0].remark.split('|')[1].split(',');
- this.dragArr = dragArr;
- //获取互斥项
- const screenArr = subobj.subMenuList.filter(item =>
- dragArr.some(
- ele => ele === item.code && item.remark.split('|')[0] == 3
- )
- );
- if (this.form.klRuleByIdSub[inx]) {
- this.$set(
- this.form.klRuleByIdSub[inx],
- 'baseTermTypeList',
- screenArr
- );
- }
- }
- this.dragVal = val;
- }
- if ((numTypes + ',').indexOf(val + ',') > -1) {
- this.$set(this.form.klRuleByIdSub[index], 'dataType', '1');
- } else {
- this.$set(this.form.klRuleByIdSub[index], 'dataType', '');
- }
- this.childClearConcept(index);
- this.childClearNumText(index);
- },
- // 去重
- unique(arr, obj) {
- return arr.reduce((cur, next) => {
- obj[next] ? '' : (obj[next] = true && cur.push(next));
- return cur;
- }, []);
- }
- },
- watch: {
- 'form.klRuleByIdSub': {
- handler(val) {
- this.form.klRuleByIdSub.forEach((item, i, arr) => {
- if (i == 0) {
- item.rowIndex = 1;
- } else if (item.groupId == arr[i - 1].groupId) {
- item.rowIndex = arr[i - 1].rowIndex;
- } else {
- item.rowIndex = arr[i - 1].rowIndex + 1;
- }
- });
- },
- deep: true
- }
- },
- computed: {
- disable: function() {
- return Object.keys(this.firstPlace || {}).length > 0;
- },
- ruleTermCodeStr: function() {
- const str = this.form.parRuleType + '-' + this.form.parLenCode + '-' + 1;
- if (str.length <= 1) {
- return '';
- }
- return str;
- },
- ruleTermCodeStr2: function() {
- const str = this.form.parRuleType + '-' + this.form.parLenCode + '-' + 0;
- if (str.length <= 1) {
- return '';
- }
- return str;
- },
- ruleTermCodeStrs: function() {
- const str = this.form.parRuleType + '-' + this.form.parLenCode;
- if (str.length <= 1) {
- return '';
- }
- return str;
- },
- showMsg: function() {
- return (
- this.ruleTermCodeStr.length > 2 &&
- this.msgDict.indexOf(this.ruleTermCodeStr) > -1
- );
- },
- showMsg2: function() {
- return (
- this.ruleTermCodeStr2.length > 2 &&
- this.msgDict.indexOf(this.ruleTermCodeStr2) > -1
- );
- },
- showHasSub() {
- if (this.ruleTermCodeStrs.length > 2) {
- return this.subDict.indexOf(this.ruleTermCodeStrs) != -1;
- }
- return false;
- },
- checkFirstPlace: function() {
- return this.dict.indexOf(this.ruleTermCodeStrs) > -1;
- }
- },
- components: { AddNewRuleTable }
- };
- </script>
|