404 lines
13 KiB
Vue
404 lines
13 KiB
Vue
<template>
|
||
<div class="fullHeight whiteBlock">
|
||
<div style="padding: 15px 15px 0">
|
||
<!-- 党员活动 -->
|
||
<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 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">
|
||
<img :preview="scope.row.image[0] ? scope.row.image[0].url : []"
|
||
:src="scope.row.image[0] ? scope.row.image[0].url : []" alt="" width="50px" />
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column prop="title" align="center" label="标题"></el-table-column>
|
||
<el-table-column prop="createTime" align="center" label="时间"></el-table-column>
|
||
<el-table-column label="操作" align="center">
|
||
<template slot-scope="scope">
|
||
<div class="tableBtns" style="margin-left: 110px !important">
|
||
<div class="operationText" @click.stop="showDetailFn(scope.row)">
|
||
<i class="el-icon-tickets" style="color: #8dacfa; font-size: 16px; margin-right: 2px"></i>
|
||
<span>详情</span>
|
||
</div>
|
||
<div @click.stop="edit(scope.row)" class="operationText">
|
||
<img src="@/assets/images/icon-edit.png" width="15px" height="15px" />
|
||
<span>编辑</span>
|
||
</div>
|
||
<div @click.stop="deleteDev(scope.row)" class="operationText">
|
||
<img src="@/assets/images/icon-delete.png" width="15px" height="15px" />
|
||
<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" width="1200px">
|
||
<div class="dialog_content">
|
||
<el-form size="medium" :model="addEditForm" ref="addEditForm" :rules="addEditRules" label-width="80px"
|
||
:inline="true">
|
||
<el-form-item label="标题" prop="title">
|
||
<el-input v-model="addEditForm.title" style="width: 1000px" 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" style="line-height: 140px">
|
||
<quill-editor class="ql-editor" style="width: 1025px; margin-left: -15px; margin-top: -20px"
|
||
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="图片" style="line-height: 140px">
|
||
<el-upload :action="$store.state.UPLOADURL" list-type="picture-card" multiple name="files" :limit="1"
|
||
accept=".png, .jpg, .jpeg" :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" width="1200px">
|
||
<div style="padding: 10px 80px">
|
||
<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>
|
||
</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 {
|
||
getSceneExposePage,
|
||
setSceneExposeAdd,
|
||
setSceneExposeEdit,
|
||
setSceneExposeDelete,
|
||
} from "@/assets/js/api/project";
|
||
import {
|
||
getCooperatorListApi
|
||
} from '@/assets/js/api/cooperationUnit'
|
||
export default {
|
||
components: {
|
||
VueQuillEditor,
|
||
},
|
||
mounted() {
|
||
this.getList();
|
||
this.getCooperatorList();
|
||
},
|
||
data() {
|
||
return {
|
||
pagInfo: {
|
||
pageNo: 1, //页数
|
||
pageSize: 10, //条数
|
||
total: 0, //总条数
|
||
},
|
||
detailData: {},
|
||
dialogContent: false,
|
||
current: -1,
|
||
title: "",
|
||
dialogShow: false,
|
||
List: [],
|
||
addEditForm: {
|
||
title: "",
|
||
content: "",
|
||
image: "",
|
||
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: [],
|
||
};
|
||
},
|
||
methods: {
|
||
//获取列表数据
|
||
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;
|
||
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() {
|
||
getSceneExposePage({
|
||
projectSn: this.$store.state.projectSn,
|
||
title: this.searchForm.title,
|
||
pageNo: this.pagInfo.pageNo,
|
||
pageSize: this.pagInfo.pageSize,
|
||
type: 1,
|
||
}).then((result) => {
|
||
if (result.success) {
|
||
result.result.records.map((item) => {
|
||
if (item.image.includes("[")) {
|
||
item.image = JSON.parse(item.image);
|
||
if (
|
||
item.image.length !== 0 &&
|
||
!item.image[0].url.includes(this.$store.state.FILEURL)
|
||
) {
|
||
item.image[0].url =
|
||
this.$store.state.FILEURL + item.image[0].url;
|
||
}
|
||
} else {
|
||
let url = item.image;
|
||
|
||
if (
|
||
url.length !== 0 &&
|
||
!url.includes(this.$store.state.FILEURL)
|
||
) {
|
||
item.image = [{}];
|
||
item.image[0].url = this.$store.state.FILEURL + url;
|
||
}
|
||
}
|
||
});
|
||
this.List = result.result.records;
|
||
this.pagInfo.total = result.result.total;
|
||
console.log(" this.List", this.List);
|
||
}
|
||
});
|
||
},
|
||
|
||
add() {
|
||
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.image;
|
||
},
|
||
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 = 1;
|
||
params.image = JSON.stringify(this.fileUplodList);
|
||
// params.enterpriseIds = params.enterpriseIds.join(",");
|
||
this.$refs.addEditForm.validate((valid) => {
|
||
if (valid) {
|
||
if (this.title == "新增") {
|
||
setSceneExposeAdd(params).then((result) => {
|
||
if (result.success) {
|
||
this.$message.success(result.message);
|
||
this.getList();
|
||
}
|
||
});
|
||
} else if (this.title == "编辑") {
|
||
setSceneExposeEdit(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(() => {
|
||
setSceneExposeDelete({ 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>
|
||
.detailHeader {
|
||
text-align: center;
|
||
padding: 20px;
|
||
|
||
span {
|
||
color: #ccc;
|
||
font-size: 12px;
|
||
margin-right: 20px;
|
||
}
|
||
}
|
||
</style>
|