Commit 03b9ce17 authored by wangwei's avatar wangwei

Merge remote-tracking branch 'origin/development' into development

parents 49c0c0e1 88e27f55
......@@ -54,6 +54,8 @@
<div class="menu_form_hd flex-bt">
<h4 class="global_info"> {{selectedItem && selectedItem.name}} </h4>
<div class="global_extra">
<a v-if="selectedChildIndex === -1" href="javascript:void(0);" @click="delMenu">删除菜单</a>
<a v-else href="javascript:void(0);" @click="delSubMenu">删除子菜单</a>
</div>
</div>
<div class="menu_form_bd" id="view">
......@@ -119,6 +121,7 @@
<script>
import {getPublicMenuApi, savePublicMenuApi} from "../../service/api";
import { MessageBox } from 'element-ui';
export default {
name: "index",
data(){
......@@ -182,25 +185,39 @@
getPublicMenuApi().then(res=> {
if (res.menu && res.menu.button) {
this.buttonList = res.menu.button
let selectedMenu = this.buttonList[this.selectedIndex]
let subButton = selectedMenu.sub_button
this.selectedItem = {
name: '',
name: '子菜单名',
sub_button: [],
type: 'view',
url: ''
}
subButton.push(this.selectedItem)
this.selectedChildIndex = subButton.length - 1
this.buttonList[this.selectedIndex].sub_button.push(this.selectedItem)
this.selectedChildIndex = this.buttonList[this.selectedIndex].sub_button.length - 1
}
})
},
delSubMenu(){
this.$confirm('此操作将删除该子菜单?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
getPublicMenuApi().then(res => {
if (res.menu && res.menu.button) {
this.buttonList = res.menu.button
this.buttonList[this.selectedIndex].sub_button.splice(this.selectedChildIndex, 1)
this.selectedChildIndex = this.buttonList[this.selectedIndex].sub_button.length - 1
this.selectedItem = this.selectedChildIndex > -1 ? this.buttonList[this.selectedIndex][this.selectedChildIndex] : this.buttonList[this.selectedIndex]
}
});
});
},
onAddMenu(){
getPublicMenuApi().then(res=> {
if (res.menu && res.menu.button) {
this.buttonList = res.menu.button
this.selectedItem = {
name: '',
name: '菜单名',
sub_button: [],
type: 'view',
url: ''
......@@ -211,6 +228,26 @@
}
})
},
delMenu(){
this.$confirm('此操作将删除该菜单?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
getPublicMenuApi().then(res=> {
if (res.menu && res.menu.button) {
this.buttonList = res.menu.button
this.buttonList.splice(this.selectedIndex,1)
this.selectedItem = this.buttonList.length > 0 ? this.buttonList[0] : {
name: '菜单名',
sub_button: [],
type: 'view',
url: ''}
this.selectedChildIndex = -1
}
})
});
},
onTypeChange(val){
console.log('onTypeChange', val)
},
......@@ -226,11 +263,19 @@
buttons: JSON.stringify(buttonList)
}
savePublicMenuApi(json).then(res=>{
this.$message({
type: 'success',
message: '保存成功!'
});
this.getMenu();
if (res.errcode === 0){
this.$message({
type: 'success',
message: '保存成功!'
});
this.getMenu();
} else {
MessageBox({
title:'错误!',
message:res.errmsg,
type:'error',
})
}
})
}
......
......@@ -10,27 +10,31 @@
<li class="media-nav js_top" :class="type === 'image' ? 'media-current-nav' : ''" @click="getMediaType('image')">
<a href="javascript:void(0);">图片<br /></a>
</li>
<!--<li class="media-nav js_top" :class="type === 'audio' ? 'media-current-nav' : ''" @click="getMediaType('audio')">-->
<!--<a href="javascript:void(0);">语音<br /></a>-->
<!--</li>-->
<!--<li class="media-nav js_top" :class="type === 'video' ? 'media-current-nav' : ''" @click="getMediaType('video')">-->
<!--<a href="javascript:void(0);">视频<br /></a>-->
<!--</li>-->
<li class="media-nav js_top" :class="type === 'voice' ? 'media-current-nav' : ''" @click="getMediaType('voice')">
<a href="javascript:void(0);">语音<br /></a>
</li>
<li class="media-nav js_top" :class="type === 'video' ? 'media-current-nav' : ''" @click="getMediaType('video')">
<a href="javascript:void(0);">视频<br /></a>
</li>
<!---->
</ul>
<div class="media-panel">
<div class="media-panel-top flex-bt">
<div class="media-panel-top-left">
图片(共{{total}}条)
{{typeText[type]}}(共{{total}}条)
</div>
<div class="progress" v-if="showProgress">
<el-progress :percentage="progress" status="success"></el-progress>
</div>
<div class="media-panel-top-right">
<el-upload
class="upload-demo"
ref="upload"
action="/api/public/upload"
action="/api/public/upload/zone"
:http-request="uploadFile"
:show-file-list="false"
:on-success="handleUploadSuccess"
>
:data="uploadParam">
<!--:on-success="handleUploadSuccess"-->
<el-button style="order:2;" slot="trigger" size="small" type="primary">选取文件</el-button>
<!--<div slot="tip" class="el-upload__tip">大小不超过5M</div>-->
</el-upload>
......@@ -50,10 +54,18 @@
</el-table-column>
<el-table-column
label="URL">
<template slot-scope="scope" v-if="type === 'image'">
<a :href="scope.row.url">
<template slot-scope="scope">
<a :href="scope.row.url" v-if="type === 'image'">
<img style="width: 60px;" :src="scope.row.url"/>
</a>
<video v-if="type === 'video'" width="100" height="100" controls="controls">
<source :src="scope.row.url"/>
Your browser does not support the video tag.
</video>
<audio v-if="type === 'voice'" id="myAudio" controls>
<source :src="scope.row.url"/>
Your browser does not support the audio element.
</audio>
</template>
</el-table-column>
</el-table>
......@@ -65,26 +77,47 @@
</template>
<script>
import {getMediaListApi} from "../../service/api";
import {getMediaListApi,uploadFileApi} from "../../service/api";
import page from '../framework/page'
export default {
name: "weChatResource",
name: "resource",
data() {
return {
mediaList: [],
nowPage: 0,
nowPage: 1,
total: 0,
loading: false,
type: 'image',
imageList: []
imageList: [],
uploadParam: {
type: 'wechat',
chunk: 0,
count: 1
},
fileUid:null,
showProgress: false,
typeText: {
'image' : '图片',
'video' : '视频',
'voice' : '语音'
}
}
},
components:{
page
},
mounted(){
this.getMediaList(this.type)
},
computed:{
progress(){
return this.$store.state.progressList.find(i=>{return i.id === this.fileUid}).num <100 ? this.$store.state.progressList.find(i=>{return i.id === this.fileUid}).num : 100
}
},
methods: {
getMediaType(type){
this.type = type;
this.nowPage = 0;
this.nowPage = 1;
this.getMediaList(type);
},
getMediaList(type){
......@@ -109,15 +142,38 @@
})
},
handleUploadSuccess(res) {
console.log('handleUploadSuccess', res)
if (res.code === 200) {
this.imageList = [{name:res.data.url,url:process.env.IMAGE_URL_HEAD + res.data.url}]
}
},
uploadFile(a) {
this.loading = true;
this.$store.dispatch('setProgress',{type:'new',id:a.file.uid});
this.fileUid = a.file.uid;
this.showProgress = true;
uploadFileApi({file:a.file,type:'wechat'}).then(res=>{
this.imageList = [{name:res.url,url:process.env.IMAGE_URL_HEAD + res.url}]
this.getMediaList(this.type)
this.loading = false;
this.showProgress = false;
this.$message({
type: 'success',
message: '上传成功!'
});
}).catch(()=>{
this.loading = false;
this.showProgress = false;
})
}
}
}
</script>
<style scoped lang="less">
.progress {
width: 50%;
}
.flex-bt {
display: flex;
justify-content: space-between;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment