feat(心理论坛模块): 更新新增/修改弹窗表单,添加同步功能

- 修改弹窗标题为“修改”,并移除链接地址输入项
- 更新表单数据结构,确保只保留分类信息
- 添加同步按钮,替换新增按钮,优化用户操作流程
- 实现同步弹窗的显示逻辑,支持数据列表的刷新
This commit is contained in:
2026-04-07 14:31:48 +08:00
parent 1ade4bfbc6
commit 822f42cd96
3 changed files with 166 additions and 26 deletions

View File

@@ -1,7 +1,7 @@
<template>
<el-dialog
width="1260px"
:title="!dataForm.id ? '新增' : '修改'"
title="修改"
:close-on-click-modal="false"
:visible.sync="visible"
@close="handlereset"
@@ -16,13 +16,6 @@
ref="dataForm"
label-width="80px"
>
<el-form-item label="链接地址" prop="url">
<el-input
v-model="dataForm.url"
placeholder="链接地址"
:rows="3"
></el-input>
</el-form-item>
<el-form-item label="分类" prop="type">
<el-select v-model="dataForm.type" placeholder="请选择分类" clearable>
<el-option
@@ -45,7 +38,7 @@
</template>
<script>
import global from "../../common/common.vue"; //引入共用组间
import global from "../../common/common.vue";
export default {
data() {
return {
@@ -56,21 +49,15 @@ export default {
typeList: [],
dataForm: {
id: null,
title: '',
url: '',
type: ''
type: ""
},
dataRule: {
type: [
{ required: true, message: "分类不能为空", trigger: "change" }
],
url: [
{ required: true, message: "链接地址不能为空", trigger: "change" }
]
},
urlList: {
info: "/master/message/getMessageById",
add: "/common/wxPublicAccount/addWxPublicAccountArticle",
update: "/common/wxPublicAccount/updateWxPublicAccountArticle"
}
};
@@ -92,8 +79,7 @@ export default {
this.getTypeList();
this.dataForm = {
id: row && row.id || null,
url: row && row.url || '',
type: row && row.type != null ? String(row.type) : ''
type: row && row.type != null ? String(row.type) : ""
};
this.visible = true;
this.$nextTick(() => {
@@ -102,22 +88,24 @@ export default {
}
});
},
// 表单提交
dataFormSubmit() {
this.$refs["dataForm"].validate(valid => {
if (valid) {
// 这里应该是提交数据的逻辑
const loading = this.$loading({
lock: true,
fullscreen: true
});
this.$http
.request({
url: this.dataForm.id ? this.$http.adornUrl(this.urlList.update) : this.$http.adornUrl(this.urlList.add),
url: this.$http.adornUrl(this.urlList.update),
method: "POST",
data: this.dataForm,
header: {
//默认 无 说明:请求头
"Content-Type": "application/json"
}
})
.then(({ data }) => {
loading.close();
if (data && data.code === 0) {
this.$message({
message: "操作成功",
@@ -131,6 +119,9 @@ export default {
} else {
this.$message.error(data.msg);
}
})
.catch(() => {
loading.close();
});
}
});

View File

@@ -0,0 +1,134 @@
<template>
<el-dialog
width="1260px"
title="同步"
:close-on-click-modal="false"
:visible.sync="visible"
@close="handlereset"
style="height: auto;"
>
<div style="margin-bottom: 60px;">
<el-form
style="height: auto;"
class="addFormBox"
:model="dataForm"
:rules="dataRule"
ref="dataForm"
label-width="80px"
>
<el-form-item label="token" prop="token">
<el-input
v-model="dataForm.token"
type="textarea"
:rows="4"
placeholder="token"
></el-input>
</el-form-item>
<el-form-item label="cookie" prop="cookie">
<el-input
v-model="dataForm.cookie"
type="textarea"
:rows="4"
placeholder="cookie"
></el-input>
</el-form-item>
</el-form>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="handlereset">取消</el-button>
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
</span>
</el-dialog>
</template>
<script>
import global from "../../common/common.vue";
export default {
data() {
return {
baseUrl: global.baseUrl,
visible: false,
dataForm: {
token: "",
cookie: ""
},
dataRule: {
token: [
{ required: true, message: "token不能为空", trigger: "blur" }
],
cookie: [
{ required: true, message: "cookie不能为空", trigger: "blur" }
]
},
urlList: {
add: "/common/wxPublicAccount/addWxPublicAccountArticle"
}
};
},
methods: {
init() {
this.dataForm = {
token: "",
cookie: ""
};
this.visible = true;
this.$nextTick(() => {
if (this.$refs["dataForm"]) {
this.$refs["dataForm"].clearValidate();
}
});
},
dataFormSubmit() {
this.$refs["dataForm"].validate(valid => {
if (valid) {
const loading = this.$loading({
lock: true,
fullscreen: true
});
this.$http
.request({
url: this.$http.adornUrl(this.urlList.add),
method: "POST",
data: this.dataForm,
header: {
"Content-Type": "application/json"
}
})
.then(({ data }) => {
loading.close();
if (data && data.code === 0) {
this.$message({
message: "操作成功",
type: "success",
duration: 1500,
onClose: () => {
this.visible = false;
this.$emit("refreshDataList");
}
});
} else {
this.$message.error(data.msg);
}
})
.catch(() => {
loading.close();
});
}
});
},
handlereset() {
if (this.$refs["dataForm"]) {
this.$refs["dataForm"].clearValidate();
}
this.visible = false;
}
}
};
</script>
<style lang="scss" scoped>
/deep/ .addFormBox.el-form-item {
margin-bottom: 10px !important;
}
</style>

View File

@@ -32,7 +32,7 @@
"
>查询</el-button
>
<el-button type="primary" @click="addOrUpdateHandle()">新增</el-button>
<el-button type="primary" @click="syncHandle()">同步</el-button>
</el-form-item>
</el-form>
<div style="height: calc(100% - 80px );">
@@ -131,7 +131,13 @@
</el-pagination>
</div>
<!-- 弹窗, 新增 / 修改 -->
<!-- 弹窗同步 -->
<psychological-forum-add
v-if="addVisible"
ref="psychologicalForumAdd"
@refreshDataList="getDataList"
></psychological-forum-add>
<!-- 弹窗修改 -->
<add-or-update
v-if="addOrUpdateVisible"
ref="addOrUpdate"
@@ -142,6 +148,7 @@
<script>
import AddOrUpdate from "./psychologicalForum-add-or-update";
import PsychologicalForumAdd from "./psychologicalForum-add";
export default {
data() {
return {
@@ -162,6 +169,7 @@ export default {
totalPage: 0,
dataListLoading: false,
dataListSelections: [],
addVisible: false,
addOrUpdateVisible: false,
urlList: {
list: "/common/wxPublicAccount/getWxPublicAccountArticleList"
@@ -169,7 +177,8 @@ export default {
};
},
components: {
AddOrUpdate
AddOrUpdate,
PsychologicalForumAdd
},
activated() {
if (this.$route.query.upPageInde != null) {
@@ -242,7 +251,13 @@ export default {
selectionChangeHandle(val) {
this.dataListSelections = val;
},
// 新增 / 修改
syncHandle() {
this.addVisible = true;
this.$nextTick(() => {
this.$refs.psychologicalForumAdd.init();
});
},
// 修改
addOrUpdateHandle(row) {
this.addOrUpdateVisible = true;
this.$nextTick(() => {