Skip to content

Commit

Permalink
准备封装组件
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo committed Oct 26, 2018
1 parent f067e46 commit 7d9919c
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 28 deletions.
11 changes: 11 additions & 0 deletions src/api/Public/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,14 @@ export function download(AffixID) {
}


export function GetFileList(MasterID) {
return fetch({
url: '/file/list',
method: 'get',
params:{
MasterID
}
})
}


23 changes: 1 addition & 22 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import '@/icons' // icon
import '@/permission' // 权限import axios from 'axios';
// import axios from 'axios'
import '@/styles/index.scss' // global css

import * as filters from './filters' // global filters

Vue.use(ElementUI)
Expand All @@ -23,27 +22,7 @@ new Vue({
router,
store,
render: h => h(App)
})


})


Date.prototype.format = function(format)
{
var o = {
"M+" : this.getMonth()+1, //month
"d+" : this.getDate(), //day
"h+" : this.getHours(), //hour
"m+" : this.getMinutes(), //minute
"s+" : this.getSeconds(), //second
"q+" : Math.floor((this.getMonth()+3)/3), //quarter
"S" : this.getMilliseconds() //millisecond
}
if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
(this.getFullYear()+"").substr(4 - RegExp.$1.length));
for(var k in o)if(new RegExp("("+ k +")").test(format))
format = format.replace(RegExp.$1,
RegExp.$1.length==1 ? o[k] :
("00"+ o[k]).substr((""+ o[k]).length));
return format;
}
10 changes: 10 additions & 0 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,13 @@
return d.getMonth() + 1 + '月' + d.getDate() + '日' + d.getHours() + '时' + d.getMinutes() + '分'
}
}
export function timestampToTime(timestamp) {
var date = new Date(timestamp);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
var Y = date.getFullYear() + '-';
var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
var D = date.getDate() + ' ';
var h = date.getHours() + ':';
var m = date.getMinutes() + ':';
var s = date.getSeconds();
return Y+M+D+h+m+s;
}
67 changes: 61 additions & 6 deletions src/views/Archive/person.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,30 @@
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
</el-upload>
<el-button @click="exportfile()"></el-button>
</el-row>
<el-row>
<el-table :default-sort="{prop: 'name', order: 'descending'}" :data="list" v-loading.body="listLoading" element-loading-text="拼命加载中" border fit highlight-current-row>

<el-table-column label="文件名" prop="filename" sortable align="center">
<template slot-scope="scope">
{{scope.row.filename}}
</template>
</el-table-column>
<el-table-column label="上传时间" prop="timestamp" sortable align="center">
<template slot-scope="scope">
<span>{{timestampToTime(scope.row.timestamp)}}</span>
</template>
</el-table-column>


<el-table-column label="操作" align="center" min-width="110px">
<template slot-scope="scope">
<el-button @click="exportfile(scope.row.id)" type="success" size="small">下载</el-button>

<el-button @click="delete_file(scope.row.id)" type="danger" size="small">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
Expand All @@ -128,7 +152,8 @@ import {
} from "@/api/Archive/person";
import { getToken } from "@/utils/auth";
import Multiselect from "vue-multiselect";
import {download} from '@/api/public/file'
import {download,GetFileList} from '@/api/public/file'
import {timestampToTime} from '@/utils/index'
export default {
//
data() {
Expand All @@ -149,7 +174,7 @@ export default {
SearchValue: ""
},
formData: {
MasterID: "123"
MasterID: ""
},
token: {
auth: getToken()
Expand All @@ -159,7 +184,7 @@ export default {
list: null,
listLoading: true,
RoleID: "",
filelist:null,
temp: null,
defaultProps: {
children: "children",
Expand Down Expand Up @@ -187,8 +212,8 @@ export default {
console.log(this.temp_obj);
});
},
exportfile(){
download("d186a7e6-a038-4874-8234-4d12598e6bac")
exportfile(id){
download(id)
},
handleSizeChange(val) {
this.listQuery.pageSize = val;
Expand Down Expand Up @@ -217,6 +242,15 @@ export default {
this.listLoading = false;
});
},
fetchData_File(id) {
this.listLoading = true;
GetFileList(id).then(response => {
this.filelist = response.data.list;
this.listLoading = false;
});
},
New() {
for (let i in this.temp_obj) {
this.temp_obj[i] = "";
Expand All @@ -236,6 +270,16 @@ export default {
});
});
},
Delete_File(id) {
this.$confirm("确认删除?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.fetchData_File(id)
});
},
Edit(id) {
this.dialogStatus = "update";
Expand All @@ -260,7 +304,18 @@ export default {
this.fetchData(this.listQuery);
});
}
},
timestampToTime(timestamp) {
var date = new Date(timestamp);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
var Y = date.getFullYear() + '-';
var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
var D = date.getDate() + ' ';
var h = date.getHours() + ':';
var m = date.getMinutes() + ':';
var s = date.getSeconds();
return Y+M+D+h+m+s;
}
}
};
</script>

0 comments on commit 7d9919c

Please sign in to comment.