123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- <template>
- <div class="house-list">
- <tables
- :data-api="dataApi"
- :columns="columns"
- @toEdit="toEdit"
- placeholder="账号名称"
- ref="table"
- />
- <CModal :show="show" title="用户信息" :width="420" @submit="changeUser" @close="closeModal">
- <Form :label-width="75">
- <FormItem label="用户名称">
- <Input size="large" v-model="form.name" disabled />
- </FormItem>
- <FormItem label="用户角色">
- <Select v-model="form.type" size="large">
- <Option :value="-1">未分配</Option>
- <Option :value="item.roleType" v-for="item in roleList" :key="item.roleId">{{ item.remark }}</Option>
- </Select>
- </FormItem>
- <FormItem label="手机号码">
- <Input size="large" v-model="form.phone" disabled />
- </FormItem>
- </Form>
- </CModal>
- </div>
- </template>
- <script>
- import tables from 'components/tables'
- import { fetchUserList, updateUser, fetchRoleList } from 'api/'
- import CModal from 'components/Modal'
- const roleMap = {
- 0: '超级管理员',
- 1: '普通管理员',
- 2: '经纪人',
- }
- export default {
- data() {
- return {
- show: false,
- form: {},
- // 传递给tables的表格列数据
- dataApi: fetchUserList,
- roleList: [],
- columns: [
- {
- type: 'index',
- title: '序号',
- align: 'center',
- width: 80
- },
- {
- title: '账号ID',
- key: 'admin_id',
- align: 'center'
- },
- {
- title: '账号名称',
- key: 'name',
- align: 'center'
- },
- {
- title: '角色',
- key: 'type',
- align: 'center',
- render: (h, params) => {
- return h('span', roleMap[params.row.type])
- }
- },
- {
- title: '联系方式',
- key: 'phone',
- align: 'center'
- },
- {
- title: '启动状态',
- key: 'name',
- align: 'center',
- render: (h, params) => {
- return h('i-switch', {
- props: {
- trueValue: 1,
- falseValue: 0,
- value: params.row.enable,
- // disabled: params.row.roleKey === 'admin'
- },
- on: {
- 'on-change': (val) => {
- updateUser(Object.assign(params.row, {enable: val})).catch (err => {
- params.row.enable = !val ? 1 : 0
- })
- }
- }
- })
- }
- },
- {
- title: '创建时间',
- key: 'createTime',
- align: 'center'
- },
- {
- title: '操作',
- slot: 'action',
- tools: ['edit' ],
- align: 'center'
- }
- ],
- }
- },
- components: {
- tables,
- CModal
- },
- mounted () {
- this.fetchRoleList()
- },
- methods: {
- fetchRoleList () {
- fetchRoleList().then(res => {
- this.roleList = res.data
- })
- },
- async changeUser () {
- await updateUser(this.form)
- this.closeModal()
- this.$Message.success({
- content: '修改成功'
- })
- this.$refs['table'].handleTableData()
- },
- toEdit (row) {
- this.form = JSON.parse(JSON.stringify(row))
- this.show = true
- },
- closeModal () {
- this.show = false
- }
- }
- }
- </script>
- <style lang="less" scoped>
- .house-list {
- padding: 20px;
- background: #252828;
- }
- </style>
|