AddNewRule.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  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. >
  118. </el-option>
  119. </el-select>
  120. <template slot="error" slot-scope="scope">
  121. <div class="my_error">
  122. <el-tooltip
  123. class="item"
  124. effect="light"
  125. :content="scope.error"
  126. placement="top-start"
  127. popper-class="popper_class"
  128. >
  129. <img src="../../images/exclamationpoint.png" alt="" />
  130. </el-tooltip>
  131. </div>
  132. </template>
  133. <div class="tip_text">
  134. 注:更改规则类型,将会清空已填写的规则内容~
  135. </div>
  136. </el-form-item>
  137. </div>
  138. <div class="table_cell">
  139. <!-- 规则术语类型: -->
  140. <el-form-item
  141. label-width="130px"
  142. label="规则术语类型:"
  143. :rules="rules.parLenCode"
  144. prop="parLenCode"
  145. >
  146. <template slot="error" slot-scope="scope">
  147. <div class="my_error">
  148. <el-tooltip
  149. class="item"
  150. effect="light"
  151. :content="scope.error"
  152. placement="top-start"
  153. popper-class="popper_class"
  154. >
  155. <img src="../../images/exclamationpoint.png" alt="" />
  156. </el-tooltip>
  157. </div>
  158. </template>
  159. <el-select
  160. v-model="form.parLenCode"
  161. placeholder="请选择"
  162. @change="ruleTermChange"
  163. >
  164. <el-option
  165. v-for="item in ruleTermTypeList"
  166. :key="item.id"
  167. :label="item.name"
  168. :value="item.code"
  169. >
  170. </el-option>
  171. </el-select>
  172. <div class="tip_text">
  173. 注:更改规则术语类型,将会清空已填写的规则内容~
  174. </div>
  175. </el-form-item>
  176. </div>
  177. <div class="table_cell">
  178. <el-form-item
  179. label-width="130px"
  180. label="医学标准术语:"
  181. :style="{ height: '100%' }"
  182. :rules="rules.parConceptId"
  183. prop="parConceptId"
  184. >
  185. <el-select
  186. clearable
  187. filterable
  188. remote
  189. :remote-method="searchConcept"
  190. v-model.trim="form.parConceptId"
  191. @change="parConceptIdChange"
  192. >
  193. <el-option
  194. v-for="item in conceptList"
  195. :key="item.conceptId"
  196. :label="item.conceptName"
  197. :value="item.conceptId"
  198. >
  199. </el-option>
  200. </el-select>
  201. </el-form-item>
  202. </div>
  203. <div class="table_cell" v-if="showHasSub" style="max-width: 25%">
  204. <el-form-item
  205. label-width="130px"
  206. label="有无子条件:"
  207. :rules="rules.parHasSub"
  208. prop="parHasSub"
  209. >
  210. <el-select
  211. v-model="form.parHasSub"
  212. placeholder="请选择"
  213. @change="hasSubChange"
  214. >
  215. <el-option label="有" :value="1"></el-option>
  216. <el-option label="无" :value="0"></el-option>
  217. </el-select>
  218. </el-form-item>
  219. </div>
  220. <div
  221. class="table_cell"
  222. style="flex: 3; max-width: 50%"
  223. v-if="showMsg"
  224. >
  225. <el-form-item
  226. label-width="130px"
  227. label="附加信息:"
  228. :rules="rules.parMsg"
  229. prop="parMsg"
  230. >
  231. <el-input
  232. type="textarea"
  233. :rows="1"
  234. placeholder="请输入附加信息"
  235. v-model.trim="form.parMsg"
  236. ></el-input>
  237. </el-form-item>
  238. </div>
  239. </div>
  240. <!-- 表格 -->
  241. <AddNewRuleTable
  242. ref="tableView"
  243. v-if="form.parHasSub && tableShow"
  244. :klRuleByIdSub="form.klRuleByIdSub"
  245. :maxNum="subRuleMaxNum"
  246. @subTypeChange="subTypeChange"
  247. @searchConcept="searchConcept"
  248. @addGroup="addGroup"
  249. @delGroup="delGroup"
  250. @delGroupChild="delGroupChild"
  251. @setFormData="setFormData"
  252. @editKlRuleByIdSub="editKlRuleByIdSub"
  253. @clearValidate="clearValidate"
  254. />
  255. <el-form-item>
  256. <div class="form_btn">
  257. <el-button
  258. type="primary"
  259. size="medium "
  260. @click="submitForm('ruleForm')"
  261. >确定</el-button
  262. >
  263. </div>
  264. </el-form-item>
  265. </el-form>
  266. </div>
  267. </div>
  268. </template>
  269. <script type="text/javascript">
  270. import api from "@api/knowledgeLib.js";
  271. import { formRules } from "./rules";
  272. import AddNewRuleTable from "./AddNewRuleTable";
  273. export default {
  274. name: "AddRule",
  275. data() {
  276. return {
  277. title: "规则维护-添加规则",
  278. ruleTypeList: [], //规则类型列表 1
  279. ruleTermTypeList: [], //规则术语类型列表 2
  280. conceptList: [], //医学标准术语列表 3
  281. baseTypeList: [], //基础规则类型列表 4
  282. baseTermTypeList: [], //基础规则术语类型 5
  283. subRuleMaxNum: null, //规则内容中规则的限制个数
  284. isCopy: false,
  285. parId: null,
  286. msgDict: "", //显示附加信息的类型
  287. firstPlace: null,
  288. tableShow: true,
  289. form: {
  290. parDescription: "",
  291. parRuleType: "",
  292. parConceptId: "",
  293. parlibName: "",
  294. parLenName: "",
  295. parHasSub: undefined,
  296. parLenCode: "",
  297. parMsg: "",
  298. klRuleByIdSub: []
  299. },
  300. rules: formRules
  301. };
  302. },
  303. created() {
  304. this.getTypeList();
  305. this.setDict();
  306. const param = this.$route.params;
  307. let info = param.data;
  308. if (info) {
  309. this.parId = info.parId;
  310. this.isCopy = param.copy;
  311. this.title = "规则维护-" + (this.isCopy ? "复制" : "修改") + "规则";
  312. this.form = JSON.parse(JSON.stringify(info));
  313. // 编辑初始化选择框
  314. this.initEdidData();
  315. }
  316. },
  317. methods: {
  318. clearValidate(data) {
  319. this.$refs.ruleForm.clearValidate(data);
  320. },
  321. // 编辑初始化
  322. async initEdidData() {
  323. // 规则术语类型初始化
  324. const newruleTermTypeList = await this.ruleTypeList.find(
  325. (it) => it.id == this.form.parRuleType
  326. );
  327. this.ruleTermTypeList = await newruleTermTypeList.subMenuList;
  328. // 基础规则类型初始化
  329. const obj = await this.ruleTermTypeList.find(
  330. (it1) => it1.code == this.form.parLenCode
  331. );
  332. this.baseTypeList = obj.subMenuList;
  333. this.subRuleMaxNum = obj.number;
  334. this.conceptList = [
  335. { conceptName: this.form.parlibName, conceptId: this.form.parConceptId }
  336. ];
  337. if (this.form.parConceptId && this.checkFirstPlace && this.conceptList) {
  338. this.firstPlace = this.conceptList.find(
  339. (it) => it.conceptId === this.form.parConceptId
  340. );
  341. if (this.firstPlace) {
  342. this.firstPlace["checkedType"] = this.ruleTermCodeStr;
  343. }
  344. } else if (!this.form.parConceptId) {
  345. this.setInitGroupData();
  346. this.firstPlace = null;
  347. } else {
  348. this.firstPlace = null;
  349. }
  350. await this.form.klRuleByIdSub.forEach((item, i, arr) => {
  351. item.groupId = "groupId" + item.groupType;
  352. item.groupChildId = "child" + item.subId;
  353. //TODO => 赋值时一定要注意set更新页面
  354. this.$set(item, "baseTypes", [...this.baseTypeList]);
  355. this.$set(
  356. item,
  357. "baseTermTypeList",
  358. item.baseTypes.find((it2) => it2.type === item.subType).subMenuList
  359. );
  360. this.$set(item, "conceptList", [
  361. {
  362. conceptName: item.subLibName || item.subConceptName,
  363. conceptId: item.subConceptId
  364. }
  365. ]);
  366. if (item.subMaxOperator || item.subMinOperator) {
  367. item.dataType = "1";
  368. } else if (item.subEqValue) {
  369. item.dataType = "2";
  370. }
  371. // disable
  372. if (this.form.parHasSub && this.firstPlace) {
  373. if (arr[i - 1] && arr[i - 1].groupId == item.groupId) {
  374. this.$set(item, "disabled", false);
  375. } else {
  376. this.$set(item, "disabled", true);
  377. }
  378. }
  379. });
  380. },
  381. // 提交
  382. submitForm(formName) {
  383. this.$refs[formName].validate((valid) => {
  384. if (valid) {
  385. let params = JSON.parse(JSON.stringify(this.form));
  386. params.klRuleInfoSaveSub = params.klRuleByIdSub;
  387. delete params.klRuleByIdSub;
  388. params.klRuleInfoSaveSub.forEach((item, i, arr) => {
  389. if (i === 0) {
  390. item.groupType = 1;
  391. } else {
  392. if (item.groupId == arr[i - 1].groupId) {
  393. item.groupType = arr[i - 1].groupType;
  394. } else {
  395. item.groupType = arr[i - 1].groupType + 1;
  396. }
  397. }
  398. });
  399. params.klRuleInfoSaveSub.forEach((ite) => {
  400. delete ite.groupId;
  401. delete ite.groupChildId;
  402. delete ite.rowIndex;
  403. delete ite.baseTypes;
  404. delete ite.baseTermTypeList;
  405. delete ite.conceptList;
  406. });
  407. if (this.parId) {
  408. params.parId = this.isCopy ? undefined : this.parId;
  409. params.parStatus = this.isCopy ? 1 : this.form.parStatus;
  410. }
  411. this.saveRule(params);
  412. } else {
  413. return false;
  414. }
  415. });
  416. },
  417. // 子集修改父级的数组
  418. setFormData(index, data) {
  419. this.form.klRuleByIdSub[index].conceptList = data;
  420. },
  421. // table_form 规则类型选中
  422. ruleTypeChange(val) {
  423. this.form.parLenCode = "";
  424. this.form.parMsg = "";
  425. const obj = this.ruleTypeList.find((it) => it.id === val);
  426. this.ruleTermTypeList = obj.subMenuList;
  427. this.subRuleMaxNum = undefined;
  428. this.setInitGroupData();
  429. },
  430. // table_form 规则术语类型选中
  431. ruleTermChange(val) {
  432. this.form.parMsg = "";
  433. const obj = this.ruleTermTypeList.find((it) => it.code === val);
  434. this.form.parLenName = obj.name;
  435. this.baseTypeList = obj.subMenuList;
  436. this.subRuleMaxNum = obj.number;
  437. this.form.parHasSub = obj.subMenuList.length ? 1 : 0;
  438. this.setInitGroupData();
  439. },
  440. // 医学标准术语
  441. parConceptIdChange(val) {
  442. this.$nextTick(() => {
  443. if (val && this.checkFirstPlace && this.conceptList) {
  444. this.firstPlace = this.conceptList.find((it) => it.conceptId === val);
  445. if (this.firstPlace) {
  446. this.firstPlace["checkedType"] = this.ruleTermCodeStr;
  447. }
  448. } else if (!val) {
  449. this.setInitGroupData();
  450. this.firstPlace = null;
  451. } else {
  452. this.firstPlace = null;
  453. }
  454. if (this.form.parHasSub && this.firstPlace) {
  455. const dict =
  456. localStorage
  457. .getItem("zskDicts")
  458. .match(new RegExp(this.firstPlace.checkedType + "-\\d+", "g")) ||
  459. [];
  460. const types = dict[0].split("-");
  461. let obj = this.form.klRuleByIdSub;
  462. obj.forEach((item, i, arr) => {
  463. if (arr[i - 1] && arr[i - 1].groupId == item.groupId) {
  464. this.$set(item, "disabled", false);
  465. } else {
  466. this.$set(item, "disabled", true);
  467. this.$set(item, "subType", parseInt(types[2]));
  468. const subobj = this.baseTypeList.find(
  469. (it) => it.type == types[2]
  470. );
  471. this.$set(item, "baseTermTypeList", subobj.subMenuList);
  472. this.$set(item, "subLenCode", types[1]);
  473. this.$set(item, "subDescription", this.firstPlace.conceptName);
  474. this.$set(item, "subConceptId", this.firstPlace.conceptId);
  475. this.$set(item, "subConceptName", this.firstPlace.conceptName);
  476. this.$set(item, "conceptList", [this.firstPlace]);
  477. }
  478. });
  479. this.$set(this.form, "klRuleByIdSub", obj);
  480. }
  481. });
  482. },
  483. // 初始化表格
  484. setInitGroupData(init) {
  485. this.tableShow = false;
  486. const date = new Date().valueOf();
  487. this.$nextTick(() => {
  488. if (this.form.parHasSub && this.form.parHasSub != 0) {
  489. this.$set(this.form, "klRuleByIdSub", [
  490. {
  491. groupId: date,
  492. groupChildId: "child" + new Date().valueOf(),
  493. baseTypes: this.baseTypeList,
  494. baseTermTypeList: [],
  495. conceptList: [],
  496. subDescription: "",
  497. parRuleType: "",
  498. subConceptId: "",
  499. subType: "",
  500. subMaxOperator: "",
  501. subMaxUnit: "",
  502. subMaxValue: "",
  503. subMinOperator: "",
  504. subMinUnit: "",
  505. subMinValue: "",
  506. subEqValue: "",
  507. subLenCode: "",
  508. dataType: ""
  509. }
  510. ]);
  511. } else {
  512. this.$set(this.form, "klRuleByIdSub", []);
  513. }
  514. if (!init) {
  515. this.form.parConceptId = ""; //医学标准术语清空
  516. this.conceptList = []; //下拉列表清空
  517. this.firstPlace = null;
  518. }
  519. this.tableShow = true;
  520. });
  521. },
  522. // 有无子条件切换
  523. hasSubChange(val) {
  524. if (val) {
  525. this.setInitGroupData(true);
  526. } else {
  527. this.form.klRuleByIdSub = [];
  528. }
  529. },
  530. // 基础规则类型切换
  531. subTypeChange(val, index) {
  532. // index
  533. const obj = this.baseTypeList.find((it) => it.type === val);
  534. this.form.klRuleByIdSub[index].baseTermTypeList = obj.subMenuList;
  535. this.form.klRuleByIdSub[index].subLenCode = "";
  536. this.form.klRuleByIdSub[index].dataType = "";
  537. this.clearConcept(index);
  538. this.clearNumText(index);
  539. },
  540. clearConcept(index) {
  541. this.form.klRuleByIdSub[index].subConceptId = "";
  542. this.conceptList = [];
  543. },
  544. clearNumText(index) {
  545. this.form.klRuleByIdSub[index].subMaxOperator = "";
  546. this.form.klRuleByIdSub[index].subMaxValue = "";
  547. this.form.klRuleByIdSub[index].subMaxUnit = "";
  548. this.form.klRuleByIdSub[index].subMinOperator = "";
  549. this.form.klRuleByIdSub[index].subMinValue = "";
  550. this.form.klRuleByIdSub[index].subMinUnit = "";
  551. this.form.klRuleByIdSub[index].subEqValue = "";
  552. this.form.klRuleByIdSub[index].subEqOperator = "";
  553. },
  554. editKlRuleByIdSub(data) {
  555. this.form.klRuleByIdSub = data;
  556. },
  557. // 添加分组 || 规则
  558. addGroup(date, arg = { index: null, groupId: null }) {
  559. /**
  560. * @params
  561. * date:存在则添加规则 不存在则添加分组
  562. * arg:{index:添加规则用索引,groupId:添加分组用确切id}
  563. */
  564. !date && (date = new Date().valueOf());
  565. const obj = {
  566. groupId: date,
  567. groupChildId: "child" + new Date().valueOf(),
  568. baseTypes: this.baseTypeList,
  569. baseTermTypeList: [],
  570. conceptList: [],
  571. subDescription: "",
  572. parRuleType: "",
  573. subConceptId: "",
  574. subType: "",
  575. subMaxOperator: "",
  576. subMaxUnit: "",
  577. subMaxValue: "",
  578. subMinOperator: "",
  579. subMinUnit: "",
  580. subMinValue: "",
  581. subEqValue: "",
  582. subLenCode: "",
  583. dataType: ""
  584. };
  585. if (typeof arg.index == "number") {
  586. // 添加规则 直接在当前位置之后添加
  587. this.form.klRuleByIdSub.splice(arg.index + 1, 0, obj);
  588. } else {
  589. // 添加分组 在列表中相同groupId之后添加
  590. // 添加分组时判断是否需要加disabled和添加默认值
  591. if (this.form.parHasSub && this.firstPlace) {
  592. obj.disabled = true;
  593. const dict =
  594. localStorage
  595. .getItem("zskDicts")
  596. .match(new RegExp(this.firstPlace.checkedType + "-\\d+", "g")) ||
  597. [];
  598. const types = dict[0].split("-");
  599. this.$set(obj, "disabled", true);
  600. this.$set(obj, "subType", parseInt(types[2]));
  601. const subobj = this.baseTypeList.find((it) => it.type == types[2]);
  602. this.$set(obj, "baseTermTypeList", subobj.subMenuList);
  603. this.$set(obj, "subLenCode", types[1]);
  604. this.$set(obj, "subDescription", this.firstPlace.conceptName);
  605. this.$set(obj, "subConceptId", this.firstPlace.conceptId);
  606. this.$set(obj, "subConceptName", this.firstPlace.conceptName);
  607. this.$set(obj, "conceptList", [this.firstPlace]);
  608. }
  609. var i = -1;
  610. this.form.klRuleByIdSub.forEach((item, inx) => {
  611. if (item.groupId === arg.groupId) {
  612. i = inx;
  613. }
  614. });
  615. this.form.klRuleByIdSub.splice(i + 1, 0, obj);
  616. }
  617. this.$nextTick(() => {
  618. this.$refs.tableView.scrollFun();
  619. });
  620. },
  621. // 删除分组
  622. delGroup(groupId) {
  623. const list = this.form.klRuleByIdSub.filter(
  624. (item) => item.groupId != groupId
  625. );
  626. this.form.klRuleByIdSub = list;
  627. },
  628. // 删除规则
  629. delGroupChild(groupChildId) {
  630. const newGroupList = this.form.klRuleByIdSub.filter(
  631. (item) => item.groupChildId != groupChildId
  632. );
  633. this.form.klRuleByIdSub = newGroupList;
  634. },
  635. setDict() {
  636. this.dict = localStorage.getItem("zskDicts");
  637. this.msgDict = localStorage.getItem("zskMsgDict");
  638. this.subDict = localStorage.getItem("zskSubDict");
  639. },
  640. showConfirmDialog(msg, resolve) {
  641. this.$alert(msg, "提示", {
  642. confirmButtonText: "确定",
  643. type: "warning"
  644. })
  645. .then(() => {
  646. resolve();
  647. })
  648. .catch(() => {});
  649. },
  650. searchConcept(val) {
  651. const param = {
  652. excludedConceptIds: [this.form.parRuleType],
  653. libType: this.form.parLenCode,
  654. name: val
  655. };
  656. api
  657. .searchConcept(param)
  658. .then((res) => {
  659. if (res.data.code == "0") {
  660. const data = res.data.data;
  661. this.conceptList = data;
  662. }
  663. })
  664. .catch((error) => {
  665. console.log(error);
  666. });
  667. },
  668. getTypeList() {
  669. this.ruleTypeList = JSON.parse(localStorage.getItem("zskTypesList"));
  670. },
  671. saveRule(params) {
  672. api.saveRule(params).then((res) => {
  673. if (res.data.code == 0) {
  674. this.$message({
  675. message: "操作成功",
  676. type: "success"
  677. });
  678. this.$router.push({
  679. name: "ZskRuleManager",
  680. params: Object.assign({}, this.$route.params, { currentPage: 1 })
  681. });
  682. } else {
  683. this.$message({
  684. message: res.data.msg,
  685. type: "warning"
  686. });
  687. }
  688. });
  689. }
  690. },
  691. watch: {
  692. "form.klRuleByIdSub": {
  693. handler(val) {
  694. this.form.klRuleByIdSub.forEach((item, i, arr) => {
  695. if (i == 0) {
  696. item.rowIndex = 1;
  697. } else if (item.groupId == arr[i - 1].groupId) {
  698. item.rowIndex = arr[i - 1].rowIndex;
  699. } else {
  700. item.rowIndex = arr[i - 1].rowIndex + 1;
  701. }
  702. });
  703. },
  704. deep: true
  705. }
  706. // "form.parHasSub"(val) {
  707. // console.log(val);
  708. // console.log(this.form);
  709. // // if (!val || val == 0) {
  710. // // // this.form.klRuleByIdSub = [];
  711. // // this.$set(this.form, "klRuleByIdSub", []);
  712. // // console.log(this.form);
  713. // // }
  714. // }
  715. },
  716. computed: {
  717. disable: function () {
  718. return Object.keys(this.firstPlace || {}).length > 0;
  719. },
  720. ruleTermCodeStr: function () {
  721. const str = this.form.parRuleType + "-" + this.form.parLenCode;
  722. if (str.length <= 1) {
  723. return "";
  724. }
  725. return str;
  726. },
  727. showMsg: function () {
  728. return (
  729. this.ruleTermCodeStr.length > 2 &&
  730. this.msgDict.indexOf(this.ruleTermCodeStr) > -1
  731. );
  732. },
  733. showHasSub() {
  734. if (this.ruleTermCodeStr.length > 2) {
  735. return this.subDict.indexOf(this.ruleTermCodeStr) != -1;
  736. }
  737. return false;
  738. },
  739. checkFirstPlace: function () {
  740. return this.dict.indexOf(this.ruleTermCodeStr) > -1;
  741. }
  742. },
  743. components: { AddNewRuleTable }
  744. };
  745. </script>