AddNewRule.vue 47 KB

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