LabelGroup.vue 8.9 KB

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