LabelGroup.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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="primary" @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. type="index"
  31. :index = 'indexMethod'
  32. label="编号"
  33. width="60">
  34. </el-table-column>
  35. <el-table-column
  36. prop="gmtModified"
  37. label="操作时间"
  38. width="180">
  39. </el-table-column>
  40. <el-table-column
  41. prop="typeCn"
  42. label="标签归属">
  43. </el-table-column>
  44. <el-table-column
  45. prop="tagTypeCn"
  46. label="标签类型">
  47. </el-table-column>
  48. <el-table-column
  49. prop="tagName"
  50. label="标签系统名称">
  51. </el-table-column>
  52. <el-table-column
  53. prop="modifier"
  54. label="操作人">
  55. </el-table-column>
  56. <el-table-column
  57. prop="operate"
  58. label="操作">
  59. <template slot-scope="scope">
  60. <el-button @click="modifyTagGroup(scope.row)" type="text" size="small">修改</el-button>
  61. <el-button @click="showDelDialog(scope.row.id)" class="delete" type="text" size="small">删除</el-button>
  62. </template>
  63. </el-table-column>
  64. </el-table>
  65. </div>
  66. <el-pagination v-if="total>pageSize"
  67. :current-page.sync="currentPage"
  68. @current-change="currentChange"
  69. background
  70. :page-size="pageSize"
  71. layout="total,prev, pager, next, jumper"
  72. :total="total">
  73. </el-pagination>
  74. </div>
  75. </template>
  76. <script>
  77. import api from '@api/icss.js';
  78. export default {
  79. name: 'tag-group',
  80. data: function() {
  81. return {
  82. list: [],
  83. tagTypes: [],
  84. Adscriptions: [],
  85. tagTypesList: [],
  86. filter: {
  87. tagType: [], //标签类型
  88. tagAdscription: '', //标签归属
  89. tagSysName: '', //标签系统名称
  90. },
  91. currentPage: 1,
  92. pageSize: 10,
  93. total: 0,
  94. }
  95. },
  96. created() {
  97. this.getDropList().then(() => {
  98. this.getDataList()
  99. })
  100. },
  101. methods: {
  102. getValue(val) {
  103. console.log('changeVal', val, this.filter.tagAdscription)
  104. },
  105. getDropList() {
  106. return api.getDropList().then((res) =>{
  107. console.log('dropList', res)
  108. if(res.data.code === '0') {
  109. this.Adscriptions = res.data.data[1];
  110. this.tagTypes = res.data.data[3];
  111. for (var i = 0; i < this.tagTypes.length; i++) {
  112. this.tagTypesList.push(this.tagTypes[i].val)
  113. }
  114. }
  115. })
  116. },
  117. getDataList() {
  118. console.log('data', this.tagTypesList)
  119. const param = this.getFilterItems();
  120. console.log('param', param)
  121. api.getTagList(param).then((res) => {
  122. const list = res.data.data.records
  123. for (var i = 0; i < list.length; i++) {
  124. for (var j = 0; j < this.tagTypes.length; j++) {
  125. if(list[i].tagType === this.tagTypes[j].val) {
  126. list[i].tagTypeCn = this.tagTypes[j].name
  127. }
  128. }
  129. for (var z = 0; z < this.Adscriptions.length; z++) {
  130. if(list[i].type === this.Adscriptions[z].val) {
  131. list[i].typeCn = this.Adscriptions[z].name
  132. }
  133. }
  134. }
  135. this.list = list;
  136. this.total = res.data.data.total;
  137. console.log('tagGroup',res)
  138. })
  139. },
  140. filterDatas() {
  141. this.currentPage = 1;
  142. this.getDataList();
  143. },
  144. addTagGroup() {
  145. this.$router.push({path:'LT-YXSJWH-TJBQZ'})
  146. console.log('添加产品线');
  147. },
  148. modifyTagGroup() {
  149. console.log('修改产品线');
  150. },
  151. currentChange(next) {
  152. this.currentPage = next;
  153. this.getDataList();
  154. // if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  155. // this.list = this.cacheData[next];
  156. // } else {
  157. // this.getDataList();
  158. // }
  159. },
  160. getFilterItems() {
  161. const param = {
  162. tagTypeList: this.filter.tagType[0] && this.filter.tagType|| this.tagTypesList,
  163. current: this.currentPage,
  164. size: this.pageSize,
  165. type: this.filter.tagAdscription,
  166. tagName: this.filter.tagSysName
  167. };
  168. return param;
  169. },
  170. indexMethod(index) {
  171. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  172. },
  173. getTagType(val) {
  174. return val
  175. },
  176. warning(msg,type){
  177. this.$message({
  178. showClose: true,
  179. message:msg,
  180. type:type||'warning'
  181. })
  182. },
  183. showConfirmDialog(msg,resolve){
  184. this.$alert(msg, '提示', {
  185. confirmButtonText: '确定',
  186. type: 'warning'
  187. }).then(() => {
  188. resolve();
  189. }).catch(() => {});
  190. },
  191. showDelDialog(id){
  192. this.showConfirmDialog('是否删除该标签组?',()=>{
  193. api.deleteTagGroup({ids:id}).then((res)=>{
  194. if(res.data.code=='0'){
  195. this.getDataList();
  196. this.warning(res.data.msg || '操作成功','success');
  197. }else{
  198. this.warning(res.data.msg);
  199. }
  200. }).catch((error)=>{
  201. this.warning(error);
  202. })
  203. });
  204. }
  205. }
  206. }
  207. </script>
  208. <style lang="less">
  209. .delete{
  210. color: red
  211. }
  212. .delete:hover {
  213. color: red;
  214. }
  215. </style>