index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <template>
  2. <div v-loading="loading">
  3. <div class="white-box">
  4. <div class="filter-box">
  5. <filter-user :filter-types.sync="filterTypes" filter-btn-name="Select"
  6. @select-value="handleFilterUser"></filter-user>
  7. </div>
  8. <el-table :data="tableData" stripe style="width: 100%;" @selection-change="handleSelectionChange" :height="tool.getTableHeight()">
  9. <el-table-column type="selection" width="55" :selectable="checkSelectable"></el-table-column>
  10. <el-table-column label="登录账号" prop="ADMIN_NAME" width="150">
  11. <template slot-scope="scope">
  12. <el-tag type="" size="small" class="no-border">{{scope.row.ADMIN_NAME}}</el-tag>
  13. </template>
  14. </el-table-column>
  15. <el-table-column label="姓名" prop="REAL_NAME" width="150">
  16. <template slot-scope="scope">
  17. {{scope.row.REAL_NAME}}
  18. </template>
  19. </el-table-column>
  20. <el-table-column label="备注" prop="REMARK" width="150">
  21. <template slot-scope="scope">
  22. {{scope.row.REMARK}}
  23. </template>
  24. </el-table-column>
  25. <el-table-column label="角色" prop="ROLE_NAME" width="150">
  26. <template slot-scope="scope">
  27. <el-tag type="warning" size="small" class="no-border">{{scope.row.ROLE_NAME}}</el-tag>
  28. </template>
  29. </el-table-column>
  30. <el-table-column label="是否启用" prop="IS_ENABLE">
  31. <template slot-scope="scope">
  32. <el-tag :type="(scope.row.IS_ENABLE==1?'success':'danger')">{{(scope.row.IS_ENABLE==1?'是':'否')}}</el-tag>
  33. </template>
  34. </el-table-column>
  35. <el-table-column label="登录次数" prop="LOGIN_NUMS">
  36. <template slot-scope="scope">
  37. {{scope.row.LOGIN_NUMS}}
  38. </template>
  39. </el-table-column>
  40. <el-table-column label="最后登录IP" prop="LAST_LOGIN_IP" width="150">
  41. <template slot-scope="scope">
  42. {{scope.row.LAST_LOGIN_IP}}
  43. </template>
  44. </el-table-column>
  45. <el-table-column label="最后登录时间" width="180">
  46. <template slot-scope="scope">
  47. {{tool.formatDate(scope.row.LAST_LOGIN_AT)}}
  48. </template>
  49. </el-table-column>
  50. <el-table-column label="绑定IP" width="250">
  51. <template slot-scope="scope">
  52. {{scope.row.BIND_IP}}
  53. </template>
  54. </el-table-column>
  55. <el-table-column label="创建人" width="150">
  56. <template slot-scope="scope">
  57. {{scope.row.CREATE_ADMIN_NAME}}
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="创建时间" width="180">
  61. <template slot-scope="scope">
  62. {{tool.formatDate(scope.row.CREATED_AT)}}
  63. </template>
  64. </el-table-column>
  65. <el-table-column label="修改人" width="150">
  66. <template slot-scope="scope">
  67. {{scope.row.UPDATE_ADMIN_NAME}}
  68. </template>
  69. </el-table-column>
  70. <el-table-column label="修改时间" width="180">
  71. <template slot-scope="scope">
  72. {{tool.formatDate(scope.row.UPDATED_AT)}}
  73. </template>
  74. </el-table-column>
  75. <el-table-column fixed="right" label="操作" width="180">
  76. <template slot-scope="scope">
  77. <el-dropdown size="small" trigger="click" @command="handleRow" @click.stop="" v-if="scope.row.DONT_DEL!=='1'&&(permission.hasPermission(`admin/edit`)||permission.hasPermission(`admin/admin-delete`))">
  78. <el-button type="primary" size="small">
  79. Operate on this data<i class="el-icon-arrow-down el-icon--right"></i>
  80. </el-button>
  81. <el-dropdown-menu slot="dropdown">
  82. <el-dropdown-item :command="`edit|${scope.row.ID}`" v-if="permission.hasPermission(`admin/edit`)">Edit</el-dropdown-item>
  83. <el-dropdown-item :command="`delete|${scope.row.ID}`" v-if="permission.hasPermission(`admin/admin-delete`)">Delete</el-dropdown-item>
  84. </el-dropdown-menu>
  85. </el-dropdown>
  86. </template>
  87. </el-table-column>
  88. </el-table>
  89. <div class="white-box-footer">
  90. <el-dropdown size="small" trigger="click" @command="handleMuliDel" v-if="permission.hasPermission(`admin/admin-delete`)">
  91. <el-button type="primary" size="small">
  92. Selected data<!--所选数据--><i class="el-icon-arrow-down el-icon--right"></i>
  93. </el-button>
  94. <el-dropdown-menu slot="dropdown">
  95. <el-dropdown-item command="delete">Delete</el-dropdown-item>
  96. </el-dropdown-menu>
  97. </el-dropdown>
  98. <el-button type="primary" size="small" @click="handleAdd" icon="el-icon-plus" v-show="permission.hasPermission(`admin/add`)">添加管理员</el-button>
  99. <pagination :total="totalCount" :page_size="pageSize" @size-change="handleSizeChange" @current-change="handleCurrentChange"></pagination>
  100. </div>
  101. </div>
  102. </div>
  103. </template>
  104. <script>
  105. import Vue from 'vue'
  106. import network from '@/utils/network'
  107. import tool from '@/utils/tool'
  108. import store from '@/utils/vuexStore'
  109. import FilterUser from '@/components/FilterUser'
  110. import permission from '@/utils/permission'
  111. import Pagination from '@/components/Pagination'
  112. import filterHelper from '../../utils/filterHelper'
  113. export default {
  114. name: 'dec-level',
  115. components: {FilterUser,Pagination},
  116. created () {
  117. },
  118. mounted () {
  119. this.getData()
  120. },
  121. data () {
  122. return {
  123. tableData: null,
  124. loading: true,
  125. multipleSelection: [],
  126. currentPage: 1,
  127. totalPages: 1,
  128. totalCount: 1,
  129. pageSize: 20,
  130. tool: tool,
  131. permission: permission,
  132. filterData: null,
  133. filterTypes: {
  134. 'ADMIN_NAME': {isUserTable: false, name: '登录账号'},
  135. 'REAL_NAME': {isUserTable: false, name: '姓名'},
  136. 'REMARK': {isUserTable: false, name: '备注'},
  137. 'ROLE_NAME': {isUserTable: false, name: '角色'},
  138. 'IS_ENABLE': {isUserTable: false, name: '是否启用', other: 'yesOrNo'},
  139. 'LOGIN_NUMS': {isUserTable: false, name: '登录次数'},
  140. 'LAST_LOGIN_IP': {isUserTable: false, name: '最后登录IP'},
  141. 'LAST_LOGIN_AT': {isUserTable: false, name: '最后登录时间', other: 'date'},
  142. 'BIND_IP': {isUserTable: false, name: '绑定IP'},
  143. 'CREATE_ADMIN_NAME': {isUserTable: false, name: '创建人'},
  144. 'CREATED_AT': {isUserTable: false, name: '创建时间', other: 'date'},
  145. 'UPDATE_ADMIN_NAME': {isUserTable: false, name: '修改人'},
  146. 'UPDATED_AT': {isUserTable: false, name: '修改时间', other: 'date'},
  147. },
  148. filterModel: {},
  149. }
  150. },
  151. methods: {
  152. checkSelectable(row) {
  153. return row.DONT_DEL !== '1'
  154. },
  155. handleSelectionChange (val) {
  156. this.multipleSelection = val
  157. },
  158. handleCurrentChange (page) {
  159. this.getData(page, this.pageSize)
  160. },
  161. handleSizeChange (pageSize) {
  162. this.getData(this.currentPage, pageSize)
  163. },
  164. handleRow (command) {
  165. let re = command.split('|')
  166. this.handleCommand(re[0], re[1])
  167. },
  168. handleMuliDel (command) {
  169. if (command === 'delete') {
  170. this.delData(this)
  171. }
  172. },
  173. handleAdd () {
  174. this.$router.push({path: `/admin/add`})
  175. },
  176. handleUpdate (row) {
  177. this.$router.push({path: `/admin/edit/${row.ID}`})
  178. },
  179. handleCommand (command, id) {
  180. if (command === 'edit') {
  181. this.$router.push({path: `/admin/edit/${id}`})
  182. } else if (command === 'delete') {
  183. this.delData(this, id)
  184. }
  185. },
  186. handleFilterUser(filterData) {
  187. filterHelper.handleFilterUser(this, filterData)
  188. },
  189. handleFilter() {
  190. this.getData()
  191. },
  192. getData(page, pageSize) {
  193. let filterData = this.filterModel
  194. let vueObj = this
  195. network.getPageData(this, 'admin/index', page, pageSize, filterData, function (response) {
  196. vueObj.allData = response
  197. })
  198. },
  199. delData (obj, id = null) {
  200. obj.$confirm('确定删除选定的数据?', 'Notice', {
  201. confirmButtonText: 'confirm', // 确定
  202. cancelButtonText: 'cancel', // 取消
  203. type: 'warning'
  204. }).then(() => {
  205. let selectedIds = []
  206. if (id === null) {
  207. for (let val of obj.multipleSelection) {
  208. selectedIds.push(val.ID)
  209. }
  210. } else {
  211. selectedIds.push(id)
  212. }
  213. return network.postData(`admin/admin-delete`, {
  214. selected: selectedIds
  215. })
  216. }).then(response => {
  217. obj.$message({
  218. message: response,
  219. type: 'success'
  220. })
  221. obj.getData()
  222. }).catch(response => {
  223. })
  224. }
  225. }
  226. }
  227. </script>
  228. <style scoped>
  229. </style>