Browse Source

完善公共方法

master
yunuo970428 2 months ago
parent
commit
3fbffccc7c
  1. 231
      anrui-management/anrui-management-ui/src/components/uploadFile/uploadImg.vue
  2. 14
      anrui-management/anrui-management-ui/src/main.js
  3. 30
      anrui-management/anrui-management-ui/src/router/index.js
  4. 65
      anrui-management/anrui-management-ui/src/styles/index.scss
  5. 8
      anrui-management/anrui-management-ui/src/utils/auth.js

231
anrui-management/anrui-management-ui/src/components/uploadFile/uploadImg.vue

@ -0,0 +1,231 @@
<template>
<div>
<el-upload ref="imgUpload" v-loading="loadding" class="avatar-uploader" :headers="accessToken"
:action="uploadFile" :accept="accept" list-type="picture-card"
:file-list="files" :on-remove="removeImage" :on-preview="handlePictureCardPreview"
:on-progress="uploadProgrees"
:on-error="uploadError" :on-success="uploadImgSuccess_FuJian">
<i class="el-icon-plus avatar-uploader-icon"/>
</el-upload>
<el-dialog :visible.sync="dialogVisible" :append-to-body="true" title="查看图片">
<img width="100%" :src="dialogImageUrl" alt="">
</el-dialog>
</div>
</template>
<script>
import { uploadFile } from '@/api/Common/Upload'
import { getStorage } from '@/utils/auth.js'
export default {
model: {
prop: 'name',
event: 'change'
},
props: {
placeholder: {
type: String,
default: ''
},
bucket: {
type: String,
default: 'abc'
},
//
width: {
type: String,
default: '270px'
},
limit: {
type: Number,
default: 1
},
accept: {
type: String,
default:
'.jpg,.jpeg,.png,'
},
//
name: {
type: Array,
required: true
},
uploadData: {
type: Object,
default: {}
}
},
data() {
return {
dialogImageUrl: '',
dialogVisible: false,
accessToken: null,
uploadFile: uploadFile,
fileList_FuJian: [],
enclosure: '',
file_add: '',
file_catch: '',
files: [],
files_list: [],
filedUrl: '',
// fileUrl: fileUrl,
// showpicture:false,
isview: false,
nameArr: '',
loadding: false,
stateName: ''
}
},
watch: {
name: {
deep: true,
immediate: true,
handler(newVal, oldVal) {
console.log('aaaa1', newVal)
console.log('aaaa2', oldVal)
this.files = newVal
console.log('aaaa2this.files', this.files)
}
}
},
mounted() {
this.$nextTick(() => {
this.Init()
})
},
created() {
this.uploadFile = uploadFile //
this.accessToken = {
token: getStorage()
}
},
methods: {
//
Init() {
if (this.name !== undefined) {
this.files = []
for (var i = 0; i < this.name.length; i++) {
if (this.name[i].url !== null && this.name[i].url !== undefined) {
this.files.push({
name: this.name[i].name,
url: this.name[i].url
})
} else {
this.files.push({
name: this.name[i],
url: this.name[i]
})
}
}
}
},
// --
uploadImgSuccess_FuJian(response, file, fileList) {
console.log('您选择的file:', file)
if (file.response.code === '200') {
this.loadding = false
//
this.filedUrl = this.fileUrl + file.response.data
// var uid = file.response.data
this.files.push({
name: file.response.data.sourceFileName,
url: file.response.data.fullUrl,
filePath: file.response.data.filePath,
size: file.response.data.size
})
this.$emit('change', this.files)
this.$emit('eett', this.files)
}
},
removeImage(file, ImageFileList) {
this.files.splice(this.files.indexOf(file), 1)
const imgFiles = []
this.files.forEach((o) => {
imgFiles.push(o.url)
})
this.$emit('fileChange', this.files)
this.$emit('change', this.files)
},
handleRemove(file, fileList) {
console.log('file:' + JSON.stringify(file))
console.log('fileList:' + JSON.stringify(fileList))
this.enclosure = ''
// 1. id(this.file_add)
this.getNewFileId(fileList)
// 2. id(this.file_catch)
this.getCatchFileId(file)
// 3. id
this.getFileId()
// 4. id
this.$emit('change', this.enclosure)
},
// this.file_add(id)
getNewFileId(fileList) {
// debugger
this.file_add = ''
for (var i = 0; i < fileList.length; i++) {
if (fileList[i].response && fileList[i].response.code === '200') {
this.file_add = this.file_add + fileList[i].response.data + ','
}
}
if (this.file_add !== '') {
this.file_add = this.file_add.substring(0, this.file_add.length - 1)
}
// console.log('1. this.file_add: ' + this.file_add)
},
// this.file_catchid
getCatchFileId(file) {
for (var i = 0; i < this.files_list.length; i++) {
if (this.file_catch !== '') {
// 1. id
if (this.files_list[i].name === file.name) {
// 2. file_catchfils_arry
var fils_arry = this.file_catch.split(',')
// 3. fils_arry this.files_list[i].id
var arry = []
fils_arry.forEach((element) => {
//
if (element !== this.files_list[i].id) {
arry.push(element)
}
})
// 4. file_catch
this.file_catch = arry.join(',')
}
}
}
// console.log('2. this.file_catch:' + this.file_catch)
},
// id
getFileId() {
// console.log('3. this.file_catch:' + this.file_catch + ',this.file_add:' + this.file_add)
if (this.file_catch !== '') {
if (this.file_add !== '') {
this.enclosure = this.file_catch + ',' + this.file_add
} else {
this.enclosure = this.file_catch
}
} else {
this.enclosure = this.file_add
}
},
handlePictureCardPreview(file) {
this.dialogVisible = true
this.dialogImageUrl = file.url
},
//
uploadError() {
this.loadding = false
},
uploadProgrees(event, file, fileList) {
if (Number(event.percent) > 0) {
this.loadding = true
}
}
}
}
</script>
<style lang="scss" scoped></style>

14
anrui-management/anrui-management-ui/src/main.js

@ -11,7 +11,7 @@ import '@/styles/index.scss' // global css
import App from './App'
import store from './store'
import router from './router'
import { setStorage, setDefaultOrgPathName, setDefaultOrgPath } from './utils/auth.js'
import '@/icons' // icon
import request from '@/utils/request'
// import '@/permission' //权限控制
@ -28,7 +28,6 @@ Vue.component('eimage', eimage)
import Print from '@/utils/print' // 引入附件的js文件
Vue.use(Print) // 注册
import { setStorage, getStorage } from './utils/auth.js'
let token = null
token = GetQueryString('token')
@ -39,6 +38,17 @@ let href = window.location.href
// window.location.href = href.slice(0, href.length - 1)
}
var one = window.location.href.indexOf('&organizationData') + 18
if (parseInt(one) > 18) {
const data = window.location.href.substr(one) // url解码unescape()已从web中移除,尽量不使用
var data1 = decodeURIComponent(data)
if (data1 !== undefined) {
const obj = JSON.parse(data1)
setDefaultOrgPath(obj.defaultOrgPath)
setDefaultOrgPathName(obj.defaultOrgPathName)
}
}
// 获取登录用户信息
function getUserInfo() {
return request({

30
anrui-management/anrui-management-ui/src/router/index.js

@ -21,16 +21,6 @@ export const constantRoutes = [
path: '/',
redirect: 'index'
},
/*{
path: '/login',
component: () => import('@/views/login/login.vue')
},*/
/* {
path: '/home',
component: () => import('@/views/Home/Home.vue'),
name: 'home'
},*/
{
path: '/index',
component: Layout,
@ -59,8 +49,24 @@ export const constantRoutes = [
path: '/yuangongguanli',
component: () => import('@/views/sysstaffinfo/yuangongguanli.vue'),
name: 'yuangongguanli',
meta: { title: '员工信息管理',noCache:false }
},
meta: { title: '员工信息管理', noCache: false }
}
]
},
{
path: '/commodity',
component: Layout,
redirect: '/commodity',
meta: {
title: '商品管理'
},
children: [
{
path: '/commodity/commodity',
component: () => import('@/views/commodity/commodity.vue'),
name: 'Commodity',
meta: { title: '商品管理', noCache: false }
}
]
},
{

65
anrui-management/anrui-management-ui/src/styles/index.scss

@ -188,6 +188,71 @@ div:focus {
.footer{margin: 20px;}
}
.formaddcopy02 {
padding: 10px 40px 0 40px;
.title {
padding: 12px;
font-weight: bold;
font-size: 16px;
background-color: #0294d7;
color: #ffffff;
text-align: left;
}
.el-row {
display: flex;
flex-wrap: wrap;
border-left: 1px solid $table-border-color;
.el-col {
border-right: 1px solid $table-border-color;
border-bottom: 1px solid $table-border-color;
min-height: 42px;
padding: 0 15px;
line-height: 42px;
position: relative;
.span-sty {
position: absolute;
top: 0;
bottom: 0;
left: 0;
line-height: 42px;
text-align: right;
font-size: 14px;
color: #606266;
font-weight: 600;
width: 70px;
padding-right: 5px;
border-right: 1px solid #e0e3eb;
}
.el-form-item {
margin-bottom: 0;
line-height: 42px;
.addinputw {
//padding: 5px 0;
width: 65%;
margin-left: 80px;
line-height: 42px;
}
.addinputInfo {
margin-left: 80px;
line-height: 42px;
}
.el-input__inner {
height: 36px !important;
}
}
}
}
.footer {
margin: 20px;
}
}
.forminfo {
padding: 20px 0;

8
anrui-management/anrui-management-ui/src/utils/auth.js

@ -27,3 +27,11 @@ export function setStorage(session) {
export function removeStorage() {
return sessionStorage.removeItem('token')
}
export function setDefaultOrgPathName(data) {
return sessionStorage.setItem('defaultOrgPathName', data)
}
export function setDefaultOrgPath(data) {
return sessionStorage.setItem('defaultOrgPath', data)
}

Loading…
Cancel
Save