Files
2026-08-12 17:19:37 +08:00

141 lines
4.9 KiB
Vue

<template>
<div class="tabs-wrapper">
<Tabs class="tabs-panel" type="card" v-model="tabIndex">
<TabPane label="PC选择人员" name="1"></TabPane>
<TabPane label="WebApp选择人员" name="2"></TabPane>
</Tabs>
<div class="main-container" v-show="tabIndex === '1'">
<Checkbox v-model="isAddto">是否追加</Checkbox>
<Button type="primary" @click="show">选择人员</Button>
<Tooltip content="查看代码">
<Button class="ml-15" icon="md-code" @click="showCode({ name: '选择人员', url: 'userCheck.vue' })"></Button>
</Tooltip>
<user-check ref="userCheck" :treeData="treeData" v-model="userids" @on-submit="submit" :isDisabled="isAddto" />
<br />
ids: {{ userids }}
<br />
names:{{ userNames }}
</div>
<div class="main-container" v-show="tabIndex === '2'">
<div class="webapp-panel fl">
<Button type="primary" @click="showWebAppUserCheck">选择人员</Button>
<br />
ids: {{ userids }}
<br />
names:{{ userNames }}
<app-user-check v-model="userids" :treeData="treeData" @on-submit="submit" ref="userChecks"></app-user-check>
</div>
<p class="mt-30">../components/UserCheck 文件夹内</p>
</div>
</div>
</template>
<script>
import userCheck from "../components/user_check.vue";
import appUserCheck from "../components/UserCheck/index.vue";
export default {
components: { userCheck, appUserCheck },
data() {
return {
treeData: [],
tabIndex: "1",
userids: [161240, 162190, 162666, 162667, 162698, 162699, 162710, 162711, 161225],
userNames: [],
isAddto: false,
};
},
created() {
const _this = this;
this.treeData = [
{
name: "教师",
data: [
{
name: "基础平台",
data: _this.getTreeData2(),
},
{
name: "教学组",
data: _this.getTreeData2(),
},
{
name: "自定义组",
data: _this.getTreeData(3),
},
{
name: "自定义组",
data: _this.getTreeData(3),
},
],
},
{
name: "班级",
data: [
{
name: "必修班",
data: _this.getTreeData(4),
},
{
name: "选修班",
data: _this.getTreeData(5),
},
],
},
];
},
methods: {
show() {
this.$refs.userCheck.show();
},
submit(arr) {
this.userNames = arr.map(x => x.name);
},
getTreeData(type) {
return () =>
new Promise((resolve, reject) => {
console.time("time");
function randomFun(index) {
const id = Math.floor(Math.random() * index);
return id;
}
var arr = Array.from({ length: 2000 }, (item, index) => {
return {
id: index + 1,
name: `dep:${index + 1}`,
pid: randomFun(index),
};
});
function treeArr(arr = []) {
arr.forEach(item => {
const children = arr.filter(_ => _.pid === item.id);
if (children.length) {
item.children = children;
}
});
return arr.find(item => item.pid === 0);
}
var tree = [treeArr(arr, 0)];
setTimeout(() => {
console.log("请求完成!");
resolve(tree);
}, 200);
});
},
getTreeData2() {
return () =>
new Promise((resolve, reject) => {
this.$api.get(APIConfig.Base.GetSchoolAll, null, resp => {
console.log("请求完成!");
resolve(resp.Data);
});
});
},
showWebAppUserCheck() {
this.$refs["userChecks"].show();
},
},
};
</script>
<style>
</style>