123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341 |
- <template>
- <a-card :bordered="false">
- <div class="table-page-search-wrapper">
- <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
- <a-row :gutter="48">
- <a-col :md="6" :sm="24">
- <a-form-item label="用户名称" :label-col="{ span: 3 }" :wrapper-col="{ span: 12 }">
- <a-input
- allowClear
- v-model.trim="queryParam.name"
- placeholder="请输入用户名称"
- id="userList-name"
- :maxLength="30"
- />
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="手机号码" :label-col="{ span: 3 }" :wrapper-col="{ span: 12 }">
- <a-input
- allowClear
- v-model.trim="queryParam.phone"
- placeholder="请输入手机号码"
- :maxLength="11"
- id="userList-phone"
- />
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="合作商" :label-col="{ span:3 }" :wrapper-col="{ span:12}">
- <a-select
- placeholder="请选择"
- allowClear
- v-model="queryParam.orgCode"
- :showSearch="true"
- option-filter-prop="children"
- :filter-option="filterOption"
- @focus="handleFocus"
- @blur="handleBlur"
- @change="handleChange">
- <a-select-option v-for="item in optionData" :key="item.orgCode" :value="item.orgCode">{{ item.name }}</a-select-option>
- </a-select>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-button type="primary" @click="$refs.table.refresh(true)" id="userList-handSubmit" style="margin-right: 10px;">查询</a-button>
- <a-button type="" @click="reset" id="userList-reset">重置</a-button>
- </a-col>
- </a-row>
- <a-row :gutter="48" style="margin-top: 25px;">
- <a-col :md="6" :sm="24">
- <a-form-item label="用户状态" >
- <v-select code="ENABLE_FLAG" v-model="queryParam.loginFlag" allowClear placeholder="请选择状态" id="userList-check-enable-state"></v-select>
- </a-form-item>
- </a-col>
- </a-row>
- </a-form>
- </div>
- <a-divider />
- <div class="table-operator">
- <a-button type="primary" icon="plus" @click="openModal" id="userList-openModal">新增</a-button>
- </div>
- <s-table
- ref="table"
- size="default"
- rowKey="id"
- :columns="columns"
- :data="loadData"
- bordered>
- <span slot="status" slot-scope="text, record">
- <a-switch
- checkedChildren="启用"
- unCheckedChildren="禁用"
- v-model="record.loginFlag"
- @change="changeFlagHandle(text, record)"
- id="userList-changeFlagHandle" />
- </span>
- <span slot="action" slot-scope="text, record">
- <a-icon
- type="unlock"
- title="重置密码"
- v-if="record.loginFlag==1"
- class="actionBtn icon-orange"
- @click="resetPassword(record)" />
- <a-icon
- type="edit"
- title="编辑"
- class="actionBtn icon-blues"
- @click="handleEdit(record)"
- />
- <a-icon
- type="delete"
- title="删除"
- class="actionBtn icon-red"
- v-if="record.loginFlag==0"
- @click="delect(record)"/>
- </span>
- </s-table>
- <userModal :visible="showModal" @refresh="$refs.table.refresh(true)" :itemId="itemId" @close="cancel"></userModal>
- </a-card>
- </template>
- <script>
- import {
- STable,
- VSelect
- } from '@/components'
- import userModal from './userModal.vue'
- import { sellerList, resetPSD, updateEnableStatus, getPowerUserList, delectUserPower } from '@/api/userManage.js'
- export default {
- name: 'UserManage',
- components: {
- STable,
- VSelect,
- userModal
- },
- data () {
- return {
- // 查询参数
- queryParam: {
- name: '',
- phone: '',
- loginFlag: '',
- orgCode: undefined
- },
- showModal: false,
- itemId: null, // 编辑行id
- optionData: [],
- // 表头
- columns: [{
- title: '序号',
- dataIndex: 'no',
- width: 60,
- align: 'center'
- },
- {
- title: '创建时间',
- dataIndex: 'createDate',
- width: 150,
- align: 'center'
- },
- {
- title: '用户名称',
- dataIndex: 'name',
- width: 100,
- align: 'center'
- },
- {
- title: '手机号码',
- dataIndex: 'phone',
- width: 100,
- align: 'center'
- },
- {
- title: '合作商',
- dataIndex: 'org.name',
- width: 100,
- align: 'center'
- },
- // {
- // title: '超级管理员',
- // width: '100',
- // align: 'center',
- // scopedSlots: {
- // customRender: 'status'
- // }
- // },
- // {
- // title: '角色',
- // width: '100',
- // align: 'center',
- // dataIndex: 'roleNames'
- // },
- {
- title: '状态',
- width: 100,
- align: 'center',
- scopedSlots: {
- customRender: 'status'
- }
- },
- {
- title: '操作',
- width: 100,
- align: 'center',
- scopedSlots: {
- customRender: 'action'
- }
- }
- ],
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- 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'
- }
- return res.data
- })
- }
- }
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {
- vm.getSellerList()
- })
- },
- methods: {
- handleChange (value) {
- console.log(`selected ${value}`)
- },
- handleBlur () {
- console.log('blur')
- },
- handleFocus () {
- console.log('focus')
- },
- filterOption (input, option) {
- return (
- option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
- )
- },
- cancel () {
- this.itemId = null
- this.showModal = false
- },
- // 获取合作商数据
- getSellerList () {
- sellerList().then(res => {
- console.log(res, '-----合作商')
- if (res.status == 200) {
- this.optionData = res.data || []
- }
- })
- },
- // 刷新列表
- refreshTable () {
- this.$refs.table.refresh(true)
- },
- // 新建
- openModal () {
- this.showModal = true
- this.itemData = {}
- },
- // 重置
- reset () {
- this.queryParam.name = ''
- this.queryParam.phone = '',
- this.queryParam.loginFlag = ''
- this.queryParam.orgCode = undefined
- this.refreshTable()
- },
- // 重置密码
- resetPassword (row) {
- resetPSD({
- id: row.id
- }).then(res => {
- if (res.status == 200) {
- this.$message.success(res.message)
- }
- })
- },
- // 删除
- delect (row) {
- const _this = this
- this.$confirm({
- title: '警告',
- centered: true,
- content: '删除后无法恢复,确认删除?',
- okText: '确定',
- cancelText: '取消',
- onOk () {
- delectUserPower({
- id: row.id
- }).then(res => {
- if (res.status == 200) {
- _this.$message.success(res.message)
- _this.$refs.table.refresh()
- }
- })
- }
- })
- },
- // getBizStr (storeBizList) {
- // const str = []
- // storeBizList.forEach(item => {
- // str.push(item.bizTypeName)
- // })
- // return str.join(',')
- // },
- handleEdit (row) {
- console.log(row, 'row')
- this.itemId = row.id
- this.showModal = true
- },
- // 修改状态
- changeFlagHandle (text, record) {
- const _data = {
- id: record.id,
- flag: record.loginFlag ? '1' : '0'
- }
- updateEnableStatus(_data).then(res => {
- if (res.status + '' === '200') {
- this.$message.success(res.message)
- } else {
- record.loginFlag = !record.loginFlag
- }
- })
- }
- }
- }
- </script>
- <style scoped>
- .table-page-search-wrapper .ant-form-inline .ant-form-item {
- margin-bottom: 0;
- }
- .action-button {
- line-height: 40px;
- white-space: nowrap;
- padding: 5px 10px;
- background-color: #1890ff;
- border-radius: 4px;
- color: #fff;
- margin-right: 5px;
- }
- .red-text {
- background-color: red;
- }
- .reset-text {
- background-color: #31b50b;
- }
- </style>
|