AddTermSet.vue 22 KB

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