添加文件缓存

This commit is contained in:
JiaXing_Cheng@163.com 2021-10-15 17:27:07 +08:00
parent 469548b972
commit 98244fc048
8 changed files with 449 additions and 194 deletions

View File

@ -2,6 +2,7 @@ package com.ruoyi.productionManager.service;
import java.util.List; import java.util.List;
import com.ruoyi.productionManager.domain.StandardInfo; import com.ruoyi.productionManager.domain.StandardInfo;
import org.springframework.web.multipart.MultipartFile;
/** /**
* 试验标准管理Service接口 * 试验标准管理Service接口
@ -58,4 +59,11 @@ public interface IStandardInfoService
* @return 结果 * @return 结果
*/ */
public int deleteStandardInfoByStandardId(Long standardId); public int deleteStandardInfoByStandardId(Long standardId);
/**
* 上传文件
* @param file
* @return
*/
public String uploadFile(MultipartFile file);
} }

View File

@ -1,12 +1,24 @@
package com.ruoyi.productionManager.service.impl; package com.ruoyi.productionManager.service.impl;
import java.util.List; 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.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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.productionManager.mapper.StandardInfoMapper; import com.ruoyi.productionManager.mapper.StandardInfoMapper;
import com.ruoyi.productionManager.domain.StandardInfo; import com.ruoyi.productionManager.domain.StandardInfo;
import com.ruoyi.productionManager.service.IStandardInfoService; import com.ruoyi.productionManager.service.IStandardInfoService;
import org.springframework.web.multipart.MultipartFile;
import sun.misc.BASE64Encoder;
/** /**
* 试验标准管理Service业务层处理 * 试验标准管理Service业务层处理
@ -20,6 +32,9 @@ public class StandardInfoServiceImpl implements IStandardInfoService
@Autowired @Autowired
private StandardInfoMapper standardInfoMapper; private StandardInfoMapper standardInfoMapper;
@Autowired
private RedisCache redisCache;
/** /**
* 查询试验标准管理 * 查询试验标准管理
* *
@ -93,4 +108,38 @@ public class StandardInfoServiceImpl implements IStandardInfoService
{ {
return standardInfoMapper.deleteStandardInfoByStandardId(standardId); 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;
}
} }

View File

@ -3,6 +3,7 @@ package com.ruoyi.web.controller.productionManager;
import java.util.List; import java.util.List;
import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.utils.file.FileUploadUtils; import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.framework.config.ServerConfig; import com.ruoyi.framework.config.ServerConfig;
import com.ruoyi.productionManager.domain.StandardInfo; import com.ruoyi.productionManager.domain.StandardInfo;
@ -111,18 +112,22 @@ public class StandardInfoController extends BaseController
@PostMapping("/upload") @PostMapping("/upload")
public AjaxResult getFiles(@Param("file") MultipartFile file){ public AjaxResult getFiles(@Param("file") MultipartFile file){
try{ // String filePath = RuoYiConfig.getUploadPath();
String filePath = RuoYiConfig.getUploadPath(); // // 上传并返回新文件名称
// 上传并返回新文件名称 // String fileName = FileUploadUtils.upload(filePath, file);
String fileName = FileUploadUtils.upload(filePath, file); String fileName = standardInfoService.uploadFile(file);
String url = serverConfig.getUrl() + fileName; String url = serverConfig.getUrl() + fileName;
AjaxResult ajax = AjaxResult.success(); AjaxResult ajax = AjaxResult.success();
ajax.put("fileName", fileName); ajax.put("fileName", fileName);
ajax.put("url", url); url.split("/");
return ajax; String path ="";
}catch (Exception e){ for(String s:url.split("/",4)){
return AjaxResult.error(e.getMessage()); System.out.println("path>>>"+s);
path = s;
} }
ajax.put("url", path);
return ajax;
} }
} }

View File

@ -148,4 +148,9 @@ public class Constants
* LDAP 远程方法调用 * LDAP 远程方法调用
*/ */
public static final String LOOKUP_LDAP = "ldap://"; public static final String LOOKUP_LDAP = "ldap://";
/**
* LDAP 远程方法调用
*/
public static final String UPLOAD_FILE = "file:";
} }

View File

@ -2,7 +2,12 @@ package com.ruoyi.common.utils.file;
import java.io.File; import java.io.File;
import java.io.IOException; 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.apache.commons.io.FilenameUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.constant.Constants; 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.DateUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.uuid.IdUtils; 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 public class FileUploadUtils
{ {
/** /**
* 默认大小 50M * 默认大小 50M
*/ */
@ -110,8 +117,8 @@ public class FileUploadUtils
String fileName = extractFilename(file); String fileName = extractFilename(file);
File desc = getAbsoluteFile(baseDir, fileName); // File desc = getAbsoluteFile(baseDir, fileName);
file.transferTo(desc); // file.transferTo(desc);
String pathFileName = getPathFileName(baseDir, fileName); String pathFileName = getPathFileName(baseDir, fileName);
return pathFileName; return pathFileName;
} }

View File

@ -1,7 +1,6 @@
<template> <template>
<div> <div>
<el-upload <el-upload :action="uploadUrl"
:action="uploadUrl"
:before-upload="handleBeforeUpload" :before-upload="handleBeforeUpload"
:on-success="handleUploadSuccess" :on-success="handleUploadSuccess"
:on-error="handleUploadError" :on-error="handleUploadError"
@ -10,10 +9,11 @@
:headers="headers" :headers="headers"
style="display: none" style="display: none"
ref="upload" ref="upload"
v-if="this.type == 'url'" v-if="this.type == 'url'">
>
</el-upload> </el-upload>
<div class="editor" ref="editor" :style="styles"></div> <div class="editor"
ref="editor"
:style="styles"></div>
</div> </div>
</template> </template>
@ -58,7 +58,7 @@ export default {
default: "url", default: "url",
} }
}, },
data() { data () {
return { return {
uploadUrl: process.env.VUE_APP_BASE_API + "/common/upload", // uploadUrl: process.env.VUE_APP_BASE_API + "/common/upload", //
headers: { headers: {
@ -91,7 +91,7 @@ export default {
}; };
}, },
computed: { computed: {
styles() { styles () {
let style = {}; let style = {};
if (this.minHeight) { if (this.minHeight) {
style.minHeight = `${this.minHeight}px`; style.minHeight = `${this.minHeight}px`;
@ -104,7 +104,7 @@ export default {
}, },
watch: { watch: {
value: { value: {
handler(val) { handler (val) {
if (val !== this.currentValue) { if (val !== this.currentValue) {
this.currentValue = val === null ? "" : val; this.currentValue = val === null ? "" : val;
if (this.Quill) { if (this.Quill) {
@ -115,14 +115,14 @@ export default {
immediate: true, immediate: true,
}, },
}, },
mounted() { mounted () {
this.init(); this.init();
}, },
beforeDestroy() { beforeDestroy () {
this.Quill = null; this.Quill = null;
}, },
methods: { methods: {
init() { init () {
const editor = this.$refs.editor; const editor = this.$refs.editor;
this.Quill = new Quill(editor, this.options); this.Quill = new Quill(editor, this.options);
// //
@ -157,7 +157,7 @@ export default {
}); });
}, },
// //
handleBeforeUpload(file) { handleBeforeUpload (file) {
// //
if (this.fileSize) { if (this.fileSize) {
const isLt = file.size / 1024 / 1024 < this.fileSize; const isLt = file.size / 1024 / 1024 < this.fileSize;
@ -168,7 +168,7 @@ export default {
} }
return true; return true;
}, },
handleUploadSuccess(res, file) { handleUploadSuccess (res, file) {
// //
let quill = this.Quill; let quill = this.Quill;
// //
@ -183,7 +183,7 @@ export default {
this.$message.error("图片插入失败"); this.$message.error("图片插入失败");
} }
}, },
handleUploadError() { handleUploadError () {
this.$message.error("图片插入失败"); this.$message.error("图片插入失败");
}, },
}, },
@ -191,7 +191,8 @@ export default {
</script> </script>
<style> <style>
.editor, .ql-toolbar { .editor,
.ql-toolbar {
white-space: pre-wrap !important; white-space: pre-wrap !important;
line-height: normal !important; line-height: normal !important;
} }

View File

@ -1,174 +1,265 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> <el-form :model="queryParams"
<el-form-item label="区域分类" prop="areaCategory"> ref="queryForm"
<el-input :inline="true"
v-model="queryParams.areaCategory" v-show="showSearch"
label-width="68px">
<el-form-item label="区域分类"
prop="areaCategory">
<el-input v-model="queryParams.areaCategory"
placeholder="请输入区域分类" placeholder="请输入区域分类"
clearable clearable
size="small" size="small"
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery" />
/>
</el-form-item> </el-form-item>
<el-form-item label="标准名称" prop="standardName"> <el-form-item label="标准名称"
<el-input prop="standardName">
v-model="queryParams.standardName" <el-input v-model="queryParams.standardName"
placeholder="请输入标准名称" placeholder="请输入标准名称"
clearable clearable
size="small" size="small"
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery" />
/>
</el-form-item> </el-form-item>
<el-form-item label="标准类型" prop="standardCategory"> <el-form-item label="标准类型"
<el-select v-model="queryParams.standardCategory" placeholder="请选择标准类型" clearable size="small"> prop="standardCategory">
<el-option <el-select v-model="queryParams.standardCategory"
v-for="dict in dict.type.pro_standard_category" placeholder="请选择标准类型"
clearable
size="small">
<el-option v-for="dict in dict.type.pro_standard_category"
:key="dict.value" :key="dict.value"
:label="dict.label" :label="dict.label"
:value="dict.value" :value="dict.value" />
/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="实施日期" prop="standardBeginDate"> <el-form-item label="实施日期"
<el-date-picker clearable size="small" prop="standardBeginDate">
<el-date-picker clearable
size="small"
v-model="queryParams.standardBeginDate" v-model="queryParams.standardBeginDate"
type="date" type="date"
value-format="yyyy-MM-dd" value-format="yyyy-MM-dd"
placeholder="选择实施日期"> placeholder="选择实施日期">
</el-date-picker> </el-date-picker>
</el-form-item> </el-form-item>
<el-form-item label="标准状态" prop="standardStatus"> <el-form-item label="标准状态"
<el-select v-model="queryParams.standardStatus" placeholder="请选择标准状态" clearable size="small"> prop="standardStatus">
<el-option <el-select v-model="queryParams.standardStatus"
v-for="dict in dict.type.pro_standard_status" placeholder="请选择标准状态"
clearable
size="small">
<el-option v-for="dict in dict.type.pro_standard_status"
:key="dict.value" :key="dict.value"
:label="dict.label" :label="dict.label"
:value="dict.value" :value="dict.value" />
/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> <el-button type="primary"
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> 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-item>
</el-form> </el-form>
<el-row :gutter="10" class="mb8"> <el-row :gutter="10"
class="mb8">
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button type="primary"
type="primary"
plain plain
icon="el-icon-plus" icon="el-icon-plus"
size="mini" size="mini"
@click="handleAdd" @click="handleAdd"
v-hasPermi="['productionManager:standard:add']" v-hasPermi="['productionManager:standard:add']">新增</el-button>
>新增</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button type="success"
type="success"
plain plain
icon="el-icon-edit" icon="el-icon-edit"
size="mini" size="mini"
:disabled="single" :disabled="single"
@click="handleUpdate" @click="handleUpdate"
v-hasPermi="['productionManager:standard:edit']" v-hasPermi="['productionManager:standard:edit']">修改</el-button>
>修改</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button type="danger"
type="danger"
plain plain
icon="el-icon-delete" icon="el-icon-delete"
size="mini" size="mini"
:disabled="multiple" :disabled="multiple"
@click="handleDelete" @click="handleDelete"
v-hasPermi="['productionManager:standard:remove']" v-hasPermi="['productionManager:standard:remove']">删除</el-button>
>删除</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button type="warning"
type="warning"
plain plain
icon="el-icon-download" icon="el-icon-download"
size="mini" size="mini"
:loading="exportLoading" :loading="exportLoading"
@click="handleExport" @click="handleExport"
v-hasPermi="['productionManager:standard:export']" v-hasPermi="['productionManager:standard:export']">导出</el-button>
>导出</el-button>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch"
@queryTable="getList"></right-toolbar>
</el-row> </el-row>
<el-table v-loading="loading" :data="standardList" @selection-change="handleSelectionChange"> <el-table v-loading="loading"
<el-table-column type="selection" width="55" align="center" /> :data="standardList"
<el-table-column label="标准id" align="center" prop="standardId" /> @selection-change="handleSelectionChange">
<el-table-column label="区域分类" align="center" prop="areaCategory" /> <el-table-column type="selection"
<el-table-column label="标准名称" align="center" prop="standardName" /> width="55"
<el-table-column label="标准类型" align="center" prop="standardCategory"> 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"> <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> </template>
</el-table-column> </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"> <template slot-scope="scope">
<span>{{ parseTime(scope.row.standardBeginDate, '{y}-{m}-{d}') }}</span> <span>{{ parseTime(scope.row.standardBeginDate, '{y}-{m}-{d}') }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="标准状态" align="center" prop="standardStatus"> <el-table-column label="标准状态"
align="center"
prop="standardStatus">
<template slot-scope="scope"> <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> </template>
</el-table-column> </el-table-column>
<el-table-column label="备注" align="center" prop="remark" /> <el-table-column label="备注"
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> align="center"
prop="remark" />
<el-table-column label="操作"
align="center"
class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button size="mini"
size="mini"
type="text" type="text"
icon="el-icon-edit" icon="el-icon-edit"
@click="handleUpdate(scope.row)" @click="handleUpdate(scope.row)"
v-hasPermi="['productionManager:standard:edit']" v-hasPermi="['productionManager:standard:edit']">修改</el-button>
>修改</el-button> <el-button size="mini"
<el-button
size="mini"
type="text" type="text"
icon="el-icon-delete" icon="el-icon-delete"
@click="handleDelete(scope.row)" @click="handleDelete(scope.row)"
v-hasPermi="['productionManager:standard:remove']" v-hasPermi="['productionManager:standard:remove']">删除</el-button>
>删除</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> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<pagination <pagination v-show="total>0"
v-show="total>0"
:total="total" :total="total"
:page.sync="queryParams.pageNum" :page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize" :limit.sync="queryParams.pageSize"
@pagination="getList" @pagination="getList" />
/>
<!-- 添加或修改试验标准管理对话框 --> <!-- 添加或修改试验标准管理对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> <el-dialog :title="title"
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> :visible.sync="open"
<el-form-item label="区域分类" prop="areaCategory"> width="500px"
<el-input v-model="form.areaCategory" placeholder="请输入区域分类" /> 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>
<el-form-item label="标准名称" prop="standardName"> <el-form-item label="标准名称"
<el-input v-model="form.standardName" placeholder="请输入标准名称" /> prop="standardName">
<el-input v-model="form.standardName"
placeholder="请输入标准名称" />
</el-form-item> </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-form-item label="标准类型">
<el-radio-group v-model="form.standardCategory"> <el-radio-group v-model="form.standardCategory">
<el-radio <el-radio v-for="dict in dict.type.pro_standard_category"
v-for="dict in dict.type.pro_standard_category"
:key="dict.value" :key="dict.value"
:label="dict.value" :label="dict.value">{{dict.label}}</el-radio>
>{{dict.label}}</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="实施日期" prop="standardBeginDate"> <el-form-item label="实施日期"
<el-date-picker clearable size="small" prop="standardBeginDate">
<el-date-picker clearable
size="small"
v-model="form.standardBeginDate" v-model="form.standardBeginDate"
type="date" type="date"
value-format="yyyy-MM-dd" value-format="yyyy-MM-dd"
@ -177,19 +268,22 @@
</el-form-item> </el-form-item>
<el-form-item label="标准状态"> <el-form-item label="标准状态">
<el-radio-group v-model="form.standardStatus"> <el-radio-group v-model="form.standardStatus">
<el-radio <el-radio v-for="dict in dict.type.pro_standard_status"
v-for="dict in dict.type.pro_standard_status"
:key="dict.value" :key="dict.value"
:label="dict.value" :label="dict.value">{{dict.label}}</el-radio>
>{{dict.label}}</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="备注" prop="remark"> <el-form-item label="备注"
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" /> prop="remark">
<el-input v-model="form.remark"
type="textarea"
placeholder="请输入内容" />
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer"
<el-button type="primary" @click="submitForm"> </el-button> class="dialog-footer">
<el-button type="primary"
@click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button> <el-button @click="cancel"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
@ -198,12 +292,41 @@
<script> <script>
import { listStandard, getStandard, delStandard, addStandard, updateStandard, exportStandard } from "@/api/productionManager/standard"; import { listStandard, getStandard, delStandard, addStandard, updateStandard, exportStandard } from "@/api/productionManager/standard";
import { getToken } from "@/utils/auth";
export default { export default {
// pdf
//
name: "Standard", name: "Standard",
dicts: ['pro_standard_category', 'pro_standard_status'], 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 { 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, loading: true,
// //
@ -233,6 +356,7 @@ export default {
standardCategory: null, standardCategory: null,
standardBeginDate: null, standardBeginDate: null,
standardStatus: null, standardStatus: null,
}, },
// //
form: {}, form: {},
@ -250,15 +374,63 @@ export default {
standardStatus: [ standardStatus: [
{ required: true, message: "标准状态不能为空", trigger: "blur" } { required: true, message: "标准状态不能为空", trigger: "blur" }
], ],
// path: [
// { required: true, message: "", trigger: ["blur"] }
// ],
// path: [
// { required: true, validator: validatorPath, trigger: ["blur", "change"] }
// ],
} }
}; };
}, },
created() { created () {
this.getList(); this.getList();
}, },
methods: { 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; this.loading = true;
listStandard(this.queryParams).then(response => { listStandard(this.queryParams).then(response => {
this.standardList = response.rows; this.standardList = response.rows;
@ -267,12 +439,12 @@ export default {
}); });
}, },
// //
cancel() { cancel () {
this.open = false; this.open = false;
this.reset(); this.reset();
}, },
// //
reset() { reset () {
this.form = { this.form = {
standardId: null, standardId: null,
areaCategory: null, areaCategory: null,
@ -289,29 +461,30 @@ export default {
this.resetForm("form"); this.resetForm("form");
}, },
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery () {
this.queryParams.pageNum = 1; this.queryParams.pageNum = 1;
this.getList(); this.getList();
}, },
/** 重置按钮操作 */ /** 重置按钮操作 */
resetQuery() { resetQuery () {
this.resetForm("queryForm"); this.resetForm("queryForm");
this.handleQuery(); this.handleQuery();
}, },
// //
handleSelectionChange(selection) { handleSelectionChange (selection) {
this.ids = selection.map(item => item.standardId) this.ids = selection.map(item => item.standardId)
this.single = selection.length!==1 this.single = selection.length !== 1
this.multiple = !selection.length this.multiple = !selection.length
}, },
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd () {
this.reset(); this.reset();
this.open = true; this.open = true;
this.upload.fileList = [];
this.title = "添加试验标准管理"; this.title = "添加试验标准管理";
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate (row) {
this.reset(); this.reset();
const standardId = row.standardId || this.ids const standardId = row.standardId || this.ids
getStandard(standardId).then(response => { getStandard(standardId).then(response => {
@ -321,7 +494,7 @@ export default {
}); });
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm() { submitForm () {
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
if (this.form.standardId != null) { if (this.form.standardId != null) {
@ -341,17 +514,17 @@ export default {
}); });
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete (row) {
const standardIds = row.standardId || this.ids; const standardIds = row.standardId || this.ids;
this.$modal.confirm('是否确认删除试验标准管理编号为"' + standardIds + '"的数据项?').then(function() { this.$modal.confirm('是否确认删除试验标准管理编号为"' + standardIds + '"的数据项?').then(function () {
return delStandard(standardIds); return delStandard(standardIds);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.$modal.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
}).catch(() => {}); }).catch(() => { });
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport () {
const queryParams = this.queryParams; const queryParams = this.queryParams;
this.$modal.confirm('是否确认导出所有试验标准管理数据项?').then(() => { this.$modal.confirm('是否确认导出所有试验标准管理数据项?').then(() => {
this.exportLoading = true; this.exportLoading = true;
@ -359,8 +532,13 @@ export default {
}).then(response => { }).then(response => {
this.$download.name(response.msg); this.$download.name(response.msg);
this.exportLoading = false; this.exportLoading = false;
}).catch(() => {}); }).catch(() => { });
} }
} }
}; };
</script> </script>
<style>
.el-upload__tip {
line-height: 1.2;
}
</style>

View File

@ -693,9 +693,9 @@ create table STANDARD_INFO (
standard_id bigint(20) not null auto_increment comment '标准id', standard_id bigint(20) not null auto_increment comment '标准id',
area_category varchar(120) not null comment '区域分类', area_category varchar(120) not null comment '区域分类',
standard_name varchar(200) 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_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_by varchar(64) default '' comment '创建者',
create_time datetime comment '创建时间', create_time datetime comment '创建时间',
update_by varchar(64) default '' comment '更新者', update_by varchar(64) default '' comment '更新者',
@ -703,10 +703,12 @@ create table STANDARD_INFO (
remark varchar(500) default null comment '备注', remark varchar(500) default null comment '备注',
primary key (standard_id) primary key (standard_id)
) engine=innodb comment = '标准信息表'; ) engine=innodb comment = '标准信息表';
drop table if exists STANDARD_INFO_DETAILS; drop table if exists STANDARD_INFO_DETAILS;
create table STANDARD_INFO_DETAILS ( create table STANDARD_INFO_DETAILS (
standard_id bigint(20) not null auto_increment comment '标准id', details_id bigint(20) not null auto_increment comment '标准明细ID',
details_id bigint(20) not null comment '岗位ID', standard_id bigint(20) not null comment '标准id',
file_name varchar(200) not null comment '文件名称', file_name varchar(200) not null comment '文件名称',
file_url varchar(200) not null comment '文件路径', file_url varchar(200) not null comment '文件路径',
create_by varchar(64) default '' comment '创建者', create_by varchar(64) default '' comment '创建者',
@ -714,5 +716,5 @@ create table STANDARD_INFO_DETAILS (
update_by varchar(64) default '' comment '更新者', update_by varchar(64) default '' comment '更新者',
update_time datetime comment '更新时间', update_time datetime comment '更新时间',
remark varchar(500) default null comment '备注', remark varchar(500) default null comment '备注',
primary key (standard_id, details_id) primary key (details_id,standard_id)
) engine=innodb comment = '标准信息文件表'; ) engine=innodb comment = '标准信息文件表';