LabelGroup.vue 8.7 KB

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