添加文件缓存
This commit is contained in:
parent
469548b972
commit
98244fc048
@ -2,6 +2,7 @@ package com.ruoyi.productionManager.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.productionManager.domain.StandardInfo;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 试验标准管理Service接口
|
||||
@ -58,4 +59,11 @@ public interface IStandardInfoService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteStandardInfoByStandardId(Long standardId);
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
public String uploadFile(MultipartFile file);
|
||||
}
|
||||
|
@ -1,12 +1,24 @@
|
||||
package com.ruoyi.productionManager.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.ruoyi.common.config.RuoYiConfig;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.file.FileUploadUtils;
|
||||
import com.ruoyi.common.utils.uuid.IdUtils;
|
||||
import io.netty.handler.codec.base64.Base64;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.productionManager.mapper.StandardInfoMapper;
|
||||
import com.ruoyi.productionManager.domain.StandardInfo;
|
||||
import com.ruoyi.productionManager.service.IStandardInfoService;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import sun.misc.BASE64Encoder;
|
||||
|
||||
/**
|
||||
* 试验标准管理Service业务层处理
|
||||
@ -20,6 +32,9 @@ public class StandardInfoServiceImpl implements IStandardInfoService
|
||||
@Autowired
|
||||
private StandardInfoMapper standardInfoMapper;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
/**
|
||||
* 查询试验标准管理
|
||||
*
|
||||
@ -93,4 +108,38 @@ public class StandardInfoServiceImpl implements IStandardInfoService
|
||||
{
|
||||
return standardInfoMapper.deleteStandardInfoByStandardId(standardId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String uploadFile(MultipartFile file) {
|
||||
try {
|
||||
String filePath = RuoYiConfig.getUploadPath();
|
||||
IdUtils.fastUUID();
|
||||
// 上传并返回新文件名称
|
||||
String fileName = FileUploadUtils.upload(filePath, file);
|
||||
String name ="";
|
||||
for(String s:fileName.split("/",9)){
|
||||
System.out.println("path>>>"+s);
|
||||
name = s;
|
||||
}
|
||||
Byte[] data = new Byte[file.getResource().getInputStream().available()];
|
||||
redisCache.setCacheObject(Constants.UPLOAD_FILE+name,
|
||||
data, 30, TimeUnit.MINUTES);
|
||||
// 取出缓存数据
|
||||
Byte[] bytes = redisCache.getCacheObject(Constants.UPLOAD_FILE+name);
|
||||
|
||||
return fileName;
|
||||
}catch (Exception e){
|
||||
throw new ServiceException("上传失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 设置cache key
|
||||
*
|
||||
* @param fileName 参数键
|
||||
* @return 缓存键key
|
||||
*/
|
||||
private String getCacheKey(String fileName)
|
||||
{
|
||||
return Constants.UPLOAD_FILE + fileName;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.ruoyi.web.controller.productionManager;
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.common.config.RuoYiConfig;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.utils.file.FileUploadUtils;
|
||||
import com.ruoyi.framework.config.ServerConfig;
|
||||
import com.ruoyi.productionManager.domain.StandardInfo;
|
||||
@ -111,18 +112,22 @@ public class StandardInfoController extends BaseController
|
||||
|
||||
@PostMapping("/upload")
|
||||
public AjaxResult getFiles(@Param("file") MultipartFile file){
|
||||
try{
|
||||
String filePath = RuoYiConfig.getUploadPath();
|
||||
// 上传并返回新文件名称
|
||||
String fileName = FileUploadUtils.upload(filePath, file);
|
||||
// String filePath = RuoYiConfig.getUploadPath();
|
||||
// // 上传并返回新文件名称
|
||||
// String fileName = FileUploadUtils.upload(filePath, file);
|
||||
String fileName = standardInfoService.uploadFile(file);
|
||||
String url = serverConfig.getUrl() + fileName;
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("fileName", fileName);
|
||||
ajax.put("url", url);
|
||||
return ajax;
|
||||
}catch (Exception e){
|
||||
return AjaxResult.error(e.getMessage());
|
||||
url.split("/");
|
||||
String path ="";
|
||||
for(String s:url.split("/",4)){
|
||||
System.out.println("path>>>"+s);
|
||||
path = s;
|
||||
}
|
||||
ajax.put("url", path);
|
||||
return ajax;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -148,4 +148,9 @@ public class Constants
|
||||
* LDAP 远程方法调用
|
||||
*/
|
||||
public static final String LOOKUP_LDAP = "ldap://";
|
||||
|
||||
/**
|
||||
* LDAP 远程方法调用
|
||||
*/
|
||||
public static final String UPLOAD_FILE = "file:";
|
||||
}
|
||||
|
@ -2,7 +2,12 @@ package com.ruoyi.common.utils.file;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Base64;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.ruoyi.common.config.RuoYiConfig;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
@ -12,6 +17,7 @@ import com.ruoyi.common.exception.file.InvalidExtensionException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.uuid.IdUtils;
|
||||
import sun.misc.BASE64Encoder;
|
||||
|
||||
/**
|
||||
* 文件上传工具类
|
||||
@ -20,6 +26,7 @@ import com.ruoyi.common.utils.uuid.IdUtils;
|
||||
*/
|
||||
public class FileUploadUtils
|
||||
{
|
||||
|
||||
/**
|
||||
* 默认大小 50M
|
||||
*/
|
||||
@ -110,8 +117,8 @@ public class FileUploadUtils
|
||||
|
||||
String fileName = extractFilename(file);
|
||||
|
||||
File desc = getAbsoluteFile(baseDir, fileName);
|
||||
file.transferTo(desc);
|
||||
// File desc = getAbsoluteFile(baseDir, fileName);
|
||||
// file.transferTo(desc);
|
||||
String pathFileName = getPathFileName(baseDir, fileName);
|
||||
return pathFileName;
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-upload
|
||||
:action="uploadUrl"
|
||||
<el-upload :action="uploadUrl"
|
||||
:before-upload="handleBeforeUpload"
|
||||
:on-success="handleUploadSuccess"
|
||||
:on-error="handleUploadError"
|
||||
@ -10,10 +9,11 @@
|
||||
:headers="headers"
|
||||
style="display: none"
|
||||
ref="upload"
|
||||
v-if="this.type == 'url'"
|
||||
>
|
||||
v-if="this.type == 'url'">
|
||||
</el-upload>
|
||||
<div class="editor" ref="editor" :style="styles"></div>
|
||||
<div class="editor"
|
||||
ref="editor"
|
||||
:style="styles"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -58,7 +58,7 @@ export default {
|
||||
default: "url",
|
||||
}
|
||||
},
|
||||
data() {
|
||||
data () {
|
||||
return {
|
||||
uploadUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 上传的图片服务器地址
|
||||
headers: {
|
||||
@ -91,7 +91,7 @@ export default {
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
styles() {
|
||||
styles () {
|
||||
let style = {};
|
||||
if (this.minHeight) {
|
||||
style.minHeight = `${this.minHeight}px`;
|
||||
@ -104,7 +104,7 @@ export default {
|
||||
},
|
||||
watch: {
|
||||
value: {
|
||||
handler(val) {
|
||||
handler (val) {
|
||||
if (val !== this.currentValue) {
|
||||
this.currentValue = val === null ? "" : val;
|
||||
if (this.Quill) {
|
||||
@ -115,14 +115,14 @@ export default {
|
||||
immediate: true,
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
mounted () {
|
||||
this.init();
|
||||
},
|
||||
beforeDestroy() {
|
||||
beforeDestroy () {
|
||||
this.Quill = null;
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
init () {
|
||||
const editor = this.$refs.editor;
|
||||
this.Quill = new Quill(editor, this.options);
|
||||
// 如果设置了上传地址则自定义图片上传事件
|
||||
@ -157,7 +157,7 @@ export default {
|
||||
});
|
||||
},
|
||||
// 上传前校检格式和大小
|
||||
handleBeforeUpload(file) {
|
||||
handleBeforeUpload (file) {
|
||||
// 校检文件大小
|
||||
if (this.fileSize) {
|
||||
const isLt = file.size / 1024 / 1024 < this.fileSize;
|
||||
@ -168,7 +168,7 @@ export default {
|
||||
}
|
||||
return true;
|
||||
},
|
||||
handleUploadSuccess(res, file) {
|
||||
handleUploadSuccess (res, file) {
|
||||
// 获取富文本组件实例
|
||||
let quill = this.Quill;
|
||||
// 如果上传成功
|
||||
@ -183,7 +183,7 @@ export default {
|
||||
this.$message.error("图片插入失败");
|
||||
}
|
||||
},
|
||||
handleUploadError() {
|
||||
handleUploadError () {
|
||||
this.$message.error("图片插入失败");
|
||||
},
|
||||
},
|
||||
@ -191,7 +191,8 @@ export default {
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.editor, .ql-toolbar {
|
||||
.editor,
|
||||
.ql-toolbar {
|
||||
white-space: pre-wrap !important;
|
||||
line-height: normal !important;
|
||||
}
|
||||
|
@ -1,174 +1,265 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="区域分类" prop="areaCategory">
|
||||
<el-input
|
||||
v-model="queryParams.areaCategory"
|
||||
<el-form :model="queryParams"
|
||||
ref="queryForm"
|
||||
:inline="true"
|
||||
v-show="showSearch"
|
||||
label-width="68px">
|
||||
<el-form-item label="区域分类"
|
||||
prop="areaCategory">
|
||||
<el-input v-model="queryParams.areaCategory"
|
||||
placeholder="请输入区域分类"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
@keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="标准名称" prop="standardName">
|
||||
<el-input
|
||||
v-model="queryParams.standardName"
|
||||
<el-form-item label="标准名称"
|
||||
prop="standardName">
|
||||
<el-input v-model="queryParams.standardName"
|
||||
placeholder="请输入标准名称"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
@keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="标准类型" prop="standardCategory">
|
||||
<el-select v-model="queryParams.standardCategory" placeholder="请选择标准类型" clearable size="small">
|
||||
<el-option
|
||||
v-for="dict in dict.type.pro_standard_category"
|
||||
<el-form-item label="标准类型"
|
||||
prop="standardCategory">
|
||||
<el-select v-model="queryParams.standardCategory"
|
||||
placeholder="请选择标准类型"
|
||||
clearable
|
||||
size="small">
|
||||
<el-option v-for="dict in dict.type.pro_standard_category"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
:value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="实施日期" prop="standardBeginDate">
|
||||
<el-date-picker clearable size="small"
|
||||
<el-form-item label="实施日期"
|
||||
prop="standardBeginDate">
|
||||
<el-date-picker clearable
|
||||
size="small"
|
||||
v-model="queryParams.standardBeginDate"
|
||||
type="date"
|
||||
value-format="yyyy-MM-dd"
|
||||
placeholder="选择实施日期">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="标准状态" prop="standardStatus">
|
||||
<el-select v-model="queryParams.standardStatus" placeholder="请选择标准状态" clearable size="small">
|
||||
<el-option
|
||||
v-for="dict in dict.type.pro_standard_status"
|
||||
<el-form-item label="标准状态"
|
||||
prop="standardStatus">
|
||||
<el-select v-model="queryParams.standardStatus"
|
||||
placeholder="请选择标准状态"
|
||||
clearable
|
||||
size="small">
|
||||
<el-option v-for="dict in dict.type.pro_standard_status"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
:value="dict.value" />
|
||||
</el-select>
|
||||
</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-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-row :gutter="10"
|
||||
class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
<el-button type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['productionManager:standard:add']"
|
||||
>新增</el-button>
|
||||
v-hasPermi="['productionManager:standard:add']">新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
<el-button type="success"
|
||||
plain
|
||||
icon="el-icon-edit"
|
||||
size="mini"
|
||||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
v-hasPermi="['productionManager:standard:edit']"
|
||||
>修改</el-button>
|
||||
v-hasPermi="['productionManager:standard:edit']">修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
<el-button type="danger"
|
||||
plain
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['productionManager:standard:remove']"
|
||||
>删除</el-button>
|
||||
v-hasPermi="['productionManager:standard:remove']">删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
<el-button type="warning"
|
||||
plain
|
||||
icon="el-icon-download"
|
||||
size="mini"
|
||||
:loading="exportLoading"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['productionManager:standard:export']"
|
||||
>导出</el-button>
|
||||
v-hasPermi="['productionManager:standard:export']">导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
<right-toolbar :showSearch.sync="showSearch"
|
||||
@queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="standardList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="标准id" align="center" prop="standardId" />
|
||||
<el-table-column label="区域分类" align="center" prop="areaCategory" />
|
||||
<el-table-column label="标准名称" align="center" prop="standardName" />
|
||||
<el-table-column label="标准类型" align="center" prop="standardCategory">
|
||||
<el-table v-loading="loading"
|
||||
:data="standardList"
|
||||
@selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection"
|
||||
width="55"
|
||||
align="center" />
|
||||
<el-table-column label="标准id"
|
||||
align="center"
|
||||
prop="standardId"
|
||||
v-if="false" />
|
||||
<el-table-column label="区域分类"
|
||||
align="center"
|
||||
prop="areaCategory" />
|
||||
<el-table-column label="标准名称"
|
||||
align="center"
|
||||
prop="standardName" />
|
||||
<el-table-column label="标准类型"
|
||||
align="center"
|
||||
prop="standardCategory">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.pro_standard_category" :value="scope.row.standardCategory"/>
|
||||
<dict-tag :options="dict.type.pro_standard_category"
|
||||
:value="scope.row.standardCategory" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="实施日期" align="center" prop="standardBeginDate" width="180">
|
||||
<el-table-column label="实施日期"
|
||||
align="center"
|
||||
prop="standardBeginDate"
|
||||
width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.standardBeginDate, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="标准状态" align="center" prop="standardStatus">
|
||||
<el-table-column label="标准状态"
|
||||
align="center"
|
||||
prop="standardStatus">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.pro_standard_status" :value="scope.row.standardStatus"/>
|
||||
<dict-tag :options="dict.type.pro_standard_status"
|
||||
:value="scope.row.standardStatus" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<el-table-column label="备注"
|
||||
align="center"
|
||||
prop="remark" />
|
||||
<el-table-column label="操作"
|
||||
align="center"
|
||||
class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
<el-button size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['productionManager:standard:edit']"
|
||||
>修改</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
v-hasPermi="['productionManager:standard:edit']">修改</el-button>
|
||||
<el-button size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['productionManager:standard:remove']"
|
||||
>删除</el-button>
|
||||
v-hasPermi="['productionManager:standard:remove']">删除</el-button>
|
||||
<el-button size="mini"
|
||||
type="text"
|
||||
icon="el-icon-download"
|
||||
@click="downloadFile(scope.row)"
|
||||
v-hasPermi="['productionManager:standard:remove']">下载</el-button>
|
||||
<el-dropdown size="mini"
|
||||
@command="(command) => handleCommand(command, scope.row)"
|
||||
v-hasPermi="['system:user:resetPwd', 'system:user:edit']">
|
||||
<span class="el-dropdown-link">
|
||||
<i class="el-icon-d-arrow-right el-icon--right"></i>更多
|
||||
</span>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<!-- <el-dropdown-item command="handleResetPwd"
|
||||
icon="el-icon-key"
|
||||
v-hasPermi="['system:user:resetPwd']">重置密码</el-dropdown-item>
|
||||
<el-dropdown-item command="handleAuthRole"
|
||||
icon="el-icon-circle-check"
|
||||
v-hasPermi="['system:user:edit']">分配角色</el-dropdown-item> -->
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
<pagination v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
@pagination="getList" />
|
||||
|
||||
<!-- 添加或修改试验标准管理对话框 -->
|
||||
<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="areaCategory">
|
||||
<el-input v-model="form.areaCategory" placeholder="请输入区域分类" />
|
||||
<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="areaCategory">
|
||||
<el-input v-model="form.areaCategory"
|
||||
placeholder="请输入区域分类" />
|
||||
</el-form-item>
|
||||
<el-form-item label="标准名称" prop="standardName">
|
||||
<el-input v-model="form.standardName" placeholder="请输入标准名称" />
|
||||
<el-form-item label="标准名称"
|
||||
prop="standardName">
|
||||
<el-input v-model="form.standardName"
|
||||
placeholder="请输入标准名称" />
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="PDF文件"
|
||||
prop="pdfFiles">
|
||||
</el-form-item> -->
|
||||
|
||||
<el-form-item label="上传"
|
||||
prop="path">
|
||||
<el-input v-model="form.path"
|
||||
placeholder="请选择上传文件"
|
||||
:disabled="true" />
|
||||
<!-- accept=".jpg, .png" -->
|
||||
<el-upload ref="upload"
|
||||
:limit="1"
|
||||
: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">只能上传jpg/png文件,且不超过500kb</div> -->
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item size="large">
|
||||
<el-button type="primary"
|
||||
@click="submitForm">提交</el-button>
|
||||
<el-button @click="resetForm">重置</el-button>
|
||||
</el-form-item> -->
|
||||
|
||||
<el-form-item label="标准类型">
|
||||
<el-radio-group v-model="form.standardCategory">
|
||||
<el-radio
|
||||
v-for="dict in dict.type.pro_standard_category"
|
||||
<el-radio v-for="dict in dict.type.pro_standard_category"
|
||||
:key="dict.value"
|
||||
:label="dict.value"
|
||||
>{{dict.label}}</el-radio>
|
||||
:label="dict.value">{{dict.label}}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="实施日期" prop="standardBeginDate">
|
||||
<el-date-picker clearable size="small"
|
||||
<el-form-item label="实施日期"
|
||||
prop="standardBeginDate">
|
||||
<el-date-picker clearable
|
||||
size="small"
|
||||
v-model="form.standardBeginDate"
|
||||
type="date"
|
||||
value-format="yyyy-MM-dd"
|
||||
@ -177,19 +268,22 @@
|
||||
</el-form-item>
|
||||
<el-form-item label="标准状态">
|
||||
<el-radio-group v-model="form.standardStatus">
|
||||
<el-radio
|
||||
v-for="dict in dict.type.pro_standard_status"
|
||||
<el-radio v-for="dict in dict.type.pro_standard_status"
|
||||
:key="dict.value"
|
||||
:label="dict.value"
|
||||
>{{dict.label}}</el-radio>
|
||||
:label="dict.value">{{dict.label}}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||
<el-form-item label="备注"
|
||||
prop="remark">
|
||||
<el-input v-model="form.remark"
|
||||
type="textarea"
|
||||
placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<div slot="footer"
|
||||
class="dialog-footer">
|
||||
<el-button type="primary"
|
||||
@click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
@ -198,12 +292,41 @@
|
||||
|
||||
<script>
|
||||
import { listStandard, getStandard, delStandard, addStandard, updateStandard, exportStandard } from "@/api/productionManager/standard";
|
||||
import { getToken } from "@/utils/auth";
|
||||
|
||||
export default {
|
||||
// pdf文件导入参数
|
||||
|
||||
//
|
||||
|
||||
name: "Standard",
|
||||
dicts: ['pro_standard_category', 'pro_standard_status'],
|
||||
data() {
|
||||
data () {
|
||||
var validatorPath = (rule, value, callback) => {
|
||||
if (value === '') {
|
||||
callback(new Error('请上传文件'));
|
||||
} else {
|
||||
// if (this.form.path !== '') {
|
||||
// this.$refs.ruleForm.validateField('checkPass');
|
||||
// }
|
||||
callback();
|
||||
}
|
||||
};
|
||||
return {
|
||||
//导入相关参数 process.env.VUE_APP_BASE_API + "/productionManager/standard/upload"
|
||||
// 上传参数
|
||||
upload: {
|
||||
// 是否禁用上传
|
||||
isUploading: false,
|
||||
// 设置上传的请求头部
|
||||
headers: { Authorization: "Bearer " + getToken() },
|
||||
// 上传的地址
|
||||
url: process.env.VUE_APP_BASE_API + "/productionManager/standard/upload",
|
||||
// 上传的文件列表
|
||||
fileList: [],
|
||||
filePath: ""
|
||||
|
||||
},
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 导出遮罩层
|
||||
@ -233,6 +356,7 @@ export default {
|
||||
standardCategory: null,
|
||||
standardBeginDate: null,
|
||||
standardStatus: null,
|
||||
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
@ -250,15 +374,63 @@ export default {
|
||||
standardStatus: [
|
||||
{ required: true, message: "标准状态不能为空", trigger: "blur" }
|
||||
],
|
||||
// path: [
|
||||
// { required: true, message: "文件不能为空", trigger: ["blur"] }
|
||||
// ],
|
||||
// path: [
|
||||
// { required: true, validator: validatorPath, trigger: ["blur", "change"] }
|
||||
// ],
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
created () {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
// pdf导入相关方法
|
||||
// submitForm () {
|
||||
// this.$refs['elForm'].validate(valid => {
|
||||
// if (!valid) return
|
||||
// // TODO 提交表单
|
||||
// })
|
||||
// },
|
||||
// resetForm () {
|
||||
// this.$refs['elForm'].resetFields()
|
||||
// },
|
||||
|
||||
|
||||
pdffileBeforeUpload (file) {
|
||||
let isRightSize = file.size / 1024 / 1024 < 20
|
||||
if (!isRightSize) {
|
||||
this.$message.error('文件大小超过 20MB')
|
||||
}
|
||||
let isAccept = new RegExp('.pdf').test(file.type)
|
||||
if (!isAccept) {
|
||||
this.$message.error('应该选择.pdf类型的文件')
|
||||
}
|
||||
return isRightSize && isAccept
|
||||
},
|
||||
// 文件提交处理
|
||||
submitUpload () {
|
||||
this.$refs.upload.submit();
|
||||
},
|
||||
// 文件上传中处理
|
||||
handleFileUploadProgress (event, file, fileList) {
|
||||
this.upload.isUploading = true;
|
||||
},
|
||||
// 文件上传成功处理
|
||||
handleFileSuccess (response, file, fileList) {
|
||||
this.upload.isUploading = false;
|
||||
this.upload.filePath = response.url;
|
||||
console.log("filepath>>>" + this.upload.filePath)
|
||||
this.form.path = response.url;
|
||||
this.$modal.msgSuccess(response.msg);
|
||||
// this.$nextTick(() => this.$refs.form.clearValidate())
|
||||
},
|
||||
|
||||
|
||||
/** 查询试验标准管理列表 */
|
||||
getList() {
|
||||
getList () {
|
||||
this.loading = true;
|
||||
listStandard(this.queryParams).then(response => {
|
||||
this.standardList = response.rows;
|
||||
@ -267,12 +439,12 @@ export default {
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
cancel () {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
reset () {
|
||||
this.form = {
|
||||
standardId: null,
|
||||
areaCategory: null,
|
||||
@ -289,29 +461,30 @@ export default {
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
handleQuery () {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
resetQuery () {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
handleSelectionChange (selection) {
|
||||
this.ids = selection.map(item => item.standardId)
|
||||
this.single = selection.length!==1
|
||||
this.single = selection.length !== 1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
handleAdd () {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.upload.fileList = [];
|
||||
this.title = "添加试验标准管理";
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
handleUpdate (row) {
|
||||
this.reset();
|
||||
const standardId = row.standardId || this.ids
|
||||
getStandard(standardId).then(response => {
|
||||
@ -321,7 +494,7 @@ export default {
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
submitForm () {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.form.standardId != null) {
|
||||
@ -341,17 +514,17 @@ export default {
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
handleDelete (row) {
|
||||
const standardIds = row.standardId || this.ids;
|
||||
this.$modal.confirm('是否确认删除试验标准管理编号为"' + standardIds + '"的数据项?').then(function() {
|
||||
this.$modal.confirm('是否确认删除试验标准管理编号为"' + standardIds + '"的数据项?').then(function () {
|
||||
return delStandard(standardIds);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
}).catch(() => { });
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
handleExport () {
|
||||
const queryParams = this.queryParams;
|
||||
this.$modal.confirm('是否确认导出所有试验标准管理数据项?').then(() => {
|
||||
this.exportLoading = true;
|
||||
@ -359,8 +532,13 @@ export default {
|
||||
}).then(response => {
|
||||
this.$download.name(response.msg);
|
||||
this.exportLoading = false;
|
||||
}).catch(() => {});
|
||||
}).catch(() => { });
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
.el-upload__tip {
|
||||
line-height: 1.2;
|
||||
}
|
||||
</style>
|
||||
|
@ -693,9 +693,9 @@ create table STANDARD_INFO (
|
||||
standard_id bigint(20) not null auto_increment comment '标准id',
|
||||
area_category varchar(120) not null comment '区域分类',
|
||||
standard_name varchar(200) not null comment '标准名称',
|
||||
standard_category varchar(200) not null comment '标准类型',(字典处理)
|
||||
standard_category varchar(200) not null comment '标准类型',
|
||||
standard_begin_date varchar(250) null comment '标准实施日期',
|
||||
standard_status varchar(20) not null comment '标准状态',(字典处理)
|
||||
standard_status varchar(20) not null comment '标准状态',
|
||||
create_by varchar(64) default '' comment '创建者',
|
||||
create_time datetime comment '创建时间',
|
||||
update_by varchar(64) default '' comment '更新者',
|
||||
@ -703,10 +703,12 @@ create table STANDARD_INFO (
|
||||
remark varchar(500) default null comment '备注',
|
||||
primary key (standard_id)
|
||||
) engine=innodb comment = '标准信息表';
|
||||
|
||||
|
||||
drop table if exists STANDARD_INFO_DETAILS;
|
||||
create table STANDARD_INFO_DETAILS (
|
||||
standard_id bigint(20) not null auto_increment comment '标准id',
|
||||
details_id bigint(20) not null comment '岗位ID',
|
||||
details_id bigint(20) not null auto_increment comment '标准明细ID',
|
||||
standard_id bigint(20) not null comment '标准id',
|
||||
file_name varchar(200) not null comment '文件名称',
|
||||
file_url varchar(200) not null comment '文件路径',
|
||||
create_by varchar(64) default '' comment '创建者',
|
||||
@ -714,5 +716,5 @@ create table STANDARD_INFO_DETAILS (
|
||||
update_by varchar(64) default '' comment '更新者',
|
||||
update_time datetime comment '更新时间',
|
||||
remark varchar(500) default null comment '备注',
|
||||
primary key (standard_id, details_id)
|
||||
primary key (details_id,standard_id)
|
||||
) engine=innodb comment = '标准信息文件表';
|
||||
|
Loading…
x
Reference in New Issue
Block a user