AddNewRule.vue 47 KB

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