feat(系统公告管理): 修改弹窗的图片上传问题修复

This commit is contained in:
hzj 2025-10-16 14:13:13 +08:00
parent e0ed82f60f
commit 99ae9e0957

View File

@ -15,9 +15,7 @@
:value="item.value" :value="item.value"
> >
<span style="float: left;"> <span style="float: left;">
<sys-origin-icon <sys-origin-icon :icon="item.value" :desc="item.value"
:icon="item.value"
:desc="item.value"
/></span> /></span>
<span style="float: left;margin-left:10px">{{ item.label }}</span> <span style="float: left;margin-left:10px">{{ item.label }}</span>
</el-option> </el-option>
@ -115,11 +113,7 @@
/> />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column prop="announcementTime" label="发布时间" align="center">
prop="announcementTime"
label="发布时间"
align="center"
>
<template slot-scope="scope"> <template slot-scope="scope">
{{ scope.row.announcementTime | dateFormat }} {{ scope.row.announcementTime | dateFormat }}
</template> </template>
@ -139,14 +133,12 @@
</el-table-column> </el-table-column>
<el-table-column fixed="right" label="操作" align="center" width="200"> <el-table-column fixed="right" label="操作" align="center" width="200">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button type="text" @click.native="handleUpdate(scope.row)"
type="text" >修改</el-button
@click.native="handleUpdate(scope.row)" >
>修改</el-button> <el-button type="text" @click.native="handlDel(scope.row.id)"
<el-button >删除</el-button
type="text" >
@click.native="handlDel(scope.row.id)"
>删除</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -180,11 +172,9 @@
fit="fill" fit="fill"
style="width: 50px; height: 50px" style="width: 50px; height: 50px"
/> />
<el-button <el-button v-loading="uploadLoading" size="small" type="primary"
v-loading="uploadLoading" >点击上传</el-button
size="small" >
type="primary"
>点击上传</el-button>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
<el-form-item label="系统" prop="sysOrigin"> <el-form-item label="系统" prop="sysOrigin">
@ -201,9 +191,7 @@
:value="item.value" :value="item.value"
> >
<span style="float: left;"> <span style="float: left;">
<sys-origin-icon <sys-origin-icon :icon="item.value" :desc="item.value"
:icon="item.value"
:desc="item.value"
/></span> /></span>
<span style="float: left;margin-left:10px">{{ <span style="float: left;margin-left:10px">{{
item.label item.label
@ -228,7 +216,8 @@
<span <span
class="numberV" class="numberV"
style="position: absolute; right: 10px;bottom: 0;" style="position: absolute; right: 10px;bottom: 0;"
>{{ txtVal }}/300</span> >{{ txtVal }}/300</span
>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="submitForm()">保存</el-button> <el-button type="primary" @click="submitForm()">保存</el-button>
@ -248,21 +237,21 @@ import {
addNoticeMessage, addNoticeMessage,
changeAnnouncementStatus, changeAnnouncementStatus,
changeShelfStatus changeShelfStatus
} from '@/api/notice-message' } from "@/api/notice-message";
import Pagination from '@/components/Pagination' import Pagination from "@/components/Pagination";
import { getAddressUrl } from '@/api/oss' import { getAccessImgUrl } from "@/api/oss";
import { productConfigShowcase, announcementArray } from '@/constant/type' import { productConfigShowcase, announcementArray } from "@/constant/type";
import { pickerOptions } from '@/constant/el-const' import { pickerOptions } from "@/constant/el-const";
import { mapGetters } from 'vuex' import { mapGetters } from "vuex";
function getFormData() { function getFormData() {
return { return {
id: '', id: "",
cover: '', cover: "",
sysOrigin: '', sysOrigin: "",
title: '', title: "",
link: '', link: "",
description: '' description: ""
} };
} }
export default { export default {
components: { Pagination }, components: { Pagination },
@ -272,7 +261,7 @@ export default {
productConfigShowcase, productConfigShowcase,
pickerOptions, pickerOptions,
txtVal: 0, txtVal: 0,
activeGiftId: '', activeGiftId: "",
pushTextHistoryLoading: false, pushTextHistoryLoading: false,
pushTextHistoryVisible: false, pushTextHistoryVisible: false,
pushTextHistory: [], pushTextHistory: [],
@ -282,28 +271,28 @@ export default {
listQuery: { listQuery: {
cursor: 1, cursor: 1,
limit: 20, limit: 20,
sysOrigin: '', sysOrigin: "",
startTime: '', startTime: "",
endTime: '' endTime: ""
}, },
formVisible: false, formVisible: false,
textOptTitle: '', textOptTitle: "",
form: getFormData(), form: getFormData(),
submitLoading: false, submitLoading: false,
rules: { rules: {
sysOrigin: [{ required: true, message: '请选择系统', trigger: 'blur' }], sysOrigin: [{ required: true, message: "请选择系统", trigger: "blur" }],
title: [{ required: true, message: '请填写标题', trigger: 'blur' }], title: [{ required: true, message: "请填写标题", trigger: "blur" }],
description: [ description: [
{ required: true, message: '请填写描述', trigger: 'blur' } { required: true, message: "请填写描述", trigger: "blur" }
] ]
}, },
rangeDate: '', rangeDate: "",
listLoading: true, listLoading: true,
uploadLoading: false uploadLoading: false
} };
}, },
computed: { computed: {
...mapGetters(['permissionsSysOriginPlatforms']) ...mapGetters(["permissionsSysOriginPlatforms"])
}, },
watch: { watch: {
rangeDate: { rangeDate: {
@ -311,185 +300,183 @@ export default {
deep: true, deep: true,
handler(newVal) { handler(newVal) {
if (newVal && newVal.length > 0) { if (newVal && newVal.length > 0) {
this.listQuery.startTime = newVal[0] this.listQuery.startTime = newVal[0];
this.listQuery.endTime = newVal[1] this.listQuery.endTime = newVal[1];
return return;
} }
this.listQuery.startTime = '' this.listQuery.startTime = "";
this.listQuery.endTime = '' this.listQuery.endTime = "";
} }
} }
}, },
created() { created() {
const that = this const that = this;
const querySystem = this.permissionsSysOriginPlatforms[0] const querySystem = this.permissionsSysOriginPlatforms[0];
if (!querySystem) { if (!querySystem) {
return return;
} }
that.listQuery.sysOrigin = querySystem.value that.listQuery.sysOrigin = querySystem.value;
that.renderData() that.renderData();
}, },
methods: { methods: {
renderData() { renderData() {
const that = this const that = this;
that.listLoading = true that.listLoading = true;
noticeMessageTable(that.listQuery).then(res => { noticeMessageTable(that.listQuery).then(res => {
const { body } = res const { body } = res;
that.total = body.total || 0 that.total = body.total || 0;
that.list = body.records that.list = body.records;
that.listLoading = false that.listLoading = false;
}) });
}, },
handleSearch() { handleSearch() {
this.renderData() this.renderData();
}, },
handleSwitchAnnouncementChange(row) { handleSwitchAnnouncementChange(row) {
const that = this const that = this;
if (!row.announcement) { if (!row.announcement) {
this.$message({ this.$message({
message: '不可以取消发布', message: "不可以取消发布",
type: 'error' type: "error"
}) });
row.announcement = true row.announcement = true;
return return;
} }
that that
.$confirm('确认发布公告吗?发布后不可以取消!', '提示', { .$confirm("确认发布公告吗?发布后不可以取消!", "提示", {
type: 'warning' type: "warning"
}) })
.then(() => { .then(() => {
that.listLoading = true that.listLoading = true;
changeAnnouncementStatus(row.id) changeAnnouncementStatus(row.id)
.then(res => { .then(res => {
this.listLoading = false this.listLoading = false;
this.$message({ this.$message({
message: '发布成功', message: "发布成功",
type: 'success' type: "success"
});
this.renderData();
}) })
this.renderData() .catch(() => {});
})
.catch(() => {})
}) })
.catch(() => { .catch(() => {
if (!row.announcement) { if (!row.announcement) {
row.announcement = true row.announcement = true;
} else if (row.announcement) { } else if (row.announcement) {
row.announcement = false row.announcement = false;
} }
}) });
}, },
handleSwitchShelfStatusChange(row) { handleSwitchShelfStatusChange(row) {
changeShelfStatus(row.id, row.shelfStatus) changeShelfStatus(row.id, row.shelfStatus)
.then(res => { .then(res => {
this.$message({ this.$message({
message: row.shelfStatus ? '上架 成功' : '下架 成功', message: row.shelfStatus ? "上架 成功" : "下架 成功",
type: 'success' type: "success"
}) });
}) })
.catch(er => { .catch(er => {
if (row.status === 0) { if (row.status === 0) {
row.status = 1 row.status = 1;
} else if (row.status === 1) { } else if (row.status === 1) {
row.status = 0 row.status = 0;
} }
}) });
}, },
renderDataSuccess() { renderDataSuccess() {
this.$message({ this.$message({
message: 'Successful', message: "Successful",
type: 'success' type: "success"
}) });
this.renderData() this.renderData();
}, },
queryUserDetails(row) { queryUserDetails(row) {
this.userDeatilsDrawer = true this.userDeatilsDrawer = true;
this.thatSelectedUserId = row.id this.thatSelectedUserId = row.id;
}, },
submitForm() { submitForm() {
const that = this const that = this;
that.$refs.form.validate(valid => { that.$refs.form.validate(valid => {
if (valid) { if (valid) {
that.submitLoading = true that.submitLoading = true;
if (that.form.id) { if (that.form.id) {
updateNoticeMessage(that.form) updateNoticeMessage(that.form)
.then(res => { .then(res => {
that.submitLoading = false that.submitLoading = false;
that.formVisible = false that.formVisible = false;
that.form = getFormData() that.form = getFormData();
that.renderData() that.renderData();
}) })
.catch(er => { .catch(er => {
that.submitLoading = false that.submitLoading = false;
that.$emit('fial', er) that.$emit("fial", er);
}) });
return return;
} }
addNoticeMessage(that.form) addNoticeMessage(that.form)
.then(res => { .then(res => {
that.submitLoading = false that.submitLoading = false;
that.formVisible = false that.formVisible = false;
that.form = getFormData() that.form = getFormData();
that.renderData() that.renderData();
}) })
.catch(er => { .catch(er => {
that.submitLoading = false that.submitLoading = false;
console.error(er) console.error(er);
that.$emit('fial', er) that.$emit("fial", er);
}) });
} else { } else {
console.error('error submit!!') console.error("error submit!!");
return false return false;
} }
}) });
}, },
// //
handlDel(id) { handlDel(id) {
this.$confirm('确认删除吗?', '提示', { this.$confirm("确认删除吗?", "提示", {
type: 'warning' type: "warning"
}) })
.then(() => { .then(() => {
this.listLoading = true this.listLoading = true;
deleteNoticeMessage(id).then(res => { deleteNoticeMessage(id).then(res => {
this.listLoading = false this.listLoading = false;
this.$message({ this.$message({
message: '删除成功', message: "删除成功",
type: 'success' type: "success"
});
this.renderData();
});
}) })
this.renderData() .catch(() => {});
})
})
.catch(() => {})
}, },
handleClose() { handleClose() {
this.formVisible = false this.formVisible = false;
}, },
descInput() { descInput() {
this.txtVal = this.form.description.length this.txtVal = this.form.description.length;
}, },
httpRequest(file) { httpRequest(file) {
const that = this const that = this;
that.uploadLoading = true that.uploadLoading = true;
this.$simpleUploadFlie(file) this.$simpleUploadFlie(file)
.then(res => { .then(res => {
that.uploadLoading = false that.uploadLoading = false;
getAddressUrl(res.name).then(result => { that.form.cover = getAccessImgUrl(res.name);
that.form.cover = result.body
})
}) })
.catch(er => { .catch(er => {
that.uploadLoading = false that.uploadLoading = false;
}) });
}, },
handleCreate() { handleCreate() {
this.formVisible = true this.formVisible = true;
this.textOptTitle = '添加' this.textOptTitle = "添加";
this.form = getFormData() this.form = getFormData();
}, },
handleUpdate(row) { handleUpdate(row) {
this.textOptTitle = '修改' this.textOptTitle = "修改";
this.formVisible = true this.formVisible = true;
this.form = Object.assign(this.form, row) this.form = Object.assign(this.form, row);
}
} }
} }
};
</script> </script>