1.微服务
1.知识点
1.前端获取当前用户
this.currentUser = JSON.parse(localStorage.getItem("currentUser"))
2.关闭当前标签页
//路由跳转
this.$router.push({ path: '/flowable/definition/model',query: { deployId: row.deploymentId }})
//关闭当前标签页
/** 保存xml */
save (data) {
const params = {
name: data.process.name,
category: data.process.category,
xml: data.xml
}
saveXml(params).then(res => {
this.$modal.message(res.msg)
// 关闭当前标签页
this.$store.dispatch("tagsView/delView", this.$route);
this.$router.go(-1)
})
},
3.解决19位整数精度丢失问题
package com.ruoyi.framework.config;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.ruoyi.framework.jackson.BigNumberSerializer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.TimeZone;
/**
* jackson 配置
*
* @author Lion Li
*/
@Slf4j
@Configuration
public class JacksonConfig {
@Bean
public Jackson2ObjectMapperBuilderCustomizer customizer() {
return builder -> {
// 全局配置序列化返回 JSON 处理
JavaTimeModule javaTimeModule = new JavaTimeModule();
javaTimeModule.addSerializer(Long.class, BigNumberSerializer.INSTANCE);
javaTimeModule.addSerializer(Long.TYPE, BigNumberSerializer.INSTANCE);
javaTimeModule.addSerializer(BigInteger.class, BigNumberSerializer.INSTANCE);
javaTimeModule.addSerializer(BigDecimal.class, ToStringSerializer.instance);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(formatter));
javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(formatter));
builder.modules(javaTimeModule);
builder.timeZone(TimeZone.getDefault());
log.info("初始化 jackson 配置");
};
}
}
BigNumberSerializer类
package com.ruoyi.framework.jackson;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JacksonStdImpl;
import com.fasterxml.jackson.databind.ser.std.NumberSerializer;
import java.io.IOException;
/**
* 超出 JS 最大最小值 处理
*
* @author Lion Li
*/
@JacksonStdImpl
public class BigNumberSerializer extends NumberSerializer {
/**
* 根据 JS Number.MAX_SAFE_INTEGER 与 Number.MIN_SAFE_INTEGER 得来
*/
private static final long MAX_SAFE_INTEGER = 9007199254740991L;
private static final long MIN_SAFE_INTEGER = -9007199254740991L;
/**
* 提供实例
*/
public static final BigNumberSerializer INSTANCE = new BigNumberSerializer(Number.class);
public BigNumberSerializer(Class<? extends Number> rawType) {
super(rawType);
}
@Override
public void serialize(Number value, JsonGenerator gen, SerializerProvider provider) throws IOException {
// 超出范围 序列化位字符串
if (value.longValue() > MIN_SAFE_INTEGER && value.longValue() < MAX_SAFE_INTEGER) {
super.serialize(value, gen, provider);
} else {
gen.writeString(value.toString());
}
}
}
2.项目实例
1.上报率
SELECT (j.yes + k.`no`) `all`,j.`yes`,k.`no`,CAST(j.yes/(j.yes + k.`no`) AS DECIMAL(6,2)) rate FROM (
SELECT COUNT(*) `yes` FROM rom_workorder_dgs a LEFT JOIN wrp_rsr_bsin b on a.rscd = b.rscd
WHERE a.dgs_state = 4 ) j
LEFT JOIN (
SELECT COUNT(*) `no` FROM rom_workorder_dgs a LEFT JOIN wrp_rsr_bsin b on a.rscd = b.rscd
WHERE a.dgs_state != 4 ) k
on 1 = 1
2.工程资料管理
<template>
<div class="app-container">
<el-form :model="queryParams" :rules="rules" ref="queryForm" :inline="true" v-show="showSearch">
<el-form-item label="行政区划">
<el-cascader :style="{ width: '90%' }" v-model="queryParams.addvcd" size="small" :options="addvcdList"
:props="addvcdProps" filterable @change="handleChangeAddvcdQy" clearable></el-cascader>
</el-form-item>
<el-form-item label="水库选择" prop="rscd">
<el-select size="small" :style="{ width: '80%' }" v-model="queryParams.rscd" clearable placeholder="请选择"
filterable @change="handleChangeOfrsvrcd">
<el-option v-for="item in rsvbListQy" :key="item.rscd" :label="item.rsnm" :value="item.rscd">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="资料类型" prop="filetype">
<el-select v-model="queryParams.filetype" placeholder="请选择资料类型" :style="{ width: '80%' }" clearable
size="small">
<el-option v-for="dict in dict.type.document_type" :key="dict.value" :label="dict.label"
:value="dict.value" />
</el-select>
</el-form-item>
<el-form-item label="年份" prop="year">
<el-date-picker clearable size="small" :style="{ width: '90%' }" v-model="queryParams.year" type="year"
format="yyyy" value-format="yyyy" placeholder="选择年份">
</el-date-picker>
</el-form-item>
<el-form-item label="文件名称" prop="title">
<el-input :style="{ width: '80%' }" v-model="queryParams.title" placeholder="标题" clearable size="small"
@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="['oam:tprojectdocumentr:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
v-hasPermi="['oam:tprojectdocumentr:edit']">修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple"
@click="handleDelete" v-hasPermi="['oam:tprojectdocumentr:remove']">删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
v-hasPermi="['oam:tprojectdocumentr:export']">导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="tprojectdocumentrList" @selection-change="handleSelectionChange" border>
<el-table-column type="selection" width="55" align="center" />
<!-- <el-table-column label="主键ID" align="center" prop="id" /> -->
<el-table-column label="水库" align="center" prop="rsnm" width="180" show-overflow-tooltip></el-table-column>
<el-table-column label="标题" align="center" prop="title" width="300" show-overflow-tooltip />
<el-table-column label="资料类型" align="center" prop="filetype" width="180">
<template slot-scope="scope">
<dict-tag :options="dict.type.document_type" :value="scope.row.filetype" />
</template>
</el-table-column>
<el-table-column label="年份" align="center" prop="year" width="120" />
<!-- <el-table-column label="资料路径" align="center" prop="path" show-overflow-tooltip/> -->
<el-table-column label="上传人" align="center" prop="username" width="160" />
<el-table-column label="上传时间" align="center" prop="uploadtm" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.uploadtm, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<!-- <el-table-column label="资料大小(KB)" align="center" prop="size" /> -->
<!-- <el-table-column label="下载量" align="center" prop="downloads" /> -->
<!-- <el-table-column label="资料" align="center" prop="path" show-overflow-tooltip>
<template slot-scope="scope">
<div v-if="scope.row.filetype==1" class="imageStyle1">
<a title="文件" href="javascript:;" v-for="(item,index) in scope.row.fileNames" :key="index+item+1" :src="item.path" >{{item.name}}</a>
</div>
<div v-if="scope.row.filetype==2" class="imageStyle2">
<el-image title="预览" v-for="(item,index) in scope.row.fileLists" :key="index+item+2" :src="item" fit="cover" :style="imgStyle" :preview-src-list="scope.row.fileLists" />
</div>
<div v-if="scope.row.filetype==3" class="imageStyle2"> -->
<!-- <el-image title="预览" v-for="(item,index) in scope.row.fileLists" :key="index+item+2" :src="item" fit="cover" :style="imgStyle" :preview-src-list="scope.row.fileLists" /> -->
<!-- <video title="播放" :style="imgStyle" v-for="(item,index) in scope.row.fileLists" :key="index+item+3" :src="item" controls>
<source src="movie.ogg" type="video/ogg">
<source src="movie.mp4" type="video/mp4">
<source src="movie.webm" type="video/webm">
<object data="movie.mp4" width="320" height="240">
<embed width="320" height="240" src="movie.swf">
</object>
</video>
</div>
</template>
</el-table-column> -->
<el-table-column label="备注" align="center" prop="nt" show-overflow-tooltip />
<el-table-column label="操作" align="center" width="180" 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="['oam:tprojectdocumentr:edit']">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
v-hasPermi="['oam:tprojectdocumentr:remove']">删除</el-button>
<el-button size="mini" type="text" icon="el-icon-view" @click="handleLookup(scope.row)">查看
</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
@pagination="getList" />
<!-- 添加或修改工程资料管理对话框 -->
<el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="行政区划">
<el-cascader filterable :style="{ width: '90%' }" v-model="tempParams.addvcd" :options="addvcdList"
:props="addvcdProps" @change="handleChangeAddvcdQy"></el-cascader>
</el-form-item>
<el-form-item label="水库选择" prop="rscd">
<el-select :style="{ width: '90%' }" filterable v-model="form.rscd" placeholder="请选择" clearable>
<el-option v-for="item in rsvbListQy" :key="item.rscd" :label="item.rsnm" :value="item.rscd">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="标题" prop="title">
<el-input v-model="form.title" placeholder="请输入资料名称" :style="{ width: '90%' }" />
</el-form-item>
<el-form-item label="资料类型" prop="filetype">
<el-select v-model="form.filetype" placeholder="请选择资料类型" :style="{ width: '90%' }">
<el-option v-for="dict in dict.type.document_type" :key="dict.value" :label="dict.label"
:value="dict.value"></el-option>
</el-select>
</el-form-item>
<el-form-item label="年份" prop="year">
<el-date-picker :style="{ width: '90%' }" v-model="form.year" type="year" value-format="yyyy"
format="yyyy" placeholder="选择年份">
</el-date-picker>
</el-form-item>
<el-form-item label="资料" prop="path">
<!-- <el-input v-model="form.path" placeholder="请输入资料路径" :style="{ width: '90%' }" /> -->
<el-upload ref="upload" :limit="9" multiple :accept="upload.accept" :before-upload="beforeUpload"
:on-remove="handleRemove" :action="upload.url" :headers="upload.headers"
:file-list="upload.fileList" :on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess" :auto-upload="false">
<el-button slot="trigger" size="small" type="primary">选取资料</el-button>
<el-button style="margin-left: 10px;" size="small" type="success" :loading="upload.isUploading"
@click="submitUpload">上传到服务器</el-button>
<div slot="tip" class="el-upload__tip">{{upload.msg}}</div>
</el-upload>
</el-form-item>
<el-form-item label="上传人" prop="username">
<el-input v-model="form.username" placeholder="请输入上传人" :style="{ width: '90%' }" />
</el-form-item>
<!-- <el-form-item label="上传时间" prop="uploadtm">
<el-date-picker clearable size="small"
:style="{ width: '90%' }"
v-model="form.uploadtm"
type="date"
value-format="yyyy-MM-dd"
placeholder="选择上传时间">
</el-date-picker>
</el-form-item> -->
<!-- <el-form-item label="资料大小" prop="size">
<el-input v-model="form.size" placeholder="请输入资料大小" :style="{ width: '90%' }" />
</el-form-item> -->
<el-form-item label="备注" prop="nt">
<el-input v-model="form.nt" type="textarea" rows="5" placeholder="请输入内容"
:style="{ width: '90%' }" />
</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>
<el-dialog title="" :visible.sync="lookupShow" width="70%" center>
<el-row>
<el-col :span="20" :offset="4">
<el-descriptions :title="form2.title">
<el-descriptions-item label="所属水库">{{form2.rsnm}}<i class="el-icon-location-outline"
style="color:#1890ff"></i></el-descriptions-item>
<el-descriptions-item label="资料类型">
<dict-tag :options="dict.type.document_type" :value="form2.filetype" />
</el-descriptions-item>
<el-descriptions-item label="年份">{{form2.year}}</el-descriptions-item>
<el-descriptions-item label="上传时间">{{form2.uploadtm}}</el-descriptions-item>
<el-descriptions-item label="上传人" :span="2">{{form2.username}}</el-descriptions-item>
<el-descriptions-item label="资料简介" :span="3">{{form2.nt}}</el-descriptions-item>
<el-descriptions-item label="资料" :span="3"></el-descriptions-item>
</el-descriptions>
</el-col>
</el-row>
<el-row>
<el-col :span="17" :offset="4">
<div style="margin-left:0px" class="descrt2">
<div v-for="(it,index) in form2.fileNames" :key="index+it+1" class="imageStyle1">
<div style="padding-top:30px;height:120px;width:190px;line-height:25px"
v-if="formFiletype(it.path)==1" title="下载" href="javascript:;" :src="it.path"
@click="handleDownload(it)"><i style="color:#409EFF"
class="el-icon-document"></i> {{it.name}}</div>
<el-image v-else-if="formFiletype(it.path)==2" title="预览" :key="index+it+2" :src="it.path"
fit="cover" :style="imgStyle2" :preview-src-list="filterImages(form2.fileLists)" />
<video title="播放" v-else-if="formFiletype(it.path)==3" :style="imgStyle2" :src="it.path"
controls>
<source src="movie.ogg" type="video/ogg">
<source src="movie.mp4" type="video/mp4">
<source src="movie.webm" type="video/webm">
<object data="movie.mp4" width="320" height="240">
<embed width="320" height="240" src="movie.swf">
</object>
</video>
</div>
<!-- <div v-if="form2.filetype==1" class="imageStyle1">
<a title="下载" href="javascript:;" @click="handleDownload(it)" v-for="(it,index) in form2.fileNames" :key="index+it+1" :src="it.path" >{{it.name}}</a>
</div> -->
<!-- <div v-if="form2.filetype==2" class="imageStyle2">
<el-image title="预览" v-for="(it,index) in form2.fileLists" :key="index+it+2" :src="it" fit="cover" :style="imgStyle2" :preview-src-list="form2.fileLists" />
</div>
<div v-if="form2.filetype==3" class="imageStyle2">
<video title="播放" :style="imgStyle2" v-for="(it,index) in form2.fileLists" :key="index+it+3" :src="it" controls>
<source src="movie.ogg" type="video/ogg">
<source src="movie.mp4" type="video/mp4">
<source src="movie.webm" type="video/webm">
<object data="movie.mp4" width="320" height="240">
<embed width="320" height="240" src="movie.swf">
</object>
</video>
</div> -->
</div>
</el-col>
</el-row>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="cancel2">关 闭</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import {
listTprojectdocumentr,
getTprojectdocumentr,
delTprojectdocumentr,
addTprojectdocumentr,
updateTprojectdocumentr
} from "@/api/oam/basic/tprojectdocumentr";
import {
getToken
} from "@/utils/auth";
import {
loadAddvcd,
getRsrbDropdown
} from "@/api/oam/basic/wrprsrbsin";
import Cookies from "js-cookie";
export default {
name: "Tprojectdocumentr",
dicts: ['document_type'],
data() {
return {
//图片样式
imgStyle2: {
width: '100%',
height: '100%',
},
//默认图片地址
defaultImgUrl: 'http://127.0.0.1:9300/statics/2022/03/10/83490f24-1cf8-45c4-8bae-53afdcf3acd6.png',
//查看
lookupShow: false,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 工程资料管理表格数据
tprojectdocumentrList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
filetype: null,
year: this.$moment().format("YYYY"),
title: null,
rscd: null,
addvcd: null,
},
tempParams: {
addvcd: null,
},
addvcd: null,
// 表单参数
form: {},
//浏览表单
form2: {},
//水库列表
rsvbListQy: [],
// 行政区划列表
addvcdList: [],
addvcdProps: {
emitPath: false,
checkStrictly: true,
// expandTrigger: 'hover'
},
// 表单校验
rules: {
filetype: [{
required: true,
message: "资料类型不能为空",
trigger: "change"
}],
},
// 上传参数
upload: {
// 是否禁用上传
isUploading: false,
// 设置上传的请求头部
headers: {
Authorization: "Bearer " + getToken()
},
// 上传的地址
url: process.env.VUE_APP_BASE_API + "/file/upload",
// 上传的资料列表
fileList: [],
//资料上传的类型
accept: '.xls,.xlsx,.doc,.docx,.rar,.zip,.wps,.wpt,.jpeg,.jpg,.png,.gif,.bmp,.mp4,.wmv,.m4v,.avi,.dat,.mkv,.flv,.vob',
//文字描述
msg: '只能上传文件,且不超过20M',
//文件上传大小:20M
size: 20971520,
},
//图片样式
imgStyle: {
width: '70px',
height: '50px',
},
//文件地址List
filePathList: [],
//文件名List
fileNameList: [],
//可接收的文件类型
acceptFileType1: '.xls,.xlsx,.doc,.docx,.rar,.zip,.wps,.wpt', //文件类型
acceptFileType2: '.jpg,.jpeg,.png,.gif,.bmp', //图片类型
acceptFileType3: '.mp4,.wmv,.m4v,.avi,.dat,.mkv,.flv,.vob', //视频类型
};
},
created() {
this.loadAddvcdList();
// this.getList();
},
methods: {
//文档类型
documentFormat(row, column) {
return this.selectDictLabel(this.dict.type.document_type, row.name);
},
//获取行政区划数据
loadAddvcdList() {
loadAddvcd({
isTree: true
}).then((res) => {
this.addvcdList = res.data;
this.queryParams.addvcd = res.data[0].value;
this.getRsrbDropdownQy(this.queryParams.addvcd);
this.getList();
});
},
// 查询区域行政区划选择事件
handleChangeAddvcdQy(value) {
this.queryParams.rscd = null;
this.getRsrbDropdownQy(value);
},
//根据行政区划查询水库
getRsrbDropdownQy(val) {
getRsrbDropdown({
addvcd: val
}).then((res) => {
this.rsvbListQy = res.data;
});
},
//查询水库
handleChangeOfrsvrcd(value) {
this.getList();
},
/** 查询工程资料管理列表 */
getList() {
this.loading = true;
listTprojectdocumentr(this.queryParams).then(response => {
this.tprojectdocumentrList = response.rows;
this.tprojectdocumentrList.forEach((item, index) => {
let lisPth = item.path.split(',');
let lisNam = item.filename.split(',');
if (lisPth.length > 0) {
let temp = [];
for (var i = 0; i < lisPth.length; i++) {
temp.push({
name: lisNam[i] == null ? '' : lisNam[i],
path: lisPth[i] == null ? '' : lisPth[i]
});
}
this.tprojectdocumentrList[index].fileNames = temp;
}
this.tprojectdocumentrList[index].fileLists = item.path == null ? '' : item.path
.split(',');
// this.tprojectdocumentrList[index].fileNames=item.title==null?'':item.title.split(',');
})
this.total = response.total;
this.loading = false;
});
},
//过滤图片
filterImages(items) {
let lists = [];
if (items != null && items.length > 0) {
items.forEach(item => {
var type = this.formFiletype(item);
if (type == 2) {
lists.push(item);
}
})
}
return lists;
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 取消按钮
cancel2() {
this.lookupShow = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: null,
title: null,
filetype: '1',
filename: null,
year: null,
path: null,
username: null,
uploadtm: null,
size: null,
nt: null,
type: null,
downloads: null
};
this.tempParams.addvcd = null;
this.queryParams.addvcd = null;
this.fileNameList = [];
this.filePathList = [];
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.filePathList = [];
this.fileNameList = [];
this.addvcdList = [];
this.rsvbListQy = [];
this.tempParams.addvcd = null;
this.queryParams.addvcd = null;
this.loadAddvcdList();
},
//查看
handleLookup(row) {
this.lookupShow = true;
this.form2 = row;
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length !== 1
this.multiple = !selection.length;
},
/** 新增按钮操作 */
handleAdd() {
let nickName = this.getUserName();
this.reset();
this.open = true;
this.form.username = nickName;
this.form.year = this.$moment().format('YYYY');
this.title = "添加工程资料管理";
this.upload.fileList = [];
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
// this.selectUploadType(row.filetype);
const id = row.id || this.ids
getTprojectdocumentr(id).then(response => {
this.tempParams.addvcd = response.data.addvcd;
this.form = response.data;
this.fileNameList = response.data.filename.split(',');
this.filePathList = response.data.path.split(',');
this.open = true;
this.title = "修改工程资料管理";
var tempList = [];
for (var i = 0; i < this.fileNameList.length; i++) {
tempList.push({
name: this.fileNameList[i],
url: this.filePathList[i]
});
}
this.upload.fileList = tempList;
});
},
/**根据选项改变上传类型 */
// selectUploadType(value){
// switch(value){
// case '1':
// this.upload.accept='.xls,.xlsx,.doc,.docx,.rar,.zip,.wps,.wpt';
// this.upload.msg='只能上传文件,且不超过20M';
// break;
// case '2':
// this.upload.accept='.jpg,.png,.gif,.bmp';
// this.upload.msg='只能上传图片,且不超过20M';
// break;
// case '3':
// this.upload.accept='.mp4,.wmv,.m4v,.avi,.dat,.mkv,.flv,.vob';
// this.upload.msg='只能上传视频,且不超过20M';
// break;
// default:
// this.$modal.msgError("类型异常");
// break;
// }
// },
/** 提交按钮 */
submitForm() {
if (this.filePathList.length < 1) {
this.$modal.msgError("上传资料不能为空");
return false;
}
this.$refs["form"].validate(valid => {
if (valid) {
this.form.path = this.filePathList.toString();
this.form.filename = this.fileNameList.toString();
if (this.form.id != null) {
updateTprojectdocumentr(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
this.filePathList = [];
this.fileNameList = [];
});
} else {
addTprojectdocumentr(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
this.filePathList = [];
this.fileNameList = [];
});
}
}
});
},
getUserName() {
// 获取当前用户名
let nickName = Cookies.get("nickName");
if (nickName != null && !$.isEmptyObject(nickName)) {
return nickName;
}
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除工程资料管理号为"' + ids + '"的数据项?').then(function() {
return delTprojectdocumentr(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
handleRemove(file, fileList) {
this.filePathList.forEach((item, index) => {
if (item == file.url) {
this.filePathList.splice(index, 1);
this.fileNameList.splice(index, 1);
}
})
// if (this.fileList != null) {
//
// this.fileList.map((item, index) => {
// if (item.uid == file.uid) {
// this.fileList.splice(index, 1)
// }
// })
// }
},
/** 导出按钮操作 */
handleExport() {
this.download('oam/basic/tprojectdocumentr/export', {
...this.queryParams
}, `tprojectdocumentr_${new Date().getTime()}.xlsx`)
},
/**下载 */
handleDownload(row) {
var name = row.title;
var url = row.path;
const a = document.createElement('a')
a.setAttribute('download', name)
a.setAttribute('target', '_blank')
a.setAttribute('href', url)
a.click()
},
//文件类型
formFiletype(value) {
let filetype = value.substring(value.lastIndexOf('.'));
let type = 0;
let arr1 = this.acceptFileType1.split(',');
arr1.forEach(item => {
if (filetype == item) {
type = 1;
}
})
let arr2 = this.acceptFileType2.split(',')
arr2.forEach(item => {
if (filetype == item) {
type = 2;
}
})
let arr3 = this.acceptFileType3.split(',')
arr3.forEach(item => {
if (filetype == item) {
type = 3;
}
})
return type;
},
/**文件上传模块 */
// 文件提交处理
beforeUpload(file) {
if (this.form.filetype == null) {
this.$modal.msgError("请选择上传资料类型");
return false;
}
if (file.size > this.upload.size) {
this.$modal.msgError("上传文件过大");
return false;
}
var fileType = file.name.substring(file.name.lastIndexOf('.')).trim();
let acceptType = this.upload.accept.split(',');
let flag = false;
acceptType.forEach(item => {
if (fileType == item) {
flag = true;
return true;
}
})
if (!flag) {
this.$modal.msgError("文件类型异常");
}
return flag;
},
submitUpload() {
this.$refs.upload.submit();
},
// 文件上传中处理
handleFileUploadProgress(event, file, fileList) {
this.upload.isUploading = true;
},
// 文件上传成功处理
handleFileSuccess(response, file, fileList) {
// this.form.filename = response.data.name;
var si = 0;
if (this.form.size) {
si = this.form.size;
}
fileList.forEach(item => {
si += (item.size / 1024 / 1024);
})
this.form.size = si;
this.form.uploadtm = this.$moment().format('YYYY-MM-DD');
this.form.type = file.name.substring(file.name.lastIndexOf('.') + 1);
this.filePathList.push(response.data.url);
this.fileNameList.push(file.name.replace(/,/g, ""));
this.upload.isUploading = false;
this.$modal.msgSuccess("上传成功!");
}
}
};
</script>
<style lang="scss" scoped>
/* ::v-deep .el-dialog:not(.is-fullscreen) {
margin-top: 3vh !important;
} */
/* 对话框底部按钮右对齐 */
.dialog-footer {
text-align: right;
display: flex;
justify-content: flex-end;
padding-right: 20px;
}
// 对话框样式
// 对话框标题
::v-deep .el-descriptions {
font-size: 17px;
.el-descriptions-item__label {
font-weight: bold;
}
.el-descriptions__title {
font-size: 26px;
}
.el-descriptions--medium:not(.is-bordered) .el-descriptions-item__cell {
padding-bottom: 16px;
}
}
/* 文档和图片样式 */
.imageStyle1 {
width: 200px;
height: 130px;
vertical-align: middle;
text-align: center;
align-content: center;
padding: 5px 5px;
border: 1px solid #1890ff;
margin-right: 15px;
font-size: 16px;
word-wrap: break-all;
}
.imageStyle1:hover {
border: 1px dashed #1890ff;
cursor: pointer;
box-shadow: 3px 3px 5px #81c3ff;
}
.imageStyle1 a {
color: #515a6e;
}
/* 图片样式 */
.imageStyle2 {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: flex-start;
align-content: center;
}
.imageStyle2 .el-image {
display: inline-block;
margin: 2px 10px;
}
.imageStyle2 video {
display: inline-block;
margin: 2px 10px;
}
/* 表格超出隐藏 */
.el-table__row {
height: 60px;
overflow: hidden;
}
/**简介样式 */
.descrt {
text-overflow: -o-ellipsis-lastline;
height: 260px;
overflow: auto;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 7;
-webkit-box-orient: vertical;
border: 1px solid #e6ebf5;
text-indent: 2em;
/*缩进*/
padding: 6px;
}
.descrt::-webkit-scrollbar {
display: none;
}
/**资料样式 */
.descrt2 {
display: flex;
justify-content: flex-start;
flex-wrap: wrap;
min-height: 300px;
max-height: 500px;
overflow: auto;
// border: 1px solid #e6ebf5;
padding: 10px;
box-sizing: border-box;
}
//隐藏滚动条
.descrt2::-webkit-scrollbar {
display: none;
}
.front1 {
font-weight: bold;
font-size: 14px;
padding: 10px;
line-height: 30px;
}
.front2 {
font-weight: bold;
font-size: 14px;
padding: 10px;
line-height: 30px;
}
.el-form-item ::v-deep .el-upload-list {
height: 110px;
overflow-y: scroll;
}
</style>
4.关闭标签
/** 保存xml */
save(data) {
const params = {
name: data.process.name,
category: data.process.category,
xml: data.xml
}
saveXml(params).then(res => {
this.$message(res.msg)
// 关闭当前标签页
this.$store.dispatch("tagsView/delView", this.$route);
this.$router.go(-1)
})
},