|
|
|
@ -0,0 +1,449 @@
|
|
|
|
|
<template>
|
|
|
|
|
<div class="app-container">
|
|
|
|
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
|
|
|
|
<el-form-item label="案例标题" prop="caseInfoTitle">
|
|
|
|
|
<el-input v-model="form.caseInfoTitle" placeholder="请输入案例标题" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="配置类型" prop="configTypeId">
|
|
|
|
|
<treeselect v-model="form.configTypeId" :options="editedConfigTypeOptions" :show-count="true"
|
|
|
|
|
placeholder="请选择门户网站配置类型"/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="典型案例标识" prop="typicalFlag">
|
|
|
|
|
<el-select v-model="form.typicalFlag" placeholder="请选择配典型案例标识" style="width: 300px;">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="dict in dict.type.hw_product_case_info_typical_flag"
|
|
|
|
|
:key="dict.value"
|
|
|
|
|
:label="dict.label"
|
|
|
|
|
:value="dict.value"
|
|
|
|
|
></el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="案例内容" prop="caseInfoDesc">
|
|
|
|
|
<el-input v-model="form.caseInfoDesc" type="textarea" placeholder="请输入内容" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="案例内容图片" prop="caseInfoPic">
|
|
|
|
|
<el-upload
|
|
|
|
|
single
|
|
|
|
|
:action="uploadImgUrl"
|
|
|
|
|
list-type="picture-card"
|
|
|
|
|
:limit="limit"
|
|
|
|
|
:on-success="handleUploadSuccess"
|
|
|
|
|
:before-upload="handleBeforeUpload"
|
|
|
|
|
:on-error="handleUploadError"
|
|
|
|
|
:on-exceed="handleExceed"
|
|
|
|
|
ref="imageUpload"
|
|
|
|
|
:on-remove="handleDeletePicture"
|
|
|
|
|
:show-file-list="true"
|
|
|
|
|
:headers="headers"
|
|
|
|
|
:file-list="fileList"
|
|
|
|
|
:on-preview="handlePictureCardPreview"
|
|
|
|
|
:class="{hide: this.fileList.length >= 1}"
|
|
|
|
|
>
|
|
|
|
|
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>
|
|
|
|
|
<i class="el-icon-plus"></i>
|
|
|
|
|
</el-upload>
|
|
|
|
|
|
|
|
|
|
<!-- 上传提示 -->
|
|
|
|
|
<div class="el-upload__tip" slot="tip">
|
|
|
|
|
请上传
|
|
|
|
|
<template v-if="fileSize"> 大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b></template>
|
|
|
|
|
<template v-if="fileType"> 格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b></template>
|
|
|
|
|
的文件
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<el-dialog
|
|
|
|
|
:visible.sync="dialogVisible"
|
|
|
|
|
title="预览"
|
|
|
|
|
width="800"
|
|
|
|
|
append-to-body
|
|
|
|
|
>
|
|
|
|
|
<img
|
|
|
|
|
:src="dialogImageUrl"
|
|
|
|
|
style="display: block; max-width: 100%; margin: 0 auto"
|
|
|
|
|
/>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
<el-form-item label="案例详情" prop="caseInfoHtml">
|
|
|
|
|
<editor v-model="form.caseInfoHtml" :min-height="192"/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
|
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
|
|
|
|
<el-button @click="close">取 消</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import { listProductCaseInfo, getProductCaseInfo, delProductCaseInfo, addProductCaseInfo, updateProductCaseInfo,portalConfigTypeTree } from "@/api/portal/productCaseInfo";
|
|
|
|
|
import {getToken} from "@/utils/auth";
|
|
|
|
|
import Treeselect from "@riophae/vue-treeselect";
|
|
|
|
|
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
|
|
|
|
import {debug} from "script-ext-html-webpack-plugin/lib/common";
|
|
|
|
|
export default {
|
|
|
|
|
name: "ProductCaseInfo",
|
|
|
|
|
dicts: ['hw_product_case_info_typical_flag'],
|
|
|
|
|
components: {Treeselect},
|
|
|
|
|
props: {
|
|
|
|
|
value: [String, Object, Array],
|
|
|
|
|
// 图片数量限制
|
|
|
|
|
limit: {
|
|
|
|
|
type: Number,
|
|
|
|
|
default: 1,
|
|
|
|
|
},
|
|
|
|
|
// 大小限制(MB)
|
|
|
|
|
fileSize: {
|
|
|
|
|
type: Number,
|
|
|
|
|
default: 5,
|
|
|
|
|
},
|
|
|
|
|
// 文件类型, 例如['png', 'jpg', 'jpeg']
|
|
|
|
|
fileType: {
|
|
|
|
|
type: Array,
|
|
|
|
|
default: () => ["png", "jpg", "jpeg"],
|
|
|
|
|
},
|
|
|
|
|
// 是否显示提示
|
|
|
|
|
isShowTip: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: true
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
// 遮罩层
|
|
|
|
|
loading: true,
|
|
|
|
|
// 选中数组
|
|
|
|
|
ids: [],
|
|
|
|
|
// 非单个禁用
|
|
|
|
|
single: true,
|
|
|
|
|
// 非多个禁用
|
|
|
|
|
multiple: true,
|
|
|
|
|
// 显示搜索条件
|
|
|
|
|
showSearch: true,
|
|
|
|
|
// 总条数
|
|
|
|
|
total: 0,
|
|
|
|
|
// 案例内容表格数据
|
|
|
|
|
productCaseInfoList: [],
|
|
|
|
|
// 弹出层标题
|
|
|
|
|
title: "",
|
|
|
|
|
// 是否显示弹出层
|
|
|
|
|
open: false,
|
|
|
|
|
// 查询参数
|
|
|
|
|
queryParams: {
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
caseInfoTitle: null,
|
|
|
|
|
configTypeId: null,
|
|
|
|
|
typicalFlag: null,
|
|
|
|
|
caseInfoDesc: null,
|
|
|
|
|
caseInfoPic: null,
|
|
|
|
|
caseInfoHtml: null,
|
|
|
|
|
},
|
|
|
|
|
// 表单参数
|
|
|
|
|
form: {},
|
|
|
|
|
// 表单校验
|
|
|
|
|
rules: {
|
|
|
|
|
caseInfoTitle: [
|
|
|
|
|
{ required: true, message: "案例标题不能为空", trigger: "blur" }
|
|
|
|
|
],
|
|
|
|
|
typicalFlag: [
|
|
|
|
|
{ required: true, message: "典型案例标识不能为空", trigger: "blur" }
|
|
|
|
|
],
|
|
|
|
|
caseInfoDesc: [
|
|
|
|
|
{ required: true, message: "案例内容不能为空", trigger: "blur" }
|
|
|
|
|
],
|
|
|
|
|
caseInfoHtml: [
|
|
|
|
|
{ required: true, message: "案例详情不能为空", trigger: "blur" }
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
number: 0,
|
|
|
|
|
uploadList: [],
|
|
|
|
|
dialogImageUrl: "",
|
|
|
|
|
dialogVisible: false,
|
|
|
|
|
hideUpload: false,
|
|
|
|
|
uploadImgUrl: process.env.VUE_APP_BASE_API + "/file/upload", // 上传的图片服务器地址
|
|
|
|
|
headers: {
|
|
|
|
|
Authorization: "Bearer " + getToken(),
|
|
|
|
|
},
|
|
|
|
|
fileList: [],
|
|
|
|
|
|
|
|
|
|
//查询页面门户网站配置类型树页面
|
|
|
|
|
configTypeOptions: [],
|
|
|
|
|
//编辑页面门户网站配置类型树页面
|
|
|
|
|
editedConfigTypeOptions: [],
|
|
|
|
|
// 门户网站配置类型名称
|
|
|
|
|
portalConfigTypeName: undefined,
|
|
|
|
|
defaultProps: {
|
|
|
|
|
children: "children",
|
|
|
|
|
label: "label"
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
|
const caseInfoId = this.$route.params && this.$route.params.caseInfoId;
|
|
|
|
|
if(caseInfoId && caseInfoId!=='0'){
|
|
|
|
|
this.getEditPortalConfigTypeTree();
|
|
|
|
|
getProductCaseInfo(caseInfoId).then(response => {
|
|
|
|
|
this.form = response.data;
|
|
|
|
|
this.form.caseInfoHtml = decodeURI(this.form.caseInfoHtml)
|
|
|
|
|
console.log(this.form.caseInfoHtml)
|
|
|
|
|
if (response.data.caseInfoPic != null) {
|
|
|
|
|
let previewFile = {};
|
|
|
|
|
previewFile.url = response.data.caseInfoPic
|
|
|
|
|
this.fileList.push(previewFile);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}else{
|
|
|
|
|
this.reset();
|
|
|
|
|
this.getEditPortalConfigTypeTree();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
activated() {
|
|
|
|
|
const caseInfoId = this.$route.params && this.$route.params.caseInfoId;
|
|
|
|
|
if(caseInfoId && caseInfoId!=='0'){
|
|
|
|
|
this.getEditPortalConfigTypeTree();
|
|
|
|
|
getProductCaseInfo(caseInfoId).then(response => {
|
|
|
|
|
this.form = response.data;
|
|
|
|
|
this.form.caseInfoHtml = decodeURI(this.form.caseInfoHtml)
|
|
|
|
|
console.log(this.form.caseInfoHtml)
|
|
|
|
|
if (response.data.caseInfoPic != null) {
|
|
|
|
|
let previewFile = {};
|
|
|
|
|
previewFile.url = response.data.caseInfoPic
|
|
|
|
|
this.fileList.push(previewFile);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}else{
|
|
|
|
|
this.reset();
|
|
|
|
|
this.getEditPortalConfigTypeTree();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
/** 查询案例内容列表 */
|
|
|
|
|
getList() {
|
|
|
|
|
this.loading = true;
|
|
|
|
|
listProductCaseInfo(this.queryParams).then(response => {
|
|
|
|
|
this.productCaseInfoList = response.rows;
|
|
|
|
|
this.total = response.total;
|
|
|
|
|
this.loading = false;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
// 取消按钮
|
|
|
|
|
cancel() {
|
|
|
|
|
this.open = false;
|
|
|
|
|
this.reset();
|
|
|
|
|
},
|
|
|
|
|
// 表单重置
|
|
|
|
|
reset() {
|
|
|
|
|
this.form = {
|
|
|
|
|
caseInfoId: null,
|
|
|
|
|
caseInfoTitle: null,
|
|
|
|
|
configTypeId: null,
|
|
|
|
|
typicalFlag: null,
|
|
|
|
|
caseInfoDesc: null,
|
|
|
|
|
caseInfoPic: null,
|
|
|
|
|
caseInfoHtml: null,
|
|
|
|
|
createTime: null,
|
|
|
|
|
createBy: null,
|
|
|
|
|
updateTime: null,
|
|
|
|
|
updateBy: null
|
|
|
|
|
};
|
|
|
|
|
this.resetForm("form");
|
|
|
|
|
this.fileList = [];
|
|
|
|
|
},
|
|
|
|
|
/** 搜索按钮操作 */
|
|
|
|
|
handleQuery() {
|
|
|
|
|
this.queryParams.pageNum = 1;
|
|
|
|
|
},
|
|
|
|
|
/** 重置按钮操作 */
|
|
|
|
|
resetQuery() {
|
|
|
|
|
this.resetForm("queryForm");
|
|
|
|
|
this.handleQuery();
|
|
|
|
|
},
|
|
|
|
|
// 多选框选中数据
|
|
|
|
|
handleSelectionChange(selection) {
|
|
|
|
|
this.ids = selection.map(item => item.caseInfoId)
|
|
|
|
|
this.single = selection.length!==1
|
|
|
|
|
this.multiple = !selection.length
|
|
|
|
|
},
|
|
|
|
|
/** 新增按钮操作 */
|
|
|
|
|
handleAdd() {
|
|
|
|
|
this.reset();
|
|
|
|
|
this.getEditPortalConfigTypeTree();
|
|
|
|
|
this.open = true;
|
|
|
|
|
this.title = "添加案例内容";
|
|
|
|
|
},
|
|
|
|
|
/** 修改按钮操作 */
|
|
|
|
|
handleUpdate(row) {
|
|
|
|
|
this.reset();
|
|
|
|
|
this.getEditPortalConfigTypeTree();
|
|
|
|
|
const caseInfoId = row.caseInfoId || this.ids
|
|
|
|
|
getProductCaseInfo(caseInfoId).then(response => {
|
|
|
|
|
this.form = response.data;
|
|
|
|
|
this.form.caseInfoHtml = decodeURI(this.form.caseInfoHtml)
|
|
|
|
|
this.open = true;
|
|
|
|
|
this.title = "修改案例内容";
|
|
|
|
|
if (response.data.caseInfoPic != null) {
|
|
|
|
|
let previewFile = {};
|
|
|
|
|
previewFile.url = response.data.caseInfoPic
|
|
|
|
|
this.fileList.push(previewFile);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
/** 提交按钮 */
|
|
|
|
|
submitForm() {
|
|
|
|
|
this.$refs["form"].validate(valid => {
|
|
|
|
|
if (valid) {
|
|
|
|
|
this.form.caseInfoHtml = encodeURI(this.form.caseInfoHtml)
|
|
|
|
|
if (this.form.caseInfoId != null) {
|
|
|
|
|
updateProductCaseInfo(this.form).then(response => {
|
|
|
|
|
this.$modal.msgSuccess("修改成功");
|
|
|
|
|
this.close();
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
this.form.caseInfoHtml = encodeURI(this.form.caseInfoHtml);
|
|
|
|
|
addProductCaseInfo(this.form).then(response => {
|
|
|
|
|
this.$modal.msgSuccess("新增成功");
|
|
|
|
|
this.close();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
/** 删除按钮操作 */
|
|
|
|
|
handleDelete(row) {
|
|
|
|
|
const caseInfoIds = row.caseInfoId || this.ids;
|
|
|
|
|
this.$modal.confirm('是否确认删除案例内容编号为"' + caseInfoIds + '"的数据项?').then(function() {
|
|
|
|
|
return delProductCaseInfo(caseInfoIds);
|
|
|
|
|
}).then(() => {
|
|
|
|
|
this.getList();
|
|
|
|
|
this.$modal.msgSuccess("删除成功");
|
|
|
|
|
}).catch(() => {});
|
|
|
|
|
},
|
|
|
|
|
/** 导出按钮操作 */
|
|
|
|
|
handleExport() {
|
|
|
|
|
this.download('portal/productCaseInfo/export', {
|
|
|
|
|
...this.queryParams
|
|
|
|
|
}, `productCaseInfo_${new Date().getTime()}.xlsx`)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**上传图片处理*/
|
|
|
|
|
// 上传前loading加载
|
|
|
|
|
handleBeforeUpload(file) {
|
|
|
|
|
let isImg = false;
|
|
|
|
|
if (this.fileType.length) {
|
|
|
|
|
let fileExtension = "";
|
|
|
|
|
if (file.name.lastIndexOf(".") > -1) {
|
|
|
|
|
fileExtension = file.name.slice(file.name.lastIndexOf(".") + 1);
|
|
|
|
|
}
|
|
|
|
|
isImg = this.fileType.some(type => {
|
|
|
|
|
if (file.type.indexOf(type) > -1) return true;
|
|
|
|
|
if (fileExtension && fileExtension.indexOf(type) > -1) return true;
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
isImg = file.type.indexOf("image") > -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isImg) {
|
|
|
|
|
this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}图片格式文件!`);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (this.fileSize) {
|
|
|
|
|
const isLt = file.size / 1024 / 1024 < this.fileSize;
|
|
|
|
|
if (!isLt) {
|
|
|
|
|
this.$modal.msgError(`上传头像图片大小不能超过 ${this.fileSize} MB!`);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.$modal.loading("正在上传图片,请稍候...");
|
|
|
|
|
this.number++;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 文件个数超出
|
|
|
|
|
handleExceed() {
|
|
|
|
|
this.$modal.msgError(`上传文件数量不能超过 ${this.limit} !`);
|
|
|
|
|
},
|
|
|
|
|
// 上传成功回调
|
|
|
|
|
handleUploadSuccess(res, file) {
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
this.uploadList.push(res.data.url);
|
|
|
|
|
this.uploadedSuccessfully();
|
|
|
|
|
} else {
|
|
|
|
|
this.number--;
|
|
|
|
|
this.$modal.closeLoading();
|
|
|
|
|
this.$modal.msgError(res.msg);
|
|
|
|
|
this.$refs.imageUpload.handleRemove(file);
|
|
|
|
|
this.uploadedSuccessfully();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 上传结束处理
|
|
|
|
|
uploadedSuccessfully() {
|
|
|
|
|
if (this.number > 0 && this.uploadList.length === this.number) {
|
|
|
|
|
this.fileList = this.fileList.concat(this.uploadList);
|
|
|
|
|
this.uploadList = [];
|
|
|
|
|
this.number = 0;
|
|
|
|
|
this.form.caseInfoPic = this.fileList[0];
|
|
|
|
|
// this.$emit("input", this.listToString(this.fileList));
|
|
|
|
|
this.$modal.closeLoading();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 删除图片
|
|
|
|
|
handleDeletePicture(file) {
|
|
|
|
|
const findex = this.fileList.map(f => f.name).indexOf(file.name);
|
|
|
|
|
if (findex > -1) {
|
|
|
|
|
this.fileList.splice(findex, 1);
|
|
|
|
|
// this.$emit("input", this.listToString(this.fileList));
|
|
|
|
|
}
|
|
|
|
|
this.form.caseInfoPic = '';
|
|
|
|
|
},
|
|
|
|
|
// 上传失败
|
|
|
|
|
handleUploadError() {
|
|
|
|
|
this.$modal.msgError("上传图片失败,请重试");
|
|
|
|
|
this.$modal.closeLoading();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 预览
|
|
|
|
|
handlePictureCardPreview(file) {
|
|
|
|
|
this.dialogImageUrl = file.url;
|
|
|
|
|
this.dialogVisible = true;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 筛选节点
|
|
|
|
|
filterNode(value, data) {
|
|
|
|
|
if (!value) return true;
|
|
|
|
|
return data.label.indexOf(value) !== -1;
|
|
|
|
|
},
|
|
|
|
|
// 节点单击事件
|
|
|
|
|
handleNodeClick(data) {
|
|
|
|
|
this.queryParams.configTypeId = data.id;
|
|
|
|
|
this.handleQuery();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/** 案例信息查询页面查询部门下拉树结构 */
|
|
|
|
|
getPortalConfigTypeTree() {
|
|
|
|
|
portalConfigTypeTree({}).then(response => {
|
|
|
|
|
this.configTypeOptions = response.data;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
/** 案例编辑页面查询部门下拉树结构 */
|
|
|
|
|
getEditPortalConfigTypeTree() {
|
|
|
|
|
// this.deptParams.tenantId = tenantId;
|
|
|
|
|
portalConfigTypeTree({}).then(response => {
|
|
|
|
|
this.editedConfigTypeOptions = response.data;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
close() {
|
|
|
|
|
const obj = {path: "/portal/productCaseInfo", query: {t: Date.now(), pageNum: this.$route.query.pageNum}};
|
|
|
|
|
this.$tab.closeOpenPage(obj);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|