AddNewRule.vue 39 KB

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