This commit is contained in:
linfeng 2022-12-29 09:35:09 +08:00
parent ce9e093fb4
commit 5a6865e07e

View File

@ -2,19 +2,23 @@
<el-dialog <el-dialog
:title="!dataForm.id ? '新增' : '修改'" :title="!dataForm.id ? '新增' : '修改'"
:close-on-click-modal="false" :close-on-click-modal="false"
:visible.sync="visible"> :visible.sync="visible"
<el-form :model="dataForm" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px"> >
<el-form
<el-form-item label="浏览量" prop="readCount"> :model="dataForm"
<el-input v-model="dataForm.readCount" placeholder="浏览量"></el-input> ref="dataForm"
</el-form-item> @keyup.enter.native="dataFormSubmit()"
<el-form-item label="置顶" prop="postTop"> label-width="80px"
>
<el-form-item label="浏览量" prop="readCount">
<el-input v-model="dataForm.readCount" placeholder="浏览量"></el-input>
</el-form-item>
<el-form-item label="平台置顶" prop="postTop">
<el-radio-group v-model="dataForm.postTop"> <el-radio-group v-model="dataForm.postTop">
<el-radio :label="0"></el-radio> <el-radio :label="0"></el-radio>
<el-radio :label="1"></el-radio> <el-radio :label="1"></el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-form> </el-form>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="visible = false">取消</el-button> <el-button @click="visible = false">取消</el-button>
@ -24,107 +28,108 @@
</template> </template>
<script> <script>
export default { export default {
data () { data() {
return { return {
visible: false, visible: false,
dataForm: { dataForm: {
id: 0, id: 0,
uid: '', uid: "",
topicId: '', topicId: "",
discussId: '', discussId: "",
voteId: '', voteId: "",
title: '', title: "",
content: '', content: "",
media: '', media: "",
readCount: '', readCount: "",
postTop: '', postTop: "",
type: '', type: "",
address: '', address: "",
longitude: '', longitude: "",
latitude: '', latitude: "",
createTime: '', createTime: "",
status:'', status: "",
},
}
},
methods: {
init (id) {
this.dataForm.id = id || 0
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
if (this.dataForm.id) {
this.$http({
url: this.$http.adornUrl(`/admin/post/info/${this.dataForm.id}`),
method: 'get',
params: this.$http.adornParams()
}).then(({data}) => {
if (data && data.code === 0) {
this.dataForm.uid = data.post.uid
this.dataForm.topicId = data.post.topicId
this.dataForm.discussId = data.post.discussId
this.dataForm.voteId = data.post.voteId
this.dataForm.title = data.post.title
this.dataForm.content = data.post.content
this.dataForm.media = data.post.media
this.dataForm.readCount = data.post.readCount
this.dataForm.postTop = data.post.postTop
this.dataForm.type = data.post.type
this.dataForm.address = data.post.address
this.dataForm.longitude = data.post.longitude
this.dataForm.latitude = data.post.latitude
this.dataForm.createTime = data.post.createTime
this.dataForm.status = data.post.status
}
})
}
})
}, },
// };
dataFormSubmit () { },
this.$refs['dataForm'].validate((valid) => { methods: {
if (valid) { init(id) {
this.$http({ this.dataForm.id = id || 0;
url: this.$http.adornUrl(`/admin/post/${!this.dataForm.id ? 'save' : 'update'}`), this.visible = true;
method: 'post', this.$nextTick(() => {
data: this.$http.adornData({ this.$refs["dataForm"].resetFields();
'id': this.dataForm.id || undefined, if (this.dataForm.id) {
'uid': this.dataForm.uid, this.$http({
'topicId': this.dataForm.topicId, url: this.$http.adornUrl(`/admin/post/info/${this.dataForm.id}`),
'discussId': this.dataForm.discussId, method: "get",
'voteId': this.dataForm.voteId, params: this.$http.adornParams(),
'title': this.dataForm.title, }).then(({ data }) => {
'content': this.dataForm.content, if (data && data.code === 0) {
'media': this.dataForm.media, this.dataForm.uid = data.post.uid;
'readCount': this.dataForm.readCount, this.dataForm.topicId = data.post.topicId;
'postTop': this.dataForm.postTop, this.dataForm.discussId = data.post.discussId;
'type': this.dataForm.type, this.dataForm.voteId = data.post.voteId;
'address': this.dataForm.address, this.dataForm.title = data.post.title;
'longitude': this.dataForm.longitude, this.dataForm.content = data.post.content;
'latitude': this.dataForm.latitude, this.dataForm.media = data.post.media;
'createTime': this.dataForm.createTime, this.dataForm.readCount = data.post.readCount;
'status': this.dataForm.status, this.dataForm.postTop = data.post.postTop;
}) this.dataForm.type = data.post.type;
}).then(({data}) => { this.dataForm.address = data.post.address;
if (data && data.code === 0) { this.dataForm.longitude = data.post.longitude;
this.$message({ this.dataForm.latitude = data.post.latitude;
message: '操作成功', this.dataForm.createTime = data.post.createTime;
type: 'success', this.dataForm.status = data.post.status;
duration: 1500, }
onClose: () => { });
this.visible = false }
this.$emit('refreshDataList') });
} },
}) //
} else { dataFormSubmit() {
this.$message.error(data.msg) this.$refs["dataForm"].validate((valid) => {
} if (valid) {
}) this.$http({
} url: this.$http.adornUrl(
}) `/admin/post/${!this.dataForm.id ? "save" : "update"}`
} ),
} method: "post",
} data: this.$http.adornData({
id: this.dataForm.id || undefined,
uid: this.dataForm.uid,
topicId: this.dataForm.topicId,
discussId: this.dataForm.discussId,
voteId: this.dataForm.voteId,
title: this.dataForm.title,
content: this.dataForm.content,
media: this.dataForm.media,
readCount: this.dataForm.readCount,
postTop: this.dataForm.postTop,
type: this.dataForm.type,
address: this.dataForm.address,
longitude: this.dataForm.longitude,
latitude: this.dataForm.latitude,
createTime: this.dataForm.createTime,
status: this.dataForm.status,
}),
}).then(({ data }) => {
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);
}
});
}
});
},
},
};
</script> </script>