Skip to content

Commit

Permalink
活动添加修改删除功能
Browse files Browse the repository at this point in the history
  • Loading branch information
dplcz committed Nov 3, 2022
1 parent 929c584 commit d75ef6b
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 59 deletions.
116 changes: 80 additions & 36 deletions components/ActTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
type="danger"
icon="el-icon-delete"
size="mini"
@click="deleteUser(scope.row.id)"
@click="deleteAct(scope.row.id)"
></el-button>
</template>
</el-table-column>
Expand Down Expand Up @@ -143,7 +143,7 @@
</el-dialog>

<el-dialog
title="修改用户信息"
title="修改活动信息"
:visible.sync="editDialogVisible"
@close="editDialogClosed"
>
Expand All @@ -152,19 +152,31 @@
:model="editForm"
:rules="editFromRules"
ref="editFormRef"

>
<el-form-item label="用户名" prop="username">
<el-input
v-model="editForm.username"
autocomplete="off"
disabled
></el-input>
<el-form-item label="第一标题" prop="first_title">
<el-input v-model="editForm.first_title" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="第二标题" prop="second_title">
<el-input v-model="editForm.second_title" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="活动图片" prop="img_url">
<el-input v-model="editForm.img_url" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="活动小图" prop="resize_img_url">
<el-input v-model="editForm.resize_img_url" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="活动时间" prop="time">
<el-input v-model="editForm.time" autocomplete="off" type="date"></el-input>
</el-form-item>
<el-form-item label="密码" prop="password">
<el-input v-model="editForm.password" autocomplete="off"></el-input>
<el-form-item label="活动详情id" prop="detail_page_id">
<el-input v-model="editForm.detail_page_id" autocomplete="off" type="number"></el-input>
</el-form-item>
<el-form-item label="邮箱" prop="email">
<el-input v-model="editForm.email" autocomplete="off"></el-input>
<el-form-item label="活动详情url" prop="detail_page_url">
<el-input v-model="editForm.detail_page_url" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="活动类型" prop="type">
<el-input v-model="editForm.type" autocomplete="off" type="number"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
Expand Down Expand Up @@ -208,6 +220,7 @@ export default {
userList: [],
total: 0,
currentPage: 1,
currentActId: null,
addDialogVisible: false,
editDialogVisible: false,
addForm: {
Expand Down Expand Up @@ -259,29 +272,52 @@ export default {
],
},
editForm: {
username: "",
password: "",
email: "",
first_title: null,
second_title: null,
img_url: null,
resize_img_url: null,
time: null,
detail_page_id: null,
detail_page_url: null,
type: 0,
},
editFromRules: {
password: [
{required: true, message: "请输入密码", trigger: "blur"},
first_title: [
{required: true, message: "请输入第一标题", trigger: "blur"},
{
min: 6,
max: 10,
message: "长度在 610 个字符",
min: 4,
max: 12,
message: "长度在 412 个字符",
trigger: "blur",
},
],
email: [
{required: true, message: "请输入邮箱", trigger: "blur"},
second_title: [
{required: true, message: "请输入第二标题", trigger: "blur"},
{
min: 6,
max: 15,
message: "长度在 615 个字符",
min: 4,
max: 12,
message: "长度在 412 个字符",
trigger: "blur",
},
],
img_url: [
{required: false, message: "请输入图片地址", trigger: "blur"},
],
resize_img_url: [
{required: false, message: "请输入小图地址", trigger: "blur"},
],
time: [
{required: true, message: "请选择时间", trigger: "blur"},
],
detail_page_id: [
{required: false, message: "请输入详情页面id", trigger: "blur"},
],
detail_page_url: [
{required: false, message: "请输入详情页面网址", trigger: "blur"},
],
type: [
{required: false, message: "请输入活动类型(默认为0)", trigger: "blur"},
],
},
searchWord: ''
};
Expand Down Expand Up @@ -362,13 +398,13 @@ export default {
return this.$message.error("操作失败");
}
this.$message.success("操作成功");
this.tableData.append(this.addForm)
await this.getActivityList(this.currentPage)
this.addDialogVisible = false;
});
},
async deleteUser(id) {
async deleteAct(id) {
const confirmResult = await this.$confirm(
"此操作将永久删除用户,是否继续?",
"此操作将永久删除该活动,是否继续?",
"提示",
{
confirmButtonText: "确定",
Expand All @@ -379,26 +415,34 @@ export default {
if (confirmResult != "confirm") {
return this.$message.info("已取消删除");
}
const {data: res} = await this.$http.delete("deleteUser?id=" + id);
if (res != "success") {
return this.$message.error("操作失败");
}
const res = await this.$axios.delete("/man/delete/activity?del_id=" + id, {withCredentials: true}).catch((err) => {
this.$message.error("操作失败");
});
// if (res.status != 200) {
// return this.$message.error("操作失败");
// }
this.$message.success("操作成功");
await this.getActivityList(this.currentPage)
},
async showEditDialog(id) {
this.editDialogVisible = true;
this.currentActId = id
},
editDialogClosed() {
this.$refs.editFormRef.resetFields();
},
editUser() {
this.$refs.editFormRef.validate(async (valid) => {
async editUser() {
await this.$refs.editFormRef.validate(async (valid) => {
if (!valid) return;
const {data: res} = await this.$http.post("edituser", this.editForm);
if (res != "success") {
const res = await this.$axios.post("/man/update/activity?act_id=" + this.currentActId, this.editForm, {withCredentials: true}).catch((err) => {
this.$message.error("操作失败")
});
if (res.status != 200) {
return this.$message.error("操作失败");
}
this.$message.success("操作成功");
await this.getActivityList(this.currentPage)
this.editDialogVisible = false;
});
},
Expand Down
50 changes: 28 additions & 22 deletions nuxt.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

export default {
mode: 'universal',
/*
Expand All @@ -7,32 +6,40 @@ export default {
head: {
title: process.env.npm_package_name || '',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: process.env.npm_package_description || '' }
{charset: 'utf-8'},
{name: 'viewport', content: 'width=device-width, initial-scale=1'},
{hid: 'description', name: 'description', content: process.env.npm_package_description || ''}
],
link: [
{ rel: 'shortcut icon', sizes: '32*32', type: 'image/ico', href: 'https://hxm-1314321198.cos.ap-nanjing.myqcloud.com/bitbug_favicon.ico' },
{ rel: "stylesheet", href: "https://fonts.googleapis.com/css2?family=Oswald:wght@300;400;500;600;700&display=swap" },
{ rel: "stylesheet", href: "/assets/css/bootstrap.min.css" },
{ rel: "stylesheet", href: "/assets/css/animate.min.css" },
{ rel: "stylesheet", href: "/assets/css/font-awesome.min.css" },
{ rel: "stylesheet", href: "/assets/plugins/glightbox/glightbox.min.css" },
{ rel: "stylesheet", href: "/assets/css/fontawesome-all.min.css" },
{ rel: "stylesheet", href: "/assets/css/flaticon.css" },
{ rel: "stylesheet", href: "/assets/css/default.css" },
{ rel: "stylesheet", href: "/assets/css/style.css" }
{
rel: 'shortcut icon',
sizes: '32*32',
type: 'image/ico',
href: 'https://hxm-1314321198.cos.ap-nanjing.myqcloud.com/bitbug_favicon.ico'
},
{
rel: "stylesheet",
href: "https://fonts.googleapis.com/css2?family=Oswald:wght@300;400;500;600;700&display=swap"
},
{rel: "stylesheet", href: "/assets/css/bootstrap.min.css"},
{rel: "stylesheet", href: "/assets/css/animate.min.css"},
{rel: "stylesheet", href: "/assets/css/font-awesome.min.css"},
{rel: "stylesheet", href: "/assets/plugins/glightbox/glightbox.min.css"},
{rel: "stylesheet", href: "/assets/css/fontawesome-all.min.css"},
{rel: "stylesheet", href: "/assets/css/flaticon.css"},
{rel: "stylesheet", href: "/assets/css/default.css"},
{rel: "stylesheet", href: "/assets/css/style.css"}
],

script: [
{ src: "/assets/plugins/glightbox/glightbox.min.js", body: true },
{ src: "/assets/plugins/accordion/accordion.min.js", body: true }
{src: "/assets/plugins/glightbox/glightbox.min.js", body: true},
{src: "/assets/plugins/accordion/accordion.min.js", body: true}
]
},
/*
** Customize the progress-bar color
*/
loading: { color: '#ff5316', height: '4px' },
loading: {color: '#ff5316', height: '4px'},
/*
** Global CSS
*/
Expand All @@ -42,26 +49,25 @@ export default {
** Plugins to load before mounting the App
*/
plugins: [
{ src: 'plugins/owl.js', ssr: false },
{src: 'plugins/owl.js', ssr: false},
{
src: 'plugins/element-ui',
ssr: true, // 不支持 ssr 渲染的只会在客户端运行,不用给 true
// mode: 'server' // client v2.4+ 版本 用 mode: 'server' 代替了 ssr
}
}
],
/*
** Nuxt.js dev-modules
*/
buildModules: [
],
buildModules: [],
/*
** Nuxt.js modules
*/
modules: [
'@nuxtjs/axios'
],
axios: {
baseURL: "http://124.221.228.222:9801",
baseURL: "http://124.221.228.222:9801"
// withCredentials: true
},
publicRuntimeConfig: {
Expand Down
2 changes: 1 addition & 1 deletion pages/man-index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default {
methods: {
change(nu) {
this.index = nu;
console.log(this.index);
// console.log(this.index);
},
async judgeLogin() {
const response = await this.$axios
Expand Down

0 comments on commit d75ef6b

Please sign in to comment.