parent
659df35446
commit
3858e21e39
2
pom.xml
2
pom.xml
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
<version>3.3.0</version>
|
||||||
|
|
||||||
<name>管理系统</name>
|
<name>管理系统</name>
|
||||||
<description>微服务系统</description>
|
<description>微服务系统</description>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package com.ruoyi.common.core.utils;
|
package com.ruoyi.common.core.utils;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||||
import com.ruoyi.common.core.constant.TokenConstants;
|
import com.ruoyi.common.core.constant.TokenConstants;
|
||||||
import com.ruoyi.common.core.text.Convert;
|
import com.ruoyi.common.core.text.Convert;
|
||||||
|
|
@ -8,10 +7,12 @@ import io.jsonwebtoken.Claims;
|
||||||
import io.jsonwebtoken.Jwts;
|
import io.jsonwebtoken.Jwts;
|
||||||
import io.jsonwebtoken.SignatureAlgorithm;
|
import io.jsonwebtoken.SignatureAlgorithm;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Jwt工具类
|
* Jwt工具类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author xiejs
|
||||||
*/
|
*/
|
||||||
public class JwtUtils
|
public class JwtUtils
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
package com.ruoyi.file.controller;
|
||||||
|
|
||||||
|
import com.aliyun.oss.common.utils.BinaryUtil;
|
||||||
|
import com.aliyun.oss.model.MatchMode;
|
||||||
|
import com.aliyun.oss.model.PolicyConditions;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.file.utils.OssClient;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.ruoyi.file.utils.OssClient.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* oss服务控制器
|
||||||
|
*
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-03-15
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("oss")
|
||||||
|
@Api(tags = "OSS管理")
|
||||||
|
@Log4j2
|
||||||
|
public class OssController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
OssClient ossClient;
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/policy")
|
||||||
|
public R policy() {
|
||||||
|
String host = HTTPS + bucketName + DOT + endpoint;
|
||||||
|
String dir = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
||||||
|
|
||||||
|
Map<String, String> respMap = null;
|
||||||
|
try {
|
||||||
|
//10分钟过期
|
||||||
|
long expireTime = 600;
|
||||||
|
long expireEndTime = System.currentTimeMillis() + expireTime * 1000;
|
||||||
|
Date expiration = new Date(expireEndTime);
|
||||||
|
PolicyConditions policyConds = new PolicyConditions();
|
||||||
|
policyConds.addConditionItem(PolicyConditions.COND_CONTENT_LENGTH_RANGE, 0, 1048576000);
|
||||||
|
policyConds.addConditionItem(MatchMode.StartWith, PolicyConditions.COND_KEY, dir);
|
||||||
|
|
||||||
|
String postPolicy = ossClient.getOssClient().generatePostPolicy(expiration, policyConds);
|
||||||
|
byte[] binaryData = postPolicy.getBytes(StandardCharsets.UTF_8);
|
||||||
|
String encodedPolicy = BinaryUtil.toBase64String(binaryData);
|
||||||
|
String postSignature = ossClient.getOssClient().calculatePostSignature(postPolicy);
|
||||||
|
|
||||||
|
respMap = new LinkedHashMap<>();
|
||||||
|
respMap.put("accessid", keyId);
|
||||||
|
respMap.put("policy", encodedPolicy);
|
||||||
|
respMap.put("signature", postSignature);
|
||||||
|
respMap.put("dir", dir);
|
||||||
|
respMap.put("host", host);
|
||||||
|
respMap.put("expire", String.valueOf(expireEndTime / 1000));
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return R.ok(respMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -2,10 +2,9 @@ package com.ruoyi.file.service;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.aliyun.oss.OSS;
|
import com.aliyun.oss.OSS;
|
||||||
import com.aliyun.oss.OSSClientBuilder;
|
|
||||||
import com.ruoyi.common.core.text.UUID;
|
import com.ruoyi.common.core.text.UUID;
|
||||||
import com.ruoyi.file.config.AliyunOssProperties;
|
|
||||||
import com.ruoyi.file.utils.FileUploadUtils;
|
import com.ruoyi.file.utils.FileUploadUtils;
|
||||||
|
import com.ruoyi.file.utils.OssClient;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Primary;
|
import org.springframework.context.annotation.Primary;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
@ -16,6 +15,8 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import static com.ruoyi.file.utils.OssClient.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 阿里云oss文件上传实现
|
* 阿里云oss文件上传实现
|
||||||
*
|
*
|
||||||
|
|
@ -26,22 +27,17 @@ import java.util.Date;
|
||||||
@Primary
|
@Primary
|
||||||
public class AliyunOssFileServiceImpl implements ISysFileService {
|
public class AliyunOssFileServiceImpl implements ISysFileService {
|
||||||
|
|
||||||
public static final String HTTPS = "https://";
|
|
||||||
|
|
||||||
public static final String DOT = ".";
|
|
||||||
|
|
||||||
public static final String SLASH = "/";
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AliyunOssProperties aliyunOssProperties;
|
private OssClient ossClient;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String uploadFile(MultipartFile file) throws Exception {
|
public String uploadFile(MultipartFile file) throws Exception {
|
||||||
Assert.notNull(file, "file is null");
|
Assert.notNull(file, "file is null");
|
||||||
try {
|
try {
|
||||||
String endpoint = aliyunOssProperties.getEndpoint();
|
String endpoint = OssClient.endpoint;
|
||||||
String bucketName = aliyunOssProperties.getBucketName();
|
String bucketName = OssClient.bucketName;
|
||||||
OSS ossClient = this.getOssClient();
|
OSS oss = ossClient.getOssClient();
|
||||||
//获取流
|
//获取流
|
||||||
InputStream is = file.getInputStream();
|
InputStream is = file.getInputStream();
|
||||||
//获取文件后缀
|
//获取文件后缀
|
||||||
|
|
@ -49,9 +45,9 @@ public class AliyunOssFileServiceImpl implements ISysFileService {
|
||||||
//获取文件名称
|
//获取文件名称
|
||||||
String fileName = this.getDataTime() + DOT + extension;
|
String fileName = this.getDataTime() + DOT + extension;
|
||||||
//执行文件上传 bucket名称 文件名称 文件流
|
//执行文件上传 bucket名称 文件名称 文件流
|
||||||
ossClient.putObject(bucketName, fileName, is);
|
oss.putObject(bucketName, fileName, is);
|
||||||
//关闭ossClient
|
//关闭ossClient
|
||||||
ossClient.shutdown();
|
oss.shutdown();
|
||||||
//拼接文件地址
|
//拼接文件地址
|
||||||
return HTTPS + bucketName + DOT + endpoint + SLASH + fileName;
|
return HTTPS + bucketName + DOT + endpoint + SLASH + fileName;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
@ -62,8 +58,8 @@ public class AliyunOssFileServiceImpl implements ISysFileService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeFile(String url) {
|
public void removeFile(String url) {
|
||||||
String endpoint = aliyunOssProperties.getEndpoint();
|
String endpoint = OssClient.endpoint;
|
||||||
String bucketName = aliyunOssProperties.getBucketName();
|
String bucketName = OssClient.bucketName;
|
||||||
String host = HTTPS + bucketName + DOT + endpoint + SLASH;
|
String host = HTTPS + bucketName + DOT + endpoint + SLASH;
|
||||||
|
|
||||||
//如果路径中不包含host
|
//如果路径中不包含host
|
||||||
|
|
@ -73,14 +69,13 @@ public class AliyunOssFileServiceImpl implements ISysFileService {
|
||||||
|
|
||||||
String objectName = url.substring(host.length());
|
String objectName = url.substring(host.length());
|
||||||
|
|
||||||
|
OSS oss = ossClient.getOssClient();
|
||||||
OSS ossClient = this.getOssClient();
|
|
||||||
|
|
||||||
//执行删除
|
//执行删除
|
||||||
ossClient.deleteObject(bucketName, objectName);
|
oss.deleteObject(bucketName, objectName);
|
||||||
|
|
||||||
//关闭ossClient
|
//关闭ossClient
|
||||||
ossClient.shutdown();
|
oss.shutdown();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,16 +89,4 @@ public class AliyunOssFileServiceImpl implements ISysFileService {
|
||||||
return today + SLASH + UUID.randomUUID();
|
return today + SLASH + UUID.randomUUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取oss实例
|
|
||||||
*
|
|
||||||
* @return OSS
|
|
||||||
*/
|
|
||||||
private OSS getOssClient() {
|
|
||||||
String endpoint = aliyunOssProperties.getEndpoint();
|
|
||||||
String keyId = aliyunOssProperties.getKeyId();
|
|
||||||
String keySecret = aliyunOssProperties.getKeySecret();
|
|
||||||
return new OSSClientBuilder().build(endpoint,
|
|
||||||
keyId, keySecret);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
package com.ruoyi.file.utils;
|
||||||
|
|
||||||
|
import com.aliyun.oss.OSS;
|
||||||
|
import com.aliyun.oss.OSSClientBuilder;
|
||||||
|
import com.ruoyi.file.config.AliyunOssProperties;
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取ossClient
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-03-15
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class OssClient implements BeanPostProcessor {
|
||||||
|
|
||||||
|
public static final String HTTPS = "https://";
|
||||||
|
|
||||||
|
public static final String DOT = ".";
|
||||||
|
|
||||||
|
public static final String SLASH = "/";
|
||||||
|
|
||||||
|
public static String endpoint;
|
||||||
|
public static String keyId;
|
||||||
|
public static String keySecret;
|
||||||
|
public static String bucketName;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AliyunOssProperties aliyunOssProperties;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||||
|
OssClient.endpoint = aliyunOssProperties.getEndpoint();
|
||||||
|
OssClient.keyId = aliyunOssProperties.getKeyId();
|
||||||
|
OssClient.keySecret = aliyunOssProperties.getKeySecret();
|
||||||
|
OssClient.bucketName = aliyunOssProperties.getBucketName();
|
||||||
|
return bean;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取oss实例
|
||||||
|
*
|
||||||
|
* @return OSS
|
||||||
|
*/
|
||||||
|
public OSS getOssClient() {
|
||||||
|
String endpoint = aliyunOssProperties.getEndpoint();
|
||||||
|
String keyId = aliyunOssProperties.getKeyId();
|
||||||
|
String keySecret = aliyunOssProperties.getKeySecret();
|
||||||
|
return new OSSClientBuilder().build(endpoint,
|
||||||
|
keyId, keySecret);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
|
|
||||||
//上传图片
|
//上传图片
|
||||||
export function uploadImg(data){
|
export function uploadImg(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/file/upload',
|
url: '/file/upload',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
|
|
@ -12,10 +12,18 @@ export function uploadImg(data){
|
||||||
}
|
}
|
||||||
|
|
||||||
//删除图片
|
//删除图片
|
||||||
export function removeImg(url){
|
export function removeImg(url) {
|
||||||
return request({
|
return request({
|
||||||
url: '/file/remove',
|
url: '/file/remove',
|
||||||
method: 'delete',
|
method: 'delete',
|
||||||
params: url
|
params: url
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//获取oss上传秘钥
|
||||||
|
export function policy() {
|
||||||
|
return request({
|
||||||
|
url: '/file/oss/policy',
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,118 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<el-upload
|
||||||
|
action="http://xjs-cloud.oss-cn-hangzhou.aliyuncs.com"
|
||||||
|
:data="dataObj"
|
||||||
|
list-type="picture-card"
|
||||||
|
:file-list="fileList"
|
||||||
|
:before-upload="beforeUpload"
|
||||||
|
:on-remove="handleRemove"
|
||||||
|
:on-success="handleUploadSuccess"
|
||||||
|
:on-preview="handlePreview"
|
||||||
|
:limit="maxCount"
|
||||||
|
:on-exceed="handleExceed"
|
||||||
|
>
|
||||||
|
<i class="el-icon-plus"></i>
|
||||||
|
</el-upload>
|
||||||
|
<el-dialog :visible.sync="dialogVisible">
|
||||||
|
<img width="100%" :src="dialogImageUrl" alt />
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import { policy } from "./policy";
|
||||||
|
import { getUUID } from '@/utils'
|
||||||
|
export default {
|
||||||
|
name: "multiUpload",
|
||||||
|
props: {
|
||||||
|
//图片属性数组
|
||||||
|
value: Array,
|
||||||
|
//最大上传图片数量
|
||||||
|
maxCount: {
|
||||||
|
type: Number,
|
||||||
|
default: 30
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
dataObj: {
|
||||||
|
policy: "",
|
||||||
|
signature: "",
|
||||||
|
key: "",
|
||||||
|
ossaccessKeyId: "",
|
||||||
|
dir: "",
|
||||||
|
host: "",
|
||||||
|
uuid: ""
|
||||||
|
},
|
||||||
|
dialogVisible: false,
|
||||||
|
dialogImageUrl: null
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
fileList() {
|
||||||
|
let fileList = [];
|
||||||
|
for (let i = 0; i < this.value.length; i++) {
|
||||||
|
fileList.push({ url: this.value[i] });
|
||||||
|
}
|
||||||
|
|
||||||
|
return fileList;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {},
|
||||||
|
methods: {
|
||||||
|
emitInput(fileList) {
|
||||||
|
let value = [];
|
||||||
|
for (let i = 0; i < fileList.length; i++) {
|
||||||
|
value.push(fileList[i].url);
|
||||||
|
}
|
||||||
|
this.$emit("input", value);
|
||||||
|
},
|
||||||
|
handleRemove(file, fileList) {
|
||||||
|
this.emitInput(fileList);
|
||||||
|
},
|
||||||
|
handlePreview(file) {
|
||||||
|
this.dialogVisible = true;
|
||||||
|
this.dialogImageUrl = file.url;
|
||||||
|
},
|
||||||
|
beforeUpload(file) {
|
||||||
|
let _self = this;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
policy()
|
||||||
|
.then(response => {
|
||||||
|
console.log("这是什么${filename}");
|
||||||
|
_self.dataObj.policy = response.data.policy;
|
||||||
|
_self.dataObj.signature = response.data.signature;
|
||||||
|
_self.dataObj.ossaccessKeyId = response.data.accessid;
|
||||||
|
_self.dataObj.key = response.data.dir + "/"+getUUID()+"_${filename}";
|
||||||
|
_self.dataObj.dir = response.data.dir;
|
||||||
|
_self.dataObj.host = response.data.host;
|
||||||
|
resolve(true);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.log("出错了...",err)
|
||||||
|
reject(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleUploadSuccess(res, file) {
|
||||||
|
this.fileList.push({
|
||||||
|
name: file.name,
|
||||||
|
// url: this.dataObj.host + "/" + this.dataObj.dir + "/" + file.name; 替换${filename}为真正的文件名
|
||||||
|
url: this.dataObj.host + "/" + this.dataObj.key.replace("${filename}",file.name)
|
||||||
|
});
|
||||||
|
this.emitInput(this.fileList);
|
||||||
|
},
|
||||||
|
handleExceed(files, fileList) {
|
||||||
|
this.$message({
|
||||||
|
message: "最多只能上传" + this.maxCount + "张图片",
|
||||||
|
type: "warning",
|
||||||
|
duration: 1000
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,143 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<el-upload class="el-upload-list__item"
|
||||||
|
action="https://xjs-cloud.oss-cn-hangzhou.aliyuncs.com"
|
||||||
|
:data="dataObj"
|
||||||
|
:multiple="false"
|
||||||
|
:show-file-list="showFileList"
|
||||||
|
accept="image/*"
|
||||||
|
:file-list="fileList"
|
||||||
|
:limit=2
|
||||||
|
:on-remove="handleRemove"
|
||||||
|
:on-success="handleUploadSuccess"
|
||||||
|
:before-upload="picture_rulBeforeUpload"
|
||||||
|
:before-remove="removeImg"
|
||||||
|
list-type="picture-card"
|
||||||
|
:on-preview="handlePreview">
|
||||||
|
<el-button size="small" type="text">+</el-button>
|
||||||
|
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过10MB</div>
|
||||||
|
</el-upload>
|
||||||
|
<el-dialog :visible.sync="dialogVisible">
|
||||||
|
<img width="100%" :src="fileList[0].url" alt="">
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {policy, removeImg, uploadImg} from "@/api/common";
|
||||||
|
import {getUUID} from '@/utils'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'SingleUpload',
|
||||||
|
props: {
|
||||||
|
value: String
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
imageUrl() {
|
||||||
|
return this.value;
|
||||||
|
},
|
||||||
|
imageName() {
|
||||||
|
if (this.value != null && this.value !== '') {
|
||||||
|
return this.value.substr(this.value.lastIndexOf("/") + 1);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fileList() {
|
||||||
|
return [{
|
||||||
|
name: this.imageName,
|
||||||
|
url: this.imageUrl
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
showFileList: {
|
||||||
|
get: function () {
|
||||||
|
return this.value !== null && this.value !== '' && this.value !== undefined;
|
||||||
|
},
|
||||||
|
set: function (newValue) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
dataObj: {
|
||||||
|
policy: '',
|
||||||
|
signature: '',
|
||||||
|
key: '',
|
||||||
|
ossaccessKeyId: '',
|
||||||
|
dir: '',
|
||||||
|
host: '',
|
||||||
|
},
|
||||||
|
dialogVisible: false
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
created() {
|
||||||
|
this.init()
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
emitInput(val) {
|
||||||
|
this.$emit('input', val)
|
||||||
|
},
|
||||||
|
handleRemove(file, fileList) {
|
||||||
|
this.emitInput('');
|
||||||
|
},
|
||||||
|
handlePreview(file) {
|
||||||
|
this.dialogVisible = true;
|
||||||
|
},
|
||||||
|
|
||||||
|
init() {
|
||||||
|
policy().then(response => {
|
||||||
|
this.dataObj.policy = response.data.policy;
|
||||||
|
this.dataObj.signature = response.data.signature;
|
||||||
|
this.dataObj.ossaccessKeyId = response.data.accessid;
|
||||||
|
this.dataObj.key = response.data.dir + '/' + getUUID() + '_${filename}'
|
||||||
|
this.dataObj.dir = response.data.dir;
|
||||||
|
this.dataObj.host = response.data.host;
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
handleUploadSuccess(res, file) {
|
||||||
|
this.showFileList = true;
|
||||||
|
this.fileList.pop();
|
||||||
|
this.fileList.push({
|
||||||
|
name: file.name,
|
||||||
|
url: this.dataObj.host + '/' + this.dataObj.key.replace("${filename}", file.name)
|
||||||
|
});
|
||||||
|
this.emitInput(this.fileList[0].url);
|
||||||
|
},
|
||||||
|
|
||||||
|
picture_rulBeforeUpload(file) {
|
||||||
|
let isRightSize = file.size / 1024 / 1024 < 10
|
||||||
|
if (!isRightSize) {
|
||||||
|
this.$message.error('文件大小超过 10MB')
|
||||||
|
}
|
||||||
|
let isAccept = new RegExp('image/*').test(file.type)
|
||||||
|
if (!isAccept) {
|
||||||
|
this.$message.error('应该选择image/*类型的文件')
|
||||||
|
}
|
||||||
|
|
||||||
|
return isRightSize && isAccept;
|
||||||
|
},
|
||||||
|
|
||||||
|
//删除图片
|
||||||
|
removeImg() {
|
||||||
|
if (this.fileList[0].url) {
|
||||||
|
let pictureUrl = {"url": this.fileList[0].url};
|
||||||
|
removeImg(pictureUrl).then(res => {
|
||||||
|
})
|
||||||
|
this.emitInput('');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style scoped>
|
||||||
|
.el-upload-list__item {
|
||||||
|
transition: none !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,390 +1,399 @@
|
||||||
import { parseTime } from './ruoyi'
|
import { parseTime } from './ruoyi'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表格时间格式化
|
* 表格时间格式化
|
||||||
*/
|
*/
|
||||||
export function formatDate(cellValue) {
|
export function formatDate(cellValue) {
|
||||||
if (cellValue == null || cellValue == "") return "";
|
if (cellValue == null || cellValue == "") return "";
|
||||||
var date = new Date(cellValue)
|
var date = new Date(cellValue)
|
||||||
var year = date.getFullYear()
|
var year = date.getFullYear()
|
||||||
var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
|
var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
|
||||||
var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
|
var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
|
||||||
var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
|
var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
|
||||||
var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
|
var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
|
||||||
var seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
|
var seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
|
||||||
return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds
|
return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} time
|
* @param {number} time
|
||||||
* @param {string} option
|
* @param {string} option
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
export function formatTime(time, option) {
|
export function formatTime(time, option) {
|
||||||
if (('' + time).length === 10) {
|
if (('' + time).length === 10) {
|
||||||
time = parseInt(time) * 1000
|
time = parseInt(time) * 1000
|
||||||
} else {
|
} else {
|
||||||
time = +time
|
time = +time
|
||||||
}
|
}
|
||||||
const d = new Date(time)
|
const d = new Date(time)
|
||||||
const now = Date.now()
|
const now = Date.now()
|
||||||
|
|
||||||
const diff = (now - d) / 1000
|
const diff = (now - d) / 1000
|
||||||
|
|
||||||
if (diff < 30) {
|
if (diff < 30) {
|
||||||
return '刚刚'
|
return '刚刚'
|
||||||
} else if (diff < 3600) {
|
} else if (diff < 3600) {
|
||||||
// less 1 hour
|
// less 1 hour
|
||||||
return Math.ceil(diff / 60) + '分钟前'
|
return Math.ceil(diff / 60) + '分钟前'
|
||||||
} else if (diff < 3600 * 24) {
|
} else if (diff < 3600 * 24) {
|
||||||
return Math.ceil(diff / 3600) + '小时前'
|
return Math.ceil(diff / 3600) + '小时前'
|
||||||
} else if (diff < 3600 * 24 * 2) {
|
} else if (diff < 3600 * 24 * 2) {
|
||||||
return '1天前'
|
return '1天前'
|
||||||
}
|
}
|
||||||
if (option) {
|
if (option) {
|
||||||
return parseTime(time, option)
|
return parseTime(time, option)
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
d.getMonth() +
|
d.getMonth() +
|
||||||
1 +
|
1 +
|
||||||
'月' +
|
'月' +
|
||||||
d.getDate() +
|
d.getDate() +
|
||||||
'日' +
|
'日' +
|
||||||
d.getHours() +
|
d.getHours() +
|
||||||
'时' +
|
'时' +
|
||||||
d.getMinutes() +
|
d.getMinutes() +
|
||||||
'分'
|
'分'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} url
|
* @param {string} url
|
||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
export function getQueryObject(url) {
|
export function getQueryObject(url) {
|
||||||
url = url == null ? window.location.href : url
|
url = url == null ? window.location.href : url
|
||||||
const search = url.substring(url.lastIndexOf('?') + 1)
|
const search = url.substring(url.lastIndexOf('?') + 1)
|
||||||
const obj = {}
|
const obj = {}
|
||||||
const reg = /([^?&=]+)=([^?&=]*)/g
|
const reg = /([^?&=]+)=([^?&=]*)/g
|
||||||
search.replace(reg, (rs, $1, $2) => {
|
search.replace(reg, (rs, $1, $2) => {
|
||||||
const name = decodeURIComponent($1)
|
const name = decodeURIComponent($1)
|
||||||
let val = decodeURIComponent($2)
|
let val = decodeURIComponent($2)
|
||||||
val = String(val)
|
val = String(val)
|
||||||
obj[name] = val
|
obj[name] = val
|
||||||
return rs
|
return rs
|
||||||
})
|
})
|
||||||
return obj
|
return obj
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} input value
|
* @param {string} input value
|
||||||
* @returns {number} output value
|
* @returns {number} output value
|
||||||
*/
|
*/
|
||||||
export function byteLength(str) {
|
export function byteLength(str) {
|
||||||
// returns the byte length of an utf8 string
|
// returns the byte length of an utf8 string
|
||||||
let s = str.length
|
let s = str.length
|
||||||
for (var i = str.length - 1; i >= 0; i--) {
|
for (var i = str.length - 1; i >= 0; i--) {
|
||||||
const code = str.charCodeAt(i)
|
const code = str.charCodeAt(i)
|
||||||
if (code > 0x7f && code <= 0x7ff) s++
|
if (code > 0x7f && code <= 0x7ff) s++
|
||||||
else if (code > 0x7ff && code <= 0xffff) s += 2
|
else if (code > 0x7ff && code <= 0xffff) s += 2
|
||||||
if (code >= 0xDC00 && code <= 0xDFFF) i--
|
if (code >= 0xDC00 && code <= 0xDFFF) i--
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Array} actual
|
* @param {Array} actual
|
||||||
* @returns {Array}
|
* @returns {Array}
|
||||||
*/
|
*/
|
||||||
export function cleanArray(actual) {
|
export function cleanArray(actual) {
|
||||||
const newArray = []
|
const newArray = []
|
||||||
for (let i = 0; i < actual.length; i++) {
|
for (let i = 0; i < actual.length; i++) {
|
||||||
if (actual[i]) {
|
if (actual[i]) {
|
||||||
newArray.push(actual[i])
|
newArray.push(actual[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newArray
|
return newArray
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Object} json
|
* @param {Object} json
|
||||||
* @returns {Array}
|
* @returns {Array}
|
||||||
*/
|
*/
|
||||||
export function param(json) {
|
export function param(json) {
|
||||||
if (!json) return ''
|
if (!json) return ''
|
||||||
return cleanArray(
|
return cleanArray(
|
||||||
Object.keys(json).map(key => {
|
Object.keys(json).map(key => {
|
||||||
if (json[key] === undefined) return ''
|
if (json[key] === undefined) return ''
|
||||||
return encodeURIComponent(key) + '=' + encodeURIComponent(json[key])
|
return encodeURIComponent(key) + '=' + encodeURIComponent(json[key])
|
||||||
})
|
})
|
||||||
).join('&')
|
).join('&')
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} url
|
* @param {string} url
|
||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
export function param2Obj(url) {
|
export function param2Obj(url) {
|
||||||
const search = decodeURIComponent(url.split('?')[1]).replace(/\+/g, ' ')
|
const search = decodeURIComponent(url.split('?')[1]).replace(/\+/g, ' ')
|
||||||
if (!search) {
|
if (!search) {
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
const obj = {}
|
const obj = {}
|
||||||
const searchArr = search.split('&')
|
const searchArr = search.split('&')
|
||||||
searchArr.forEach(v => {
|
searchArr.forEach(v => {
|
||||||
const index = v.indexOf('=')
|
const index = v.indexOf('=')
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
const name = v.substring(0, index)
|
const name = v.substring(0, index)
|
||||||
const val = v.substring(index + 1, v.length)
|
const val = v.substring(index + 1, v.length)
|
||||||
obj[name] = val
|
obj[name] = val
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return obj
|
return obj
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} val
|
* @param {string} val
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
export function html2Text(val) {
|
export function html2Text(val) {
|
||||||
const div = document.createElement('div')
|
const div = document.createElement('div')
|
||||||
div.innerHTML = val
|
div.innerHTML = val
|
||||||
return div.textContent || div.innerText
|
return div.textContent || div.innerText
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merges two objects, giving the last one precedence
|
* Merges two objects, giving the last one precedence
|
||||||
* @param {Object} target
|
* @param {Object} target
|
||||||
* @param {(Object|Array)} source
|
* @param {(Object|Array)} source
|
||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
export function objectMerge(target, source) {
|
export function objectMerge(target, source) {
|
||||||
if (typeof target !== 'object') {
|
if (typeof target !== 'object') {
|
||||||
target = {}
|
target = {}
|
||||||
}
|
}
|
||||||
if (Array.isArray(source)) {
|
if (Array.isArray(source)) {
|
||||||
return source.slice()
|
return source.slice()
|
||||||
}
|
}
|
||||||
Object.keys(source).forEach(property => {
|
Object.keys(source).forEach(property => {
|
||||||
const sourceProperty = source[property]
|
const sourceProperty = source[property]
|
||||||
if (typeof sourceProperty === 'object') {
|
if (typeof sourceProperty === 'object') {
|
||||||
target[property] = objectMerge(target[property], sourceProperty)
|
target[property] = objectMerge(target[property], sourceProperty)
|
||||||
} else {
|
} else {
|
||||||
target[property] = sourceProperty
|
target[property] = sourceProperty
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return target
|
return target
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {HTMLElement} element
|
* @param {HTMLElement} element
|
||||||
* @param {string} className
|
* @param {string} className
|
||||||
*/
|
*/
|
||||||
export function toggleClass(element, className) {
|
export function toggleClass(element, className) {
|
||||||
if (!element || !className) {
|
if (!element || !className) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let classString = element.className
|
let classString = element.className
|
||||||
const nameIndex = classString.indexOf(className)
|
const nameIndex = classString.indexOf(className)
|
||||||
if (nameIndex === -1) {
|
if (nameIndex === -1) {
|
||||||
classString += '' + className
|
classString += '' + className
|
||||||
} else {
|
} else {
|
||||||
classString =
|
classString =
|
||||||
classString.substr(0, nameIndex) +
|
classString.substr(0, nameIndex) +
|
||||||
classString.substr(nameIndex + className.length)
|
classString.substr(nameIndex + className.length)
|
||||||
}
|
}
|
||||||
element.className = classString
|
element.className = classString
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} type
|
* @param {string} type
|
||||||
* @returns {Date}
|
* @returns {Date}
|
||||||
*/
|
*/
|
||||||
export function getTime(type) {
|
export function getTime(type) {
|
||||||
if (type === 'start') {
|
if (type === 'start') {
|
||||||
return new Date().getTime() - 3600 * 1000 * 24 * 90
|
return new Date().getTime() - 3600 * 1000 * 24 * 90
|
||||||
} else {
|
} else {
|
||||||
return new Date(new Date().toDateString())
|
return new Date(new Date().toDateString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Function} func
|
* @param {Function} func
|
||||||
* @param {number} wait
|
* @param {number} wait
|
||||||
* @param {boolean} immediate
|
* @param {boolean} immediate
|
||||||
* @return {*}
|
* @return {*}
|
||||||
*/
|
*/
|
||||||
export function debounce(func, wait, immediate) {
|
export function debounce(func, wait, immediate) {
|
||||||
let timeout, args, context, timestamp, result
|
let timeout, args, context, timestamp, result
|
||||||
|
|
||||||
const later = function() {
|
const later = function() {
|
||||||
// 据上一次触发时间间隔
|
// 据上一次触发时间间隔
|
||||||
const last = +new Date() - timestamp
|
const last = +new Date() - timestamp
|
||||||
|
|
||||||
// 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait
|
// 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait
|
||||||
if (last < wait && last > 0) {
|
if (last < wait && last > 0) {
|
||||||
timeout = setTimeout(later, wait - last)
|
timeout = setTimeout(later, wait - last)
|
||||||
} else {
|
} else {
|
||||||
timeout = null
|
timeout = null
|
||||||
// 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
|
// 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
|
||||||
if (!immediate) {
|
if (!immediate) {
|
||||||
result = func.apply(context, args)
|
result = func.apply(context, args)
|
||||||
if (!timeout) context = args = null
|
if (!timeout) context = args = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return function(...args) {
|
return function(...args) {
|
||||||
context = this
|
context = this
|
||||||
timestamp = +new Date()
|
timestamp = +new Date()
|
||||||
const callNow = immediate && !timeout
|
const callNow = immediate && !timeout
|
||||||
// 如果延时不存在,重新设定延时
|
// 如果延时不存在,重新设定延时
|
||||||
if (!timeout) timeout = setTimeout(later, wait)
|
if (!timeout) timeout = setTimeout(later, wait)
|
||||||
if (callNow) {
|
if (callNow) {
|
||||||
result = func.apply(context, args)
|
result = func.apply(context, args)
|
||||||
context = args = null
|
context = args = null
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is just a simple version of deep copy
|
* This is just a simple version of deep copy
|
||||||
* Has a lot of edge cases bug
|
* Has a lot of edge cases bug
|
||||||
* If you want to use a perfect deep copy, use lodash's _.cloneDeep
|
* If you want to use a perfect deep copy, use lodash's _.cloneDeep
|
||||||
* @param {Object} source
|
* @param {Object} source
|
||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
export function deepClone(source) {
|
export function deepClone(source) {
|
||||||
if (!source && typeof source !== 'object') {
|
if (!source && typeof source !== 'object') {
|
||||||
throw new Error('error arguments', 'deepClone')
|
throw new Error('error arguments', 'deepClone')
|
||||||
}
|
}
|
||||||
const targetObj = source.constructor === Array ? [] : {}
|
const targetObj = source.constructor === Array ? [] : {}
|
||||||
Object.keys(source).forEach(keys => {
|
Object.keys(source).forEach(keys => {
|
||||||
if (source[keys] && typeof source[keys] === 'object') {
|
if (source[keys] && typeof source[keys] === 'object') {
|
||||||
targetObj[keys] = deepClone(source[keys])
|
targetObj[keys] = deepClone(source[keys])
|
||||||
} else {
|
} else {
|
||||||
targetObj[keys] = source[keys]
|
targetObj[keys] = source[keys]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return targetObj
|
return targetObj
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Array} arr
|
* @param {Array} arr
|
||||||
* @returns {Array}
|
* @returns {Array}
|
||||||
*/
|
*/
|
||||||
export function uniqueArr(arr) {
|
export function uniqueArr(arr) {
|
||||||
return Array.from(new Set(arr))
|
return Array.from(new Set(arr))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
export function createUniqueString() {
|
export function createUniqueString() {
|
||||||
const timestamp = +new Date() + ''
|
const timestamp = +new Date() + ''
|
||||||
const randomNum = parseInt((1 + Math.random()) * 65536) + ''
|
const randomNum = parseInt((1 + Math.random()) * 65536) + ''
|
||||||
return (+(randomNum + timestamp)).toString(32)
|
return (+(randomNum + timestamp)).toString(32)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if an element has a class
|
* Check if an element has a class
|
||||||
* @param {HTMLElement} elm
|
* @param {HTMLElement} elm
|
||||||
* @param {string} cls
|
* @param {string} cls
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
export function hasClass(ele, cls) {
|
export function hasClass(ele, cls) {
|
||||||
return !!ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'))
|
return !!ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add class to element
|
* Add class to element
|
||||||
* @param {HTMLElement} elm
|
* @param {HTMLElement} elm
|
||||||
* @param {string} cls
|
* @param {string} cls
|
||||||
*/
|
*/
|
||||||
export function addClass(ele, cls) {
|
export function addClass(ele, cls) {
|
||||||
if (!hasClass(ele, cls)) ele.className += ' ' + cls
|
if (!hasClass(ele, cls)) ele.className += ' ' + cls
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove class from element
|
* Remove class from element
|
||||||
* @param {HTMLElement} elm
|
* @param {HTMLElement} elm
|
||||||
* @param {string} cls
|
* @param {string} cls
|
||||||
*/
|
*/
|
||||||
export function removeClass(ele, cls) {
|
export function removeClass(ele, cls) {
|
||||||
if (hasClass(ele, cls)) {
|
if (hasClass(ele, cls)) {
|
||||||
const reg = new RegExp('(\\s|^)' + cls + '(\\s|$)')
|
const reg = new RegExp('(\\s|^)' + cls + '(\\s|$)')
|
||||||
ele.className = ele.className.replace(reg, ' ')
|
ele.className = ele.className.replace(reg, ' ')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function makeMap(str, expectsLowerCase) {
|
export function makeMap(str, expectsLowerCase) {
|
||||||
const map = Object.create(null)
|
const map = Object.create(null)
|
||||||
const list = str.split(',')
|
const list = str.split(',')
|
||||||
for (let i = 0; i < list.length; i++) {
|
for (let i = 0; i < list.length; i++) {
|
||||||
map[list[i]] = true
|
map[list[i]] = true
|
||||||
}
|
}
|
||||||
return expectsLowerCase
|
return expectsLowerCase
|
||||||
? val => map[val.toLowerCase()]
|
? val => map[val.toLowerCase()]
|
||||||
: val => map[val]
|
: val => map[val]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const exportDefault = 'export default '
|
export const exportDefault = 'export default '
|
||||||
|
|
||||||
export const beautifierConf = {
|
export const beautifierConf = {
|
||||||
html: {
|
html: {
|
||||||
indent_size: '2',
|
indent_size: '2',
|
||||||
indent_char: ' ',
|
indent_char: ' ',
|
||||||
max_preserve_newlines: '-1',
|
max_preserve_newlines: '-1',
|
||||||
preserve_newlines: false,
|
preserve_newlines: false,
|
||||||
keep_array_indentation: false,
|
keep_array_indentation: false,
|
||||||
break_chained_methods: false,
|
break_chained_methods: false,
|
||||||
indent_scripts: 'separate',
|
indent_scripts: 'separate',
|
||||||
brace_style: 'end-expand',
|
brace_style: 'end-expand',
|
||||||
space_before_conditional: true,
|
space_before_conditional: true,
|
||||||
unescape_strings: false,
|
unescape_strings: false,
|
||||||
jslint_happy: false,
|
jslint_happy: false,
|
||||||
end_with_newline: true,
|
end_with_newline: true,
|
||||||
wrap_line_length: '110',
|
wrap_line_length: '110',
|
||||||
indent_inner_html: true,
|
indent_inner_html: true,
|
||||||
comma_first: false,
|
comma_first: false,
|
||||||
e4x: true,
|
e4x: true,
|
||||||
indent_empty_lines: true
|
indent_empty_lines: true
|
||||||
},
|
},
|
||||||
js: {
|
js: {
|
||||||
indent_size: '2',
|
indent_size: '2',
|
||||||
indent_char: ' ',
|
indent_char: ' ',
|
||||||
max_preserve_newlines: '-1',
|
max_preserve_newlines: '-1',
|
||||||
preserve_newlines: false,
|
preserve_newlines: false,
|
||||||
keep_array_indentation: false,
|
keep_array_indentation: false,
|
||||||
break_chained_methods: false,
|
break_chained_methods: false,
|
||||||
indent_scripts: 'normal',
|
indent_scripts: 'normal',
|
||||||
brace_style: 'end-expand',
|
brace_style: 'end-expand',
|
||||||
space_before_conditional: true,
|
space_before_conditional: true,
|
||||||
unescape_strings: false,
|
unescape_strings: false,
|
||||||
jslint_happy: true,
|
jslint_happy: true,
|
||||||
end_with_newline: true,
|
end_with_newline: true,
|
||||||
wrap_line_length: '110',
|
wrap_line_length: '110',
|
||||||
indent_inner_html: true,
|
indent_inner_html: true,
|
||||||
comma_first: false,
|
comma_first: false,
|
||||||
e4x: true,
|
e4x: true,
|
||||||
indent_empty_lines: true
|
indent_empty_lines: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 首字母大小
|
// 首字母大小
|
||||||
export function titleCase(str) {
|
export function titleCase(str) {
|
||||||
return str.replace(/( |^)[a-z]/g, L => L.toUpperCase())
|
return str.replace(/( |^)[a-z]/g, L => L.toUpperCase())
|
||||||
}
|
}
|
||||||
|
|
||||||
// 下划转驼峰
|
// 下划转驼峰
|
||||||
export function camelCase(str) {
|
export function camelCase(str) {
|
||||||
return str.replace(/_[a-z]/g, str1 => str1.substr(-1).toUpperCase())
|
return str.replace(/_[a-z]/g, str1 => str1.substr(-1).toUpperCase())
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isNumberStr(str) {
|
export function isNumberStr(str) {
|
||||||
return /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g.test(str)
|
return /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g.test(str)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取uuid
|
||||||
|
*/
|
||||||
|
export function getUUID () {
|
||||||
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
|
||||||
|
return (c === 'x' ? (Math.random() * 16 | 0) : ('r&0x3' | '0x8')).toString(16)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<el-dialog
|
<el-dialog width="550px"
|
||||||
:title="!dataForm.id ? '新增' : '修改'"
|
:title="!dataForm.id ? '新增' : '修改'"
|
||||||
:close-on-click-modal="false"
|
:close-on-click-modal="false"
|
||||||
:visible.sync="visible"
|
:visible.sync="visible"
|
||||||
|
|
@ -9,16 +9,16 @@
|
||||||
:rules="dataRule"
|
:rules="dataRule"
|
||||||
ref="dataForm"
|
ref="dataForm"
|
||||||
@keyup.enter.native="dataFormSubmit()"
|
@keyup.enter.native="dataFormSubmit()"
|
||||||
label-width="140px"
|
label-width="90px"
|
||||||
>
|
>
|
||||||
<el-form-item label="品牌名" prop="name">
|
<el-form-item label="品牌名" prop="name">
|
||||||
<el-input v-model="dataForm.name" placeholder="品牌名"></el-input>
|
<el-input v-model="dataForm.name" placeholder="品牌名" style="width: 380px"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<!-- <el-form-item label="品牌logo地址" prop="logo">
|
<el-form-item label="品牌logo" prop="logo">
|
||||||
<single-upload v-model="dataForm.logo"></single-upload>
|
<single-upload v-model="dataForm.logo"></single-upload>
|
||||||
</el-form-item>-->
|
</el-form-item>
|
||||||
<el-form-item label="介绍" prop="descript">
|
<el-form-item label="介绍" prop="descript">
|
||||||
<el-input v-model="dataForm.descript" placeholder="介绍"></el-input>
|
<el-input type="textarea" :rows="5" v-model="dataForm.descript" placeholder="介绍" style="width: 380px"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="显示状态" prop="showStatus">
|
<el-form-item label="显示状态" prop="showStatus">
|
||||||
<el-switch
|
<el-switch
|
||||||
|
|
@ -29,8 +29,8 @@
|
||||||
:inactive-value="0"
|
:inactive-value="0"
|
||||||
></el-switch>
|
></el-switch>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="检索首字母" prop="firstLetter">
|
<el-form-item label="检索首字母" prop="firstLetter" >
|
||||||
<el-input v-model="dataForm.firstLetter" placeholder="检索首字母"></el-input>
|
<el-input v-model="dataForm.firstLetter" placeholder="检索首字母" style="width: 200px"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="排序" prop="sort">
|
<el-form-item label="排序" prop="sort">
|
||||||
<el-input-number v-model.number="dataForm.sort" :min="1" :max="9999" label="描述文字"></el-input-number>
|
<el-input-number v-model.number="dataForm.sort" :min="1" :max="9999" label="描述文字"></el-input-number>
|
||||||
|
|
@ -44,11 +44,11 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// import SingleUpload from "@/components/upload/singleUpload";
|
import SingleUpload from "@/components/OssUpload/singleUpload";
|
||||||
import {addBrand, editBrand, getBrand} from "@/api/mall/product/brand";
|
import {addBrand, editBrand, getBrand} from "@/api/mall/product/brand";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
// components: { SingleUpload },
|
components: { SingleUpload },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
visible: false,
|
visible: false,
|
||||||
|
|
@ -62,12 +62,16 @@ export default {
|
||||||
sort: 0
|
sort: 0
|
||||||
},
|
},
|
||||||
dataRule: {
|
dataRule: {
|
||||||
name: [{ required: true, message: "品牌名不能为空", trigger: "blur" }],
|
name: [
|
||||||
/*logo: [
|
{ required: true, message: "品牌名不能为空", trigger: "blur" },
|
||||||
|
{ min: 1, max: 50, message: '长度在 1 到 50 个字符', trigger: 'blur' }
|
||||||
|
],
|
||||||
|
logo: [
|
||||||
{ required: true, message: "品牌logo地址不能为空", trigger: "blur" }
|
{ required: true, message: "品牌logo地址不能为空", trigger: "blur" }
|
||||||
],*/
|
],
|
||||||
descript: [
|
descript: [
|
||||||
{ required: true, message: "介绍不能为空", trigger: "blur" }
|
{ required: true, message: "介绍不能为空", trigger: "blur" },
|
||||||
|
{ min: 1, max: 500, message: '长度在 1 到 500 个字符', trigger: 'blur' }
|
||||||
],
|
],
|
||||||
showStatus: [
|
showStatus: [
|
||||||
{
|
{
|
||||||
|
|
@ -114,8 +118,10 @@ export default {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs["dataForm"].resetFields();
|
this.$refs["dataForm"].resetFields();
|
||||||
if (this.dataForm.brandId) {
|
if (this.dataForm.brandId) {
|
||||||
|
this.$modal.loading("请稍候...");
|
||||||
getBrand(this.dataForm.brandId).then(res =>{
|
getBrand(this.dataForm.brandId).then(res =>{
|
||||||
this.dataForm = res.data
|
this.dataForm = res.data
|
||||||
|
this.$modal.closeLoading()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -126,6 +132,7 @@ export default {
|
||||||
this.$refs["dataForm"].validate(valid => {
|
this.$refs["dataForm"].validate(valid => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
this.$modal.loading("请稍候...");
|
this.$modal.loading("请稍候...");
|
||||||
|
|
||||||
if (!this.dataForm.brandId) {
|
if (!this.dataForm.brandId) {
|
||||||
addBrand(this.dataForm).then(res =>{
|
addBrand(this.dataForm).then(res =>{
|
||||||
this.$modal.notifySuccess("添加成功");
|
this.$modal.notifySuccess("添加成功");
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
>
|
>
|
||||||
<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
|
<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
|
||||||
<el-table-column prop="name" header-align="center" align="center" label="品牌名"></el-table-column>
|
<el-table-column prop="name" header-align="center" align="center" label="品牌名"></el-table-column>
|
||||||
<el-table-column prop="logo" header-align="center" align="center" label="品牌logo地址">
|
<el-table-column prop="logo" header-align="center" align="center" label="品牌logo">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<img :src="scope.row.logo" style="width: 100px; height: 80px" alt=""/>
|
<img :src="scope.row.logo" style="width: 100px; height: 80px" alt=""/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>xjs-project-mall</artifactId>
|
|
||||||
<groupId>com.xjs</groupId>
|
|
||||||
<version>3.3.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<name>第三方服务</name>
|
|
||||||
|
|
||||||
<artifactId>mall-third-party</artifactId>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>11</maven.compiler.source>
|
|
||||||
<maven.compiler.target>11</maven.compiler.target>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!--阿里云存储-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alicloud-oss</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
package com.xjs.mall.thirdparty;
|
|
||||||
|
|
||||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration;
|
|
||||||
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
|
|
||||||
import com.ruoyi.common.security.annotation.EnableCustomConfig;
|
|
||||||
import com.ruoyi.common.security.annotation.EnableRyFeignClients;
|
|
||||||
import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
|
|
||||||
import io.seata.spring.boot.autoconfigure.SeataAutoConfiguration;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 商城Product启动器
|
|
||||||
* @author xiejs
|
|
||||||
* @since 2022-03-15
|
|
||||||
*/
|
|
||||||
@SpringBootApplication(exclude ={DataSourceAutoConfiguration.class,
|
|
||||||
SeataAutoConfiguration.class,
|
|
||||||
MybatisPlusAutoConfiguration.class,
|
|
||||||
DynamicDataSourceAutoConfiguration.class} )
|
|
||||||
@EnableCustomConfig
|
|
||||||
@EnableCustomSwagger2
|
|
||||||
@EnableRyFeignClients
|
|
||||||
public class MallThirdPartyApp {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SpringApplication.run(MallThirdPartyApp.class, args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
# Tomcat
|
|
||||||
server:
|
|
||||||
port: 9986
|
|
||||||
|
|
||||||
# Spring
|
|
||||||
spring:
|
|
||||||
application:
|
|
||||||
# 应用名称
|
|
||||||
name: xjs-mall-third-party
|
|
||||||
profiles:
|
|
||||||
# 环境配置
|
|
||||||
active: dev
|
|
||||||
cloud:
|
|
||||||
nacos:
|
|
||||||
discovery:
|
|
||||||
# 服务注册地址
|
|
||||||
server-addr: 127.0.0.1:8848
|
|
||||||
config:
|
|
||||||
# 配置中心地址
|
|
||||||
server-addr: 127.0.0.1:8848
|
|
||||||
# 配置文件格式
|
|
||||||
file-extension: yml
|
|
||||||
# 共享配置
|
|
||||||
shared-configs:
|
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
||||||
#配置组
|
|
||||||
group: xjs
|
|
||||||
#命名空间
|
|
||||||
namespace: xjs-666
|
|
||||||
|
|
@ -1,81 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
|
||||||
<!-- 日志存放路径 -->
|
|
||||||
<property name="log.path" value="logs/xjs-mall/third-party"/>
|
|
||||||
<!-- 日志输出格式 -->
|
|
||||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
|
|
||||||
|
|
||||||
<!-- 控制台输出 -->
|
|
||||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
|
||||||
<encoder>
|
|
||||||
<pattern>${log.pattern}</pattern>
|
|
||||||
</encoder>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- 系统日志输出 -->
|
|
||||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<file>${log.path}/info.log</file>
|
|
||||||
<!-- 循环政策:基于时间创建日志文件 -->
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<!-- 日志文件名格式 -->
|
|
||||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
|
||||||
<!-- 日志最大的历史 60天 -->
|
|
||||||
<maxHistory>60</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
<encoder>
|
|
||||||
<pattern>${log.pattern}</pattern>
|
|
||||||
</encoder>
|
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
|
||||||
<!-- 过滤的级别 -->
|
|
||||||
<level>INFO</level>
|
|
||||||
<!-- 匹配时的操作:接收(记录) -->
|
|
||||||
<onMatch>ACCEPT</onMatch>
|
|
||||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
|
||||||
<onMismatch>DENY</onMismatch>
|
|
||||||
</filter>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<file>${log.path}/error.log</file>
|
|
||||||
<!-- 循环政策:基于时间创建日志文件 -->
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<!-- 日志文件名格式 -->
|
|
||||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
|
||||||
<!-- 日志最大的历史 60天 -->
|
|
||||||
<maxHistory>60</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
<encoder>
|
|
||||||
<pattern>${log.pattern}</pattern>
|
|
||||||
</encoder>
|
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
|
||||||
<!-- 过滤的级别 -->
|
|
||||||
<level>ERROR</level>
|
|
||||||
<!-- 匹配时的操作:接收(记录) -->
|
|
||||||
<onMatch>ACCEPT</onMatch>
|
|
||||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
|
||||||
<onMismatch>DENY</onMismatch>
|
|
||||||
</filter>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- 系统模块日志级别控制 -->
|
|
||||||
<logger name="com.xjs" level="info" />
|
|
||||||
<!--打印feign DEBUG日志-->
|
|
||||||
<logger name="com.xjs.common.client" level="debug"/>
|
|
||||||
<!-- Spring日志级别控制 -->
|
|
||||||
<logger name="org.springframework" level="warn" />
|
|
||||||
|
|
||||||
<!-- 打开 Bean Searcher 的 SQL 日志 -->
|
|
||||||
<logger name="com.ejlchina.searcher.implement.DefaultSqlExecutor" level="DEBUG" additivity="false">
|
|
||||||
<appender-ref ref="console" />
|
|
||||||
</logger>
|
|
||||||
|
|
||||||
<root level="info">
|
|
||||||
<appender-ref ref="console" />
|
|
||||||
</root>
|
|
||||||
|
|
||||||
<!--系统操作日志-->
|
|
||||||
<root level="info">
|
|
||||||
<appender-ref ref="file_info" />
|
|
||||||
<appender-ref ref="file_error" />
|
|
||||||
</root>
|
|
||||||
</configuration>
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
This is the JRebel configuration file. It maps the running application to your IDE workspace, enabling JRebel reloading for this project.
|
|
||||||
Refer to https://manuals.jrebel.com/jrebel/standalone/config.html for more information.
|
|
||||||
-->
|
|
||||||
<application generated-by="intellij" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://update.zeroturnaround.com/jrebel/rebel-2_3.xsd">
|
|
||||||
|
|
||||||
<id>mall-third-party</id>
|
|
||||||
|
|
||||||
<classpath>
|
|
||||||
<dir name="D:/Dev/IdeaPerject/GitHub/Cloud/xjs-business/xjs-project-mall/mall-third-party/target/classes">
|
|
||||||
</dir>
|
|
||||||
</classpath>
|
|
||||||
|
|
||||||
</application>
|
|
||||||
|
|
@ -16,7 +16,6 @@
|
||||||
<module>mall-member</module>
|
<module>mall-member</module>
|
||||||
<module>mall-coupon</module>
|
<module>mall-coupon</module>
|
||||||
<module>renren-generator</module>
|
<module>renren-generator</module>
|
||||||
<module>mall-third-party</module>
|
|
||||||
</modules>
|
</modules>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue