单位暂提

This commit is contained in:
fan 2021-01-06 13:23:16 +08:00
parent 42dd23b716
commit 26d2556502
5 changed files with 198 additions and 31 deletions

View File

@ -97,14 +97,6 @@ export function putCompanyMember(companyId, data) {
data data
}); });
} }
/** 导入单位成员信息 */
export function importCompanyMember(companyId, data) {
return request({
url: `/api/company/${companyId}/refUserInfo/import`,
method: 'post',
data
});
}
/** 删除单位成员信息 */ /** 删除单位成员信息 */
export function deleteCompanyMember(companyId, memberId) { export function deleteCompanyMember(companyId, memberId) {
return request({ return request({
@ -172,3 +164,26 @@ export function deleteDeptInfo(deptId) {
method: 'delete' method: 'delete'
}); });
} }
/** 获取用户单位的部门信息 */
export function getCompanyDeptInfo(companyId) {
return request({
url: `/api/company/${companyId}/userDeparts`,
method: 'get'
});
}
/** 导入单位成员信息 */
export function importCompanyMember(companyId, data) {
return request({
url: `/api/company/${companyId}/departUserInfo/import`,
method: 'post',
data
});
}
/** 分页查询单位部门成员信息 */
export function queryDeptInfoPaging(params) {
return request({
url: `/api/company/dept/${params.deptId}/departUserInfo`,
method: 'get',
params
});
}

View File

@ -11,7 +11,7 @@
<span style="display:block;" @click="handleDetail">{{ $t('global.personalDetails') }}</span> <span style="display:block;" @click="handleDetail">{{ $t('global.personalDetails') }}</span>
</el-dropdown-item> </el-dropdown-item>
<!--<el-dropdown-item>--> <!--<el-dropdown-item>-->
<!--<span style="display:block;" @click="handleOrganization">{{ $t('global.organization') }}</span>--> <!--<span style="display:block;" @click="handleOrganization">{{ $t('global.organization') }}</span>-->
<!--</el-dropdown-item>--> <!--</el-dropdown-item>-->
<el-dropdown-item> <el-dropdown-item>
<span style="display:block;" @click="logout">{{ $t('global.exit') }}</span> <span style="display:block;" @click="logout">{{ $t('global.exit') }}</span>

View File

@ -18,7 +18,8 @@ const user = {
wxId: '', wxId: '',
wxUnionId: '', wxUnionId: '',
account: '', account: '',
projectDevice: '' projectDevice: '',
companyId: ''
}, },
mutations: { mutations: {
@ -49,6 +50,9 @@ const user = {
SET_ACCOUNT: (state, account) => { SET_ACCOUNT: (state, account) => {
state.account = account; state.account = account;
}, },
SET_COMPANYID: (state, companyId) => {
state.companyId = companyId;
},
CLEAR_AUTO_PARAMS: () => { CLEAR_AUTO_PARAMS: () => {
Cookies.remove('UserDesignName'); Cookies.remove('UserDesignName');
Cookies.remove('UserDesignToken'); Cookies.remove('UserDesignToken');
@ -123,6 +127,7 @@ const user = {
commit('SET_NATIONCODE', user.nationcode); commit('SET_NATIONCODE', user.nationcode);
commit('SET_WXID', user.wxId); commit('SET_WXID', user.wxId);
commit('SET_WXUNIONID', user.wxUnionId); commit('SET_WXUNIONID', user.wxUnionId);
commit('SET_COMPANYID', user.companyId);
resolve(user); resolve(user);
}).catch(error => { }).catch(error => {
reject(error); reject(error);

View File

@ -6,7 +6,7 @@ export function getBaseUrl() {
// BASE_API = 'http://192.168.8.107:9000'; // 袁琪 // BASE_API = 'http://192.168.8.107:9000'; // 袁琪
// BASE_API = 'http://192.168.8.129:9000'; // 旭强 // BASE_API = 'http://192.168.8.129:9000'; // 旭强
// BASE_API = 'http://192.168.8.119:9000'; // 张赛 // BASE_API = 'http://192.168.8.119:9000'; // 张赛
// BASE_API = 'http://192.168.8.110:9000'; // 杜康 // BASE_API = 'http://192.168.8.140:9000'; // 杜康
// BASE_API = 'http://b29z135112.zicp.vip'; // BASE_API = 'http://b29z135112.zicp.vip';
// BASE_API = 'http://2925963m2a.zicp.vip'; // 杜康 // BASE_API = 'http://2925963m2a.zicp.vip'; // 杜康
// BASE_API = 'http://2i38984j47.qicp.vip'; // 张赛 // BASE_API = 'http://2i38984j47.qicp.vip'; // 张赛

View File

@ -1,6 +1,17 @@
<template> <template>
<div> <div>
<div class="back_box"> <div class="back_box">
<el-button :loading="loadingStudentInfo" type="text" class="uploadDemo" style="margin-top: 10px;">
<input
id="importResults"
ref="files"
type="file"
class="file_box"
accept=".json, application/json, .csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
@change="importResults"
>
导入学生信息
</el-button>
<el-button type="text" @click="goBack">返回</el-button> <el-button type="text" @click="goBack">返回</el-button>
</div> </div>
<el-tabs v-model="activeName" type="card" @tab-click="handleClick"> <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
@ -8,39 +19,71 @@
<el-tree :data="data" :props="defaultProps" @node-click="handleNodeClick" /> <el-tree :data="data" :props="defaultProps" @node-click="handleNodeClick" />
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="成员管理" name="second"> <el-tab-pane label="成员管理" name="second">
<QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" /> <el-form :inline="true" size="small" :model="formInline">
<el-row>
<el-col :span="21" :offset="1">
<el-form-item label="班级">
<el-select v-model="formInline.classId" placeholder="班级">
<el-option
v-for="item in classList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="2">
<el-form-item>
<el-button type="primary" @click="onSubmit">查询</el-button>
</el-form-item>
</el-col>
</el-row>
</el-form>
<el-table :data="tableData" border style="width: 100%">
<el-table-column prop="studentId" label="学号" />
<el-table-column prop="name" label="姓名" />
<el-table-column prop="classId" label="班级" />
</el-table>
<div style="text-align: center;">
<el-pagination
:current-page="currentPage"
:page-sizes="[10, 20, 30, 50, 100]"
:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="totalNum"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
/>
</div>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</div> </div>
</template> </template>
<script> <script>
import { getCompanyDeptInfo, importCompanyMember, queryDeptInfoPaging } from '@/api/company';
import { convertSheetToList } from '@/utils/runPlan';
import XLSX from 'xlsx';
export default { export default {
name: 'Organization', name: 'Organization',
data() { data() {
return { return {
activeName: 'first', activeName: 'first',
defaultProps: '', defaultProps: '',
data: '', currentPage: 1,
pagerConfig: { totalNum: 0,
pageSize: 'pageSize', pageSize: 10,
pageIndex: 'pageNum' data: [],
}, tableData: [],
queryForm: { loadingStudentInfo: false,
labelWidth: '140px', formInline: {
reset: true, classId: ''
queryObject: {
classId: {
type: 'select',
label: '班级',
config: {
data: []
}
}
}
}, },
classList: [],
queryList: { queryList: {
query: this.queryFunction, query: queryDeptInfoPaging,
selectCheckShow: false, selectCheckShow: false,
indexShow: true, indexShow: true,
columns: [ columns: [
@ -60,7 +103,93 @@ export default {
} }
}; };
}, },
computed: {
companyId() {
return this.$store.state.user.companyId;
}
},
mounted() {
getCompanyDeptInfo(this.companyId).then(resp => {
console.log(resp);
}).catch(error => {
console.error(error);
});
},
methods: { methods: {
onSubmit() {
console.log('submit!');
},
handleSizeChange(val) {
console.log(val);
},
handleCurrentChange(val) {
console.log(val);
},
importResults(e) {
const obj = this.$refs.files;
if (obj.files) {
const file = obj.files[0];
this.handleImportResults(file);
obj.value = '';
}
},
handleImportResults(file) {
const studentData = { depart: '', parentDepart: '', companyUsers:[] };
if (file) {
setTimeout(() => {
const that = this;
const reader = new FileReader();
if (reader) {
reader.onload = function (e) {
let wb;
const data = e.target.result;
if (that.rABS) {
wb = XLSX.read(btoa(that.fixdata(data)), { //
type: 'base64'
});
} else {
wb = XLSX.read(data, {
type: 'binary'
});
}
if (wb) {
try {
const students = [];
for (const index in wb.Sheets) {
const dataList = convertSheetToList(wb.Sheets[index], true);
if (dataList.length) {
const depart = dataList[2][0].trim();
const parentDepart = dataList[1][0].trim();
studentData.depart = depart;
studentData.parentDepart = parentDepart;
for ( let i = 2; i <= dataList[0].length; i++) {
if (dataList[2][i] && dataList[1][i]) {
students.push({account:dataList[1][i], name: dataList[2][i]});
}
}
}
studentData.companyUsers = students;
}
that.loadingStudentInfo = true;
importCompanyMember(that.companyId, studentData).then(resp => {
}).catch((error) => {
that.$message.error('学生信息导入失败:' + error.message);
that.loadingStudentInfo = false;
});
} catch (error) {
that.$message.warning(`解析成绩单失败:${error}`);
}
}
};
if (that.rABS) {
reader.readAsArrayBuffer(file);
} else {
reader.readAsBinaryString(file);
}
}
}, 200);
}
},
handleClick() { handleClick() {
this.dialogVisible = false; this.dialogVisible = false;
}, },
@ -82,9 +211,27 @@ export default {
padding-right: 20px; padding-right: 20px;
height: 40px; height: 40px;
z-index: 36; z-index: 36;
width: 60px; width: 200px;
text-align: center; text-align: center;
position: absolute; position: absolute;
right: 0; right: 0;
} }
.file_box {
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
opacity: 0;
cursor: pointer;
z-index: 100;
}
.uploadDemo {
position: relative;
overflow: hidden;
margin-right: 3px;
cursor: pointer;
padding: 0 15px;
height: 28px;
}
</style> </style>