Browse Source

DP-1750 线上教室学员授权需求

pull/7/head
Wangwei 1 year ago
parent
commit
91f742c2b6
  1. 259
      src/views/class/admin/student_admin_class.vue

259
src/views/class/admin/student_admin_class.vue

@ -1,15 +1,12 @@
<template>
<div>
<div class="tab-header flex-3">
<li>
<el-button type="primary" size="medium" icon="el-icon-circle-plus" @click="dialogFormVisible = true">添加学生
</el-button>
<el-button type="primary" size="medium" icon="el-icon-circle-plus" @click="dialogFormVisible = true">添加学生 </el-button>
<el-button type="danger" size="medium" icon="el-icon-delete" @click="handleClose()" class="mrt10">批量删除</el-button>
</li>
<li>
<el-input style="width: 200px; margin-right: 10px" placeholder="uid / 姓名" v-model="kw" @change="handleOption"
size="medium" clearable>
<el-input style="width: 200px; margin-right: 10px" placeholder="uid / 姓名" v-model="kw" @change="handleOption" size="medium" clearable>
<template #prefix>
<i class="el-input__icon el-icon-search"></i>
</template>
@ -18,22 +15,18 @@
</li>
</div>
<el-table v-loading="loading" :data="tableData" tooltip-effect="dark" style="width: 100%" stripe
@selection-change="handleSelectionChange" @cell-dblclick="openStudent">
<el-table-column type="selection" width="50">
</el-table-column>
<el-table-column prop="id" label="编号" width="80">
</el-table-column>
<el-table v-loading="loading" :data="tableData" tooltip-effect="dark" style="width: 100%" stripe @selection-change="handleSelectionChange" @cell-dblclick="openStudent">
<el-table-column type="selection" width="50"> </el-table-column>
<el-table-column prop="id" label="编号" width="80"> </el-table-column>
<el-table-column prop="uid" label="uid">
<template #default='scope'>
<template #default="scope">
<span>{{ scope.row.uid }}</span>
</template>
</el-table-column>
<el-table-column prop="username" label="昵称">
<template #default='scope'>
<template #default="scope">
<div>
<li>{{ scope.row.username }}</li>
<a :href="com_shequ_url + '/u/' + scope.row.uid" target="_blank" class="col008 f12">查看主页</a>
@ -41,11 +34,10 @@
</template>
</el-table-column>
<el-table-column prop="xs_name" label="姓名">
</el-table-column>
<el-table-column prop="xs_name" label="姓名"> </el-table-column>
<el-table-column prop="gongsi" label="公司">
<template #default='scope'>
<template #default="scope">
<el-popover effect="light" trigger="hover" placement="top" v-if="scope.row.gongsi">
<template #default>
<p>{{ scope.row.gongsi }}</p>
@ -60,24 +52,32 @@
</template>
</el-table-column>
<el-table-column prop="shouji" label="手机号" width="130px">
</el-table-column>
<el-table-column prop="shouji" label="手机号" width="130px"> </el-table-column>
<el-table-column prop="pfenshu" label="学生动态" width="200px">
<template #default='scope'>
<template #default="scope">
<div style="line-height: 28px;">
<a @click="getUserLog(scope.row.uid)" href="javascript:;" class="col008 item_log">观看记录<span
class="colff3">{{scope.row.logNum}}</span></a>
<span class="item_log">已看课时<span class="colff3">{{scope.row.videoNum}}</span></span>
<span class="item_log">已提交作业<span class="colff3">{{scope.row.workNum}}</span></span>
<span class="item_log">作业平均分<span class="colff3">{{scope.row.pfenshu}}</span></span>
<a @click="getUserLog(scope.row.uid)" href="javascript:;" class="col008 item_log"
>观看记录<span class="colff3">{{ scope.row.logNum }}</span
></a
>
<span class="item_log"
>已看课时<span class="colff3">{{ scope.row.videoNum }}</span
></span
>
<span class="item_log"
>已提交作业<span class="colff3">{{ scope.row.workNum }}</span
></span
>
<span class="item_log"
>作业平均分<span class="colff3">{{ scope.row.pfenshu }}</span></span
>
</div>
</template>
</el-table-column>
<el-table-column prop="beizhu" label="备注">
<template #default='scope'>
<template #default="scope">
<el-popover effect="light" trigger="hover" placement="top" width="300px" v-if="scope.row.beizhu">
<template #default>
<p style=" padding:6px; line-height: 24px;">{{ scope.row.beizhu }}</p>
@ -103,25 +103,22 @@
</el-popconfirm>
</template>
</el-table-column>
</el-table>
<!--总数超过一页再展示分页器-->
<div class="myel-pg-lf">
<el-pagination background @size-change="handleSizeChange" layout="total, prev, pager, next,jumper" :total="total"
:page-size="perpage" :current-page="page" @current-change="changePage" />
<el-pagination background @size-change="handleSizeChange" layout="total, prev, pager, next,jumper" :total="total" :page-size="perpage" :current-page="page" @current-change="changePage" />
</div>
</div>
<!-- 报名弹出层 -->
<el-dialog title="添加学生" v-model="dialogFormVisible" width="650px" center custom-class="sign-form">
<el-form :model="numbereRef" :rules="rules" label-position="right" ref="numberValidateRef">
<el-form-item label="学生uid" prop="uids">
<el-input type="textarea" v-model="numbereRef.uids" class="key-input" placeholder="输入学生的社区用户uid"></el-input>
<el-form-item label="手机号" prop="uids">
<el-input type="textarea" v-model="numbereRef.uids" class="key-input" placeholder="输入学生的手机号"></el-input>
</el-form-item>
<div class="col7e8" style="line-height: 24px">
<p>支持批量添加101,102,103多个uid用英文逗号隔开</p>
<p>支持批量添加15900012345,158xxx,...多个手机号用英文逗号隔开</p>
</div>
</el-form>
@ -133,11 +130,9 @@
</template>
</el-dialog>
<!-- 编辑弹出层 -->
<el-dialog :title="'编辑学生:' + modEdit.username" v-model="dialogEdit" width="650px" center custom-class="sign-form">
<el-form :model="modEdit" label-position="right" label-width="100px">
<el-form-item label="姓名" prop="xs_name">
<el-input class="key-input" v-model="modEdit.xs_name"></el-input>
</el-form-item>
@ -145,7 +140,6 @@
<el-input class="key-input" v-model="modEdit.gongsi"></el-input>
</el-form-item>
<!-- <el-select v-model="modEdit.gangwei" multiple placeholder="岗位" class="fl">
<el-option :key="2" label="业务人员" :value="2"></el-option>
<el-option :key="3" label="技术人员" :value="3"></el-option>
@ -155,17 +149,14 @@
<el-option :key="1" label="其他" :value="1"></el-option>
</el-select> -->
<el-form-item label="手机" prop="shouji">
<el-input class="key-input" v-model="modEdit.shouji"></el-input>
</el-form-item>
<el-form-item label="备注" prop="beizhu">
<el-input type="textarea" class="key-input" v-model="modEdit.beizhu">
</el-input>
<el-input type="textarea" class="key-input" v-model="modEdit.beizhu"> </el-input>
</el-form-item>
<el-input type="hidden" class="key-input" v-model="modEdit.id" :value="modEdit.id"></el-input>
</el-form>
<template #footer>
@ -180,21 +171,21 @@
<el-table :data="uidLog" v-loading="loading">
<el-table-column property="title" label="课时名称"></el-table-column>
<el-table-column property="videotime1" label="课时时长">
<template #default='scope'>
<template #default="scope">
<span v-if="scope.row.videotime1">{{ scope.row.videotime1 }}:</span>
<span v-else>{{ scope.row.videotime2 }}:{{ scope.row.videotime3 }}</span>
</template>
</el-table-column>
<el-table-column property="sum" label="观看总时长"></el-table-column>
<el-table-column property="id" label="开始观看时间">
<template #default='scope'>
<template #default="scope">
<div v-for="(item, i) in scope.row.item" :key="i">
{{ item.startTime }}
</div>
</template>
</el-table-column>
<el-table-column property="id" label="本次观看时长">
<template #default='scope'>
<template #default="scope">
<div v-for="(item, i) in scope.row.item" :key="i">
{{ item.onetime }}
</div>
@ -202,26 +193,23 @@
</el-table-column>
</el-table>
</el-dialog>
</template>
<script>
import { useRoute } from 'vue-router'
import { useRoute } from "vue-router";
import { studentList, addStudent, getStudent, editStudent, delStudent, studyLog } from "@/api/study_admin";
import { ref, toRefs, reactive, getCurrentInstance, nextTick } from 'vue';
import store from '@/store'
import { ref, toRefs, reactive, getCurrentInstance, nextTick } from "vue";
import store from "@/store";
import { _debounce } from "@/utils/debounce";
export default {
name: 'class_homework',
name: "class_homework",
setup() {
const { proxy } = getCurrentInstance()
const route = useRoute()
const { proxy } = getCurrentInstance();
const route = useRoute();
const classid = route.params.classid;
const state = reactive({
headers: {
'authentication': store.getters.get_authentication
authentication: store.getters.get_authentication,
},
loading: true,
tableData: [], //
@ -229,137 +217,134 @@
total: 0, //
page: 1, //
perpage: 10, //
id: '',
kw: '',
id: "",
kw: "",
dialogFormVisible: false,
dialogEdit: false,
dialogUidLog: false,
numbereRef: {
uids: ''
uids: "",
},
rules: {
uids: [
{ required: true, message: '请输入学生uid', trigger: 'blur' },
],
uids: [{ required: true, message: "请输入学生手机号", trigger: "blur" }],
},
rowStudent: {},
modEdit: {
id: '',
xs_name: '',
gongsi: '',
gangwei: '',
shouji: '',
fenshu: '',
beizhu: '',
id: "",
xs_name: "",
gongsi: "",
gangwei: "",
shouji: "",
fenshu: "",
beizhu: "",
},
uidLog: [],
alltime:'',
username:'',
})
alltime: "",
username: "",
});
//
const getStudentList = async () => {
state.loading = true
state.loading = true;
const params = {
page: state.page,
perpage: state.perpage,
id: state.id,
kw: state.kw,
}
};
const res = await studentList(classid, params);
if (res.code === 200) {
state.tableData = res.data.data
state.total = res.data.total
state.page = res.data.current_page
state.loading = false
state.tableData = res.data.data;
state.total = res.data.total;
state.page = res.data.current_page;
state.loading = false;
}
};
getStudentList();
//
const getUserLog = async (uid) => {
state.loading = true
state.loading = true;
const res = await studyLog(classid, uid);
if (res.code === 200) {
state.uidLog = res.data.data;
state.alltime = res.data.alltime;
state.username = res.data.username;
state.dialogUidLog = true;
state.loading = false
state.loading = false;
}
};
// item
const setItem = (item) => {
state.item = item
state.isShowItem = true
}
state.item = item;
state.isShowItem = true;
};
const handleOption = () => {
state.page = 1
getStudentList()
}
state.page = 1;
getStudentList();
};
//
const handleSelectionChange = (val) => {
state.multipleSelection = val
}
state.multipleSelection = val;
};
const changePage = (val) => {
state.page = val
getStudentList()
}
state.page = val;
getStudentList();
};
//
const handleSizeChange = (val) => {
state.perpage = val
getStudentList()
}
state.perpage = val;
getStudentList();
};
//
const resdelStudent = async (params) => {
const res = await delStudent(classid, params);
if (res.code === 200) {
proxy.$message({
type: 'success',
message: '删除成功',
center: true
type: "success",
message: "删除成功",
center: true,
});
getStudentList()
getStudentList();
}
};
const handleClose = (id) => {
let params
let params;
if (id) {
params = [id]
params = [id];
} else {
if (!state.multipleSelection.length) {
proxy.$message({
type: 'error',
message: '请选择编号',
center: true
type: "error",
message: "请选择编号",
center: true,
});
return
return;
}
params = state.multipleSelection.map(i => i.id)
params = state.multipleSelection.map((i) => i.id);
}
proxy.$confirm('此操作将永久删除, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
proxy
.$confirm("此操作将永久删除, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
resdelStudent(params);
}).catch(() => {
});
}
})
.catch(() => {});
};
//
const submitForm = _debounce(() => {
_submitForm();
}, 300)
}, 300);
const numberValidateRef = ref(null);
const _submitForm = () => {
nextTick(() => {
@ -367,30 +352,30 @@
if (valid) {
const params = {
uids: state.numbereRef.uids,
}
const res = await addStudent(classid, params)
if (res.message === 'success') {
};
const res = await addStudent(classid, params);
if (res.message === "success") {
state.dialogFormVisible = false;
proxy.$message({
type: 'success',
message: '添加成功',
center: true
type: "success",
message: "添加成功",
center: true,
});
setTimeout(function() {
getStudentList()
getStudentList();
}, 100);
}
}
});
})
}
});
};
//
const resgetStudent = async (id) => {
const res = await getStudent(classid, id);
if (res.code === 200) {
state.modEdit = res.data
state.dialogEdit = true
state.modEdit = res.data;
state.dialogEdit = true;
}
};
@ -398,30 +383,30 @@
const reseditStudent = async () => {
const params = {
data: state.modEdit,
}
};
const res = await editStudent(classid, params);
if (res.code === 200) {
state.dialogEdit = false;
proxy.$message({
type: 'success',
message: '编辑成功',
center: true
type: "success",
message: "编辑成功",
center: true,
});
getStudentList()
getStudentList();
}
};
const getid = (id) => {
resgetStudent(id);
}
};
const eidtForm = () => {
reseditStudent();
}
};
const openStudent = (row) => {
state.modEdit = row;
state.dialogEdit = true;
}
};
return {
...toRefs(state),
@ -439,9 +424,9 @@
eidtForm,
getUserLog,
openStudent,
}
}
}
};
},
};
</script>
<style lang="scss" scoped>

Loading…
Cancel
Save