AddNewRule.vue 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073
  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. let klRuleByIdSub = this.form.klRuleByIdSub;
  368. klRuleByIdSub.forEach((item, i, arr) => {
  369. if (arr[0].subType == 1) {
  370. const arr = this.baseTypeList.filter(it => {
  371. return it.type == 1;
  372. });
  373. if (i > 0) {
  374. this.$set(item, 'baseTypes', arr);
  375. }
  376. }
  377. });
  378. if (i == 2) {
  379. //获取互斥项code
  380. const list = obj.subMenuList.filter(it => {
  381. return (
  382. it.code == arr[i - 1].subLenCode &&
  383. it.remark.split('|')[0] == 3
  384. );
  385. });
  386. const dragArr = list[0].remark.split('|')[1].split(',');
  387. this.dragArr = dragArr;
  388. this.dragVal = item.subLenCode;
  389. //取出互斥项
  390. const screenArr = obj.subMenuList.filter(item =>
  391. dragArr.some(
  392. ele => ele === item.code && item.remark.split('|')[0] == 3
  393. )
  394. );
  395. this.$set(item, 'baseTermTypeList', screenArr);
  396. } else {
  397. const screenArr = obj.subMenuList.filter(item => {
  398. if (item.remark == '') {
  399. return item;
  400. } else {
  401. return item.remark.split('|')[0] == i + 1;
  402. }
  403. });
  404. this.$set(item, 'baseTermTypeList', screenArr);
  405. }
  406. }
  407. }
  408. });
  409. },
  410. // 提交
  411. submitForm(formName) {
  412. this.$refs[formName].validate(valid => {
  413. if (valid) {
  414. let params = JSON.parse(JSON.stringify(this.form));
  415. params.klRuleInfoSaveSub = params.klRuleByIdSub;
  416. delete params.klRuleByIdSub;
  417. params.klRuleInfoSaveSub.forEach((item, i, arr) => {
  418. if (i === 0) {
  419. item.groupType = 1;
  420. } else {
  421. if (item.groupId == arr[i - 1].groupId) {
  422. item.groupType = arr[i - 1].groupType;
  423. item.subMsg = arr[i - 1].subMsg;
  424. } else {
  425. item.groupType = arr[i - 1].groupType + 1;
  426. }
  427. }
  428. });
  429. params.klRuleInfoSaveSub.forEach(ite => {
  430. delete ite.groupId;
  431. delete ite.groupChildId;
  432. delete ite.rowIndex;
  433. delete ite.baseTypes;
  434. delete ite.baseTermTypeList;
  435. delete ite.conceptList;
  436. });
  437. if (this.parId) {
  438. params.parId = this.isCopy ? undefined : this.parId;
  439. params.parStatus = this.isCopy ? 1 : this.form.parStatus;
  440. }
  441. this.saveRule(params);
  442. } else {
  443. return false;
  444. }
  445. });
  446. },
  447. // 子集修改父级的数组
  448. setFormData(index, data) {
  449. this.$set(this.form.klRuleByIdSub[index], 'conceptList', data);
  450. },
  451. // table_form 规则类型选中
  452. ruleTypeChange(val) {
  453. this.form.parLenCode = '';
  454. const obj = this.ruleTypeList.find(it => it.id === val);
  455. this.ruleTermTypeList = obj.subMenuList;
  456. this.subRuleMaxNum = undefined;
  457. this.setInitGroupData();
  458. },
  459. // table_form 规则术语类型选中
  460. ruleTermChange(val) {
  461. const obj = this.ruleTermTypeList.find(it => it.code === val);
  462. this.form.parLenName = obj.name;
  463. this.baseTypeList = obj.subMenuList;
  464. this.subRuleMaxNum = obj.number;
  465. this.form.parHasSub = obj.subMenuList.length ? 1 : 0;
  466. this.setInitGroupData();
  467. },
  468. // 医学标准术语
  469. parConceptIdChange(val) {
  470. this.$nextTick(() => {
  471. if (val && this.checkFirstPlace && this.conceptList) {
  472. this.firstPlace = this.conceptList.find(it => it.conceptId === val);
  473. if (this.firstPlace) {
  474. this.firstPlace['checkedType'] = this.ruleTermCodeStrs;
  475. }
  476. } else if (!val) {
  477. this.setInitGroupData();
  478. this.firstPlace = null;
  479. } else {
  480. this.firstPlace = null;
  481. }
  482. if (this.form.parHasSub && this.firstPlace) {
  483. const dict =
  484. localStorage
  485. .getItem('zskDicts')
  486. .match(new RegExp(this.firstPlace.checkedType + '-\\d+', 'g')) ||
  487. [];
  488. const del =
  489. localStorage
  490. .getItem('zskDelDict')
  491. .match(
  492. new RegExp(this.firstPlace.checkedType + '-\\d+' + '-\\d+', 'g')
  493. ) || [];
  494. const types = dict[0].split('-');
  495. let obj = this.form.klRuleByIdSub;
  496. obj.forEach((item, i, arr) => {
  497. if (arr[i - 1] && arr[i - 1].groupId == item.groupId) {
  498. this.$set(item, 'disabled', false);
  499. if (del.length > 0) {
  500. const delType = del[0].split('-');
  501. if (
  502. item.subType == delType[2] ||
  503. item.subLenCode == delType[3]
  504. ) {
  505. this.$set(this.form.klRuleByIdSub, i, {
  506. groupId: item.groupId,
  507. groupChildId: 'child' + new Date().valueOf(),
  508. baseTypes: this.baseTypeList,
  509. baseTermTypeList: [],
  510. conceptList: [],
  511. subDescription: '',
  512. parRuleType: '',
  513. subConceptId: '',
  514. subType: '',
  515. subMaxOperator: '',
  516. subMaxUnit: '',
  517. subMaxValue: '',
  518. subMinOperator: '',
  519. subMinUnit: '',
  520. subMinValue: '',
  521. subEqValue: '',
  522. subLenCode: '',
  523. dataType: ''
  524. });
  525. }
  526. }
  527. } else {
  528. this.$set(item, 'disabled', true);
  529. this.$set(item, 'subType', parseInt(types[2]));
  530. const subobj = this.baseTypeList.find(it => it.type == types[2]);
  531. this.$set(item, 'baseTermTypeList', subobj.subMenuList);
  532. this.$set(item, 'subLenCode', types[1]);
  533. this.$set(item, 'subDescription', this.firstPlace.conceptName);
  534. this.$set(item, 'subConceptId', this.firstPlace.conceptId);
  535. this.$set(item, 'subConceptName', this.firstPlace.conceptName);
  536. this.$set(item, 'conceptList', [this.firstPlace]);
  537. }
  538. });
  539. this.$set(this.form, 'klRuleByIdSub', obj);
  540. }
  541. });
  542. },
  543. // 初始化表格
  544. setInitGroupData(init) {
  545. this.tableShow = false;
  546. const date = new Date().valueOf();
  547. this.$nextTick(() => {
  548. if (this.form.parHasSub && this.form.parHasSub != 0) {
  549. this.$set(this.form, 'klRuleByIdSub', [
  550. {
  551. groupId: date,
  552. groupChildId: 'child' + new Date().valueOf(),
  553. baseTypes: this.baseTypeList,
  554. baseTermTypeList: [],
  555. conceptList: [],
  556. subDescription: '',
  557. parRuleType: '',
  558. subConceptId: '',
  559. subType: '',
  560. subMaxOperator: '',
  561. subMaxUnit: '',
  562. subMaxValue: '',
  563. subMinOperator: '',
  564. subMinUnit: '',
  565. subMinValue: '',
  566. subEqValue: '',
  567. subLenCode: '',
  568. dataType: ''
  569. }
  570. ]);
  571. } else {
  572. this.$set(this.form, 'klRuleByIdSub', []);
  573. }
  574. if (!init) {
  575. this.form.parConceptId = ''; //医学标准术语清空
  576. this.conceptList = []; //下拉列表清空
  577. this.firstPlace = null;
  578. }
  579. this.tableShow = true;
  580. });
  581. },
  582. // 有无子条件切换
  583. hasSubChange(val) {
  584. if (val) {
  585. this.setInitGroupData(true);
  586. } else {
  587. this.form.klRuleByIdSub = [];
  588. }
  589. },
  590. // 基础规则类型切换
  591. subTypeChange(val, index) {
  592. // index
  593. const dragDel =
  594. localStorage
  595. .getItem('zskDragDict')
  596. .match(new RegExp(this.ruleTermCodeStrs, 'g')) || [];
  597. const obj = this.baseTypeList.find(it => it.type === val);
  598. let dragType = false;
  599. let isDel = false;
  600. let screenArr;
  601. //药品开单合理判断
  602. if (dragDel.length > 0) {
  603. dragType = true;
  604. const types = dragDel[0].split('-');
  605. if (this.dragArr && index > 0) {
  606. //获取互斥项code
  607. const list = obj.subMenuList.filter(it => {
  608. return it.code == this.dragVal && it.remark.split('|')[0] == 3;
  609. });
  610. const dragArr = list[0].remark.split('|')[1].split(',');
  611. this.dragArr = dragArr;
  612. //取出互斥项
  613. screenArr = obj.subMenuList.filter(item =>
  614. dragArr.some(
  615. ele => ele === item.code && item.remark.split('|')[0] == 3
  616. )
  617. );
  618. } else {
  619. screenArr = obj.subMenuList.filter(item => {
  620. if (item.remark == '') {
  621. return item;
  622. } else {
  623. return item.remark.split('|')[0] == index + 1;
  624. }
  625. });
  626. }
  627. let klRuleByIdSub = this.form.klRuleByIdSub;
  628. klRuleByIdSub.forEach((item, i, arr) => {
  629. if (arr[0].subType == 1) {
  630. const arr = this.baseTypeList.filter(it => {
  631. return it.type == 1;
  632. });
  633. if (i > 0) {
  634. this.$set(item, 'baseTypes', arr);
  635. }
  636. }
  637. });
  638. }
  639. //危急值实验室子项目已选医学标准术语判断
  640. if (this.form.parHasSub && this.firstPlace) {
  641. const del =
  642. localStorage
  643. .getItem('zskDelDict')
  644. .match(
  645. new RegExp(this.firstPlace.checkedType + '-\\d+' + '-\\d+', 'g')
  646. ) || [];
  647. if (del.length > 0) {
  648. isDel = true;
  649. const types = del[0].split('-');
  650. let baseTypeList = JSON.parse(JSON.stringify(this.baseTypeList));
  651. const subobj = this.baseTypeList.find(it => it.type == types[2]);
  652. screenArr = subobj.subMenuList.filter(item => {
  653. return !types[3].includes(item.code);
  654. });
  655. }
  656. }
  657. this.$set(
  658. this.form.klRuleByIdSub[index],
  659. 'baseTermTypeList',
  660. (isDel && val == 2) || dragType ? screenArr : obj.subMenuList
  661. );
  662. this.$set(this.form.klRuleByIdSub[index], 'subLenCode', '');
  663. this.$set(this.form.klRuleByIdSub[index], 'dataType', '');
  664. this.clearConcept(index);
  665. this.clearNumText(index);
  666. },
  667. clearConcept(index) {
  668. this.$set(this.form.klRuleByIdSub[index], 'subConceptId', '');
  669. this.conceptList = [];
  670. },
  671. clearNumText(index) {
  672. this.$set(this.form.klRuleByIdSub[index], 'subMaxOperator', '');
  673. this.$set(this.form.klRuleByIdSub[index], 'subMaxValue', '');
  674. this.$set(this.form.klRuleByIdSub[index], 'subMaxUnit', '');
  675. this.$set(this.form.klRuleByIdSub[index], 'subMinOperator', '');
  676. this.$set(this.form.klRuleByIdSub[index], 'subMinValue', '');
  677. this.$set(this.form.klRuleByIdSub[index], 'subMinUnit', '');
  678. this.$set(this.form.klRuleByIdSub[index], 'subEqValue', '');
  679. this.$set(this.form.klRuleByIdSub[index], 'subEqOperator', '');
  680. },
  681. editKlRuleByIdSub(data) {
  682. this.$set(this.form, 'klRuleByIdSub', data);
  683. // this.form.klRuleByIdSub = data;
  684. },
  685. // 添加分组 || 规则
  686. addGroup(date, arg = { index: null, groupId: null }) {
  687. /**
  688. * @params
  689. * date:存在则添加规则 不存在则添加分组
  690. * arg:{index:添加规则用索引,groupId:添加分组用确切id}
  691. */
  692. !date && (date = new Date().valueOf());
  693. const obj = {
  694. groupId: date,
  695. groupChildId: 'child' + new Date().valueOf(),
  696. baseTypes: this.baseTypeList,
  697. baseTermTypeList: [],
  698. conceptList: [],
  699. subDescription: '',
  700. parRuleType: '',
  701. subConceptId: '',
  702. subType: '',
  703. subMaxOperator: '',
  704. subMaxUnit: '',
  705. subMaxValue: '',
  706. subMinOperator: '',
  707. subMinUnit: '',
  708. subMinValue: '',
  709. subEqValue: '',
  710. subLenCode: '',
  711. dataType: ''
  712. };
  713. if (typeof arg.index == 'number') {
  714. // 添加规则 直接在当前位置之后添加
  715. this.form.klRuleByIdSub.splice(arg.index + 1, 0, obj);
  716. const dragDel =
  717. localStorage
  718. .getItem('zskDragDict')
  719. .match(new RegExp(this.ruleTermCodeStrs, 'g')) || [];
  720. if (dragDel.length > 0) {
  721. let obj = this.form.klRuleByIdSub;
  722. obj.forEach((item, i, arr) => {
  723. if (arr[0].subType == 1) {
  724. const arr = this.baseTypeList.filter(it => {
  725. return it.type == 1;
  726. });
  727. if (i > 0) {
  728. this.$set(item, 'baseTypes', arr);
  729. }
  730. }
  731. });
  732. }
  733. } else {
  734. // 添加分组 在列表中相同groupId之后添加
  735. // 添加分组时判断是否需要加disabled和添加默认值
  736. if (this.form.parHasSub && this.firstPlace) {
  737. obj.disabled = true;
  738. const dict =
  739. localStorage
  740. .getItem('zskDicts')
  741. .match(new RegExp(this.firstPlace.checkedType + '-\\d+', 'g')) ||
  742. [];
  743. const types = dict[0].split('-');
  744. this.$set(obj, 'disabled', true);
  745. this.$set(obj, 'subType', parseInt(types[2]));
  746. const subobj = this.baseTypeList.find(it => it.type == types[2]);
  747. this.$set(obj, 'baseTermTypeList', subobj.subMenuList);
  748. this.$set(obj, 'subLenCode', types[1]);
  749. this.$set(obj, 'subDescription', this.firstPlace.conceptName);
  750. this.$set(obj, 'subConceptId', this.firstPlace.conceptId);
  751. this.$set(obj, 'subConceptName', this.firstPlace.conceptName);
  752. this.$set(obj, 'conceptList', [this.firstPlace]);
  753. }
  754. var i = -1;
  755. this.form.klRuleByIdSub.forEach((item, inx) => {
  756. if (item.groupId === arg.groupId) {
  757. i = inx;
  758. }
  759. });
  760. this.form.klRuleByIdSub.splice(i + 1, 0, obj);
  761. }
  762. this.$nextTick(() => {
  763. this.$refs.tableView.scrollFun();
  764. });
  765. },
  766. // 删除分组
  767. delGroup(groupId) {
  768. const list = this.form.klRuleByIdSub.filter(
  769. item => item.groupId != groupId
  770. );
  771. this.form.klRuleByIdSub = list;
  772. },
  773. // 删除规则
  774. delGroupChild(groupChildId, index) {
  775. let newGroupList;
  776. const dragDel =
  777. localStorage
  778. .getItem('zskDragDict')
  779. .match(new RegExp(this.ruleTermCodeStrs, 'g')) || [];
  780. let list;
  781. if (dragDel.length > 0) {
  782. if (index == 0) {
  783. const date = new Date().valueOf();
  784. newGroupList = [
  785. {
  786. groupId: date,
  787. groupChildId: 'child' + new Date().valueOf(),
  788. baseTypes: this.baseTypeList,
  789. baseTermTypeList: [],
  790. conceptList: [],
  791. subDescription: '',
  792. parRuleType: '',
  793. subConceptId: '',
  794. subType: '',
  795. subMaxOperator: '',
  796. subMaxUnit: '',
  797. subMaxValue: '',
  798. subMinOperator: '',
  799. subMinUnit: '',
  800. subMinValue: '',
  801. subEqValue: '',
  802. subLenCode: '',
  803. dataType: ''
  804. }
  805. ];
  806. } else if (index == 0 || index == 1) {
  807. newGroupList = this.form.klRuleByIdSub.filter((item, i) => {
  808. return i == 0;
  809. });
  810. } else {
  811. newGroupList = this.form.klRuleByIdSub.filter(
  812. item => item.groupChildId != groupChildId
  813. );
  814. }
  815. } else {
  816. newGroupList = this.form.klRuleByIdSub.filter(
  817. item => item.groupChildId != groupChildId
  818. );
  819. }
  820. this.form.klRuleByIdSub = newGroupList;
  821. },
  822. setDict() {
  823. this.dict = localStorage.getItem('zskDicts');
  824. this.msgDict = localStorage.getItem('zskMsgDict');
  825. this.subDict = localStorage.getItem('zskSubDict');
  826. },
  827. showConfirmDialog(msg, resolve) {
  828. this.$alert(msg, '提示', {
  829. confirmButtonText: '确定',
  830. type: 'warning'
  831. })
  832. .then(() => {
  833. resolve();
  834. })
  835. .catch(() => {});
  836. },
  837. searchConcept(val) {
  838. const param = {
  839. excludedConceptIds: [this.form.parRuleType],
  840. libType: this.form.parLenCode,
  841. name: val
  842. };
  843. api
  844. .searchConcept(param)
  845. .then(res => {
  846. if (res.data.code == '0') {
  847. const data = res.data.data;
  848. this.conceptList = data;
  849. }
  850. })
  851. .catch(error => {
  852. console.log(error);
  853. });
  854. },
  855. getTypeList() {
  856. this.ruleTypeList = JSON.parse(localStorage.getItem('zskTypesList'));
  857. },
  858. saveRule(params) {
  859. api.saveRule(params).then(res => {
  860. if (res.data.code == 0) {
  861. this.$message({
  862. message: '操作成功',
  863. type: 'success'
  864. });
  865. this.$router.push({
  866. name: 'ZskRuleManager',
  867. params: Object.assign({}, this.$route.params, { currentPage: 1 })
  868. });
  869. } else {
  870. this.$message({
  871. message: res.data.msg,
  872. type: 'warning'
  873. });
  874. }
  875. });
  876. },
  877. /**
  878. * 子组件调用方法
  879. */
  880. childClearConcept(index) {
  881. this.$set(this.form.klRuleByIdSub[index], 'subConceptId', '');
  882. this.$set(this.form.klRuleByIdSub[index], 'conceptList', []);
  883. },
  884. childClearNumText(index) {
  885. let obj = JSON.parse(JSON.stringify(this.form.klRuleByIdSub));
  886. obj[index].subMaxOperator = '';
  887. obj[index].subMaxValue = '';
  888. obj[index].subMaxUnit = '';
  889. obj[index].subMinOperator = '';
  890. obj[index].subMinValue = '';
  891. obj[index].subMinUnit = '';
  892. obj[index].subEqValue = '';
  893. // this.$set(obj[index], "subEqValue", "");
  894. obj[index].subEqOperator = '';
  895. // this.klRuleByIdSub = obj;
  896. // this.$emit("editKlRuleByIdSub", obj);
  897. this.editKlRuleByIdSub(obj);
  898. },
  899. ChildDataTypeChange(val, index) {
  900. this.form.klRuleByIdSub[index].subEqOperator = val === '2' ? '=' : '';
  901. this.$set(
  902. this.form.klRuleByIdSub[index],
  903. 'subEqOperator',
  904. val === '2' ? '=' : ''
  905. );
  906. this.childClearNumText(index);
  907. // TODO 新增的内容追踪不到
  908. this.form.klRuleByIdSub.forEach((item, i) => {
  909. if (index === i) {
  910. this.$set(item, 'dataType', val);
  911. }
  912. });
  913. },
  914. childSubCodeChange(val, index, numTypes) {
  915. const dragDel =
  916. localStorage
  917. .getItem('zskDragDict')
  918. .match(new RegExp(this.ruleTermCodeStrs, 'g')) || [];
  919. const inx = index == 1 ? index + 1 : index == 2 ? index - 1 : index;
  920. const subobj = this.baseTypeList.find(it => it.type == 1);
  921. let obj = this.form.klRuleByIdSub;
  922. const mutex = obj.some((item, i, arr) => {
  923. return item.subLenCode == '';
  924. });
  925. //判断药品合理性总条数是否大于1条,是否存在第二条或第三条类型为1,存在触发互斥
  926. if (
  927. //判断3条规则是否都已选中
  928. dragDel.length > 0 &&
  929. index > 0 &&
  930. this.form.klRuleByIdSub.length > 1 &&
  931. this.form.klRuleByIdSub[0].subType == 1
  932. ) {
  933. if (this.form.klRuleByIdSub.length == 3 && !mutex) {
  934. //判断是否存在符合互斥条件的两条出具,若存在,置空另一条出具
  935. if (this.dragArr.indexOf(this.dragVal) > -1) {
  936. //剂型给药途径互斥判断
  937. const arr = this.baseTypeList.filter(it => {
  938. return it.type == 1;
  939. });
  940. this.$set(this.form.klRuleByIdSub, inx, {
  941. groupId: this.form.klRuleByIdSub[inx].groupId,
  942. groupChildId: 'child' + new Date().valueOf(),
  943. baseTypes: arr,
  944. baseTermTypeList: [],
  945. conceptList: [],
  946. subDescription: '',
  947. parRuleType: '',
  948. subConceptId: '',
  949. subType: '',
  950. subMaxOperator: '',
  951. subMaxUnit: '',
  952. subMaxValue: '',
  953. subMinOperator: '',
  954. subMinUnit: '',
  955. subMinValue: '',
  956. subEqValue: '',
  957. subLenCode: '',
  958. dataType: ''
  959. });
  960. }
  961. } else {
  962. const list = subobj.subMenuList.filter(it => {
  963. return it.code == val && it.remark.split('|')[0] == 3;
  964. });
  965. //获取互斥项code
  966. const dragArr = list[0].remark.split('|')[1].split(',');
  967. this.dragArr = dragArr;
  968. //获取互斥项
  969. const screenArr = subobj.subMenuList.filter(item =>
  970. dragArr.some(
  971. ele => ele === item.code && item.remark.split('|')[0] == 3
  972. )
  973. );
  974. if (this.form.klRuleByIdSub[inx]) {
  975. this.$set(
  976. this.form.klRuleByIdSub[inx],
  977. 'baseTermTypeList',
  978. screenArr
  979. );
  980. }
  981. }
  982. this.dragVal = val;
  983. }
  984. if ((numTypes + ',').indexOf(val + ',') > -1) {
  985. this.$set(this.form.klRuleByIdSub[index], 'dataType', '1');
  986. } else {
  987. this.$set(this.form.klRuleByIdSub[index], 'dataType', '');
  988. }
  989. this.childClearConcept(index);
  990. this.childClearNumText(index);
  991. },
  992. // 去重
  993. unique(arr, obj) {
  994. return arr.reduce((cur, next) => {
  995. obj[next] ? '' : (obj[next] = true && cur.push(next));
  996. return cur;
  997. }, []);
  998. }
  999. },
  1000. watch: {
  1001. 'form.klRuleByIdSub': {
  1002. handler(val) {
  1003. this.form.klRuleByIdSub.forEach((item, i, arr) => {
  1004. if (i == 0) {
  1005. item.rowIndex = 1;
  1006. } else if (item.groupId == arr[i - 1].groupId) {
  1007. item.rowIndex = arr[i - 1].rowIndex;
  1008. } else {
  1009. item.rowIndex = arr[i - 1].rowIndex + 1;
  1010. }
  1011. });
  1012. },
  1013. deep: true
  1014. }
  1015. },
  1016. computed: {
  1017. disable: function() {
  1018. return Object.keys(this.firstPlace || {}).length > 0;
  1019. },
  1020. ruleTermCodeStr: function() {
  1021. const str = this.form.parRuleType + '-' + this.form.parLenCode + '-' + 1;
  1022. if (str.length <= 1) {
  1023. return '';
  1024. }
  1025. return str;
  1026. },
  1027. ruleTermCodeStr2: function() {
  1028. const str = this.form.parRuleType + '-' + this.form.parLenCode + '-' + 0;
  1029. if (str.length <= 1) {
  1030. return '';
  1031. }
  1032. return str;
  1033. },
  1034. ruleTermCodeStrs: function() {
  1035. const str = this.form.parRuleType + '-' + this.form.parLenCode;
  1036. if (str.length <= 1) {
  1037. return '';
  1038. }
  1039. return str;
  1040. },
  1041. showMsg: function() {
  1042. return (
  1043. this.ruleTermCodeStr.length > 2 &&
  1044. this.msgDict.indexOf(this.ruleTermCodeStr) > -1
  1045. );
  1046. },
  1047. showMsg2: function() {
  1048. return (
  1049. this.ruleTermCodeStr2.length > 2 &&
  1050. this.msgDict.indexOf(this.ruleTermCodeStr2) > -1
  1051. );
  1052. },
  1053. showHasSub() {
  1054. if (this.ruleTermCodeStrs.length > 2) {
  1055. return this.subDict.indexOf(this.ruleTermCodeStrs) != -1;
  1056. }
  1057. return false;
  1058. },
  1059. checkFirstPlace: function() {
  1060. return this.dict.indexOf(this.ruleTermCodeStrs) > -1;
  1061. }
  1062. },
  1063. components: { AddNewRuleTable }
  1064. };
  1065. </script>