TermSet.vue 11 KB

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