added ESlint 语法检测
This commit is contained in:
@@ -1,40 +1,40 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="button-box clearflex">
|
||||
<el-button @click="addUser" type="primary">新增用户</el-button>
|
||||
<el-button type="primary" @click="addUser">新增用户</el-button>
|
||||
</div>
|
||||
<el-table :data="tableData" border stripe>
|
||||
<el-table-column label="头像" min-width="50">
|
||||
<template slot-scope="scope">
|
||||
<div :style="{'textAlign':'center'}">
|
||||
<CustomPic :picSrc="scope.row.headerImg" />
|
||||
<CustomPic :pic-src="scope.row.headerImg" />
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="uuid" min-width="250" prop="uuid"></el-table-column>
|
||||
<el-table-column label="用户名" min-width="150" prop="userName"></el-table-column>
|
||||
<el-table-column label="昵称" min-width="150" prop="nickName"></el-table-column>
|
||||
<el-table-column label="uuid" min-width="250" prop="uuid" />
|
||||
<el-table-column label="用户名" min-width="150" prop="userName" />
|
||||
<el-table-column label="昵称" min-width="150" prop="nickName" />
|
||||
<el-table-column label="用户角色" min-width="150">
|
||||
<template slot-scope="scope">
|
||||
<el-cascader
|
||||
@change="changeAuthority(scope.row)"
|
||||
v-model="scope.row.authority.authorityId"
|
||||
:options="authOptions"
|
||||
:show-all-levels="false"
|
||||
:props="{ checkStrictly: true,label:'authorityName',value:'authorityId',disabled:'disabled',emitPath:false}"
|
||||
filterable
|
||||
></el-cascader>
|
||||
@change="changeAuthority(scope.row)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" min-width="150">
|
||||
<template slot-scope="scope">
|
||||
<el-popover placement="top" width="160" v-model="scope.row.visible">
|
||||
<el-popover v-model="scope.row.visible" placement="top" width="160">
|
||||
<p>确定要删除此用户吗</p>
|
||||
<div style="text-align: right; margin: 0">
|
||||
<el-button size="mini" type="text" @click="scope.row.visible = false">取消</el-button>
|
||||
<el-button type="primary" size="mini" @click="deleteUser(scope.row)">确定</el-button>
|
||||
</div>
|
||||
<el-button type="danger" icon="el-icon-delete" size="small" slot="reference">删除</el-button>
|
||||
<el-button slot="reference" type="danger" icon="el-icon-delete" size="small">删除</el-button>
|
||||
</el-popover>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -45,25 +45,25 @@
|
||||
:page-sizes="[10, 30, 50, 100]"
|
||||
:style="{float:'right',padding:'20px'}"
|
||||
:total="total"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@current-change="handleCurrentChange"
|
||||
@size-change="handleSizeChange"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
></el-pagination>
|
||||
/>
|
||||
|
||||
<el-dialog :visible.sync="addUserDialog" custom-class="user-dialog" title="新增用户">
|
||||
<el-form :rules="rules" ref="userForm" :model="userInfo">
|
||||
<el-form ref="userForm" :rules="rules" :model="userInfo">
|
||||
<el-form-item label="用户名" label-width="80px" prop="username">
|
||||
<el-input v-model="userInfo.username"></el-input>
|
||||
<el-input v-model="userInfo.username" />
|
||||
</el-form-item>
|
||||
<el-form-item label="密码" label-width="80px" prop="password">
|
||||
<el-input v-model="userInfo.password"></el-input>
|
||||
<el-input v-model="userInfo.password" />
|
||||
</el-form-item>
|
||||
<el-form-item label="别名" label-width="80px" prop="nickName">
|
||||
<el-input v-model="userInfo.nickName"></el-input>
|
||||
<el-input v-model="userInfo.nickName" />
|
||||
</el-form-item>
|
||||
<el-form-item label="头像" label-width="80px">
|
||||
<div style="display:inline-block" @click="openHeaderChange">
|
||||
<img class="header-img-box" v-if="userInfo.headerImg" :src="userInfo.headerImg" />
|
||||
<img v-if="userInfo.headerImg" class="header-img-box" :src="userInfo.headerImg">
|
||||
<div v-else class="header-img-box">从媒体库选择</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
@@ -74,37 +74,36 @@
|
||||
:show-all-levels="false"
|
||||
:props="{ checkStrictly: true,label:'authorityName',value:'authorityId',disabled:'disabled',emitPath:false}"
|
||||
filterable
|
||||
></el-cascader>
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="dialog-footer" slot="footer">
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="closeAddUserDialog">取 消</el-button>
|
||||
<el-button @click="enterAddUserDialog" type="primary">确 定</el-button>
|
||||
<el-button type="primary" @click="enterAddUserDialog">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<ChooseImg ref="chooseImg" :target="userInfo" :targetKey="`headerImg`"/>
|
||||
<ChooseImg ref="chooseImg" :target="userInfo" :target-key="`headerImg`" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
<script>
|
||||
// 获取列表内容封装在mixins内部 getTableData方法 初始化已封装完成
|
||||
const path = process.env.VUE_APP_BASE_API;
|
||||
const path = process.env.VUE_APP_BASE_API
|
||||
import {
|
||||
getUserList,
|
||||
setUserAuthority,
|
||||
register,
|
||||
deleteUser
|
||||
} from "@/api/user";
|
||||
import { getAuthorityList } from "@/api/authority";
|
||||
import infoList from "@/mixins/infoList";
|
||||
import { mapGetters } from "vuex";
|
||||
import CustomPic from "@/components/customPic";
|
||||
import ChooseImg from "@/components/chooseImg";
|
||||
} from '@/api/user'
|
||||
import { getAuthorityList } from '@/api/authority'
|
||||
import infoList from '@/mixins/infoList'
|
||||
import { mapGetters } from 'vuex'
|
||||
import CustomPic from '@/components/customPic'
|
||||
import ChooseImg from '@/components/chooseImg'
|
||||
export default {
|
||||
name: "Api",
|
||||
name: 'Api',
|
||||
components: { CustomPic, ChooseImg },
|
||||
mixins: [infoList],
|
||||
components: { CustomPic,ChooseImg },
|
||||
data() {
|
||||
return {
|
||||
listApi: getUserList,
|
||||
@@ -112,40 +111,45 @@ export default {
|
||||
authOptions: [],
|
||||
addUserDialog: false,
|
||||
userInfo: {
|
||||
username: "",
|
||||
password: "",
|
||||
nickName: "",
|
||||
headerImg: "",
|
||||
authorityId: ""
|
||||
username: '',
|
||||
password: '',
|
||||
nickName: '',
|
||||
headerImg: '',
|
||||
authorityId: ''
|
||||
},
|
||||
rules: {
|
||||
username: [
|
||||
{ required: true, message: "请输入用户名", trigger: "blur" },
|
||||
{ min: 5, message: "最低5位字符", trigger: "blur" }
|
||||
{ required: true, message: '请输入用户名', trigger: 'blur' },
|
||||
{ min: 5, message: '最低5位字符', trigger: 'blur' }
|
||||
],
|
||||
password: [
|
||||
{ required: true, message: "请输入用户密码", trigger: "blur" },
|
||||
{ min: 6, message: "最低6位字符", trigger: "blur" }
|
||||
{ required: true, message: '请输入用户密码', trigger: 'blur' },
|
||||
{ min: 6, message: '最低6位字符', trigger: 'blur' }
|
||||
],
|
||||
nickName: [
|
||||
{ required: true, message: "请输入用户昵称", trigger: "blur" }
|
||||
{ required: true, message: '请输入用户昵称', trigger: 'blur' }
|
||||
],
|
||||
authorityId: [
|
||||
{ required: true, message: "请选择用户角色", trigger: "blur" }
|
||||
{ required: true, message: '请选择用户角色', trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters("user", ["token"])
|
||||
...mapGetters('user', ['token'])
|
||||
},
|
||||
async created() {
|
||||
this.getTableData()
|
||||
const res = await getAuthorityList({ page: 1, pageSize: 999 })
|
||||
this.setOptions(res.data.list)
|
||||
},
|
||||
methods: {
|
||||
openHeaderChange(){
|
||||
openHeaderChange() {
|
||||
this.$refs.chooseImg.open()
|
||||
},
|
||||
setOptions(authData) {
|
||||
this.authOptions = [];
|
||||
this.setAuthorityOptions(authData, this.authOptions);
|
||||
this.authOptions = []
|
||||
this.setAuthorityOptions(authData, this.authOptions)
|
||||
},
|
||||
setAuthorityOptions(AuthorityData, optionsData) {
|
||||
AuthorityData &&
|
||||
@@ -155,66 +159,61 @@ export default {
|
||||
authorityId: item.authorityId,
|
||||
authorityName: item.authorityName,
|
||||
children: []
|
||||
};
|
||||
this.setAuthorityOptions(item.children, option.children);
|
||||
optionsData.push(option);
|
||||
}
|
||||
this.setAuthorityOptions(item.children, option.children)
|
||||
optionsData.push(option)
|
||||
} else {
|
||||
const option = {
|
||||
authorityId: item.authorityId,
|
||||
authorityName: item.authorityName
|
||||
};
|
||||
optionsData.push(option);
|
||||
}
|
||||
optionsData.push(option)
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
async deleteUser(row) {
|
||||
const res = await deleteUser({ id: row.ID });
|
||||
if (res.code == 0) {
|
||||
this.getTableData();
|
||||
row.visible = false;
|
||||
const res = await deleteUser({ id: row.ID })
|
||||
if (res.code === 0) {
|
||||
this.getTableData()
|
||||
row.visible = false
|
||||
}
|
||||
},
|
||||
async enterAddUserDialog() {
|
||||
this.$refs.userForm.validate(async valid => {
|
||||
if (valid) {
|
||||
const res = await register(this.userInfo);
|
||||
if (res.code == 0) {
|
||||
this.$message({ type: "success", message: "创建成功" });
|
||||
const res = await register(this.userInfo)
|
||||
if (res.code === 0) {
|
||||
this.$message({ type: 'success', message: '创建成功' })
|
||||
}
|
||||
await this.getTableData();
|
||||
this.closeAddUserDialog();
|
||||
await this.getTableData()
|
||||
this.closeAddUserDialog()
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
closeAddUserDialog() {
|
||||
this.$refs.userForm.resetFields();
|
||||
this.addUserDialog = false;
|
||||
this.$refs.userForm.resetFields()
|
||||
this.addUserDialog = false
|
||||
},
|
||||
handleAvatarSuccess(res) {
|
||||
this.userInfo.headerImg = res.data.file.url;
|
||||
this.userInfo.headerImg = res.data.file.url
|
||||
},
|
||||
addUser() {
|
||||
this.addUserDialog = true;
|
||||
this.addUserDialog = true
|
||||
},
|
||||
async changeAuthority(row) {
|
||||
const res = await setUserAuthority({
|
||||
uuid: row.uuid,
|
||||
authorityId: row.authority.authorityId
|
||||
});
|
||||
if (res.code == 0) {
|
||||
this.$message({ type: "success", message: "角色设置成功" });
|
||||
})
|
||||
if (res.code === 0) {
|
||||
this.$message({ type: 'success', message: '角色设置成功' })
|
||||
}
|
||||
}
|
||||
},
|
||||
async created() {
|
||||
this.getTableData();
|
||||
const res = await getAuthorityList({ page: 1, pageSize: 999 });
|
||||
this.setOptions(res.data.list);
|
||||
}
|
||||
};
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
|
||||
<style lang="scss">
|
||||
.button-box {
|
||||
padding: 10px 20px;
|
||||
.el-button {
|
||||
@@ -251,4 +250,4 @@ export default {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user