AddNewRule.vue 49 KB

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