|
|
|
@ -0,0 +1,659 @@
|
|
|
|
|
<template>
|
|
|
|
|
<div class="app-container">
|
|
|
|
|
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
|
|
|
|
<el-form-item label="大类(1产品中心,2案例)" prop="configTypeClassfication">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="queryParams.configTypeClassfication"
|
|
|
|
|
placeholder="请输入大类(1产品中心,2案例)"
|
|
|
|
|
clearable
|
|
|
|
|
@keyup.enter.native="handleQuery"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="类型名称" prop="configTypeName">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="queryParams.configTypeName"
|
|
|
|
|
placeholder="请输入类型名称"
|
|
|
|
|
clearable
|
|
|
|
|
@keyup.enter.native="handleQuery"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item>
|
|
|
|
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
|
|
|
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
|
|
|
|
|
<el-row :gutter="10" class="mb8">
|
|
|
|
|
<el-col :span="1.5">
|
|
|
|
|
<el-button
|
|
|
|
|
type="primary"
|
|
|
|
|
plain
|
|
|
|
|
icon="el-icon-plus"
|
|
|
|
|
size="mini"
|
|
|
|
|
@click="handleAdd"
|
|
|
|
|
v-hasPermi="['portal:portalConfigType:add']"
|
|
|
|
|
>新增</el-button>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="1.5">
|
|
|
|
|
<el-button
|
|
|
|
|
type="info"
|
|
|
|
|
plain
|
|
|
|
|
icon="el-icon-sort"
|
|
|
|
|
size="mini"
|
|
|
|
|
@click="toggleExpandAll"
|
|
|
|
|
>展开/折叠</el-button>
|
|
|
|
|
</el-col>
|
|
|
|
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
|
|
</el-row>
|
|
|
|
|
|
|
|
|
|
<el-table
|
|
|
|
|
v-if="refreshTable"
|
|
|
|
|
v-loading="loading"
|
|
|
|
|
:data="portalConfigTypeList"
|
|
|
|
|
row-key="configTypeId"
|
|
|
|
|
:default-expand-all="isExpandAll"
|
|
|
|
|
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
|
|
|
|
>
|
|
|
|
|
<el-table-column label="首页名称" align="center" prop="homeConfigTypeName" />
|
|
|
|
|
<el-table-column label="类型名称" align="center" prop="configTypeName" />
|
|
|
|
|
<el-table-column label="大类(1产品中心,2案例)" prop="configTypeClassfication" />
|
|
|
|
|
<el-table-column label="类型备注" align="center" prop="configTypeDesc" />
|
|
|
|
|
<el-table-column label="图片地址" align="center" prop="homeConfigTypePic" />
|
|
|
|
|
<el-table-column label="父级ID" align="center" prop="parentId" />
|
|
|
|
|
<el-table-column label="祖级列表" align="center" prop="ancestors" />
|
|
|
|
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
|
|
<template slot-scope="scope">
|
|
|
|
|
<el-button
|
|
|
|
|
size="mini"
|
|
|
|
|
type="text"
|
|
|
|
|
icon="el-icon-edit"
|
|
|
|
|
@click="handleUpdate(scope.row)"
|
|
|
|
|
v-hasPermi="['portal:portalConfigType:edit']"
|
|
|
|
|
>修改</el-button>
|
|
|
|
|
<el-button
|
|
|
|
|
size="mini"
|
|
|
|
|
type="text"
|
|
|
|
|
icon="el-icon-plus"
|
|
|
|
|
@click="handleAdd(scope.row)"
|
|
|
|
|
v-hasPermi="['portal:portalConfigType:add']"
|
|
|
|
|
>新增</el-button>
|
|
|
|
|
<el-button
|
|
|
|
|
size="mini"
|
|
|
|
|
type="text"
|
|
|
|
|
icon="el-icon-delete"
|
|
|
|
|
@click="handleDelete(scope.row)"
|
|
|
|
|
v-hasPermi="['portal:portalConfigType:remove']"
|
|
|
|
|
>删除</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
|
|
|
|
|
<!-- 添加或修改门户网站配置类型对话框 -->
|
|
|
|
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
|
|
|
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
|
|
|
|
<el-form-item label="父级" prop="parentId">
|
|
|
|
|
<treeselect v-model="form.parentId" :options="portalConfigTypeOptions" :normalizer="normalizer" placeholder="请选择父级ID" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="大类(1产品中心,2案例)" prop="configTypeClassfication">
|
|
|
|
|
<el-input v-model="form.configTypeClassfication" placeholder="请输入大类(1产品中心,2案例)" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="首页显示名称" prop="homeConfigTypeName">
|
|
|
|
|
<el-input v-model="form.homeConfigTypeName" placeholder="请输入类型名称" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="类型名称" prop="configTypeName">
|
|
|
|
|
<el-input v-model="form.configTypeName" placeholder="请输入类型名称" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="类型备注" prop="configTypeDesc">
|
|
|
|
|
<el-input v-model="form.configTypeDesc" type="textarea" placeholder="请输入内容" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<el-form-item label="图标" prop="configTypeIcon">
|
|
|
|
|
<el-upload
|
|
|
|
|
single
|
|
|
|
|
:action="iconUploadImgUrl"
|
|
|
|
|
list-type="picture-card"
|
|
|
|
|
:limit="iconLimit"
|
|
|
|
|
:on-success="handleIconUploadSuccess"
|
|
|
|
|
:before-upload="handleIconBeforeUpload"
|
|
|
|
|
:on-error="handleIconUploadError"
|
|
|
|
|
:on-exceed="handleIconExceed"
|
|
|
|
|
ref="iconImageUpload"
|
|
|
|
|
:on-remove="handleIconDeletePicture"
|
|
|
|
|
:show-file-list="true"
|
|
|
|
|
:headers="iconHeaders"
|
|
|
|
|
:file-list="iconFileList"
|
|
|
|
|
:on-preview="handleIconPictureCardPreview"
|
|
|
|
|
:class="{hide: this.iconFileList.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="iconFileSize"> 大小不超过 <b style="color: #f56c6c">{{ iconFileSize }}MB</b></template>
|
|
|
|
|
<template v-if="iconFileType"> 格式为 <b style="color: #f56c6c">{{ iconFileType.join("/") }}</b></template>
|
|
|
|
|
的文件
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<el-dialog
|
|
|
|
|
:visible.sync="iconDialogVisible"
|
|
|
|
|
title="预览"
|
|
|
|
|
width="800"
|
|
|
|
|
append-to-body
|
|
|
|
|
>
|
|
|
|
|
<img
|
|
|
|
|
:src="iconDialogImageUrl"
|
|
|
|
|
style="display: block; max-width: 100%; margin: 0 auto"
|
|
|
|
|
/>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<el-form-item label="图片" prop="homeConfigTypePic">
|
|
|
|
|
<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>
|
|
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
|
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
|
|
|
|
<el-button @click="cancel">取 消</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import { listPortalConfigType, getPortalConfigType, delPortalConfigType, addPortalConfigType, updatePortalConfigType } from "@/api/portal/portalConfigType";
|
|
|
|
|
import Treeselect from "@riophae/vue-treeselect";
|
|
|
|
|
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
|
|
|
|
import {getToken} from "@/utils/auth";
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: "PortalConfigType",
|
|
|
|
|
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
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
iconValue: [String, Object, Array],
|
|
|
|
|
// 图片数量限制
|
|
|
|
|
iconLimit: {
|
|
|
|
|
type: Number,
|
|
|
|
|
default: 1,
|
|
|
|
|
},
|
|
|
|
|
// 大小限制(MB)
|
|
|
|
|
iconFileSize: {
|
|
|
|
|
type: Number,
|
|
|
|
|
default: 5,
|
|
|
|
|
},
|
|
|
|
|
// 文件类型, 例如['png', 'jpg', 'jpeg']
|
|
|
|
|
iconFileType: {
|
|
|
|
|
type: Array,
|
|
|
|
|
default: () => ["png", "jpg", "jpeg"],
|
|
|
|
|
},
|
|
|
|
|
// 是否显示提示
|
|
|
|
|
iconIsShowTip: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
components: {
|
|
|
|
|
Treeselect
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
// 遮罩层
|
|
|
|
|
loading: true,
|
|
|
|
|
// 显示搜索条件
|
|
|
|
|
showSearch: true,
|
|
|
|
|
// 门户网站配置类型表格数据
|
|
|
|
|
portalConfigTypeList: [],
|
|
|
|
|
// 门户网站配置类型树选项
|
|
|
|
|
portalConfigTypeOptions: [],
|
|
|
|
|
// 弹出层标题
|
|
|
|
|
title: "",
|
|
|
|
|
// 是否显示弹出层
|
|
|
|
|
open: false,
|
|
|
|
|
// 是否展开,默认全部展开
|
|
|
|
|
isExpandAll: true,
|
|
|
|
|
// 重新渲染表格状态
|
|
|
|
|
refreshTable: true,
|
|
|
|
|
// 查询参数
|
|
|
|
|
queryParams: {
|
|
|
|
|
configTypeClassfication: null,
|
|
|
|
|
configTypeName: null,
|
|
|
|
|
configTypeDesc: null,
|
|
|
|
|
configTypeIcon: null,
|
|
|
|
|
parentId: null,
|
|
|
|
|
ancestors: null,
|
|
|
|
|
},
|
|
|
|
|
// 表单参数
|
|
|
|
|
form: {},
|
|
|
|
|
// 表单校验
|
|
|
|
|
rules: {
|
|
|
|
|
configTypeClassfication: [
|
|
|
|
|
{ required: true, message: "大类(1产品中心,2案例)不能为空", trigger: "blur" }
|
|
|
|
|
],
|
|
|
|
|
configTypeName: [
|
|
|
|
|
{ required: true, message: "类型名称不能为空", trigger: "blur" }
|
|
|
|
|
],
|
|
|
|
|
parentId: [
|
|
|
|
|
{ required: true, message: "父级ID不能为空", trigger: "blur" }
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
number: 0,
|
|
|
|
|
uploadList: [],
|
|
|
|
|
dialogImageUrl: "",
|
|
|
|
|
dialogVisible: false,
|
|
|
|
|
hideUpload: false,
|
|
|
|
|
uploadImgUrl: process.env.VUE_APP_BASE_API + "/file/upload", // 上传的图片服务器地址
|
|
|
|
|
headers: {
|
|
|
|
|
Authorization: "Bearer " + getToken(),
|
|
|
|
|
},
|
|
|
|
|
fileList: [],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
iconNumber: 0,
|
|
|
|
|
iconUploadList: [],
|
|
|
|
|
iconDialogImageUrl: "",
|
|
|
|
|
iconDialogVisible: false,
|
|
|
|
|
iconHideUpload: false,
|
|
|
|
|
iconUploadImgUrl: process.env.VUE_APP_BASE_API + "/file/upload", // 上传的图片服务器地址
|
|
|
|
|
iconHeaders: {
|
|
|
|
|
Authorization: "Bearer " + getToken(),
|
|
|
|
|
},
|
|
|
|
|
iconFileList: [],
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
this.getList();
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
/** 查询门户网站配置类型列表 */
|
|
|
|
|
getList() {
|
|
|
|
|
this.loading = true;
|
|
|
|
|
listPortalConfigType(this.queryParams).then(response => {
|
|
|
|
|
this.portalConfigTypeList = this.handleTree(response.data, "configTypeId", "parentId");
|
|
|
|
|
this.loading = false;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
/** 转换门户网站配置类型数据结构 */
|
|
|
|
|
normalizer(node) {
|
|
|
|
|
if (node.children && !node.children.length) {
|
|
|
|
|
delete node.children;
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
id: node.configTypeId,
|
|
|
|
|
label: node.configTypeName,
|
|
|
|
|
children: node.children
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
/** 查询门户网站配置类型下拉树结构 */
|
|
|
|
|
getTreeselect() {
|
|
|
|
|
listPortalConfigType().then(response => {
|
|
|
|
|
this.portalConfigTypeOptions = [];
|
|
|
|
|
const data = { configTypeId: 0, configTypeName: '顶级节点', children: [] };
|
|
|
|
|
data.children = this.handleTree(response.data, "configTypeId", "parentId");
|
|
|
|
|
this.portalConfigTypeOptions.push(data);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
// 取消按钮
|
|
|
|
|
cancel() {
|
|
|
|
|
this.open = false;
|
|
|
|
|
this.reset();
|
|
|
|
|
},
|
|
|
|
|
// 表单重置
|
|
|
|
|
reset() {
|
|
|
|
|
this.form = {
|
|
|
|
|
configTypeId: null,
|
|
|
|
|
configTypeClassfication: null,
|
|
|
|
|
homeConfigTypeName: null,
|
|
|
|
|
configTypeName: null,
|
|
|
|
|
configTypeDesc: null,
|
|
|
|
|
configTypeIcon: null,
|
|
|
|
|
homeConfigTypePic: null,
|
|
|
|
|
parentId: null,
|
|
|
|
|
ancestors: null,
|
|
|
|
|
createTime: null,
|
|
|
|
|
createBy: null,
|
|
|
|
|
updateTime: null,
|
|
|
|
|
updateBy: null
|
|
|
|
|
};
|
|
|
|
|
this.resetForm("form");
|
|
|
|
|
this.fileList = [];
|
|
|
|
|
this.iconFileList = [];
|
|
|
|
|
},
|
|
|
|
|
/** 搜索按钮操作 */
|
|
|
|
|
handleQuery() {
|
|
|
|
|
this.getList();
|
|
|
|
|
},
|
|
|
|
|
/** 重置按钮操作 */
|
|
|
|
|
resetQuery() {
|
|
|
|
|
this.resetForm("queryForm");
|
|
|
|
|
this.handleQuery();
|
|
|
|
|
},
|
|
|
|
|
/** 新增按钮操作 */
|
|
|
|
|
handleAdd(row) {
|
|
|
|
|
this.reset();
|
|
|
|
|
this.getTreeselect();
|
|
|
|
|
if (row != null && row.configTypeId) {
|
|
|
|
|
this.form.parentId = row.configTypeId;
|
|
|
|
|
} else {
|
|
|
|
|
this.form.parentId = 0;
|
|
|
|
|
}
|
|
|
|
|
this.open = true;
|
|
|
|
|
this.title = "添加门户网站配置类型";
|
|
|
|
|
},
|
|
|
|
|
/** 展开/折叠操作 */
|
|
|
|
|
toggleExpandAll() {
|
|
|
|
|
this.refreshTable = false;
|
|
|
|
|
this.isExpandAll = !this.isExpandAll;
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
this.refreshTable = true;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
/** 修改按钮操作 */
|
|
|
|
|
handleUpdate(row) {
|
|
|
|
|
this.reset();
|
|
|
|
|
this.getTreeselect();
|
|
|
|
|
if (row != null) {
|
|
|
|
|
this.form.parentId = row.configTypeId;
|
|
|
|
|
}
|
|
|
|
|
getPortalConfigType(row.configTypeId).then(response => {
|
|
|
|
|
this.form = response.data;
|
|
|
|
|
this.open = true;
|
|
|
|
|
this.title = "修改门户网站配置类型";
|
|
|
|
|
|
|
|
|
|
if (response.data.homeConfigTypePic != null) {
|
|
|
|
|
let previewFile = {};
|
|
|
|
|
previewFile.url = response.data.homeConfigTypePic
|
|
|
|
|
this.fileList.push(previewFile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (response.data.configTypeIcon != null) {
|
|
|
|
|
let previewFile = {};
|
|
|
|
|
previewFile.url = response.data.configTypeIcon
|
|
|
|
|
this.iconFileList.push(previewFile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
/** 提交按钮 */
|
|
|
|
|
submitForm() {
|
|
|
|
|
this.$refs["form"].validate(valid => {
|
|
|
|
|
if (valid) {
|
|
|
|
|
if (this.form.configTypeId != null) {
|
|
|
|
|
updatePortalConfigType(this.form).then(response => {
|
|
|
|
|
this.$modal.msgSuccess("修改成功");
|
|
|
|
|
this.open = false;
|
|
|
|
|
this.getList();
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
addPortalConfigType(this.form).then(response => {
|
|
|
|
|
this.$modal.msgSuccess("新增成功");
|
|
|
|
|
this.open = false;
|
|
|
|
|
this.getList();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
/** 删除按钮操作 */
|
|
|
|
|
handleDelete(row) {
|
|
|
|
|
this.$modal.confirm('是否确认删除门户网站配置类型编号为"' + row.configTypeId + '"的数据项?').then(function() {
|
|
|
|
|
return delPortalConfigType(row.configTypeId);
|
|
|
|
|
}).then(() => {
|
|
|
|
|
this.getList();
|
|
|
|
|
this.$modal.msgSuccess("删除成功");
|
|
|
|
|
}).catch(() => {});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**上传图片处理*/
|
|
|
|
|
// 上传前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.homeConfigTypePic = 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.homeConfigTypePic = '';
|
|
|
|
|
},
|
|
|
|
|
// 上传失败
|
|
|
|
|
handleUploadError() {
|
|
|
|
|
this.$modal.msgError("上传图片失败,请重试");
|
|
|
|
|
this.$modal.closeLoading();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 预览
|
|
|
|
|
handlePictureCardPreview(file) {
|
|
|
|
|
this.dialogImageUrl = file.url;
|
|
|
|
|
this.dialogVisible = true;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**上传图片处理*/
|
|
|
|
|
// 上传前loading加载
|
|
|
|
|
handleIconBeforeUpload(file) {
|
|
|
|
|
let isImg = false;
|
|
|
|
|
if (this.iconFileType.length) {
|
|
|
|
|
let fileExtension = "";
|
|
|
|
|
if (file.name.lastIndexOf(".") > -1) {
|
|
|
|
|
fileExtension = file.name.slice(file.name.lastIndexOf(".") + 1);
|
|
|
|
|
}
|
|
|
|
|
isImg = this.iconFileType.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.iconFileType.join("/")}图片格式文件!`);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (this.iconFileSize) {
|
|
|
|
|
const isLt = file.size / 1024 / 1024 < this.iconFileSize;
|
|
|
|
|
if (!isLt) {
|
|
|
|
|
this.$modal.msgError(`上传头像图片大小不能超过 ${this.iconFileSize} MB!`);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.$modal.loading("正在上传图片,请稍候...");
|
|
|
|
|
this.iconNumber++;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 文件个数超出
|
|
|
|
|
handleIconExceed() {
|
|
|
|
|
this.$modal.msgError(`上传文件数量不能超过 ${this.iconLimit} !`);
|
|
|
|
|
},
|
|
|
|
|
// 上传成功回调
|
|
|
|
|
handleIconUploadSuccess(res, file) {
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
this.iconUploadList.push(res.data.url);
|
|
|
|
|
this.uploadedIconSuccessfully();
|
|
|
|
|
} else {
|
|
|
|
|
this.iconNumber--;
|
|
|
|
|
this.$modal.closeLoading();
|
|
|
|
|
this.$modal.msgError(res.msg);
|
|
|
|
|
this.$refs.iconImageUpload.handleRemove(file);
|
|
|
|
|
this.uploadedIconSuccessfully();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 上传结束处理
|
|
|
|
|
uploadedIconSuccessfully() {
|
|
|
|
|
alert(this.iconNumber)
|
|
|
|
|
if (this.iconNumber > 0 && this.iconUploadList.length === this.iconNumber) {
|
|
|
|
|
this.iconFileList = this.iconFileList.concat(this.iconUploadList);
|
|
|
|
|
this.iconUploadList = [];
|
|
|
|
|
this.iconNumber = 0;
|
|
|
|
|
this.form.configTypeIcon = this.iconFileList[0];
|
|
|
|
|
// this.$emit("input", this.listToString(this.fileList));
|
|
|
|
|
this.$modal.closeLoading();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 删除图片
|
|
|
|
|
handleIconDeletePicture(file) {
|
|
|
|
|
const findex = this.iconFileList.map(f => f.name).indexOf(file.name);
|
|
|
|
|
if (findex > -1) {
|
|
|
|
|
this.iconFileList.splice(findex, 1);
|
|
|
|
|
// this.$emit("input", this.listToString(this.fileList));
|
|
|
|
|
}
|
|
|
|
|
this.form.configTypeIcon = '';
|
|
|
|
|
},
|
|
|
|
|
// 上传失败
|
|
|
|
|
handleIconUploadError() {
|
|
|
|
|
this.$modal.msgError("上传图片失败,请重试");
|
|
|
|
|
this.$modal.closeLoading();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 预览
|
|
|
|
|
handleIconPictureCardPreview(file) {
|
|
|
|
|
this.iconDialogImageUrl = file.url;
|
|
|
|
|
this.iconDialogVisible = true;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|