AddNewRule.vue 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197
  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,lens) {
  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. if (lens == 4) {
  922. const obj = this.baseTypeList.find((it) => it.type === 1);
  923. const screenArr = obj.subMenuList.filter((item) => {
  924. return item.remark.split("|")[0] == 2;
  925. })
  926. newGroupList[1].baseTermTypeList = screenArr
  927. }
  928. this.dragVal = len[1].subLenCode;
  929. }
  930. } else {
  931. newGroupList = this.form.klRuleByIdSub.filter(
  932. (item) => item.groupChildId != groupChildId
  933. );
  934. }
  935. this.form.klRuleByIdSub = newGroupList;
  936. },
  937. setDict() {
  938. this.dict = localStorage.getItem("zskDicts");
  939. this.msgDict = localStorage.getItem("zskMsgDict");
  940. this.subDict = localStorage.getItem("zskSubDict");
  941. },
  942. showConfirmDialog(msg, resolve) {
  943. this.$alert(msg, "提示", {
  944. confirmButtonText: "确定",
  945. type: "warning",
  946. })
  947. .then(() => {
  948. resolve();
  949. })
  950. .catch(() => {});
  951. },
  952. searchConcept(val) {
  953. const param = {
  954. excludedConceptIds: [this.form.parRuleType],
  955. libType: this.form.parLenCode,
  956. name: val,
  957. };
  958. api
  959. .searchConcept(param)
  960. .then((res) => {
  961. if (res.data.code == "0") {
  962. const data = res.data.data;
  963. this.conceptList = data;
  964. }
  965. })
  966. .catch((error) => {
  967. console.log(error);
  968. });
  969. },
  970. getTypeList() {
  971. this.ruleTypeList = JSON.parse(localStorage.getItem("zskTypesList"));
  972. },
  973. saveRule(params) {
  974. api.saveRule(params).then((res) => {
  975. if (res.data.code == 0) {
  976. this.$message({
  977. message: "操作成功",
  978. type: "success",
  979. });
  980. this.$router.push({
  981. name: "ZskRuleManager",
  982. params: Object.assign({}, this.$route.params, { currentPage: 1 }),
  983. });
  984. } else {
  985. this.$message({
  986. message: res.data.msg,
  987. type: "warning",
  988. });
  989. }
  990. });
  991. },
  992. /**
  993. * 子组件调用方法
  994. */
  995. childClearConcept(index) {
  996. this.$set(this.form.klRuleByIdSub[index], "subConceptId", "");
  997. this.$set(this.form.klRuleByIdSub[index], "conceptList", []);
  998. },
  999. childClearNumText(index) {
  1000. let obj = JSON.parse(JSON.stringify(this.form.klRuleByIdSub));
  1001. obj[index].subMaxOperator = "";
  1002. obj[index].subMaxValue = "";
  1003. obj[index].subMaxUnit = "";
  1004. obj[index].subMinOperator = "";
  1005. obj[index].subMinValue = "";
  1006. obj[index].subMinUnit = "";
  1007. obj[index].subEqValue = "";
  1008. // this.$set(obj[index], "subEqValue", "");
  1009. obj[index].subEqOperator = "";
  1010. // this.klRuleByIdSub = obj;
  1011. // this.$emit("editKlRuleByIdSub", obj);
  1012. this.editKlRuleByIdSub(obj);
  1013. },
  1014. ChildDataTypeChange(val, index) {
  1015. this.form.klRuleByIdSub[index].subEqOperator = val === "2" ? "=" : "";
  1016. this.$set(
  1017. this.form.klRuleByIdSub[index],
  1018. "subEqOperator",
  1019. val === "2" ? "=" : ""
  1020. );
  1021. this.childClearNumText(index);
  1022. // TODO 新增的内容追踪不到
  1023. this.form.klRuleByIdSub.forEach((item, i) => {
  1024. if (index === i) {
  1025. this.$set(item, "dataType", val);
  1026. }
  1027. });
  1028. },
  1029. childSubCodeChange(val, index, numTypes, groupId, key, code, lens) {
  1030. const dragDel =
  1031. localStorage
  1032. .getItem("zskDragDict")
  1033. .match(new RegExp(this.ruleTermCodeStrs, "g")) || [];
  1034. const subobj = this.baseTypeList.find((it) => it.type == 1);
  1035. let obj = this.form.klRuleByIdSub;
  1036. let type;
  1037. const len = this.form.klRuleByIdSub.filter((item, i) => {
  1038. return item.groupId == groupId;
  1039. });
  1040. const inx = key % 3 == 2 ? index - 1 : key % 3 == 1 ? index + 1 : index;
  1041. if (key == 1 && len[2]) {
  1042. type = len[2].subLenCode == "" ? false : true;
  1043. } else if (key == 2) {
  1044. type = len[1].subLenCode == "" ? false : true;
  1045. }
  1046. //判断药品合理性总条数是否大于1条,是否存在第二条或第三条类型为1,存在触发互斥
  1047. if (
  1048. //判断3条规则是否都已选中
  1049. dragDel.length > 0 &&
  1050. len.length > 1 &&
  1051. index > 0 &&
  1052. key > 0
  1053. ) {
  1054. if (len.length == 3 && type) {
  1055. //判断是否存在符合互斥条件的两条出具,若存在,置空另一条出具
  1056. if (code != "" && this.dragArr.indexOf(val) > -1 && lens == 4) {
  1057. //剂型给药途径互斥判断
  1058. const arr = this.baseTypeList.filter((it) => {
  1059. return it.type == 1;
  1060. });
  1061. this.$set(this.form.klRuleByIdSub, inx, {
  1062. groupId: this.form.klRuleByIdSub[inx].groupId,
  1063. groupChildId: "child" + new Date().valueOf(),
  1064. baseTypes: arr,
  1065. baseTermTypeList: [],
  1066. conceptList: [],
  1067. subDescription: "",
  1068. parRuleType: "",
  1069. subConceptId: "",
  1070. subType: "",
  1071. subMaxOperator: "",
  1072. subMaxUnit: "",
  1073. subMaxValue: "",
  1074. subMinOperator: "",
  1075. subMinUnit: "",
  1076. subMinValue: "",
  1077. subEqValue: "",
  1078. subLenCode: "",
  1079. dataType: "",
  1080. del: false,
  1081. key: key == 2 ? 1 : 2,
  1082. });
  1083. }
  1084. } else {
  1085. const list = subobj.subMenuList.filter((it) => {
  1086. return it.code == val && it.remark.split("|")[0] == 3;
  1087. });
  1088. //获取互斥项code
  1089. const dragArr = list[0].remark.split("|")[1].split(",");
  1090. this.dragArr = dragArr;
  1091. //获取互斥项
  1092. const screenArr = subobj.subMenuList.filter((item) =>
  1093. dragArr.some(
  1094. (ele) => ele === item.code && item.remark.split("|")[0] == 3
  1095. )
  1096. );
  1097. if (this.form.klRuleByIdSub[inx]) {
  1098. this.$set(
  1099. this.form.klRuleByIdSub[inx],
  1100. "baseTermTypeList",
  1101. screenArr
  1102. );
  1103. }
  1104. }
  1105. this.dragVal = val;
  1106. }
  1107. if ((numTypes + ",").indexOf(val + ",") > -1) {
  1108. this.$set(this.form.klRuleByIdSub[index], "dataType", "1");
  1109. } else {
  1110. this.$set(this.form.klRuleByIdSub[index], "dataType", "");
  1111. }
  1112. this.childClearConcept(index);
  1113. this.childClearNumText(index);
  1114. },
  1115. // 去重
  1116. unique(arr, obj) {
  1117. return arr.reduce((cur, next) => {
  1118. obj[next] ? "" : (obj[next] = true && cur.push(next));
  1119. return cur;
  1120. }, []);
  1121. },
  1122. },
  1123. watch: {
  1124. "form.klRuleByIdSub": {
  1125. handler(val) {
  1126. this.form.klRuleByIdSub.forEach((item, i, arr) => {
  1127. if (i == 0) {
  1128. item.rowIndex = 1;
  1129. } else if (item.groupId == arr[i - 1].groupId) {
  1130. item.rowIndex = arr[i - 1].rowIndex;
  1131. } else {
  1132. item.rowIndex = arr[i - 1].rowIndex + 1;
  1133. }
  1134. });
  1135. },
  1136. deep: true,
  1137. },
  1138. },
  1139. computed: {
  1140. disable: function() {
  1141. return Object.keys(this.firstPlace || {}).length > 0;
  1142. },
  1143. ruleTermCodeStr: function() {
  1144. const str = this.form.parRuleType + "-" + this.form.parLenCode + "-" + 1;
  1145. if (str.length <= 1) {
  1146. return "";
  1147. }
  1148. return str;
  1149. },
  1150. ruleTermCodeStr2: function() {
  1151. const str = this.form.parRuleType + "-" + this.form.parLenCode + "-" + 0;
  1152. if (str.length <= 1) {
  1153. return "";
  1154. }
  1155. return str;
  1156. },
  1157. ruleTermCodeStrs: function() {
  1158. const str = this.form.parRuleType + "-" + this.form.parLenCode;
  1159. if (str.length <= 1) {
  1160. return "";
  1161. }
  1162. return str;
  1163. },
  1164. showMsg: function() {
  1165. return (
  1166. this.ruleTermCodeStr.length > 2 &&
  1167. this.msgDict.indexOf(this.ruleTermCodeStr) > -1
  1168. );
  1169. },
  1170. showMsg2: function() {
  1171. return (
  1172. this.ruleTermCodeStr2.length > 2 &&
  1173. this.msgDict.indexOf(this.ruleTermCodeStr2) > -1
  1174. );
  1175. },
  1176. showHasSub() {
  1177. if (this.ruleTermCodeStrs.length > 2) {
  1178. return this.subDict.indexOf(this.ruleTermCodeStrs) != -1;
  1179. }
  1180. return false;
  1181. },
  1182. checkFirstPlace: function() {
  1183. return this.dict.indexOf(this.ruleTermCodeStrs) > -1;
  1184. },
  1185. },
  1186. components: { AddNewRuleTable },
  1187. };
  1188. </script>