教学公告添加发布功能

This commit is contained in:
2026-09-18 10:50:26 +08:00
parent f3ae9fb2fd
commit a0d5a3b0fe
2 changed files with 117 additions and 4 deletions
+18
View File
@@ -45,3 +45,21 @@ export function delTeachNotice(Id) {
params: { Id } params: { Id }
}) })
} }
// 发布或重新发布公告:{id, scopeType: ALL|ALL_TEACHERS|DEPARTMENTS, departmentIds?}
export function publishTeachNotice(data) {
return request({
url: '/notice-announcement/publish',
method: 'post',
data: data
})
}
// 下架已发布公告
export function downTeachNotice(id) {
return request({
url: '/notice-announcement/down',
method: 'post',
data: { id }
})
}
+99 -4
View File
@@ -90,13 +90,22 @@
@click="handleView(scope.row)" @click="handleView(scope.row)"
>详情</el-button> >详情</el-button>
<el-button <el-button
v-if="scope.row.status !== '已发布'"
type="text" type="text"
size="mini" size="mini"
icon="el-icon-edit" icon="el-icon-edit"
@click="handleUpdate(scope.row)" @click="handleUpdate(scope.row)"
>修改</el-button> >修改</el-button>
<el-button <el-button
v-if="scope.row.status !== '已下架'" v-if="scope.row.status !== '已发布'"
type="text"
size="mini"
icon="el-icon-position"
style="color: #67c23a"
@click="handlePublish(scope.row)"
>发布</el-button>
<el-button
v-if="scope.row.status === '已发布'"
type="text" type="text"
size="mini" size="mini"
icon="el-icon-download" icon="el-icon-download"
@@ -202,11 +211,56 @@
<el-button size="mini" @click="handleViewVisible(false)"> </el-button> <el-button size="mini" @click="handleViewVisible(false)"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
<!-- 发布 对话框 -->
<el-dialog
title="发布公告"
:visible="publishVisible"
:close-on-click-modal="false"
width="520px"
@update:visible="val => publishVisible = val"
>
<el-form label-width="90px">
<el-form-item label="公告标题">
<span>{{ publishRow.title }}</span>
</el-form-item>
<el-form-item label="发布范围" required>
<el-radio-group v-model="publishForm.scopeType">
<el-radio label="ALL">全校</el-radio>
<el-radio label="ALL_TEACHERS">全体教员</el-radio>
<el-radio label="DEPARTMENTS">指定部别</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item v-if="publishForm.scopeType === 'DEPARTMENTS'" label="部别" required>
<el-select
v-model="publishForm.departmentIds"
multiple
filterable
collapse-tags
placeholder="请选择部别"
style="width: 100%"
:loading="deptLoading"
>
<el-option
v-for="d in deptOptions"
:key="d.deptId"
:label="d.deptName"
:value="String(d.deptId)"
/>
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" size="mini" :loading="publishing" @click="submitPublish"> </el-button>
<el-button size="mini" @click="publishVisible = false"> </el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { listTeachNotice, getTeachNotice, addTeachNotice, updateTeachNotice, delTeachNotice } from "@/api/teachNotice" import { listTeachNotice, getTeachNotice, addTeachNotice, updateTeachNotice, delTeachNotice, publishTeachNotice, downTeachNotice } from "@/api/teachNotice"
import { listDept } from "@/api/system/dept"
export default { export default {
name: "TeachNotice", name: "TeachNotice",
@@ -236,7 +290,14 @@ export default {
}, },
// 详情 对话框 // 详情 对话框
viewVisible: false, viewVisible: false,
viewForm: {} viewForm: {},
// 发布 对话框
publishVisible: false,
publishing: false,
publishRow: {},
publishForm: { scopeType: 'ALL', departmentIds: [] },
deptOptions: [],
deptLoading: false
} }
}, },
created() { created() {
@@ -331,6 +392,40 @@ export default {
} }
}) })
}, },
/** 发布(拟制/已下架 → 已发布) */
handlePublish(row) {
this.publishRow = row
this.publishForm = { scopeType: 'ALL', departmentIds: [] }
this.publishVisible = true
if (!this.deptOptions.length && !this.deptLoading) {
this.deptLoading = true
listDept({ status: '0' }).then(res => {
this.deptOptions = res.data || []
}).catch(() => {}).finally(() => {
this.deptLoading = false
})
}
},
/** 提交发布 */
submitPublish() {
const f = this.publishForm
if (f.scopeType === 'DEPARTMENTS' && !f.departmentIds.length) {
this.$message.warning("请选择至少一个部别")
return
}
this.publishing = true
publishTeachNotice({
id: this.publishRow.id,
scopeType: f.scopeType,
departmentIds: f.scopeType === 'DEPARTMENTS' ? f.departmentIds : undefined
}).then(() => {
this.$message.success("发布成功")
this.publishVisible = false
this.getList()
}).catch(() => {}).finally(() => {
this.publishing = false
})
},
/** 下架 */ /** 下架 */
handleOffline(row) { handleOffline(row) {
this.$confirm("确认下架该公告吗?", "提示", { this.$confirm("确认下架该公告吗?", "提示", {
@@ -338,7 +433,7 @@ export default {
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning"
}).then(() => { }).then(() => {
updateTeachNotice({ id: row.id, status: '已下架' }).then(() => { downTeachNotice(row.id).then(() => {
this.$message.success("下架成功") this.$message.success("下架成功")
this.getList() this.getList()
}).catch(() => {}) }).catch(() => {})