AddNewRuleTable.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801
  1. <style lang="less" scoped>
  2. .AddNewRuleTable {
  3. width: 100%;
  4. background: #fff;
  5. margin-top: 10px;
  6. padding: 20px;
  7. box-sizing: border-box;
  8. /deep/ .el-table .el-input--mini .el-input__inner,
  9. .el-select {
  10. width: 100%;
  11. font-size: 12px;
  12. }
  13. .btn_box {
  14. width: 100%;
  15. height: 100%;
  16. display: flex;
  17. align-items: center;
  18. justify-content: space-around;
  19. .btn_div {
  20. flex: 1;
  21. display: flex;
  22. align-items: center;
  23. justify-content: center;
  24. }
  25. img {
  26. width: 16px;
  27. height: 16px;
  28. cursor: pointer;
  29. }
  30. }
  31. .inp_box {
  32. // width: 100px;
  33. height: 100%;
  34. margin: 0 auto;
  35. }
  36. /deep/ .el-form-item__error {
  37. // position: absolute;
  38. top: 28px;
  39. }
  40. .type_content {
  41. /deep/ .el-form-item--mini.el-form-item,
  42. .el-form-item--small.el-form-item {
  43. margin: 0;
  44. width: 100%;
  45. }
  46. display: flex;
  47. .type_content_item1 {
  48. /deep/ .el-form-item__content {
  49. padding-bottom: 8px;
  50. }
  51. .row_box {
  52. .el-col {
  53. /deep/ .el-form-item__content {
  54. position: static;
  55. }
  56. /deep/ .el-form-item__error {
  57. position: absolute;
  58. width: 260px;
  59. left: 72px;
  60. white-space: normal;
  61. }
  62. }
  63. }
  64. }
  65. /deep/ .el-input.is-disabled .el-input__inner {
  66. color: #888;
  67. }
  68. }
  69. .custom_table_header {
  70. vertical-align: middle;
  71. &::before {
  72. content: "*";
  73. color: red;
  74. font-size: 12px;
  75. margin-right: 4px;
  76. }
  77. }
  78. // ::v-deep .el-table tbody tr:hover > td {
  79. // // background-color: transparent;
  80. // }
  81. /deep/ .el-table th {
  82. background: transparent;
  83. }
  84. /deep/ .el-form-item__content {
  85. padding-bottom: 14px;
  86. }
  87. .table_cell_cls {
  88. vertical-align: top;
  89. }
  90. // /deep/ .el-table__body .el-table__row.hover-row td {
  91. // // background-color: transparent;
  92. // }
  93. /deep/ .el-form-item__label {
  94. font-size: 12px;
  95. }
  96. h4 {
  97. font-size: 14px;
  98. font-weight: 400;
  99. }
  100. // /deep/ .el-table__body tr.current-row>td{
  101. // background: #fff;
  102. // }
  103. /deep/ .el-table .cell {
  104. // overflow: initial;
  105. }
  106. }
  107. </style>
  108. <template>
  109. <!-- :prop="`klRuleByIdSub[${scope.$index}].subDescription`" -->
  110. <div class="AddNewRuleTable">
  111. <h4 style="margin-bottom: 24px">规则内容:</h4>
  112. <!-- 隔行换色 :row-style="rowStyle" -->
  113. <el-table
  114. border
  115. :data="klRuleByIdSub"
  116. size="mini"
  117. style="min-height: 200px"
  118. height="calc(100vh - 383px)"
  119. :header-row-style="{ background: '#E3EAF4' }"
  120. :cell-style="cellStyle"
  121. :span-method="ObjectSpanMethod"
  122. ref="table"
  123. row-key="groupChildId"
  124. >
  125. <el-table-column width="80px" label="组" prop="groupType" fixed="left">
  126. <template slot-scope="scope">
  127. <div class="btn_box">
  128. <div class="btn_div">
  129. <img
  130. @click="addGroup(scope)"
  131. src="../../images/add-new-rule-sub.png"
  132. alt=""
  133. />
  134. </div>
  135. <div class="btn_div" v-if="!isLastDate(scope.row.groupId)">
  136. <img
  137. @click="$emit('delGroup', scope.row.groupId)"
  138. src="../../images/add-new-rule-del.png"
  139. alt=""
  140. />
  141. </div>
  142. </div>
  143. </template>
  144. </el-table-column>
  145. <el-table-column
  146. width="80px"
  147. v-if="maxNum && maxNum > 1"
  148. fixed="left"
  149. label="基础规则"
  150. prop="groupType"
  151. >
  152. <template slot-scope="scope">
  153. <div class="btn_box">
  154. <div class="btn_div" v-if="!isMax(scope.row.groupId)">
  155. <img
  156. @click="addChildGroup(scope)"
  157. src="../../images/add-new-rule-sub.png"
  158. alt=""
  159. />
  160. </div>
  161. <div
  162. class="btn_div"
  163. v-if="klRuleByIdSub.length > 1 && !scope.row.disabled"
  164. >
  165. <img
  166. @click="$emit('delGroupChild', scope.row.groupChildId)"
  167. src="../../images/add-new-rule-del.png"
  168. alt=""
  169. />
  170. </div>
  171. </div>
  172. </template>
  173. </el-table-column>
  174. <el-table-column width="170px" prop="subDescription" label="基础规则名称">
  175. <template slot="header" slot-scope="scope">
  176. <div class="custom_table_header">基础规则名称</div>
  177. </template>
  178. <template slot-scope="scope">
  179. <el-form-item
  180. class="inp_box"
  181. :prop="`klRuleByIdSub[${scope.$index}].subDescription`"
  182. :rules="rules.subDescription"
  183. >
  184. <el-input
  185. type="text"
  186. :disabled="scope.row.disabled"
  187. v-model="scope.row.subDescription"
  188. clearable
  189. placeholder="请输入"
  190. ></el-input>
  191. </el-form-item>
  192. </template>
  193. </el-table-column>
  194. <el-table-column width="170px" prop="subType" label="基础规则类型">
  195. <template slot="header" slot-scope="scope">
  196. <div class="custom_table_header">基础规则类型</div>
  197. </template>
  198. <template slot-scope="scope">
  199. <el-form-item
  200. class="inp_box"
  201. :prop="`klRuleByIdSub[${scope.$index}].subType`"
  202. :rules="rules.subType"
  203. >
  204. <el-select
  205. v-model="scope.row.subType"
  206. :disabled="scope.row.disabled"
  207. placeholder="请选择"
  208. @change="subTypeChange($event, scope.$index)"
  209. :ref="`klRuleByIdSub[${scope.$index}].subType`"
  210. >
  211. <el-option
  212. v-for="item in scope.row.baseTypes"
  213. :key="item.id"
  214. :label="item.name"
  215. :value="item.type"
  216. >
  217. </el-option>
  218. </el-select>
  219. </el-form-item>
  220. </template>
  221. </el-table-column>
  222. <el-table-column width="170px" prop="subLenCode" label="基础规则术语类型">
  223. <template slot="header" slot-scope="scope">
  224. <div class="custom_table_header">基础规则术语类型</div>
  225. </template>
  226. <template slot-scope="scope">
  227. <el-form-item
  228. class="inp_box"
  229. :prop="`klRuleByIdSub[${scope.$index}].subLenCode`"
  230. :rules="rules.subLenCode"
  231. >
  232. <el-select
  233. :disabled="scope.row.disabled"
  234. v-model="scope.row.subLenCode"
  235. placeholder="请选择"
  236. :ref="`klRuleByIdSub[${scope.$index}].subLenCode`"
  237. @change="subCodeChange($event, scope.$index)"
  238. >
  239. <el-option
  240. v-for="item in scope.row.baseTermTypeList"
  241. :key="item.id"
  242. :label="item.name"
  243. :value="item.code"
  244. >
  245. </el-option>
  246. </el-select>
  247. </el-form-item>
  248. </template>
  249. </el-table-column>
  250. <el-table-column width="170px" label="医学标准术语" prop="subConceptId">
  251. <template slot="header" slot-scope="scope">
  252. <div class="custom_table_header">医学标准术语</div>
  253. </template>
  254. <template slot-scope="scope">
  255. <el-form-item
  256. class="inp_box"
  257. :prop="`klRuleByIdSub[${scope.$index}].subConceptId`"
  258. :rules="rules.subConceptId"
  259. >
  260. <el-select
  261. clearable
  262. remote
  263. filterable
  264. :disabled="scope.row.disabled"
  265. @focus="subConceptIdfocus(scope.$index)"
  266. :remote-method="searchConcept"
  267. v-model.trim="scope.row.subConceptId"
  268. :ref="`klRuleByIdSub[${scope.$index}].subConceptId`"
  269. >
  270. <el-option
  271. v-for="item in scope.row.conceptList"
  272. :key="item.conceptId"
  273. :label="item.conceptName"
  274. :value="item.conceptId"
  275. >
  276. </el-option>
  277. </el-select>
  278. </el-form-item>
  279. </template>
  280. </el-table-column>
  281. <el-table-column label="规则具体内容" min-width="900px" prop="">
  282. <template slot-scope="scope">
  283. <div class="type_content">
  284. <el-form-item
  285. style="width: 100px; margin-right: 20px"
  286. :prop="`klRuleByIdSub[${scope.$index}].dataType`"
  287. :rules="rules.dataType"
  288. v-if="scope.row.subType === 2 && showDataType(scope.$index)"
  289. >
  290. <el-select
  291. v-model="scope.row.dataType"
  292. placeholder="选择类型"
  293. @change="dataTypeChange($event, scope.$index)"
  294. :ref="`klRuleByIdSub[${scope.$index}].dataType`"
  295. >
  296. <el-option label="数值类型" value="1"> </el-option>
  297. <el-option label="文本类型" value="2"> </el-option>
  298. </el-select>
  299. </el-form-item>
  300. <!-- v-if="klRuleByIdSub[scope.$index].dataType === '1'" -->
  301. <el-form-item
  302. class="type_content_item type_content_item1"
  303. style="flex: 2; margin: 0 10px"
  304. label="最大值:"
  305. v-if="scope.row.dataType === '1'"
  306. >
  307. <!-- <div> -->
  308. <el-row :gutter="10" class="row_box">
  309. <el-col :span="6">
  310. <el-form-item
  311. :prop="`klRuleByIdSub[${scope.$index}].subMaxOperator`"
  312. :rules="[
  313. {
  314. validator: (rule, value, callback) => {
  315. subMaxOperator(scope, rule, value, callback);
  316. },
  317. trigger: ['blur']
  318. }
  319. ]"
  320. >
  321. <el-select
  322. v-model="scope.row.subMaxOperator"
  323. placeholder="请选择"
  324. clearable
  325. :ref="`klRuleByIdSub[${scope.$index}].subMaxOperator`"
  326. >
  327. <el-option
  328. v-for="item in operMaxList"
  329. :key="item.key"
  330. :label="item.name"
  331. :value="item.key"
  332. >
  333. </el-option>
  334. </el-select>
  335. </el-form-item>
  336. </el-col>
  337. <el-col :span="6">
  338. <el-form-item
  339. :prop="`klRuleByIdSub[${scope.$index}].subMaxValue`"
  340. :rules="[
  341. {
  342. validator: (rule, value, callback) => {
  343. subMaxValue(scope, rule, value, callback);
  344. },
  345. trigger: ['blur']
  346. }
  347. ]"
  348. >
  349. <el-input
  350. type="text"
  351. v-model="scope.row.subMaxValue"
  352. placeholder="填写数值"
  353. />
  354. </el-form-item>
  355. </el-col>
  356. <el-col :span="6">
  357. <el-form-item
  358. :prop="`klRuleByIdSub[${scope.$index}].subMaxUnit`"
  359. :rules="rules.subMaxUnit"
  360. >
  361. <el-input
  362. type="text"
  363. v-model.trim="scope.row.subMaxUnit"
  364. placeholder="填写单位"
  365. />
  366. </el-form-item>
  367. </el-col>
  368. </el-row>
  369. <!-- </div> -->
  370. </el-form-item>
  371. <el-form-item
  372. class="type_content_item type_content_item1"
  373. style="flex: 2"
  374. label="最小值:"
  375. v-if="scope.row.dataType === '1'"
  376. >
  377. <el-row :gutter="10" class="row_box">
  378. <el-col :span="6">
  379. <el-form-item
  380. :prop="`klRuleByIdSub[${scope.$index}].subMinOperator`"
  381. :rules="[
  382. {
  383. validator: (rule, value, callback) => {
  384. subMinOperatorRule(scope, rule, value, callback);
  385. },
  386. trigger: ['blur']
  387. }
  388. ]"
  389. >
  390. <el-select
  391. v-model="scope.row.subMinOperator"
  392. placeholder="请选择"
  393. clearable
  394. :ref="`klRuleByIdSub[${scope.$index}].subMinOperator`"
  395. >
  396. <el-option
  397. v-for="item in operMinList"
  398. :key="item.name"
  399. :label="item.name"
  400. :value="item.name"
  401. >
  402. </el-option>
  403. </el-select>
  404. </el-form-item>
  405. </el-col>
  406. <el-col :span="6">
  407. <el-form-item
  408. :prop="`klRuleByIdSub[${scope.$index}].subMinValue`"
  409. :rules="[
  410. {
  411. validator: (rule, value, callback) => {
  412. subMinValueRule(scope, rule, value, callback);
  413. },
  414. trigger: ['blur']
  415. }
  416. ]"
  417. >
  418. <el-input
  419. type="text"
  420. v-model="scope.row.subMinValue"
  421. placeholder="填写数值"
  422. />
  423. </el-form-item>
  424. </el-col>
  425. <el-col :span="6">
  426. <el-form-item
  427. :prop="`klRuleByIdSub[${scope.$index}].subMinUnit`"
  428. :rules="rules.subMinUnit"
  429. >
  430. <el-input
  431. type="text"
  432. v-model.trim="scope.row.subMinUnit"
  433. placeholder="填写单位"
  434. />
  435. </el-form-item>
  436. </el-col>
  437. </el-row>
  438. </el-form-item>
  439. <!-- v-if="klRuleByIdSub[scope.$index].subType !== 6 && klRuleByIdSub[scope.$index].dataType === '2'" -->
  440. <el-form-item
  441. class="type_content_item"
  442. style="flex: 2"
  443. v-show="scope.row.subType !== 6 && scope.row.dataType === '2'"
  444. label="医学内容:"
  445. label-width="100px"
  446. :prop="`klRuleByIdSub[${scope.$index}].subEqValue`"
  447. :rules="[
  448. {
  449. required: true,
  450. message: '请输入' + textName(scope.$index),
  451. trigger: 'blur'
  452. },
  453. {
  454. validator: (rule, value, callback) => {
  455. subEqValue(scope, rule, value, callback);
  456. },
  457. trigger: 'blur'
  458. }
  459. ]"
  460. >
  461. <el-input
  462. type="textarea"
  463. rows="1"
  464. placeholder="请输入医学内容"
  465. v-model.trim="scope.row.subEqValue"
  466. ></el-input>
  467. </el-form-item>
  468. <!-- v-if="groupData.subType === 6" -->
  469. <el-form-item
  470. class="type_content_item"
  471. label="正则表达式:"
  472. label-width="120px"
  473. style="flex: 2"
  474. v-show="scope.row.subType === 6"
  475. :prop="`klRuleByIdSub[${scope.$index}].subEqValue1`"
  476. :rules="[
  477. {
  478. required: true,
  479. message: '请输入' + textName(scope.$index),
  480. trigger: 'blur'
  481. },
  482. {
  483. validator: (rule, value, callback) => {
  484. subEqValue(scope, rule, value, callback);
  485. },
  486. trigger: 'blur'
  487. }
  488. ]"
  489. >
  490. <el-input
  491. type="textarea"
  492. rows="1"
  493. placeholder="请输入正则表达式"
  494. v-model.trim="scope.row.subEqValue"
  495. ></el-input>
  496. </el-form-item>
  497. </div>
  498. </template>
  499. </el-table-column>
  500. </el-table>
  501. </div>
  502. </template>
  503. <script>
  504. import api from "@api/knowledgeLib.js";
  505. import { tableRules } from "./rules";
  506. export default {
  507. name: "AddNewRuleTable",
  508. data() {
  509. return {
  510. numTypes: "",
  511. subConceptIdIndex: "",
  512. operMaxList: [
  513. { name: "<=", key: "<=" },
  514. { name: "<", key: "<" }
  515. ],
  516. operMinList: [
  517. { name: ">", key: ">" },
  518. { name: ">=", key: ">=" }
  519. ],
  520. rules: tableRules
  521. };
  522. },
  523. methods: {
  524. addGroup(scope) {
  525. this.$emit("addGroup", null, { groupId: scope.row.groupId });
  526. this.$refs.table.bodyWrapper.scrollLeft = 0;
  527. },
  528. addChildGroup(scope) {
  529. this.$emit("addGroup", scope.row.groupId, { index: scope.$index });
  530. this.$refs.table.bodyWrapper.scrollLeft = 0;
  531. },
  532. // table 隔行换色
  533. // rowStyle({ row }) {
  534. // if (row.rowIndex % 2 == 0) {
  535. // return {
  536. // background: "#DFF7EF"
  537. // };
  538. // }
  539. // },
  540. // cellStyle
  541. cellStyle({ row, column, rowIndex, columnIndex }) {
  542. if (column.label == "组" || column.label == "基础规则") return {};
  543. return { "vertical-align": "top", "padding-top": "14px" };
  544. },
  545. // 最大值 选择rule
  546. subMaxOperator(scope, rule, value, callback) {
  547. const { subMaxValue, subMinOperator, subMinValue } = scope.row;
  548. const val = value + subMinOperator + subMinValue + subMaxValue;
  549. if (!val || (!value && subMaxValue !== "")) {
  550. callback(new Error("最大值和最小值至少完整填写一个,单位不必填"));
  551. } else {
  552. callback();
  553. }
  554. },
  555. // 最大值 数值rule
  556. subMaxValue(scope, rule, value, callback) {
  557. const { subMaxOperator, subMinOperator, subMinValue } = scope.row;
  558. const val = value + subMaxOperator + subMinValue + subMinOperator;
  559. const isNum = /^(\-|\+)?\d+(\.\d+)?$/.test(value);
  560. if (!val || (value == "" && subMaxOperator)) {
  561. callback(new Error("最大值和最小值至少完整填写一个,单位不必填"));
  562. } else if (value !== "" && !isNum) {
  563. callback(new Error("只能输入数字"));
  564. } else {
  565. callback();
  566. }
  567. },
  568. // 最小值 选择rule
  569. subMinOperatorRule(scope, rule, value, callback) {
  570. const { subMaxValue, subMaxOperator, subMinValue } = scope.row;
  571. const val = value + subMaxOperator + subMinValue + subMaxValue;
  572. if (!val || (!value && subMinValue !== "")) {
  573. callback(new Error("最大值和最小值至少完整填写一个,单位不必填"));
  574. } else {
  575. callback();
  576. }
  577. },
  578. // 最小值 数值rule
  579. subMinValueRule(scope, rule, value, callback) {
  580. const { subMaxValue, subMinOperator, subMaxOperator } = scope.row;
  581. const val = value + subMaxOperator + subMaxValue + subMinOperator;
  582. const isNum = /^(\-|\+)?\d+(\.\d+)?$/.test(value);
  583. if (!val || (value == "" && subMinOperator)) {
  584. callback(new Error("最大值和最小值至少完整填写一个,单位不必填"));
  585. } else if (value !== "" && !isNum) {
  586. callback(new Error("只能输入数字"));
  587. } else {
  588. callback();
  589. }
  590. },
  591. // 医学内容rule
  592. subEqValue(scope, rule, value, callback) {
  593. if (value === "") {
  594. callback(new Error("请输入" + this.textName(scope.$index)));
  595. } else if (value.length > 200) {
  596. callback(new Error(this.textName(scope.$index) + "不能超过200字"));
  597. } else {
  598. callback();
  599. }
  600. },
  601. // 判断是否为最后一条规则
  602. isLastDate(id) {
  603. const tableLength = this.klRuleByIdSub.filter(
  604. (item) => item.groupId !== id
  605. ).length;
  606. return tableLength === 0;
  607. },
  608. // 是否超出最大规则数
  609. isMax(id) {
  610. const typeNum = this.klRuleByIdSub.filter((item) => item.groupId === id)
  611. .length;
  612. return typeNum >= this.maxNum;
  613. },
  614. // 基础规则类型选择
  615. subTypeChange(e, index) {
  616. this.$emit("subTypeChange", e, index);
  617. },
  618. // 规则术语类型
  619. subCodeChange(val, index) {
  620. //基础规则术语类型修改
  621. if ((this.numTypes + ",").indexOf(val + ",") > -1) {
  622. this.klRuleByIdSub[index].dataType = "1";
  623. } else {
  624. this.klRuleByIdSub[index].dataType = "";
  625. }
  626. this.clearConcept(index);
  627. this.clearNumText(index);
  628. },
  629. clearConcept(index) {
  630. this.klRuleByIdSub[index].subConceptId = "";
  631. this.klRuleByIdSub[index].conceptList = [];
  632. },
  633. clearNumText(index) {
  634. let obj = JSON.parse(JSON.stringify(this.klRuleByIdSub));
  635. obj[index].subMaxOperator = "";
  636. obj[index].subMaxValue = "";
  637. obj[index].subMaxUnit = "";
  638. obj[index].subMinOperator = "";
  639. obj[index].subMinValue = "";
  640. obj[index].subMinUnit = "";
  641. obj[index].subEqValue = "";
  642. // this.$set(obj[index], "subEqValue", "");
  643. obj[index].subEqOperator = "";
  644. // this.klRuleByIdSub = obj;
  645. this.$emit('editKlRuleByIdSub',obj)
  646. },
  647. //医学标准术语change
  648. subConceptIdfocus(index) {
  649. this.subConceptIdIndex = "";
  650. this.subConceptIdIndex = index;
  651. },
  652. // 医学标准术语
  653. searchConcept(val) {
  654. const param = {
  655. excludedConceptIds: [
  656. this.klRuleByIdSub[this.subConceptIdIndex].subType
  657. ],
  658. libType: this.klRuleByIdSub[this.subConceptIdIndex].subLenCode,
  659. name: val
  660. };
  661. api
  662. .searchConcept(param)
  663. .then((res) => {
  664. if (res.data.code == "0") {
  665. const data = res.data.data;
  666. this.$emit("setFormData", this.subConceptIdIndex, data);
  667. }
  668. })
  669. .catch((error) => {
  670. console.log(error);
  671. });
  672. },
  673. dataTypeChange(val, index) {
  674. console.log(val,index);
  675. this.klRuleByIdSub[index].subEqOperator = val === "2" ? "=" : "";
  676. this.clearNumText(index);
  677. // TODO 新增的内容追踪不到
  678. //delete this.klRuleByIdSub[index].dataType; //触发更新
  679. this.$set(this.klRuleByIdSub[index], "dataType", val);
  680. },
  681. // 处理要合并相同行的列
  682. getSpanArr(data) {
  683. this.spanArr = [];
  684. for (var i = 0; i < data.length; i++) {
  685. if (i === 0) {
  686. // 如果是第一条记录(即索引是0的时候),向数组中加入1
  687. /** *
  688. * 例子:
  689. * name:1
  690. * name:1
  691. * name:2
  692. * name:2
  693. * 最终结果:spanArr = [2,0,2,0]
  694. */
  695. this.spanArr.push(1);
  696. this.pos = 0;
  697. } else {
  698. if (data[i].groupId === data[i - 1].groupId) {
  699. // 如果remark相等就累加,并且push 0
  700. this.spanArr[this.pos] += 1;
  701. this.spanArr.push(0);
  702. } else {
  703. // 不相等push 1,并且pos 要换成当前下标
  704. this.spanArr.push(1);
  705. this.pos = i;
  706. }
  707. }
  708. }
  709. },
  710. // 合并单元格
  711. ObjectSpanMethod({ row, column, rowIndex, columnIndex }) {
  712. if (columnIndex == 0) {
  713. const _row = this.spanArr[rowIndex];
  714. const _col = _row > 0 ? 1 : 0;
  715. return {
  716. rowspan: _row,
  717. colspan: _col
  718. };
  719. }
  720. },
  721. showDataType(index) {
  722. return (
  723. (this.numTypes + ",").indexOf(
  724. this.klRuleByIdSub[index].subLenCode + ","
  725. ) === -1
  726. );
  727. },
  728. textName(index) {
  729. return this.klRuleByIdSub[index].subType !== 6 &&
  730. this.klRuleByIdSub[index].dataType === "2"
  731. ? "医学内容"
  732. : "正则表达式";
  733. }
  734. },
  735. components: {},
  736. created() {
  737. this.numTypes = localStorage.getItem("zskNumDict");
  738. this.getSpanArr(this.klRuleByIdSub);
  739. },
  740. beforeUpdate() {
  741. this.getSpanArr(this.klRuleByIdSub);
  742. },
  743. mounted() {},
  744. // beforeUpdate() {
  745. // this.getSpanArr(this.klRuleByIdSub);
  746. // console.log("boxxxxxxx", this.box);
  747. // // if (this.box) {
  748. // // this.box.removeEventListener("scroll");
  749. // // }
  750. // // console.log(box);
  751. // // if (!this.box) {
  752. // this.box = document.querySelector(".el-table__body-wrapper");
  753. // // }
  754. // let that = this;
  755. // this.box.addEventListener("scroll", function (e) {
  756. // console.log(that.klRuleByIdSub.length);
  757. // console.log('subType',that.$refs[`klRuleByIdSub[1].subType`]);
  758. // that.klRuleByIdSub.forEach((ite, index) => {
  759. // // console.log(
  760. // // that.$refs[`klRuleByIdSub[${index}].subType`],
  761. // // that.$refs[`klRuleByIdSub[${index}].subLenCode`],
  762. // // that.$refs[`klRuleByIdSub[${index}].subConceptId`],
  763. // // that.$refs[`klRuleByIdSub[${index}].subMaxOperator`],
  764. // // that.$refs[`klRuleByIdSub[${index}].subMinOperator`],
  765. // // that.$refs[`klRuleByIdSub[${index}].subMinOperator`]
  766. // // );
  767. // that.$refs[`klRuleByIdSub[${index}].subType`] &&
  768. // that.$refs[`klRuleByIdSub[${index}].subType`].blur();
  769. // that.$refs[`klRuleByIdSub[${index}].subLenCode`] &&
  770. // that.$refs[`klRuleByIdSub[${index}].subLenCode`].blur();
  771. // that.$refs[`klRuleByIdSub[${index}].subConceptId`] &&
  772. // that.$refs[`klRuleByIdSub[${index}].subConceptId`].blur();
  773. // that.$refs[`klRuleByIdSub[${index}].dataType`] &&
  774. // that.$refs[`klRuleByIdSub[${index}].dataType`].blur();
  775. // that.$refs[`klRuleByIdSub[${index}].subMaxOperator`] &&
  776. // that.$refs[`klRuleByIdSub[${index}].subMaxOperator`].blur();
  777. // that.$refs[`klRuleByIdSub[${index}].subMinOperator`] &&
  778. // that.$refs[`klRuleByIdSub[${index}].subMinOperator`].blur();
  779. // that.$refs[`klRuleByIdSub[${index}]subMinOperator`] &&
  780. // that.$refs[`klRuleByIdSub[${index}]subMinOperator`].blur();
  781. // });
  782. // });
  783. // },
  784. updated() {},
  785. props: {
  786. klRuleByIdSub: {
  787. type: Array,
  788. required: true
  789. },
  790. maxNum: {
  791. default: null
  792. }
  793. }
  794. };
  795. </script>