AddTermSet.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826
  1. <style lang="less" scoped>
  2. // @import "../../less/admin.less";
  3. #AddRuleContent {
  4. width: 100%;
  5. min-width: 1000px;
  6. padding: 20px;
  7. padding-top: 50px;
  8. padding-bottom: 0;
  9. box-sizing: border-box;
  10. .form {
  11. width: 100%;
  12. }
  13. .remark {
  14. font-size: 14px;
  15. color: #606266;
  16. position: relative;
  17. left: 34px;
  18. top: -10px;
  19. padding-right: 30px;
  20. }
  21. .left_header {
  22. height: 40px;
  23. display: flex;
  24. justify-content: space-between;
  25. .tips {
  26. margin-top: 15px;
  27. }
  28. .inp {
  29. width: 150px;
  30. /deep/.el-input__inner {
  31. height: 30px;
  32. margin-top: 10px;
  33. }
  34. }
  35. }
  36. .right_header {
  37. display: flex;
  38. }
  39. .table_form {
  40. width: 100%;
  41. box-sizing: border-box;
  42. background: #fff;
  43. padding: 20px;
  44. padding-bottom: 0;
  45. display: flex;
  46. flex-wrap: wrap;
  47. }
  48. .table_content {
  49. margin-top: 10px;
  50. overflow: hidden;
  51. .table_left {
  52. width: 45%;
  53. float: left;
  54. margin-right: 10px;
  55. background: #ffffff;
  56. padding: 0 2%;
  57. .left_box {
  58. margin: 30px 0;
  59. overflow: hidden;
  60. min-height: calc(100vh - 410px);
  61. }
  62. .tabs {
  63. max-width: 100%;
  64. min-width: 100%;
  65. border-color: #979797;
  66. }
  67. .form_btn {
  68. display: flex;
  69. justify-content: flex-end;
  70. padding-bottom: 15px;
  71. }
  72. }
  73. .table_right {
  74. width: 45%;
  75. float: right;
  76. background: #ffffff;
  77. padding: 0 2%;
  78. .right_box {
  79. margin: 30px 0;
  80. overflow: hidden;
  81. min-height: calc(100vh - 410px);
  82. }
  83. .tabs {
  84. max-width: 100%;
  85. min-width: 100%;
  86. border-color: #979797;
  87. }
  88. .inp {
  89. width: 100px;
  90. /deep/.el-input__inner {
  91. height: 30px;
  92. margin-top: 10px;
  93. }
  94. }
  95. .inps {
  96. margin-right: 10px;
  97. }
  98. .form_btn {
  99. display: flex;
  100. justify-content: space-between;
  101. padding-bottom: 15px;
  102. }
  103. }
  104. }
  105. /deep/.el-select-dropdown__item.hover,
  106. .el-select-dropdown__item:hover {
  107. color: #48c5d7;
  108. }
  109. /deep/ .el-form--inline .el-form-item__label {
  110. font-size: 14px;
  111. color: #606266;
  112. }
  113. /deep/ .el-input--mini .el-input__inner,
  114. .el-select {
  115. width: 100%;
  116. font-size: 14px;
  117. }
  118. /deep/ .el-form-item.is-success .el-input__inner,
  119. .el-form-item.is-success .el-textarea__inner {
  120. border-color: #c9c9c9 !important;
  121. }
  122. /deep/ .el-form-item.is-success .el-textarea__inner {
  123. border-color: #c9c9c9 !important;
  124. }
  125. /deep/ .el-form-item.is-success .el-textarea__inner {
  126. border-color: #c9c9c9 !important;
  127. }
  128. /deep/ .el-table th.gutter {
  129. display: table-cell !important;
  130. }
  131. /deep/.el-table .cell,
  132. .el-table--border td:first-child .cell,
  133. .el-table--border th:first-child .cell {
  134. padding-right: 14px;
  135. }
  136. /*table边框颜色*/
  137. /deep/ .el-table--border:after,
  138. .el-table--group:after,
  139. .el-table:before {
  140. background-color: #979797;
  141. }
  142. /deep/ .el-table--border,
  143. .el-table--group {
  144. border-color: #979797;
  145. }
  146. /deep/ .el-table td,
  147. .el-table th.is-leaf {
  148. border-bottom: 1px solid #979797;
  149. }
  150. /deep/ .el-table--border th,
  151. .el-table--border th.gutter:last-of-type {
  152. border-bottom: 1px solid #979797;
  153. }
  154. /deep/ .el-table--border td,
  155. .el-table--border th {
  156. border-right: 1px solid #979797;
  157. }
  158. }
  159. .test_box {
  160. min-height: 300px;
  161. max-height: 300px;
  162. outline: 0;
  163. border: 1px solid #dcdfe6;
  164. font-size: 14px;
  165. line-height: 1.5;
  166. word-wrap: break-word;
  167. overflow-x: hidden;
  168. overflow-y: auto;
  169. border-radius: 4px;
  170. margin-top: 6px;
  171. padding: 10px 15px;
  172. }
  173. </style>
  174. <style scoped>
  175. </style>
  176. <template>
  177. <div>
  178. <crumbs :title="title" :param="$route.params" linkTo="TermSet"></crumbs>
  179. <div id="AddRuleContent">
  180. <div class="table_form">
  181. <el-form
  182. size="mini"
  183. :inline="true"
  184. class="demo-form-inline form"
  185. :model="form"
  186. :rules="rules"
  187. >
  188. <el-form-item label-width="130px" label="术语集合类型:" prop="collectionLibType">
  189. <el-select
  190. v-model="form.collectionLibType"
  191. placeholder="请选择"
  192. @change="getConceptLibType"
  193. :disabled="sign==2?true:false"
  194. :title="form.collectionLibName"
  195. >
  196. <el-option
  197. v-for="item in ruleTypeList"
  198. :key="item.val"
  199. :label="item.name"
  200. :value="item.val"
  201. ></el-option>
  202. </el-select>
  203. </el-form-item>
  204. <!-- 规则术语类型: -->
  205. <el-form-item label-width="130px" label="术语集合名称:" prop="collectionLibName">
  206. <el-select
  207. clearable
  208. remote
  209. filterable
  210. v-model.trim="form.collectionLibName"
  211. placeholder="请输入"
  212. :remote-method="searchLibName"
  213. @change="getCollectionLib"
  214. :disabled="sign==2?true:false"
  215. value-key="conceptId"
  216. :title="form.collectionLibName"
  217. >
  218. <el-option
  219. v-for="item in ruleTermTypeList"
  220. :key="item.conceptId"
  221. :label="item.conceptName"
  222. :value="item.conceptName"
  223. ></el-option>
  224. </el-select>
  225. </el-form-item>
  226. </el-form>
  227. <div class="remark">说明:{{form.collectionRemark}}</div>
  228. </div>
  229. <div class="table_content" v-if="onshow">
  230. <div class="table_left">
  231. <div class="left_header">
  232. <h5 class="tips">关联的术语({{form.concepts.length}})</h5>
  233. <div style="display:flex">
  234. <el-input v-model.trim="searchtext" @input="searchList" placeholder="关键词" class="inp"></el-input>
  235. <span style="display:flex;align-items: center;margin:0 5px">-</span>
  236. <el-input
  237. v-model.trim="searchtext2"
  238. @input="searchList"
  239. placeholder="关键词"
  240. class="inp"
  241. ></el-input>
  242. </div>
  243. </div>
  244. <div class="left_box">
  245. <el-table
  246. :data="leftList"
  247. border
  248. style="min-height: 200px"
  249. height="calc(100vh - 393px)"
  250. class="tabs"
  251. ref="table"
  252. :header-row-style="{height:'40px'}"
  253. :header-cell-style="{height:'40px',borderColor:'#979797'}"
  254. >
  255. <el-table-column prop="conceptLibName" :show-overflow-tooltip="true" label="术语名称"></el-table-column>
  256. <el-table-column label="操作">
  257. <template slot-scope="scope">
  258. <el-button
  259. type="text"
  260. size="small"
  261. class="delete"
  262. @click="showDelDialog(scope.row)"
  263. >移除</el-button>
  264. </template>
  265. </el-table-column>
  266. </el-table>
  267. </div>
  268. <div class="form_btn">
  269. <el-button type="primary" size="medium " @click="saveSet">确定</el-button>
  270. </div>
  271. </div>
  272. <div class="table_right">
  273. <div class="right_header">
  274. <el-select
  275. v-model="formInline.logicalOperator"
  276. class="inp inps"
  277. @change="searchConcept"
  278. >
  279. <el-option label="and" value="0"></el-option>
  280. <el-option label="or" value="1"></el-option>
  281. </el-select>
  282. <el-input
  283. v-model.trim="formInline.name1"
  284. @input="searchConcept"
  285. placeholder="关键词"
  286. class="inp"
  287. ></el-input>
  288. <span style="display:flex;align-items: center;margin:0 5px">-</span>
  289. <el-input
  290. v-model.trim="formInline.name2"
  291. @input="searchConcept"
  292. placeholder="关键词"
  293. class="inp"
  294. ></el-input>
  295. <span style="display:flex;align-items: center;margin:0 5px">-</span>
  296. <el-input
  297. v-model.trim="formInline.name3"
  298. @input="searchConcept"
  299. placeholder="关键词"
  300. class="inp"
  301. ></el-input>
  302. </div>
  303. <div class="right_box">
  304. <el-table
  305. :data="conceptList"
  306. border
  307. style="min-height: 200px"
  308. height="calc(100vh - 393px)"
  309. class="tabs"
  310. ref="tables"
  311. @row-click="btn"
  312. :header-row-style="{height:'40px'}"
  313. :header-cell-style="{height:'40px',borderColor:'#979797'}"
  314. @selection-change="handleSelectionChange"
  315. >
  316. <el-table-column type="selection"></el-table-column>
  317. <el-table-column prop="conceptName" :show-overflow-tooltip="true" label="术语名称"></el-table-column>
  318. </el-table>
  319. </div>
  320. <div class="form_btn">
  321. <el-button size="medium " @click="add" icon="el-icon-caret-left">添加</el-button>
  322. <el-button size="medium " @click="dialogVisible = true">文本批量添加</el-button>
  323. </div>
  324. </div>
  325. </div>
  326. </div>
  327. <el-dialog
  328. :title="'请输入要添加到关联的标准术语(每行一个)'+'共'+len+'行'"
  329. :visible.sync="dialogVisible"
  330. width="30%"
  331. :close-on-click-modal="false"
  332. :showClose="false"
  333. >
  334. <div
  335. class="test_box"
  336. contenteditable="true"
  337. ref="msg"
  338. style="white-space: pre-wrap"
  339. @input="handleInput"
  340. ></div>
  341. <span slot="footer" class="dialog-footer">
  342. <el-button @click="collectcancel">保存并关闭</el-button>
  343. <el-button type="primary" @click="collectionMatch">确 定</el-button>
  344. </span>
  345. </el-dialog>
  346. </div>
  347. </template>
  348. <script type="text/javascript">
  349. import api from '@api/knowledgeLib.js';
  350. import AddNewRuleTable from './AddNewRuleTable';
  351. import axios from 'axios';
  352. export default {
  353. name: 'AddRule',
  354. data() {
  355. return {
  356. title: '术语集合内容维护-添加',
  357. formInline: {
  358. logicalOperator: '0',
  359. name1: '',
  360. name2: '',
  361. name3: ''
  362. },
  363. innerText: '',
  364. ruleTypeList: [],
  365. ruleTermTypeList: [],
  366. conceptList: [],
  367. conceptText: '',
  368. excludedConceptIds: [],
  369. type: [],
  370. leftList: [],
  371. multipleSelection: [],
  372. sign: 1,
  373. searchtext: '',
  374. searchtext2: '',
  375. dialogVisible: false,
  376. form: {
  377. collectionLibType: '',
  378. collectionLibName: '',
  379. concepts: [],
  380. conceptLibType: '',
  381. collectionRemark: '',
  382. collectionId: ''
  383. },
  384. whether: false,
  385. editCount: -1, // 页面会否被编辑 >0被编辑 =0 未编辑
  386. startCount: -1,
  387. isSaveSuccess: false, // 是否保存成功
  388. timeout: null,
  389. rules: {
  390. collectionLibType: [
  391. { required: true, message: '请选择术语集合类型', trigger: 'change' }
  392. ],
  393. collectionLibName: [
  394. { required: true, message: '请选择术语集合名称', trigger: 'change' }
  395. ]
  396. }
  397. };
  398. },
  399. created() {
  400. this.getDict();
  401. const param = this.$route.params;
  402. let type = param.type;
  403. if (type == 2) {
  404. this.title = '术语集合内容维护-' + '修改';
  405. this.getInfo(param.id);
  406. this.sign = 2;
  407. this.$nextTick(() => {
  408. this.getIds(this.form.concepts);
  409. this.getTreeSearchList();
  410. });
  411. }
  412. setTimeout(() => {
  413. this.startCount = this.editCount;
  414. }, 500);
  415. },
  416. methods: {
  417. handleInput(event) {
  418. let text = event.target.innerText;
  419. this.innerText = text.replace(/(^\s*)|(\s*$)/g, '');
  420. },
  421. getInfo(id) {
  422. const loading = this.$loading({
  423. lock: true,
  424. text: 'Loading',
  425. spinner: 'el-icon-loading',
  426. background: 'rgba(0, 0, 0, 0.7)'
  427. });
  428. api
  429. .getRecordById({ id })
  430. .then(res => {
  431. loading.close();
  432. if (res.data.code == '0') {
  433. const data = res.data.data;
  434. this.form.collectionLibType = JSON.stringify(
  435. data.collectionLibType
  436. );
  437. this.form.collectionLibName = data.collectionLibName;
  438. this.form.concepts = data.concepts;
  439. this.form.conceptLibType = data.concepts[0].conceptLibType;
  440. this.form.collectionId = data.collectionId;
  441. this.form.collectionRemark = data.collectionRemark;
  442. this.leftList = data.concepts;
  443. }
  444. })
  445. .catch(error => {
  446. loading.close();
  447. this.warning('获取详情失败,请重试');
  448. });
  449. },
  450. collectcancel() {
  451. this.dialogVisible = false;
  452. },
  453. cancelRequest() {
  454. if (typeof this.source === 'function') {
  455. this.source('终止请求');
  456. }
  457. },
  458. getDict() {
  459. api
  460. .zskgetDict()
  461. .then(res => {
  462. if (res.data.code == '0') {
  463. const data = res.data.data;
  464. this.ruleTypeList = data[63];
  465. this.type = data[61];
  466. }
  467. })
  468. .catch(error => {
  469. console.log(error);
  470. });
  471. },
  472. //过滤集合id
  473. getIds(arr) {
  474. arr.forEach((item, index) => {
  475. this.excludedConceptIds.push(item.conceptId);
  476. });
  477. },
  478. //获取术语集合名称
  479. searchLibName(val) {
  480. api
  481. .getSearchConcept({
  482. excludedConceptIds: [0],
  483. libType: this.form.collectionLibType,
  484. name: val
  485. })
  486. .then(res => {
  487. if (res.data.code == '0') {
  488. const data = res.data.data;
  489. this.ruleTermTypeList = data;
  490. }
  491. })
  492. .catch(error => {
  493. console.log(error);
  494. });
  495. },
  496. searchList() {
  497. let concepts, val;
  498. if (
  499. (this.searchtext != '' && this.searchtext2 == '') ||
  500. (this.searchtext == '' && this.searchtext2 != '')
  501. ) {
  502. concepts = JSON.parse(JSON.stringify(this.form.concepts));
  503. val = this.searchtext != '' ? this.searchtext : this.searchtext2;
  504. } else if (this.searchtext != '' && this.searchtext2 != '') {
  505. concepts = JSON.parse(JSON.stringify(this.leftList));
  506. val = this.searchtext2;
  507. } else if (this.searchtext == '' && this.searchtext2 == '') {
  508. this.leftList = JSON.parse(JSON.stringify(this.form.concepts));
  509. return;
  510. }
  511. let str = '.*' + val + '.*';
  512. let reg = new RegExp(str);
  513. let arr = [];
  514. //通过附加信息查询
  515. for (var i = 0; i < concepts.length; i++) {
  516. if (reg.test(concepts[i].conceptLibName)) {
  517. arr.push(concepts[i]);
  518. }
  519. }
  520. this.$refs.table.bodyWrapper.scrollTop = 0;
  521. this.leftList = arr;
  522. },
  523. getCollectionLib(newValue) {
  524. this.ruleTermTypeList.forEach(item => {
  525. if (newValue == item.conceptName) {
  526. // this.form.collectionLibName = item.conceptName;
  527. this.form.collectionId = item.conceptId;
  528. this.form.collectionRemark = item.remark;
  529. }
  530. });
  531. },
  532. // 基础术语
  533. searchConcept(e) {
  534. if (this.timeout) {
  535. clearTimeout(this.timeout);
  536. }
  537. this.timeout = setTimeout(() => {
  538. this.getTreeSearchList();
  539. this.$refs.tables.bodyWrapper.scrollTop = 0;
  540. }, 800);
  541. },
  542. async getTreeSearchList() {
  543. this.whether = true;
  544. const params = {
  545. libType: this.form.conceptLibType,
  546. names: [
  547. this.formInline.name1,
  548. this.formInline.name2,
  549. this.formInline.name3
  550. ],
  551. excludedConceptIds: this.excludedConceptIds,
  552. logicalOperator: this.formInline.logicalOperator
  553. };
  554. const data = await api.searchCollectionConceptVO(params);
  555. if (data.data.code == '0') {
  556. this.conceptList = data.data.data;
  557. this.whether = false;
  558. }
  559. },
  560. btn(row) {
  561. if (this.whether) {
  562. return;
  563. }
  564. let concepts = {
  565. conceptId: row.conceptId,
  566. conceptLibType: row.libType,
  567. conceptLibName: row.conceptName
  568. };
  569. this.excludedConceptIds.push(row.conceptId);
  570. this.form.concepts.push(concepts);
  571. this.leftList = this.form.concepts;
  572. this.conceptList = [];
  573. this.searchtext = '';
  574. this.searchtext2 = '';
  575. this.$nextTick(() => {
  576. setTimeout(() => {
  577. this.getTreeSearchList();
  578. }, 150);
  579. });
  580. },
  581. handleSelectionChange(val) {
  582. this.multipleSelection = val;
  583. },
  584. add() {
  585. if (this.multipleSelection.length == 0) {
  586. this.$message({
  587. message: '添加数据不能为空',
  588. type: 'warning'
  589. });
  590. return;
  591. }
  592. this.processing(this.multipleSelection);
  593. this.searchtext = '';
  594. this.searchtext2 = '';
  595. },
  596. //去重
  597. unique(arr) {
  598. let obj = {};
  599. arr = arr.reduce(function(item, next) {
  600. obj[next.conceptId]
  601. ? ''
  602. : (obj[next.conceptId] = true && item.push(next));
  603. return item;
  604. }, []);
  605. return arr;
  606. },
  607. //过滤数组去重
  608. unique2(arr) {
  609. let obj = {};
  610. arr = arr.reduce(function(item, next) {
  611. obj[next] ? '' : (obj[next] = true && item.push(next));
  612. return item;
  613. }, []);
  614. return arr;
  615. },
  616. //处理数据
  617. processing(arr) {
  618. if (this.whether) {
  619. return;
  620. }
  621. arr.forEach(it => {
  622. let concepts = {
  623. conceptId: it.conceptId,
  624. conceptLibType: it.libType ? it.libType : it.conceptLibType,
  625. conceptLibName: it.conceptName ? it.conceptName : it.conceptLibName
  626. };
  627. this.excludedConceptIds.push(it.conceptId);
  628. this.form.concepts.push(concepts);
  629. });
  630. this.form.concepts = this.unique(this.form.concepts);
  631. this.excludedConceptIds = this.unique2(this.excludedConceptIds);
  632. this.leftList = this.form.concepts;
  633. this.conceptList = [];
  634. this.multipleSelection = [];
  635. this.$nextTick(() => {
  636. setTimeout(() => {
  637. this.getTreeSearchList();
  638. }, 150);
  639. });
  640. },
  641. // 切换术语类型
  642. getConceptLibType() {
  643. this.type.forEach(it => {
  644. let id = it.val.split('-');
  645. if (this.form.collectionLibType == id[0]) {
  646. this.form.conceptLibType = id[2];
  647. }
  648. });
  649. this.clearData();
  650. },
  651. // 移除术语
  652. showDelDialog(row) {
  653. if (this.searchtext == '' && this.searchtext2 == '') {
  654. this.form.concepts.forEach((item, index) => {
  655. if (item.conceptId == row.conceptId) {
  656. this.form.concepts.splice(index, 1);
  657. this.excludedConceptIds.splice(index, 1);
  658. }
  659. });
  660. this.leftList = this.form.concepts;
  661. } else {
  662. this.leftList.forEach((item, index) => {
  663. if (item.conceptId == row.conceptId) {
  664. this.leftList.splice(index, 1);
  665. }
  666. });
  667. this.form.concepts.forEach((item, index) => {
  668. if (item.conceptId == row.conceptId) {
  669. this.form.concepts.splice(index, 1);
  670. this.excludedConceptIds.splice(index, 1);
  671. }
  672. });
  673. }
  674. this.getTreeSearchList();
  675. },
  676. saveSet() {
  677. let params = {
  678. ...this.form,
  679. relationId: 0
  680. };
  681. const loading = this.$loading({
  682. lock: true,
  683. text: 'Loading',
  684. spinner: 'el-icon-loading',
  685. background: 'rgba(0, 0, 0, 0.7)'
  686. });
  687. api.saveOrUpdateRecord(params).then(res => {
  688. loading.close();
  689. if (res.data.code == 0) {
  690. this.$message({
  691. message: '操作成功',
  692. type: 'success'
  693. });
  694. this.loading2 = false;
  695. this.isSaveSuccess = true;
  696. this.$router.push({
  697. name: 'TermSet',
  698. params: Object.assign({}, this.$route.params, { currentPage: 1 })
  699. });
  700. } else {
  701. this.$message({
  702. message: res.data.msg,
  703. type: 'error'
  704. });
  705. loading.close();
  706. }
  707. });
  708. },
  709. collectionMatch() {
  710. if (this.innerText.length == 0) {
  711. this.$message({
  712. message: '术语名称不能为空',
  713. type: 'error'
  714. });
  715. return;
  716. }
  717. const loading = this.$loading({
  718. lock: true,
  719. text: 'Loading',
  720. spinner: 'el-icon-loading',
  721. background: 'rgba(0, 0, 0, 0.7)'
  722. });
  723. let params = {
  724. conceptLibNames: this.innerText,
  725. conceptLibType: this.form.conceptLibType
  726. };
  727. api
  728. .collectionMatch(params)
  729. .then(res => {
  730. loading.close();
  731. if (res.data.code == '0') {
  732. const data = res.data.data;
  733. let text = '';
  734. if (data.matchList.length > 0) {
  735. this.processing(data.matchList);
  736. if (
  737. data.unMatchList.length == 0 &&
  738. data.disableList.length == 0
  739. ) {
  740. this.dialogVisible = false;
  741. }
  742. }
  743. if (data.unMatchList.length > 0 || data.disableList.length > 0) {
  744. this.$message({
  745. message: '列表中存在非标准术语或禁用术语',
  746. type: 'error'
  747. });
  748. let arr = data.unMatchList.concat(data.disableList);
  749. arr.forEach(it => {
  750. text += it.conceptLibName + '\n';
  751. });
  752. }
  753. this.$refs.msg.innerHTML = text;
  754. this.innerText = text;
  755. }
  756. })
  757. .catch(error => {
  758. console.log(error);
  759. loading.close();
  760. });
  761. },
  762. clearData() {
  763. this.form.collectionLibName = '';
  764. this.conceptText = '';
  765. this.ruleTermTypeList = [];
  766. this.form.concepts = [];
  767. this.leftList = [];
  768. this.getTreeSearchList();
  769. }
  770. },
  771. watch: {
  772. form: {
  773. handler(newName, oldName) {
  774. this.editCount++;
  775. },
  776. deep: true,
  777. immediate: true
  778. }
  779. },
  780. beforeRouteLeave(to, from, next) {
  781. if (
  782. this.startCount !== this.editCount &&
  783. this.form.concepts.length > 0 &&
  784. !this.isSaveSuccess
  785. ) {
  786. this.$alert('还有未保存的内容,确定要退出当前页面吗?', '提示', {
  787. confirmButtonText: '确定',
  788. // cancelButtonText: '取消',
  789. // cancelButtonClass: 'leaveBtn',
  790. // customClass: 'leaveBox',
  791. type: 'warning'
  792. })
  793. .then(() => {
  794. next();
  795. })
  796. .catch(() => {});
  797. } else {
  798. next();
  799. }
  800. },
  801. computed: {
  802. onshow() {
  803. return (
  804. this.form.collectionLibType != '' && this.form.collectionLibName != ''
  805. );
  806. },
  807. len() {
  808. let arr = this.innerText.split('\n');
  809. let len = 0;
  810. arr.forEach(it => {
  811. if (it != '') {
  812. len++;
  813. }
  814. });
  815. return len;
  816. }
  817. }
  818. };
  819. </script>