|
@@ -17,8 +17,30 @@
|
|
|
</Select>
|
|
|
<!-- 字串模糊搜尋 -->
|
|
|
<Input v-special-char v-model="searchText" clearable :placeholder="$t('stuAccount.searchHolder')" style="width: 220px;margin-left:20px;" search @on-search="filterData" @on-clear="filterData"></Input>
|
|
|
+ <Upload :before-upload="handleBeforeUpload" accept=".xls, .xlsx" action="" v-if="isNeedTable">
|
|
|
+ <Button style="margin-left: 20px;">
|
|
|
+ <Icon type="ios-cloud-upload" />
|
|
|
+ {{ $t('stuAccount.uploadFilter') }}
|
|
|
+ </Button>
|
|
|
+ </Upload>
|
|
|
+ <Button style="margin-left: 20px;" @click="refreshData()">
|
|
|
+ <Icon type="md-refresh" />
|
|
|
+ {{ $t('lessonRecord.reset') }}
|
|
|
+ </Button>
|
|
|
+ <Dropdown @on-click="onTemplateSelect" style="margin-top:6px; margin-left: 20px; cursor: pointer;">
|
|
|
+ <span>{{ $t('evaluation.importFile.templateDownload') }}</span>
|
|
|
+ <DropdownMenu slot="list">
|
|
|
+ <DropdownItem :name="0">中文简体(zh-CN)</DropdownItem>
|
|
|
+ <DropdownItem :name="1">中文繁體(zh-TW)</DropdownItem>
|
|
|
+ <DropdownItem :name="2">English(en-US)</DropdownItem>
|
|
|
+ </DropdownMenu>
|
|
|
+ </Dropdown>
|
|
|
</div>
|
|
|
<div style="position:relative">
|
|
|
+ <p v-if="notFoundlist.length">
|
|
|
+ {{ $t('stuAccount.notFoundStu') }}:
|
|
|
+ <span v-for="(item, index) in notFoundlist" :key="index" style="margin-right: 5px; color: #cd2b2b;">{{ item.id }}-{{ item.name }}</span>
|
|
|
+ </p>
|
|
|
<Scroll :on-reach-bottom="scrollLoad" height="600" :distance-to-edge="[15,15]">
|
|
|
<Table ref="stuSelection" :columns="tableColumns" :data="tableShowData" @on-selection-change="getSelectInfo">
|
|
|
<template slot-scope="{ row,index }" slot="status">
|
|
@@ -52,10 +74,17 @@
|
|
|
<script>
|
|
|
import PersonalPhoto from '@/components/public/personalPhoto/Index.vue'
|
|
|
import { mapGetters } from 'vuex'
|
|
|
+import excel from '@/utils/excel.js'
|
|
|
export default {
|
|
|
components: {
|
|
|
PersonalPhoto
|
|
|
},
|
|
|
+ props: {
|
|
|
+ isNeedTable: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
+ },
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
bgColor: ['#4ECDC4', '#F99406', '#075CD0', '#F7CA17', '#F2774B', '#67809F', '#BF55ED', '#00B169', '#F72459', '#F15A22', '#03C9A8', '#9A1294'],
|
|
@@ -74,7 +103,20 @@ export default {
|
|
|
basicCount: 99,
|
|
|
schoolBase: {
|
|
|
period: []
|
|
|
- }
|
|
|
+ },
|
|
|
+ notFoundlist: [],
|
|
|
+ downloadUrls: [
|
|
|
+ {
|
|
|
+ url: '/download/Screen student template-cn.xlsx',
|
|
|
+ fileName: '筛选学生模板.xlsx'
|
|
|
+ },{
|
|
|
+ url: '/download/Screen student template-tw.xlsx',
|
|
|
+ fileName: '篩選學生範本.xlsx'
|
|
|
+ },{
|
|
|
+ url: '/download/Screen student template-en.xlsx',
|
|
|
+ fileName: 'Screen student template.xlsx'
|
|
|
+ },
|
|
|
+ ]
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
@@ -238,6 +280,58 @@ export default {
|
|
|
return '-'
|
|
|
}
|
|
|
},
|
|
|
+ //获取上传的文件
|
|
|
+ handleBeforeUpload(file) {
|
|
|
+ let stuData = this._.cloneDeep(this.students)
|
|
|
+ let excelResult = []
|
|
|
+ this.readExcel(file, data => {
|
|
|
+ if (data.results.length) {
|
|
|
+ excelResult = this._.cloneDeep(data.results)
|
|
|
+ this.tableShowData = stuData.filter(item => {
|
|
|
+ let eIndex = excelResult.findIndex(results => results.id.toString() === item.id && results.name === item.name)
|
|
|
+ if(eIndex != -1) {
|
|
|
+ excelResult.splice(eIndex, 1)
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.notFoundlist = excelResult
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return false
|
|
|
+ },
|
|
|
+ /* 解析excel表格 */
|
|
|
+ readExcel(file, callback) {
|
|
|
+ var reader = new FileReader();
|
|
|
+ reader.onload = function (e) {
|
|
|
+ var data = e.target.result;
|
|
|
+ var workbook = excel.read(data, 'binary');
|
|
|
+ if (callback) callback(workbook);
|
|
|
+ };
|
|
|
+ reader.readAsBinaryString(file);
|
|
|
+ },
|
|
|
+ refreshData() {
|
|
|
+ this.searchGrade = ''
|
|
|
+ this.searchClass = ''
|
|
|
+ this.searchText = ''
|
|
|
+ this.notFoundlist = []
|
|
|
+ this.filterData()
|
|
|
+ },
|
|
|
+ /* 下载模板 */
|
|
|
+ async onTemplateSelect(val) {
|
|
|
+ let curFile = this.downloadUrls[val]
|
|
|
+ let hostName = this.$evTools.getBlobHost()
|
|
|
+ const downloadRes = async () => {
|
|
|
+ let response = await fetch(hostName + curFile.url); // 内容转变成blob地址
|
|
|
+ let blob = await response.blob(); // 创建隐藏的可下载链接
|
|
|
+ let objectUrl = window.URL.createObjectURL(blob);
|
|
|
+ let a = document.createElement('a');
|
|
|
+ a.href = objectUrl;
|
|
|
+ a.download = curFile.fileName;
|
|
|
+ a.click()
|
|
|
+ a.remove();
|
|
|
+ }
|
|
|
+ downloadRes();
|
|
|
+ },
|
|
|
},
|
|
|
created() {
|
|
|
this.initData()
|