group.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <div v-loading="loading">
  3. <div class="white-box">
  4. <div class="leo-filter" v-loading="loading">
  5. <div :class="`filter-item filter-date-range-picker`">
  6. <el-input v-model="filterModel.userName" placeholder="请输入会员编号">
  7. <template slot="append">【{{realName}}】</template>
  8. </el-input>
  9. </div>
  10. <el-button class="filter-item filter-filter-btn" type="primary" @click="handleChkUser">确认</el-button>
  11. <el-button class="filter-item filter-filter-btn" type="primary" @click="handleFilter">Select</el-button>
  12. </div>
  13. <el-table class="table-box" ref="multipleTable" :data="tableData" stripe style="width: 100%;"
  14. :height="tool.getTableHeight()">
  15. <el-table-column v-for="(tableHeader, key) in tableHeaders" :key="key" :label="tableHeader.header" :width="tableHeader.other.width ? tableHeader.other.width : ''">
  16. <template slot-scope="scope">
  17. <template v-if="scope.row[tableHeader.index].other.tag" >
  18. <el-tag :type="scope.row[tableHeader.index].other.tag.type ? scope.row[tableHeader.index].other.tag.type : null" :size="scope.row[tableHeader.index].other.tag.size ? scope.row[tableHeader.index].other.tag.size : null" :class="scope.row[tableHeader.index].other.tag.class ? scope.row[tableHeader.index].other.tag.class : null" >{{scope.row[tableHeader.index].value}}</el-tag>
  19. </template>
  20. <template v-else>
  21. <div v-html="scope.row[tableHeader.index].value"></div>
  22. </template>
  23. </template>
  24. </el-table-column>
  25. </el-table>
  26. <div class="white-box-footer">
  27. <el-button type="success" size="small" @click="handleExport" v-show="permission.hasPermission(`user/group-export`)">Export Excel</el-button>
  28. <pagination :total="totalCount" :page_size="pageSize" @size-change="handleSizeChange"
  29. @current-change="handleCurrentChange"></pagination>
  30. </div>
  31. </div>
  32. </div>
  33. </template>
  34. <script>
  35. import network from '@/utils/network'
  36. import tool from '@/utils/tool'
  37. import Pagination from '@/components/Pagination'
  38. import permission from '@/utils/permission'
  39. export default {
  40. name: 'user_group',
  41. components: {Pagination},
  42. mounted() {
  43. this.loading = false
  44. },
  45. data() {
  46. return {
  47. tableHeaders: null,
  48. tableData: null,
  49. loading: true,
  50. multipleSelection: [],
  51. currentPage: 1,
  52. totalPages: 1,
  53. totalCount: 1,
  54. pageSize: 20,
  55. tool: tool,
  56. permission: permission,
  57. filterData: null,
  58. filterModel: {
  59. userName: '',
  60. },
  61. realName: '',
  62. }
  63. },
  64. methods: {
  65. handleChkUser() {
  66. if (this.filterModel.userName) {
  67. this.loading = true
  68. network.getData('user/full-info', {userName: this.filterModel.userName}).then(response => {
  69. this.realName = response.REAL_NAME
  70. this.loading = false
  71. }).catch(response => {
  72. this.loading = false
  73. })
  74. }
  75. },
  76. handleCurrentChange(page) {
  77. this.getData(page, this.pageSize)
  78. },
  79. handleSizeChange(pageSize) {
  80. this.getData(this.currentPage, pageSize)
  81. },
  82. handleFilter() {
  83. if (this.filterModel.userName === '') {
  84. this.$message({
  85. message: '请填写会员编号',
  86. type: 'warning'
  87. })
  88. return false
  89. }
  90. this.filterData = this.filterModel
  91. this.getData(1, this.pageSize)
  92. },
  93. getData(page, pageSize) {
  94. let vueObj = this
  95. network.getPageData(this, 'user/group', page, pageSize, this.filterData, function (response) {
  96. vueObj.tableData = response.list
  97. })
  98. },
  99. handleExport(){
  100. this.$confirm(`Are you sure you want to export the current data?`, 'Hint', {
  101. confirmButtonText: 'confirm', // 确定
  102. cancelButtonText: 'cancel', // 取消
  103. type: 'warning'
  104. }).then(() => {
  105. return network.getData(`user/group-export`, this.filterModel)
  106. }).then(response => {
  107. this.$message({
  108. message: response,
  109. type: 'success'
  110. })
  111. }).catch(response => {
  112. })
  113. },
  114. }
  115. }
  116. </script>
  117. <style scoped>
  118. .leo-filter {
  119. padding: 0 0 15px 0;
  120. }
  121. .leo-filter .filter-hidden {
  122. display: none;
  123. }
  124. .filter-item {
  125. margin-right: 10px;
  126. }
  127. @media (min-width: 768px) {
  128. .leo-filter {
  129. }
  130. .leo-filter .filter-item {
  131. display: inline-block;
  132. max-width: 200px;
  133. }
  134. .leo-filter .filter-item.filter-date-month-picker {
  135. display: inline-block;
  136. max-width: 220px;
  137. }
  138. .leo-filter .filter-item.filter-date-range-picker {
  139. display: inline-block;
  140. max-width: 380px;
  141. }
  142. .leo-filter .filter-item.filter-filter-btn {
  143. height: 38px;
  144. width: 80px;
  145. }
  146. .leo-filter .filter-hidden {
  147. display: none;
  148. }
  149. }
  150. .table-box .el-form-item__label {
  151. width: 100px;
  152. color: #99a9bf;
  153. }
  154. .table-box .el-form-item {
  155. width: 30%;
  156. margin-right: 0;
  157. margin-bottom: 0;
  158. }
  159. </style>