【modify】使用ESLint格式化代码

This commit is contained in:
zer0Black
2023-03-01 09:33:58 +08:00
parent 694855ae8b
commit 63369b8b87
400 changed files with 42942 additions and 43132 deletions
+188 -188
View File
@@ -27,207 +27,207 @@
</template>
<script>
import Vue from 'vue'
import { ACCESS_TOKEN } from "@/store/mutation-types"
import { getFileAccessHttpUrl } from '@/api/manage'
const Base64 = require('js-base64').Base64
import Vue from 'vue'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { getFileAccessHttpUrl } from '@/api/manage'
const Base64 = require('js-base64').Base64
const uidGenerator=()=>{
return '-'+parseInt(Math.random()*10000+1,10);
}
export default {
name: 'JImageUpload',
data(){
return {
uploadAction:window._CONFIG['domianURL']+"/sys/common/upload",
uploadLoading:false,
picUrl:false,
headers:{},
fileList: [],
previewImage:"",
}
const uidGenerator = () => {
return '-' + parseInt(Math.random() * 10000 + 1, 10)
}
export default {
name: 'JImageUpload',
data () {
return {
uploadAction: window._CONFIG.domianURL + '/sys/common/upload',
uploadLoading: false,
picUrl: false,
headers: {},
fileList: [],
previewImage: ''
}
},
props: {
text: {
type: String,
required: false,
default: '上传'
},
props:{
text:{
type:String,
required:false,
default:"上传"
},
/*这个属性用于控制文件上传的业务路径*/
bizPath:{
type:String,
required:false,
default:"temp"
},
value:{
type:[String,Array],
required:false
},
disabled:{
type:Boolean,
required:false,
default: false
},
isMultiple:{
type:Boolean,
required:false,
default: false
},
//update-begin-author:wangshuai date:20201021 for:LOWCOD-969 新增number属性,用于判断上传数量
number:{
type:Number,
required:false,
default:0
}
//update-end-author:wangshuai date:20201021 for:LOWCOD-969 新增number属性,用于判断上传数量
/* 这个属性用于控制文件上传的业务路径 */
bizPath: {
type: String,
required: false,
default: 'temp'
},
computed: {
//透传给下级组件的事件,需要排除本组件使用的change事件
childListeners() {
const vm = this;
let result = Object.assign({},
this.$listeners,
)
delete result.change;
return result;
}
value: {
type: [String, Array],
required: false
},
watch:{
value: {
handler(val,oldValue) {
if (val instanceof Array) {
this.initFileList(val.join(','))
} else {
this.initFileList(val)
}
if(!val || val.length==0){
this.picUrl = false;
}
},
//立刻执行handler
immediate: true
}
disabled: {
type: Boolean,
required: false,
default: false
},
created(){
const token = Vue.ls.get(ACCESS_TOKEN);
this.headers = {"X-Access-Token":token}
isMultiple: {
type: Boolean,
required: false,
default: false
},
methods:{
initFileList(paths){
if(!paths || paths.length==0){
this.fileList = [];
return;
// update-begin-author:wangshuai date:20201021 for:LOWCOD-969 新增number属性,用于判断上传数量
number: {
type: Number,
required: false,
default: 0
}
// update-end-author:wangshuai date:20201021 for:LOWCOD-969 新增number属性,用于判断上传数量
},
computed: {
// 透传给下级组件的事件,需要排除本组件使用的change事件
childListeners () {
const vm = this
const result = Object.assign({},
this.$listeners
)
delete result.change
return result
}
},
watch: {
value: {
handler (val, oldValue) {
if (val instanceof Array) {
this.initFileList(val.join(','))
} else {
this.initFileList(val)
}
this.picUrl = true;
let fileList = [];
let arr = paths.split(",")
for(var a=0;a<arr.length;a++){
let url = getFileAccessHttpUrl(arr[a]);
fileList.push({
uid: uidGenerator(),
name: arr[a],
status: 'done',
url: url,
response:{
status:"history",
message:arr[a]
if (!val || val.length == 0) {
this.picUrl = false
}
},
// 立刻执行handler
immediate: true
}
},
created () {
const token = Vue.ls.get(ACCESS_TOKEN)
this.headers = { 'X-Access-Token': token }
},
methods: {
initFileList (paths) {
if (!paths || paths.length == 0) {
this.fileList = []
return
}
this.picUrl = true
const fileList = []
const arr = paths.split(',')
for (var a = 0; a < arr.length; a++) {
const url = getFileAccessHttpUrl(arr[a])
fileList.push({
uid: uidGenerator(),
name: arr[a],
status: 'done',
url: url,
response: {
status: 'history',
message: arr[a]
}
})
}
this.fileList = fileList
},
beforeUpload: function (file) {
var fileType = file.type
if (fileType.indexOf('image') < 0) {
this.$message.warning('请上传图片')
return false
}
},
handleChange (info) {
this.picUrl = false
let fileList = info.fileList
// update-begin-author:wangshuai date:20201022 for:LOWCOD-969 判断number是否大于0和是否多选,返回选定的元素。
if (this.number > 0) {
fileList = fileList.slice(-this.number)
}
// update-end-author:wangshuai date:20201022 for:LOWCOD-969 判断number是否大于0和是否多选,返回选定的元素。
if (info.file.status === 'done') {
if (info.file.response.success) {
this.picUrl = true
fileList = fileList.map((file) => {
if (file.response) {
file.url = `${file.response.result.id}`
}
return file
})
}
this.fileList = fileList
},
beforeUpload: function(file){
var fileType = file.type;
if(fileType.indexOf('image')<0){
this.$message.warning('请上传图片');
return false;
}
},
handleChange(info) {
this.picUrl = false;
let fileList = info.fileList
//update-begin-author:wangshuai date:20201022 for:LOWCOD-969 判断number是否大于0和是否多选,返回选定的元素。
if(this.number>0){
fileList = fileList.slice(-this.number);
}
//update-end-author:wangshuai date:20201022 for:LOWCOD-969 判断number是否大于0和是否多选,返回选定的元素。
if(info.file.status==='done'){
if(info.file.response.success){
this.picUrl = true;
fileList = fileList.map((file) => {
if (file.response) {
file.url = `${file.response.result.id}`;
}
return file;
});
}
//this.$message.success(`${info.file.name} 上传成功!`);
}else if (info.file.status === 'error') {
this.$message.error(`${info.file.name} 上传失败.`);
}else if(info.file.status === 'removed'){
this.handleDelete(info.file)
}
this.fileList = fileList
if(info.file.status==='done' || info.file.status === 'removed'){
this.handlePathChange()
}
},
// 预览
handlePreview(file) {
if (file && file.url) {
var fileFullUrl = `${window._CONFIG['domianWebSocketURL']}/${file.url}`
let url = `${window._CONFIG['onlinePreviewDomainURL']}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
window.open(url)
}
},
getAvatarView(){
if(this.fileList.length>0){
let url = this.fileList[this.fileList.length-1].url
return getFileAccessHttpUrl(url)
}
},
handlePathChange(){
let uploadFiles = this.fileList
let path = ''
if(!uploadFiles || uploadFiles.length==0){
path = ''
}
let arr = [];
if(!this.isMultiple && uploadFiles && uploadFiles.length > 0){
arr.push(uploadFiles[uploadFiles.length-1].url)
}else{
for(let a=0;a<uploadFiles.length;a++){
// update-begin-author:taoyan date:20200819 for:【开源问题z】上传图片组件 LOWCOD-783
if(uploadFiles[a].status === 'done' ) {
arr.push(uploadFiles[a].url)
}else{
return;
}
// update-end-author:taoyan date:20200819 for:【开源问题z】上传图片组件 LOWCOD-783
}
}
if(arr.length>0){
path = arr.join(",")
}
this.$emit('change', path);
},
handleDelete(file){
//如有需要新增 删除逻辑
},
handleCancel() {
this.close();
this.previewVisible = false;
},
close () {
},
// this.$message.success(`${info.file.name} 上传成功!`);
} else if (info.file.status === 'error') {
this.$message.error(`${info.file.name} 上传失败.`)
} else if (info.file.status === 'removed') {
this.handleDelete(info.file)
}
this.fileList = fileList
if (info.file.status === 'done' || info.file.status === 'removed') {
this.handlePathChange()
}
},
model: {
prop: 'value',
event: 'change'
// 预览
handlePreview (file) {
if (file && file.url) {
var fileFullUrl = `${window._CONFIG.domianWebSocketURL}/${file.url}`
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
window.open(url)
}
},
getAvatarView () {
if (this.fileList.length > 0) {
const url = this.fileList[this.fileList.length - 1].url
return getFileAccessHttpUrl(url)
}
},
handlePathChange () {
const uploadFiles = this.fileList
let path = ''
if (!uploadFiles || uploadFiles.length == 0) {
path = ''
}
const arr = []
if (!this.isMultiple && uploadFiles && uploadFiles.length > 0) {
arr.push(uploadFiles[uploadFiles.length - 1].url)
} else {
for (let a = 0; a < uploadFiles.length; a++) {
// update-begin-author:taoyan date:20200819 for:【开源问题z】上传图片组件 LOWCOD-783
if (uploadFiles[a].status === 'done') {
arr.push(uploadFiles[a].url)
} else {
return
}
// update-end-author:taoyan date:20200819 for:【开源问题z】上传图片组件 LOWCOD-783
}
}
if (arr.length > 0) {
path = arr.join(',')
}
this.$emit('change', path)
},
handleDelete (file) {
// 如有需要新增 删除逻辑
},
handleCancel () {
this.close()
this.previewVisible = false
},
close () {
}
},
model: {
prop: 'value',
event: 'change'
}
}
</script>
<style scoped>