提交 97a02ce7 authored 作者: 翟畅's avatar 翟畅

zc添加下载服务模块

上级 cbe5d954
......@@ -48,4 +48,13 @@ export function deleteCheckAPI(params) { //图书预览详情
method: 'get',
params
})
}
//文件删除
export function deleteFileAPI(data) {
return request({
url: `${requestPath.file}delete`,
method: 'post',
data
})
}
\ No newline at end of file
import request from '@/utils/request1'
import { requestPath } from '@/utils/global.js'
export function contactListAPI(params) { //联系信息列表
return request({
url: `${requestPath.common}/download/page`,
method: 'GET',
params
})
}
export function contactDeleteAPI(oid) { //删除
return request({
url: `${requestPath.common}/download/delete/${oid}`,
method: 'post',
})
}
export function contactSaveAPI(data) { //保存
return request({
url: `${requestPath.common}/download/save`,
method: 'post',
data
})
}
export function contactDetailAPI(oid) { //联系信息详情
return request({
url: `${requestPath.common}/download/${oid}`,
method: 'get'
})
}
export function contactMaxOrderNumAPI(params) { //查询最大排序号
return request({
url: `${requestPath.common}/download/maxOrderNum`,
method: 'get',
params
})
}
\ No newline at end of file
......@@ -120,6 +120,30 @@ const marketManageRouter = {
},
hidden: true
},
{
path: 'down_module',
component: () => import('@/views/marketing_manage/down_module/index'),
name: 'down_module',
meta: { title: '下载服务'}
},
{
path: 'createDown',
component: () => import('@/views/marketing_manage/down_module/create'),
name: 'createDown',
meta: {
title: '新建下载资源',noCache: true, activeMenu: `/marketing_manage/down_module`
},
hidden: true
},
{
path: 'editDown',
component: () => import('@/views/marketing_manage/down_module/edit'),
name: 'editDown',
meta: {
title: '编辑下载资源',noCache: true, activeMenu: `/marketing_manage/down_module`
},
hidden: true
},
]
}
......
......@@ -6,7 +6,7 @@
<div class="content">
<div class="left">
<div class="header">
<img :src="`${uploadUrl}?fileName=${data.userImg}&isOnLine=true`" v-if="data.userImg" class="avatar" >
<img :src="`${fileUrl}?fileName=${data.userImg}&isOnLine=true`" v-if="data.userImg" class="avatar" >
<img src="../../../assets/img/default.png" v-else>
</div>
<div class="name">{{data.userName}}</div>
......@@ -97,7 +97,7 @@
<script>
import Tinymce from '@/components/Tinymce'
import { uploadUrl, uploadPath, requestPath } from '@/utils/global.js'
import { fileUrl, uploadPath, requestPath } from '@/utils/global.js'
import queryString from 'query-string'
import { detailsAPI, setStatusAPI, deleteAPI, replayAPI, replayCheck } from '@/api/society-manage/resource'
import { requestMsg, confirm } from '@/utils/publicFunctions'
......@@ -130,7 +130,7 @@ export default {
}
},
created(){
this.uploadUrl = uploadUrl
this.uploadUrl = fileUrl
this.uploadPath = uploadPath
},
mounted() {
......
<template>
<div class="divBox" id="book_create">
<el-card class="box-card">
<div class="module_content">
<div class="back_box" @click="goBack()" v-if="this.$route.query.type=='view'">
<img src="@/assets/img/common/back.png"><span>返回</span>
</div>
<div class="resource_title" style="padding-left:40px;">
<img src="@/assets/img/common/basic.png">基本信息
</div>
<el-form :model="dataForm" :rules="rules" ref="dataForm" label-width="140px">
<el-form-item label="书目名称:" prop="name">
<el-input v-model="dataForm.name" style="width:40%;"></el-input>
</el-form-item>
<el-form-item label="图片:" prop="cover" ref="cover">
<div class="upload_resource">
<img :src="coverUrl(dataForm.cover)" class="box_showdow" @error="errImg('special')" v-if="dataForm.cover">
<img :src="defaultImg('special')" v-else>
</div>
<div style="float:left">
<el-upload :action="`${fileUrl}upload`" :show-file-list="false"
:on-success="handleCoverSuccess" :before-upload="beforeCoverUpload">
<div class="upload_btn">上传图片</div>
</el-upload>
<div class="upload_reset" @click="dataForm.cover = null">重置</div>
<!-- <div class="line_tip">建议尺寸286*390,仅支持jpg、jpeg、png、gif、bmp格式,不超过2M</div> -->
</div>
</el-form-item>
<el-form-item label="书目文件:">
<el-upload :action="`${fileUrl}upload`" :show-file-list="false"
:on-success="handleSuccess" :on-error="handleError" :before-upload="beforeUpload" style="display:inline-block;">
<el-button size="small" type="primary" :disabled="loading" :loading='loading'>上传文件</el-button>
</el-upload>
<span class="pdfTip upload_pdf_name" :class="dataForm.fileName?'pointer':''" @click="reviewPDF(dataForm.file)">{{dataForm.fileName?dataForm.fileName:loading?'上传中':'未上传文件!'}}</span>
<span class="deleteBtn" v-if="dataForm.fileName" @click="deleteFile()"><i class="el-icon-delete"></i></span>
<!-- <div>
<el-button class="clear_btn" size="small" v-if="dataForm.fileName" @click="clearPdf"></el-button>
</div> -->
</el-form-item>
<el-form-item label="资料大小:" prop="size">
<el-input v-model="dataForm.size" style="width:40%;"></el-input>
</el-form-item>
<el-form-item label="排序号:" prop="sort">
<el-input v-model="dataForm.sort" style="width:40%;"></el-input>
</el-form-item>
<el-form-item label="资料类型:" prop="resourceType">
<el-select clearable placeholder="资料类型" v-model="dataForm.resourceType" style="width:40%;">
<el-option v-for="(item,index) in columnList" :key="index" :label="item.name" :value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="备注:" prop="content">
<el-input type="textarea" :autosize="{ minRows: 2, maxRows: 4}" v-model="dataForm.content" style="width:40%;"></el-input>
</el-form-item>
</el-form>
</div>
<div class="footer_fixed">
<el-button @click="goBack()" size="small">取消</el-button>
<el-button v-if="!viewFlag" @click="dataSubmit" type="primary" :disabled="sending" :loading="sending" size="small">保存</el-button>
</div>
</el-card>
</div>
</template>
<script>
import { contactListAPI, contactDeleteAPI, contactSaveAPI, contactDetailAPI, contactMaxOrderNumAPI } from "@/api/marketing/down";
import { fileUrl, baseUrl } from '@/utils/global'
import { deleteFileAPI } from '@/api/common'
import { confirm } from "@/utils/function";
import { formatSort } from '@/utils/format'
import { valValidate, isbnValidate, fontValidate } from '@/utils/validate'
import store from '@/store'
export default {
name:'createDown',
components:{
},
data() {
return {
baseUrl,
loading:false,
viewFlag: false,
fileUrl,
dataForm:{
sort: null,
size: null,
name: null,
resourceType: '1',
id: null,
file:null,
fileName:null,
cover: null,
content:null,
},
columnList:[
{ name:'图书资源', id:'1'},
{ name:'书目', id:'2'},
{ name:'MAC数据', id:'3'},
],
value:null,
rules: {
name:[
{ required: true , message: '请输入书目名称' },
],
sort:[
{ required: true , message: '请输入排序号' },
],
},
sending: false,
sortList: [],
options: [],
dialogVisible: false,
listLoading: false,
}
},
created() {
this.viewFlag = this.$route.query.type == 'view'
},
mounted() {
if(this.$route.query.editId){//修改功能
this.dataForm.id = this.$route.query.editId
this.getDet()
}else{
this.dataForm.id = null
this.getMaxSort()
}
},
deactivated(){ // keep-alive生命周期 被keep-alive缓存的组件停用时调用
if(!this.$store.state.tagsView.lockViews.find(item=>item==this.$options.name)){ // 当前缓存组件不在被缓存列表中时进行销毁
this.$destroy(this.$options.name)
}
},
methods: {
handleCoverSuccess(response, file) { //封面上传成功
this.dataForm.cover = response
},
beforeCoverUpload(file) { //图片限制
const isFile = file.type == 'image/jpeg' || file.type == 'image/jpg' || file.type == 'image/png' || file.type == 'image/bmp' || file.type == 'image/gif'
const isLimit = file.size / 1024 / 1024 < 2;
if (!isFile) {
this.$message.error('上传图片仅支持jpg、jpeg、png、gif、bmp格式!');
}else if (!isLimit) {
this.$message.error('上传图片大小不能超过2MB!');
}
return isFile && isLimit;
},
handleSuccess(response, file) { //资源上传成功
console.log(response,file,'00000')
this.loading = false
this.$message.success('上传成功')
this.dataForm.file = response;
this.dataForm.fileName = file.name
},
handleError(){
this.loading = false
this.$message.error('文件上传失败');
},
beforeUpload(file) {
this.loading = true
},
reviewPDF(fileName){
window.open(this.fileUrl + '?fileName=' + fileName + '&isOnLine=true')
},
deleteFile(){
let fileName = [this.dataForm.file]
confirm.apply(this, ["确认删除该文件吗?"]).then(() => {
deleteFileAPI(fileName).then((res) => {
if(res.data.code == 0){
this.$message.success('删除成功')
this.dataForm.file = ''
this.dataForm.fileName = ''
}
})
});
},
goBack(){
let view = this.$route
this.$store.dispatch('tagsView/delView', view)
if(this.viewFlag){
this.$router.replace({path:this.$route.query.path,query:{id:this.$route.query.id}})
}else{
this.$router.replace({path:this.$route.meta.activeMenu})
}
},
getDet() { //图书详情
contactDetailAPI(this.dataForm.id).then(res =>{
if(res.data.code === 0) {
this.dataForm = res.data.data
} else {
this.$message.error('数据加载失败');
}
})
},
getMaxSort() { //获取最大排序号
contactMaxOrderNumAPI().then(res => {
res.data.code === 0 ? this.dataForm.sort = res.data.data : this.$message.error('获取失败')
})
},
dataSubmit() { //添加联系信息
this.sending = true
this.$refs['dataForm'].validate((valid) => {
if (valid) {
contactSaveAPI(this.dataForm).then(res =>{
if (res.data.code === 0) {
this.$message.success('保存成功');
this.goBack()
} else {
this.$message.error(res.data.msg);
this.sending = false
}
})
} else {
this.$message.warning("有未通过的验证");
this.sending = false
}
})
},
handleCoverSuccess(response, file) { //封面上传成功
this.dataForm.cover = response
},
beforeCoverUpload(file) { //图片限制
const isFile = file.type == 'image/jpeg' || file.type == 'image/jpg' || file.type == 'image/png' || file.type == 'image/bmp' || file.type == 'image/gif'
const isLimit = file.size / 1024 / 1024 < 2;
if (!isFile) {
this.$message.error('上传图片仅支持jpg、jpeg、png、gif、bmp格式!');
}else if (!isLimit) {
this.$message.error('上传图片大小不能超过2MB!');
}
return isFile && isLimit;
},
},
}
</script>
<style lang="scss" scoped>
@import '@/assets/css/common.scss';
.deleteBtn{
font-size:20px;
cursor:pointer;
display:inline-block;
margin-left:50px;
color:red;
}
.el_tree{
max-height: 400px;
overflow-y: auto;
min-width:420px;
}
.line_tip{
width:205px
}
.el_sel{
width: 30%;
min-width: 400px;
}
.diy_sel{
width:300px;
}
.upload_resource{
width:195px;height:195px;
}
.ueditor_box{
width: 800px;
}
.pointer{
cursor: pointer;
}
// .book_pdf{
// display: flex;
// justify-content: flex-start;
// align-items: center;
// }
.pdfName {
display: inline-block;
min-width: 260px;
height: 25px;
line-height: 25px;
font-size: 12px;
color: #666666;
background: #F5F7FA;
padding-left: 25px;
box-sizing: border-box;
margin-left: 12px;
}
.pdfTip {
// color: #FC5514;
font-size: 14px;
margin-top: 10px;
}
.upload_btn{
float: left;
}
.checkPdfName{
width: 400px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
margin-top: 0;
}
// .pdf_box{
// display: flex;
// justify-content: flex-start;
// }
#book_create .bookLeft, #book_create .bookRight {
float: left;
width: 50%;
}
#book_create .bookTab_box {
width: 800px;
height: 40px;
line-height: 40px;
border: 1px solid #DCDFE6;
border-bottom: none;
background: #F5F7FA;
border-radius: 3px 3px 0px 0px;
box-sizing: border-box;
.tab{
width: 118px;
display: inline-block;
color: #3F4560;
text-align: center;
cursor: pointer;
border-right: 1px solid #DCDFE6;
&:last-child {
border-right: none;
}
}
.hover_tab{
background: #fff;
color: #1F71FF;
font-weight: bold;
}
}
.dialog-footer{
width: 200px;
margin: 0 auto;
display: flex;
justify-content: space-between;
}
/deep/.el-dialog__body{
padding-bottom: 16px;
}
</style>
<style>
.hidden-selection {
display: none !important;
}
</style>
\ No newline at end of file
<template>
<div>
<edit></edit>
</div>
</template>
<script>
import edit from './component'
export default {
name:'createDown',
components:{
edit
}
}
</script>
\ No newline at end of file
<template>
<div>
<edit></edit>
</div>
</template>
<script>
import edit from './component'
export default {
name:'editDown',
components:{
edit
}
}
</script>
\ No newline at end of file
<template>
<div class="divBox currentDivBox">
<el-card class="box-card">
<div slot="header" class="clearfix">
<el-button class="mr10" size="small" type='primary' v-for="(item,index) in topBtn" :key="index" @click="handleBtn(item.url)">{{item.name}}</el-button>
</div>
<!-- 页面检索模块 -->
<el-form inline :model="listQuery" style="float:right;" size="small">
<el-form-item v-for="item in searchBox" :key="item.name" style="margin-bottom:0">
<el-input v-model="listQuery[item.name]" @keyup.enter.native="getList()"
:placeholder="item.placeholder" clearable>
</el-input>
</el-form-item>
<div class="search_btn" @click="getList()">
<img src="@/assets/img/common/ico-sousuo.png">
检索
</div>
</el-form>
<el-table ref="table" class="table_box" v-loading="listLoading" :data="dataList" style="width: 100%" size="mini" highlight-current-row>
<el-table-column prop="name" align="center" label="书目名称" min-width="15%"></el-table-column>
<el-table-column prop="fileName" align="center" label="书目文件名称" min-width="12%"></el-table-column>
<el-table-column prop="resourceType" align="center" label="资料类型" min-width="12%">
<template slot-scope="scope">
<!-- 资源类型 1:图书资源 2:书目 3:MAC数据 -->
<span v-if="scope.row.resourceType == '1'">图书资源</span>
<span v-if="scope.row.resourceType == '2'">书目</span>
<span v-if="scope.row.resourceType == '3'">MAC数据</span>
</template>
</el-table-column>
<el-table-column prop="size" align="center" label="文件大小" min-width="12%"></el-table-column>
<el-table-column prop="sort" align="center" label="排序号" min-width="12%"></el-table-column>
<el-table-column label="操作" min-width="15%" align="center">
<template slot-scope="scope">
<el-button type="text" size="small" v-for="(item,index) in lineBtn" @click="handleBtn(item.url,scope.row.id,scope.row.file)" v-if="(item.url != 'removeLine' || scope.row.status == 0)" :key="index">{{item.name}}</el-button>
</template>
</el-table-column>
</el-table>
<div class="block">
<el-pagination
@size-change="sizeChange"
@current-change="currentChange"
:current-page="listQuery.pageNum"
:page-sizes="[30, 50, 100, 200]"
:page-size="listQuery.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total"
/>
</div>
</el-card>
</div>
</template>
<script>
import { contactListAPI, contactDeleteAPI, contactSaveAPI, contactDetailAPI, contactMaxOrderNumAPI } from "@/api/marketing/down";
import { confirm } from "@/utils/function";
import { deleteFileAPI } from '@/api/common'
import { getSelectionIds } from "@/filters/getIds";
import { pcUrl } from '@/utils/global'
export default {
name: 'down_module',
components: {
},
data() {
return {
topBtn:[],
lineBtn:[],
collapse: false,
classisyFlag:false,
dataList: [],
listQuery: {
pageNum: 1,
pageSize: 50,
orderBy:null,
name:null,
},
searchBox:[{name:'name',placeholder:'请输入书目名称'}],
total: null,
listLoading: false,
value: null,
chooiceList: [],
sortList: [],
inResize: true,
sending: null
}
},
mounted() {
window.addEventListener("click", this.clickOther);
this.getList();
setTimeout(() => {
let list = this.$store.state.btn.btnList;
list.forEach(item => {
if(item.type == 8){
this.topBtn.push(item)
}else if(item.type == 9 ){
this.lineBtn.push(item)
}
})
},0)
console.log(this.topBtn,'this.topBtn')
},
methods: {
clickOther(){
this.classisyFlag = false
this.collapse = false
},
handleBtn(btnName, id, file) {
let status = {
createBtn: () => { //新建
this.createdBook();
},
editLine: () => { //编辑
this.createdBook(id);
},
deleteLine: () => { //删除
this.removeData(id,file);
},
};
status[btnName]();
},
createdBook(id){
if(id){
this.$router.push({path:'/marketing_manage/editDown',query:{editId:id}})
}else{
this.$router.push({path:'/marketing_manage/createDown'})
}
},
sortChanged(column){
this.listQuery.orderBy = column.prop + (column.order == 'descending'?' desc' : '')
this.getList(1)
},
getList(num) {
//列表
this.listLoading = true;
this.listQuery.pageNum = num ? num : this.listQuery.pageNum
contactListAPI(this.listQuery).then(res => {
if (res.data.code === 0) {
this.dataList = res.data.data.list?res.data.data.list:[];
this.total = res.data.data.total?res.data.data.total:0;
} else {
this.$message.error("获取数据失败");
}
this.listLoading = false;
}).catch(res => {
this.listLoading = false
this.$message.error(res.msg)
});
},
removeData(id,fileName) {
//删除数据
let arr = [];
let file = [];
arr.push(id);
file.push(fileName);
confirm.apply(this, ["确定要删除选择的下载资源吗?"]).then(() => {
deleteFileAPI(file)
contactDeleteAPI(arr).then(res => {
if (res.data.code !== 0) {
this.$message.error(res.data.msg);
return;
}
this.$message.success("删除成功");
this.getList();
});
});
},
sizeChange(val) {
this.listQuery.pageSize = val;
this.getList();
},
currentChange(val) {
this.listQuery.pageNum = val;
this.getList();
},
}
}
</script>
<style scoped lang="scss">
@import '@/styles/top_common.scss';
.cover_img{
width: 28px;
height: 38px;
}
.currentDivBox{
/deep/.el-card__header{
border-bottom: 0;
}
}
</style>
<style>
.el-input-group__append, .el-input-group__prepend{
background: #fff !important;
border: none !important;
}
</style>
\ No newline at end of file
......@@ -32,7 +32,7 @@
</template>
<script>
import { contactListAPI, contactDeleteAPI, contactSaveAPI, contactDetailAPI, contactMaxOrderNumAPI } from "@/api/marketing/pirate";
import { contactListAPI, contactDeleteAPI, contactSaveAPI, contactDetailAPI } from "@/api/marketing/pirate";
import { fileUrl, pdfFileUrl, baseUrl } from '@/utils/global'
import { formatSort } from '@/utils/format'
import { valValidate, isbnValidate, fontValidate } from '@/utils/validate'
......@@ -117,11 +117,6 @@ export default {
}
})
},
getMaxSort() { //获取最大排序号
contactMaxOrderNumAPI().then(res => {
res.data.code === 0 ? this.dataForm.sort = res.data.data : this.$message.error('获取失败')
})
},
dataSubmit() { //添加联系信息
this.sending = true
this.$refs['dataForm'].validate((valid) => {
......
......@@ -211,12 +211,11 @@
import { pdfListAPI } from '@/api/resource/pdf'
import { bookSaveAPI, detailsAPI, isbnRepeatAPI } from '@/api/resource/book'
import { sortListAPI, authorLibraryAPI,labelListAPI } from '@/api/common'
import { fileUrl } from '@/utils/global'
import { formatSort } from '@/utils/format'
import { valValidate, isbnValidate, fontValidate } from '@/utils/validate'
import { bookInfoList } from '@/utils/static'
import editAuthor from '@/components/dialog/editAuthor' //作者
import {pdfFileUrl,baseUrl} from '@/utils/global'
import {fileUrl, pdfFileUrl, baseUrl} from '@/utils/global'
import store from '@/store'
export default {
name:'createBook',
......
......@@ -6,7 +6,7 @@
<div class="content">
<div class="left">
<div class="header">
<img :src="`${uploadUrl}?fileName=${data.userImg}&isOnLine=true`" v-if="data.userImg" class="avatar" >
<img :src="`${fileUrl}?fileName=${data.userImg}&isOnLine=true`" v-if="data.userImg" class="avatar" >
<img src="../../../assets/img/default.png" v-else>
</div>
<div class="name">{{data.userName}}</div>
......@@ -97,7 +97,7 @@
<script>
import Tinymce from '@/components/Tinymce'
import { uploadUrl, uploadPath, requestPath } from '@/utils/global.js'
import { fileUrl, uploadPath, requestPath } from '@/utils/global.js'
import queryString from 'query-string'
import { detailsAPI, setStatusAPI, deleteAPI, replayAPI, replayCheck } from '@/api/society-manage/resource'
import { requestMsg, confirm } from '@/utils/publicFunctions'
......@@ -130,7 +130,7 @@ export default {
}
},
created(){
this.uploadUrl = uploadUrl
this.uploadUrl = fileUrl
this.uploadPath = uploadPath
},
mounted() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论