|
@@ -10,9 +10,21 @@
|
|
|
<div class="userlist-name">{{nowUsers.name}}({{nowUsers.mobile}})</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <p class="correlationbox-title">目前用户所关联学校:</p>
|
|
|
+ <div class="school-list-header">
|
|
|
+ <div class="correlationbox-titles">目前用户所关联学校:<span>关联数量:<span class="correlationbox-num">{{nowUsers.handleSchools.length}}</span></span></div>
|
|
|
+ <div class="correlationbox-btn">
|
|
|
+ <el-button type="primary" size="small" v-if="removeBatchschool.length >0 && PowerShow" @click="multipeRemove"> 移除选中学校</el-button>
|
|
|
+ <el-button type="primary" size="small" v-else-if="removeBatchschool.length ===0 && PowerShow" disabled>移除选中学校</el-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- <p class="correlationbox-title">目前用户所关联学校:</p>
|
|
|
+ <div class="correlationbox-btn">
|
|
|
+ <el-button type="primary" size="small" v-if="multipleSchool.length >0 && PowerShow" @click="multipleCorrelation">关联选中学校</el-button>
|
|
|
+ <el-button type="primary" size="small" v-else-if="multipleSchool.length ===0 && PowerShow" disabled>关联选中学校</el-button>
|
|
|
+ </div> -->
|
|
|
<div class="possessbox" v-if="nowUsers.handleSchools.length >0">
|
|
|
- <el-table :data="nowUsers.handleSchools" style="width: 100%" height="20vh" size="small" v-loading="loadingData.possess" element-loading-text="数据加载中...">
|
|
|
+ <el-table :data="nowUsers.handleSchools" style="width: 100%" height="20vh" size="small" @selection-change="removeBatch" v-loading="loadingData.possess" element-loading-text="数据加载中...">
|
|
|
+ <el-table-column type="selection" v-if="PowerShow" />
|
|
|
<el-table-column label="校徽" align="center">
|
|
|
<template #default="scope">
|
|
|
<el-image style="width: 40px; height: 40px;" :src="scope.row.picture" fit="fill" v-if="scope.row.picture"></el-image>
|
|
@@ -23,6 +35,16 @@
|
|
|
<el-table-column prop="id" label="学校简码" align="center" />
|
|
|
<!-- <el-table-column prop="name" label="版本" />
|
|
|
<el-table-column prop="name" label="目前顾问" /> -->
|
|
|
+ <el-table-column align="center">
|
|
|
+ <template #header>
|
|
|
+ <el-select v-model="areaList.value" placeholder="Select" size="small" @change="getAreaschool">
|
|
|
+ <el-option v-for="item in areaList.data" :key="item.value" :label="item.label" :value="item.value" />
|
|
|
+ </el-select>
|
|
|
+ </template>
|
|
|
+ <template #default="scope">
|
|
|
+ <span class="areaitem-name">{{scope.row.areaName}}</span><span class="areaitem-insti">({{scope.row.institution}})</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
<el-table-column fixed="right" label="操作" width='80' align="center" v-if="PowerShow">
|
|
|
<template #default="scope">
|
|
|
<el-button type="text" size="small" @click="removeSchool(scope.row,scope.$index)">取消关联</el-button>
|
|
@@ -98,6 +120,7 @@ export default {
|
|
|
let tableData = ref([])
|
|
|
let nowUsers = ref()
|
|
|
let multipleSchool = ref([])
|
|
|
+ let removeBatchschool = ref([])
|
|
|
let schoolSearch = ref('')
|
|
|
let original = ref([])
|
|
|
let timer = ref('')
|
|
@@ -127,13 +150,16 @@ export default {
|
|
|
console.log(scrollHeight.value, '值')
|
|
|
}
|
|
|
}
|
|
|
- function getSchoolList (value, state) {
|
|
|
- console.log(value, '触发下一页')
|
|
|
+ async function getSchoolList (value, state) {
|
|
|
+ console.log(value, nextpageToken.value, '触发下一页')
|
|
|
if ((nextpageToken.value === null) && state !== 'restart') {
|
|
|
ElMessage.success('已经到最底了')
|
|
|
return
|
|
|
}
|
|
|
loadingData.value.list = true
|
|
|
+ if (areaList.value.data.length === 1) {
|
|
|
+ await areaData()
|
|
|
+ }
|
|
|
let data = value ? { contToken: value } : {}
|
|
|
proxy.$api
|
|
|
.getSchooldata(data)
|
|
@@ -155,9 +181,11 @@ export default {
|
|
|
console.log(areaList.value.data, '是否有数据')
|
|
|
for (let y in res.schoolAssists) {
|
|
|
let areaValue = res.schoolAssists[y].areaId
|
|
|
+ console.log(areaValue, '学区的值')
|
|
|
res.schoolAssists[y].areaName = ''
|
|
|
res.schoolAssists[y].institution = ''
|
|
|
for (let i in areaList.value.data) {
|
|
|
+ console.log(areaList.value.data[i], '循环的值')
|
|
|
areaValue === areaList.value.data[i].value ? (res.schoolAssists[y].areaName = areaList.value.data[i].label, res.schoolAssists[y].institution = areaList.value.data[i].situate) : ''
|
|
|
}
|
|
|
}
|
|
@@ -192,9 +220,9 @@ export default {
|
|
|
.then((res) => {
|
|
|
console.log(res, '成功的返回')
|
|
|
res.state === 200
|
|
|
- ? (nowUsers.value.handleSchools.push(value), getSchoolList(), processingSchool(), ElMessage.success('操作成功'))
|
|
|
+ ? (nowUsers.value.handleSchools.push(value), getSchoolList('', 'restart'), processingSchool(), ElMessage.success('操作成功'))
|
|
|
: res.state === 201
|
|
|
- ? (ElMessage.success('已关联,请勿重复操作'), getSchoolList())
|
|
|
+ ? (ElMessage.success('已关联,请勿重复操作'), getSchoolList('', 'restart'))
|
|
|
: ''
|
|
|
})
|
|
|
.catch((error) => {
|
|
@@ -215,7 +243,7 @@ export default {
|
|
|
proxy.$api
|
|
|
.setAistschool(data)
|
|
|
.then((res) => {
|
|
|
- res.state === 200 ? (nowUsers.value.handleSchools.splice(index, 1), getSchoolList(), processingSchool(), ElMessage.success('操作成功')) : ''
|
|
|
+ res.state === 200 ? (nowUsers.value.handleSchools.splice(index, 1), getSchoolList('', 'restart'), processingSchool(), ElMessage.success('操作成功')) : ''
|
|
|
})
|
|
|
.catch((error) => {
|
|
|
ElMessage.error('取消关联失败,API异常')
|
|
@@ -226,6 +254,9 @@ export default {
|
|
|
multipleSchool.value = value
|
|
|
console.log(multipleSchool.value, '111')
|
|
|
}
|
|
|
+ function removeBatch (value) {
|
|
|
+ removeBatchschool.value = value
|
|
|
+ }
|
|
|
function multipleCorrelation () {
|
|
|
let schoolData = multipleSchool.value
|
|
|
let schoolName = ''
|
|
@@ -255,7 +286,7 @@ export default {
|
|
|
.then((res) => {
|
|
|
console.log(res, '成功的返回')
|
|
|
res.state === 200
|
|
|
- ? ((nowUsers.value.handleSchools = nowUsers.value.handleSchools.concat(schoolData)), getSchoolList(), processingSchool(), ElMessage.success('操作成功'))
|
|
|
+ ? ((nowUsers.value.handleSchools = nowUsers.value.handleSchools.concat(schoolData)), getSchoolList('', 'restart'), processingSchool())
|
|
|
: res.state === 201
|
|
|
? (ElMessage.success('已关联,请勿重复操作'), getSchoolList())
|
|
|
: ''
|
|
@@ -265,6 +296,54 @@ export default {
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
+ function multipeRemove () {
|
|
|
+ let schoolData = removeBatchschool.value
|
|
|
+ let schoolName = ''
|
|
|
+ console.log(schoolData, '学校信息')
|
|
|
+ if (schoolData.length < 5) {
|
|
|
+ schoolData.forEach((item) => {
|
|
|
+ schoolName = schoolName ? schoolName + ',' + item.name : item.name
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ for (let i = 0; i < 5; i++) {
|
|
|
+ schoolName = schoolName ? schoolName + ',' + schoolData[i].name : schoolData[i].name
|
|
|
+ }
|
|
|
+ schoolName = schoolName + '等...'
|
|
|
+ }
|
|
|
+ ElMessageBox.confirm(`请问您确定将 ${schoolName} 移除学校管理,取消数据关联吗 ?`, '取消关联学校', {
|
|
|
+ confirmButtonText: proxy.$t(`commonMsg.confirm`),
|
|
|
+ cancelButtonText: proxy.$t(`commonMsg.closes`),
|
|
|
+ type: 'success',
|
|
|
+ center: true,
|
|
|
+ }).then(() => {
|
|
|
+ let schoolArr = []
|
|
|
+ for (let s of schoolData) {
|
|
|
+ s.id ? schoolArr.push(s.id) : ''
|
|
|
+ }
|
|
|
+ let data = { partitionKey: nowUsers.value.partitionKey, userId: nowUsers.value.userId, tmdId: nowUsers.value.tmdId, schoolIds: schoolArr, busy: 'del' }
|
|
|
+ proxy.$api
|
|
|
+ .setAistschool(data)
|
|
|
+ .then((res) => {
|
|
|
+ if (res.state === 200) {
|
|
|
+ console.log(schoolData, '内容')
|
|
|
+ schoolData.forEach((item, index) => {
|
|
|
+ let iteId = item.id
|
|
|
+ console.log(iteId, 'ID值')
|
|
|
+ for (let e in nowUsers.value.handleSchools) {
|
|
|
+ console.log(nowUsers.value.handleSchools, '值')
|
|
|
+ iteId === nowUsers.value.handleSchools[e].id ? nowUsers.value.handleSchools.splice(e, 1) : ''
|
|
|
+ }
|
|
|
+ })
|
|
|
+ getSchoolList('', 'restart')
|
|
|
+ processingSchool()
|
|
|
+ ElMessage.success('操作成功')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ ElMessage.error('取消关联失败,API异常')
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
function processingSchool (state) {
|
|
|
console.log(tableData.value, original.value, '原始数据和变更数据')
|
|
|
state ? tableData.value = original.value : ''
|
|
@@ -308,8 +387,8 @@ export default {
|
|
|
})
|
|
|
}
|
|
|
//加载所有学区信息
|
|
|
- function areaData () {
|
|
|
- proxy.$api.getCapacity({}).then((res) => {
|
|
|
+ async function areaData () {
|
|
|
+ await proxy.$api.getCapacity({}).then((res) => {
|
|
|
console.log(res, '学区信息')
|
|
|
res.state === 200 ? res.areas.forEach((item) => { areaList.value.data.push({ value: item.id, label: item.name, situate: item.institution }) }) : ''
|
|
|
}).catch((error) => {
|
|
@@ -339,6 +418,7 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
tableData.value = res.joinAreaSchools
|
|
|
+ processingSchool()
|
|
|
nextpageToken.value = null
|
|
|
}
|
|
|
loadingData.value.list = false
|
|
@@ -348,6 +428,25 @@ export default {
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
+ //处理显示目前关联的
|
|
|
+ async function nowRelevance (value) {
|
|
|
+ nowUsers.value = JSON.parse(JSON.stringify(value))
|
|
|
+ if (areaList.value.data.length === 1) {
|
|
|
+ await areaData()
|
|
|
+ }
|
|
|
+ getSchoolList()
|
|
|
+ let nowUserdata = nowUsers.value
|
|
|
+ nowUserdata.handleSchools.forEach((item) => {
|
|
|
+ let areaIds = item.areaId
|
|
|
+ item.areaName = ''; item.institution = ''
|
|
|
+ for (let i of areaList.value.data) {
|
|
|
+ console.log(i, '值123')
|
|
|
+ i.value === areaIds ? (item.areaName = i.label, item.institution = i.situate) : ''
|
|
|
+ }
|
|
|
+ })
|
|
|
+ nowUsers.value.handleSchools = nowUserdata.handleSchools
|
|
|
+ loadingData.value.possess = false
|
|
|
+ }
|
|
|
watch(scrollHeight, (newdata, olddata) => {
|
|
|
console.log(newdata, olddata, '监听的数据')
|
|
|
if (newdata < olddata) {
|
|
@@ -357,7 +456,7 @@ export default {
|
|
|
watch(
|
|
|
props,
|
|
|
(newuser) => {
|
|
|
- newuser ? (nowUsers.value = newuser.userdata, loadingData.value.possess = false, processingSchool(true)) : ''
|
|
|
+ newuser ? (nowRelevance(newuser.userdata), processingSchool(true)) : ''
|
|
|
console.log(nowUsers.value, '触发监听')
|
|
|
},
|
|
|
{ immediate: true, deep: true }
|
|
@@ -369,8 +468,7 @@ export default {
|
|
|
tableData.value = original.value
|
|
|
}
|
|
|
})
|
|
|
- getSchoolList()
|
|
|
- areaData()
|
|
|
+ // areaData()
|
|
|
return {
|
|
|
tableData,
|
|
|
tableDatas,
|
|
@@ -390,7 +488,11 @@ export default {
|
|
|
areaData,
|
|
|
loadingData,
|
|
|
areaList,
|
|
|
- getAreaschool
|
|
|
+ getAreaschool,
|
|
|
+ removeBatchschool,
|
|
|
+ multipeRemove,
|
|
|
+ removeBatch,
|
|
|
+ nowRelevance
|
|
|
}
|
|
|
},
|
|
|
}
|
|
@@ -479,7 +581,8 @@ export default {
|
|
|
color: #ecf0f1;
|
|
|
margin: 0 auto;
|
|
|
}
|
|
|
-.areaitem-name {
|
|
|
+.areaitem-name,
|
|
|
+.correlationbox-num {
|
|
|
color: #409eff;
|
|
|
}
|
|
|
.areaitem-insti {
|