From 54ba3b8e337ba812b49ac521ca0354bd217b672c Mon Sep 17 00:00:00 2001
From: zhongrj <646384940@qq.com>
Date: Thu, 28 Dec 2023 18:34:49 +0800
Subject: [PATCH] 代码优化
---
src/views/article/publicSignUp.vue | 56 -------------
src/views/article/discussionManage.vue | 1
src/views/article/components/discussionManageChild.vue | 171 ++++++++++++++++++------------------------
3 files changed, 73 insertions(+), 155 deletions(-)
diff --git a/src/views/article/components/discussionManageChild.vue b/src/views/article/components/discussionManageChild.vue
index 7d94fe0..157e556 100644
--- a/src/views/article/components/discussionManageChild.vue
+++ b/src/views/article/components/discussionManageChild.vue
@@ -1,13 +1,21 @@
<template>
<basicContainer>
<avue-crud :data="data" ref="crud" :table-loading="loading" @current-change="currentChange"
- @search-change="searchChange" @search-reset="searchReset" @size-change="sizeChange" :option="option"
- v-model="data" @selection-change="selectionChange" @row-save="rowSave" @row-del="rowDel"
- @refresh-change="refreshChange">
+ :before-open="beforeOpen" @search-change="searchChange" @search-reset="searchReset" @size-change="sizeChange"
+ :option="option" v-model="form" @selection-change="selectionChange" @row-save="rowSave" @row-del="rowDel"
+ @row-update="rowUpdate" @refresh-change="refreshChange">
+ <template slot="menuLeft">
+ <el-button type="primary" size="small" icon="el-icon-plus" v-if="data.length <= 0"
+ @click="$refs.crud.rowAdd()">新增</el-button>
+ </template>
- <template slot-scope="scope" slot="menu">
- <el-button type="text" icon="el-icon-edit" size="small" @click.stop="openEdit(scope.row,scope.index)">编辑
+ <!-- <template slot="menuLeft">
+ <el-button size="small" icon="el-icon-delete" plain v-if="permission.article_delete" @click="handleDelete">删 除
</el-button>
+ </template> -->
+ <template slot-scope="scope" slot="menu">
+ <!-- <el-button type="text" icon="el-icon-edit" size="small" @click.stop="openEdit(scope.row,scope.index)">编辑
+ </el-button> -->
<el-button type="primary" icon="el-icon-edit" size="small" @click.stop="openDilog(scope.row,scope.index)">编辑议题
</el-button>
<el-button type="primary" icon="el-icon-edit" size="small" @click.stop="openUser(scope.row,0)">参与用户
@@ -15,7 +23,7 @@
</template>
</avue-crud>
- <el-dialog title="" append-to-body :visible.sync="dialogVisibles" width="60%" :before-close="handleClose">
+ <el-dialog title="" append-to-body :visible.sync="dialogVisibles" width="80%" :before-close="handleClose">
<span slot="title" class="dialog-footer">
{{ontitle}}
</span>
@@ -25,7 +33,7 @@
</avue-form>
</div>
- <div id="">
+ <div id="" v-if="!editFlag">
<avue-crud :option="optionList" :data="form" ref="crud" @row-update="rowUpdate" @row-del="rowDel">
<template slot="menuLeft" v-if="!editFlag">
<el-button type="primary" size="small" plain icon="el-icon-circle-plus-outline" @click="add()">添加
@@ -49,14 +57,11 @@
编辑议题
</span>
<div id="">
- <avue-form @submit="handleSubmitEdit" :option="optionDiscussEdit" v-model="discussForm"></avue-form>
+ <avue-form @submit="handleSubmitEdit" :option="option" v-model="discussForm"></avue-form>
</div>
</el-dialog>
<el-dialog title="" append-to-body :visible.sync="dialogVisiblesUser" width="50%" :before-close="userHandleClose">
- <!-- <span slot="title" class="dialog-footer">
- {{discussForm.ontitle}}
- </span> -->
<avue-crud :data="userData" :page="pageUser" :option="option1" @on-load="getUser"></avue-crud>
</el-dialog>
@@ -127,23 +132,7 @@
currentPage: 1,
total: 0
},
- discussForm: {
- title: '',
- openFlag: 0,
- numberRestrictions: 0,
- voteRestrictions: 0,
- userRestrictions: 0,
- endTime: '',
- articleId: '',
- createTime: '',
- updateTime: '',
- deleteFlag: '',
- repeatVote: 0,
- voteNumberPublic: 0,
- appointUser: '',
- userIds: '',
- eventType: 1,
- },
+ discussForm: {},
dialogVisiblesEdit: false,
dialogVisiblesUser: false,
editFlag: false,
@@ -217,59 +206,6 @@
},
]
},
- optionDiscussEdit: {
- column: [{
- label: "",
- type: 'title',
- prop: "title",
- span: 24,
- row: true,
- offset: 2,
- styles: {
- fontSize: '24px'
- }
- }, {
- labelWidth: 100,
- label: '开启投票',
- prop: 'openFlag',
- type: 'radio',
- button: true,
- row: true,
- offset: 6,
- dicData: [{
- label: '开启',
- value: 0
- }, {
- label: '不开启',
- value: 1
- }]
- }, {
- labelWidth: 100,
- label: '开启签名',
- prop: 'signatureFlag',
- type: 'radio',
- button: true,
- row: true,
- offset: 6,
- dicData: [{
- label: '开启',
- value: 0
- }, {
- label: '不开启',
- value: 1
- }]
- },
- {
- label: "截止时间",
- row: true,
- offset: 6,
- prop: "endTime",
- type: "datetime",
- format: "yyyy-MM-dd hh:mm:ss",
- valueFormat: "timestamp",
- },
- ]
- },
disCussFrom: {
discussContent: '',
optionRange: 0,
@@ -294,7 +230,6 @@
parentId: '',
level: '',
}]
-
},
ontitle: '编辑议题',
// 弹框标题
@@ -317,7 +252,25 @@
total: 0
},
// 表单数据
- form: [],
+ form: {
+ title: '',
+ openFlag: 0,
+ numberRestrictions: 0,
+ voteRestrictions: 0,
+ userRestrictions: 0,
+ endTime: '',
+ articleId: '',
+ createTime: '',
+ updateTime: '',
+ deleteFlag: '',
+ repeatVote: 0,
+ voteNumberPublic: 0,
+ appointUser: '',
+ userIds: '',
+ eventType: 1,
+ signatureFlag: 0,
+ appointUser: 0
+ },
// 选择行
selectionList: [],
// 表单配置
@@ -327,8 +280,8 @@
calcHeight: 54,
align: 'center',
menuAlign: 'center',
- // addBtn: false,
- editBtn: false,
+ addBtn: false,
+ // editBtn: false,
searchMenuSpan: 3,
// searchBtn: true,
menuWidth: 500,
@@ -343,7 +296,7 @@
label: '标题',
prop: 'title',
searchSpan: 4,
- disabled: true,
+ // disabled: true,
},
{
label: '参与人数',
@@ -356,6 +309,7 @@
prop: 'openFlag',
type: 'radio',
button: true,
+ value: 0,
dicData: [{
label: '开启',
value: 0
@@ -385,6 +339,7 @@
message: "请选择投票限制",
trigger: "blur",
}, ],
+ value: 0
}, {
label: '签名',
prop: 'signatureFlag',
@@ -402,6 +357,7 @@
message: "请选择是否签名",
trigger: "blur",
}, ],
+ value: 0
}, {
label: '指定用户',
prop: 'appointUser',
@@ -419,6 +375,7 @@
message: "请选择是否指定用户",
trigger: "blur",
}, ],
+ value: 0
},
{
label: "截止时间",
@@ -457,29 +414,31 @@
}
},
methods: {
- rowSave(row) {
+ rowSave(row, done, loading) {
addPd(row).then(
() => {
+ this.onLoad(this.discussion);
this.$message({
type: "success",
message: "操作成功!",
- })
- this.dialogVisibles = false
- done()
+ });
+ done();
},
(error) => {
- window.console.log(error)
- // loading();
+ window.console.log(error);
+ loading();
}
- )
+ );
},
+
init(data) {
this.discussion = data
// let row = {
// title: data.title
// }
- // this.data.push(row)
+ this.form.title = data.title
+ this.form.articleId = data.id;
this.onLoad(data)
},
@@ -513,10 +472,10 @@
this.dialogVisiblesEdit = true
},
// 提交修改
- handleSubmitEdit(form, done) {
+ rowUpdate(row, index, done, loading) {
done()
- if (!this.discussForm.id) {
- addPd(this.discussForm).then(() => {
+ if (!row.id) {
+ addPd(row).then(() => {
this.dialogVisiblesEdit = false
this.onLoad(this.discussion);
this.$message({
@@ -525,7 +484,7 @@
});
});
} else {
- updatePd(this.discussForm).then(() => {
+ updatePd(row).then(() => {
this.dialogVisiblesEdit = false
this.onLoad(this.discussion);
this.$message({
@@ -590,7 +549,7 @@
const data = res.data.data;
this.form = data;
this.loading = false;
- this.selectionClear();
+ // this.selectionClear();
})
},
@@ -603,6 +562,7 @@
type: "success",
message: "操作成功!",
});
+ form = {}
this.editFlag = false
let params = {
level: 1,
@@ -690,6 +650,19 @@
});
});
},
+ beforeOpen(done, type) {
+ if (["edit", "view"].includes(type)) {
+ getDetailPd(this.form.id).then((res) => {
+ let data = res.data.data
+ this.form = data;
+ });
+ }
+ if (["add"].includes(type)) {
+ this.form.title = this.discussion.title;
+ this.form.articleId = this.discussion.id;
+ }
+ done();
+ },
beforeClose(done) {
done()
this.form = {};
diff --git a/src/views/article/discussionManage.vue b/src/views/article/discussionManage.vue
index 2d904b4..10f1b61 100644
--- a/src/views/article/discussionManage.vue
+++ b/src/views/article/discussionManage.vue
@@ -10,7 +10,6 @@
</template>
<template slot-scope="{type,size,row }" slot="menu">
-
<el-button icon="el-icon-circle-plus-outline" :size="size" :type="type" @click.stop="openDilog(row,1)">
创建议题
</el-button>
diff --git a/src/views/article/publicSignUp.vue b/src/views/article/publicSignUp.vue
index 2017d5a..5db84af 100644
--- a/src/views/article/publicSignUp.vue
+++ b/src/views/article/publicSignUp.vue
@@ -282,61 +282,7 @@
}
],
},
- {
- // labelWidth: 100,
- label: '开启投票',
- prop: 'openFlag',
- type: 'radio',
- button: true,
- // row: true,
- // offset: 6,
- dicData: [{
- label: '开启',
- value: 0
- }, {
- label: '不开启',
- value: 1
- }],
- rules: [{
- required: true,
- message: "请选开启状态",
- trigger: "blur",
- }, ],
- }, {
- // labelWidth: 100,
- label: '投票限制',
- prop: 'voteRestrictions',
- type: 'radio',
- button: true,
- // row: true,
- // offset: 6,
- dicData: [{
- label: '一人一票',
- value: 0
- }, {
- label: '一户一票',
- value: 1
- }],
- rules: [{
- required: true,
- message: "请选投票限制",
- trigger: "blur",
- }, ],
- },
- {
- label: "投票截止时间",
- // row: true,
- // offset: 6,
- prop: "endTime",
- type: "datetime",
- format: "yyyy-MM-dd hh:mm:ss",
- valueFormat: "timestamp",
- rules: [{
- required: true,
- message: "请选截止时间",
- trigger: "blur",
- }, ],
- },
+
// {
// label: "视频",
// prop: "videoUrl",
--
Gitblit v1.9.3