AddNewRule.vue 40 KB

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