AddNewRule.vue 35 KB

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