yshop1.7发布,后台升級eladmin2.4(前端,后台权限,代码生成器等重构),修复商品分类等一些问题

This commit is contained in:
hupeng
2020-01-07 23:32:27 +08:00
parent 24753759f4
commit b6cc8046db
451 changed files with 13868 additions and 8883 deletions

View File

@ -1,27 +1,27 @@
<template>
<el-form ref="form" :model="form" :rules="rules" style="margin-top: 6px;" size="small" label-width="100px">
<el-form-item label="appID" prop="appID">
<el-input v-model="form.appID" style="width: 40%"/>
<el-input v-model="form.appId" style="width: 40%" />
<span style="color: #C0C0C0;margin-left: 10px;">应用APPID,收款账号既是APPID对应支付宝账号</span>
</el-form-item>
<el-form-item label="商家账号" prop="sysServiceProviderId">
<el-input v-model="form.sysServiceProviderId" style="width: 40%;"/>
<el-input v-model="form.sysServiceProviderId" style="width: 40%;" />
<span style="color: #C0C0C0;margin-left: 10px;">商家账号</span>
</el-form-item>
<el-form-item label="商户私钥" prop="privateKey">
<el-input v-model="form.privateKey" type="password" style="width: 40%;"/>
<el-input v-model="form.privateKey" type="password" style="width: 40%;" />
<span style="color: #C0C0C0;margin-left: 10px;">商户私钥你的PKCS8格式RSA2私钥</span>
</el-form-item>
<el-form-item label="支付宝公钥" prop="publicKey">
<el-input v-model="form.publicKey" type="password" style="width: 40%;"/>
<el-input v-model="form.publicKey" type="password" style="width: 40%;" />
<span style="color: #C0C0C0;margin-left: 10px;">支付宝公钥</span>
</el-form-item>
<el-form-item label="回调地址" prop="returnUrl">
<el-input v-model="form.returnUrl" style="width: 40%;"/>
<el-input v-model="form.returnUrl" style="width: 40%;" />
<span style="color: #C0C0C0;margin-left: 10px;">订单完成后返回的地址</span>
</el-form-item>
<el-form-item label="异步通知" prop="notifyUrl">
<el-input v-model="form.notifyUrl" style="width: 40%;"/>
<el-input v-model="form.notifyUrl" style="width: 40%;" />
<span style="color: #C0C0C0;margin-left: 10px;">支付结果异步通知地址</span>
</el-form-item>
<el-form-item label="">
@ -31,13 +31,13 @@
</template>
<script>
import { get, update } from '@/api/alipay'
import { get, update } from '@/api/tools/alipay'
export default {
name: 'Config',
data() {
return {
loading: false,
form: { appID: '', sysServiceProviderId: '', privateKey: '', publicKey: '', returnUrl: '', notifyUrl: '' },
form: { appId: '', sysServiceProviderId: '', privateKey: '', publicKey: '', returnUrl: '', notifyUrl: '' },
rules: {
appID: [
{ required: true, message: '请输入appID', trigger: 'blur' }

View File

@ -1,10 +1,10 @@
<template>
<el-tabs v-model="activeName" style="padding-left: 5px;">
<el-tab-pane label="参数配置" name="first">
<Config/>
<Config />
</el-tab-pane>
<el-tab-pane label="支付测试" name="second">
<ToPay/>
<ToPay />
</el-tab-pane>
<el-tab-pane label="使用说明" name="third">
<div>
@ -33,7 +33,6 @@ if (/(Android)/i.test(navigator.userAgent)){ // 判断是否为Android手机
<script>
import Config from './config'
import ToPay from './toPay'
import '@/styles/description.scss'
export default {
name: 'AliPay',
components: { Config, ToPay },

View File

@ -2,14 +2,14 @@
<div>
<el-form ref="form" :model="form" :rules="rules" style="margin-top: 6px;" size="small" label-width="90px">
<el-form-item label="商品名称" prop="subject">
<el-input v-model="form.subject" style="width: 35%"/>
<el-input v-model="form.subject" style="width: 35%" />
</el-form-item>
<el-form-item label="商品价格" prop="totalAmount">
<el-input v-model="form.totalAmount" style="width: 35%"/>
<el-input v-model="form.totalAmount" style="width: 35%" />
<span style="color: #C0C0C0;margin-left: 10px;">测试允许区间(0,5000]</span>
</el-form-item>
<el-form-item label="商品描述" prop="body">
<el-input v-model="form.body" style="width: 35%" rows="8" type="textarea"/>
<el-input v-model="form.body" style="width: 35%" rows="8" type="textarea" />
</el-form-item>
<el-form-item label="">
<el-button :loading="loading" size="medium" type="primary" @click="doSubmit">去支付</el-button>
@ -19,7 +19,7 @@
</template>
<script>
import { toAliPay } from '@/api/alipay'
import { toAliPay } from '@/api/tools/alipay'
export default {
data() {
return {

View File

@ -1,23 +1,23 @@
<template>
<el-form ref="form" :model="form" :rules="rules" style="margin-top: 6px;" size="small" label-width="100px">
<el-form-item label="发件人邮箱" prop="fromUser">
<el-input v-model="form.fromUser" style="width: 40%"/>
<el-input v-model="form.fromUser" style="width: 40%" />
<span style="color: #C0C0C0;margin-left: 10px;">Sender mailbox</span>
</el-form-item>
<el-form-item label="发件用户名" prop="user">
<el-input v-model="form.user" style="width: 40%;"/>
<el-input v-model="form.user" style="width: 40%;" />
<span style="color: #C0C0C0;margin-left: 10px;">Sender usernamex</span>
</el-form-item>
<el-form-item label="邮箱密码" prop="pass">
<el-input v-model="form.pass" type="password" style="width: 40%;"/>
<el-input v-model="form.pass" type="password" style="width: 40%;" />
<span style="color: #C0C0C0;margin-left: 10px;">email Password</span>
</el-form-item>
<el-form-item label="SMTP地址" prop="host">
<el-input v-model="form.host" style="width: 40%;"/>
<el-input v-model="form.host" style="width: 40%;" />
<span style="color: #C0C0C0;margin-left: 10px;">SMTP address</span>
</el-form-item>
<el-form-item label="SMTP端口" prop="port">
<el-input v-model="form.port" style="width: 40%;"/>
<el-input v-model="form.port" style="width: 40%;" />
<span style="color: #C0C0C0;margin-left: 10px;">SMTP port</span>
</el-form-item>
<el-form-item label="">
@ -27,7 +27,7 @@
</template>
<script>
import { get, update } from '@/api/email'
import { get, update } from '@/api/tools/email'
export default {
name: 'Config',
data() {

View File

@ -1,10 +1,10 @@
<template>
<el-tabs v-model="activeName" style="padding-left: 5px;">
<el-tab-pane label="邮箱配置" name="first">
<Config/>
<Config />
</el-tab-pane>
<el-tab-pane label="发送邮件" name="second">
<Send/>
<Send />
</el-tab-pane>
<el-tab-pane label="使用说明" name="third">
<div>
@ -26,7 +26,6 @@
<script>
import Config from './config'
import Send from './send'
import '@/styles/description.scss'
export default {
name: 'Email',
components: { Config, Send },

View File

@ -2,35 +2,33 @@
<div>
<el-form ref="form" :model="form" :rules="rules" style="margin-top: 6px;" size="small" label-width="100px">
<el-form-item label="邮件标题" prop="subject">
<el-input v-model="form.subject" style="width: 40%"/>
<el-input v-model="form.subject" style="width: 646px" />
</el-form-item>
<el-form-item
v-for="(domain, index) in tos"
:key="domain.key"
:label="'收件邮箱' + (index === 0 ? '': index)"
:key="domain.key">
<el-input v-model="domain.value" style="width: 31%"/>
>
<el-input v-model="domain.value" style="width: 550px" />
<el-button icon="el-icon-plus" @click="addDomain" />
<el-button style="margin-left:0px;" icon="el-icon-minus" @click.prevent="removeDomain(domain)"/>
<el-button style="margin-left:0;" icon="el-icon-minus" @click.prevent="removeDomain(domain)" />
</el-form-item>
<div ref="editor" class="editor"/>
<div ref="editor" class="editor" />
<el-button :loading="loading" style="margin-left:1.6%;" size="medium" type="primary" @click="doSubmit">发送邮件</el-button>
</el-form>
</div>
</template>
<script>
import { send } from '@/api/tools/email'
import { upload } from '@/utils/upload'
import { validEmail } from '@/utils/validate'
import { mapGetters } from 'vuex'
import { getToken } from '@/utils/auth'
import { send } from '@/api/email'
import { validatEmail } from '@/utils/validate'
import E from 'wangeditor'
export default {
name: 'Index',
data() {
return {
headers: {
'Authorization': 'Bearer ' + getToken()
},
loading: false, form: { subject: '', tos: [], content: '' },
tos: [{
value: ''
@ -44,21 +42,26 @@ export default {
},
computed: {
...mapGetters([
// sm.ms图床
'imagesUploadApi',
// 七牛云 按需选择
'qiNiuUploadApi'
'imagesUploadApi'
])
},
mounted() {
const _this = this
var editor = new E(this.$refs.editor)
editor.customConfig.uploadImgShowBase64 = true // 使用 base64 保存图片
// 不可修改
editor.customConfig.uploadImgHeaders = this.headers
// 自定义文件名,不可修改,修改后会上传失败
editor.customConfig.uploadFileName = 'file'
// 上传到哪儿,按需选择
editor.customConfig.uploadImgServer = this.imagesUploadApi // 上传图片到服务器
// 自定义菜单配置
editor.customConfig.zIndex = 10
// 文件上传
editor.customConfig.customUploadImg = function(files, insert) {
// files 是 input 中选中的文件列表
// insert 是获取图片 url 后,插入到编辑器的方法
files.forEach(image => {
files.forEach(image => {
upload(_this.imagesUploadApi, image).then(data => {
insert(data.data.url)
})
})
})
}
editor.customConfig.onchange = (html) => {
this.form.content = html
}
@ -95,7 +98,7 @@ export default {
type: 'warning'
})
sub = true
} else if (validatEmail(data.value)) {
} else if (validEmail(data.value)) {
_this.form.tos.push(data.value)
} else {
_this.$message({
@ -131,5 +134,9 @@ export default {
.editor{
text-align:left;
margin: 20px;
width: 730px;
}
/deep/ .w-e-text-container {
height: 360px !important;
}
</style>

View File

@ -2,29 +2,45 @@
<div class="app-container">
<!--工具栏-->
<div class="head-container">
<!--搜索-->
<el-input v-model="query.filename" clearable placeholder="输入文件名" style="width: 200px;" class="filter-item" @keyup.enter.native="toQuery"/>
<el-button class="filter-item" size="mini" type="success" icon="el-icon-search" @click="toQuery">搜索</el-button>
<!-- 上传 -->
<div style="display: inline-block;margin: 0px 2px;">
<div v-if="crud.props.searchToggle">
<!--搜索-->
<el-input v-model="query.filename" clearable size="small" placeholder="输入文件名" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
<el-date-picker
v-model="query.createTime"
:default-time="['00:00:00','23:59:59']"
type="daterange"
range-separator=":"
size="small"
class="date-item"
value-format="yyyy-MM-dd HH:mm:ss"
start-placeholder="开始日期"
end-placeholder="结束日期"
/>
<rrOperation :crud="crud" />
</div>
<crudOperation :permission="permission">
<!-- 上传 -->
<el-button
v-permission="['ADMIN','PICTURE_ALL','PICTURE_UPLOAD']"
slot="left"
v-permission="['admin','pictures:add']"
class="filter-item"
size="mini"
type="primary"
icon="el-icon-upload"
@click="dialog = true">上传图片</el-button>
</div>
<div v-permission="['ADMIN','PICTURE_ALL','PICTURE_DELETE']" style="display: inline-block;">
<el-button
:loading="delAllLoading"
:disabled="data.length === 0 || $refs.table.selection.length === 0"
class="filter-item"
size="mini"
type="danger"
icon="el-icon-delete"
@click="open">删除</el-button>
</div>
@click="dialog = true"
>上传</el-button>
<el-tooltip slot="right" class="item" effect="dark" content="使用同步功能需要在 https://sm.ms/login 中注册账号,并且在 application.yml 文件中修改 Secret Token" placement="top-start">
<el-button
v-permission="['admin','pictures:add']"
class="filter-item"
size="mini"
type="success"
icon="el-icon-refresh"
:loading="syncLoading"
@click="sync"
>同步</el-button>
</el-tooltip>
</crudOperation>
</div>
<!--上传图片-->
<el-dialog :visible.sync="dialog" :close-on-click-modal="false" append-to-body width="600px" @close="doSubmit">
@ -36,10 +52,11 @@
:headers="headers"
:file-list="fileList"
:action="imagesUploadApi"
list-type="picture-card">
<i class="el-icon-plus"/>
list-type="picture-card"
>
<i class="el-icon-plus" />
</el-upload>
<el-dialog :append-to-body="true" :visible.sync="dialogVisible">
<el-dialog append-to-body :visible.sync="dialogVisible">
<img :src="dialogImageUrl" width="100%" alt="">
</el-dialog>
<div slot="footer" class="dialog-footer">
@ -47,68 +64,60 @@
</div>
</el-dialog>
<!--表格渲染-->
<el-table v-loading="loading" ref="table" :data="data" size="small" style="width: 100%;">
<el-table-column type="selection" width="55"/>
<el-table-column prop="filename" label="文件名"/>
<el-table-column prop="username" label="上传者"/>
<el-table-column ref="table" :show-overflow-tooltip="true" prop="url" label="缩略图">
<template slot-scope="scope">
<a :href="scope.row.url" style="color: #42b983" target="_blank"><img :src="scope.row.url" alt="点击打开" class="el-avatar"></a>
<el-table ref="table" v-loading="crud.loading" :data="crud.data" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
<el-table-column type="selection" width="55" />
<el-table-column v-if="columns.visible('filename')" width="200" prop="filename" label="文件名" />
<el-table-column v-if="columns.visible('username')" prop="username" label="上传者" />
<el-table-column v-if="columns.visible('url')" ref="table" :show-overflow-tooltip="true" prop="url" label="缩略图">
<template slot-scope="{row}">
<el-image
:src="row.url"
:preview-src-list="[row.url]"
fit="contain"
lazy
class="el-avatar"
/>
</template>
</el-table-column>
<el-table-column prop="size" label="文件大小"/>
<el-table-column prop="height" label="高度"/>
<el-table-column prop="width" label="宽度"/>
<el-table-column width="180px" prop="createTime" label="创建日期">
<el-table-column v-if="columns.visible('size')" prop="size" label="文件大小" />
<el-table-column v-if="columns.visible('height')" prop="height" label="高度" />
<el-table-column v-if="columns.visible('width')" prop="width" label="宽度" />
<el-table-column v-if="columns.visible('createTime')" prop="createTime" label="创建日期">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column v-if="checkPermission(['ADMIN','PICTURE_ALL','PICTURE_DELETE'])" label="操作" width="100px" align="center" fixed="right">
<template slot-scope="scope">
<el-popover
:ref="scope.row.id"
placement="top"
width="180">
<p>确定删除本条数据吗</p>
<div style="text-align: right; margin: 0">
<el-button size="mini" type="text" @click="$refs[scope.row.id].doClose()">取消</el-button>
<el-button :loading="delLoading" type="primary" size="mini" @click="subDelete(scope.row.id)">确定</el-button>
</div>
<el-button slot="reference" type="danger" icon="el-icon-delete" size="mini"/>
</el-popover>
</template>
</el-table-column>
</el-table>
<!--分页组件-->
<el-pagination
:total="total"
:current-page="page + 1"
style="margin-top: 8px;"
layout="total, prev, pager, next, sizes"
@size-change="sizeChange"
@current-change="pageChange"/>
<pagination />
</div>
</template>
<script>
import checkPermission from '@/utils/permission' // 权限判断函数
import initData from '@/mixins/initData'
import { parseTime } from '@/utils/index'
import { mapGetters } from 'vuex'
import { del, delAll } from '@/api/picture'
import crudPic from '@/api/tools/picture'
import CRUD, { presenter, header, crud } from '@crud/crud'
import { getToken } from '@/utils/auth'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import pagination from '@crud/Pagination'
// crud交由presenter持有
const defaultCrud = CRUD({ title: '图片', url: 'api/pictures', crudMethod: { ...crudPic }})
export default {
name: 'Pictures',
mixins: [initData],
components: { pagination, crudOperation, rrOperation },
mixins: [presenter(defaultCrud), header(), crud()],
data() {
return {
delLoading: false, downloadLoading: false,
delAllLoading: false,
headers: {
'Authorization': 'Bearer ' + getToken()
},
dialog: false,
syncLoading: false,
headers: {
'Authorization': getToken()
},
permission: {
del: ['admin', 'pictures:del']
},
dialogImageUrl: '',
dialogVisible: false,
fileList: [],
@ -121,70 +130,10 @@ export default {
])
},
created() {
this.$nextTick(() => {
this.init()
})
this.crud.optShow.add = false
this.crud.optShow.edit = false
},
methods: {
parseTime,
checkPermission,
beforeInit() {
this.url = 'api/pictures'
const sort = 'id,desc'
const query = this.query
const filename = query.filename
this.params = { page: this.page, size: this.size, sort: sort }
if (filename) { this.params[filename] = filename }
return true
},
subDelete(id) {
this.delLoading = true
del(id).then(res => {
this.delLoading = false
this.$refs[id].doClose()
this.dleChangePage()
this.init()
this.$notify({
title: '删除成功',
type: 'success',
duration: 2500
})
}).catch(err => {
this.delLoading = false
this.$refs[id].doClose()
console.log(err.response.data.message)
})
},
doDelete() {
this.delAllLoading = true
const data = this.$refs.table.selection
const ids = []
for (let i = 0; i < data.length; i++) {
ids.push(data[i].id)
}
delAll(ids).then(res => {
this.delAllLoading = false
this.init()
this.dleChangePage(ids.length)
this.$notify({
title: '删除成功',
type: 'success',
duration: 2500
})
}).catch(err => {
this.delAllLoading = false
console.log(err.response.data.message)
})
},
open() {
this.$confirm('你确定删除选中的数据吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.doDelete()
})
},
handleSuccess(response, file, fileList) {
const uid = file.uid
const id = response.id
@ -193,7 +142,7 @@ export default {
handleBeforeRemove(file, fileList) {
for (let i = 0; i < this.pictures.length; i++) {
if (this.pictures[i].uid === file.uid) {
del(this.pictures[i].id).then(res => {})
crudPic.del(this.pictures[i].id).then(res => {})
return true
}
}
@ -208,7 +157,7 @@ export default {
this.dialogVisible = false
this.dialogImageUrl = ''
this.dialog = false
this.init()
this.crud.toQuery()
},
// 监听上传失败
handleError(e, file, fileList) {
@ -218,6 +167,14 @@ export default {
type: 'error',
duration: 2500
})
},
sync() {
this.syncLoading = true
crudPic.sync().then(res => {
this.crud.notify('同步成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
this.crud.toQuery()
this.syncLoading = false
})
}
}
}

View File

@ -1,10 +1,10 @@
<template>
<el-tabs v-model="activeName" style="padding-left: 8px;" @tab-click="tabClick">
<el-tab-pane label="本地存储" name="first">
<Local ref="local"/>
<Local ref="local" />
</el-tab-pane>
<el-tab-pane label="七牛云存储" name="second">
<QiNiu ref="qiNiu"/>
<QiNiu ref="qiNiu" />
</el-tab-pane>
</el-tabs>
</template>
@ -12,7 +12,6 @@
<script>
import QiNiu from './qiniu/index'
import Local from './local/index'
import '@/styles/description.scss'
export default {
name: 'Storage',
components: { QiNiu, Local },
@ -24,9 +23,9 @@ export default {
methods: {
tabClick(name) {
if (this.activeName === 'first') {
this.$refs.local.init()
this.$refs.local.crud.toQuery()
} else {
this.$refs.qiNiu.init()
this.$refs.qiNiu.crud.toQuery()
}
}
}

View File

@ -1,122 +0,0 @@
<template>
<el-dialog :append-to-body="true" :close-on-click-modal="false" :before-close="cancel" :visible.sync="dialog" :title="isAdd ? '上传文件' : '编辑文件'" width="500px">
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
<el-form-item label="文件名" >
<el-input v-model="form.name" style="width: 370px;"/>
</el-form-item>
<!-- 上传文件 -->
<el-form-item v-if="isAdd" label="上传">
<el-upload
ref="upload"
:limit="1"
:before-upload="beforeUpload"
:auto-upload="false"
:headers="headers"
:on-success="handleSuccess"
:on-error="handleError"
:action="fileUploadApi + '?name=' + form.name">
<div class="eladmin-upload"><i class="el-icon-upload"/> 添加文件</div>
<div slot="tip" class="el-upload__tip">可上传任意格式文件且不超过100M</div>
</el-upload>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="cancel">取消</el-button>
<el-button :loading="loading" type="primary" @click="doSubmit">确认</el-button>
</div>
</el-dialog>
</template>
<script>
import { mapGetters } from 'vuex'
import { getToken } from '@/utils/auth'
import { edit } from '@/api/localStorage'
export default {
props: {
isAdd: {
type: Boolean,
required: true
}
},
data() {
return {
loading: false, dialog: false,
headers: { 'Authorization': 'Bearer ' + getToken() },
form: {
id: '',
name: ''
},
rules: {
}
}
},
computed: {
...mapGetters([
'fileUploadApi'
])
},
methods: {
cancel() {
this.resetForm()
},
doSubmit() {
this.loading = true
if (this.isAdd) {
this.$refs.upload.submit()
} else this.doEdit()
},
doEdit() {
edit(this.form).then(res => {
this.resetForm()
this.$notify({
title: '修改成功',
type: 'success',
duration: 2500
})
this.loading = false
this.$parent.init()
}).catch(err => {
this.loading = false
console.log(err.response.data.message)
})
},
resetForm() {
this.dialog = false
this.$refs['form'].resetFields()
this.form = {
id: '',
name: ''
}
},
beforeUpload(file) {
let isLt2M = true
isLt2M = file.size / 1024 / 1024 < 100
if (!isLt2M) {
this.$message.error('上传文件大小不能超过 100MB!')
}
this.loading = false
return isLt2M
},
handleSuccess(response, file, fileList) {
this.dialog = false
this.resetForm()
this.$refs.upload.clearFiles()
this.$parent.init()
},
// 监听上传失败
handleError(e, file, fileList) {
const msg = JSON.parse(e.message)
this.$notify({
title: msg.message,
type: 'error',
duration: 2500
})
this.loading = false
}
}
}
</script>
<style scoped>
</style>

View File

@ -2,192 +2,195 @@
<div class="app-container" style="padding: 8px;">
<!--工具栏-->
<div class="head-container">
<!-- 搜索 -->
<el-input v-model="query.value" clearable placeholder="输入内容模糊搜索" style="width: 200px;" class="filter-item" @keyup.enter.native="toQuery"/>
<el-button class="filter-item" size="mini" type="success" icon="el-icon-search" @click="toQuery">搜索</el-button>
<!-- 新增 -->
<div style="display: inline-block;margin: 0px 2px;">
<div v-if="crud.props.searchToggle">
<!-- 搜索 -->
<el-input v-model="query.blurry" clearable size="small" placeholder="输入内容模糊搜索" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
<el-date-picker
v-model="query.createTime"
:default-time="['00:00:00','23:59:59']"
type="daterange"
range-separator=":"
size="small"
class="date-item"
value-format="yyyy-MM-dd HH:mm:ss"
start-placeholder="开始日期"
end-placeholder="结束日期"
/>
<rrOperation :crud="crud" />
</div>
<crudOperation :permission="permission">
<!-- 新增 -->
<el-button
v-permission="['ADMIN','LOCALSTORAGE_ALL','LOCALSTORAGE_CREATE']"
slot="left"
v-permission="['admin','storage:add']"
class="filter-item"
size="mini"
type="primary"
icon="el-icon-upload"
@click="add">文件上传</el-button>
</div>
<!-- 多选删除 -->
<div style="display: inline-block;margin: 0px 2px;">
<el-button
:loading="delAllLoading"
:disabled="data.length === 0 || $refs.table.selection.length === 0"
class="filter-item"
size="mini"
type="danger"
icon="el-icon-delete"
@click="open">删除</el-button>
</div>
@click="crud.toAdd"
>上传
</el-button>
</crudOperation>
</div>
<!--表单组件-->
<eForm ref="form" :is-add="isAdd"/>
<el-dialog append-to-body :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.add ? '文件上传' : '编辑文件'" width="500px">
<el-form ref="form" :model="form" size="small" label-width="80px">
<el-form-item label="文件名">
<el-input v-model="form.name" style="width: 370px;" />
</el-form-item>
<!-- 上传文件 -->
<el-form-item v-if="crud.status.add" label="上传">
<el-upload
ref="upload"
:limit="1"
:before-upload="beforeUpload"
:auto-upload="false"
:headers="headers"
:on-success="handleSuccess"
:on-error="handleError"
:action="fileUploadApi + '?name=' + form.name"
>
<div class="eladmin-upload"><i class="el-icon-upload" /> 添加文件</div>
<div slot="tip" class="el-upload__tip">可上传任意格式文件且不超过100M</div>
</el-upload>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="crud.cancelCU">取消</el-button>
<el-button v-if="crud.status.add" :loading="loading" type="primary" @click="upload">确认</el-button>
<el-button v-else :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
</div>
</el-dialog>
<!--表格渲染-->
<el-table v-loading="loading" ref="table" :data="data" size="small" style="width: 100%;">
<el-table-column type="selection" width="55"/>
<el-table-column :show-overflow-tooltip="true" prop="name" label="文件名">
<el-table ref="table" v-loading="crud.loading" :data="crud.data" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
<el-table-column type="selection" width="55" />
<el-table-column v-if="columns.visible('name')" prop="name" label="文件名">
<template slot-scope="scope">
<el-link :underline="false" :href="baseApi + '/file/' + scope.row.type + '/' + scope.row.realName" target="_blank" type="primary">{{ scope.row.name }}</el-link>
<el-popover
:content="'file/' + scope.row.type + '/' + scope.row.realName"
placement="top-start"
title="路径"
width="200"
trigger="hover"
>
<a
slot="reference"
:href="baseApi + '/file/' + scope.row.type + '/' + scope.row.realName"
class="el-link--primary"
style="word-break:keep-all;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color: #1890ff;font-size: 13px;"
target="_blank"
>
{{ scope.row.name }}
</a>
</el-popover>
</template>
</el-table-column>
<el-table-column prop="suffix" label="文件类型"/>
<el-table-column prop="type" label="类别"/>
<el-table-column prop="size" label="大小"/>
<el-table-column prop="operate" label="操作人"/>
<el-table-column prop="createTime" label="创建日期">
<el-table-column v-if="columns.visible('path')" prop="path" label="预览图">
<template slot-scope="{row}">
<el-image
:src=" baseApi + '/file/' + row.type + '/' + row.realName"
:preview-src-list="[baseApi + '/file/' + row.type + '/' + row.realName]"
fit="contain"
lazy
class="el-avatar"
>
<div slot="error">
<i class="el-icon-document" />
</div>
</el-image>
</template>
</el-table-column>
<el-table-column v-if="columns.visible('suffix')" prop="suffix" label="文件类型" />
<el-table-column v-if="columns.visible('type')" prop="type" label="类别" />
<el-table-column v-if="columns.visible('size')" prop="size" label="大小" />
<el-table-column v-if="columns.visible('operate')" prop="operate" label="操作人" />
<el-table-column v-if="columns.visible('createTime')" prop="createTime" label="创建日期">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column prop="updateTime" label="修改日期">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.updateTime) }}</span>
</template>
</el-table-column>
<el-table-column v-if="checkPermission(['ADMIN','LOCALSTORAGE_ALL','LOCALSTORAGE_EDIT','LOCALSTORAGE_DELETE'])" label="操作" width="150px" align="center">
<template slot-scope="scope">
<el-button v-permission="['ADMIN','LOCALSTORAGE_ALL','LOCALSTORAGE_EDIT']" size="mini" type="primary" icon="el-icon-edit" @click="edit(scope.row)"/>
<el-popover
v-permission="['ADMIN','LOCALSTORAGE_ALL','LOCALSTORAGE_DELETE']"
:ref="scope.row.id"
placement="top"
width="180">
<p>确定删除本条数据吗</p>
<div style="text-align: right; margin: 0">
<el-button size="mini" type="text" @click="$refs[scope.row.id].doClose()">取消</el-button>
<el-button :loading="delLoading" type="primary" size="mini" @click="subDelete(scope.row.id)">确定</el-button>
</div>
<el-button slot="reference" type="danger" icon="el-icon-delete" size="mini"/>
</el-popover>
</template>
</el-table-column>
</el-table>
<!--分页组件-->
<el-pagination
:total="total"
:current-page="page + 1"
style="margin-top: 8px;"
layout="total, prev, pager, next, sizes"
@size-change="sizeChange"
@current-change="pageChange"/>
<pagination />
</div>
</template>
<script>
import { mapGetters } from 'vuex'
import checkPermission from '@/utils/permission'
import initData from '@/mixins/initData'
import { del, delAll } from '@/api/localStorage'
import { parseTime } from '@/utils/index'
import eForm from './form'
import { getToken } from '@/utils/auth'
import crudFile from '@/api/tools/localStorage'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import pagination from '@crud/Pagination'
// crud交由presenter持有
const defaultCrud = CRUD({ title: '文件', url: 'api/localStorage', crudMethod: { ...crudFile }})
const defaultForm = { id: null, name: '' }
export default {
components: { eForm },
mixins: [initData],
components: { pagination, crudOperation, rrOperation },
mixins: [presenter(defaultCrud), header(), form(defaultForm), crud()],
data() {
return {
delLoading: false, delAllLoading: false,
queryTypeOptions: [
{ key: 'name', display_name: '文件名' },
{ key: 'suffix', display_name: '后缀' },
{ key: 'type', display_name: '类型' },
{ key: 'operate', display_name: '操作人' }
]
delAllLoading: false,
loading: false,
headers: { 'Authorization': getToken() },
permission: {
edit: ['admin', 'storage:edit'],
del: ['admin', 'storage:del']
}
}
},
computed: {
...mapGetters([
'baseApi'
'baseApi',
'fileUploadApi'
])
},
created() {
this.$nextTick(() => {
this.init()
})
this.crud.optShow.add = false
},
methods: {
parseTime,
checkPermission,
beforeInit() {
this.url = 'api/localStorage'
const sort = 'id,desc'
this.params = { page: this.page, size: this.size, sort: sort }
const query = this.query
const value = query.value
if (value) { this.params['blurry'] = value }
return true
// 上传文件
upload() {
this.$refs.upload.submit()
},
subDelete(id) {
this.delLoading = true
del(id).then(res => {
this.delLoading = false
this.$refs[id].doClose()
this.dleChangePage()
this.init()
this.$notify({
title: '删除成功',
type: 'success',
duration: 2500
})
}).catch(err => {
this.delLoading = false
this.$refs[id].doClose()
console.log(err.response.data.message)
})
},
add() {
this.isAdd = true
this.$refs.form.dialog = true
},
edit(data) {
this.isAdd = false
const _this = this.$refs.form
_this.form = {
id: data.id,
name: data.name
beforeUpload(file) {
let isLt2M = true
isLt2M = file.size / 1024 / 1024 < 100
if (!isLt2M) {
this.loading = false
this.$message.error('上传文件大小不能超过 100MB!')
}
_this.dialog = true
this.form.name = file.name
return isLt2M
},
doDelete() {
this.delAllLoading = true
const data = this.$refs.table.selection
const ids = []
for (let i = 0; i < data.length; i++) {
ids.push(data[i].id)
}
delAll(ids).then(res => {
this.delAllLoading = false
this.dleChangePage(ids.length)
this.init()
this.$notify({
title: '删除成功',
type: 'success',
duration: 2500
})
}).catch(err => {
this.delAllLoading = false
console.log(err.response.data.message)
})
handleSuccess(response, file, fileList) {
this.crud.notify('上传成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
this.$refs.upload.clearFiles()
this.crud.status.add = CRUD.STATUS.NORMAL
this.crud.resetForm()
this.crud.toQuery()
},
open() {
this.$confirm('你确定删除选中的数据吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.doDelete()
// 监听上传失败
handleError(e, file, fileList) {
const msg = JSON.parse(e.message)
this.$notify({
title: msg.message,
type: 'error',
duration: 2500
})
this.loading = false
}
}
}
</script>
<style scoped>
/deep/ .el-image__error, .el-image__placeholder{
background: none;
}
/deep/ .el-image-viewer__wrapper{
top: 55px;
}
</style>

View File

@ -1,18 +1,17 @@
<template>
<!--上传图片-->
<el-dialog :visible.sync="dialog" :close-on-click-modal="false" title="七牛云配置" append-to-body width="580px">
<el-form ref="form" :model="form" :rules="rules" style="margin-top: 6px;" size="small" label-width="110px">
<el-form-item label="Access Key" prop="accessKey">
<el-input v-model="form.accessKey" style="width: 95%" placeholder="accessKey在安全中心秘钥管理中查看"/>
<el-input v-model="form.accessKey" style="width: 95%" placeholder="accessKey在安全中心秘钥管理中查看" />
</el-form-item>
<el-form-item label="Secret Key" prop="secretKey">
<el-input v-model="form.secretKey" type="password" style="width: 95%;" placeholder="secretKey在安全中心秘钥管理中查看"/>
<el-input v-model="form.secretKey" type="password" style="width: 95%;" placeholder="secretKey在安全中心秘钥管理中查看" />
</el-form-item>
<el-form-item label="空间名称" prop="bucket">
<el-input v-model="form.bucket" style="width: 95%;" placeholder="存储空间名称作为唯一的 Bucket 识别符"/>
<el-input v-model="form.bucket" style="width: 95%;" placeholder="存储空间名称作为唯一的 Bucket 识别符" />
</el-form-item>
<el-form-item label="外链域名" prop="host">
<el-input v-model="form.host" style="width: 95%;" placeholder = "外链域名,可自定义,需在七牛云绑定"/>
<el-input v-model="form.host" style="width: 95%;" placeholder="外链域名,可自定义,需在七牛云绑定" />
</el-form-item>
<el-form-item label="存储区域" prop="port">
<el-select v-model="form.zone" placeholder="请选择存储区域">
@ -20,12 +19,13 @@
v-for="item in zones"
:key="item"
:label="item"
:value="item"/>
:value="item"
/>
</el-select>
</el-form-item>
<el-form-item label="空间类型" prop="host">
<el-radio v-model="form.type" label="公开">公开</el-radio>
<el-radio v-model="form.type" label="私有" >私有</el-radio>
<el-radio v-model="form.type" label="私有">私有</el-radio>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
@ -36,7 +36,7 @@
</template>
<script>
import { get, update } from '@/api/qiniu'
import { get, update } from '@/api/tools/qiniu'
export default {
data() {
return {
@ -77,7 +77,7 @@ export default {
type: 'success',
duration: 2500
})
this.$parent.init()
this.$parent.crud.toQuery()
this.loading = false
this.dialog = false
}).catch(err => {

View File

@ -1,38 +1,41 @@
<template>
<div class="app-container" style="padding: 8px;">
<!--表单组件-->
<eForm ref="form"/>
<eForm ref="form" />
<!-- 工具栏 -->
<div class="head-container">
<!-- 搜索 -->
<el-input v-model="query.value" clearable placeholder="输入文件名称搜索" style="width: 200px;" class="filter-item" @keyup.enter.native="toQuery"/>
<el-button class="filter-item" size="mini" type="success" icon="el-icon-search" @click="toQuery">搜索</el-button>
<!-- 上传 -->
<div style="display: inline-block;margin: 0px 2px;">
<el-button class="filter-item" size="mini" type="primary" icon="el-icon-upload" @click="dialog = true">上传文件</el-button>
</div>
<!-- 同步 -->
<el-button :icon="icon" class="filter-item" size="mini" type="warning" @click="synchronize">同步数据</el-button>
<!-- 配置 -->
<div style="display: inline-block;margin: 0px 2px;">
<el-button
class="filter-item"
size="mini"
type="success"
icon="el-icon-s-tools"
@click="doConfig">七牛配置</el-button>
</div>
<!-- 多选删除 -->
<div style="display: inline-block;margin: 0px 2px;">
<el-button
:loading="delAllLoading"
:disabled="data.length === 0 || $refs.table.selection.length === 0"
class="filter-item"
size="mini"
type="danger"
icon="el-icon-delete"
@click="open">删除</el-button>
<div v-if="crud.props.searchToggle">
<!-- 搜索 -->
<el-input v-model="query.key" clearable size="small" placeholder="输入文件名称搜索" style="width: 200px;" class="filter-item" @keyup.enter.native="toQuery" />
<el-date-picker
v-model="query.c"
:default-time="['00:00:00','23:59:59']"
type="daterange"
range-separator=":"
size="small"
class="date-item"
value-format="yyyy-MM-dd HH:mm:ss"
start-placeholder="开始日期"
end-placeholder="结束日期"
/>
<rrOperation :crud="crud" />
</div>
<crudOperation :permission="permission">
<template slot="left">
<!-- 上传 -->
<el-button class="filter-item" size="mini" type="primary" icon="el-icon-upload" @click="dialog = true">上传</el-button>
<!-- 同步 -->
<el-button :icon="icon" class="filter-item" size="mini" type="warning" @click="synchronize">同步</el-button>
<!-- 配置 -->
<el-button
class="filter-item"
size="mini"
type="success"
icon="el-icon-s-tools"
@click="doConfig"
>配置</el-button>
</template>
</crudOperation>
<!-- 文件上传 -->
<el-dialog :visible.sync="dialog" :close-on-click-modal="false" append-to-body width="500px" @close="doSubmit">
<el-upload
@ -43,7 +46,8 @@
:headers="headers"
:action="qiNiuUploadApi"
class="upload-demo"
multiple>
multiple
>
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" style="display: block;" class="el-upload__tip">请勿上传违法文件且文件不超过15M</div>
</el-upload>
@ -52,66 +56,53 @@
</div>
</el-dialog>
<!--表格渲染-->
<el-table v-loading="loading" ref="table" :data="data" size="small" style="width: 100%;">
<el-table-column type="selection" width="55"/>
<el-table-column :show-overflow-tooltip="true" label="文件名">
<el-table ref="table" v-loading="crud.loading" :data="crud.data" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
<el-table-column type="selection" width="55" />
<el-table-column v-if="columns.visible('name')" prop="name" :show-overflow-tooltip="true" label="文件名">
<template slot-scope="scope">
<a href="JavaScript:;" class="el-link el-link--primary" target="_blank" type="primary" @click="download(scope.row.id)">{{ scope.row.key }}</a>
<a href="JavaScript:" class="el-link el-link--primary" target="_blank" type="primary" @click="download(scope.row.id)">{{ scope.row.key }}</a>
</template>
</el-table-column>
<el-table-column :show-overflow-tooltip="true" prop="suffix" label="文件类型"/>
<el-table-column prop="bucket" label="空间名称"/>
<el-table-column prop="size" label="文件大小"/>
<el-table-column prop="type" label="空间类型"/>
<el-table-column width="180px" prop="updateTime" label="创建日期">
<el-table-column v-if="columns.visible('suffix')" :show-overflow-tooltip="true" prop="suffix" label="文件类型" @selection-change="crud.selectionChangeHandler" />
<el-table-column v-if="columns.visible('bucket')" prop="bucket" label="空间名称" />
<el-table-column v-if="columns.visible('size')" prop="size" label="文件大小" />
<el-table-column v-if="columns.visible('type')" prop="type" label="空间类型" />
<el-table-column v-if="columns.visible('updateTime')" prop="updateTime" label="创建日期">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.updateTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" width="100px" align="center" fixed="right">
<template slot-scope="scope">
<el-popover
:ref="scope.row.id"
placement="top"
width="180">
<p>确定删除本条数据吗</p>
<div style="text-align: right; margin: 0">
<el-button size="mini" type="text" @click="$refs[scope.row.id].doClose()">取消</el-button>
<el-button :loading="delLoading" type="primary" size="mini" @click="subDelete(scope.row.id)">确定</el-button>
</div>
<el-button slot="reference" type="danger" icon="el-icon-delete" size="mini"/>
</el-popover>
</template>
</el-table-column>
</el-table>
<!--分页组件-->
<el-pagination
:total="total"
:current-page="page + 1"
style="margin-top: 8px;"
layout="total, prev, pager, next, sizes"
@size-change="sizeChange"
@current-change="pageChange"/>
<pagination />
</div>
</div>
</template>
<script>
import initData from '@/mixins/initData'
import { del, download, sync, delAll } from '@/api/qiniu'
import { parseTime } from '@/utils/index'
import crudQiNiu from '@/api/tools/qiniu'
import { mapGetters } from 'vuex'
import { getToken } from '@/utils/auth'
import eForm from './form'
import CRUD, { presenter, header, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import pagination from '@crud/Pagination'
// crud交由presenter持有
const defaultCrud = CRUD({ title: '七牛云文件', url: 'api/qiNiuContent', crudMethod: { ...crudQiNiu }})
export default {
components: { eForm },
mixins: [initData],
components: { eForm, pagination, crudOperation, rrOperation },
mixins: [presenter(defaultCrud), header(), crud()],
data() {
return {
icon: 'el-icon-refresh', delAllLoading: false,
url: '', headers: { 'Authorization': 'Bearer ' + getToken() }, dialog: false,
dialogImageUrl: '', dialogVisible: false, fileList: [], files: [],
newWin: null, downloadLoading: false, delLoading: false
permission: {
del: ['admin', 'storage:del']
},
title: '文件', dialog: false,
icon: 'el-icon-refresh',
url: '', headers: { 'Authorization': getToken() },
dialogImageUrl: '', dialogVisible: false, fileList: [], files: [], newWin: null
}
},
computed: {
@ -130,51 +121,17 @@ export default {
}
}
},
created() {
this.crud.optShow.add = false
this.crud.optShow.edit = false
},
methods: {
parseTime,
beforeInit() {
this.url = 'api/qiNiuContent'
const sort = 'id,desc'
const query = this.query
const value = query.value
this.params = { page: this.page, size: this.size, sort: sort }
if (value) { this.params['key'] = value }
return true
},
// 七牛云配置
doConfig() {
const _this = this.$refs.form
_this.init()
_this.dialog = true
},
subDelete(id) {
this.delLoading = true
del(id).then(res => {
this.delLoading = false
this.$refs[id].doClose()
this.init()
this.$notify({
title: '删除成功',
type: 'success',
duration: 2500
})
}).catch(err => {
this.delLoading = false
this.$refs[id].doClose()
console.log(err.response.data.message)
})
},
download(id) {
this.downloadLoading = true
// 先打开一个空的新窗口,再请求
this.newWin = window.open()
download(id).then(res => {
this.downloadLoading = false
this.url = res.url
}).catch(err => {
this.downloadLoading = false
console.log(err.response.data.message)
})
},
handleSuccess(response, file, fileList) {
const uid = file.uid
const id = response.id
@ -183,7 +140,7 @@ export default {
handleBeforeRemove(file, fileList) {
for (let i = 0; i < this.files.length; i++) {
if (this.files[i].uid === file.uid) {
del(this.files[i].id).then(res => {})
crudQiNiu.del([this.files[i].id]).then(res => {})
return true
}
}
@ -198,65 +155,42 @@ export default {
this.dialogVisible = false
this.dialogImageUrl = ''
this.dialog = false
this.init()
this.crud.toQuery()
},
// 监听上传失败
handleError(e, file, fileList) {
const msg = JSON.parse(e.message)
this.$notify({
title: msg.message,
type: 'error',
duration: 2500
this.crud.notify(msg.message, CRUD.NOTIFICATION_TYPE.ERROR)
},
// 下载文件
download(id) {
this.downloadLoading = true
// 先打开一个空的新窗口,再请求
this.newWin = window.open()
crudQiNiu.download(id).then(res => {
this.downloadLoading = false
this.url = res.url
}).catch(err => {
this.downloadLoading = false
console.log(err.response.data.message)
})
},
// 同步数据
synchronize() {
this.icon = 'el-icon-loading'
this.buttonName = '同步中'
sync().then(res => {
crudQiNiu.sync().then(res => {
this.icon = 'el-icon-refresh'
this.buttonName = '同步数据'
this.$message({
showClose: true,
message: '数据同步成功',
type: 'success',
duration: 1500
})
this.toQuery()
this.crud.toQuery()
}).catch(err => {
this.icon = 'el-icon-refresh'
this.buttonName = '同步数据'
console.log(err.response.data.message)
})
},
doDelete() {
this.delAllLoading = true
const data = this.$refs.table.selection
const ids = []
for (let i = 0; i < data.length; i++) {
ids.push(data[i].id)
}
delAll(ids).then(res => {
this.delAllLoading = false
this.dleChangePage(ids.length)
this.init()
this.$notify({
title: '删除成功',
type: 'success',
duration: 2500
})
}).catch(err => {
this.delAllLoading = false
console.log(err.response.data.message)
})
},
open() {
this.$confirm('你确定删除选中的数据吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.doDelete()
})
}
}
}

View File

@ -1,9 +1,9 @@
<template>
<elFrame :src="swaggerApi"/>
<elFrame :src="swaggerApi" />
</template>
<script>
import { mapGetters } from 'vuex'
import elFrame from '@/components/iframe/index'
import elFrame from '@/components/Iframe/index'
export default {
name: 'Swagger',
components: { elFrame },