LabelGroup.vue 8.6 KB

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