feat(心理论坛模块): 更新新增/修改弹窗表单,添加同步功能
- 修改弹窗标题为“修改”,并移除链接地址输入项 - 更新表单数据结构,确保只保留分类信息 - 添加同步按钮,替换新增按钮,优化用户操作流程 - 实现同步弹窗的显示逻辑,支持数据列表的刷新
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog
|
<el-dialog
|
||||||
width="1260px"
|
width="1260px"
|
||||||
:title="!dataForm.id ? '新增' : '修改'"
|
title="修改"
|
||||||
:close-on-click-modal="false"
|
:close-on-click-modal="false"
|
||||||
:visible.sync="visible"
|
:visible.sync="visible"
|
||||||
@close="handlereset"
|
@close="handlereset"
|
||||||
@@ -16,13 +16,6 @@
|
|||||||
ref="dataForm"
|
ref="dataForm"
|
||||||
label-width="80px"
|
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-form-item label="分类" prop="type">
|
||||||
<el-select v-model="dataForm.type" placeholder="请选择分类" clearable>
|
<el-select v-model="dataForm.type" placeholder="请选择分类" clearable>
|
||||||
<el-option
|
<el-option
|
||||||
@@ -45,7 +38,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import global from "../../common/common.vue"; //引入共用组间
|
import global from "../../common/common.vue";
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -56,21 +49,15 @@ export default {
|
|||||||
typeList: [],
|
typeList: [],
|
||||||
dataForm: {
|
dataForm: {
|
||||||
id: null,
|
id: null,
|
||||||
title: '',
|
type: ""
|
||||||
url: '',
|
|
||||||
type: ''
|
|
||||||
},
|
},
|
||||||
dataRule: {
|
dataRule: {
|
||||||
type: [
|
type: [
|
||||||
{ required: true, message: "分类不能为空", trigger: "change" }
|
{ required: true, message: "分类不能为空", trigger: "change" }
|
||||||
],
|
|
||||||
url: [
|
|
||||||
{ required: true, message: "链接地址不能为空", trigger: "change" }
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
urlList: {
|
urlList: {
|
||||||
info: "/master/message/getMessageById",
|
info: "/master/message/getMessageById",
|
||||||
add: "/common/wxPublicAccount/addWxPublicAccountArticle",
|
|
||||||
update: "/common/wxPublicAccount/updateWxPublicAccountArticle"
|
update: "/common/wxPublicAccount/updateWxPublicAccountArticle"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -92,8 +79,7 @@ export default {
|
|||||||
this.getTypeList();
|
this.getTypeList();
|
||||||
this.dataForm = {
|
this.dataForm = {
|
||||||
id: row && row.id || null,
|
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.visible = true;
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
@@ -102,22 +88,24 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 表单提交
|
|
||||||
dataFormSubmit() {
|
dataFormSubmit() {
|
||||||
this.$refs["dataForm"].validate(valid => {
|
this.$refs["dataForm"].validate(valid => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
// 这里应该是提交数据的逻辑
|
const loading = this.$loading({
|
||||||
|
lock: true,
|
||||||
|
fullscreen: true
|
||||||
|
});
|
||||||
this.$http
|
this.$http
|
||||||
.request({
|
.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",
|
method: "POST",
|
||||||
data: this.dataForm,
|
data: this.dataForm,
|
||||||
header: {
|
header: {
|
||||||
//默认 无 说明:请求头
|
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
|
loading.close();
|
||||||
if (data && data.code === 0) {
|
if (data && data.code === 0) {
|
||||||
this.$message({
|
this.$message({
|
||||||
message: "操作成功",
|
message: "操作成功",
|
||||||
@@ -131,6 +119,9 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
this.$message.error(data.msg);
|
this.$message.error(data.msg);
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
loading.close();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
134
src/views/modules/content/psychologicalForum-add.vue
Normal file
134
src/views/modules/content/psychologicalForum-add.vue
Normal 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>
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
"
|
"
|
||||||
>查询</el-button
|
>查询</el-button
|
||||||
>
|
>
|
||||||
<el-button type="primary" @click="addOrUpdateHandle()">新增</el-button>
|
<el-button type="primary" @click="syncHandle()">同步</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<div style="height: calc(100% - 80px );">
|
<div style="height: calc(100% - 80px );">
|
||||||
@@ -131,7 +131,13 @@
|
|||||||
</el-pagination>
|
</el-pagination>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 弹窗, 新增 / 修改 -->
|
<!-- 弹窗:同步 -->
|
||||||
|
<psychological-forum-add
|
||||||
|
v-if="addVisible"
|
||||||
|
ref="psychologicalForumAdd"
|
||||||
|
@refreshDataList="getDataList"
|
||||||
|
></psychological-forum-add>
|
||||||
|
<!-- 弹窗:修改 -->
|
||||||
<add-or-update
|
<add-or-update
|
||||||
v-if="addOrUpdateVisible"
|
v-if="addOrUpdateVisible"
|
||||||
ref="addOrUpdate"
|
ref="addOrUpdate"
|
||||||
@@ -142,6 +148,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import AddOrUpdate from "./psychologicalForum-add-or-update";
|
import AddOrUpdate from "./psychologicalForum-add-or-update";
|
||||||
|
import PsychologicalForumAdd from "./psychologicalForum-add";
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -162,6 +169,7 @@ export default {
|
|||||||
totalPage: 0,
|
totalPage: 0,
|
||||||
dataListLoading: false,
|
dataListLoading: false,
|
||||||
dataListSelections: [],
|
dataListSelections: [],
|
||||||
|
addVisible: false,
|
||||||
addOrUpdateVisible: false,
|
addOrUpdateVisible: false,
|
||||||
urlList: {
|
urlList: {
|
||||||
list: "/common/wxPublicAccount/getWxPublicAccountArticleList"
|
list: "/common/wxPublicAccount/getWxPublicAccountArticleList"
|
||||||
@@ -169,7 +177,8 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
AddOrUpdate
|
AddOrUpdate,
|
||||||
|
PsychologicalForumAdd
|
||||||
},
|
},
|
||||||
activated() {
|
activated() {
|
||||||
if (this.$route.query.upPageInde != null) {
|
if (this.$route.query.upPageInde != null) {
|
||||||
@@ -242,7 +251,13 @@ export default {
|
|||||||
selectionChangeHandle(val) {
|
selectionChangeHandle(val) {
|
||||||
this.dataListSelections = val;
|
this.dataListSelections = val;
|
||||||
},
|
},
|
||||||
// 新增 / 修改
|
syncHandle() {
|
||||||
|
this.addVisible = true;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.psychologicalForumAdd.init();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 修改
|
||||||
addOrUpdateHandle(row) {
|
addOrUpdateHandle(row) {
|
||||||
this.addOrUpdateVisible = true;
|
this.addOrUpdateVisible = true;
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user