AddNewRule.vue 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598
  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
  78. :title="title"
  79. :param="$route.params"
  80. linkTo="ZskRuleManager"
  81. ></crumbs>
  82. <div id="AddRuleContent">
  83. <el-form size="mini" :model="form" ref="ruleForm">
  84. <div class="table_form">
  85. <div class="table_cell">
  86. <!-- 规则名称 -->
  87. <el-form-item
  88. label-width="130px"
  89. label="规则名称:"
  90. :rules="rules.parDescription"
  91. prop="parDescription"
  92. >
  93. <el-input
  94. style="width: 100%"
  95. v-model.trim="form.parDescription"
  96. />
  97. </el-form-item>
  98. </div>
  99. <div class="table_cell">
  100. <!-- 规则类型 -->
  101. <el-form-item
  102. label-width="130px"
  103. label="规则类型:"
  104. :rules="rules.parRuleType"
  105. prop="parRuleType"
  106. >
  107. <el-select
  108. v-model="form.parRuleType"
  109. placeholder="请选择"
  110. @change="ruleTypeChange"
  111. >
  112. <el-option
  113. v-for="item in ruleTypeList"
  114. :key="item.id"
  115. :label="item.name"
  116. :value="item.id"
  117. ></el-option>
  118. </el-select>
  119. <template slot="error" slot-scope="scope">
  120. <div class="my_error">
  121. <el-tooltip
  122. class="item"
  123. effect="light"
  124. :content="scope.error"
  125. placement="top-start"
  126. popper-class="popper_class"
  127. >
  128. <img src="../../images/exclamationpoint.png" alt />
  129. </el-tooltip>
  130. </div>
  131. </template>
  132. <div class="tip_text">
  133. 注:更改规则类型,将会清空已填写的规则内容~
  134. </div>
  135. </el-form-item>
  136. </div>
  137. <div class="table_cell">
  138. <!-- 规则术语类型: -->
  139. <el-form-item
  140. label-width="130px"
  141. label="规则术语类型:"
  142. :rules="rules.parLenCode"
  143. prop="parLenCode"
  144. >
  145. <template slot="error" slot-scope="scope">
  146. <div class="my_error">
  147. <el-tooltip
  148. class="item"
  149. effect="light"
  150. :content="scope.error"
  151. placement="top-start"
  152. popper-class="popper_class"
  153. >
  154. <img src="../../images/exclamationpoint.png" alt />
  155. </el-tooltip>
  156. </div>
  157. </template>
  158. <el-select
  159. v-model="form.parLenCode"
  160. placeholder="请选择"
  161. @change="ruleTermChange"
  162. >
  163. <el-option
  164. v-for="item in ruleTermTypeList"
  165. :key="item.id"
  166. :label="item.name"
  167. :value="item.code"
  168. ></el-option>
  169. </el-select>
  170. <div class="tip_text">
  171. 注:更改规则术语类型,将会清空已填写的规则内容~
  172. </div>
  173. </el-form-item>
  174. </div>
  175. <div class="table_cell">
  176. <el-form-item
  177. label-width="130px"
  178. label="医学标准术语:"
  179. :style="{ height: '100%' }"
  180. :rules="rules.parConceptId"
  181. prop="parConceptId"
  182. >
  183. <el-select
  184. clearable
  185. filterable
  186. remote
  187. :remote-method="searchConcept"
  188. v-model.trim="form.parConceptId"
  189. @change="parConceptIdChange"
  190. >
  191. <el-option
  192. v-for="item in conceptList"
  193. :key="item.conceptId"
  194. :label="item.conceptName"
  195. :value="item.conceptId"
  196. :title="item.conceptName"
  197. ></el-option>
  198. </el-select>
  199. </el-form-item>
  200. </div>
  201. <div
  202. class="table_cell"
  203. v-if="showHasSub && isShow"
  204. style="max-width: 25%"
  205. >
  206. <el-form-item
  207. label-width="130px"
  208. label="有无子条件:"
  209. :rules="rules.parHasSub"
  210. prop="parHasSub"
  211. >
  212. <el-select
  213. v-model="form.parHasSub"
  214. placeholder="请选择"
  215. @change="hasSubChange"
  216. >
  217. <el-option label="有" :value="1"></el-option>
  218. <el-option label="无" :value="0"></el-option>
  219. </el-select>
  220. </el-form-item>
  221. </div>
  222. <!-- <div
  223. class="table_cell"
  224. style="flex: 3; max-width: 50%"
  225. v-if="showMsg"
  226. >
  227. <el-form-item
  228. label-width="130px"
  229. label="附加信息:"
  230. :rules="rules.parMsg"
  231. prop="parMsg"
  232. >
  233. <el-input
  234. type="textarea"
  235. :rows="1"
  236. placeholder="请输入附加信息"
  237. v-model.trim="form.parMsg"
  238. ></el-input>
  239. </el-form-item>
  240. </div>-->
  241. </div>
  242. <!-- 表格 -->
  243. <AddNewRuleTable ref="tableView" v-if="form.parHasSub && tableShow"
  244. :klRuleByIdSub="form.klRuleByIdSub" :maxNum="subRuleMaxNum"
  245. :showMsg="showMsg" :showMsg2="showMsg2"
  246. :ruleTermCodeStr="ruleTermCodeStr" <<<<<<< HEAD
  247. :isStaticChild='isStatic' :isRedMsgs='isRedMsg' =======
  248. :isStaticChild="isStatic" :isRedMsgs="isRedMsg" >>>>>>> bug0818
  249. @subTypeChange="subTypeChange" @searchConcept="searchConcept"
  250. @addGroup="addGroup" @delGroup="delGroup" @delGroupChild="delGroupChild"
  251. @setFormData="setFormData" @editKlRuleByIdSub="editKlRuleByIdSub"
  252. @clearValidate="clearValidate" @childClearConcept="childClearConcept"
  253. @childClearNumText="childClearNumText"
  254. @ChildDataTypeChange="ChildDataTypeChange"
  255. @childSubCodeChange="childSubCodeChange" />
  256. <AddNewRuleContent
  257. ref="ruleContent"
  258. v-if="(!form.parHasSub && !tableShow) || contentRuls"
  259. @ruleContent="ruleContent"
  260. :isContent="isEdit"
  261. :formEidtCopy="formEidt"
  262. :isError="isErr"
  263. >
  264. </AddNewRuleContent>
  265. <el-form-item>
  266. <div class="form_btn">
  267. <el-button
  268. type="primary"
  269. size="medium "
  270. @click="submitForm('ruleForm')"
  271. >确定</el-button
  272. >
  273. </div>
  274. </el-form-item>
  275. </el-form>
  276. </div>
  277. </div>
  278. </template>
  279. <script type="text/javascript">
  280. import api from "@api/knowledgeLib.js";
  281. import { formRules } from "./rules";
  282. import AddNewRuleTable from "./AddNewRuleTable";
  283. import AddNewRuleContent from "./AddNewRuleContent";
  284. export default {
  285. name: "AddRule",
  286. data() {
  287. return {
  288. isRedMsg: [],
  289. isErr: false, //控制护理开单项里面的错误提示
  290. staicData: {
  291. //护理开单项里面的数据
  292. gljtxx: [],
  293. fjxx: "",
  294. },
  295. formEidt: {},
  296. isEdit: false, //判断是否是编辑页面
  297. isStatic: false, //判断关联静态知识的tabel列是否显示
  298. contentRuls: false, //判断规则内容为列表还是表单
  299. title: "规则维护-添加规则",
  300. ruleTypeList: [], //规则类型列表 1
  301. ruleTermTypeList: [], //规则术语类型列表 2
  302. conceptList: [], //医学标准术语列表 3
  303. baseTypeList: [], //基础规则类型列表 4
  304. baseTermTypeList: [], //基础规则术语类型 5
  305. subRuleMaxNum: null, //规则内容中规则的限制个数
  306. isCopy: false,
  307. parId: null,
  308. msgDict: "", //显示附加信息的类型
  309. firstPlace: null,
  310. tableShow: true,
  311. form: {
  312. parDescription: "",
  313. parRuleType: "",
  314. parConceptId: "",
  315. parlibName: "",
  316. parLenName: "",
  317. parHasSub: undefined,
  318. parLenCode: "",
  319. klRuleByIdSub: [],
  320. },
  321. isShow: false,
  322. rules: formRules,
  323. dragVal: null,
  324. dragArr: null,
  325. };
  326. },
  327. created() {
  328. this.getTypeList();
  329. this.setDict();
  330. const param = this.$route.params;
  331. let info = param.data;
  332. if (info) {
  333. this.parId = info.parId;
  334. this.isCopy = param.copy;
  335. this.title = "规则维护-" + (this.isCopy ? "复制" : "修改") + "规则";
  336. this.getDragData(info);
  337. // 编辑初始化选择框
  338. this.initEdidData();
  339. }
  340. },
  341. mounted() {},
  342. watch: {},
  343. methods: {
  344. //护理开单项子组件里面的传过来的值
  345. ruleContent(data) {
  346. this.staicData = data;
  347. },
  348. clearValidate(data) {
  349. this.$refs.ruleForm.clearValidate(data);
  350. },
  351. // 编辑初始化
  352. async initEdidData() {
  353. // 规则术语类型初始化
  354. this.contentRuls = false;
  355. this.isEdit = false;
  356. this.isRedMsg = [];
  357. const newruleTermTypeList = await this.ruleTypeList.find(
  358. (it) => it.id == this.form.parRuleType
  359. );
  360. this.ruleTermTypeList = await newruleTermTypeList.subMenuList;
  361. // 基础规则类型初始化
  362. const obj = await this.ruleTermTypeList.find(
  363. (it1) => it1.code == this.form.parLenCode
  364. );
  365. this.baseTypeList = obj.subMenuList;
  366. this.subRuleMaxNum = obj.number;
  367. this.conceptList = [
  368. {
  369. conceptName: this.form.parlibName,
  370. conceptId: this.form.parConceptId,
  371. },
  372. ];
  373. // 加载护理开单项的推送内容
  374. if (!this.form.klRuleByIdSub) {
  375. this.isEdit = true;
  376. this.contentRuls = true;
  377. this.formEidt = JSON.parse(JSON.stringify(this.form));
  378. return;
  379. }
  380. //加载护理非开单项的关联静态知识
  381. if (this.form.parRuleType == 8) {
  382. this.isStatic = true;
  383. if (Array.isArray(this.form.klRuleByIdGroup)) {
  384. let itemCopy = {}; //用来存放对象
  385. let itemsCopy = {};
  386. let klRuleByIdSub = []; //中间数组
  387. this.form.klRuleByIdGroup.forEach((item, index) => {
  388. let obj = {
  389. groupType: item.groupType,
  390. klRuleStaticSub: item.klRuleStaticSub,
  391. };
  392. itemCopy = JSON.parse(JSON.stringify(obj));
  393. klRuleByIdSub.push(itemCopy);
  394. });
  395. if (Array.isArray(this.form.klRuleByIdSub)) {
  396. this.form.klRuleByIdSub.forEach((item) => {
  397. this.$set(item, "ruleStatic", []);
  398. this.$set(item, "ruleStaticList", []);
  399. this.$set(item, "ruleStaticLists", []);
  400. });
  401. }
  402. this.form.klRuleByIdSub.forEach((item, index) => {
  403. klRuleByIdSub.forEach((items) => {
  404. if (items.groupType == item.groupType) {
  405. this.form.klRuleByIdSub[index].ruleStaticLists =
  406. items.klRuleStaticSub;
  407. }
  408. });
  409. });
  410. this.form.klRuleByIdSub.forEach((item, index) => {
  411. if (Array.isArray(item.ruleStaticLists)) {
  412. item.ruleStaticLists.forEach((items) => {
  413. let obj = {
  414. id: items.conceptId,
  415. name: items.name,
  416. };
  417. itemsCopy = JSON.parse(JSON.stringify(obj));
  418. this.form.klRuleByIdSub[index].ruleStaticList.push(itemsCopy);
  419. this.form.klRuleByIdSub[index].ruleStatic.push(itemsCopy.id);
  420. });
  421. }
  422. });
  423. }
  424. }
  425. //加载列表规则内容
  426. if (this.form.parConceptId && this.checkFirstPlace && this.conceptList) {
  427. this.firstPlace = this.conceptList.find(
  428. (it) => it.conceptId === this.form.parConceptId
  429. );
  430. if (this.firstPlace) {
  431. this.firstPlace["checkedType"] = this.ruleTermCodeStrs;
  432. }
  433. } else if (!this.form.parConceptId) {
  434. this.setInitGroupData();
  435. this.firstPlace = null;
  436. } else {
  437. this.firstPlace = null;
  438. }
  439. await this.form.klRuleByIdSub.forEach((item, i, arr) => {
  440. item.groupId = "groupId" + item.groupType;
  441. item.groupChildId = "child" + item.subId;
  442. //TODO => 赋值时一定要注意set更新页面
  443. this.$set(item, "baseTypes", [...this.baseTypeList]);
  444. // this.$set(key, "baseTypes", [...this.baseTypeList]);
  445. this.$set(
  446. item,
  447. "baseTermTypeList",
  448. item.baseTypes.find((it2) => it2.type === item.subType).subMenuList
  449. );
  450. this.$set(item, "conceptList", [
  451. {
  452. conceptName: item.subLibName || item.subConceptName,
  453. conceptId: item.subConceptId,
  454. },
  455. ]);
  456. if (item.subMaxOperator || item.subMinOperator) {
  457. item.dataType = "1";
  458. } else if (item.subEqValue) {
  459. item.dataType = "2";
  460. }
  461. // disable
  462. if (this.form.parHasSub && this.firstPlace) {
  463. const del =
  464. localStorage
  465. .getItem("zskDelDict")
  466. .match(
  467. new RegExp(this.firstPlace.checkedType + "-\\d+" + "-\\d+", "g")
  468. ) || [];
  469. if (arr[i - 1] && arr[i - 1].groupId == item.groupId) {
  470. this.$set(item, "disabled", false);
  471. if (del.length > 0 && item.subType == del[0].split("-")[2]) {
  472. const delType = del[0].split("-");
  473. const types = del[0].split("-");
  474. const subobj = this.baseTypeList.find(
  475. (it) => it.type == types[2]
  476. );
  477. const screenArr = subobj.subMenuList.filter((item) => {
  478. return !types[3].includes(item.code);
  479. });
  480. this.$set(item, "baseTermTypeList", screenArr);
  481. }
  482. } else {
  483. this.$set(item, "disabled", true);
  484. if (this.form.parLenCode == "108" && this.form.parRuleType == "8") {
  485. const subobj = this.baseTypeList.find((it) => it.type == "2");
  486. subobj.subMenuList.push({
  487. code: "108",
  488. creator: "0",
  489. firstPlace: null,
  490. gmtCreate: "1970-01-01 12:00:00",
  491. gmtModified: "1970-01-01 12:00:00",
  492. id: 27106,
  493. isDeleted: "N",
  494. modifier: "0",
  495. name: "实验室检查子项目",
  496. number: null,
  497. orderNo: 1,
  498. parentId: 27103,
  499. planCode: "rule",
  500. remark: "",
  501. ruleType: 8,
  502. subMenuList: [],
  503. type: null,
  504. });
  505. this.$set(item, "baseTermTypeList", subobj.subMenuList);
  506. }
  507. }
  508. }
  509. const dragDel =
  510. localStorage
  511. .getItem("zskDragDict")
  512. .match(new RegExp(this.ruleTermCodeStrs, "g")) || [];
  513. //药品开单合理判断
  514. if (dragDel.length > 0) {
  515. const obj = this.baseTypeList.find((it) => it.type === 1);
  516. if (arr[i - 1] && arr[i - 1].groupId == item.groupId) {
  517. let klRuleByIdSub = this.form.klRuleByIdSub;
  518. klRuleByIdSub.forEach((item, i, arr) => {
  519. if (arr[i].key != 0) {
  520. const arr = this.baseTypeList.filter((it) => {
  521. return it.type == 1;
  522. });
  523. if (i > 0) {
  524. this.$set(item, "baseTypes", arr);
  525. }
  526. }
  527. });
  528. if (item.key == 2) {
  529. //获取互斥项code
  530. const list = obj.subMenuList.filter((it) => {
  531. return (
  532. it.code == arr[i - 1].subLenCode &&
  533. it.remark.split("|")[0] == 3
  534. );
  535. });
  536. const dragArr = list[0].remark.split("|")[1].split(",");
  537. this.dragArr = dragArr;
  538. this.dragVal = item.subLenCode;
  539. item.dragArr = dragArr;
  540. //取出互斥项
  541. const screenArr = obj.subMenuList.filter((item) =>
  542. dragArr.some(
  543. (ele) => ele === item.code && item.remark.split("|")[0] == 3
  544. )
  545. );
  546. this.$set(item, "baseTermTypeList", screenArr);
  547. } else {
  548. const screenArr = obj.subMenuList.filter((it) => {
  549. if (it.remark == "") {
  550. return it;
  551. } else {
  552. return it.remark.split("|")[0] == (item.key % 3) + 1;
  553. }
  554. });
  555. this.$set(item, "baseTermTypeList", screenArr);
  556. }
  557. }
  558. }
  559. });
  560. },
  561. //药品数据处理
  562. getDragData(info) {
  563. let dataArr = [];
  564. //处理修改接口请求的数据
  565. //先将数据深拷贝,避免数据污染
  566. let infoCopy = JSON.parse(JSON.stringify(info));
  567. infoCopy.klRuleByIdSubCopy = [];
  568. if (info.klRuleByIdGroup.length > 0) {
  569. let klRuleByIdSub = {};
  570. info.klRuleByIdGroup.forEach((item) => {
  571. if (item.klRuleByIdSub && Array.isArray(item.klRuleByIdSub)) {
  572. item.klRuleByIdSub.forEach((items) => {
  573. klRuleByIdSub = JSON.parse(JSON.stringify(items));
  574. infoCopy.klRuleByIdSubCopy.push(klRuleByIdSub);
  575. });
  576. infoCopy.klRuleByIdSub = [...item.klRuleByIdSub];
  577. }
  578. });
  579. }
  580. if (
  581. Array.isArray(info.klRuleByIdGroup) &&
  582. info.klRuleByIdGroup.length == 0
  583. ) {
  584. this.form = JSON.parse(JSON.stringify(info));
  585. return;
  586. }
  587. //判断是否存在klRuleByIdSub,没有就是护理开单项直接赋值
  588. if (!info.klRuleByIdGroup[0].klRuleByIdSub) {
  589. this.form = JSON.parse(JSON.stringify(info));
  590. } else {
  591. let arr = JSON.parse(JSON.stringify(infoCopy.klRuleByIdSubCopy));
  592. arr.map((mapItem) => {
  593. if (dataArr.length == 0) {
  594. dataArr.push({ groupType: mapItem.groupType, List: [mapItem] });
  595. } else {
  596. let res = dataArr.some((item) => {
  597. //判断相同日期,有就添加到当前项
  598. if (item.groupType == mapItem.groupType) {
  599. item.List.push(mapItem);
  600. return true;
  601. }
  602. });
  603. if (!res) {
  604. //如果没找相同日期添加一个新对象
  605. dataArr.push({ groupType: mapItem.groupType, List: [mapItem] });
  606. }
  607. }
  608. });
  609. this.getDragData2(info, dataArr);
  610. }
  611. },
  612. getDragData2(info, dataArr) {
  613. let arr = [];
  614. dataArr.map((item) => {
  615. item.List.map((it, i) => {
  616. it.key = i;
  617. it.del = i == 0 ? true : false;
  618. arr.push(it);
  619. });
  620. });
  621. info.klRuleByIdSub = arr;
  622. this.form = JSON.parse(JSON.stringify(info));
  623. },
  624. // 提交
  625. submitForm(formName) {
  626. this.$refs[formName].validate((valid) => {
  627. if (valid) {
  628. this.isErr = false;
  629. this.isRedMsg = [];
  630. let params = JSON.parse(JSON.stringify(this.form));
  631. if (params.klRuleByIdSub) {
  632. params.klRuleInfoSaveSub = params.klRuleByIdSub;
  633. delete params.klRuleByIdSub;
  634. params.klRuleInfoSaveSub.forEach((item, i, arr) => {
  635. if (i === 0) {
  636. item.groupType = 1;
  637. } else {
  638. if (item.groupId == arr[i - 1].groupId) {
  639. item.groupType = arr[i - 1].groupType;
  640. item.subMsg = arr[i - 1].subMsg;
  641. } else {
  642. item.groupType = arr[i - 1].groupType + 1;
  643. }
  644. }
  645. });
  646. params.klRuleInfoSaveSub.forEach((ite) => {
  647. delete ite.groupId;
  648. delete ite.groupChildId;
  649. delete ite.rowIndex;
  650. delete ite.baseTypes;
  651. delete ite.baseTermTypeList;
  652. delete ite.conceptList;
  653. });
  654. }
  655. if (this.parId) {
  656. params.parId = this.isCopy ? undefined : this.parId;
  657. params.parStatus = this.isCopy ? 1 : this.form.parStatus;
  658. }
  659. //改造params,保存护理开单项类型的
  660. let paramsCopy = JSON.parse(JSON.stringify(params));
  661. //先遍历子集klRuleInfoSaveSub
  662. paramsCopy.klRuleInfoSaveGroup = [];
  663. let obj = {
  664. groupType: 0,
  665. klRuleInfoSaveSub: [],
  666. };
  667. this.$set(obj, "ruleStatic", []);
  668. if (
  669. params.klRuleInfoSaveSub &&
  670. Array.isArray(params.klRuleInfoSaveSub)
  671. ) {
  672. if (params.klRuleInfoSaveSub.length > 0) {
  673. params.klRuleInfoSaveSub.forEach((item) => {
  674. obj.groupType = item.groupType;
  675. obj.klRuleInfoSaveSub = [item];
  676. let objCopy = JSON.parse(JSON.stringify(obj));
  677. //可以处理objCopy,将groupType相同的放入klRuleInfoSaveSub里面
  678. paramsCopy.klRuleInfoSaveGroup.push(objCopy);
  679. });
  680. } else {
  681. paramsCopy.klRuleInfoSaveGroup.push(obj);
  682. }
  683. } else {
  684. paramsCopy.klRuleInfoSaveGroup.push(obj);
  685. }
  686. if (
  687. paramsCopy.klRuleInfoSaveSub &&
  688. Array.isArray(paramsCopy.klRuleInfoSaveSub)
  689. ) {
  690. //护理非开单项的关联静态知识的处理
  691. paramsCopy.klRuleInfoSaveSub.forEach((item, ind) => {
  692. let ruleObj = {};
  693. if (Array.isArray(item.ruleStatic)) {
  694. item.ruleStatic.forEach((items, index) => {
  695. ruleObj.conceptId = items;
  696. ruleObj.orderNo = index;
  697. let ruleObjCopy = JSON.parse(JSON.stringify(ruleObj));
  698. //将关联静态知识的对象放入数组内
  699. paramsCopy.klRuleInfoSaveGroup[ind].ruleStatic.push(
  700. ruleObjCopy
  701. );
  702. });
  703. }
  704. });
  705. //删除第二层的klRuleInfoSaveSub
  706. delete paramsCopy.klRuleInfoSaveSub;
  707. //清除子集的关联静态知识
  708. paramsCopy.klRuleInfoSaveGroup.forEach((item, index) => {
  709. if (index + 1 >= paramsCopy.klRuleInfoSaveGroup.length) return;
  710. if (
  711. item.groupType ==
  712. paramsCopy.klRuleInfoSaveGroup[index + 1].groupType
  713. ) {
  714. paramsCopy.klRuleInfoSaveGroup[index + 1].ruleStatic = [];
  715. }
  716. });
  717. }
  718. //判断护理开单是否附加信息和关联静态信息是否都没存在值
  719. let flagRule = false;
  720. //附加信息
  721. if (this.staicData.fjxx) {
  722. paramsCopy.klRuleInfoSaveGroup[0].groupType = "1";
  723. paramsCopy.parMsg = this.staicData.fjxx;
  724. flagRule = true;
  725. } else {
  726. paramsCopy.parMsg = "";
  727. }
  728. //关联静态知识
  729. if (this.staicData.gljtxx.length > 0) {
  730. paramsCopy.klRuleInfoSaveGroup[0].groupType = "1";
  731. let rule = {};
  732. this.staicData.gljtxx.forEach((item, index) => {
  733. rule.conceptId = item;
  734. rule.orderNo = index;
  735. let ruleCopy = JSON.parse(JSON.stringify(rule));
  736. paramsCopy.klRuleInfoSaveGroup[0].ruleStatic.push(ruleCopy);
  737. });
  738. flagRule = true;
  739. }
  740. //如果是护理项并且静态知识和附加信息都没有值
  741. if (this.contentRuls && !flagRule) {
  742. this.isErr = true;
  743. return;
  744. }
  745. //如果护理非开单项关联静态知识和附加信息都没有值
  746. if (this.isStatic) {
  747. if (Array.isArray(paramsCopy.klRuleInfoSaveGroup)) {
  748. paramsCopy.klRuleInfoSaveGroup.forEach((item) => {
  749. if (Array.isArray(item.klRuleInfoSaveSub)) {
  750. item.klRuleInfoSaveSub.forEach((items) => {
  751. if (items.ruleStatic && Array.isArray(items.ruleStatic)) {
  752. if (items.ruleStatic.length > 0 || items.subMsg) {
  753. this.isRedMsg.push(false);
  754. } else {
  755. this.isRedMsg.push(true);
  756. }
  757. } else {
  758. this.isRedMsg.push(false);
  759. }
  760. });
  761. }
  762. });
  763. }
  764. }
  765. //判断护理非开单项里面的附加信息和关联静态知识是否填写
  766. if (this.isStatic && this.isRedMsg.length > 0) {
  767. let flag = this.isRedMsg.some((item) => {
  768. return item;
  769. });
  770. //都填写了
  771. if (!flag) this.saveRule(paramsCopy);
  772. } else {
  773. this.saveRule(paramsCopy);
  774. }
  775. } else {
  776. return false;
  777. }
  778. });
  779. },
  780. // 子集修改父级的数组
  781. setFormData(index, data) {
  782. this.$set(this.form.klRuleByIdSub[index], "conceptList", data);
  783. },
  784. // table_form 规则类型选中
  785. ruleTypeChange(val) {
  786. //先初始化
  787. this.contentRuls = false;
  788. this.isStatic = false;
  789. this.isRedMsg = [];
  790. //是否护理非开单项
  791. if (val === 8) {
  792. this.isStatic = true;
  793. }
  794. this.form.parLenCode = "";
  795. const obj = this.ruleTypeList.find((it) => it.id === val);
  796. this.ruleTermTypeList = obj.subMenuList;
  797. this.subRuleMaxNum = undefined;
  798. this.setInitGroupData();
  799. },
  800. // table_form 规则术语类型选中
  801. ruleTermChange(val) {
  802. this.contentRuls = false;
  803. this.isRedMsg = [];
  804. const obj = this.ruleTermTypeList.find((it) => it.code === val);
  805. this.form.parLenName = obj.name;
  806. this.baseTypeList = obj.subMenuList;
  807. this.subRuleMaxNum = obj.number;
  808. this.form.parHasSub = obj.subMenuList.length ? 1 : 0;
  809. if (!this.form.parHasSub) {
  810. this.contentRuls = true;
  811. }
  812. //初始化护理开单项的输入框
  813. if (this.contentRuls) {
  814. this.$nextTick(() => {
  815. this.isEdit = false;
  816. this.$refs.ruleContent.clearFormData();
  817. });
  818. }
  819. this.isShow = obj.subMenuList.length ? 1 : 0;
  820. this.setInitGroupData();
  821. },
  822. // 医学标准术语
  823. parConceptIdChange(val) {
  824. this.$nextTick(() => {
  825. if (val && this.checkFirstPlace && this.conceptList) {
  826. this.firstPlace = this.conceptList.find((it) => it.conceptId === val);
  827. if (this.firstPlace) {
  828. this.firstPlace["checkedType"] = this.ruleTermCodeStrs;
  829. }
  830. } else if (!val) {
  831. this.setInitGroupData();
  832. this.firstPlace = null;
  833. } else {
  834. this.firstPlace = null;
  835. }
  836. if (this.form.parHasSub && this.firstPlace) {
  837. const dict =
  838. localStorage
  839. .getItem("zskDicts")
  840. .match(new RegExp(this.firstPlace.checkedType + "-\\d+", "g")) ||
  841. [];
  842. const del =
  843. localStorage
  844. .getItem("zskDelDict")
  845. .match(
  846. new RegExp(this.firstPlace.checkedType + "-\\d+" + "-\\d+", "g")
  847. ) || [];
  848. const types = dict[0].split("-");
  849. let obj = this.form.klRuleByIdSub;
  850. obj.forEach((item, i, arr) => {
  851. if (arr[i - 1] && arr[i - 1].groupId == item.groupId) {
  852. this.$set(item, "disabled", false);
  853. if (del.length > 0) {
  854. const delType = del[0].split("-");
  855. if (
  856. item.subType == delType[2] ||
  857. item.subLenCode == delType[3]
  858. ) {
  859. this.$set(this.form.klRuleByIdSub, i, {
  860. groupId: item.groupId,
  861. groupChildId: "child" + new Date().valueOf(),
  862. baseTypes: this.baseTypeList,
  863. baseTermTypeList: [],
  864. conceptList: [],
  865. subDescription: "",
  866. parRuleType: "",
  867. subConceptId: "",
  868. subType: "",
  869. subMaxOperator: "",
  870. subMaxUnit: "",
  871. subMaxValue: "",
  872. subMinOperator: "",
  873. subMinUnit: "",
  874. subMinValue: "",
  875. subEqValue: "",
  876. subLenCode: "",
  877. dataType: "",
  878. key: 0,
  879. });
  880. }
  881. }
  882. } else {
  883. this.$set(item, "disabled", true);
  884. // //因为字典传的时候第三个值没有护理所以重新赋值为9,因为这里后端逻辑问题先注释后面可能有用
  885. // this.baseTypeList.forEach((item)=>{
  886. // if(item.type==9){
  887. // types[2]='9'
  888. // }
  889. // })
  890. this.$set(item, "subType", parseInt(types[2]));
  891. const subobj = this.baseTypeList.find(
  892. (it) => it.type == types[2]
  893. );
  894. if (
  895. this.form.parLenCode == "108" &&
  896. this.form.parRuleType == "8"
  897. ) {
  898. subobj.subMenuList.push({
  899. code: "108",
  900. creator: "0",
  901. firstPlace: null,
  902. gmtCreate: "1970-01-01 12:00:00",
  903. gmtModified: "1970-01-01 12:00:00",
  904. id: 27106,
  905. isDeleted: "N",
  906. modifier: "0",
  907. name: "实验室检查子项目",
  908. number: null,
  909. orderNo: 1,
  910. parentId: 27103,
  911. planCode: "rule",
  912. remark: "",
  913. ruleType: 8,
  914. subMenuList: [],
  915. type: null,
  916. });
  917. }
  918. this.$set(item, "baseTermTypeList", subobj.subMenuList);
  919. this.$set(item, "subLenCode", types[1]);
  920. this.$set(item, "subDescription", this.firstPlace.conceptName);
  921. this.$set(item, "subConceptId", this.firstPlace.conceptId);
  922. this.$set(item, "subConceptName", this.firstPlace.conceptName);
  923. this.$set(item, "conceptList", [this.firstPlace]);
  924. }
  925. });
  926. this.$set(this.form, "klRuleByIdSub", obj);
  927. if (this.form.parLenCode == "104" && this.form.parRuleType == "8") {
  928. this.form.klRuleByIdSub[0].dataType = "1";
  929. }
  930. }
  931. });
  932. },
  933. // 初始化表格
  934. setInitGroupData(init) {
  935. this.tableShow = false;
  936. const date = new Date().valueOf();
  937. this.$nextTick(() => {
  938. if (this.form.parHasSub && this.form.parHasSub != 0) {
  939. this.$set(this.form, "klRuleByIdSub", [
  940. {
  941. groupId: date,
  942. groupChildId: "child" + new Date().valueOf(),
  943. baseTypes: this.baseTypeList,
  944. baseTermTypeList: [],
  945. conceptList: [],
  946. subDescription: "",
  947. parRuleType: "",
  948. subConceptId: "",
  949. subType: "",
  950. subMaxOperator: "",
  951. subMaxUnit: "",
  952. subMaxValue: "",
  953. subMinOperator: "",
  954. subMinUnit: "",
  955. subMinValue: "",
  956. subEqValue: "",
  957. subLenCode: "",
  958. dataType: "",
  959. key: 0,
  960. del: true,
  961. },
  962. ]);
  963. } else {
  964. this.$set(this.form, "klRuleByIdSub", []);
  965. }
  966. if (!init) {
  967. this.form.parConceptId = ""; //医学标准术语清空
  968. this.conceptList = []; //下拉列表清空
  969. this.firstPlace = null;
  970. }
  971. this.tableShow = true;
  972. });
  973. },
  974. // 有无子条件切换
  975. hasSubChange(val) {
  976. if (val) {
  977. this.setInitGroupData(true);
  978. } else {
  979. this.form.klRuleByIdSub = [];
  980. }
  981. },
  982. // 基础规则类型切换
  983. subTypeChange(val, index, groupId, key) {
  984. // index
  985. const dragDel =
  986. localStorage
  987. .getItem("zskDragDict")
  988. .match(new RegExp(this.ruleTermCodeStrs, "g")) || [];
  989. const obj = this.baseTypeList.find((it) => it.type === val);
  990. let dragType = false;
  991. let isDel = false;
  992. let screenArr;
  993. let type;
  994. //药品开单合理判断
  995. if (dragDel.length > 0) {
  996. dragType = true;
  997. const types = dragDel[0].split("-");
  998. const arr = this.form.klRuleByIdSub.filter((item, i) => {
  999. return item.groupId == groupId;
  1000. });
  1001. if (key == 1 && arr[2]) {
  1002. type = arr[2].subLenCode == "" ? false : true;
  1003. } else if (key == 2) {
  1004. type = arr[1].subLenCode == "" ? false : true;
  1005. }
  1006. if (arr.length == 3 && key != 0 && type) {
  1007. //获取互斥项code
  1008. const val = key == 1 ? arr[2].subLenCode : arr[1].subLenCode;
  1009. const list = obj.subMenuList.filter((it) => {
  1010. return it.code == val && it.remark.split("|")[0] == 3;
  1011. });
  1012. const dragArr = list[0].remark.split("|")[1].split(",");
  1013. this.dragArr = dragArr;
  1014. arr[1].dragArr = arr[2].dragArr = dragArr;
  1015. //取出互斥项
  1016. screenArr = obj.subMenuList.filter((item) =>
  1017. dragArr.some(
  1018. (ele) => ele === item.code && item.remark.split("|")[0] == 3
  1019. )
  1020. );
  1021. } else {
  1022. screenArr = obj.subMenuList.filter((item) => {
  1023. if (item.remark == "") {
  1024. return item;
  1025. } else {
  1026. return item.remark.split("|")[0] == (key % 3) + 1;
  1027. }
  1028. });
  1029. }
  1030. }
  1031. //危急值实验室子项目已选医学标准术语判断
  1032. if (this.form.parHasSub && this.firstPlace) {
  1033. const del =
  1034. localStorage
  1035. .getItem("zskDelDict")
  1036. .match(
  1037. new RegExp(this.firstPlace.checkedType + "-\\d+" + "-\\d+", "g")
  1038. ) || [];
  1039. if (del.length > 0) {
  1040. isDel = true;
  1041. const types = del[0].split("-");
  1042. const subobj = this.baseTypeList.find((it) => it.type == types[2]);
  1043. screenArr = subobj.subMenuList.filter((item) => {
  1044. return !types[3].includes(item.code);
  1045. });
  1046. }
  1047. if (this.form.parLenCode == "108" && this.form.parRuleType == "8") {
  1048. const subobj = this.baseTypeList.find((it) => it.type == "2");
  1049. subobj.subMenuList.splice(1, 1);
  1050. this.$set(obj, "baseTermTypeList", subobj.subMenuList);
  1051. }
  1052. }
  1053. this.$set(
  1054. this.form.klRuleByIdSub[index],
  1055. "baseTermTypeList",
  1056. (isDel && val == 2) || dragType ? screenArr : obj.subMenuList
  1057. );
  1058. this.$set(this.form.klRuleByIdSub[index], "subLenCode", "");
  1059. this.$set(this.form.klRuleByIdSub[index], "dataType", "");
  1060. this.clearConcept(index);
  1061. this.clearNumText(index);
  1062. },
  1063. clearConcept(index) {
  1064. this.$set(this.form.klRuleByIdSub[index], "subConceptId", "");
  1065. this.conceptList = [];
  1066. },
  1067. clearNumText(index) {
  1068. this.$set(this.form.klRuleByIdSub[index], "subMaxOperator", "");
  1069. this.$set(this.form.klRuleByIdSub[index], "subMaxValue", "");
  1070. this.$set(this.form.klRuleByIdSub[index], "subMaxUnit", "");
  1071. this.$set(this.form.klRuleByIdSub[index], "subMinOperator", "");
  1072. this.$set(this.form.klRuleByIdSub[index], "subMinValue", "");
  1073. this.$set(this.form.klRuleByIdSub[index], "subMinUnit", "");
  1074. this.$set(this.form.klRuleByIdSub[index], "subEqValue", "");
  1075. this.$set(this.form.klRuleByIdSub[index], "subEqOperator", "");
  1076. },
  1077. editKlRuleByIdSub(data) {
  1078. this.$set(this.form, "klRuleByIdSub", data);
  1079. // this.form.klRuleByIdSub = data;
  1080. },
  1081. // 添加分组 || 规则
  1082. addGroup(date, key, arg = { index: null, groupId: null }, index) {
  1083. /**
  1084. * @params
  1085. * date:存在则添加规则 不存在则添加分组
  1086. * arg:{index:添加规则用索引,groupId:添加分组用确切id}
  1087. */
  1088. !date && (date = new Date().valueOf());
  1089. let dataType = "";
  1090. if (this.form.parLenCode == "104" && this.form.parRuleType == "8") {
  1091. dataType = "1";
  1092. } else {
  1093. dataType = "";
  1094. }
  1095. const obj = {
  1096. groupId: date,
  1097. groupChildId: "child" + new Date().valueOf(),
  1098. baseTypes: this.baseTypeList,
  1099. baseTermTypeList: [],
  1100. conceptList: [],
  1101. subDescription: "",
  1102. parRuleType: "",
  1103. subConceptId: "",
  1104. subType: "",
  1105. subMaxOperator: "",
  1106. subMaxUnit: "",
  1107. subMaxValue: "",
  1108. subMinOperator: "",
  1109. subMinUnit: "",
  1110. subMinValue: "",
  1111. subEqValue: "",
  1112. subLenCode: "",
  1113. dataType: dataType,
  1114. };
  1115. if (
  1116. this.form.parLenCode == "108" &&
  1117. this.form.parRuleType == "8" &&
  1118. index == "1"
  1119. ) {
  1120. const subobj = this.baseTypeList.find((it) => it.type == "2");
  1121. subobj.subMenuList.push({
  1122. code: "108",
  1123. creator: "0",
  1124. firstPlace: null,
  1125. gmtCreate: "1970-01-01 12:00:00",
  1126. gmtModified: "1970-01-01 12:00:00",
  1127. id: 27106,
  1128. isDeleted: "N",
  1129. modifier: "0",
  1130. name: "实验室检查子项目",
  1131. number: null,
  1132. orderNo: 1,
  1133. parentId: 27103,
  1134. planCode: "rule",
  1135. remark: "",
  1136. ruleType: 8,
  1137. subMenuList: [],
  1138. type: null,
  1139. });
  1140. this.$set(obj, "baseTermTypeList", subobj.subMenuList);
  1141. }
  1142. if (typeof arg.index == "number") {
  1143. // 添加规则 直接在当前位置之后添加
  1144. this.form.klRuleByIdSub.splice(arg.index + 1, 0, obj);
  1145. this.$set(obj, "del", false);
  1146. const dragDel =
  1147. localStorage
  1148. .getItem("zskDragDict")
  1149. .match(new RegExp(this.ruleTermCodeStrs, "g")) || [];
  1150. if (dragDel.length > 0) {
  1151. const len = this.form.klRuleByIdSub.filter((item, i) => {
  1152. return item.groupId == date;
  1153. });
  1154. let obj = this.form.klRuleByIdSub;
  1155. obj.forEach((item, i, arr) => {
  1156. len.forEach((its, index) => {
  1157. if (item.groupId == its.groupId) {
  1158. this.$set(its, "key", index);
  1159. if (its.key > 0 && index > 0) {
  1160. const arrList = this.baseTypeList.filter((it) => {
  1161. return it.type == 1;
  1162. });
  1163. this.$set(its, "baseTypes", arrList);
  1164. }
  1165. }
  1166. });
  1167. });
  1168. if (
  1169. len.length == 3 && (key == 1 || key == 0) && key == 0
  1170. ? len[2].subLenCode
  1171. : len[1].subLenCode
  1172. ) {
  1173. const dragVal = key == 0 ? len[2].subLenCode : len[1].subLenCode;
  1174. this.dragVal = dragVal;
  1175. const subobj = this.baseTypeList.find((it) => it.type == 1);
  1176. const list = subobj.subMenuList.filter((it) => {
  1177. return it.code == dragVal && it.remark.split("|")[0] == 3;
  1178. });
  1179. // //获取互斥项code
  1180. const dragArr = list[0].remark.split("|")[1].split(",");
  1181. len[1].dragArr = len[2].dragArr = dragArr;
  1182. }
  1183. }
  1184. } else {
  1185. // 添加分组 在列表中相同groupId之后添加
  1186. // 添加分组时判断是否需要加disabled和添加默认值
  1187. if (this.form.parHasSub && this.firstPlace) {
  1188. obj.disabled = true;
  1189. const dict =
  1190. localStorage
  1191. .getItem("zskDicts")
  1192. .match(new RegExp(this.firstPlace.checkedType + "-\\d+", "g")) ||
  1193. [];
  1194. const types = dict[0].split("-");
  1195. // //因为字典传的时候第三个值没有护理所以重新赋值为9,因为这里后端逻辑问题先注释后面可能有用
  1196. // this.baseTypeList.forEach((item)=>{
  1197. // if(item.type==9){
  1198. // types[2]='9'
  1199. // }
  1200. // })
  1201. this.$set(obj, "disabled", true);
  1202. this.$set(obj, "subType", parseInt(types[2]));
  1203. const subobj = this.baseTypeList.find((it) => it.type == types[2]);
  1204. this.$set(obj, "baseTermTypeList", subobj.subMenuList);
  1205. this.$set(obj, "subLenCode", types[1]);
  1206. this.$set(obj, "subDescription", this.firstPlace.conceptName);
  1207. this.$set(obj, "subConceptId", this.firstPlace.conceptId);
  1208. this.$set(obj, "subConceptName", this.firstPlace.conceptName);
  1209. this.$set(obj, "conceptList", [this.firstPlace]);
  1210. }
  1211. var i = -1;
  1212. this.form.klRuleByIdSub.forEach((item, inx) => {
  1213. if (item.groupId === arg.groupId) {
  1214. i = inx;
  1215. }
  1216. });
  1217. this.form.klRuleByIdSub.splice(i + 1, 0, obj);
  1218. this.$set(obj, "del", true);
  1219. this.$set(obj, "key", 0);
  1220. this.dragArr = null;
  1221. }
  1222. this.$nextTick(() => {
  1223. this.$refs.tableView.scrollFun();
  1224. });
  1225. },
  1226. // 删除分组
  1227. delGroup(groupId) {
  1228. const list = this.form.klRuleByIdSub.filter(
  1229. (item) => item.groupId != groupId
  1230. );
  1231. this.form.klRuleByIdSub = list;
  1232. },
  1233. // 删除规则
  1234. delGroupChild(groupChildId, index, groupId, del, key, lens) {
  1235. let newGroupList;
  1236. const dragDel =
  1237. localStorage
  1238. .getItem("zskDragDict")
  1239. .match(new RegExp(this.ruleTermCodeStrs, "g")) || [];
  1240. let list;
  1241. if (dragDel.length > 0) {
  1242. const arr = this.form.klRuleByIdSub.filter((item, i) => {
  1243. return item.groupId != groupId;
  1244. });
  1245. const len = this.form.klRuleByIdSub.filter((item, i) => {
  1246. return item.groupId == groupId;
  1247. });
  1248. if (del) {
  1249. const date = new Date().valueOf();
  1250. if (key == 0 && arr.length > 0) {
  1251. newGroupList = this.form.klRuleByIdSub.filter((item, i) => {
  1252. return item.groupId != groupId;
  1253. });
  1254. } else {
  1255. newGroupList = [
  1256. {
  1257. groupId: date,
  1258. groupChildId: "child" + new Date().valueOf(),
  1259. baseTypes: this.baseTypeList,
  1260. baseTermTypeList: [],
  1261. conceptList: [],
  1262. subDescription: "",
  1263. parRuleType: "",
  1264. subConceptId: "",
  1265. subType: "",
  1266. subMaxOperator: "",
  1267. subMaxUnit: "",
  1268. subMaxValue: "",
  1269. subMinOperator: "",
  1270. subMinUnit: "",
  1271. subMinValue: "",
  1272. subEqValue: "",
  1273. subLenCode: "",
  1274. dataType: "",
  1275. key: 0,
  1276. del: true,
  1277. },
  1278. ];
  1279. this.dragVal = null;
  1280. this.dragArr = null;
  1281. }
  1282. } else if (key == 1) {
  1283. let klRuleByIdSub = JSON.parse(
  1284. JSON.stringify(this.form.klRuleByIdSub)
  1285. );
  1286. for (let i = klRuleByIdSub.length - 1; i >= 0; i--) {
  1287. if (
  1288. klRuleByIdSub[i].groupId == groupId &&
  1289. klRuleByIdSub[i].key > 0
  1290. ) {
  1291. klRuleByIdSub.splice(i, 1);
  1292. }
  1293. }
  1294. newGroupList = klRuleByIdSub;
  1295. this.dragVal = null;
  1296. this.dragArr = null;
  1297. } else {
  1298. newGroupList = this.form.klRuleByIdSub.filter(
  1299. (item) => item.groupChildId != groupChildId
  1300. );
  1301. if (lens == 4) {
  1302. const obj = this.baseTypeList.find((it) => it.type === 1);
  1303. const screenArr = obj.subMenuList.filter((item) => {
  1304. return item.remark.split("|")[0] == 2;
  1305. });
  1306. len[1].baseTermTypeList = screenArr;
  1307. }
  1308. this.dragVal = len[1].subLenCode;
  1309. }
  1310. } else {
  1311. newGroupList = this.form.klRuleByIdSub.filter(
  1312. (item) => item.groupChildId != groupChildId
  1313. );
  1314. }
  1315. this.form.klRuleByIdSub = newGroupList;
  1316. },
  1317. setDict() {
  1318. this.dict = localStorage.getItem("zskDicts");
  1319. this.msgDict = localStorage.getItem("zskMsgDict");
  1320. this.subDict = localStorage.getItem("zskSubDict");
  1321. },
  1322. showConfirmDialog(msg, resolve) {
  1323. this.$alert(msg, "提示", {
  1324. confirmButtonText: "确定",
  1325. type: "warning",
  1326. })
  1327. .then(() => {
  1328. resolve();
  1329. })
  1330. .catch(() => {});
  1331. },
  1332. searchConcept(val) {
  1333. const param = {
  1334. excludedConceptIds: [this.form.parRuleType],
  1335. libType: this.form.parLenCode,
  1336. name: val,
  1337. };
  1338. api
  1339. .searchConcept(param)
  1340. .then((res) => {
  1341. if (res.data.code == "0") {
  1342. const data = res.data.data;
  1343. this.conceptList = data;
  1344. }
  1345. })
  1346. .catch((error) => {
  1347. console.log(error);
  1348. });
  1349. },
  1350. getTypeList() {
  1351. this.ruleTypeList = JSON.parse(localStorage.getItem("zskTypesList"));
  1352. },
  1353. saveRule(params) {
  1354. api.saveRule(params).then((res) => {
  1355. if (res.data.code == 0) {
  1356. this.$message({
  1357. message: "操作成功",
  1358. type: "success",
  1359. });
  1360. this.$router.push({
  1361. name: "ZskRuleManager",
  1362. params: Object.assign({}, this.$route.params, { currentPage: 1 }),
  1363. });
  1364. } else {
  1365. this.$message({
  1366. message: res.data.msg,
  1367. type: "warning",
  1368. });
  1369. }
  1370. });
  1371. },
  1372. /**
  1373. * 子组件调用方法
  1374. */
  1375. childClearConcept(index) {
  1376. this.$set(this.form.klRuleByIdSub[index], "subConceptId", "");
  1377. this.$set(this.form.klRuleByIdSub[index], "conceptList", []);
  1378. },
  1379. childClearNumText(index) {
  1380. let obj = JSON.parse(JSON.stringify(this.form.klRuleByIdSub));
  1381. obj[index].subMaxOperator = "";
  1382. obj[index].subMaxValue = "";
  1383. obj[index].subMaxUnit = "";
  1384. obj[index].subMinOperator = "";
  1385. obj[index].subMinValue = "";
  1386. obj[index].subMinUnit = "";
  1387. obj[index].subEqValue = "";
  1388. // this.$set(obj[index], "subEqValue", "");
  1389. obj[index].subEqOperator = "";
  1390. // this.klRuleByIdSub = obj;
  1391. // this.$emit("editKlRuleByIdSub", obj);
  1392. this.editKlRuleByIdSub(obj);
  1393. },
  1394. ChildDataTypeChange(val, index) {
  1395. this.form.klRuleByIdSub[index].subEqOperator = val === "2" ? "=" : "";
  1396. this.$set(
  1397. this.form.klRuleByIdSub[index],
  1398. "subEqOperator",
  1399. val === "2" ? "=" : ""
  1400. );
  1401. this.childClearNumText(index);
  1402. // TODO 新增的内容追踪不到
  1403. this.form.klRuleByIdSub.forEach((item, i) => {
  1404. if (index === i) {
  1405. this.$set(item, "dataType", val);
  1406. }
  1407. });
  1408. },
  1409. childSubCodeChange(val, index, numTypes, groupId, key, code, lens) {
  1410. const dragDel =
  1411. localStorage
  1412. .getItem("zskDragDict")
  1413. .match(new RegExp(this.ruleTermCodeStrs, "g")) || [];
  1414. const subobj = this.baseTypeList.find((it) => it.type == 1);
  1415. let obj = this.form.klRuleByIdSub;
  1416. let type;
  1417. const len = this.form.klRuleByIdSub.filter((item, i) => {
  1418. return item.groupId == groupId;
  1419. });
  1420. const inx = key % 3 == 2 ? index - 1 : key % 3 == 1 ? index + 1 : index;
  1421. if (key == 1 && len[2]) {
  1422. type = len[2].subLenCode == "" ? false : true;
  1423. } else if (key == 2) {
  1424. type = len[1].subLenCode == "" ? false : true;
  1425. }
  1426. //判断药品合理性总条数是否大于1条,是否存在第二条或第三条类型为1,存在触发互斥
  1427. if (
  1428. //判断3条规则是否都已选中
  1429. dragDel.length > 0 &&
  1430. len.length == 3 &&
  1431. index > 0 &&
  1432. key > 0
  1433. ) {
  1434. if (type) {
  1435. //判断是否存在符合互斥条件的两条出具,若存在,置空另一条出具
  1436. if (
  1437. code != "" &&
  1438. (key == 1
  1439. ? len[2].dragArr.indexOf(val)
  1440. : len[1].dragArr.indexOf(val)) > -1 &&
  1441. lens == 4
  1442. ) {
  1443. //剂型给药途径互斥判断
  1444. const arr = this.baseTypeList.filter((it) => {
  1445. return it.type == 1;
  1446. });
  1447. this.$set(this.form.klRuleByIdSub, inx, {
  1448. groupId: this.form.klRuleByIdSub[inx].groupId,
  1449. groupChildId: "child" + new Date().valueOf(),
  1450. baseTypes: arr,
  1451. baseTermTypeList: [],
  1452. conceptList: [],
  1453. subDescription: "",
  1454. parRuleType: "",
  1455. subConceptId: "",
  1456. subType: "",
  1457. subMaxOperator: "",
  1458. subMaxUnit: "",
  1459. subMaxValue: "",
  1460. subMinOperator: "",
  1461. subMinUnit: "",
  1462. subMinValue: "",
  1463. subEqValue: "",
  1464. subLenCode: "",
  1465. dataType: "",
  1466. del: false,
  1467. key: key == 2 ? 1 : 2,
  1468. });
  1469. }
  1470. } else {
  1471. const list = subobj.subMenuList.filter((it) => {
  1472. return it.code == val && it.remark.split("|")[0] == 3;
  1473. });
  1474. //获取互斥项code
  1475. const dragArr = list[0].remark.split("|")[1].split(",");
  1476. this.dragArr = dragArr;
  1477. len[1].dragArr = dragArr;
  1478. len[2].dragArr = dragArr;
  1479. // if (len[1]) {
  1480. // len[1].dragArr = dragArr;
  1481. // } else if (len[2]) {
  1482. // len[2].dragArr = dragArr;
  1483. // }
  1484. //获取互斥项
  1485. const screenArr = subobj.subMenuList.filter((item) =>
  1486. dragArr.some(
  1487. (ele) => ele === item.code && item.remark.split("|")[0] == 3
  1488. )
  1489. );
  1490. if (
  1491. this.form.klRuleByIdSub[inx] &&
  1492. this.form.klRuleByIdSub[inx].subType != ""
  1493. ) {
  1494. this.$set(
  1495. this.form.klRuleByIdSub[inx],
  1496. "baseTermTypeList",
  1497. screenArr
  1498. );
  1499. }
  1500. }
  1501. this.dragVal = val;
  1502. }
  1503. if ((numTypes + ",").indexOf(val + ",") > -1) {
  1504. this.$set(this.form.klRuleByIdSub[index], "dataType", "1");
  1505. } else {
  1506. this.$set(this.form.klRuleByIdSub[index], "dataType", "");
  1507. }
  1508. this.childClearConcept(index);
  1509. this.childClearNumText(index);
  1510. },
  1511. // 去重
  1512. unique(arr, obj) {
  1513. return arr.reduce((cur, next) => {
  1514. obj[next] ? "" : (obj[next] = true && cur.push(next));
  1515. return cur;
  1516. }, []);
  1517. },
  1518. },
  1519. watch: {
  1520. form: {
  1521. handler(val) {
  1522. if (val.klRuleByIdSub) {
  1523. this.form.klRuleByIdSub.forEach((item, i, arr) => {
  1524. if (i == 0) {
  1525. item.rowIndex = 1;
  1526. } else if (item.groupId == arr[i - 1].groupId) {
  1527. item.rowIndex = arr[i - 1].rowIndex;
  1528. } else {
  1529. item.rowIndex = arr[i - 1].rowIndex + 1;
  1530. }
  1531. });
  1532. }
  1533. },
  1534. immediate: true,
  1535. deep: true,
  1536. },
  1537. },
  1538. computed: {
  1539. disable: function () {
  1540. return Object.keys(this.firstPlace || {}).length > 0;
  1541. },
  1542. ruleTermCodeStr: function () {
  1543. const str = this.form.parRuleType + "-" + this.form.parLenCode + "-" + 1;
  1544. if (str.length <= 1) {
  1545. return "";
  1546. }
  1547. return str;
  1548. },
  1549. ruleTermCodeStr2: function () {
  1550. const str = this.form.parRuleType + "-" + this.form.parLenCode + "-" + 0;
  1551. if (str.length <= 1) {
  1552. return "";
  1553. }
  1554. return str;
  1555. },
  1556. ruleTermCodeStrs: function () {
  1557. const str = this.form.parRuleType + "-" + this.form.parLenCode;
  1558. if (str.length <= 1) {
  1559. return "";
  1560. }
  1561. return str;
  1562. },
  1563. showMsg: function () {
  1564. return (
  1565. this.ruleTermCodeStr.length > 2 &&
  1566. this.msgDict.indexOf(this.ruleTermCodeStr) > -1
  1567. );
  1568. },
  1569. showMsg2: function () {
  1570. return (
  1571. this.ruleTermCodeStr2.length > 2 &&
  1572. this.msgDict.indexOf(this.ruleTermCodeStr2) > -1
  1573. );
  1574. },
  1575. showHasSub() {
  1576. if (this.ruleTermCodeStrs.length > 2) {
  1577. console.log(this.subDict.indexOf(this.ruleTermCodeStrs) != -1);
  1578. return this.subDict.indexOf(this.ruleTermCodeStrs) != -1;
  1579. }
  1580. return false;
  1581. },
  1582. checkFirstPlace: function () {
  1583. return this.dict.indexOf(this.ruleTermCodeStrs) > -1;
  1584. },
  1585. },
  1586. components: { AddNewRuleTable, AddNewRuleContent },
  1587. };
  1588. </script>