This commit is contained in:
宋文超
2022-11-25 18:29:19 +08:00
11 changed files with 258 additions and 136 deletions

View File

@@ -107,17 +107,18 @@
<span style="margin-right: 3px">授课老师</span>
</div>
<div class="btnbox">
<a-select
v-model:value="value"
<a-auto-complete
v-model:value="memberValue"
show-search
:not-found-content="fetching ? undefined : null"
placeholder="Select a teacher"
style="width: 364px"
:options="options"
:filter-option="filterOption"
@focus="handleFocus"
@blur="handleBlur"
@change="handleChange2"
></a-select>
@popupScroll="templateScroll"
@search="handleSearch"
></a-auto-complete>
</div>
</div>
<div class="main_item2">
@@ -324,7 +325,9 @@ import * as apiTask from "../../api/indexTaskadd";
import { toDate } from "@/api/method";
import { RouterEditTask } from "@/api/indexTask";
import { addTempTask } from "../../api/indexTaskadd";
import { getMemberInfo } from "@/api/index1";
import dayjs from "dayjs";
import { debounce } from "lodash-es";
// import { useRouter } from "vue-router";
function getBase64(img, callback) {
const reader = new FileReader();
@@ -382,10 +385,14 @@ export default {
},
setup(props, ctx) {
// const router = useRouter();
const options = ref([]);
const state = reactive({
currentPage: 1,
tableDataTotal: 100,
pageSize: 10,
fetching: false,
totalPages: 0,
memberValue: null, // 授课老师关键词
inputV1: "", //*直播名称
time: "", //*直播时间
inputV2: "", //*直播时长
@@ -651,16 +658,64 @@ export default {
.catch(() => {});
}
};
const templateScroll = (e) => {
console.log("滚动", e);
const { target } = e;
const scrllHeight = target.scrollHeight - target.scrollTop;
const clientHeight = target.clientHeight;
// console.log("scrllHeight", scrllHeight, clientHeight);
if (scrllHeight === 0 && clientHeight === 0) {
state.currentPage = 1;
} else if (scrllHeight - clientHeight == 0) {
// 下拉到底部时
if (state.currentPage < state.totalPages) {
// 如果滑到底部,则加载下一页
state.currentPage++;
// queryMember();
}
}
};
// 获取员工
const queryMember = () => {
if (!state.memberValue) return;
let obj = {
keyWord: state.memberValue,
id: 0,
org: 0,
pageNo: state.currentPage,
pageSize: state.pageSize,
};
getMemberInfo(obj)
.then((res) => {
let data = res.data.data.rows;
state.totalPages = res.data.data.total;
for (let i in data) {
options.value.push({
value: data[i].id,
label: data[i].realName,
});
}
})
.catch((err) => {
message.error("获取员工失败" + err);
});
};
const handleSearch = debounce((memberValue) => {
console.log("fetching user", memberValue);
options.value = [];
state.fetching = true;
state.currentPage = 1;
state.memberValue = memberValue;
queryMember();
state.fetching = false;
}, 300);
const options = ref([]);
const handleChange2 = (value) => {
console.log(`selected ${value}`);
};
const handleBlur = () => {
console.log("blur");
state.inputV3 = value;
};
const handleFocus = () => {
console.log("focus");
queryMember();
};
const checkRadio = () => {
if (state.checkedC1) {
@@ -669,9 +724,6 @@ export default {
state.discussSettings = "false";
}
};
const filterOption = (input, option) => {
return option.value.toLowerCase().indexOf(input.toLowerCase()) >= 0;
};
const handleChangeAssessment = (option) => {
state.assessmentId = option.assessmentId;
};
@@ -683,13 +735,14 @@ export default {
handleChange,
beforeUpload,
updateLiveBroadcast,
filterOption,
handleBlur,
handleFocus,
handleChange2,
options,
checkRadio,
handleChangeAssessment,
queryMember,
templateScroll,
handleSearch,
};
},
};