525 lines
17 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="fullHeight whiteBlock">
<div class="pt_15 px_15">
<!-- 党员活动 -->
<el-form :inline="true" ref="searchForm" :model="searchForm" size="medium">
<el-form-item label="标题">
<el-input v-model="searchForm.title" placeholder="请输入"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" plain @click="getList">{{ $t('message.energyManage.waybill.query') }}</el-button>
<el-button type="warning" plain @click="refresh">{{ $t('message.deviceManage.refresh') }}</el-button>
<el-button
v-permission="{ key: 'add', menuPath: '/project/guidancePartyBuilding/thematicActivitie' }"
type="primary"
size="medium"
@click="add"
>新增</el-button
>
</el-form-item>
</el-form>
</div>
<div class="table_wrap whiteBlock">
<el-table class="tables" :data="List">
<el-table-column type="index" label="序号" align="center"></el-table-column>
<el-table-column prop="image" align="center" label="图片/视频">
<template slot-scope="scope">
<div v-for="item in scope.row.file" :key="item.uid">
<video
@click="dialogPoint(4, item)"
v-if="item.name.includes('.mp4')"
:width="$fontSize(50)"
:src="`${item.url}#t=1`"
preload="metadata"
></video>
<el-image style="width: 50px" v-else :preview-src-list="[item.url]" :src="item.url" />
</div>
</template>
</el-table-column>
<el-table-column prop="title" align="center" label="标题"></el-table-column>
<el-table-column prop="createDate" align="center" label="时间"></el-table-column>
<el-table-column prop="image" align="center" label="阅读状态">
<template slot-scope="scope">
{{ scope.row.isRead == 1 ? '已读' : '未读' }}
</template>
</el-table-column>
<el-table-column label="操作" align="center">
<template slot-scope="scope">
<div class="tableBtns">
<div
v-permission="{ key: 'detail', menuPath: '/project/guidancePartyBuilding/thematicActivitie' }"
class="operationText"
@click.stop="showDetailFn(scope.row)"
>
<i class="el-icon-tickets el-icon-tickets_up"></i>
<span>详情</span>
</div>
<div
v-permission="{ key: 'edit', menuPath: '/project/guidancePartyBuilding/thematicActivitie' }"
@click.stop="edit(scope.row)"
class="operationText"
>
<img src="@/assets/images/icon-edit.png" class="w_15 h_15" />
<span>编辑</span>
</div>
<div
v-permission="{ key: 'delete', menuPath: '/project/guidancePartyBuilding/thematicActivitie' }"
@click.stop="deleteDev(scope.row)"
class="operationText"
>
<img src="@/assets/images/icon-delete.png" class="w_15 h_15" />
<span>删除</span>
</div>
</div>
</template>
</el-table-column>
</el-table>
<el-pagination
class="pagerBox"
@size-change="SizeChange"
@current-change="CurrentChange"
:current-page="pagInfo.pageNo"
:page-sizes="$store.state.PAGESIZRS"
:page-size="pagInfo.pageSize"
layout="total, sizes, prev, pager, next"
:total="Number(pagInfo.total)"
background
></el-pagination>
</div>
<!-- 新增 -->
<el-dialog :modal-append-to-body="false" :title="title" :visible.sync="dialogShow" @close="close" class="dialog_w1200">
<div class="dialog_content">
<el-form size="medium" :model="addEditForm" ref="addEditForm" :rules="addEditRules" :label-width="$px2rem(80)" :inline="true">
<el-form-item label="标题" prop="title">
<el-input v-model="addEditForm.title" class="w_1000" placeholder="请输入标题"></el-input>
</el-form-item>
<!-- <el-form-item label="合作单位" prop="enterpriseIds">
<el-select multiple v-model="addEditForm.enterpriseIds"
:placeholder="$t('message.personnelPosition.please_select')" filterable>
<el-option :label="item.enterpriseName" :value="item.id" v-for="(item, index) in cooperatorList"
:key="index">
</el-option>
</el-select>
</el-form-item> -->
<el-form-item label="内容" prop="content" class="line_h_140">
<quill-editor
class="ql-editor w_1000 ml_12f mt_20f"
v-model="addEditForm.content"
ref="myQuillEditor"
:options="editorOption"
@blur="onEditorBlur($event)"
@focus="onEditorFocus($event)"
@change="onEditorChange($event)"
>
</quill-editor>
</el-form-item>
<el-form-item label="图片/视频" class="line_h_140">
<el-upload
:action="$store.state.UPLOADURL"
list-type="picture-card"
multiple
name="files"
:limit="1"
accept=".png, .jpg, .jpeg, .mp4"
:file-list="fileUplodList"
:on-success="(res, file) => handleSuccess(res, file)"
:on-remove="(file, fileList) => handleRemove(file, fileList)"
:on-exceed="handleExceed"
>
<i class="el-icon-plus"></i>
</el-upload>
</el-form-item>
</el-form>
<div class="dialog-footer">
<el-button class="cancleBtn" @click="dialogShow = false" icon="el-icon-circle-close" size="medium">取消 </el-button>
<el-button type="primary" icon="el-icon-circle-check" @click="submit" size="medium">确认 </el-button>
</div>
</div>
</el-dialog>
<!-- 详情 -->
<el-dialog :modal-append-to-body="false" title="详情" :visible.sync="dialogContent" class="dialog_w1200">
<div class="p_10_80">
<h1 style="text-align: center">{{ detailData.title }}</h1>
<div class="detailHeader">
<span>{{ detailData.createTime }}</span>
</div>
<div class="detailContent">
<div class="ql-editor" style="white-space: pre-wrap" v-html="detailData.content"></div>
</div>
<div class="dialog-footer">
<el-button type="primary" icon="el-icon-circle-check" @click="dialogContent = false" size="medium">确认 </el-button>
</div>
</div>
</el-dialog>
<!-- 新增 -->
<el-dialog
:destroy-on-close="true"
:modal-append-to-body="false"
:title="cardDialogTitle"
:visible.sync="cardDialog"
class="dialog_w900"
:before-close="handleClose"
>
<div class="dialog_content" v-if="dialogType == 4">
<iframe :src="previewUrl" width="100%" height="550px" frameborder="1"> </iframe>
</div>
</el-dialog>
<RoutingPopup v-if="routingInfo.routFlag" @fatherMethodRout="fatherMethodRout" :routingInfo="routingInfo" />
</div>
</template>
<script>
import VueQuillEditor from 'vue-quill-editor';
import 'quill/dist/quill.core.css';
import 'quill/dist/quill.snow.css';
import 'quill/dist/quill.bubble.css';
import {
getPartyBuildingGuidanceInfo,
addPartyBuildingGuidanceInfo,
editPartyBuildingGuidanceInfo,
isReadPartyBuildingGuidanceApi,
deletePartyBuildingGuidanceInfo
} from '@/assets/js/api/guidancePartyBuilding';
import { isJSON } from '@/util/nowDate';
import { getCooperatorListApi } from '@/assets/js/api/cooperationUnit';
import { encode } from 'js-base64';
export default {
components: {
VueQuillEditor
},
mounted() {
this.getList();
this.getCooperatorList();
},
data() {
return {
routingInfo: {
routFlag: false,
routName: ''
},
pagInfo: {
pageNo: 1, //页数
pageSize: 10, //条数
total: 0 //总条数
},
detailData: {},
dialogContent: false,
current: -1,
title: '',
dialogShow: false,
List: [],
addEditForm: {
title: '',
content: '',
file: '',
enterpriseIds: []
},
addEditRules: {
title: [
{
required: true,
message: '必填',
trigger: 'blur'
}
],
content: [
{
required: true,
message: '必填',
trigger: 'blur'
}
],
enterpriseIds: [
{
required: true,
message: '必选',
trigger: 'change'
}
]
},
searchForm: {
title: ''
},
fileUplodList: [],
editorOption: {
modules: {
toolbar: [
['bold', 'italic', 'underline', 'strike'], //加粗,斜体,下划线,删除线
['blockquote', 'code-block'], //引用,代码块
[{ header: 1 }, { header: 2 }], // 标题键值对的形式1、2表示字体大小
[{ list: 'ordered' }, { list: 'bullet' }], //列表
[{ script: 'sub' }, { script: 'super' }], // 上下标
[{ indent: '-1' }, { indent: '+1' }], // 缩进
[{ direction: 'rtl' }], // 文本方向
[{ size: ['small', false, 'large', 'huge'] }], // 字体大小
[{ header: [1, 2, 3, 4, 5, 6, false] }], //几级标题
[{ color: [] }, { background: [] }], // 字体颜色,字体背景颜色
[{ font: [] }], //字体
[{ align: [] }], //对齐方式
['clean'], //清除字体样式
['image'] //上传图片、上传视频
]
},
theme: 'snow'
},
cooperatorList: [],
previewUrl: '',
cardDialogTitle: '',
dialogType: -1, // 1 新增 2 二维码 3 人员 4 预览
cardDialog: false
};
},
methods: {
// 关闭前执行
handleClose(done) {
this.dialogType = -1;
this.cardDialog = false;
},
// 弹窗
dialogPoint(dialogType, row) {
this.dialogType = dialogType;
// this.cardDialog = true;
this.cardDialogTitle = '预览';
const videoList = ['.mp4', '.avi', '.wmv'];
const every = videoList.every(item => {
return row.name.indexOf(item) == -1;
});
console.log(every);
let src = row.url;
this.previewUrl = every ? `${this.$store.state.PREVIEWURL}?url=${encodeURIComponent(encode(src))}` : src;
console.log(this.previewUrl);
window.open(this.previewUrl, '_blank');
},
//获取列表数据
getCooperatorList() {
let data = {
projectSn: this.$store.state.projectSn,
pageNo: 1,
pageSize: -1
// enterpriseTypeId: this.enterpriseTypeSelectId,
};
getCooperatorListApi(data).then(res => {
if (res.code == 200) {
this.cooperatorList = res.result.records;
}
});
},
onEditorBlur() {
// 失去焦点事件
},
onEditorFocus() {
// 获得焦点事件
},
onEditorChange() {
this.$refs.addEditForm.clearValidate();
// 内容改变事件
},
//显示检查详细弹框
showDetailFn(row) {
this.detailData = row;
if (row.isRead != 1) {
isReadPartyBuildingGuidanceApi({
projectSn: this.$store.state.projectSn,
id: row.id
}).then(res => {
if (res.success) {
this.getList();
}
});
}
this.dialogContent = true;
},
handleExceed() {
this.$message.warning('文件超出最大限制,请删除上份文件!');
},
// 删除文件
handleRemove(file, fileList) {
this.fileUplodList = fileList;
},
handleSuccess(res, file, type) {
if (res.status == 'SUCCESS') {
this.fileUplodList.push({
name: file.name,
url: this.$store.state.FILEURL + file.response.data[0].imageUrl
});
}
},
//查询数据
getList() {
getPartyBuildingGuidanceInfo({
projectSn: this.$store.state.projectSn,
title: this.searchForm.title,
pageNo: this.pagInfo.pageNo,
pageSize: this.pagInfo.pageSize,
type: 2
}).then(result => {
if (result.success) {
// result.result.records.map(item => {
// if (item.file.includes('[')) {
// item.file = JSON.parse(item.file);
// if (item.file.length !== 0 && !item.file[0].url.includes(this.$store.state.FILEURL)) {
// item.file[0].url = this.$store.state.FILEURL + item.file[0].url;
// }
// } else {
// let url = item.file;
// if (url.length !== 0 && !url.includes(this.$store.state.FILEURL)) {
// item.file = [{}];
// item.file[0].url = this.$store.state.FILEURL + url;
// }
// }
// });
this.List = result.result.records.map(item => {
return {
...item,
file:
isJSON(item.file) && JSON.parse(item.file) instanceof Array
? JSON.parse(item.file).map(item => {
return {
...item,
url: item.url.includes(this.$store.state.FILEURL) ? item.url : this.$store.state.FILEURL + item.url
};
})
: []
};
});
this.pagInfo.total = result.result.total;
console.log(' this.List', this.List);
}
});
},
linkRouteWorkSpace() {
this.routingInfo.routFlag = true;
this.routingInfo.routName = '专题报道';
},
fatherMethodRout() {
this.routingInfo.routFlag = false;
},
add() {
if (this.$store.state.userInfo.accountType == 6) {
this.linkRouteWorkSpace();
return;
}
this.title = '新增';
this.dialogShow = true;
this.fileUplodList = [];
this.close();
},
edit(obj) {
this.title = '编辑';
this.dialogShow = true;
this.addEditForm = JSON.parse(JSON.stringify(obj));
// this.addEditForm.enterpriseIds = obj.enterpriseIds.split(",");
this.fileUplodList = obj.file;
},
submit() {
if (this.fileUplodList.length == 0) {
this.$message.error('请上传图片');
return false;
}
let params = JSON.parse(JSON.stringify(this.addEditForm));
params.projectSn = this.$store.state.projectSn;
params.type = 2;
params.file = JSON.stringify(this.fileUplodList);
// params.enterpriseIds = params.enterpriseIds.join(",");
this.$refs.addEditForm.validate(valid => {
if (valid) {
if (this.title == '新增') {
addPartyBuildingGuidanceInfo(params).then(result => {
if (result.success) {
this.$message.success(result.message);
this.getList();
}
});
} else if (this.title == '编辑') {
editPartyBuildingGuidanceInfo(params).then(result => {
if (result.success) {
this.$message.success(result.message);
this.getList();
}
});
}
this.dialogShow = false;
} else {
return false;
}
});
},
deleteDev(obj) {
this.$confirm('此操作将永久删除, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
deletePartyBuildingGuidanceInfo({ id: obj.id }).then(res => {
if (res.success) {
this.getList();
this.$message({
type: 'success',
message: '删除成功!'
});
} else {
this.$message({
type: 'error',
message: res.message
});
}
});
})
.catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
},
close() {
this.fileUplodList = [];
this.addEditForm = {};
this.$nextTick(() => {
this.$refs.addEditForm.clearValidate();
});
},
SizeChange(val) {
this.pagInfo.pageSize = val;
this.getList();
},
CurrentChange(val) {
this.pagInfo.pageNo = val;
this.getList();
},
refresh() {
this.searchForm = {};
this.pagInfo.pageNo = 1; //页数
this.pagInfo.pageSize = 10; //条数
this.getList();
}
}
};
</script>
<style lang="less" scoped>
.detailContent {
/deep/ img {
width: 100%;
}
}
.detailHeader {
text-align: center;
padding: 20px;
span {
color: #ccc;
font-size: 12px;
margin-right: 20px;
}
}
</style>