AddNewRuleTable.vue 29 KB

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