-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
180 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<template> | ||
<div> | ||
<el-upload :http-request="readFile" ref="uploader" accept=".xls,.xlsx" | ||
:show-file-list="false" | ||
:on-change="onChange"> | ||
<el-button size="small" type="primary">打开文件</el-button> | ||
<div slot="tip" class="el-upload__tip">只能上传excel文件,且不超过5MB</div> | ||
</el-upload> | ||
</div> | ||
</template> | ||
<script> | ||
function readWorkbookFromLocalFile(XLSX, file, callback) { | ||
var reader = new FileReader() | ||
reader.onload = function (e) { | ||
var data = e.target.result | ||
var workbook = XLSX.read(data, {type: 'binary'}) | ||
if (callback) callback(workbook) | ||
} | ||
reader.readAsBinaryString(file) | ||
} | ||
export default{ | ||
data () { | ||
return {} | ||
}, | ||
components: {}, | ||
methods: { | ||
onChange(file, fileList) { | ||
console.log(file) | ||
}, | ||
readFile(req) { | ||
let file = req.file | ||
import('xlsx').then(XLSX => { | ||
readWorkbookFromLocalFile(XLSX, file, (wb) => { | ||
let data = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]) | ||
this.$emit('read', {file, data, wb}) | ||
}) | ||
}) | ||
} | ||
}, | ||
computed: {} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<template> | ||
<div v-html="value[field.name]"> | ||
html | ||
</div> | ||
</template> | ||
<script> | ||
export default{ | ||
props: { | ||
value: String, | ||
field: Object, | ||
context: Object | ||
}, | ||
data () { | ||
return {} | ||
}, | ||
components: {}, | ||
methods: {}, | ||
computed: {} | ||
} | ||
</script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Vue from 'vue' | ||
|
||
const party = { | ||
state: { | ||
name: null, | ||
logo: null | ||
}, | ||
|
||
mutations: { | ||
setParty(state, payload){ | ||
Object.assign(state, payload) | ||
} | ||
}, | ||
actions: { | ||
getPartyInfo ({commit, rootState}){ | ||
return Vue.http.get("/saas/party/current/").then(({data}) => { | ||
commit("setParty", data) | ||
return data | ||
}) | ||
} | ||
} | ||
} | ||
|
||
export default party |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Created by denishuang on 2020/5/15. | ||
*/ | ||
import UserStorage from '../../utils/user_storage' | ||
import {logout} from '../../utils/auth' | ||
export default { | ||
state: { | ||
storage: UserStorage() | ||
}, | ||
mutations: { | ||
setUser (state, payload) { | ||
Object.assign(state, payload) | ||
state.storage = UserStorage(payload.id) | ||
}, | ||
clearUser (state) { | ||
state.user = {} | ||
} | ||
}, | ||
actions: { | ||
getUserInfo ({commit, rootState}) { | ||
return Vue.http.get('/auth/user/current/').then(({data}) => { | ||
commit('setUser', data) | ||
rootState.bus.$emit('get-user-info', data) | ||
return data | ||
}) | ||
}, | ||
logout ({commit, rootState}) { | ||
return logout().then((data) => { | ||
commit('clearUser') | ||
rootState.bus.$emit('user-logout') | ||
return data | ||
}) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Created by denishuang on 2020/4/29. | ||
*/ | ||
|
||
export function img2canvas(img) { | ||
let canvas = document.createElement('canvas') | ||
canvas.width = img.width | ||
canvas.height = img.height | ||
canvas.getContext('2d').drawImage(img, 0, 0) | ||
return canvas | ||
} | ||
|
||
export function dataurl2blob(durl) { | ||
let arr = durl.split(','), | ||
mime = arr[0].match(/:(.*?);/)[1], | ||
bstr = atob(arr[1]), | ||
n = bstr.length, | ||
u8arr = new Uint8Array(n) | ||
while (n--) { | ||
u8arr[n] = bstr.charCodeAt(n) | ||
} | ||
return new Blob([u8arr], {type:mime}) | ||
} | ||
|
||
export function img2blob(img) { | ||
return dataurl2blob(img2canvas(img).toDataURL('image/png')) | ||
} |