This commit is contained in:
kclf
2022-12-06 00:16:38 +08:00
parent b29f6230f1
commit 86e61caed7
2 changed files with 83 additions and 67 deletions

View File

@@ -34,69 +34,73 @@ export default {
props: { props: {
value: { value: {
type: String, type: String,
default: '' default: "",
}, },
name: { name: {
type: String, type: String,
default: '' default: "",
}, },
disabled: { disabled: {
type: Boolean, type: Boolean,
default: false default: false,
}, },
placeholder: { placeholder: {
type: String, type: String,
default: '请选择' default: "请选择",
}, },
// 'multiple' | 'tags' // 'multiple' | 'tags'
mode: { mode: {
type: String, type: String,
default: 'select' default: "select",
}, },
}, },
setup(props, ctx) { setup(props, ctx) {
const state = reactive({ const state = reactive({
options: [], options: [],
managerArray: [], managerArray: [],
memberParam: {keyWord: '', pageNo: 1, pageSize: 10}, memberParam: { keyWord: "", pageNo: 1, pageSize: 10 },
loading: false, loading: false,
init: false init: false,
}); });
watch(()=>state.memberParam.keyWord , throttle(getMember, 500)) watch(() => state.memberParam.keyWord, throttle(getMember, 500));
watch(()=>state.memberParam.pageNo , throttle(getPushMember, 500)) watch(() => state.memberParam.pageNo, throttle(getPushMember, 500));
watch(props, init) watch(props, init);
onMounted(() => { onMounted(() => {
console.log('onMounted') console.log("onMounted");
// init() // init()
}) });
function getMember() { function getMember() {
state.loading = true state.loading = true;
state.options = [] state.options = [];
getMemberData() getMemberData();
} }
function getPushMember() { function getPushMember() {
state.loading = true state.loading = true;
getMemberData() getMemberData();
} }
function getMemberData() { function getMemberData() {
console.log('getMemberData') console.log("getMemberData");
api1.getMemberInfo(state.memberParam).then((res) => { api1.getMemberInfo(state.memberParam).then((res) => {
const list = res.data.data.rows.filter(e => !(props.value + '')?.includes(e.id + '')).map(e => ({ const list = res.data.data.rows
.filter((e) => !(props.value + "")?.includes(e.id + ""))
.map((e) => ({
label: e.realName, label: e.realName,
value: e.id value: e.id,
})); }));
if (state.memberParam.pageNo === 1 && props.value) { if (state.memberParam.pageNo === 1 && props.value) {
const arrManagerId = (props.value + '').split(',') const arrManagerId = (props.value + "").split(",");
const arrManager = props.name.split(',') const arrManager = props.name.split(",");
state.options = [...arrManager.map((e, i) => ({label: e, value: arrManagerId[i]})), ...list] state.options = [
} else state.options.push(...list) ...arrManager.map((e, i) => ({ label: e, value: arrManagerId[i] })),
state.loading = false ...list,
];
} else state.options.push(...list);
state.loading = false;
}); });
} }
@@ -114,37 +118,46 @@ export default {
}; };
function init() { function init() {
console.log('init--', props) console.log("init--", props);
console.log(Array.isArray(state.managerArray)) console.log(Array.isArray(state.managerArray));
if ((props.value + '') !== (Array.isArray(state.managerArray) ? state.managerArray.join(',') : (state.managerArray + ''))) { if (
props.value + "" !==
(Array.isArray(state.managerArray)
? state.managerArray.join(",")
: state.managerArray + "")
) {
if (props.value) { if (props.value) {
const arrManager = props.name.split(',') const arrManager = props.name.split(",");
const arrManagerId = (props.value + '').split(',') const arrManagerId = (props.value + "").split(",");
state.managerArray = props.mode === 'select' ? props.value : arrManagerId; state.managerArray =
state.options = arrManager.map((e, i) => ({label: e, value: arrManagerId[i]})) props.mode === "select" ? props.value : arrManagerId;
state.options = arrManager.map((e, i) => ({
label: e,
value: arrManagerId[i],
}));
} else { } else {
state.managerArray = [] state.managerArray = [];
} }
getMemberData() getMemberData();
return; return;
} }
if (!props.value) { if (!props.value) {
if (!(state.options && state.options.length)) { if (!(state.options && state.options.length)) {
state.options = [] state.options = [];
getMember() getMember();
} }
return; return;
} }
} }
function change(e, l) { function change(e, l) {
console.log('change', l) console.log("change", l);
if (Array.isArray(l)) { if (Array.isArray(l)) {
ctx.emit('update:value', l.map(t => t.value).join(',')) ctx.emit("update:value", l.map((t) => t.value).join(","));
ctx.emit('update:name', l.map(t => t.label).join(',')) ctx.emit("update:name", l.map((t) => t.label).join(","));
} else { } else {
ctx.emit('update:value', l.value) ctx.emit("update:value", l.value);
ctx.emit('update:name', l.label) ctx.emit("update:name", l.label);
} }
} }
@@ -152,7 +165,7 @@ export default {
...toRefs(state), ...toRefs(state),
searchMember, searchMember,
memberScroll, memberScroll,
change change,
}; };
}, },
}; };

View File

@@ -547,6 +547,7 @@
alt="asterisk" alt="asterisk"
/> />
</div> </div>
<!-- 授课教师1 -->
<span style="margin-right: 14px">授课教师</span> <span style="margin-right: 14px">授课教师</span>
</div> </div>
<div class="item_inp"> <div class="item_inp">
@@ -4501,6 +4502,7 @@ export default defineComponent({
state.qdms_inputV1 = state.xzinputV1; state.qdms_inputV1 = state.xzinputV1;
state.xzinputV1 = ""; state.xzinputV1 = "";
getDictList("faceclassPic"); getDictList("faceclassPic");
getTea();
} }
if (state.bs_hs && state.valueE1 != "") { if (state.bs_hs && state.valueE1 != "") {
state.addOnlineCoursevisible = true; state.addOnlineCoursevisible = true;
@@ -5062,7 +5064,7 @@ export default defineComponent({
}; };
//获取教师 //获取教师
const getTea = async () => { const getTea = async () => {
console.log("获取授课教师信息"); console.log("获取授课教师信息33333333333");
options4CurName.value = state.teacher; options4CurName.value = state.teacher;
options4CurId.value = state.teacherId; options4CurId.value = state.teacherId;
@@ -5157,6 +5159,7 @@ export default defineComponent({
state.ft_hs = true; state.ft_hs = true;
state.ft_eidt = true; state.ft_eidt = true;
getTea();
}; };
// 预览弹框 开启和关闭 // 预览弹框 开启和关闭