Commit 03b9ce17 authored by wangwei's avatar wangwei

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

parents 49c0c0e1 88e27f55
...@@ -54,6 +54,8 @@ ...@@ -54,6 +54,8 @@
<div class="menu_form_hd flex-bt"> <div class="menu_form_hd flex-bt">
<h4 class="global_info"> {{selectedItem && selectedItem.name}} </h4> <h4 class="global_info"> {{selectedItem && selectedItem.name}} </h4>
<div class="global_extra"> <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> </div>
<div class="menu_form_bd" id="view"> <div class="menu_form_bd" id="view">
...@@ -119,6 +121,7 @@ ...@@ -119,6 +121,7 @@
<script> <script>
import {getPublicMenuApi, savePublicMenuApi} from "../../service/api"; import {getPublicMenuApi, savePublicMenuApi} from "../../service/api";
import { MessageBox } from 'element-ui';
export default { export default {
name: "index", name: "index",
data(){ data(){
...@@ -182,25 +185,39 @@ ...@@ -182,25 +185,39 @@
getPublicMenuApi().then(res=> { getPublicMenuApi().then(res=> {
if (res.menu && res.menu.button) { if (res.menu && res.menu.button) {
this.buttonList = res.menu.button this.buttonList = res.menu.button
let selectedMenu = this.buttonList[this.selectedIndex]
let subButton = selectedMenu.sub_button
this.selectedItem = { this.selectedItem = {
name: '', name: '子菜单名',
sub_button: [], sub_button: [],
type: 'view', type: 'view',
url: '' url: ''
} }
subButton.push(this.selectedItem) this.buttonList[this.selectedIndex].sub_button.push(this.selectedItem)
this.selectedChildIndex = subButton.length - 1 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(){ onAddMenu(){
getPublicMenuApi().then(res=> { getPublicMenuApi().then(res=> {
if (res.menu && res.menu.button) { if (res.menu && res.menu.button) {
this.buttonList = res.menu.button this.buttonList = res.menu.button
this.selectedItem = { this.selectedItem = {
name: '', name: '菜单名',
sub_button: [], sub_button: [],
type: 'view', type: 'view',
url: '' url: ''
...@@ -211,6 +228,26 @@ ...@@ -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){ onTypeChange(val){
console.log('onTypeChange', val) console.log('onTypeChange', val)
}, },
...@@ -226,11 +263,19 @@ ...@@ -226,11 +263,19 @@
buttons: JSON.stringify(buttonList) buttons: JSON.stringify(buttonList)
} }
savePublicMenuApi(json).then(res=>{ savePublicMenuApi(json).then(res=>{
this.$message({ if (res.errcode === 0){
type: 'success', this.$message({
message: '保存成功!' type: 'success',
}); message: '保存成功!'
this.getMenu(); });
this.getMenu();
} else {
MessageBox({
title:'错误!',
message:res.errmsg,
type:'error',
})
}
}) })
} }
......
...@@ -10,27 +10,31 @@ ...@@ -10,27 +10,31 @@
<li class="media-nav js_top" :class="type === 'image' ? 'media-current-nav' : ''" @click="getMediaType('image')"> <li class="media-nav js_top" :class="type === 'image' ? 'media-current-nav' : ''" @click="getMediaType('image')">
<a href="javascript:void(0);">图片<br /></a> <a href="javascript:void(0);">图片<br /></a>
</li> </li>
<!--<li class="media-nav js_top" :class="type === 'audio' ? 'media-current-nav' : ''" @click="getMediaType('audio')">--> <li class="media-nav js_top" :class="type === 'voice' ? 'media-current-nav' : ''" @click="getMediaType('voice')">
<!--<a href="javascript:void(0);">语音<br /></a>--> <a href="javascript:void(0);">语音<br /></a>
<!--</li>--> </li>
<!--<li class="media-nav js_top" :class="type === 'video' ? 'media-current-nav' : ''" @click="getMediaType('video')">--> <li class="media-nav js_top" :class="type === 'video' ? 'media-current-nav' : ''" @click="getMediaType('video')">
<!--<a href="javascript:void(0);">视频<br /></a>--> <a href="javascript:void(0);">视频<br /></a>
<!--</li>--> </li>
<!----> <!---->
</ul> </ul>
<div class="media-panel"> <div class="media-panel">
<div class="media-panel-top flex-bt"> <div class="media-panel-top flex-bt">
<div class="media-panel-top-left"> <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>
<div class="media-panel-top-right"> <div class="media-panel-top-right">
<el-upload <el-upload
class="upload-demo" class="upload-demo"
ref="upload" ref="upload"
action="/api/public/upload" action="/api/public/upload/zone"
:http-request="uploadFile"
:show-file-list="false" :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> <el-button style="order:2;" slot="trigger" size="small" type="primary">选取文件</el-button>
<!--<div slot="tip" class="el-upload__tip">大小不超过5M</div>--> <!--<div slot="tip" class="el-upload__tip">大小不超过5M</div>-->
</el-upload> </el-upload>
...@@ -50,10 +54,18 @@ ...@@ -50,10 +54,18 @@
</el-table-column> </el-table-column>
<el-table-column <el-table-column
label="URL"> label="URL">
<template slot-scope="scope" v-if="type === 'image'"> <template slot-scope="scope">
<a :href="scope.row.url"> <a :href="scope.row.url" v-if="type === 'image'">
<img style="width: 60px;" :src="scope.row.url"/> <img style="width: 60px;" :src="scope.row.url"/>
</a> </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> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
...@@ -65,26 +77,47 @@ ...@@ -65,26 +77,47 @@
</template> </template>
<script> <script>
import {getMediaListApi} from "../../service/api"; import {getMediaListApi,uploadFileApi} from "../../service/api";
import page from '../framework/page'
export default { export default {
name: "weChatResource", name: "resource",
data() { data() {
return { return {
mediaList: [], mediaList: [],
nowPage: 0, nowPage: 1,
total: 0, total: 0,
loading: false, loading: false,
type: 'image', type: 'image',
imageList: [] imageList: [],
uploadParam: {
type: 'wechat',
chunk: 0,
count: 1
},
fileUid:null,
showProgress: false,
typeText: {
'image' : '图片',
'video' : '视频',
'voice' : '语音'
}
} }
}, },
components:{
page
},
mounted(){ mounted(){
this.getMediaList(this.type) 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: { methods: {
getMediaType(type){ getMediaType(type){
this.type = type; this.type = type;
this.nowPage = 0; this.nowPage = 1;
this.getMediaList(type); this.getMediaList(type);
}, },
getMediaList(type){ getMediaList(type){
...@@ -109,15 +142,38 @@ ...@@ -109,15 +142,38 @@
}) })
}, },
handleUploadSuccess(res) { handleUploadSuccess(res) {
console.log('handleUploadSuccess', res)
if (res.code === 200) { if (res.code === 200) {
this.imageList = [{name:res.data.url,url:process.env.IMAGE_URL_HEAD + res.data.url}] 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> </script>
<style scoped lang="less"> <style scoped lang="less">
.progress {
width: 50%;
}
.flex-bt { .flex-bt {
display: flex; display: flex;
justify-content: space-between; 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