123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- <template>
- <a-card size="small" :bordered="false">
- <a-spin :spinning="spinning" tip="Loading...">
- <div ref="tableSearch" class="table-page-search-wrapper">
- <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
- <a-row :gutter="15">
- <a-col :md="6" :sm="24">
- <a-form-item label="用户名称">
- <a-input allowClear v-model.trim="queryParam.name" placeholder="请输入用户名称"/>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="手机号码">
- <a-input allowClear v-model.trim="queryParam.phone" placeholder="请输入手机号码"/>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="状态">
- <v-select code="ENABLE_FLAG" v-model="queryParam.loginFlag" allowClear placeholder="请选择状态"></v-select>
- </a-form-item>
- </a-col>
- <a-col :md="4" :sm="24">
- <a-button type="primary" @click="$refs.table.refresh(true)" style="margin-right: 10px;">查询</a-button>
- <a-button type="" @click="reset" id="roleList-reset">重置</a-button>
- </a-col>
- </a-row>
- </a-form>
- </div>
- <div class="table-operator">
- <a-button type="primary" v-if="$hasPermissions('B_power_user_add')" class="button-error" @click="openModal">新增</a-button>
- </div>
- <s-table
- class="sTable fixPagination"
- ref="table"
- size="small"
- :style="{ height: tableHeight+84.5+'px' }"
- rowKey="id"
- :columns="columns"
- :data="loadData"
- :scroll="{ x: 1350, y: tableHeight }"
- style="word-break: break-all;"
- :defaultLoadData="false"
- bordered
- >
- <span slot="status" slot-scope="text, record">
- <!-- 超级管理员不可删除不可编辑不可启禁用 -->
- <a-switch v-if="record.superAdmin!=1 && $hasPermissions('B_power_user_enable')" checkedChildren="启用" unCheckedChildren="禁用" v-model="record.loginFlag" @change="changeFlagHandle(text, record)"/>
- <span v-else>{{ record.loginFlag==1?'已启用':'已禁用' }}</span>
- </span>
- <span slot="action" slot-scope="text, record">
- <a-icon
- type="edit"
- title="编辑"
- v-if="record.superAdmin!=1 &&$hasPermissions('B_power_user_edit')"
- :style="{fontSize: '20px',color:' #1890FF',padding:' 0 10px'}"
- @click="handleEdit(record)"
- />
- <a-icon
- type="unlock"
- title="重置密码"
- v-if="record.loginFlag==1 && record.superAdmin!=1 &&$hasPermissions('B_power_user_resetPsd')"
- :style="{fontSize: '20px',color:' #ffaa00',padding: '0 10px'}"
- @click="resetPassword(record)" />
- <a-icon
- type="delete"
- title="删除"
- :style="{fontSize: '20px',color: '#f00',padding: '0 10px'}"
- v-if="record.loginFlag==0 && record.superAdmin!=1 &&$hasPermissions('B_power_user_del')"
- @click="delect(record)"/>
- <a-icon
- type="setting"
- title="分区设置"
- v-if="$hasPermissions('B_power_user_set')"
- :style="{fontSize: '20px',color:' #00aa00',padding: '0 10px'}"
- @click="handleSetting(record)" />
- </span>
- </s-table>
- </a-spin>
- <userModal :visible="showModal" @refresh="$refs.table.refresh(true)" :nowData="itemData" @close="showModal = false"></userModal>
- <!-- 分区设置 -->
- <UpdateArea ref="UpdateArea" :openUdModal="openUdModal" @ok="$refs.table.refresh(true)" @close="openUdModal=false"></UpdateArea>
- </a-card>
- </template>
- <script>
- import { STable, VSelect } from '@/components'
- import userModal from './userModal.vue'
- import { resetPSD, updateEnableStatus, getPowerUserList, delectUserPower } from '@/api/power-user.js'
- import UpdateArea from './updateAreal.vue'
- export default {
- name: 'UserList',
- components: {
- STable, VSelect, userModal, UpdateArea
- },
- data () {
- return {
- spinning: false,
- tableHeight: 0,
- // 查询参数
- queryParam: {
- name: '',
- phone: '',
- loginFlag: undefined
- },
- showModal: false,
- openUdModal: false,
- itemData: null, // 编辑行数据
- // 表头
- columns: [
- { title: '序号', dataIndex: 'no', width: 70, align: 'center' },
- { title: '创建时间', dataIndex: 'createDate', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '用户名称', dataIndex: 'name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '手机号码', dataIndex: 'phone', width: 150, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '用户账号', dataIndex: 'loginName', width: 150, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '所属分区', dataIndex: 'allSubareaName', width: 150, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '角色', dataIndex: 'roleNames', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '状态', width: 100, align: 'center', scopedSlots: { customRender: 'status' }, fixed: 'right' },
- { title: '操作', width: 160, align: 'center', scopedSlots: { customRender: 'action' }, fixed: 'right' }
- ],
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.spinning = true
- return getPowerUserList(Object.assign(parameter, this.queryParam)).then(res => {
- const no = (res.data.pageNo - 1) * res.data.pageSize
- for (let i = 0; i < res.data.list.length; i++) {
- const _item = res.data.list[i]
- _item.no = no + i + 1
- _item.loginFlag = _item.loginFlag + '' === '1'
- }
- this.spinning = false
- return res.data
- })
- },
- optionAlertShow: false
- }
- },
- methods: {
- // 新增
- openModal () {
- this.showModal = true
- this.itemData = null
- },
- // 重置
- reset () {
- this.queryParam.name = ''
- this.queryParam.phone = ''
- this.queryParam.loginFlag = undefined
- this.$refs.table.refresh(true)
- },
- // 分区设置
- handleSetting (row) {
- this.openUdModal = true
- this.$refs.UpdateArea.setData(row)
- },
- // 重置密码
- resetPassword (row) {
- const _this = this
- this.$confirm({
- title: '提示',
- content: '确认重置密码吗?',
- centered: true,
- onOk () {
- _this.spinning = true
- resetPSD({
- id: row.id
- }).then(res => {
- if (res.status == 200) {
- _this.$message.success(res.message)
- _this.$refs.table.refresh()
- _this.spinning = false
- } else {
- _this.spinning = false
- }
- })
- }
- })
- },
- // 删除
- delect (row) {
- const _this = this
- this.$confirm({
- title: '警告',
- content: '删除后无法恢复,确认删除?',
- centered: true,
- onOk () {
- _this.spinning = true
- delectUserPower({
- id: row.id
- }).then(res => {
- if (res.status == 200) {
- _this.$message.success(res.message)
- _this.$refs.table.refresh()
- _this.spinning = false
- } else {
- _this.$message.error(res.message)
- _this.spinning = false
- }
- })
- }
- })
- },
- handleEdit (row) {
- this.showModal = true
- this.itemData = row
- },
- // 修改状态
- changeFlagHandle (text, record) {
- const _data = {
- id: record.id,
- flag: record.loginFlag ? '1' : '0'
- }
- this.spinning = true
- updateEnableStatus(_data).then(res => {
- if (res.status == 200) {
- this.$message.success(res.message)
- this.$refs.table.refresh()
- this.spinning = false
- } else {
- this.$refs.table.refresh()
- this.spinning = false
- }
- })
- },
- pageInit () {
- const _this = this
- this.$nextTick(() => { // 页面渲染完成后的回调
- _this.setTableH()
- })
- },
- setTableH () {
- const tableSearchH = this.$refs.tableSearch.offsetHeight
- this.tableHeight = window.innerHeight - tableSearchH - 235
- }
- },
- mounted () {
- if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
- this.pageInit()
- this.reset()
- }
- },
- activated () {
- // 如果是新页签打开,则重置当前页面
- if (this.$store.state.app.isNewTab) {
- this.pageInit()
- this.reset()
- }
- }
- }
- </script>
|