LabelGroup.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  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. export default {
  102. name: 'tag-group',
  103. data: function() {
  104. return {
  105. list: [],
  106. tagTypes: [],
  107. Adscriptions: [], //标签归属列表
  108. tagTypesList: [], //标签类型列表
  109. searched: false,
  110. filter: {
  111. tagType: [], //标签类型
  112. tagAdscription: '', //标签归属
  113. tagSysName: '', //标签系统名称
  114. },
  115. currentPage: 1,
  116. pageSize: config.pageSize,
  117. pageSizeArr:config.pageSizeArr,
  118. pageLayout:config.pageLayout,
  119. total: 0,
  120. }
  121. },
  122. created() {
  123. this.getDropList().then(() => {
  124. this.getDataList()
  125. })
  126. },
  127. watch: {
  128. 'filter': {
  129. handler: function () {
  130. this.searched = false;
  131. },
  132. deep: true
  133. }
  134. },
  135. beforeRouteEnter(to, from, next) {
  136. next(vm => {
  137. //const pm = to.param;
  138. Object.assign(vm, to.params);
  139. })
  140. },
  141. methods: {
  142. handleSizeChange(val){
  143. this.pageSize = val;
  144. this.getDataList();
  145. },
  146. getValue(val) {
  147. // console.log('changeVal', val, this.filter.tagAdscription)
  148. },
  149. getDropList() {
  150. return api.getDropList().then((res) =>{
  151. // console.log('dropList', res)
  152. if(res.data.code === '0') {
  153. // this.Adscriptions = res.data.data[1];
  154. let tmpLis = res.data.data[1]
  155. this.Adscriptions = tmpLis.filter(item => item.val != 7);
  156. this.tagTypes = res.data.data[2];
  157. for (var i = 0; i < this.tagTypes.length; i++) {
  158. this.tagTypesList.push(this.tagTypes[i].val)
  159. }
  160. }
  161. })
  162. },
  163. getDataList(isTurnPage) {
  164. const param = this.getFilterItems(isTurnPage);
  165. this.searched = true;
  166. api.getTagList(param).then((res) => {
  167. const list = res.data.data.records
  168. for (var i = 0; i < list.length; i++) {
  169. for (var j = 0; j < this.tagTypes.length; j++) {
  170. if(list[i].tagType == this.tagTypes[j].val) {
  171. list[i].tagTypeCn = this.tagTypes[j].name
  172. }
  173. }
  174. for (var z = 0; z < this.Adscriptions.length; z++) {
  175. if(list[i].type == this.Adscriptions[z].val) {
  176. list[i].typeCn = this.Adscriptions[z].name
  177. }
  178. }
  179. }
  180. this.list = list;
  181. this.total = res.data.data.total;
  182. })
  183. },
  184. filterDatas() {
  185. this.currentPage = 1;
  186. this.getDataList();
  187. },
  188. addTagGroup() {
  189. const pam = this.searched ? {
  190. currentPage: this.currentPage,
  191. pageSize:this.pageSize,
  192. filter: this.filter
  193. } : {currentPage: this.currentPage,
  194. pageSize:this.pageSize};
  195. this.$router.push({name: 'AddLabelGroup', params: pam});
  196. },
  197. modifyTagGroup(row, type) {
  198. api.detailsTag({id:row.id}).then((res)=>{
  199. const {code,data,msg} = res.data;
  200. if(code=='0'){
  201. const item = Object.assign({},row,data);
  202. const pam = this.searched ? {
  203. currentPage: this.currentPage,
  204. filter: this.filter
  205. } : {currentPage: this.currentPage};
  206. // console.log('item', item)
  207. if(type == 'modify') {
  208. this.$router.push({
  209. name: 'AddLabelGroup',
  210. params: Object.assign(pam, {isEdit: true, data: item})
  211. });
  212. } else if( type == 'copy') {
  213. this.$router.push({
  214. name: 'AddLabelGroup',
  215. params: Object.assign(pam, {isCopy: true, data: item})
  216. });
  217. } else {
  218. return
  219. }
  220. }else{
  221. this.$message({
  222. message: msg,
  223. type: 'warning'
  224. });
  225. }
  226. });
  227. },
  228. currentChange(next) {
  229. this.currentPage = next;
  230. this.getDataList(true);
  231. // if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  232. // this.list = this.cacheData[next];
  233. // } else {
  234. // this.getDataList();
  235. // }
  236. },
  237. getFilterItems(isTurnPage) {
  238. //翻页时筛选条件没点确定则清空
  239. if(isTurnPage&&!this.searched){
  240. this.clearFilter();
  241. };
  242. const param = {
  243. tagTypeList: this.filter.tagType[0] && this.filter.tagType|| this.tagTypesList,
  244. current: this.currentPage,
  245. size: this.pageSize,
  246. type: this.filter.tagAdscription,
  247. tagName: this.filter.tagSysName.trim(),
  248. notTypeList: [7]
  249. };
  250. return param;
  251. },
  252. indexMethod(index) {
  253. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  254. },
  255. getTagType(val) {
  256. return val
  257. },
  258. warning(msg,type){
  259. this.$message({
  260. showClose: true,
  261. dangerouslyUseHTMLString: true,
  262. message:'<p>'+msg+'</p>',
  263. type:type||'warning'
  264. })
  265. },
  266. showConfirmDialog(msg,resolve){
  267. this.$alert(msg, '提示', {
  268. confirmButtonText: '确定',
  269. type: 'warning'
  270. }).then(() => {
  271. resolve();
  272. }).catch(() => {});
  273. },
  274. clearFilter(){
  275. this.filter={
  276. tagType: [], //标签类型
  277. tagAdscription: '', //标签归属
  278. tagSysName: '', //标签系统名称
  279. };
  280. },
  281. showDelDialog(id,type){
  282. this.showConfirmDialog('是否删除该标签组?',()=>{
  283. api.deleteTagGroup({ids:id,type:type}).then((res)=>{
  284. if(res.data.code=='0'){
  285. if(!this.searched){
  286. //未点确认时清空搜索条件
  287. this.clearFilter();
  288. }
  289. if(this.list.length==1){
  290. //当前在最后一页且只有一条数据时,删除后跳到前一页
  291. this.currentPage = this.currentPage===1?1:this.currentPage-1;
  292. }
  293. this.getDataList();
  294. this.warning(res.data.msg || '操作成功','success');
  295. }else{
  296. this.warning(res.data.msg);
  297. }
  298. }).catch((error)=>{
  299. this.warning(error);
  300. })
  301. });
  302. }
  303. }
  304. }
  305. </script>
  306. <style lang="less">
  307. @import "../../less/admin.less";
  308. .delete{
  309. color: red;
  310. }
  311. .delete:hover {
  312. color: red;
  313. }
  314. .pagination {
  315. min-width: 1010px;
  316. }
  317. </style>