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