-- 项目自动带出组织

This commit is contained in:
yuping
2022-12-06 23:51:55 +08:00
parent 19d110d910
commit e83e0afed3
3 changed files with 112 additions and 102 deletions

View File

@@ -9,7 +9,7 @@
:placeholder="placeholder" :placeholder="placeholder"
:filterOption="false" :filterOption="false"
style="width: 100%" style="width: 100%"
:options="options" :options="isOpen?options:selectOptions"
allowClear allowClear
showSearch showSearch
:mode="mode" :mode="mode"
@@ -39,13 +39,17 @@ const props = defineProps({
default: '' default: ''
}, },
disabled: Boolean, disabled: Boolean,
placeholder: String, placeholder: {
type: String,
default: "请输入搜索关键字",
},
mode: String mode: String
}) })
const options = ref([]) const options = ref([])
const selectOptions = ref([])
const managerArray = computed(() => props.mode === 'select' ? props.value : (props.value ? props.value.split(',') : [])) const managerArray = computed(() => props.mode === 'select' ? props.value : (props.value ? props.value.split(',') : []))
const emit = defineEmits({}) const emit = defineEmits({})
@@ -61,10 +65,10 @@ watch(() => memberParam.value.pageNo, throttle(getPageMember, 500))
watch(props, init) watch(props, init)
function init() { function init() {
props.value && (options.value = props.value.split(',').map((e, i) => ({ //第一次进来 编辑赋值
value: e, if (props.value && (props.value + '') !== selectOptions.value.map(e => e.value).join(',')) {
label: props.name.split(',')[i] selectOptions.value = (props.value + '').split(',').map((e, i) => ({label: props.name.split(',')[i], value: e}))
}))) }
} }
onMounted(() => { onMounted(() => {
@@ -94,7 +98,8 @@ function getMemberData() {
} }
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,
deptId: e.departId
})); }));
memberParam.value.pageNo === 1 && props.value ? (options.value = list) : options.value.push(...list) memberParam.value.pageNo === 1 && props.value ? (options.value = list) : options.value.push(...list)
loading.value = false loading.value = false
@@ -117,16 +122,10 @@ const searchMember = (keyWord) => {
}; };
function change(e, l) { function change(e, l) {
console.log('change', l) selectOptions.value = l
isOpen.value = false isOpen.value = false
emit('onChange', e, l, selectOptions.value.find(e => e.deptId)?.deptId)
if (Array.isArray(l)) { if (Array.isArray(l)) {
// const selectIds = l.filter(t => t.value).map(t => t.value).join(',')
// const arr = props.value ? props.value.split(',').filter(e => !selectIds.includes(e)).map((e, i) => ({
// value: e,
// name: props.name.split(',')[i]
// })) : []
// l.push(...arr)
// l=l.filter(t => t.label)
emit('update:name', l.map(t => t.label).join(',')) emit('update:name', l.map(t => t.label).join(','))
emit('update:value', l.map(t => t.value).join(',')) emit('update:value', l.map(t => t.value).join(','))
} else { } else {

View File

@@ -128,6 +128,7 @@
<ProjectManager <ProjectManager
v-model:value="projectInfo.managerId" v-model:value="projectInfo.managerId"
v-model:name="projectInfo.manager" v-model:name="projectInfo.manager"
@change="managerChange"
mode="multiple" mode="multiple"
></ProjectManager> ></ProjectManager>
</div> </div>
@@ -458,8 +459,13 @@ export default {
}); });
}; };
function managerChange(e, l, d) {
state.projectInfo.sourceBelongId = d
}
return { return {
...toRefs(state), ...toRefs(state),
managerChange,
timeChange, timeChange,
classificationChange, classificationChange,
classificationChange5, classificationChange5,
@@ -474,6 +480,7 @@ export default {
.flex-top { .flex-top {
align-items: flex-start !important; align-items: flex-start !important;
} }
.projectAdd { .projectAdd {
width: 100%; width: 100%;
// height: inherit; // height: inherit;

View File

@@ -9,7 +9,6 @@
v-model:value="searchParam.name" v-model:value="searchParam.name"
style="width: 270px; height: 40px; border-radius: 8px" style="width: 270px; height: 40px; border-radius: 8px"
placeholder="请输入项目名称" placeholder="请输入项目名称"
@change="sProjectNameChange"
allowClear allowClear
showSearch showSearch
> >
@@ -20,7 +19,6 @@
v-model:value="searchParam.manager" v-model:value="searchParam.manager"
style="width: 270px; height: 40px; border-radius: 8px" style="width: 270px; height: 40px; border-radius: 8px"
placeholder="请输入项目经理" placeholder="请输入项目经理"
@change="sProjectOrderChange"
allowClear allowClear
showSearch showSearch
> >
@@ -31,7 +29,6 @@
v-model:value="searchParam.createName" v-model:value="searchParam.createName"
style="width: 270px; height: 40px; border-radius: 8px" style="width: 270px; height: 40px; border-radius: 8px"
placeholder="请输入项目创建人" placeholder="请输入项目创建人"
@change="sProjectCreateChange"
allowClear allowClear
showSearch showSearch
> >
@@ -212,6 +209,7 @@
<ProjectManager <ProjectManager
v-model:value="projectInfo.managerId" v-model:value="projectInfo.managerId"
v-model:name="projectInfo.manager" v-model:name="projectInfo.manager"
@onChange="managerChange"
mode="multiple" mode="multiple"
></ProjectManager> ></ProjectManager>
</div> </div>
@@ -1753,10 +1751,16 @@ export default {
}); });
} }
); );
function managerChange(e, l, d) {
state.projectInfo.sourceBelongId = d
}
return { return {
...toRefs(state), ...toRefs(state),
dayjs, dayjs,
moment, moment,
managerChange,
reFinashedProject, reFinashedProject,
showBackFinashModal, showBackFinashModal,
timeChange, timeChange,