AddNewRule.vue 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090
  1. <style lang="less" scoped>
  2. // @import "../../less/admin.less";
  3. #AddRuleContent {
  4. width: 100%;
  5. min-width: 1000px;
  6. padding: 20px;
  7. padding-top: 50px;
  8. padding-bottom: 0;
  9. box-sizing: border-box;
  10. .table_form {
  11. width: 100%;
  12. box-sizing: border-box;
  13. background: #fff;
  14. padding: 20px;
  15. padding-bottom: 0;
  16. display: flex;
  17. flex-wrap: wrap;
  18. .table_cell {
  19. flex: 1;
  20. min-width: 25%;
  21. }
  22. }
  23. /deep/ .el-input--mini .el-input__inner,
  24. .el-select {
  25. width: 100%;
  26. font-size: 14px;
  27. }
  28. .tip_text {
  29. // margin-top: -8px;
  30. font-size: 12px;
  31. color: red;
  32. line-height: 16px;
  33. // transform: scale(.8, .8);
  34. }
  35. .form_btn {
  36. width: 100%;
  37. background: #fff;
  38. padding-bottom: 20px;
  39. text-align: center;
  40. }
  41. /deep/ .el-form-item.is-success .el-input__inner,
  42. .el-form-item.is-success .el-textarea__inner {
  43. border-color: #c9c9c9 !important;
  44. }
  45. /deep/ .el-form-item.is-success .el-textarea__inner {
  46. border-color: #c9c9c9 !important;
  47. }
  48. /deep/ .el-form-item.is-success .el-textarea__inner {
  49. border-color: #c9c9c9 !important;
  50. }
  51. .my_error {
  52. position: absolute;
  53. top: 0;
  54. left: -16px;
  55. img {
  56. width: 12px;
  57. height: 12px;
  58. cursor: pointer;
  59. }
  60. }
  61. }
  62. </style>
  63. <style lang="less">
  64. .popper_class {
  65. // background: #fff !important;
  66. border: 1px solid #ffa0a0 !important;
  67. color: #999999 !important;
  68. padding: 3px 50px 3px 10px !important;
  69. margin-left: -10px;
  70. }
  71. .popper__arrow {
  72. border-top-color: #ffa0a0 !important;
  73. }
  74. </style>
  75. <template>
  76. <div>
  77. <crumbs :title="title" :param="$route.params" linkTo="ZskRuleManager"></crumbs>
  78. <div id="AddRuleContent">
  79. <el-form size="mini" :model="form" ref="ruleForm">
  80. <div class="table_form">
  81. <div class="table_cell">
  82. <!-- 规则名称 -->
  83. <el-form-item
  84. label-width="130px"
  85. label="规则名称:"
  86. :rules="rules.parDescription"
  87. prop="parDescription"
  88. >
  89. <el-input style="width: 100%" v-model.trim="form.parDescription" />
  90. </el-form-item>
  91. </div>
  92. <div class="table_cell">
  93. <!-- 规则类型 -->
  94. <el-form-item
  95. label-width="130px"
  96. label="规则类型:"
  97. :rules="rules.parRuleType"
  98. prop="parRuleType"
  99. >
  100. <el-select v-model="form.parRuleType" placeholder="请选择" @change="ruleTypeChange">
  101. <el-option
  102. v-for="item in ruleTypeList"
  103. :key="item.id"
  104. :label="item.name"
  105. :value="item.id"
  106. ></el-option>
  107. </el-select>
  108. <template slot="error" slot-scope="scope">
  109. <div class="my_error">
  110. <el-tooltip
  111. class="item"
  112. effect="light"
  113. :content="scope.error"
  114. placement="top-start"
  115. popper-class="popper_class"
  116. >
  117. <img src="../../images/exclamationpoint.png" alt />
  118. </el-tooltip>
  119. </div>
  120. </template>
  121. <div class="tip_text">注:更改规则类型,将会清空已填写的规则内容~</div>
  122. </el-form-item>
  123. </div>
  124. <div class="table_cell">
  125. <!-- 规则术语类型: -->
  126. <el-form-item
  127. label-width="130px"
  128. label="规则术语类型:"
  129. :rules="rules.parLenCode"
  130. prop="parLenCode"
  131. >
  132. <template slot="error" slot-scope="scope">
  133. <div class="my_error">
  134. <el-tooltip
  135. class="item"
  136. effect="light"
  137. :content="scope.error"
  138. placement="top-start"
  139. popper-class="popper_class"
  140. >
  141. <img src="../../images/exclamationpoint.png" alt />
  142. </el-tooltip>
  143. </div>
  144. </template>
  145. <el-select v-model="form.parLenCode" placeholder="请选择" @change="ruleTermChange">
  146. <el-option
  147. v-for="item in ruleTermTypeList"
  148. :key="item.id"
  149. :label="item.name"
  150. :value="item.code"
  151. ></el-option>
  152. </el-select>
  153. <div class="tip_text">注:更改规则术语类型,将会清空已填写的规则内容~</div>
  154. </el-form-item>
  155. </div>
  156. <div class="table_cell">
  157. <el-form-item
  158. label-width="130px"
  159. label="医学标准术语:"
  160. :style="{ height: '100%' }"
  161. :rules="rules.parConceptId"
  162. prop="parConceptId"
  163. >
  164. <el-select
  165. clearable
  166. filterable
  167. remote
  168. :remote-method="searchConcept"
  169. v-model.trim="form.parConceptId"
  170. @change="parConceptIdChange"
  171. >
  172. <el-option
  173. v-for="item in conceptList"
  174. :key="item.conceptId"
  175. :label="item.conceptName"
  176. :value="item.conceptId"
  177. :title="item.conceptName"
  178. ></el-option>
  179. </el-select>
  180. </el-form-item>
  181. </div>
  182. <div class="table_cell" v-if="showHasSub" style="max-width: 25%">
  183. <el-form-item
  184. label-width="130px"
  185. label="有无子条件:"
  186. :rules="rules.parHasSub"
  187. prop="parHasSub"
  188. >
  189. <el-select v-model="form.parHasSub" placeholder="请选择" @change="hasSubChange">
  190. <el-option label="有" :value="1"></el-option>
  191. <el-option label="无" :value="0"></el-option>
  192. </el-select>
  193. </el-form-item>
  194. </div>
  195. <!-- <div
  196. class="table_cell"
  197. style="flex: 3; max-width: 50%"
  198. v-if="showMsg"
  199. >
  200. <el-form-item
  201. label-width="130px"
  202. label="附加信息:"
  203. :rules="rules.parMsg"
  204. prop="parMsg"
  205. >
  206. <el-input
  207. type="textarea"
  208. :rows="1"
  209. placeholder="请输入附加信息"
  210. v-model.trim="form.parMsg"
  211. ></el-input>
  212. </el-form-item>
  213. </div>-->
  214. </div>
  215. <!-- 表格 -->
  216. <AddNewRuleTable
  217. ref="tableView"
  218. v-if="form.parHasSub && tableShow"
  219. :klRuleByIdSub="form.klRuleByIdSub"
  220. :maxNum="subRuleMaxNum"
  221. :showMsg="showMsg"
  222. :showMsg2="showMsg2"
  223. :ruleTermCodeStr="ruleTermCodeStr"
  224. @subTypeChange="subTypeChange"
  225. @searchConcept="searchConcept"
  226. @addGroup="addGroup"
  227. @delGroup="delGroup"
  228. @delGroupChild="delGroupChild"
  229. @setFormData="setFormData"
  230. @editKlRuleByIdSub="editKlRuleByIdSub"
  231. @clearValidate="clearValidate"
  232. @childClearConcept="childClearConcept"
  233. @childClearNumText="childClearNumText"
  234. @ChildDataTypeChange="ChildDataTypeChange"
  235. @childSubCodeChange="childSubCodeChange"
  236. />
  237. <el-form-item>
  238. <div class="form_btn">
  239. <el-button type="primary" size="medium " @click="submitForm('ruleForm')">确定</el-button>
  240. </div>
  241. </el-form-item>
  242. </el-form>
  243. </div>
  244. </div>
  245. </template>
  246. <script type="text/javascript">
  247. import api from '@api/knowledgeLib.js';
  248. import { formRules } from './rules';
  249. import AddNewRuleTable from './AddNewRuleTable';
  250. export default {
  251. name: 'AddRule',
  252. data() {
  253. return {
  254. title: '规则维护-添加规则',
  255. ruleTypeList: [], //规则类型列表 1
  256. ruleTermTypeList: [], //规则术语类型列表 2
  257. conceptList: [], //医学标准术语列表 3
  258. baseTypeList: [], //基础规则类型列表 4
  259. baseTermTypeList: [], //基础规则术语类型 5
  260. subRuleMaxNum: null, //规则内容中规则的限制个数
  261. isCopy: false,
  262. parId: null,
  263. msgDict: '', //显示附加信息的类型
  264. firstPlace: null,
  265. tableShow: true,
  266. form: {
  267. parDescription: '',
  268. parRuleType: '',
  269. parConceptId: '',
  270. parlibName: '',
  271. parLenName: '',
  272. parHasSub: undefined,
  273. parLenCode: '',
  274. klRuleByIdSub: []
  275. },
  276. rules: formRules,
  277. dragVal: null,
  278. dragArr: null
  279. };
  280. },
  281. created() {
  282. this.getTypeList();
  283. this.setDict();
  284. const param = this.$route.params;
  285. let info = param.data;
  286. if (info) {
  287. this.parId = info.parId;
  288. this.isCopy = param.copy;
  289. this.title = '规则维护-' + (this.isCopy ? '复制' : '修改') + '规则';
  290. this.form = JSON.parse(JSON.stringify(info));
  291. // 编辑初始化选择框
  292. this.initEdidData();
  293. }
  294. },
  295. methods: {
  296. clearValidate(data) {
  297. this.$refs.ruleForm.clearValidate(data);
  298. },
  299. // 编辑初始化
  300. async initEdidData() {
  301. // 规则术语类型初始化
  302. const newruleTermTypeList = await this.ruleTypeList.find(
  303. it => it.id == this.form.parRuleType
  304. );
  305. this.ruleTermTypeList = await newruleTermTypeList.subMenuList;
  306. // 基础规则类型初始化
  307. const obj = await this.ruleTermTypeList.find(
  308. it1 => it1.code == this.form.parLenCode
  309. );
  310. this.baseTypeList = obj.subMenuList;
  311. this.subRuleMaxNum = obj.number;
  312. this.conceptList = [
  313. { conceptName: this.form.parlibName, conceptId: this.form.parConceptId }
  314. ];
  315. if (this.form.parConceptId && this.checkFirstPlace && this.conceptList) {
  316. this.firstPlace = this.conceptList.find(
  317. it => it.conceptId === this.form.parConceptId
  318. );
  319. if (this.firstPlace) {
  320. this.firstPlace['checkedType'] = this.ruleTermCodeStrs;
  321. }
  322. } else if (!this.form.parConceptId) {
  323. this.setInitGroupData();
  324. this.firstPlace = null;
  325. } else {
  326. this.firstPlace = null;
  327. }
  328. await this.form.klRuleByIdSub.forEach((item, i, arr) => {
  329. item.groupId = 'groupId' + item.groupType;
  330. item.groupChildId = 'child' + item.subId;
  331. //TODO => 赋值时一定要注意set更新页面
  332. this.$set(item, 'baseTypes', [...this.baseTypeList]);
  333. this.$set(
  334. item,
  335. 'baseTermTypeList',
  336. item.baseTypes.find(it2 => it2.type === item.subType).subMenuList
  337. );
  338. this.$set(item, 'conceptList', [
  339. {
  340. conceptName: item.subLibName || item.subConceptName,
  341. conceptId: item.subConceptId
  342. }
  343. ]);
  344. if (item.subMaxOperator || item.subMinOperator) {
  345. item.dataType = '1';
  346. } else if (item.subEqValue) {
  347. item.dataType = '2';
  348. }
  349. // disable
  350. if (this.form.parHasSub && this.firstPlace) {
  351. const del =
  352. localStorage
  353. .getItem('zskDelDict')
  354. .match(
  355. new RegExp(this.firstPlace.checkedType + '-\\d+' + '-\\d+', 'g')
  356. ) || [];
  357. if (arr[i - 1] && arr[i - 1].groupId == item.groupId) {
  358. this.$set(item, 'disabled', false);
  359. if (del.length > 0 && item.subType == del[0].split('-')[2]) {
  360. const delType = del[0].split('-');
  361. const types = del[0].split('-');
  362. let baseTypeList = JSON.parse(JSON.stringify(this.baseTypeList));
  363. const subobj = this.baseTypeList.find(it => it.type == types[2]);
  364. const screenArr = subobj.subMenuList.filter(item => {
  365. return !types[3].includes(item.code);
  366. });
  367. this.$set(item, 'baseTermTypeList', screenArr);
  368. }
  369. } else {
  370. this.$set(item, 'disabled', true);
  371. }
  372. }
  373. const dragDel =
  374. localStorage
  375. .getItem('zskDragDict')
  376. .match(new RegExp(this.ruleTermCodeStrs, 'g')) || [];
  377. //药品开单合理判断
  378. if (dragDel.length > 0) {
  379. const obj = this.baseTypeList.find(it => it.type === 1);
  380. if (arr[i - 1] && arr[i - 1].groupId == item.groupId) {
  381. let klRuleByIdSub = this.form.klRuleByIdSub;
  382. klRuleByIdSub.forEach((item, i, arr) => {
  383. if (arr[0].subType == 1) {
  384. const arr = this.baseTypeList.filter(it => {
  385. return it.type == 1;
  386. });
  387. if (i > 0) {
  388. this.$set(item, 'baseTypes', arr);
  389. }
  390. }
  391. });
  392. if (i == 2) {
  393. //获取互斥项code
  394. const list = obj.subMenuList.filter(it => {
  395. return (
  396. it.code == arr[i - 1].subLenCode &&
  397. it.remark.split('|')[0] == 3
  398. );
  399. });
  400. const dragArr = list[0].remark.split('|')[1].split(',');
  401. this.dragArr = dragArr;
  402. this.dragVal = item.subLenCode;
  403. //取出互斥项
  404. const screenArr = obj.subMenuList.filter(item =>
  405. dragArr.some(
  406. ele => ele === item.code && item.remark.split('|')[0] == 3
  407. )
  408. );
  409. this.$set(item, 'baseTermTypeList', screenArr);
  410. } else {
  411. const screenArr = obj.subMenuList.filter(item => {
  412. if (item.remark == '') {
  413. return item;
  414. } else {
  415. return item.remark.split('|')[0] == i + 1;
  416. }
  417. });
  418. this.$set(item, 'baseTermTypeList', screenArr);
  419. }
  420. }
  421. }
  422. });
  423. },
  424. // 提交
  425. submitForm(formName) {
  426. this.$refs[formName].validate(valid => {
  427. if (valid) {
  428. let params = JSON.parse(JSON.stringify(this.form));
  429. params.klRuleInfoSaveSub = params.klRuleByIdSub;
  430. delete params.klRuleByIdSub;
  431. params.klRuleInfoSaveSub.forEach((item, i, arr) => {
  432. if (i === 0) {
  433. item.groupType = 1;
  434. } else {
  435. if (item.groupId == arr[i - 1].groupId) {
  436. item.groupType = arr[i - 1].groupType;
  437. item.subMsg = arr[i - 1].subMsg;
  438. } else {
  439. item.groupType = arr[i - 1].groupType + 1;
  440. }
  441. }
  442. });
  443. params.klRuleInfoSaveSub.forEach(ite => {
  444. delete ite.groupId;
  445. delete ite.groupChildId;
  446. delete ite.rowIndex;
  447. delete ite.baseTypes;
  448. delete ite.baseTermTypeList;
  449. delete ite.conceptList;
  450. });
  451. if (this.parId) {
  452. params.parId = this.isCopy ? undefined : this.parId;
  453. params.parStatus = this.isCopy ? 1 : this.form.parStatus;
  454. }
  455. this.saveRule(params);
  456. } else {
  457. return false;
  458. }
  459. });
  460. },
  461. // 子集修改父级的数组
  462. setFormData(index, data) {
  463. this.$set(this.form.klRuleByIdSub[index], 'conceptList', data);
  464. },
  465. // table_form 规则类型选中
  466. ruleTypeChange(val) {
  467. this.form.parLenCode = '';
  468. const obj = this.ruleTypeList.find(it => it.id === val);
  469. this.ruleTermTypeList = obj.subMenuList;
  470. this.subRuleMaxNum = undefined;
  471. this.setInitGroupData();
  472. },
  473. // table_form 规则术语类型选中
  474. ruleTermChange(val) {
  475. const obj = this.ruleTermTypeList.find(it => it.code === val);
  476. this.form.parLenName = obj.name;
  477. this.baseTypeList = obj.subMenuList;
  478. this.subRuleMaxNum = obj.number;
  479. this.form.parHasSub = obj.subMenuList.length ? 1 : 0;
  480. this.setInitGroupData();
  481. },
  482. // 医学标准术语
  483. parConceptIdChange(val) {
  484. this.$nextTick(() => {
  485. if (val && this.checkFirstPlace && this.conceptList) {
  486. this.firstPlace = this.conceptList.find(it => it.conceptId === val);
  487. if (this.firstPlace) {
  488. this.firstPlace['checkedType'] = this.ruleTermCodeStrs;
  489. }
  490. } else if (!val) {
  491. this.setInitGroupData();
  492. this.firstPlace = null;
  493. } else {
  494. this.firstPlace = null;
  495. }
  496. if (this.form.parHasSub && this.firstPlace) {
  497. const dict =
  498. localStorage
  499. .getItem('zskDicts')
  500. .match(new RegExp(this.firstPlace.checkedType + '-\\d+', 'g')) ||
  501. [];
  502. const del =
  503. localStorage
  504. .getItem('zskDelDict')
  505. .match(
  506. new RegExp(this.firstPlace.checkedType + '-\\d+' + '-\\d+', 'g')
  507. ) || [];
  508. const types = dict[0].split('-');
  509. let obj = this.form.klRuleByIdSub;
  510. obj.forEach((item, i, arr) => {
  511. if (arr[i - 1] && arr[i - 1].groupId == item.groupId) {
  512. this.$set(item, 'disabled', false);
  513. if (del.length > 0) {
  514. const delType = del[0].split('-');
  515. if (
  516. item.subType == delType[2] ||
  517. item.subLenCode == delType[3]
  518. ) {
  519. this.$set(this.form.klRuleByIdSub, i, {
  520. groupId: item.groupId,
  521. groupChildId: 'child' + new Date().valueOf(),
  522. baseTypes: this.baseTypeList,
  523. baseTermTypeList: [],
  524. conceptList: [],
  525. subDescription: '',
  526. parRuleType: '',
  527. subConceptId: '',
  528. subType: '',
  529. subMaxOperator: '',
  530. subMaxUnit: '',
  531. subMaxValue: '',
  532. subMinOperator: '',
  533. subMinUnit: '',
  534. subMinValue: '',
  535. subEqValue: '',
  536. subLenCode: '',
  537. dataType: ''
  538. });
  539. }
  540. }
  541. } else {
  542. this.$set(item, 'disabled', true);
  543. this.$set(item, 'subType', parseInt(types[2]));
  544. const subobj = this.baseTypeList.find(it => it.type == types[2]);
  545. this.$set(item, 'baseTermTypeList', subobj.subMenuList);
  546. this.$set(item, 'subLenCode', types[1]);
  547. this.$set(item, 'subDescription', this.firstPlace.conceptName);
  548. this.$set(item, 'subConceptId', this.firstPlace.conceptId);
  549. this.$set(item, 'subConceptName', this.firstPlace.conceptName);
  550. this.$set(item, 'conceptList', [this.firstPlace]);
  551. }
  552. });
  553. this.$set(this.form, 'klRuleByIdSub', obj);
  554. }
  555. });
  556. },
  557. // 初始化表格
  558. setInitGroupData(init) {
  559. this.tableShow = false;
  560. const date = new Date().valueOf();
  561. this.$nextTick(() => {
  562. if (this.form.parHasSub && this.form.parHasSub != 0) {
  563. this.$set(this.form, 'klRuleByIdSub', [
  564. {
  565. groupId: date,
  566. groupChildId: 'child' + new Date().valueOf(),
  567. baseTypes: this.baseTypeList,
  568. baseTermTypeList: [],
  569. conceptList: [],
  570. subDescription: '',
  571. parRuleType: '',
  572. subConceptId: '',
  573. subType: '',
  574. subMaxOperator: '',
  575. subMaxUnit: '',
  576. subMaxValue: '',
  577. subMinOperator: '',
  578. subMinUnit: '',
  579. subMinValue: '',
  580. subEqValue: '',
  581. subLenCode: '',
  582. dataType: ''
  583. }
  584. ]);
  585. } else {
  586. this.$set(this.form, 'klRuleByIdSub', []);
  587. }
  588. if (!init) {
  589. this.form.parConceptId = ''; //医学标准术语清空
  590. this.conceptList = []; //下拉列表清空
  591. this.firstPlace = null;
  592. }
  593. this.tableShow = true;
  594. });
  595. },
  596. // 有无子条件切换
  597. hasSubChange(val) {
  598. if (val) {
  599. this.setInitGroupData(true);
  600. } else {
  601. this.form.klRuleByIdSub = [];
  602. }
  603. },
  604. // 基础规则类型切换
  605. subTypeChange(val, index) {
  606. // index
  607. const dragDel =
  608. localStorage
  609. .getItem('zskDragDict')
  610. .match(new RegExp(this.ruleTermCodeStrs, 'g')) || [];
  611. const obj = this.baseTypeList.find(it => it.type === val);
  612. let dragType = false;
  613. let isDel = false;
  614. let screenArr;
  615. //药品开单合理判断
  616. if (dragDel.length > 0) {
  617. dragType = true;
  618. const types = dragDel[0].split('-');
  619. if (this.dragArr && index > 0) {
  620. //获取互斥项code
  621. const list = obj.subMenuList.filter(it => {
  622. return it.code == this.dragVal && it.remark.split('|')[0] == 3;
  623. });
  624. const dragArr = list[0].remark.split('|')[1].split(',');
  625. this.dragArr = dragArr;
  626. //取出互斥项
  627. screenArr = obj.subMenuList.filter(item =>
  628. dragArr.some(
  629. ele => ele === item.code && item.remark.split('|')[0] == 3
  630. )
  631. );
  632. } else {
  633. screenArr = obj.subMenuList.filter(item => {
  634. if (item.remark == '') {
  635. return item;
  636. } else {
  637. return item.remark.split('|')[0] == index + 1;
  638. }
  639. });
  640. }
  641. let klRuleByIdSub = this.form.klRuleByIdSub;
  642. klRuleByIdSub.forEach((item, i, arr) => {
  643. if (arr[0].subType == 1) {
  644. const arr = this.baseTypeList.filter(it => {
  645. return it.type == 1;
  646. });
  647. if (i > 0) {
  648. this.$set(item, 'baseTypes', arr);
  649. }
  650. }
  651. });
  652. }
  653. //危急值实验室子项目已选医学标准术语判断
  654. if (this.form.parHasSub && this.firstPlace) {
  655. const del =
  656. localStorage
  657. .getItem('zskDelDict')
  658. .match(
  659. new RegExp(this.firstPlace.checkedType + '-\\d+' + '-\\d+', 'g')
  660. ) || [];
  661. if (del.length > 0) {
  662. isDel = true;
  663. const types = del[0].split('-');
  664. let baseTypeList = JSON.parse(JSON.stringify(this.baseTypeList));
  665. const subobj = this.baseTypeList.find(it => it.type == types[2]);
  666. screenArr = subobj.subMenuList.filter(item => {
  667. return !types[3].includes(item.code);
  668. });
  669. }
  670. }
  671. this.$set(
  672. this.form.klRuleByIdSub[index],
  673. 'baseTermTypeList',
  674. (isDel && val == 2) || dragType ? screenArr : obj.subMenuList
  675. );
  676. this.$set(this.form.klRuleByIdSub[index], 'subLenCode', '');
  677. this.$set(this.form.klRuleByIdSub[index], 'dataType', '');
  678. this.clearConcept(index);
  679. this.clearNumText(index);
  680. },
  681. clearConcept(index) {
  682. this.$set(this.form.klRuleByIdSub[index], 'subConceptId', '');
  683. this.conceptList = [];
  684. },
  685. clearNumText(index) {
  686. this.$set(this.form.klRuleByIdSub[index], 'subMaxOperator', '');
  687. this.$set(this.form.klRuleByIdSub[index], 'subMaxValue', '');
  688. this.$set(this.form.klRuleByIdSub[index], 'subMaxUnit', '');
  689. this.$set(this.form.klRuleByIdSub[index], 'subMinOperator', '');
  690. this.$set(this.form.klRuleByIdSub[index], 'subMinValue', '');
  691. this.$set(this.form.klRuleByIdSub[index], 'subMinUnit', '');
  692. this.$set(this.form.klRuleByIdSub[index], 'subEqValue', '');
  693. this.$set(this.form.klRuleByIdSub[index], 'subEqOperator', '');
  694. },
  695. editKlRuleByIdSub(data) {
  696. this.$set(this.form, 'klRuleByIdSub', data);
  697. // this.form.klRuleByIdSub = data;
  698. },
  699. // 添加分组 || 规则
  700. addGroup(date, arg = { index: null, groupId: null }) {
  701. /**
  702. * @params
  703. * date:存在则添加规则 不存在则添加分组
  704. * arg:{index:添加规则用索引,groupId:添加分组用确切id}
  705. */
  706. !date && (date = new Date().valueOf());
  707. const obj = {
  708. groupId: date,
  709. groupChildId: 'child' + new Date().valueOf(),
  710. baseTypes: this.baseTypeList,
  711. baseTermTypeList: [],
  712. conceptList: [],
  713. subDescription: '',
  714. parRuleType: '',
  715. subConceptId: '',
  716. subType: '',
  717. subMaxOperator: '',
  718. subMaxUnit: '',
  719. subMaxValue: '',
  720. subMinOperator: '',
  721. subMinUnit: '',
  722. subMinValue: '',
  723. subEqValue: '',
  724. subLenCode: '',
  725. dataType: ''
  726. };
  727. if (typeof arg.index == 'number') {
  728. // 添加规则 直接在当前位置之后添加
  729. this.form.klRuleByIdSub.splice(arg.index + 1, 0, obj);
  730. const dragDel =
  731. localStorage
  732. .getItem('zskDragDict')
  733. .match(new RegExp(this.ruleTermCodeStrs, 'g')) || [];
  734. if (dragDel.length > 0) {
  735. let obj = this.form.klRuleByIdSub;
  736. obj.forEach((item, i, arr) => {
  737. if (arr[0].subType == 1) {
  738. const arr = this.baseTypeList.filter(it => {
  739. return it.type == 1;
  740. });
  741. if (i > 0) {
  742. this.$set(item, 'baseTypes', arr);
  743. }
  744. }
  745. });
  746. }
  747. } else {
  748. // 添加分组 在列表中相同groupId之后添加
  749. // 添加分组时判断是否需要加disabled和添加默认值
  750. if (this.form.parHasSub && this.firstPlace) {
  751. obj.disabled = true;
  752. const dict =
  753. localStorage
  754. .getItem('zskDicts')
  755. .match(new RegExp(this.firstPlace.checkedType + '-\\d+', 'g')) ||
  756. [];
  757. const types = dict[0].split('-');
  758. this.$set(obj, 'disabled', true);
  759. this.$set(obj, 'subType', parseInt(types[2]));
  760. const subobj = this.baseTypeList.find(it => it.type == types[2]);
  761. this.$set(obj, 'baseTermTypeList', subobj.subMenuList);
  762. this.$set(obj, 'subLenCode', types[1]);
  763. this.$set(obj, 'subDescription', this.firstPlace.conceptName);
  764. this.$set(obj, 'subConceptId', this.firstPlace.conceptId);
  765. this.$set(obj, 'subConceptName', this.firstPlace.conceptName);
  766. this.$set(obj, 'conceptList', [this.firstPlace]);
  767. }
  768. var i = -1;
  769. this.form.klRuleByIdSub.forEach((item, inx) => {
  770. if (item.groupId === arg.groupId) {
  771. i = inx;
  772. }
  773. });
  774. this.form.klRuleByIdSub.splice(i + 1, 0, obj);
  775. }
  776. this.$nextTick(() => {
  777. this.$refs.tableView.scrollFun();
  778. });
  779. },
  780. // 删除分组
  781. delGroup(groupId) {
  782. const list = this.form.klRuleByIdSub.filter(
  783. item => item.groupId != groupId
  784. );
  785. this.form.klRuleByIdSub = list;
  786. },
  787. // 删除规则
  788. delGroupChild(groupChildId, index) {
  789. let newGroupList;
  790. const dragDel =
  791. localStorage
  792. .getItem('zskDragDict')
  793. .match(new RegExp(this.ruleTermCodeStrs, 'g')) || [];
  794. let list;
  795. if (dragDel.length > 0) {
  796. if (index == 0) {
  797. const date = new Date().valueOf();
  798. newGroupList = [
  799. {
  800. groupId: date,
  801. groupChildId: 'child' + new Date().valueOf(),
  802. baseTypes: this.baseTypeList,
  803. baseTermTypeList: [],
  804. conceptList: [],
  805. subDescription: '',
  806. parRuleType: '',
  807. subConceptId: '',
  808. subType: '',
  809. subMaxOperator: '',
  810. subMaxUnit: '',
  811. subMaxValue: '',
  812. subMinOperator: '',
  813. subMinUnit: '',
  814. subMinValue: '',
  815. subEqValue: '',
  816. subLenCode: '',
  817. dataType: ''
  818. }
  819. ];
  820. } else if (index == 0 || index == 1) {
  821. newGroupList = this.form.klRuleByIdSub.filter((item, i) => {
  822. return i == 0;
  823. });
  824. } else {
  825. newGroupList = this.form.klRuleByIdSub.filter(
  826. item => item.groupChildId != groupChildId
  827. );
  828. }
  829. } else {
  830. newGroupList = this.form.klRuleByIdSub.filter(
  831. item => item.groupChildId != groupChildId
  832. );
  833. }
  834. this.form.klRuleByIdSub = newGroupList;
  835. },
  836. setDict() {
  837. this.dict = localStorage.getItem('zskDicts');
  838. this.msgDict = localStorage.getItem('zskMsgDict');
  839. this.subDict = localStorage.getItem('zskSubDict');
  840. },
  841. showConfirmDialog(msg, resolve) {
  842. this.$alert(msg, '提示', {
  843. confirmButtonText: '确定',
  844. type: 'warning'
  845. })
  846. .then(() => {
  847. resolve();
  848. })
  849. .catch(() => {});
  850. },
  851. searchConcept(val) {
  852. const param = {
  853. excludedConceptIds: [this.form.parRuleType],
  854. libType: this.form.parLenCode,
  855. name: val
  856. };
  857. api
  858. .searchConcept(param)
  859. .then(res => {
  860. if (res.data.code == '0') {
  861. const data = res.data.data;
  862. this.conceptList = data;
  863. }
  864. })
  865. .catch(error => {
  866. console.log(error);
  867. });
  868. },
  869. getTypeList() {
  870. this.ruleTypeList = JSON.parse(localStorage.getItem('zskTypesList'));
  871. },
  872. saveRule(params) {
  873. api.saveRule(params).then(res => {
  874. if (res.data.code == 0) {
  875. this.$message({
  876. message: '操作成功',
  877. type: 'success'
  878. });
  879. this.$router.push({
  880. name: 'ZskRuleManager',
  881. params: Object.assign({}, this.$route.params, { currentPage: 1 })
  882. });
  883. } else {
  884. this.$message({
  885. message: res.data.msg,
  886. type: 'warning'
  887. });
  888. }
  889. });
  890. },
  891. /**
  892. * 子组件调用方法
  893. */
  894. childClearConcept(index) {
  895. this.$set(this.form.klRuleByIdSub[index], 'subConceptId', '');
  896. this.$set(this.form.klRuleByIdSub[index], 'conceptList', []);
  897. },
  898. childClearNumText(index) {
  899. let obj = JSON.parse(JSON.stringify(this.form.klRuleByIdSub));
  900. obj[index].subMaxOperator = '';
  901. obj[index].subMaxValue = '';
  902. obj[index].subMaxUnit = '';
  903. obj[index].subMinOperator = '';
  904. obj[index].subMinValue = '';
  905. obj[index].subMinUnit = '';
  906. obj[index].subEqValue = '';
  907. // this.$set(obj[index], "subEqValue", "");
  908. obj[index].subEqOperator = '';
  909. // this.klRuleByIdSub = obj;
  910. // this.$emit("editKlRuleByIdSub", obj);
  911. this.editKlRuleByIdSub(obj);
  912. },
  913. ChildDataTypeChange(val, index) {
  914. this.form.klRuleByIdSub[index].subEqOperator = val === '2' ? '=' : '';
  915. this.$set(
  916. this.form.klRuleByIdSub[index],
  917. 'subEqOperator',
  918. val === '2' ? '=' : ''
  919. );
  920. this.childClearNumText(index);
  921. // TODO 新增的内容追踪不到
  922. this.form.klRuleByIdSub.forEach((item, i) => {
  923. if (index === i) {
  924. this.$set(item, 'dataType', val);
  925. }
  926. });
  927. },
  928. childSubCodeChange(val, index, numTypes) {
  929. const dragDel =
  930. localStorage
  931. .getItem('zskDragDict')
  932. .match(new RegExp(this.ruleTermCodeStrs, 'g')) || [];
  933. const inx = index == 1 ? index + 1 : index == 2 ? index - 1 : index;
  934. const subobj = this.baseTypeList.find(it => it.type == 1);
  935. let obj = this.form.klRuleByIdSub;
  936. const mutex = obj.some((item, i, arr) => {
  937. return item.subLenCode == '';
  938. });
  939. //判断药品合理性总条数是否大于1条,是否存在第二条或第三条类型为1,存在触发互斥
  940. if (
  941. //判断3条规则是否都已选中
  942. dragDel.length > 0 &&
  943. index > 0 &&
  944. this.form.klRuleByIdSub.length > 1 &&
  945. this.form.klRuleByIdSub[0].subType == 1
  946. ) {
  947. if (this.form.klRuleByIdSub.length == 3 && !mutex) {
  948. //判断是否存在符合互斥条件的两条出具,若存在,置空另一条出具
  949. if (this.dragArr.indexOf(this.dragVal) > -1) {
  950. //剂型给药途径互斥判断
  951. const arr = this.baseTypeList.filter(it => {
  952. return it.type == 1;
  953. });
  954. this.$set(this.form.klRuleByIdSub, inx, {
  955. groupId: this.form.klRuleByIdSub[inx].groupId,
  956. groupChildId: 'child' + new Date().valueOf(),
  957. baseTypes: arr,
  958. baseTermTypeList: [],
  959. conceptList: [],
  960. subDescription: '',
  961. parRuleType: '',
  962. subConceptId: '',
  963. subType: '',
  964. subMaxOperator: '',
  965. subMaxUnit: '',
  966. subMaxValue: '',
  967. subMinOperator: '',
  968. subMinUnit: '',
  969. subMinValue: '',
  970. subEqValue: '',
  971. subLenCode: '',
  972. dataType: ''
  973. });
  974. }
  975. } else {
  976. const list = subobj.subMenuList.filter(it => {
  977. return it.code == val && it.remark.split('|')[0] == 3;
  978. });
  979. //获取互斥项code
  980. const dragArr = list[0].remark.split('|')[1].split(',');
  981. this.dragArr = dragArr;
  982. //获取互斥项
  983. const screenArr = subobj.subMenuList.filter(item =>
  984. dragArr.some(
  985. ele => ele === item.code && item.remark.split('|')[0] == 3
  986. )
  987. );
  988. if (this.form.klRuleByIdSub[inx]) {
  989. this.$set(
  990. this.form.klRuleByIdSub[inx],
  991. 'baseTermTypeList',
  992. screenArr
  993. );
  994. }
  995. }
  996. this.dragVal = val;
  997. }
  998. if ((numTypes + ',').indexOf(val + ',') > -1) {
  999. this.$set(this.form.klRuleByIdSub[index], 'dataType', '1');
  1000. } else {
  1001. this.$set(this.form.klRuleByIdSub[index], 'dataType', '');
  1002. }
  1003. this.childClearConcept(index);
  1004. this.childClearNumText(index);
  1005. },
  1006. // 去重
  1007. unique(arr, obj) {
  1008. return arr.reduce((cur, next) => {
  1009. obj[next] ? '' : (obj[next] = true && cur.push(next));
  1010. return cur;
  1011. }, []);
  1012. }
  1013. },
  1014. watch: {
  1015. 'form.klRuleByIdSub': {
  1016. handler(val) {
  1017. this.form.klRuleByIdSub.forEach((item, i, arr) => {
  1018. if (i == 0) {
  1019. item.rowIndex = 1;
  1020. } else if (item.groupId == arr[i - 1].groupId) {
  1021. item.rowIndex = arr[i - 1].rowIndex;
  1022. } else {
  1023. item.rowIndex = arr[i - 1].rowIndex + 1;
  1024. }
  1025. });
  1026. },
  1027. deep: true
  1028. }
  1029. },
  1030. computed: {
  1031. disable: function() {
  1032. return Object.keys(this.firstPlace || {}).length > 0;
  1033. },
  1034. ruleTermCodeStr: function() {
  1035. const str = this.form.parRuleType + '-' + this.form.parLenCode + '-' + 1;
  1036. if (str.length <= 1) {
  1037. return '';
  1038. }
  1039. return str;
  1040. },
  1041. ruleTermCodeStr2: function() {
  1042. const str = this.form.parRuleType + '-' + this.form.parLenCode + '-' + 0;
  1043. if (str.length <= 1) {
  1044. return '';
  1045. }
  1046. return str;
  1047. },
  1048. ruleTermCodeStrs: function() {
  1049. const str = this.form.parRuleType + '-' + this.form.parLenCode;
  1050. if (str.length <= 1) {
  1051. return '';
  1052. }
  1053. return str;
  1054. },
  1055. showMsg: function() {
  1056. return (
  1057. this.ruleTermCodeStr.length > 2 &&
  1058. this.msgDict.indexOf(this.ruleTermCodeStr) > -1
  1059. );
  1060. },
  1061. showMsg2: function() {
  1062. return (
  1063. this.ruleTermCodeStr2.length > 2 &&
  1064. this.msgDict.indexOf(this.ruleTermCodeStr2) > -1
  1065. );
  1066. },
  1067. showHasSub() {
  1068. if (this.ruleTermCodeStrs.length > 2) {
  1069. return this.subDict.indexOf(this.ruleTermCodeStrs) != -1;
  1070. }
  1071. return false;
  1072. },
  1073. checkFirstPlace: function() {
  1074. return this.dict.indexOf(this.ruleTermCodeStrs) > -1;
  1075. }
  1076. },
  1077. components: { AddNewRuleTable }
  1078. };
  1079. </script>