LabelGroup.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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. prop="modifier"
  60. label="操作人">
  61. </el-table-column>
  62. <el-table-column
  63. :resizable = "false"
  64. prop="operate"
  65. label="操作">
  66. <template slot-scope="scope">
  67. <el-button @click="modifyTagGroup(scope.row)" type="text" size="small">修改</el-button>
  68. <span style="margin:0 3px;">|</span>
  69. <el-button @click="showDelDialog(scope.row.id,scope.row.type)" class="delete" type="text" size="small">删除</el-button>
  70. </template>
  71. </el-table-column>
  72. </el-table>
  73. <div class="pagination">
  74. <el-pagination v-if="total>pageSize"
  75. :current-page.sync="currentPage"
  76. @current-change="currentChange"
  77. background
  78. :page-size="pageSize"
  79. layout="total,prev, pager, next, jumper"
  80. :total="total">
  81. </el-pagination>
  82. </div>
  83. </div>
  84. <!-- <div class="pagination">
  85. <el-pagination v-if="total>pageSize"
  86. :current-page.sync="currentPage"
  87. @current-change="currentChange"
  88. background
  89. :page-size="pageSize"
  90. layout="total,prev, pager, next, jumper"
  91. :total="total">
  92. </el-pagination>
  93. </div> -->
  94. </div>
  95. </template>
  96. <script>
  97. import api from '@api/icss.js';
  98. export default {
  99. name: 'tag-group',
  100. data: function() {
  101. return {
  102. list: [],
  103. tagTypes: [],
  104. Adscriptions: [], //标签归属列表
  105. tagTypesList: [], //标签类型列表
  106. filter: {
  107. tagType: [], //标签类型
  108. tagAdscription: '', //标签归属
  109. tagSysName: '', //标签系统名称
  110. },
  111. currentPage: 1,
  112. pageSize: 10,
  113. total: 0,
  114. }
  115. },
  116. created() {
  117. this.getDropList().then(() => {
  118. this.getDataList()
  119. })
  120. },
  121. methods: {
  122. getValue(val) {
  123. console.log('changeVal', val, this.filter.tagAdscription)
  124. },
  125. getDropList() {
  126. return api.getDropList().then((res) =>{
  127. // console.log('dropList', res)
  128. if(res.data.code === '0') {
  129. // this.Adscriptions = res.data.data[1];
  130. let tmpLis = res.data.data[1]
  131. this.Adscriptions = tmpLis.filter(item => item.val != 7);
  132. this.tagTypes = res.data.data[2];
  133. for (var i = 0; i < this.tagTypes.length; i++) {
  134. this.tagTypesList.push(this.tagTypes[i].val)
  135. }
  136. }
  137. })
  138. },
  139. getDataList() {
  140. const param = this.getFilterItems();
  141. api.getTagList(param).then((res) => {
  142. const list = res.data.data.records
  143. for (var i = 0; i < list.length; i++) {
  144. for (var j = 0; j < this.tagTypes.length; j++) {
  145. if(list[i].tagType == this.tagTypes[j].val) {
  146. list[i].tagTypeCn = this.tagTypes[j].name
  147. }
  148. }
  149. for (var z = 0; z < this.Adscriptions.length; z++) {
  150. if(list[i].type == this.Adscriptions[z].val) {
  151. list[i].typeCn = this.Adscriptions[z].name
  152. }
  153. }
  154. }
  155. this.list = list;
  156. this.total = res.data.data.total;
  157. })
  158. },
  159. filterDatas() {
  160. this.currentPage = 1;
  161. this.getDataList();
  162. },
  163. addTagGroup() {
  164. this.$router.push({path:'LT-YXSJWH-TJBQZ'})
  165. },
  166. modifyTagGroup(row) {
  167. api.detailsTag({id:row.id}).then((res)=>{
  168. const {code,data,msg} = res.data;
  169. if(code=='0'){
  170. const item = Object.assign({},row,data);
  171. // console.log('item', item)
  172. this.$router.push({name:'AddLabelGroup',params:{isEdit:true,data:item}});
  173. }else{
  174. this.$message({
  175. message: msg,
  176. type: 'warning'
  177. });
  178. }
  179. });
  180. },
  181. currentChange(next) {
  182. this.currentPage = next;
  183. this.getDataList();
  184. // if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  185. // this.list = this.cacheData[next];
  186. // } else {
  187. // this.getDataList();
  188. // }
  189. },
  190. getFilterItems() {
  191. const param = {
  192. tagTypeList: this.filter.tagType[0] && this.filter.tagType|| this.tagTypesList,
  193. current: this.currentPage,
  194. size: this.pageSize,
  195. type: this.filter.tagAdscription,
  196. tagName: this.filter.tagSysName,
  197. notTypeList: [7]
  198. };
  199. return param;
  200. },
  201. indexMethod(index) {
  202. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  203. },
  204. getTagType(val) {
  205. return val
  206. },
  207. warning(msg,type){
  208. this.$message({
  209. showClose: true,
  210. message:msg,
  211. type:type||'warning'
  212. })
  213. },
  214. showConfirmDialog(msg,resolve){
  215. this.$alert(msg, '提示', {
  216. confirmButtonText: '确定',
  217. type: 'warning'
  218. }).then(() => {
  219. resolve();
  220. }).catch(() => {});
  221. },
  222. showDelDialog(id,type){
  223. this.showConfirmDialog('是否删除该标签组?',()=>{
  224. api.deleteTagGroup({ids:id,type:type}).then((res)=>{
  225. if(res.data.code=='0'){
  226. this.getDataList();
  227. this.warning(res.data.msg || '操作成功','success');
  228. }else{
  229. this.warning(res.data.msg);
  230. }
  231. }).catch((error)=>{
  232. this.warning(error);
  233. })
  234. });
  235. }
  236. }
  237. }
  238. </script>
  239. <style lang="less">
  240. @import "../../less/admin.less";
  241. .delete{
  242. color: red;
  243. }
  244. .delete:hover {
  245. color: red;
  246. }
  247. .pagination {
  248. min-width: 1010px;
  249. }
  250. </style>