|
|
|
|
@ -75,18 +75,25 @@
|
|
|
|
|
this.dialogVisible = false;
|
|
|
|
|
},
|
|
|
|
|
// 获取表头
|
|
|
|
|
async getHeaders() {
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
async getHeaders() {
|
|
|
|
|
let _except = []
|
|
|
|
|
// 学员去除一些信息
|
|
|
|
|
if (this.tableName === 'users') {
|
|
|
|
|
_except = ['plate', 'is_import', 'is_vip', 'is_schoolmate', 'appointment_total', 'letter', 'score', 'code',
|
|
|
|
|
'pid'
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
const res = await realTableShow({
|
|
|
|
|
table_name: this.tableName
|
|
|
|
|
table_name: this.tableName,
|
|
|
|
|
except: _except
|
|
|
|
|
})
|
|
|
|
|
let b = [];
|
|
|
|
|
for (let key in res) {
|
|
|
|
|
if (!this.base.isNull(res[key])) {
|
|
|
|
|
b.push({
|
|
|
|
|
key: key,
|
|
|
|
|
title: res[key]
|
|
|
|
|
title: res[key],
|
|
|
|
|
width:120
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -94,7 +101,8 @@
|
|
|
|
|
if (this.tableName === 'course_contents') {
|
|
|
|
|
b.push({
|
|
|
|
|
key: '',
|
|
|
|
|
title: '老师简介'
|
|
|
|
|
title: '老师简介',
|
|
|
|
|
width:120
|
|
|
|
|
});
|
|
|
|
|
b.map(item => {
|
|
|
|
|
if (item.key === 'teacher_id') {
|
|
|
|
|
@ -112,13 +120,14 @@
|
|
|
|
|
item.key = 'status_name'
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// 学员 + 课程
|
|
|
|
|
if (this.tableName === 'users') {
|
|
|
|
|
b.unshift({
|
|
|
|
|
key: 'course_name',
|
|
|
|
|
title: '课程名字'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
// 学员 + 课程
|
|
|
|
|
if (this.tableName === 'users') {
|
|
|
|
|
b.unshift({
|
|
|
|
|
key: 'course_name',
|
|
|
|
|
title: '课程名字',
|
|
|
|
|
width:120
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.table = this.headers = b
|
|
|
|
|
@ -132,30 +141,30 @@
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
uploadSuccess(response, file, fileList) {
|
|
|
|
|
console.log(response, file, fileList)
|
|
|
|
|
console.log("window.screen.height",window.screen.height)
|
|
|
|
|
console.log(response, file, fileList)
|
|
|
|
|
console.log("window.screen.height", window.screen.height)
|
|
|
|
|
if (response && response.hasOwnProperty("errcode")) {
|
|
|
|
|
this.$message({
|
|
|
|
|
message: response.errmsg || "上传失败",
|
|
|
|
|
type: "error",
|
|
|
|
|
duration:2000,
|
|
|
|
|
type: "error",
|
|
|
|
|
duration: 2000,
|
|
|
|
|
offset: window.screen.height / 4
|
|
|
|
|
});
|
|
|
|
|
this.fileList = []
|
|
|
|
|
this.tableList = []
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 考勤导入
|
|
|
|
|
if (this.tableName === 'course_keeps') {
|
|
|
|
|
response.map(item => {
|
|
|
|
|
item.status_name = item.status === 1 ? '正常' : '缺勤'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// 学员导入
|
|
|
|
|
if (this.tableName === 'users') {
|
|
|
|
|
response.map(item => {
|
|
|
|
|
item.is_schoolmate = 1
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// 学员导入
|
|
|
|
|
if (this.tableName === 'users') {
|
|
|
|
|
response.map(item => {
|
|
|
|
|
item.is_schoolmate = 1
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
this.tableList = response;
|
|
|
|
|
this.fileList = fileList
|
|
|
|
|
@ -167,7 +176,7 @@
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
exportExcel(sheetName) {
|
|
|
|
|
const data = [this.headers.map((header) =>header.title)];
|
|
|
|
|
const data = [this.headers.map((header) => header.title)];
|
|
|
|
|
const wb = XLSX.utils.book_new();
|
|
|
|
|
const ws = XLSX.utils.aoa_to_sheet(data);
|
|
|
|
|
XLSX.utils.book_append_sheet(wb, ws, sheetName);
|
|
|
|
|
@ -184,7 +193,12 @@
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
imports() {
|
|
|
|
|
imports() {
|
|
|
|
|
if(this.tableName=='users'){
|
|
|
|
|
this.tableList.map(item=>{
|
|
|
|
|
item.username = item.name
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
request({
|
|
|
|
|
method: "post",
|
|
|
|
|
url: this.import_action,
|
|
|
|
|
@ -207,7 +221,7 @@
|
|
|
|
|
},
|
|
|
|
|
computed: {},
|
|
|
|
|
watch: {
|
|
|
|
|
formInfo(newVal) {
|
|
|
|
|
formInfo(newVal) {
|
|
|
|
|
console.log("formInfo", newVal)
|
|
|
|
|
if (newVal && newVal instanceof Array) {
|
|
|
|
|
this.table = this.headers = newVal.map((i) => {
|
|
|
|
|
@ -219,32 +233,32 @@
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
dialogVisible(newval) {
|
|
|
|
|
console.log("newval", newval, this.tableName,this.formInfo)
|
|
|
|
|
console.log("newval", newval, this.tableName, this.formInfo)
|
|
|
|
|
if (newval) {
|
|
|
|
|
let changeTableName = this.tableName.replace('_', '-')
|
|
|
|
|
this.action = `${process.env.VUE_APP_BASE_API}/api/admin/${changeTableName}/excel-show`
|
|
|
|
|
this.import_action = `/api/admin/${changeTableName}/import`
|
|
|
|
|
// 学员导入
|
|
|
|
|
if(this.tableName==='users'){
|
|
|
|
|
this.import_action = `/api/admin/${changeTableName}/import-study`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if(this.tableName==='users'){
|
|
|
|
|
// this.import_action = `/api/admin/${changeTableName}/import-study`
|
|
|
|
|
// this.table = this.headers = this.formInfo.map((i) => {
|
|
|
|
|
|
|
|
|
|
// if(i.prop){
|
|
|
|
|
// console.log("i.prop",i.prop)
|
|
|
|
|
// return {
|
|
|
|
|
// key: i.prop,
|
|
|
|
|
// title: i.label,
|
|
|
|
|
// };
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
// console.log("this.table",this.headers)
|
|
|
|
|
// }else{
|
|
|
|
|
this.getHeaders()
|
|
|
|
|
let changeTableName = this.tableName.replace('_', '-')
|
|
|
|
|
this.action = `${process.env.VUE_APP_BASE_API}/api/admin/${changeTableName}/excel-show`
|
|
|
|
|
this.import_action = `/api/admin/${changeTableName}/import`
|
|
|
|
|
// 学员导入
|
|
|
|
|
if (this.tableName === 'users') {
|
|
|
|
|
this.import_action = `/api/admin/${changeTableName}/import-study`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if(this.tableName==='users'){
|
|
|
|
|
// this.import_action = `/api/admin/${changeTableName}/import-study`
|
|
|
|
|
// this.table = this.headers = this.formInfo.map((i) => {
|
|
|
|
|
|
|
|
|
|
// if(i.prop){
|
|
|
|
|
// console.log("i.prop",i.prop)
|
|
|
|
|
// return {
|
|
|
|
|
// key: i.prop,
|
|
|
|
|
// title: i.label,
|
|
|
|
|
// };
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
// console.log("this.table",this.headers)
|
|
|
|
|
// }else{
|
|
|
|
|
this.getHeaders()
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
console.log("action", this.action, this.import_action)
|
|
|
|
|
|