Commit a3917a65 by baihong

add:管理员增删改查

parent 1ce24c12
......@@ -60,4 +60,20 @@ export const getActivityConfigByPay = (data) => {
}
export const delGroups = (id) => {
return $http.delete('/cms/groups/'+id)
}
//管理员列表
export const admins = (data) => {
return $http.get('/cms/admins', data)
}
export const addAdmins = (data) => {
return $http.postObj('/cms/admins', data)
}
export const updateAdmins = (id,data) => {
return $http.putObj('/cms/admins/'+id, data)
}
export const adminsDe = (data) => {
return $http.get('/cms/admins/'+data)
}
export const delAdmins = (id) => {
return $http.delete('/cms/admins/'+id)
}
\ No newline at end of file
......@@ -13,165 +13,130 @@
placeholder="请输入"
></Input>
</FormItem>
<FormItem label="联系方式" prop="name">
<FormItem label="联系方式" prop="mobile">
<Input
style="width:60%"
v-model="formValidate.name"
v-model="formValidate.mobile"
placeholder="请输入"
></Input>
</FormItem>
<FormItem label="管理员账号" prop="name">
<FormItem label="管理员账号" prop="account">
<Input
style="width:60%"
v-model="formValidate.name"
v-model="formValidate.account"
placeholder="请输入"
></Input>
</FormItem>
<FormItem label="密码" prop="name">
<FormItem label="密码" prop="password">
<Input
style="width:60%"
v-model="formValidate.name"
v-model="formValidate.password"
placeholder="请输入"
></Input>
</FormItem>
<FormItem label="权限信息" prop="name">
<Tree :data="data4" show-checkbox multiple></Tree>
<FormItem label="管理员身份" prop="group_uuid">
<Select v-model="formValidate.group_uuid" style="width: 150px" placeholder="请选择">
<Option v-for="i in groupsList" :key="i.uuid" :value="i.uuid">{{
i.name
}}</Option>
</Select>
</FormItem>
</Form>
<div class="btn">
<Button type="primary" @click="$router.go(-1)">确定</Button>
<div class="btn">
<Button type="primary" @click="handleSubmit('formValidate')">确定</Button>
</div>
</div>
</template>
<script>
import {
groups,
addAdmins,
updateAdmins,
adminsDe
} from "@/api/clock/activityClocks";
export default {
data() {
return {
data4: [
{
title: "parent 1",
expand: true,
selected: true,
children: [
{
title: "parent 1-1",
expand: true,
children: [
{
title: "leaf 1-1-1",
disabled: true
},
{
title: "leaf 1-1-2"
}
]
},
{
title: "parent 1-2",
expand: true,
children: [
{
title: "leaf 1-2-1",
checked: true
},
{
title: "leaf 1-2-1"
}
]
}
]
}
],
groupsList: [],
formValidate: {
name: "",
mail: "",
city: "",
gender: "",
interest: [],
date: "",
time: "",
desc: ""
mobile: "",
account: "",
password: "",
group_uuid: ""
},
ruleValidate: {
name: [
{
required: true,
message: "The name cannot be empty",
message: "请输入管理员姓名",
trigger: "blur"
}
],
mail: [
mobile: [
{
required: true,
message: "Mailbox cannot be empty",
message: "请输入联系方式",
trigger: "blur"
},
{ type: "email", message: "Incorrect email format", trigger: "blur" }
],
city: [
{
required: true,
message: "Please select the city",
trigger: "change"
}
],
gender: [
{ required: true, message: "Please select gender", trigger: "change" }
],
interest: [
account: [
{
required: true,
type: "array",
min: 1,
message: "Choose at least one hobby",
trigger: "change"
},
{
type: "array",
max: 2,
message: "Choose two hobbies at best",
trigger: "change"
message: "请输入管理员账号",
trigger: "blur"
}
],
date: [
password: [
{
required: true,
type: "date",
message: "Please select the date",
trigger: "change"
message: "请输入密码",
trigger: "blur"
}
],
time: [
group_uuid: [
{
required: true,
type: "string",
message: "Please select time",
message: "请选择管理员身份",
trigger: "change"
}
],
desc: [
{
required: true,
message: "Please enter a personal introduction",
trigger: "blur"
},
{
type: "string",
min: 20,
message: "Introduce no less than 20 words",
trigger: "blur"
}
]
}
};
},
mounted() {
this.search();
if (this.$route.query.id) {
adminsDe(this.$route.query.id).then(res => {
this.formValidate = Object.assign(this.formValidate, res);
});
}
},
methods: {
search() {
let params = {
language: "cn",
page_index: 1,
page_size: 100
};
groups(params).then(res => {
this.groupsList = res.data;
});
},
handleSubmit(name) {
this.$refs[name].validate(valid => {
if (valid) {
this.$Message.success("Success!");
} else {
this.$Message.error("Fail!");
if (this.$route.query.id) {
updateAdmins(this.$route.query.id, this.formValidate).then(res => {
this.$Message.success("编辑成功!");
this.$router.push({ path: "/admin/list"});
});
} else {
addAdmins(this.formValidate).then(res => {
this.$Message.success("新增成功!");
this.$router.push({ path: "/admin/list"});
});
}
}
});
},
......
......@@ -4,84 +4,106 @@
<div class="left">
管理员搜索:
<Input
v-model="keyword"
style="width:200px"
enter-button
placeholder="请输入"
/>
<Button type="primary" @click="goDetail">查 询</Button>
<Button type="primary" ghost>重 置</Button>
<Button type="primary" @click="goAdd">新增管理员</Button>
<Button type="primary" @click="goDetail">查 询</Button>
<Button type="primary" ghost>重 置</Button>
<Button type="primary" @click="goAdd">新增管理员</Button>
</div>
</div>
<Table :loading="$store.state.app.isLoading" border ref="selection" :columns="columns" :data="data">
<template slot-scope="{ row }" slot="name">
<span>{{ row.details.name }}</span>
</template>
<template slot-scope="{ row }" slot="title">
<span>{{ row.details.title }}</span>
</template>
<template slot-scope="{ row }" slot="created_at">
<span>{{ row.created_at | format}}</span>
</template>
<template slot-scope="{ row }" slot="enable">
<i-switch
:value="row.is_enable === 1 ? true : false"
@on-change="
value => {
change(value, row);
}
"
/>
</template>
<Table
:loading="$store.state.app.isLoading"
border
ref="selection"
:columns="columns"
:data="data"
>
<template slot-scope="{ row }" slot="action">
<a @click="edit(row)">编辑</a>
</template>
<template slot-scope="{ row }" slot="edit">
<a @click="goTheme(row)">编辑</a>
<a style="margin-left:10px" @click="del(row.uuid)">删除</a>
</template>
</Table>
<Pager
class="margin-top-10"
:config="config"
@on-change="handlePager"
></Pager>
</div>
</template>
<script>
import { getScenes, delScenes, editScenes } from '@/api/scenes'
import { admins, delAdmins } from "@/api/clock/activityClocks";
import Pager from "@/view/common/Pager.vue";
export default {
name: 'categories',
name: "categories",
components: {
Pager
},
data () {
data() {
return {
keyword: "",
config: { total: 0, size: 10, current: 1 },
pageIndex: 1,
pageSize: 10,
data: [],
columns: [
{
title: '管理员姓名',
key: 'created_at'
title: "管理员姓名",
key: "name"
},
{
title: '联系方式',
slot: 'name'
title: "联系方式",
key: "mobile"
},
{
title: '管理员账号',
slot: 'title'
title: "管理员账号",
key: "account"
},
{
title: '操作',
slot: 'action'
title: "操作",
slot: "action"
}
]
}
};
},
methods: {
goAdd () {
this.$router.push({ path: '/admin/add', query: { id: 'new' } })
search() {
let params = {
keyword: this.keyword,
language: "cn",
page_index: this.pageIndex,
page_size: this.pageSize
};
admins(params).then(res => {
this.config.total = res.total;
this.data = res.data;
});
},
handlePager(pager) {
this.pageIndex = pager.current;
this.pageSize = pager.size;
this.search();
},
del(id) {
delAdmins(id).then(res => {
this.$Message.success("删除成功");
this.search();
});
},
edit(p) {
this.$router.push({ path: "/admin/add", query: { id: p.uuid } });
},
goAdd() {
this.$router.push({ path: "/admin/add" });
}
},
mounted () {
mounted() {
this.search();
}
}
};
</script>
<style lang="less"></style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment