AddNewRuleTable.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898
  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,scope.$index,scope.row.groupId,scope.row.del,scope.row.key)"
  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,scope.row.groupId,scope.row.key)"
  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,scope.row.groupId,scope.row.key)"
  261. @focus="
  262. setTheRef($event, `klRuleByIdSub[${scope.$index}].subLenCode`,scope.row.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. code:''
  567. };
  568. },
  569. methods: {
  570. setScrollRight() {
  571. this.$nextTick(() => {
  572. this.$refs.table.bodyWrapper.scrollLeft = this.$refs.table.bodyWrapper.scrollWidth;
  573. });
  574. },
  575. maxChange(e, val, type) {
  576. if (
  577. type === 'i' &&
  578. this.klRuleByIdSub[val].subMaxOperator &&
  579. this.klRuleByIdSub[val].subMaxOperator != ''
  580. ) {
  581. this.$emit('clearValidate', [
  582. `klRuleByIdSub[${val}].subMinValue`,
  583. `klRuleByIdSub[${val}].subMinOperator`
  584. ]);
  585. } else if (
  586. type === 's' &&
  587. this.klRuleByIdSub[val].subMaxValue &&
  588. this.klRuleByIdSub[val].subMaxValue != ''
  589. ) {
  590. this.$emit('clearValidate', [
  591. `klRuleByIdSub[${val}].subMinValue`,
  592. `klRuleByIdSub[${val}].subMinOperator`
  593. ]);
  594. }
  595. this.setScrollRight();
  596. },
  597. minChange(e, val, type) {
  598. if (
  599. type === 'i' &&
  600. this.klRuleByIdSub[val].subMinOperator &&
  601. this.klRuleByIdSub[val].subMinOperator != ''
  602. ) {
  603. this.$emit('clearValidate', [
  604. `klRuleByIdSub[${val}].subMaxOperator`,
  605. `klRuleByIdSub[${val}].subMaxValue`
  606. ]);
  607. } else if (
  608. type === 's' &&
  609. this.klRuleByIdSub[val].subMinValue &&
  610. this.klRuleByIdSub[val].subMinValue != ''
  611. ) {
  612. this.$emit('clearValidate', [
  613. `klRuleByIdSub[${val}].subMaxOperator`,
  614. `klRuleByIdSub[${val}].subMaxValue`
  615. ]);
  616. }
  617. this.setScrollRight();
  618. },
  619. addGroup(scope) {
  620. this.$emit('addGroup', null, { groupId: scope.row.groupId });
  621. this.$refs.table.bodyWrapper.scrollLeft = 0;
  622. },
  623. addChildGroup(scope) {
  624. this.$emit('addGroup', scope.row.groupId,{ index: scope.$index });
  625. this.$refs.table.bodyWrapper.scrollLeft = 0;
  626. },
  627. scrollFun() {
  628. this.$refs.table.bodyWrapper.scrollTop =
  629. this.$refs.table.bodyWrapper.scrollTop + 60;
  630. },
  631. // table 隔行换色
  632. // rowStyle({ row }) {
  633. // if (row.rowIndex % 2 == 0) {
  634. // return {
  635. // background: "#DFF7EF"
  636. // };
  637. // }
  638. // },
  639. // cellStyle
  640. cellStyle({ row, column, rowIndex, columnIndex }) {
  641. if (column.label == '组' || column.label == '基础规则') return {};
  642. if (column.label == '附加信息') return { 'padding-top': '14px' };
  643. return { 'vertical-align': 'top', 'padding-top': '14px' };
  644. },
  645. // 最大值 选择rule
  646. subMaxOperator(scope, rule, value, callback) {
  647. const { subMaxValue, subMinOperator, subMinValue } = scope.row;
  648. const val = value + subMinOperator + subMinValue + subMaxValue;
  649. if (!val || (!value && subMaxValue !== '')) {
  650. callback(new Error('最大值和最小值至少完整填写一个,单位不必填'));
  651. } else {
  652. callback();
  653. }
  654. },
  655. // 最大值 数值rule
  656. subMaxValue(scope, rule, value, callback) {
  657. const { subMaxOperator, subMinOperator, subMinValue } = scope.row;
  658. const val = value + subMaxOperator + subMinValue + subMinOperator;
  659. const isNum = /^(\-|\+)?\d+(\.\d+)?$/.test(value);
  660. if (!val || (value == '' && subMaxOperator)) {
  661. callback(new Error('最大值和最小值至少完整填写一个,单位不必填'));
  662. } else if (value !== '' && !isNum) {
  663. callback(new Error('只能输入数字'));
  664. } else {
  665. callback();
  666. }
  667. },
  668. // 最小值 选择rule
  669. subMinOperatorRule(scope, rule, value, callback) {
  670. const { subMaxValue, subMaxOperator, subMinValue } = scope.row;
  671. const val = value + subMaxOperator + subMinValue + subMaxValue;
  672. if (!val || (!value && subMinValue !== '')) {
  673. callback(new Error('最大值和最小值至少完整填写一个,单位不必填'));
  674. } else {
  675. callback();
  676. }
  677. },
  678. // 最小值 数值rule
  679. subMinValueRule(scope, rule, value, callback) {
  680. const { subMaxValue, subMinOperator, subMaxOperator } = scope.row;
  681. const val = value + subMaxOperator + subMaxValue + subMinOperator;
  682. const isNum = /^(\-|\+)?\d+(\.\d+)?$/.test(value);
  683. if (!val || (value == '' && subMinOperator)) {
  684. callback(new Error('最大值和最小值至少完整填写一个,单位不必填'));
  685. } else if (value !== '' && !isNum) {
  686. callback(new Error('只能输入数字'));
  687. } else {
  688. callback();
  689. }
  690. },
  691. // 医学内容rule
  692. subEqValue(scope, rule, value, callback) {
  693. if (value === '') {
  694. callback(new Error('请输入' + this.textName(scope.$index)));
  695. } else if (value.length > 200) {
  696. callback(new Error(this.textName(scope.$index) + '不能超过200字'));
  697. } else {
  698. callback();
  699. }
  700. },
  701. // 判断是否为最后一条规则
  702. isLastDate(id) {
  703. const tableLength = this.klRuleByIdSub.filter(item => item.groupId !== id)
  704. .length;
  705. return tableLength === 0;
  706. },
  707. // 是否超出最大规则数
  708. isMax(id) {
  709. const typeNum = this.klRuleByIdSub.filter(item => item.groupId === id)
  710. .length;
  711. return typeNum >= this.maxNum;
  712. },
  713. // 基础规则类型选择
  714. subTypeChange(e, index,groupId,key) {
  715. this.$emit('subTypeChange', e, index,groupId,key);
  716. },
  717. //
  718. setTheRef(e, val,code) {
  719. this.theRef = val;
  720. this.code = code?code:''
  721. },
  722. // 规则术语类型
  723. subCodeChange(val, index,groupId,key) {
  724. //基础规则术语类型修改
  725. this.$emit('childSubCodeChange', val, index, this.numTypes,groupId,key,this.code);
  726. },
  727. clearConcept(index) {
  728. this.$emit('childClearConcept', index);
  729. },
  730. clearNumText(index) {
  731. this.$emit('childClearNumText', index);
  732. },
  733. //医学标准术语change
  734. subConceptIdfocus(index) {
  735. this.subConceptIdIndex = '';
  736. this.subConceptIdIndex = index;
  737. this.setTheRef(1, `klRuleByIdSub[${index}].subConceptId`);
  738. },
  739. // 医学标准术语
  740. searchConcept(val) {
  741. const param = {
  742. excludedConceptIds: [
  743. this.klRuleByIdSub[this.subConceptIdIndex].subType
  744. ],
  745. libType: this.klRuleByIdSub[this.subConceptIdIndex].subLenCode,
  746. name: val,
  747. };
  748. api
  749. .searchConcept(param)
  750. .then(res => {
  751. if (res.data.code == '0') {
  752. const data = res.data.data;
  753. this.$emit('setFormData', this.subConceptIdIndex, data);
  754. }
  755. })
  756. .catch(error => {
  757. console.log(error);
  758. });
  759. },
  760. dataTypeChange(val, index) {
  761. this.$emit('ChildDataTypeChange', val, index);
  762. },
  763. // 处理要合并相同行的列
  764. getSpanArr(data) {
  765. this.spanArr = [];
  766. for (var i = 0; i < data.length; i++) {
  767. if (i === 0) {
  768. // 如果是第一条记录(即索引是0的时候),向数组中加入1
  769. /** *
  770. * 例子:
  771. * name:1
  772. * name:1
  773. * name:2
  774. * name:2
  775. * 最终结果:spanArr = [2,0,2,0]
  776. */
  777. this.spanArr.push(1);
  778. this.pos = 0;
  779. } else {
  780. if (data[i].groupId === data[i - 1].groupId) {
  781. // 如果remark相等就累加,并且push 0
  782. this.spanArr[this.pos] += 1;
  783. this.spanArr.push(0);
  784. } else {
  785. // 不相等push 1,并且pos 要换成当前下标
  786. this.spanArr.push(1);
  787. this.pos = i;
  788. }
  789. }
  790. }
  791. },
  792. // 合并单元格
  793. ObjectSpanMethod({ row, column, rowIndex, columnIndex }) {
  794. if (this.ruleTermCodeStr == '3-108-1') {
  795. if (columnIndex == 0) {
  796. const _row = this.spanArr[rowIndex];
  797. const _col = _row > 0 ? 1 : 0;
  798. return {
  799. rowspan: _row,
  800. colspan: _col
  801. };
  802. }
  803. } else {
  804. if (columnIndex == 0 || columnIndex == 1) {
  805. const _row = this.spanArr[rowIndex];
  806. const _col = _row > 0 ? 1 : 0;
  807. return {
  808. rowspan: _row,
  809. colspan: _col
  810. };
  811. }
  812. }
  813. },
  814. showDataType(index) {
  815. return (
  816. (this.numTypes + ',').indexOf(
  817. this.klRuleByIdSub[index].subLenCode + ','
  818. ) === -1
  819. );
  820. },
  821. textName(index) {
  822. return this.klRuleByIdSub[index].subType !== 6 &&
  823. this.klRuleByIdSub[index].dataType == '2'
  824. ? '医学内容'
  825. : '正则表达式';
  826. },
  827. blurRef() {
  828. if (this.theRef) {
  829. this.$refs[this.theRef].blur();
  830. // console.log(document.getElementById(this.theRef).blur,'hehehe');
  831. // document.getElementById(this.theRef).focus()
  832. // document.getElementById(this.theRef).value = 123
  833. }
  834. }
  835. },
  836. components: {},
  837. mounted() {
  838. // this.theRef
  839. // console.log('mounted');
  840. // let that = this;
  841. // this.$refs.table.bodyWrapper.addEventListener(
  842. // "scroll",
  843. // that.blurRef,
  844. // false
  845. // );
  846. },
  847. created() {
  848. this.numTypes = localStorage.getItem('zskNumDict');
  849. this.getSpanArr(this.klRuleByIdSub);
  850. },
  851. beforeUpdate() {
  852. this.getSpanArr(this.klRuleByIdSub);
  853. },
  854. updated() {
  855. // let that = this;
  856. // this.$nextTick(() => {
  857. // // FIX 滚动添加事件
  858. // this.$refs.table.bodyWrapper.removeEventListener(
  859. // "scroll",
  860. // that.blurRef,
  861. // false
  862. // );
  863. // setTimeout(() => {
  864. // that.$refs.table.bodyWrapper.addEventListener(
  865. // "scroll",
  866. // that.blurRef,
  867. // false
  868. // );
  869. // }, 300);
  870. // });
  871. },
  872. props: {
  873. klRuleByIdSub: {
  874. type: Array,
  875. required: true
  876. },
  877. maxNum: {
  878. default: null
  879. },
  880. showMsg: {
  881. default: null
  882. },
  883. showMsg2:{
  884. default: null
  885. },
  886. ruleTermCodeStr: {
  887. default: null
  888. },
  889. }
  890. };
  891. </script>