AddNewRule.vue 49 KB

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