AddNewRuleTable.vue 28 KB

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