TermSet.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. <template>
  2. <div>
  3. <crumbs title="术语集合内容维护" :minWidth="titleWidth" class="knowledgeTitle">
  4. <el-form :inline="true" class="demo-form-inline">
  5. <el-form-item label="术语集合类型:">
  6. <el-select
  7. v-model.trim="filter.collectionLibType"
  8. clearable
  9. placeholder="请选择"
  10. size="mini"
  11. >
  12. <el-option
  13. v-for="item in ruleTypeList"
  14. :key="item.val"
  15. :label="item.name"
  16. :value="item.val"
  17. ></el-option>
  18. </el-select>
  19. </el-form-item>
  20. <el-form-item label="术语集合名称:">
  21. <el-input size="mini" v-model.trim="filter.collectionLibName" placeholder="请输入" clearable></el-input>
  22. </el-form-item>
  23. <el-form-item label="基础术语名称:">
  24. <el-input size="mini" v-model.trim="filter.conceptLibName" placeholder="请输入" clearable></el-input>
  25. </el-form-item>
  26. </el-form>
  27. <el-form :inline="true" class="demo-form-inline secLine">
  28. <el-form-item label="说明:">
  29. <el-input size="mini" v-model.trim="filter.collectionRemark" placeholder="请输入" clearable></el-input>
  30. </el-form-item>
  31. <el-form-item>
  32. <el-button size="mini" @click="filterDatas">确认</el-button>
  33. </el-form-item>
  34. <el-form-item>
  35. <el-button size="mini" @click="addRule" type="warning" style="margin:0 10px">+ 关联术语</el-button>
  36. <el-button size="mini" @click="update">更新数据</el-button>
  37. </el-form-item>
  38. </el-form>
  39. </crumbs>
  40. <div class="contents knowledgeContents">
  41. <el-table :data="list" border style="width: 100%">
  42. <el-table-column type="index" :index="indexMethod" label="编号" width="60"></el-table-column>
  43. <el-table-column prop="collectionLibName" label="术语集合名称"></el-table-column>
  44. <el-table-column prop="conceptLibName" label="术语集合类型">
  45. <template slot-scope="scope">
  46. <span
  47. v-for="item in ruleTypeList"
  48. >{{item.val==scope.row.collectionLibType?item.name:''}}</span>
  49. </template>
  50. </el-table-column>
  51. <el-table-column prop="collectionRemark" label="说明" width="400">
  52. <template slot-scope="scope">
  53. <el-tooltip
  54. v-if="scope.row.collectionRemark && scope.row.collectionRemark.length>80"
  55. class="item"
  56. effect="dark"
  57. :content="scope.row.collectionRemark"
  58. placement="top"
  59. >
  60. <span>{{scope.row.collectionRemark.slice(0,80)+'...'}}</span>
  61. </el-tooltip>
  62. <span
  63. v-if="scope.row.collectionRemark && scope.row.collectionRemark.length<81"
  64. >{{scope.row.collectionRemark}}</span>
  65. </template>
  66. </el-table-column>
  67. <el-table-column prop="concatConceptLibName" label="基础术语名称">
  68. <template slot-scope="scope">
  69. <el-tooltip
  70. class="item"
  71. effect="dark"
  72. :content="scope.row.concatConceptLibName.length>200?scope.row.concatConceptLibName.slice(0,200)+'...':scope.row.concatConceptLibName"
  73. placement="top"
  74. >
  75. <span
  76. style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"
  77. >{{scope.row.concatConceptLibName}}</span>
  78. </el-tooltip>
  79. </template>
  80. </el-table-column>
  81. <el-table-column prop="modifier" label="操作人"></el-table-column>
  82. <el-table-column prop="gmtModified" label="操作时间"></el-table-column>
  83. <el-table-column label="操作" fixed="right">
  84. <template slot-scope="scope">
  85. <el-button type="text" size="small" @click="editData(scope.row.collectionId)">修改</el-button>
  86. <span style="margin:0 3px;">|</span>
  87. <el-button
  88. type="text"
  89. size="small"
  90. class="delete"
  91. @click="showDelDialog(scope.row,1)"
  92. >删除</el-button>
  93. </template>
  94. </el-table-column>
  95. </el-table>
  96. <el-pagination
  97. :current-page.sync="currentPage"
  98. @current-change="currentChange"
  99. background
  100. :page-size="pageSize"
  101. :page-sizes="pageSizeArr"
  102. @size-change="handleSizeChange"
  103. :layout="pageLayout"
  104. :total="total"
  105. ></el-pagination>
  106. </div>
  107. </div>
  108. </template>
  109. <script>
  110. import api from '@api/knowledgeLib.js';
  111. import config from '@api/config.js';
  112. import utils from '@api/utils.js';
  113. export default {
  114. name: 'TermSet',
  115. data: function() {
  116. return {
  117. list: [],
  118. ruleTypeList: [],
  119. searched: false,
  120. filter: {
  121. collectionRemark: '',
  122. collectionLibName: '',
  123. conceptLibName: '',
  124. collectionLibType: '0'
  125. },
  126. cacheData: {},
  127. currentPage: 1,
  128. pageSize: config.pageSize,
  129. pageSizeArr: config.pageSizeArr,
  130. pageLayout: config.pageLayout,
  131. total: 0,
  132. titleWidth: '970px' //头部最小宽度
  133. };
  134. },
  135. created() {
  136. const param = this.$route.params;
  137. if (param.currentPage && param.filter) {
  138. this.inCurrentPage = param.currentPage;
  139. this.filter = param.filter;
  140. }
  141. const that = this;
  142. //返回时避免参数未赋值就获取列表
  143. setTimeout(function() {
  144. that.getDataList();
  145. });
  146. this.getDict();
  147. },
  148. watch: {
  149. filter: {
  150. handler: function() {
  151. this.searched = false;
  152. },
  153. deep: true
  154. }
  155. },
  156. methods: {
  157. getDict() {
  158. api
  159. .zskgetDict()
  160. .then(res => {
  161. if (res.data.code == '0') {
  162. const data = res.data.data;
  163. this.ruleTypeList = data[62];
  164. }
  165. })
  166. .catch(error => {
  167. console.log(error);
  168. });
  169. },
  170. handleSizeChange(val) {
  171. this.pageSize = val;
  172. this.currentPage = utils.getCurrentPage(
  173. this.currentPage,
  174. this.total,
  175. this.pageSize
  176. );
  177. this.getDataList();
  178. },
  179. addRule() {
  180. const pam = this.searched
  181. ? {
  182. currentPage: this.currentPage,
  183. pageSize: this.pageSize,
  184. filter: this.filter
  185. }
  186. : { currentPage: this.currentPage, pageSize: this.pageSize };
  187. this.$router.push({ name: 'AddTermSet', params: pam });
  188. },
  189. filterDatas() {
  190. this.currentPage = 1;
  191. this.getDataList(1);
  192. },
  193. getDataList(flag, isTurnPage) {
  194. const params = this.getFilterItems(isTurnPage);
  195. this.searched = true;
  196. const loading = this.$loading({
  197. lock: true,
  198. text: 'Loading',
  199. spinner: 'el-icon-loading',
  200. background: 'rgba(0, 0, 0, 0.7)'
  201. });
  202. api
  203. .getConceptPage(params)
  204. .then(res => {
  205. loading.close();
  206. if (res.data.code == '0') {
  207. const data = res.data.data;
  208. for (let j = 0; j < data.records.length; j++) {
  209. data.records[j].condition =
  210. data.records[j].parStatus == '1' ? '启用' : '禁用';
  211. }
  212. this.list = data.records;
  213. if (!flag) {
  214. //搜索时不缓存
  215. this.cacheData[params.current] = data.records;
  216. } else {
  217. this.cacheData = {};
  218. }
  219. this.total = data.total;
  220. if (this.inCurrentPage !== undefined) {
  221. this.currentPage = this.inCurrentPage;
  222. this.inCurrentPage = undefined;
  223. }
  224. } else {
  225. this.warning(res.data.msg || '获取列表数据失败');
  226. }
  227. })
  228. .catch(error => {
  229. loading.close();
  230. console.log(error);
  231. });
  232. },
  233. getFilterItems(isTurnPage) {
  234. //翻页时筛选条件没点确定则清空
  235. if (isTurnPage && !this.searched) {
  236. this.clearFilter();
  237. }
  238. const param = {
  239. current: this.inCurrentPage || this.currentPage,
  240. size: this.pageSize,
  241. ...this.filter
  242. };
  243. return param;
  244. },
  245. indexMethod(index) {
  246. return (this.currentPage - 1) * this.pageSize + index + 1;
  247. },
  248. currentChange(next) {
  249. this.currentPage = next;
  250. /*if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  251. this.list = this.cacheData[next];
  252. } else {*/
  253. this.getDataList(1, true);
  254. //}
  255. },
  256. warning(msg, type) {
  257. this.$message({
  258. showClose: true,
  259. message: msg,
  260. type: type || 'warning'
  261. });
  262. },
  263. showConfirmDialog(msg, resolve) {
  264. this.$alert(msg, '提示', {
  265. confirmButtonText: '确定',
  266. type: 'warning'
  267. })
  268. .then(() => {
  269. resolve();
  270. })
  271. .catch(() => {});
  272. },
  273. editData(id) {
  274. const pam = this.searched
  275. ? {
  276. currentPage: this.currentPage,
  277. pageSize: this.pageSize,
  278. filter: this.filter,
  279. type: 2,
  280. id: id
  281. }
  282. : {
  283. currentPage: this.currentPage,
  284. pageSize: this.pageSize,
  285. type: 2,
  286. id: id
  287. };
  288. this.$router.push({
  289. name: 'AddTermSet',
  290. params: { ...pam }
  291. });
  292. },
  293. showDelDialog(row) {
  294. const param = {
  295. id: row.collectionId
  296. };
  297. let waringTxt = '是否删除该集合内容,可能对现有系统造成影响';
  298. this.showConfirmDialog(waringTxt, () => {
  299. api
  300. .deleteById(param)
  301. .then(res => {
  302. if (res.data.code == '0') {
  303. if (!this.searched) {
  304. //未点确认时清空搜索条件
  305. this.clearFilter();
  306. }
  307. if (this.list.length == 1) {
  308. //当前在最后一页且只有一条数据时,删除后跳到前一页
  309. this.currentPage =
  310. this.currentPage === 1 ? 1 : this.currentPage - 1;
  311. }
  312. this.warning(res.data.msg || '操作成功', 'success');
  313. this.getDataList();
  314. } else {
  315. this.warning(res.data.msg);
  316. }
  317. })
  318. .catch(error => {
  319. this.warning(error);
  320. });
  321. });
  322. },
  323. clearFilter() {
  324. this.filter = {
  325. collectionRemark: '',
  326. conceptLibName: '',
  327. collectionLibName: '',
  328. collectionLibType: ''
  329. };
  330. },
  331. update() {
  332. const loading = this.$loading({
  333. lock: true,
  334. text: 'Loading',
  335. spinner: 'el-icon-loading',
  336. background: 'rgba(0, 0, 0, 0.7)'
  337. });
  338. api
  339. .zskUpdateAll()
  340. .then(res => {
  341. loading.close();
  342. if (res.data.code == '0') {
  343. this.warning('更新成功', 'success');
  344. this.getDataList();
  345. } else {
  346. this.warning(res.data.msg || '更新失败,请重试');
  347. }
  348. })
  349. .catch(error => {
  350. loading.close();
  351. this.warning('更新失败,请重试');
  352. });
  353. }
  354. }
  355. };
  356. </script>
  357. <style lang="less" scoped>
  358. @import '../../less/admin.less';
  359. /deep/ .container.knowledgeTitle {
  360. height: 80px;
  361. }
  362. /deep/ .contents.knowledgeContents {
  363. padding: 104px 20px 0;
  364. }
  365. // /deep/ .el-form--inline .el-form-item{
  366. // height: 40px;
  367. // }
  368. /deep/ .secLine {
  369. float: right;
  370. display: flex;
  371. position: relative;
  372. top: -10px;
  373. .el-input__inner {
  374. width: 380px;
  375. }
  376. }
  377. .delete {
  378. color: red;
  379. }
  380. .review {
  381. color: #22ccc8;
  382. }
  383. .el-table .cell {
  384. overflow: hidden;
  385. white-space: nowrap;
  386. }
  387. #upFile {
  388. display: none !important;
  389. }
  390. .unvailable {
  391. color: #fe7d3d;
  392. &:hover {
  393. color: #f19061;
  394. }
  395. }
  396. </style>