| | |
| | | <template> |
| | | <div> |
| | | 公共宣传 |
| | | <div style="height: 100%"> |
| | | <el-card style="height: 100%"> |
| | | <template slot="header"> |
| | | <el-form :inline="true" :model="queryInfo" class="demo-form-inline"> |
| | | <el-form-item label="标题:"> |
| | | <el-input placeholder="请输入" v-model="queryInfo.publicityTitle"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="状态:"> |
| | | <el-select v-model="queryInfo.status" placeholder="请选择" :style="{ width: '120px' }"> |
| | | <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" @click="search">查询</el-button> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" @click="addPublicityVisibel = true">添加</el-button> |
| | | </el-form-item> |
| | | |
| | | <el-form-item> |
| | | <el-upload name="multipartFile" class="upload-demo" action="/api/publicity/upload " :show-file-list="false" |
| | | :before-upload="beforeAvatarUpload" :on-success="respond" :limit="1"> |
| | | <el-button type="primary">导入</el-button> |
| | | </el-upload> |
| | | </el-form-item> |
| | | </el-form> |
| | | </template> |
| | | <template> |
| | | <el-table :data="publicityList" style="width: 100%"> |
| | | |
| | | <el-table-column label="序号" type="index" width="180" align="center"> |
| | | <template slot-scope="scope"> |
| | | <span>{{ (current - 1) * size + scope.$index + 1 }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="publicityTitle" label="标题" width="180" align="center"> |
| | | </el-table-column> |
| | | <el-table-column prop="status" label="状态" width="180" header-align="center" align="center"> |
| | | <template slot-scope="scope"> |
| | | <span v-if="scope.row.status == 0">未发布</span> |
| | | <span v-if="scope.row.status == 1">已发布</span> |
| | | <span v-if="scope.row.status == 2">下架</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="userName" label="创建人" width="180" header-align="center" align="center"> |
| | | </el-table-column> |
| | | <el-table-column prop="releaseTime" label="发布时间" width="180" header-align="center" align="center"> |
| | | </el-table-column> |
| | | <el-table-column label="操作" align="conter"> |
| | | <template slot-scope="scope"> |
| | | <el-button type="text" size="medium" @click="details(scope.row.id)">详情</el-button> |
| | | <el-button type="text" size="medium" @click="punlish(scope.row.id, scope.row.status)" |
| | | :disabled="scope.row.status == 2"> |
| | | <span v-if="scope.row.status === 1" style="color:#ff0000">下架</span> |
| | | <span v-else>发布</span> |
| | | </el-button> |
| | | <el-button type="text" size="medium" @click="remove(scope.row.id)" style="color:#ff0000">删除 |
| | | </el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </template> |
| | | <el-pagination @current-change="handleCurrentChange" :current-page="queryInfo.current" :page-size="queryInfo.size" |
| | | layout="prev, pager, next" :total="total"></el-pagination> |
| | | </el-card> |
| | | |
| | | <!--添加公共宣传弹窗--> |
| | | <el-dialog title="公共宣传添加" :visible.sync="addPublicityVisibel" width="50%" :before-close="addPublicityClose" |
| | | :append-to-body="true"> |
| | | <el-row :gutter="15"> |
| | | <el-form ref="addPublicityForm" :model="addPublicityForm" :rules="rules" size="medium" label-width="100px"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="标题 " prop="publicityTitle"> |
| | | <el-input v-model="addPublicityForm.publicityTitle" clearable placeholder="请输入标题" |
| | | :style="{ width: '100%' }"></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="内容 " prop="content"> |
| | | <el-input v-model="addPublicityForm.content" type="textarea" placeholder="请输入公告内容" clearable |
| | | :autosize="{ minRows: 4, maxRows: 4 }" :style="{ width: '100%' }"></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-form> |
| | | </el-row> |
| | | <span slot="footer" class="dialog-footer"> |
| | | <el-button @click="addPublicityVisibel = false">取 消</el-button> |
| | | <el-button type="primary" @click="add">确 定</el-button> |
| | | </span> |
| | | </el-dialog> |
| | | |
| | | <!--公共宣传详情弹窗--> |
| | | <el-dialog title="公共宣传详情" :visible.sync="detailsVisible" width="50%" :append-to-body="true" |
| | | :before-close="detailsVisibleclose"> |
| | | |
| | | <el-row :gutter="15"> |
| | | <el-form ref="addGroupForm" :model="addGroupForm" size="medium" label-width="100px"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="标题" prop="effectiveEtime"> |
| | | <el-input v-model="detailsRow.publicityTitle" disabled></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="内容 " prop="text"> |
| | | <el-input v-model="detailsRow.text" type="textarea" placeholder="请输入公告内容" disabled |
| | | :autosize="{ minRows: 4, maxRows: 4 }" :style="{ width: '100%' }"></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <!-- <el-col :span="12"> |
| | | <el-form-item label="公告有效期" prop="effectiveStime"> |
| | | <el-date-picker v-model="detailsGroupAn.effectiveStime" type="datetime" placeholder="选择日期时间" disabled |
| | | :style="{ width: '100%' }" value-format="yyyy-MM-dd HH:mm:ss"> |
| | | </el-date-picker> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="至" prop="effectiveEtime"> |
| | | <el-date-picker v-model="detailsGroupAn.effectiveEtime" type="datetime" placeholder="选择日期时间" disabled |
| | | :style="{ width: '100%' }" value-format="yyyy-MM-dd HH:mm:ss"> |
| | | </el-date-picker> |
| | | </el-form-item> |
| | | </el-col> --> |
| | | <el-col :span="12"> |
| | | <el-form-item label="发布时间" prop="effectiveEtime"> |
| | | <el-date-picker v-model="detailsRow.releaseTime" type="datetime" placeholder="选择日期时间" disabled |
| | | :style="{ width: '100%' }" value-format="yyyy-MM-dd HH:mm:ss"> |
| | | </el-date-picker> |
| | | </el-form-item> |
| | | </el-col> |
| | | <!-- <el-col :span="12"> |
| | | <el-form-item label="创建人" prop="effectiveEtime"> |
| | | <el-input v-model="detailsGroupAn.createName" disabled></el-input> |
| | | </el-form-item> |
| | | </el-col> --> |
| | | <el-col :span="12"> |
| | | <el-form-item label="状态" prop="status"> |
| | | <span v-if="detailsRow.status === 1">已发布</span> |
| | | <span v-else-if="detailsRow.status === 0">未发布</span> |
| | | <span v-else="detailsRow.status === 2">已下架</span> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-form> |
| | | </el-row> |
| | | |
| | | |
| | | <!-- <div style="display:flex; width:180;"> |
| | | <div style="display:flex; width:180;"> |
| | | <h4>标题</h4> |
| | | <p>{{ detailsRow.publicityTitle }}</p> |
| | | </div> |
| | | <div style="display:flex; width:180;"> |
| | | <h4>内容</h4> |
| | | <p>{{ detailsRow.text }}</p> |
| | | </div> |
| | | <div style="display:flex; width:180;"> |
| | | <h4>创建时间</h4> |
| | | <p>{{ detailsRow.ctime }}</p> |
| | | </div> |
| | | </div> --> |
| | | |
| | | <!-- <el-table-column width="180" prop="effectiveStime" label="群组公告"></el-table-column> |
| | | <el-table-column width="120" prop="status" label="状态"> |
| | | <template slot-scope="scope"> |
| | | <span v-if="scope.row.status === 1">已发布</span> |
| | | <span v-else-if="scope.row.status === 0">未发布</span> |
| | | <span v-else="scope.row.status=== 2">已下架</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column width="100" prop="createName" label="创建人"></el-table-column> |
| | | <el-table-column width="180" prop="publishTime" label="发布时间"> |
| | | </el-table-column> --> |
| | | |
| | | </el-dialog> |
| | | |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import { |
| | | getPublicityList, |
| | | addPublicityList |
| | | } from '@/api/publicty' |
| | | |
| | | |
| | | export default { |
| | | name: "Publicity" |
| | | name: "Publicity", |
| | | data() { |
| | | return { |
| | | |
| | | |
| | | //详细内容弹框 |
| | | detailsVisible: false, |
| | | //详细内容 |
| | | detailsRow: [], |
| | | //表单提交内容 |
| | | addPublicityForm: { |
| | | publicityTitle: '', |
| | | text: '' |
| | | }, |
| | | //添加弹框 |
| | | addPublicityVisibel: false, |
| | | //序号当前页 |
| | | current: 1, |
| | | //序号数目 |
| | | size: 10, |
| | | //页面查询总数 |
| | | total: null, |
| | | //查询条件 |
| | | queryInfo: { |
| | | publicityTitle: '', |
| | | status: null, |
| | | current: 1, |
| | | size: 10 |
| | | }, |
| | | rules: { |
| | | publicityTitle: [{ |
| | | required: true, |
| | | message: '请输入标题 ', |
| | | trigger: 'blur' |
| | | }], |
| | | content: [{ |
| | | required: true, |
| | | message: '请输入内容 ', |
| | | trigger: 'blur' |
| | | }], |
| | | }, |
| | | |
| | | options: [ |
| | | { |
| | | value: null, |
| | | label: '全部' |
| | | }, |
| | | { |
| | | value: '0', |
| | | label: '未发布' |
| | | }, |
| | | { |
| | | value: '1', |
| | | label: '已发布' |
| | | } |
| | | , { |
| | | value: '2', |
| | | label: '下架 ' |
| | | } |
| | | ], |
| | | publicityList: [] |
| | | , |
| | | } |
| | | }, |
| | | created() { |
| | | this.init(); |
| | | |
| | | }, |
| | | methods: |
| | | { |
| | | //删除 |
| | | remove(val) { |
| | | this.$http.delete('/api/publicity/' + val).then(res => { |
| | | this.$message({ |
| | | message: '删除成功', |
| | | type: 'success' |
| | | }) |
| | | |
| | | this.search(); |
| | | }) |
| | | }, |
| | | //发布/下架 |
| | | punlish(val, val2) { |
| | | if (val2 == 0) { |
| | | this.$http.get('/api/publicity/release/' + val).then(res => { |
| | | this.$message({ |
| | | message: '发布成功', |
| | | type: 'success' |
| | | }) |
| | | |
| | | this.search(); |
| | | } |
| | | ) |
| | | } |
| | | if (val2 == 1) { |
| | | this.$http.get('/api/publicity/offline/' + val).then(res => { |
| | | this.$message({ |
| | | message: '下架成功', |
| | | type: 'success' |
| | | }) |
| | | this.search(); |
| | | } |
| | | ); |
| | | } |
| | | }, |
| | | |
| | | //详情 |
| | | details(val) { |
| | | this.detailsVisible = true; |
| | | this.$http.get('/api/publicity/' + val).then(res => this.detailsRow = res.data.data); |
| | | }, |
| | | //添加 |
| | | add() { |
| | | this.$refs.addPublicityForm.validate(async (vaild) => { |
| | | if (!vaild) return this.$message.error('输入有误') |
| | | let param = null; |
| | | param = this.addPublicityForm; |
| | | addPublicityList(param).then(res => { |
| | | this.$message({ |
| | | message: '操作成功', |
| | | type: 'success' |
| | | }); |
| | | this.addPublicityForm = {} |
| | | this.init(); |
| | | } |
| | | ) |
| | | this.addPublicityVisibel = false; |
| | | }) |
| | | }, |
| | | //关闭之前 |
| | | addPublicityClose() { |
| | | this.addPublicityVisibel = false; |
| | | }, |
| | | detailsVisibleclose() { |
| | | this.detailsVisible = false; |
| | | }, |
| | | //分页方法 |
| | | handleCurrentChange(val) { |
| | | this.queryInfo.current = val; |
| | | this.search(); |
| | | }, |
| | | //导入 |
| | | beforeAvatarUpload(file) { |
| | | let Xls = file.name.split('.'); |
| | | if (Xls[1] === 'xls' || Xls[1] === 'xlsx') { |
| | | return file |
| | | } else { |
| | | this.$message.error('上传文件只能是 xls/xlsx 格式!') |
| | | return false |
| | | } |
| | | }, |
| | | //导入成功 |
| | | respond(res) { |
| | | if (res.code == 200) { |
| | | this.$message({ |
| | | message: '上传成功', |
| | | type: 'success' |
| | | } |
| | | ) |
| | | } else { |
| | | this.$message({ |
| | | message: res.msg, |
| | | type: 'error' |
| | | }) |
| | | } |
| | | location.reload(); |
| | | }, |
| | | //公共宣传加载 |
| | | init() { |
| | | let param = {} |
| | | param.current = this.queryInfo.current |
| | | param.size = this.queryInfo.size |
| | | param.status = this.queryInfo.status !== null ? this.queryInfo.status : '' |
| | | getPublicityList(param).then(res => { |
| | | this.publicityList = res.records; |
| | | this.total = res.total |
| | | }) |
| | | }, |
| | | //查询 |
| | | search() { |
| | | let param = {} |
| | | param.publicityTitle = this.queryInfo.publicityTitle; |
| | | param.current = this.queryInfo.current |
| | | param.size = this.queryInfo.size |
| | | param.status = this.queryInfo.status !== null ? this.queryInfo.status : '' |
| | | getPublicityList(param).then(res => { |
| | | this.publicityList = res.records; |
| | | this.total = res.total |
| | | this.current = res.current |
| | | }) |
| | | }, |
| | | |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | ::v-deep(.el-table thead) { |
| | | color: #000000; |
| | | } |
| | | </style> |