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