AddNewRuleTable.vue 31 KB

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