LabelGroup.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <template>
  2. <div>
  3. <crumbs title="标签组维护" style="min-width: 980px">
  4. <el-form :inline="true" class="demo-form-inline">
  5. <el-form-item label="标签类型:">
  6. <el-select size="mini" v-model="filter.tagType[0]" placeholder="标签类型" clearable>
  7. <el-option v-for="item in tagTypes" :label="item.name" :value="item.val" :key="item.id"></el-option>
  8. </el-select>
  9. </el-form-item>
  10. <el-form-item label="标签归属:">
  11. <el-select size="mini" v-model="filter.tagAdscription" @change="getValue" placeholder="标签归属" clearable>
  12. <el-option v-for="item in Adscriptions" :label="item.name" :value="item.val" :key="item.id" ></el-option>
  13. </el-select>
  14. </el-form-item>
  15. <el-form-item label="标签系统名称:">
  16. <el-input size="mini" v-model="filter.tagSysName" placeholder="标签系统名称" clearable></el-input>
  17. </el-form-item>
  18. <el-form-item>
  19. <el-button size="mini" @click="filterDatas">确认</el-button>
  20. <el-button size="mini" type="warning" @click="addTagGroup">添加标签组</el-button>
  21. </el-form-item>
  22. </el-form>
  23. </crumbs>
  24. <div class="contents">
  25. <el-table
  26. :data="list"
  27. border
  28. style="width: 100%">
  29. <el-table-column
  30. :resizable = "false"
  31. type="index"
  32. :index = 'indexMethod'
  33. label="编号"
  34. width="60">
  35. </el-table-column>
  36. <el-table-column
  37. :resizable = "false"
  38. prop="gmtModified"
  39. label="操作时间"
  40. width="180">
  41. </el-table-column>
  42. <el-table-column
  43. :resizable = "false"
  44. prop="typeCn"
  45. label="标签归属">
  46. </el-table-column>
  47. <el-table-column
  48. :resizable = "false"
  49. prop="tagTypeCn"
  50. label="标签类型">
  51. </el-table-column>
  52. <el-table-column
  53. :resizable = "false"
  54. prop="tagName"
  55. label="标签系统名称">
  56. </el-table-column>
  57. <el-table-column
  58. :resizable = "false"
  59. label="标签名称是否存在于标准术语中">
  60. <template slot-scope="scope" >
  61. <span v-if="scope.row.itemType == 0">
  62. {{scope.row.exist ? "已存在" : "未存在"}}
  63. </span>
  64. </template>
  65. </el-table-column>
  66. <el-table-column
  67. :resizable = "false"
  68. prop="modifier"
  69. label="操作人">
  70. </el-table-column>
  71. <el-table-column
  72. :resizable = "false"
  73. prop="operate"
  74. label="操作">
  75. <template slot-scope="scope">
  76. <el-button @click="modifyTagGroup(scope.row, 'modify')" type="text" size="small">修改</el-button>
  77. <span style="margin:0 3px;">|</span>
  78. <el-button @click="modifyTagGroup(scope.row, 'copy')" class="text" type="text" size="small">复制</el-button>
  79. <span style="margin:0 3px;">|</span>
  80. <el-button @click="showDelDialog(scope.row.id,scope.row.type)" class="delete" type="text" size="small">删除</el-button>
  81. </template>
  82. </el-table-column>
  83. </el-table>
  84. <div class="pagination">
  85. <el-pagination :current-page.sync="currentPage"
  86. @current-change="currentChange"
  87. background
  88. :page-size="pageSize"
  89. :page-sizes="pageSizeArr"
  90. @size-change="handleSizeChange"
  91. :layout="pageLayout"
  92. :total="total">
  93. </el-pagination>
  94. </div>
  95. </div>
  96. </div>
  97. </template>
  98. <script>
  99. import api from '@api/icss.js';
  100. import config from '@api/config.js';
  101. import utils from '@api/utils.js';
  102. export default {
  103. name: 'tag-group',
  104. data: function() {
  105. return {
  106. list: [],
  107. tagTypes: [],
  108. Adscriptions: [], //标签归属列表
  109. tagTypesList: [], //标签类型列表
  110. searched: false,
  111. filter: {
  112. tagType: [], //标签类型
  113. tagAdscription: '', //标签归属
  114. tagSysName: '', //标签系统名称
  115. },
  116. currentPage: 1,
  117. pageSize: config.pageSize,
  118. pageSizeArr:config.pageSizeArr,
  119. pageLayout:config.pageLayout,
  120. total: 0,
  121. }
  122. },
  123. created() {
  124. this.getDropList().then(() => {
  125. this.getDataList()
  126. })
  127. },
  128. watch: {
  129. 'filter': {
  130. handler: function () {
  131. this.searched = false;
  132. },
  133. deep: true
  134. }
  135. },
  136. beforeRouteEnter(to, from, next) {
  137. next(vm => {
  138. //const pm = to.param;
  139. Object.assign(vm, to.params);
  140. vm.inCurrentPage=to.params.currentPage;
  141. })
  142. },
  143. methods: {
  144. handleSizeChange(val){
  145. this.pageSize = val;
  146. this.currentPage = utils.getCurrentPage(this.currentPage, this.total, this.pageSize);
  147. this.getDataList();
  148. },
  149. getValue(val) {
  150. // console.log('changeVal', val, this.filter.tagAdscription)
  151. },
  152. getDropList() {
  153. return api.getDropList().then((res) =>{
  154. // console.log('dropList', res)
  155. if(res.data.code === '0') {
  156. // this.Adscriptions = res.data.data[1];
  157. let tmpLis = res.data.data[1]
  158. this.Adscriptions = tmpLis.filter(item => item.val != 7);
  159. this.tagTypes = res.data.data[2];
  160. for (var i = 0; i < this.tagTypes.length; i++) {
  161. this.tagTypesList.push(this.tagTypes[i].val)
  162. }
  163. }
  164. })
  165. },
  166. getDataList(isTurnPage) {
  167. const param = this.getFilterItems(isTurnPage);
  168. this.searched = true;
  169. const loading = this.$loading({
  170. lock: true,
  171. text: 'Loading',
  172. spinner: 'el-icon-loading',
  173. background: 'rgba(0, 0, 0, 0.7)'
  174. });
  175. api.getTagList(param).then((res) => {
  176. loading.close()
  177. const list = res.data.data.records
  178. for (var i = 0; i < list.length; i++) {
  179. for (var j = 0; j < this.tagTypes.length; j++) {
  180. if(list[i].tagType == this.tagTypes[j].val) {
  181. list[i].tagTypeCn = this.tagTypes[j].name
  182. }
  183. }
  184. for (var z = 0; z < this.Adscriptions.length; z++) {
  185. if(list[i].type == this.Adscriptions[z].val) {
  186. list[i].typeCn = this.Adscriptions[z].name
  187. }
  188. }
  189. }
  190. this.list = list;
  191. this.total = res.data.data.total;
  192. if(this.inCurrentPage!==undefined){
  193. this.currentPage=this.inCurrentPage;
  194. this.inCurrentPage = undefined;
  195. }
  196. })
  197. },
  198. filterDatas() {
  199. this.currentPage = 1;
  200. this.getDataList();
  201. },
  202. addTagGroup() {
  203. const pam = this.searched ? {
  204. currentPage: this.currentPage,
  205. pageSize:this.pageSize,
  206. filter: this.filter
  207. } : {currentPage: this.currentPage,
  208. pageSize:this.pageSize};
  209. this.$router.push({name: 'AddLabelGroup', params: pam});
  210. },
  211. modifyTagGroup(row, type) {
  212. api.detailsTag({id:row.id}).then((res)=>{
  213. const {code,data,msg} = res.data;
  214. if(code=='0'){
  215. const item = Object.assign({},row,data);
  216. const pam = this.searched ? {
  217. currentPage: this.currentPage,
  218. filter: this.filter
  219. } : {currentPage: this.currentPage};
  220. // console.log('item', item)
  221. if(type == 'modify') {
  222. this.$router.push({
  223. name: 'AddLabelGroup',
  224. params: Object.assign(pam, {isEdit: true, data: item})
  225. });
  226. } else if( type == 'copy') {
  227. this.$router.push({
  228. name: 'AddLabelGroup',
  229. params: Object.assign(pam, {isCopy: true, data: item})
  230. });
  231. } else {
  232. return
  233. }
  234. }else{
  235. this.$message({
  236. message: msg,
  237. type: 'warning'
  238. });
  239. }
  240. });
  241. },
  242. currentChange(next) {
  243. this.currentPage = next;
  244. this.getDataList(true);
  245. // if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  246. // this.list = this.cacheData[next];
  247. // } else {
  248. // this.getDataList();
  249. // }
  250. },
  251. getFilterItems(isTurnPage) {
  252. //翻页时筛选条件没点确定则清空
  253. if(isTurnPage&&!this.searched){
  254. this.clearFilter();
  255. };
  256. const param = {
  257. tagTypeList: this.filter.tagType[0] && this.filter.tagType|| this.tagTypesList,
  258. current: this.inCurrentPage||this.currentPage,
  259. size: this.pageSize,
  260. type: this.filter.tagAdscription,
  261. tagName: this.filter.tagSysName.trim(),
  262. notTypeList: [7]
  263. };
  264. return param;
  265. },
  266. indexMethod(index) {
  267. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  268. },
  269. getTagType(val) {
  270. return val
  271. },
  272. warning(msg,type){
  273. this.$message({
  274. showClose: true,
  275. dangerouslyUseHTMLString: true,
  276. message:'<p>'+msg+'</p>',
  277. type:type||'warning'
  278. })
  279. },
  280. showConfirmDialog(msg,resolve){
  281. this.$alert(msg, '提示', {
  282. confirmButtonText: '确定',
  283. type: 'warning'
  284. }).then(() => {
  285. resolve();
  286. }).catch(() => {});
  287. },
  288. clearFilter(){
  289. this.filter={
  290. tagType: [], //标签类型
  291. tagAdscription: '', //标签归属
  292. tagSysName: '', //标签系统名称
  293. };
  294. },
  295. showDelDialog(id,type){
  296. this.showConfirmDialog('是否删除该标签组?',()=>{
  297. api.deleteTagGroup({ids:id,type:type}).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 = this.currentPage===1?1:this.currentPage-1;
  306. }
  307. this.getDataList();
  308. this.warning(res.data.msg || '操作成功','success');
  309. }else{
  310. this.warning(res.data.msg);
  311. }
  312. }).catch((error)=>{
  313. this.warning(error);
  314. })
  315. });
  316. }
  317. }
  318. }
  319. </script>
  320. <style lang="less">
  321. @import "../../less/admin.less";
  322. .delete{
  323. color: red;
  324. }
  325. .delete:hover {
  326. color: red;
  327. }
  328. .pagination {
  329. min-width: 1010px;
  330. }
  331. </style>