TermSet.vue 12 KB

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