web-base-admin/src/views/siteConfiguration/companyNews.vue

453 lines
12 KiB
Vue
Raw Normal View History

2025-03-23 09:18:42 +08:00
<!--
* @Descripttion:
* @version:
* @Author: kBank
* @Date: 2022-10-24 15:45:01
-->
<template>
<div class="page">
<topBar v-if="topList.length > 0"
:topList="topList"
:moren="moren"></topBar>
<div class="main">
<div class="form_all">
<el-form ref="select"
:model="select"
label-width="auto">
<el-row :gutter="10">
<el-col :span="4" style="margin-left:-25px">
2025-04-01 23:46:26 +08:00
<el-form-item :label="'标题'">
2025-03-23 09:18:42 +08:00
<el-input clearable
v-model="select.titleName"></el-input>
</el-form-item>
</el-col>
<el-col :span="8">
2025-04-01 23:46:26 +08:00
<el-form-item :label="'创建日期'">
2025-03-23 09:18:42 +08:00
<el-date-picker v-model="creationTime"
@change="changeTime"
value-format="yyyy-MM-dd"
type="daterange"
2025-04-01 23:46:26 +08:00
:range-separator="'至'"
:start-placeholder="'开始日期'"
:end-placeholder="'结束日期'">
2025-03-23 09:18:42 +08:00
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="8">
2025-04-01 23:46:26 +08:00
<el-form-item :label="'生效日期'">
2025-03-23 09:18:42 +08:00
<el-date-picker v-model="creationTime1"
@change="changeTime1"
value-format="yyyy-MM-dd"
type="daterange"
2025-04-01 23:46:26 +08:00
:range-separator="'至'"
:start-placeholder="'开始日期'"
:end-placeholder="'结束日期'">
2025-03-23 09:18:42 +08:00
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="4">
<el-button type="primary"
2025-04-01 23:46:26 +08:00
@click="getDataList"> {{ '搜索' }}</el-button>
<el-button type="primary" class="resetBtn" @click="reset"> {{ '重置' }}</el-button>
2025-03-23 09:18:42 +08:00
</el-col>
</el-row>
</el-form>
</div>
<div class="maintop">
<div class="mainbtn">
<el-button size="small"
@click="openDig"
v-hasButtons="['CompanyNewsAdd']"
2025-04-01 23:46:26 +08:00
class="addBtn">{{'添加'}}</el-button>
2025-03-23 09:18:42 +08:00
<el-button size="small"
@click="handleExport"
v-hasButtons="['CompanyNewsExport']"
2025-04-01 23:46:26 +08:00
class="exportBtn"> {{ '导出' }}</el-button>
2025-03-23 09:18:42 +08:00
</div>
</div>
<div class="maintable">
<el-table :data="tableData"
v-loading="loading"
style="width: 100%"
:header-cell-style="{ background: '#EEEEEE' }"
:row-class-name="tableRowClassName"
@selection-change="handleSelectionChange">
<el-table-column type="selection"
width="55"> </el-table-column>
<el-table-column align="center"
prop="sort"
2025-04-01 23:46:26 +08:00
:label="'排序'"> </el-table-column>
2025-03-23 09:18:42 +08:00
<el-table-column align="center"
prop="titleName"
2025-04-01 23:46:26 +08:00
:label="'标题'"> </el-table-column>
2025-03-23 09:18:42 +08:00
<el-table-column align="center"
prop=""
2025-04-01 23:46:26 +08:00
:label="'图片'">
2025-03-23 09:18:42 +08:00
<template slot-scope="scope">
<div class="img">
<img :src="scope.row.picture"
alt="">
</div>
</template>
</el-table-column>
<el-table-column align="center"
prop="creationTime"
2025-04-01 23:46:26 +08:00
:label="'创建日期'">
2025-03-23 09:18:42 +08:00
</el-table-column>
<el-table-column align="center"
prop="effectiveDate"
2025-04-01 23:46:26 +08:00
:label="'生效日期'">
2025-03-23 09:18:42 +08:00
</el-table-column>
<el-table-column align="center"
prop="time"
2025-04-01 23:46:26 +08:00
:label="'操作'"
2025-03-23 09:18:42 +08:00
fixed="right">
<template slot-scope="scope">
<el-button @click="toFixed(scope.row.pkId)"
type="text" style="color:#F3A900"
v-hasButtons="['CompanyNewsUpdate']"
size="small">
2025-04-01 23:46:26 +08:00
{{'修改'}}
2025-03-23 09:18:42 +08:00
</el-button>
<el-button @click="handleDelete(scope.row.pkId)"
type="text"
v-hasButtons="['CompanyNewsDelete']"
size="small"
style="color: #C8161D">
2025-04-01 23:46:26 +08:00
{{'删除'}}
2025-03-23 09:18:42 +08:00
</el-button>
</template>
</el-table-column>
</el-table>
</div>
</div>
<pagination v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getDataList" />
</div>
</template>
<script>
import topBar from '@/components/topBar'
import * as api from '@/api/site.js'
import { classifyUpdate, classifySave } from '@/api/product'
import ImageUpload from '@/components/ImageUpload'
export default {
name: 'Bzpz',
components: {
topBar,
ImageUpload,
},
filters: {
isAgree(val) {
if (!val) {
2025-04-01 23:46:26 +08:00
return '允许';
2025-03-23 09:18:42 +08:00
} else {
2025-04-01 23:46:26 +08:00
return '禁止';
2025-03-23 09:18:42 +08:00
}
},
},
data() {
return {
typeList: [
{
value: 0,
2025-04-01 23:46:26 +08:00
label: '前台',
2025-03-23 09:18:42 +08:00
},
{
value: 1,
2025-04-01 23:46:26 +08:00
label: '后台',
2025-03-23 09:18:42 +08:00
},
],
digList: [
{
value: 0,
2025-04-01 23:46:26 +08:00
label: '允许',
2025-03-23 09:18:42 +08:00
},
{
value: 1,
2025-04-01 23:46:26 +08:00
label: '禁止',
2025-03-23 09:18:42 +08:00
},
],
creationTime: [],
creationTime1: [],
select: {},
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 50,
},
addOrEdit: '',
total: 0,
dialogVisible: false,
tableData: [],
loading:false,
moren: 'companyNews',
topList: [
{
2025-04-01 23:46:26 +08:00
name: '公司新闻',
2025-03-23 09:18:42 +08:00
path: 'companyNews',
},
{
2025-04-01 23:46:26 +08:00
name: '分公司风采',
2025-03-23 09:18:42 +08:00
path: 'companyFeng',
},
],
form: {
sort: '',
creationTime: '',
picture: '',
},
rules: {
2025-04-01 23:46:26 +08:00
name: [{ required: true, message: '请输入规格类型', trigger: 'blur' }],
2025-03-23 09:18:42 +08:00
},
webList: [],
localList: [],
popList: [],
gradeList: [],
stateList: [],
}
},
mounted() {
// 获取下拉
// this.getData()
// 获取列表
this.getDataList()
},
methods: {
reset(){
this.select = {}
this.creationTime = []
this.creationTime1 = []
this.getDataList()
},
upList(id) {
api.moveUp({ pkId: id }).then((res) => {
this.getDataList()
})
},
downList(id) {
api.moveDown({ pkId: id }).then((res) => {
this.getDataList()
})
},
toTopList(id) {
api.updateTopping({ pkId: id }).then((res) => {
this.getDataList()
})
},
getData() {
api.noticeWebsite().then((res) => {
this.webList = res.data
})
api.noticeLocation().then((res) => {
this.localList = res.data
})
api.noticePopup().then((res) => {
this.popList = res.data
})
api.noticeGrade().then((res) => {
this.gradeList = res.data
})
api.noticeState().then((res) => {
this.stateList = res.data
})
},
changeTime(val) {
this.select.startDate = val?val[0]:''
this.select.endDate = val?val[1]:''
},
changeTime1(val) {
this.select.startEffectDate = val?val[0]:''
this.select.endEffectDate = val?val[1]:''
},
// 点击修改
toFixed(id) {
this.$router.push({
path: 'companyDetails',
query: {
pkId: id,
news:true
},
})
},
// 删除
handleDelete(id) {
2025-04-01 23:46:26 +08:00
this.$confirm('确认删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
2025-03-23 09:18:42 +08:00
type: 'warning',
}).then(() => {
api.newsDel(id).then((res) => {
this.getDataList()
})
})
},
onSubmit(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
let url = ''
if (this.addOrEdit == true) {
url = api.honorSave
} else {
url = api.honorUpdate
}
url(this.form).then((res) => {
if (res.code == 200) {
this.$message({
message: res.msg,
type: 'success',
})
this.dialogVisible = false
// 充值数据
this.$refs[formName].resetFields()
// 获取列表
this.getDataList()
}
})
} else {
return false
}
})
},
handleClose() {
this.dialogVisible = false
this.form = {}
this.$refs['form'].clearValidate()
this.$refs['form'].resetFields()
},
openDig() {
this.$router.push({
path: 'companyDetails',
})
},
getDataList() {
this.loading = true
api
.newsList(Object.assign({}, this.queryParams, this.select))
.then((res) => {
this.tableData = res.rows
this.total = res.total
this.loading = false
})
},
handleSelectionChange(val) {},
/** 导出按钮操作 */
handleExport() {
2025-04-01 23:46:26 +08:00
this.$confirm( '是否确认导出所有数据项?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
2025-03-23 09:18:42 +08:00
type: 'warning',
}).then((_) => {
this.download(
'/system/manage/ho-enterprise-news/export',
Object.assign({}, this.queryParams, this.select),
2025-04-01 23:46:26 +08:00
`${'公司新闻'}${new Date().getTime()}.xlsx`
2025-03-23 09:18:42 +08:00
)
})
},
tableRowClassName({ row, rowIndex }) {
if (rowIndex % 2 == 1) {
return 'warning-row'
} else if (rowIndex % 2 == 0) {
return 'success-row'
}
return ''
},
},
}
</script>
<style scoped lang="scss">
::v-deep .el-table .warning-row {
background: #f9f9f9;
}
::v-deep .el-table .success-row {
background: #ffffff;
}
::v-deep .el-table thead {
color: #000000;
}
::v-deep .el-select {
width: 100%;
}
.uploadIcon ::v-deep .el-upload--picture-card {
display: none !important; /* 上传按钮隐藏 */
}
.page {
padding: 20px;
background: #f9f9f9;
font-size: 14px;
.main {
background: #ffffff;
border-radius: 8px;
box-shadow: 0px 2px 20px 0px rgba(238, 238, 238, 0.5);
.maintop {
display: flex;
padding: 0px 0px;
justify-content: space-between;
align-items: center;
background: #f8f8f8;
.mainbtn {
.thebtn1 {
background: #3181e5;
color: #ffffff;
}
.thebtn2 {
background: #ffad41;
color: #ffffff;
}
}
.maintitle {
font-size: 10px;
font-family: MicrosoftYaHei;
color: #999999;
}
}
}
.tem {
display: flex;
align-items: center;
justify-content: center;
img {
width: 28px;
height: 20px;
margin-right: 3px;
}
}
.isRed {
color: #ed1d25;
}
.isGreen {
color: #1ab62b;
}
.bgImg {
width: 48px;
height: 48px;
}
}
.openClose {
text-align: right;
margin-right: 10px;
color: #3181e5;
}
.img {
img {
width: 44px;
height: 44px;
}
}
::v-deep .el-date-editor--daterange {
width: 100%;
}
.form_all{
padding: 0 20px;
}
</style>