|
@@ -1,34 +1,48 @@
|
|
<template>
|
|
<template>
|
|
<div class="house-list">
|
|
<div class="house-list">
|
|
<tables
|
|
<tables
|
|
|
|
+ :buttonList="buttonList"
|
|
:data-api="dataApi"
|
|
:data-api="dataApi"
|
|
|
|
+ :deleteApi="toDel"
|
|
:columns="columns"
|
|
:columns="columns"
|
|
@toEdit="toEdit"
|
|
@toEdit="toEdit"
|
|
|
|
+ @create="authShow = true"
|
|
placeholder="账号名称"
|
|
placeholder="账号名称"
|
|
ref="table"
|
|
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 />
|
|
|
|
|
|
+
|
|
|
|
+ <CModal :show="show" title="讲解员信息" :width="420" @submit="updateUser" @close="closeModal">
|
|
|
|
+ <Form :label-width="100">
|
|
|
|
+ <FormItem label="讲解员ID">
|
|
|
|
+ <p>{{form.viewerId}}</p>
|
|
|
|
+ </FormItem>
|
|
|
|
+ <FormItem label="讲解员名称">
|
|
|
|
+ <Input size="large" v-model="form.name" />
|
|
</FormItem>
|
|
</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 label="公司名称">
|
|
|
|
+ <Input size="large" v-model="form.companyName" />
|
|
</FormItem>
|
|
</FormItem>
|
|
<FormItem label="手机号码">
|
|
<FormItem label="手机号码">
|
|
- <Input size="large" v-model="form.phone" disabled />
|
|
|
|
|
|
+ <Input size="large" v-model="form.phoneNum" />
|
|
|
|
+ </FormItem>
|
|
|
|
+ <FormItem label="头像">
|
|
|
|
+ <picUpload class="pic-upload" tips="只能上传jpg/png文件,且不超过500kb" ref="post-upload" :limit="1" :multiple="false" :preUploads="postPreUploads" :hasUploads="postHasUploads" />
|
|
</FormItem>
|
|
</FormItem>
|
|
</Form>
|
|
</Form>
|
|
</CModal>
|
|
</CModal>
|
|
|
|
+
|
|
|
|
+ <CModal :show="authShow" title="新增讲解员" :width="640" @submit="authSubmit" @close="authClose">
|
|
|
|
+ <UserList @selected="s => selectViews = s" />
|
|
|
|
+ </CModal>
|
|
|
|
+
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
|
+import picUpload from '@/components/upload'
|
|
|
|
+import UserList from './userList'
|
|
import tables from 'components/tables'
|
|
import tables from 'components/tables'
|
|
-import { fetchUserList, updateUser, fetchRoleList } from 'api/'
|
|
|
|
|
|
+import { fetchGuidList, updateGuide, updateViewerToGuide } from 'api/'
|
|
import CModal from 'components/Modal'
|
|
import CModal from 'components/Modal'
|
|
|
|
|
|
const roleMap = {
|
|
const roleMap = {
|
|
@@ -39,10 +53,19 @@ const roleMap = {
|
|
export default {
|
|
export default {
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
|
|
+ postPreUploads: [],
|
|
|
|
+ postHasUploads: [],
|
|
|
|
+ buttonList: [
|
|
|
|
+ {
|
|
|
|
+ text: '新增',
|
|
|
|
+ handle: 'create'
|
|
|
|
+ }
|
|
|
|
+ ],
|
|
|
|
+ authShow: false,
|
|
show: false,
|
|
show: false,
|
|
form: {},
|
|
form: {},
|
|
// 传递给tables的表格列数据
|
|
// 传递给tables的表格列数据
|
|
- dataApi: fetchUserList,
|
|
|
|
|
|
+ dataApi: fetchGuidList,
|
|
roleList: [],
|
|
roleList: [],
|
|
columns: [
|
|
columns: [
|
|
{
|
|
{
|
|
@@ -52,49 +75,37 @@ export default {
|
|
width: 80
|
|
width: 80
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- title: '账号ID',
|
|
|
|
- key: 'admin_id',
|
|
|
|
- align: 'center'
|
|
|
|
|
|
+ title: '头像',
|
|
|
|
+ key: 'avatar',
|
|
|
|
+ align: 'center',
|
|
|
|
+ render: (h, params) => {
|
|
|
|
+ return h('img', {
|
|
|
|
+ domProps: {
|
|
|
|
+ src: params.row.avatar,
|
|
|
|
+ className: 'avatar'
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- title: '账号名称',
|
|
|
|
- key: 'name',
|
|
|
|
|
|
+ title: 'ID',
|
|
|
|
+ key: 'viewerId',
|
|
align: 'center'
|
|
align: 'center'
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- title: '角色',
|
|
|
|
- key: 'type',
|
|
|
|
- align: 'center',
|
|
|
|
- render: (h, params) => {
|
|
|
|
- return h('span', roleMap[params.row.type])
|
|
|
|
- }
|
|
|
|
|
|
+ title: '讲解员名称',
|
|
|
|
+ key: 'name',
|
|
|
|
+ align: 'center'
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- title: '联系方式',
|
|
|
|
- key: 'phone',
|
|
|
|
|
|
+ title: '公司名称',
|
|
|
|
+ key: 'companyName',
|
|
align: 'center'
|
|
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: 'phoneNum',
|
|
|
|
+ align: 'center'
|
|
},
|
|
},
|
|
{
|
|
{
|
|
title: '创建时间',
|
|
title: '创建时间',
|
|
@@ -104,37 +115,61 @@ export default {
|
|
{
|
|
{
|
|
title: '操作',
|
|
title: '操作',
|
|
slot: 'action',
|
|
slot: 'action',
|
|
- tools: ['edit' ],
|
|
|
|
|
|
+ tools: ['edit', 'del'],
|
|
align: 'center'
|
|
align: 'center'
|
|
}
|
|
}
|
|
],
|
|
],
|
|
|
|
+ selectViews: []
|
|
}
|
|
}
|
|
},
|
|
},
|
|
components: {
|
|
components: {
|
|
|
|
+ UserList,
|
|
|
|
+ picUpload,
|
|
tables,
|
|
tables,
|
|
CModal
|
|
CModal
|
|
},
|
|
},
|
|
mounted () {
|
|
mounted () {
|
|
- this.fetchRoleList()
|
|
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
- fetchRoleList () {
|
|
|
|
- fetchRoleList().then(res => {
|
|
|
|
- this.roleList = res.data
|
|
|
|
- })
|
|
|
|
|
|
+ authClose() {
|
|
|
|
+ this.selectViews = []
|
|
|
|
+ this.authShow = false
|
|
},
|
|
},
|
|
- async changeUser () {
|
|
|
|
- await updateUser(this.form)
|
|
|
|
|
|
+ async authSubmit() {
|
|
|
|
+ this.authShow = false
|
|
|
|
+ let ps = this.selectViews.map(id => updateViewerToGuide(id))
|
|
|
|
+
|
|
|
|
+ await Promise.all(ps)
|
|
|
|
+
|
|
|
|
+ this.$refs['table'].handleTableData()
|
|
|
|
+ },
|
|
|
|
+ async changeUser (msg = '修改成功') {
|
|
|
|
+ if (this.postPreUploads.length) {
|
|
|
|
+ let fs = await this.$refs['post-upload'].uploadfiles()
|
|
|
|
+ this.form.avatar = fs[0]
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ await updateGuide(this.form)
|
|
this.closeModal()
|
|
this.closeModal()
|
|
this.$Message.success({
|
|
this.$Message.success({
|
|
- content: '修改成功'
|
|
|
|
|
|
+ content: msg
|
|
})
|
|
})
|
|
|
|
+ },
|
|
|
|
+ async updateUser() {
|
|
|
|
+ await this.changeUser()
|
|
this.$refs['table'].handleTableData()
|
|
this.$refs['table'].handleTableData()
|
|
},
|
|
},
|
|
toEdit (row) {
|
|
toEdit (row) {
|
|
this.form = JSON.parse(JSON.stringify(row))
|
|
this.form = JSON.parse(JSON.stringify(row))
|
|
|
|
+ this.postHasUploads = [{img: this.form.avatar}]
|
|
this.show = true
|
|
this.show = true
|
|
},
|
|
},
|
|
|
|
+ toDel(row) {
|
|
|
|
+ this.toEdit(row[0])
|
|
|
|
+ this.show = false
|
|
|
|
+ this.enable = 0
|
|
|
|
+ this.changeUser('删除成功')
|
|
|
|
+ },
|
|
closeModal () {
|
|
closeModal () {
|
|
this.show = false
|
|
this.show = false
|
|
}
|
|
}
|
|
@@ -147,5 +182,16 @@ export default {
|
|
padding: 20px;
|
|
padding: 20px;
|
|
background: #252828;
|
|
background: #252828;
|
|
}
|
|
}
|
|
|
|
+</style>
|
|
|
|
+
|
|
|
|
+<style>
|
|
|
|
+.avatar {
|
|
|
|
+ width: 38px;
|
|
|
|
+ height: 38px;
|
|
|
|
+ border-radius: 50%;
|
|
|
|
+}
|
|
|
|
|
|
|
|
+.pic-upload .tips {
|
|
|
|
+ bottom: auto;
|
|
|
|
+}
|
|
</style>
|
|
</style>
|