feat: 所有自定义动态列对接完毕

bak
刘释隆 1 year ago
parent a89e109010
commit 7ed436a454

@ -1,27 +1,27 @@
<script lang="ts" setup> <script lang="ts" setup>
import { getAllfieldList, getfieldList } from "@/api/home/filter"; import { getAllfieldList, getfieldList, savefield } from "@/api/home/filter";
import { ColumnsMap } from '@/config/final'; import { ColumnsMap } from "@/config/final";
import { useUser } from "@/store/modules/user"; import { useUser } from "@/store/modules/user";
import { difference } from 'lodash-es'; import { difference } from "lodash-es";
import { computed, onMounted, ref, watch } from 'vue'; import { computed, onMounted, ref, watch } from "vue";
import { VueDraggable } from 'vue-draggable-plus'; import { VueDraggable } from "vue-draggable-plus";
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'commit', columns: any[]) (e: "commit", columns: any[]);
}>() }>();
// //
const offList = ref<any[]>([]) const offList = ref<any[]>([]);
// //
const fixLeftList = ref<any[]>([]) const fixLeftList = ref<any[]>([]);
const onList = ref<any[]>([]) const onList = ref<any[]>([]);
const props = defineProps({ const props = defineProps({
reviewType: { reviewType: {
type: Number, type: Number,
default: () => 0, default: () => 0,
require: true, require: true,
}, },
}) });
onMounted(async () => { onMounted(async () => {
const userStore = useUser(); const userStore = useUser();
@ -37,71 +37,82 @@ onMounted(async()=>{
* fix 是否默认 * fix 是否默认
* checked 是否选中 * checked 是否选中
*/ */
const userFieldFixed = useList.userFieldFixed?.split(",");
allList.map((v) => { const userFieldUnFixed = useList.userFieldUnFixed?.split(",");
allList?.map((v) => {
let item = { let item = {
name: v.fieldDesc, name: v.fieldDesc,
id: v.name, id: v.name,
fix: v.isrequired == 2, fix: v.isrequired == 2,
checked: checked:
v.isrequired == 2 || v.isrequired == 2 ||
Boolean(useList.userFieldFixed?.indexOf(v.name)>-1) || Boolean(useList.userFieldUnFixed?.indexOf(v.name)>-1), Boolean(userFieldFixed?.find((v2) => v2 == v.name)) ||
Boolean(userFieldUnFixed?.find((v2) => v2 == v.name)),
}; };
offList.value.push(item) if (!userFieldFixed?.length && !userFieldUnFixed?.length) {
if (item.fix) {
fixLeftList.value.push(item);
}
}
if (userFieldFixed?.find((v2) => v2 == v.name)) {
fixLeftList.value.push(item);
}
if (userFieldUnFixed?.find((v2) => v2 == v.name)) {
onList.value.push(item);
}
offList.value.push(item);
});
}); });
})
const allCount = computed(() => { const allCount = computed(() => {
return `全部字段(共${offList.value.length - 1}个)` return `全部字段(共${offList.value.length - 1}个)`;
}) });
const selectCount = computed(() => { const selectCount = computed(() => {
return `显示字段(共${onList.value.length}个)` return `显示字段(共${onList.value.length}个)`;
}) });
function generatList() { function generatList() {
const keys = Object.keys(ColumnsMap) const keys = Object.keys(ColumnsMap);
// const showStr = 'name' // const showStr = 'name'
// const showKeys = showStr.split(',').map((key: string) => key.toLowerCase()) // const showKeys = showStr.split(',').map((key: string) => key.toLowerCase())
for (const key of keys) { for (const key of keys) {
const { title, fixed, fixLeft, width } = ColumnsMap[key] const { title, fixed, fixLeft, width } = ColumnsMap[key];
const item = { const item = {
id: key, id: key,
title, title,
fix: fixed, fix: fixed,
checked: ColumnsMap[key].fixed, checked: ColumnsMap[key].fixed,
width, width,
} };
if (!fixed) if (!fixed) offList.value.push(item);
offList.value.push(item)
if (fixLeft) if (fixLeft) fixLeftList.value.push(item);
fixLeftList.value.push(item)
} }
// showList = showKeys.reduce((acc, key) => { // showList = showKeys.reduce((acc, key) => {
// const config = { // const config = {
// id: key, // id: key,
// title: ColumnsMap[key].title || '', // title: ColumnsMap[key].name || '',
// fix: ColumnsMap[key].fixed, // fix: ColumnsMap[key].fixed,
// } // }
// return [...acc, config] // return [...acc, config]
// }, []) // }, [])
const fixedList = generateDefaultList() const fixedList = generateDefaultList();
const filterList = fixedList.filter((item) => { const filterList = fixedList.filter((item) => {
return !item.fixLeft return !item.fixLeft;
}) });
onList.value.unshift(...filterList) onList.value.unshift(...filterList);
offList.value.unshift(...fixedList) offList.value.unshift(...fixedList);
} }
function generateDefaultList() { function generateDefaultList() {
return Object.keys(ColumnsMap).reduce((acc, key) => { return Object.keys(ColumnsMap).reduce((acc, key) => {
const { title, fixed, fixLeft, width } = ColumnsMap[key] const { title, fixed, fixLeft, width } = ColumnsMap[key];
if (fixed) { if (fixed) {
const config = { const config = {
@ -111,174 +122,203 @@ function generateDefaultList() {
checked: true, checked: true,
fixLeft, fixLeft,
width, width,
};
return [...acc, config];
} else {
return acc;
} }
return [...acc, config] }, []);
}
else {
return acc
}
}, [])
} }
const show = ref(false) const show = ref(false);
const checkAll = ref(false) const checkAll = ref(false);
function showModal() { function showModal() {
show.value = true show.value = true;
} }
function closeModal() { function closeModal() {
show.value = false show.value = false;
} }
async function handleSumbit(e: MouseEvent) { async function handleSumbit(e: MouseEvent) {
e.preventDefault() e.preventDefault();
closeModal() closeModal();
const userStore = useUser();
const columns: any[] = [{ const userInfo = userStore.getUserInfo;
type: 'selection', let userFieldFixed = "";
fixed: 'left', let userFieldUnFixed = "";
fixLeftList.value.map((v) => {
userFieldFixed += `${v.id},`;
});
onList.value.map((v) => {
userFieldUnFixed += `${v.id},`;
});
userFieldFixed = userFieldFixed.slice(0, userFieldFixed.length - 1);
userFieldUnFixed = userFieldUnFixed.slice(0, userFieldUnFixed.length - 1);
savefield(props.reviewType, userInfo.id, userFieldFixed, userFieldUnFixed);
const columns: any[] = [
{
type: "selection",
fixed: "left",
width: 50, width: 50,
}] },
];
const leftList = fixLeftList.value.map((item) => { const leftList = fixLeftList.value.map((item) => {
return { return {
title: item.title, title: item.name,
key: item.id, key: item.id,
fixed: 'left', fixed: "left",
width: item.width, width: 120,
} };
}) });
const unfixList = onList.value.map((item) => { const unfixList = onList.value.map((item) => {
return { return {
title: item.title, title: item.name,
key: item.id, key: item.id,
width: item.width, width: 120,
} };
}) });
columns.push(...leftList, ...unfixList) columns.push(...leftList, ...unfixList);
emit('commit', columns) emit("commit", columns);
} }
defineExpose({ defineExpose({
showModal, showModal,
}) });
// generatList() // generatList()
const selectIds = ref<string[]>([]) const selectIds = ref<string[]>([]);
function onCheckAllChange(value) { function onCheckAllChange(value) {
const ids: string[] = [] const ids: string[] = [];
for (const item of offList.value) { for (const item of offList.value) {
if (!item.fix) { if (!item.fix) {
item.checked = value item.checked = value;
ids.push(item.id) ids.push(item.id);
} }
} }
selectIds.value = value ? ids : [];
selectIds.value = value ? ids : []
} }
function onCheckChange(checked: any, item: any) { function onCheckChange(checked: any, item: any) {
const index = selectIds.value.indexOf(item.id) item.checked = checked;
if (checked) {
item.checked = checked onList.value.push(item);
} else {
if (index === -1 && checked) let index = onList.value.findIndex((v) => v.id == item.id);
selectIds.value.push(item.id) if (index > -1) {
else onList.value.splice(index, 1);
selectIds.value.splice(index, 1) } else {
index = fixLeftList.value.findIndex((v) => v.id == item.id);
fixLeftList.value.splice(index, 1);
}
}
// TODO
// if (index === -1 && checked) selectIds.value.push(item.id);
// else selectIds.value.splice(index, 1);
} }
const showIds = computed(() => { const showIds = computed(() => {
return onList.value.map((item) => { return onList.value.map((item) => {
return item.id return item.id;
}) });
}) });
watch( watch(
() => selectIds.value.length, () => selectIds.value.length,
(newVal, oldVal) => { (newVal, oldVal) => {
if (newVal === oldVal) if (newVal === oldVal) return;
return
const action = newVal > oldVal ? 'add' : 'remove' const action = newVal > oldVal ? "add" : "remove";
const diff: string[] = action === 'add' ? difference(selectIds.value, showIds.value) : difference(showIds.value, selectIds.value) const diff: string[] =
action === "add"
? difference(selectIds.value, showIds.value)
: difference(showIds.value, selectIds.value);
if (diff.length === 0) if (diff.length === 0) return;
return
if (action === 'add') { if (action === "add") {
for (const item of offList.value) { for (const item of offList.value) {
if (!item.fix && diff.includes(item.id)) { if (!item.fix && diff.includes(item.id)) {
onList.value.push({ onList.value.push({
id: item.id, id: item.id,
title: item.title, name: item.name,
fix: item.fix || false, fix: item.fix || false,
width: item.width, width: 120,
}) });
}
} }
} }
else { } else {
const list = onList.value const list = onList.value;
for (let index = 0; index < list.length; index++) { for (let index = 0; index < list.length; index++) {
const item = list[index] const item = list[index];
if (!item.fix && diff.includes(item.id)) { if (!item.fix && diff.includes(item.id)) {
list.splice(index, 1) list.splice(index, 1);
index-- return;
} }
} }
} }
}, }
) );
watch( watch(
() => showIds.value.length, () => showIds.value.length,
(newVal, oldVal) => { (newVal, oldVal) => {
if (newVal === oldVal) if (newVal === oldVal) return;
return
const diff = difference(selectIds.value, showIds.value) const diff = difference(selectIds.value, showIds.value);
if (diff.length === 0) if (diff.length === 0) return;
return
for (const item of offList.value) { for (const item of offList.value) {
if (!item.fix && diff.includes(item.id)) { if (!item.fix && diff.includes(item.id)) {
const index = selectIds.value.indexOf(item.id) const index = selectIds.value.indexOf(item.id);
item.checked = false item.checked = false;
selectIds.value.splice(index, 1) selectIds.value.splice(index, 1);
} }
} }
}, }
) );
function clearDragSource() { function clearDragSource() {
onList.value = onList.value.filter((item) => { onList.value = onList.value.filter((item) => {
return item.fix === true return item.fix === true;
}) });
} }
function removeHandler(id: string, type: 'fix' | 'unfix') { function removeHandler(id: string, type: "fix" | "unfix") {
const list = type === 'fix' ? fixLeftList.value : onList.value const list = type === "fix" ? fixLeftList.value : onList.value;
const index = list.findIndex((item) => { let index = list.findIndex((item) => {
return item.id === id return item.id === id;
}) });
if (index !== -1) if (index !== -1) list.splice(index, 1);
list.splice(index, 1) index = offList.value.findIndex((v) => v.id == id);
if (index !== -1) {
offList.value[index].checked = false;
} else {
index == fixLeftList.value.findIndex((v) => v.id == id);
fixLeftList.value[index].checked = false;
}
} }
</script> </script>
<template> <template>
<n-modal v-model:show="show" transform-origin="center"> <n-modal v-model:show="show" transform-origin="center">
<n-card class="cardstyle" :bordered="false" size="huge" role="dialog" aria-modal="true"> <n-card
class="cardstyle"
:bordered="false"
size="huge"
role="dialog"
aria-modal="true"
>
<div class="wrapper"> <div class="wrapper">
<span class="wrapper-title">自定义显示列</span> <span class="wrapper-title">自定义显示列</span>
<div class="wrapper-bar"> <div class="wrapper-bar">
@ -289,7 +329,10 @@ function removeHandler(id: string, type: 'fix' | 'unfix') {
<n-grid cols="4" class="mt-4 proCard" responsive="screen" :x-gap="24"> <n-grid cols="4" class="mt-4 proCard" responsive="screen" :x-gap="24">
<n-grid-item span="3"> <n-grid-item span="3">
<NCard <NCard
:title="allCount" class="dragcardStyle" :segmented="{ content: true, footer: true }" size="small" :title="allCount"
class="dragcardStyle"
:segmented="{ content: true, footer: true }"
size="small"
:bordered="false" :bordered="false"
> >
<div> <div>
@ -300,15 +343,24 @@ function removeHandler(id: string, type: 'fix' | 'unfix') {
</n-input> </n-input>
<div class="draggable-ul"> <div class="draggable-ul">
<div class="draggable-li"> <div class="draggable-li">
<n-checkbox v-model:checked="checkAll" label="全部" @update:checked="onCheckAllChange" /> <n-checkbox
v-model:checked="checkAll"
label="全部"
@update:checked="onCheckAllChange"
/>
</div> </div>
<div class="content"> <div class="content">
<div <div
v-for="item in offList" :key="item.id" style="width: 170px;" v-for="item in offList"
:class="{ 'disable-check': item.fix }" class="draggable-li" :key="item.id"
style="width: 170px"
:class="{ 'disable-check': item.fix }"
class="draggable-li"
> >
<n-checkbox <n-checkbox
v-model:checked="item.checked" :label="item.title" :disabled="item.fix" v-model:checked="item.checked"
:label="item.name"
:disabled="item.fix"
@update:checked="onCheckChange($event, item)" @update:checked="onCheckChange($event, item)"
/> />
</div> </div>
@ -319,7 +371,10 @@ function removeHandler(id: string, type: 'fix' | 'unfix') {
</n-grid-item> </n-grid-item>
<n-grid-item> <n-grid-item>
<NCard <NCard
:title="selectCount" class="dragcardStyle" :segmented="{ content: true, footer: true }" size="small" :title="selectCount"
class="dragcardStyle"
:segmented="{ content: true, footer: true }"
size="small"
:bordered="false" :bordered="false"
> >
<template #header-extra> <template #header-extra>
@ -333,28 +388,56 @@ function removeHandler(id: string, type: 'fix' | 'unfix') {
</n-input> </n-input>
<div class="drag-wrapper"> <div class="drag-wrapper">
<div>固定在左侧</div> <div>固定在左侧</div>
<VueDraggable v-model="fixLeftList" class="draggable-ul" :animation="150" group="show"> <VueDraggable
v-model="fixLeftList"
class="draggable-ul"
:animation="150"
group="show"
>
<div <div
v-for="item in fixLeftList" :key="item.id" :class="{ fix: item.fix }" v-for="item in fixLeftList"
:key="item.id"
:class="{ fix: item.fix }"
class="cursor-move draggable-item" class="cursor-move draggable-item"
> >
<span class="ml-2">{{ item.title }}</span> <span class="ml-2">{{ item.name }}</span>
<SvgIcon <SvgIcon
v-if="!item.fix" size="16px" style="display: block; margin-left: auto; cursor: pointer" v-if="!item.fix"
name="clear" @click="removeHandler(item.id, 'fix')" size="16px"
style="
display: block;
margin-left: auto;
cursor: pointer;
"
name="clear"
@click="removeHandler(item.id, 'fix')"
/> />
</div> </div>
</VueDraggable> </VueDraggable>
<div>不固定</div> <div>不固定</div>
<VueDraggable v-model="onList" class="draggable-ul" :animation="150" group="show"> <VueDraggable
v-model="onList"
class="draggable-ul"
:animation="150"
group="show"
>
<div <div
v-for="item in onList" :key="item.id" :class="{ fix: item.fix }" v-for="item in onList"
:key="item.id"
:class="{ fix: item.fix }"
class="cursor-move draggable-item" class="cursor-move draggable-item"
> >
<span class="ml-2">{{ item.title }}</span> <span class="ml-2">{{ item.name }}</span>
<SvgIcon <SvgIcon
v-if="!item.fix" size="16px" style="display: block; margin-left: auto; cursor: pointer" v-if="!item.fix"
name="clear" @click="removeHandler(item.id, 'unfix')" size="16px"
style="
display: block;
margin-left: auto;
cursor: pointer;
"
name="clear"
@click="removeHandler(item.id, 'unfix')"
/> />
</div> </div>
</VueDraggable> </VueDraggable>
@ -367,9 +450,7 @@ function removeHandler(id: string, type: 'fix' | 'unfix') {
<template #footer> <template #footer>
<div class="wrapper-footer"> <div class="wrapper-footer">
<n-button type="info" @click="handleSumbit"> <n-button type="info" @click="handleSumbit"> </n-button>
确认
</n-button>
<n-button secondary style="margin-left: 15px" @click="closeModal"> <n-button secondary style="margin-left: 15px" @click="closeModal">
取消 取消
</n-button> </n-button>
@ -406,7 +487,7 @@ function removeHandler(id: string, type: 'fix' | 'unfix') {
&:before { &:before {
background-color: #1980ff; background-color: #1980ff;
content: ''; content: "";
width: 5px; width: 5px;
border-radius: 2px; border-radius: 2px;
top: 0; top: 0;
@ -467,7 +548,9 @@ function removeHandler(id: string, type: 'fix' | 'unfix') {
} }
} }
::v-deep(.n-card.n-card--content-segmented > .n-card__content:not(:first-child)) { ::v-deep(
.n-card.n-card--content-segmented > .n-card__content:not(:first-child)
) {
border: 0px; border: 0px;
} }

File diff suppressed because it is too large Load Diff

@ -12,7 +12,7 @@ const el = ref<HTMLDivElement | null>(null);
const keyword = ref(""); const keyword = ref("");
const canloadMore = ref(true); const canloadMore = ref(true);
const props = defineProps({ defineProps({
showFieldList: { showFieldList: {
type: Array, type: Array,
default: () => [], default: () => [],

@ -104,15 +104,15 @@ function closeModal() {
async function handleSumbit(e: MouseEvent) { async function handleSumbit(e: MouseEvent) {
const userStore = useUser(); const userStore = useUser();
const userInfo = userStore.getUserInfo; const userInfo = userStore.getUserInfo;
let userField = ""; let userFieldFixed = "";
fixList.value.map((v) => { fixList.value.map((v) => {
userField += `${v.id},`; userFieldFixed += `${v.id},`;
}); });
onList.value.map((v) => { onList.value.map((v) => {
userField += `${v.id},`; userFieldFixed += `${v.id},`;
}); });
userField = userField.slice(0, userField.length - 1); userFieldFixed = userFieldFixed.slice(0, userFieldFixed.length - 1);
savefield(props.reviewType, userInfo.id, userField); savefield(props.reviewType, userInfo.id, userFieldFixed);
e.preventDefault(); e.preventDefault();
closeModal(); closeModal();
emit("onOk"); emit("onOk");
@ -249,8 +249,8 @@ onMounted(async () => {
fix: v.isrequired == 2, fix: v.isrequired == 2,
checked: checked:
v.isrequired == 2 || v.isrequired == 2 ||
Boolean(userFieldFixed.find(v2=>v2==v.name)) || Boolean(userFieldFixed?.find(v2=>v2==v.name)) ||
Boolean(userFieldUnFixed.find(v2=>v2==v.name)) Boolean(userFieldUnFixed?.find(v2=>v2==v.name))
}; };
if (item.fix) { if (item.fix) {
fixList.value.push(item); fixList.value.push(item);

@ -10,7 +10,7 @@ const props = defineProps({
default: () => 3, default: () => 3,
require: true, require: true,
}, },
}) });
onMounted(async () => { onMounted(async () => {
const userStore = useUser(); const userStore = useUser();
const userInfo = userStore.getUserInfo; const userInfo = userStore.getUserInfo;
@ -25,7 +25,8 @@ onMounted(async () => {
* fix 是否默认 * fix 是否默认
* checked 是否选中 * checked 是否选中
*/ */
const userFieldFixed = useList.userFieldFixed?.split(",");
const userFieldUnFixed = useList.userFieldUnFixed?.split(",");
allList.map((v) => { allList.map((v) => {
let item = { let item = {
name: v.fieldDesc, name: v.fieldDesc,
@ -33,10 +34,10 @@ onMounted(async () => {
fix: v.isrequired == 2, fix: v.isrequired == 2,
checked: checked:
v.isrequired == 2 || v.isrequired == 2 ||
Boolean(useList.userFieldFixed?.indexOf(v.name)>-1) || Boolean(useList.userFieldUnFixed?.indexOf(v.name)>-1), Boolean(userFieldFixed?.find(v2=>v2==v.name)) ||
Boolean(userFieldUnFixed?.find(v2=>v2==v.name))
}; };
offList.value.push(item) offList.value.push(item);
}); });
}); });
@ -95,7 +96,7 @@ function showModal() {
function closeModal() { function closeModal() {
show.value = false; show.value = false;
} }
const emit = defineEmits(['onOk']) const emit = defineEmits(["onOk"]);
async function handleSumbit(e: MouseEvent) { async function handleSumbit(e: MouseEvent) {
const userStore = useUser(); const userStore = useUser();
@ -110,8 +111,7 @@ async function handleSumbit(e: MouseEvent) {
savefield(props.reviewType, userInfo.id, userField); savefield(props.reviewType, userInfo.id, userField);
e.preventDefault(); e.preventDefault();
closeModal(); closeModal();
emit('onOk') emit("onOk");
} }
defineExpose({ defineExpose({
@ -143,11 +143,6 @@ function onCheckChange(checked: any, item: any) {
if (index === -1 && checked) selectIds.value.push(item.id); if (index === -1 && checked) selectIds.value.push(item.id);
else selectIds.value.splice(index, 1); else selectIds.value.splice(index, 1);
} }
</script> </script>
<template> <template>
@ -172,7 +167,7 @@ function onCheckChange(checked: any, item: any) {
> >
<div> <div>
<div class="draggable-ul"> <div class="draggable-ul">
<div class="draggable-li" style="background: #f8f8f8;"> <div class="draggable-li" style="background: #f8f8f8">
<n-checkbox <n-checkbox
v-model:checked="checkAll" v-model:checked="checkAll"
label="全部" label="全部"
@ -281,7 +276,6 @@ function onCheckChange(checked: any, item: any) {
.draggable-li { .draggable-li {
padding: 10px 16px; padding: 10px 16px;
color: #333; color: #333;
} }
.draggable-item { .draggable-item {

@ -1,91 +1,154 @@
<script lang="ts" setup> <script lang="ts" setup>
import { debounce } from 'lodash-es' import { debounce } from "lodash-es";
import { computed, defineOptions, nextTick, onMounted, ref, unref, watch } from 'vue' import {
import CustomFieldModalVue from '../modal/CustomFieldModal.vue' computed,
import WorkSheetList from './WorkSheetList.vue' defineOptions,
import { getViewportOffset } from '@/utils/domUtils' nextTick,
import { useWorkOrder } from '@/store/modules/workOrder' onMounted,
import { useWindowSizeFn } from '@/hooks/event/useWindowSizeFn' ref,
unref,
watch,
} from "vue";
import CustomFieldModalVue from "../modal/CustomFieldModal.vue";
import WorkSheetList from "./WorkSheetList.vue";
import { getViewportOffset } from "@/utils/domUtils";
import { useWorkOrder } from "@/store/modules/workOrder";
import { useWindowSizeFn } from "@/hooks/event/useWindowSizeFn";
import { useUser } from "@/store/modules/user";
import { getAllfieldList, getfieldList, savefield } from "@/api/home/filter";
defineOptions({ name: "AsideContent" });
defineOptions({ name: 'AsideContent' }) const collapse = ref(false);
const workStore = useWorkOrder();
const collapse = ref(false) const filterModalRef = ref(null);
const workStore = useWorkOrder() const packageListRef = ref<HTMLDivElement | null>(null);
const filterModalRef = ref(null) //
const packageListRef = ref<HTMLDivElement | null>(null) const showFieldList = ref<any[]>([]);
const reviewType = 1;
function collapseHandler() { function collapseHandler() {
collapse.value = !collapse.value collapse.value = !collapse.value;
} }
const asideWidth = computed(() => { const asideWidth = computed(() => {
return collapse.value ? 0 : 308 return collapse.value ? 0 : 308;
}) });
const asideStyle = computed(() => { const asideStyle = computed(() => {
return { return {
width: `${asideWidth.value}px`, width: `${asideWidth.value}px`,
} };
}) });
const collapseIcon = computed(() => { const collapseIcon = computed(() => {
return collapse.value ? 'expand-cir' : 'collapse-cir' return collapse.value ? "expand-cir" : "collapse-cir";
}) });
const listHeight = ref(700) const listHeight = ref(700);
function computeListHeight() { function computeListHeight() {
const listEl = document.querySelector('.work-sheet-list')! const listEl = document.querySelector(".work-sheet-list")!;
const { bottomIncludeBody } = getViewportOffset(listEl) const { bottomIncludeBody } = getViewportOffset(listEl);
const height = bottomIncludeBody const height = bottomIncludeBody;
listHeight.value = height - 25 listHeight.value = height - 25;
} }
const listStyle = computed(() => { const listStyle = computed(() => {
return { return {
height: `${listHeight.value}px`, height: `${listHeight.value}px`,
} };
}) });
useWindowSizeFn(computeListHeight, 280);
useWindowSizeFn(computeListHeight, 280) async function getshowFieldList() {
showFieldList.value = [];
const userStore = useUser();
const userInfo = userStore.getUserInfo;
let res;
res = await getAllfieldList(reviewType); //
const allList = res.data;
res = await getfieldList(reviewType, userInfo.id); //
const useList = res.data;
/**
* name 标题
* id 键值
* fix 是否默认
* checked 是否选中
*/
if (useList.userFieldFixed) {
useList.userFieldFixed?.split(",").map((v) => {
let item = allList.find((v2) => v2.name == v);
if (item) {
item = {
name: item.fieldDesc,
id: item.name,
fix: item.isrequired == 2,
checked: true,
};
showFieldList.value.push(item);
}
});
} else {
//
allList.map((v) => {
if (v.isrequired == 2) {
let item = {
name: v.fieldDesc,
id: v.name,
fix: v.isrequired == 2,
checked: true,
};
showFieldList.value.push(item);
}
});
}
}
onMounted(() => { onMounted(() => {
nextTick(() => { nextTick(() => {
computeListHeight() computeListHeight();
}) getshowFieldList();
}) });
});
const asideEnter = ref(false) const asideEnter = ref(false);
const showCollapse = computed(() => { const showCollapse = computed(() => {
return collapse.value ? true : asideEnter.value return collapse.value ? true : asideEnter.value;
}) });
function showFilter() { function showFilter() {
const modal = unref(filterModalRef)! as any const modal = unref(filterModalRef)! as any;
modal.showModal() modal.showModal();
} }
watch(() => workStore.immersion, () => { watch(
collapse.value = true () => workStore.immersion,
}) () => {
collapse.value = true;
}
);
const showSearch = ref(false) const showSearch = ref(false);
function setShowSearch(value: boolean) { function setShowSearch(value: boolean) {
showSearch.value = value showSearch.value = value;
if (value === false) if (value === false) (packageListRef.value as any).search("");
(packageListRef.value as any).search('')
} }
const inputHandler = debounce((word) => { const inputHandler = debounce((word) => {
(packageListRef.value as any).search(word) (packageListRef.value as any).search(word);
}, 500) }, 500);
</script> </script>
<template> <template>
<div class="aside" :style="asideStyle" @mouseenter="asideEnter = true" @mouseleave="asideEnter = false"> <div
class="aside"
:style="asideStyle"
@mouseenter="asideEnter = true"
@mouseleave="asideEnter = false"
>
<div v-show="showCollapse" class="aside-collapse"> <div v-show="showCollapse" class="aside-collapse">
<div class="aside-collapse-btn" @click="collapseHandler"> <div class="aside-collapse-btn" @click="collapseHandler">
<SvgIcon :name="collapseIcon" size="40" /> <SvgIcon :name="collapseIcon" size="40" />
@ -95,27 +158,51 @@ const inputHandler = debounce((word) => {
<div v-show="!showSearch" class="warpper"> <div v-show="!showSearch" class="warpper">
<div class="left"> <div class="left">
<svg-icon name="all-worksheet" size="32" /> <svg-icon name="all-worksheet" size="32" />
<span style="margin-left: 8px;">所有工单</span> <span style="margin-left: 8px">所有工单</span>
</div> </div>
<div class="right"> <div class="right">
<SvgIcon <SvgIcon
style="cursor: pointer;margin-left: 10px;" size="18" name="magnifying-1" style="cursor: pointer; margin-left: 10px"
size="18"
name="magnifying-1"
@click="setShowSearch(true)" @click="setShowSearch(true)"
/> />
<SvgIcon style="cursor: pointer;margin-left: 10px;" size="18" name="filter" @click="showFilter" /> <SvgIcon
style="cursor: pointer; margin-left: 10px"
size="18"
name="filter"
@click="showFilter"
/>
</div> </div>
</div> </div>
<div v-show="showSearch" class="warpper"> <div v-show="showSearch" class="warpper">
<n-input style="flex: 1;height: 32px;" placeholder="请输入你需要搜索的内容" @input="inputHandler"> <n-input
style="flex: 1; height: 32px"
placeholder="请输入你需要搜索的内容"
@input="inputHandler"
>
<template #suffix> <template #suffix>
<SvgIcon size="14px" name="magnifying-1" /> <SvgIcon size="14px" name="magnifying-1" />
</template> </template>
</n-input> </n-input>
<SvgIcon size="16px" style="margin-left: 6px;cursor: pointer;" name="clear" @click="setShowSearch(false)" /> <SvgIcon
size="16px"
style="margin-left: 6px; cursor: pointer"
name="clear"
@click="setShowSearch(false)"
/>
</div> </div>
</div> </div>
<WorkSheetList ref="packageListRef" class="work-sheet-list" /> <WorkSheetList
<CustomFieldModalVue ref="filterModalRef" :review-type="1" /> ref="packageListRef"
class="work-sheet-list"
:showFieldList="showFieldList"
/>
<CustomFieldModalVue
ref="filterModalRef"
:review-type="1"
@onOk="getshowFieldList"
/>
</div> </div>
</template> </template>
@ -124,7 +211,7 @@ const inputHandler = debounce((word) => {
display: flex; display: flex;
position: relative; position: relative;
flex-direction: column; flex-direction: column;
background: #FFF; background: #fff;
border: 1px solid rgb(239, 239, 245); border: 1px solid rgb(239, 239, 245);
border-radius: 3px; border-radius: 3px;
box-sizing: border-box; box-sizing: border-box;

@ -1,8 +1,8 @@
<script lang="ts" setup> <script lang="ts" setup>
import { computed } from 'vue' import { computed } from "vue";
import type { PackageListItem } from '/#/workorder' import type { PackageListItem } from "/#/workorder";
defineOptions({ name: 'ListItem' }) defineOptions({ name: "ListItem" });
const props = defineProps({ const props = defineProps({
selected: { selected: {
@ -13,16 +13,41 @@ const props = defineProps({
type: Object as PropType<PackageListItem>, type: Object as PropType<PackageListItem>,
required: true, required: true,
}, },
}) showFieldList: {
type: Array,
default: () => [],
},
});
console.log(props.listItem,'listItem')
const svgName = computed(() => { const svgName = computed(() => {
return props.selected ? 'taskpack-select' : 'taskpack' return props.selected ? "taskpack-select" : "taskpack";
}) });
</script> </script>
<template> <template>
<div class="list-item" :class="{ 'list-item-selected': selected }"> <div class="list-item" :class="{ 'list-item-selected': selected }">
<div class="list-item-header"> <div v-for="(item, index) in showFieldList" :key="index">
<div class="list-item-header" v-if="item.id == 'packagename'">
<div style="display: flex">
<SvgIcon :name="svgName" size="28" />
<span
class="list-item-header-name"
:class="{ 'list-item-header-selected': selected }"
>
{{ listItem.packagename }}
</span>
<span class="list-item-header-selected"
>({{ listItem.pictureno }})</span
>
</div>
<SvgIcon v-show="selected" size="14" name="more-ver" />
</div>
<ul class="list-item-detail" v-else>
{{ item.name }}{{ listItem[item.id] }}
</ul>
</div>
<!-- <div class="list-item-header">
<div style="display: flex;"> <div style="display: flex;">
<SvgIcon :name="svgName" size="28" /> <SvgIcon :name="svgName" size="28" />
<span class="list-item-header-name" :class="{ 'list-item-header-selected': selected }"> <span class="list-item-header-name" :class="{ 'list-item-header-selected': selected }">
@ -31,11 +56,11 @@ const svgName = computed(() => {
<span class="list-item-header-selected">({{ listItem.pictureno }})</span> <span class="list-item-header-selected">({{ listItem.pictureno }})</span>
</div> </div>
<SvgIcon v-show="selected" size="14" name="more-ver" /> <SvgIcon v-show="selected" size="14" name="more-ver" />
</div> </div> -->
<ul class="list-item-detail"> <!-- <ul class="list-item-detail">
<li>筛选时间{{ listItem.createTime }}</li> <li>筛选时间{{ listItem.createTime }}</li>
<li>执行人{{ listItem.createBy }}</li> <li>执行人{{ listItem.createBy }}</li>
</ul> </ul> -->
</div> </div>
</template> </template>
@ -58,7 +83,7 @@ const svgName = computed(() => {
} }
&-selected { &-selected {
color: #507AFD; color: #507afd;
} }
} }
@ -84,7 +109,6 @@ const svgName = computed(() => {
position: absolute; position: absolute;
bottom: 0px; bottom: 0px;
} }
} }
</style> </style>
../types ../types

@ -1,99 +1,113 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useWorkOrder } from '@/store/modules/workOrder' import { useWorkOrder } from "@/store/modules/workOrder";
import { isEmpty } from '@/utils' import { isEmpty } from "@/utils";
import { useInfiniteScroll } from '@vueuse/core' import { useInfiniteScroll } from "@vueuse/core";
import { reactive, ref, watch } from 'vue' import { reactive, ref, watch } from "vue";
import ListItem from './ListItem.vue' import ListItem from "./ListItem.vue";
import type { PackageListItem } from '/#/workorder' import type { PackageListItem } from "/#/workorder";
const workStore = useWorkOrder() const workStore = useWorkOrder();
const data = ref<PackageListItem[]>([]) const data = ref<PackageListItem[]>([]);
const activeId = ref('') const activeId = ref("");
const el = ref<HTMLDivElement | null>(null) const el = ref<HTMLDivElement | null>(null);
const keyword = ref('') const keyword = ref("");
const canloadMore = ref(true) const canloadMore = ref(true);
defineProps({
showFieldList: {
type: Array,
default: () => [],
},
});
const pagination = reactive({ const pagination = reactive({
pageNo: 0, pageNo: 0,
pageSize: 10, pageSize: 10,
}) });
function selectHandler(id: string, index: number) { function selectHandler(id: string, index: number) {
workStore.setActive(index) workStore.setActive(index);
} }
const { isLoading } = useInfiniteScroll( const { isLoading } = useInfiniteScroll(
el as any, el as any,
() => { () => {
loadMore() loadMore();
}, },
{ distance: 10, interval: 800, canLoadMore: () => { {
distance: 10,
interval: 800,
canLoadMore: () => {
// console.log('canloadmore excuted!') // console.log('canloadmore excuted!')
return canloadMore.value return canloadMore.value;
} }, },
) }
);
async function loadMore() { async function loadMore() {
if (isLoading.value || el.value == null) if (isLoading.value || el.value == null) return;
return
// console.log('loadmore') // console.log('loadmore')
const more = await fetchList() const more = await fetchList();
data.value.push(...more) data.value.push(...more);
} }
async function fetchList() { async function fetchList() {
try { try {
pagination.pageNo += 1 pagination.pageNo += 1;
const result = await workStore.fetchOrderList(pagination, keyword.value) const result = await workStore.fetchOrderList(pagination, keyword.value);
const { data, pageCount } = result const { data, pageCount } = result;
canloadMore.value = pageCount >= pagination.pageNo && pageCount !== 0 canloadMore.value = pageCount >= pagination.pageNo && pageCount !== 0;
return data || [] return data || [];
} } catch (error) {
catch (error) { canloadMore.value = false;
canloadMore.value = false return [];
return []
} }
} }
watch(() => workStore.activeId, (newVal) => { watch(
if (isEmpty(newVal)) () => workStore.activeId,
return (newVal) => {
if (isEmpty(newVal)) return;
activeId.value = newVal activeId.value = newVal;
}) }
);
function reset() { function reset() {
pagination.pageNo = 0 pagination.pageNo = 0;
pagination.pageSize = 10 pagination.pageSize = 10;
canloadMore.value = true canloadMore.value = true;
data.value.length = 0 data.value.length = 0;
workStore.reset() workStore.reset();
} }
async function search(word: string) { async function search(word: string) {
keyword.value = word keyword.value = word;
reset() reset();
useInfiniteScroll( useInfiniteScroll(
el as any, el as any,
() => { () => {
loadMore() loadMore();
}, },
{ distance: 10, canLoadMore: () => canloadMore.value }, { distance: 10, canLoadMore: () => canloadMore.value }
) );
} }
defineExpose({ defineExpose({
search, search,
}) });
</script> </script>
<template> <template>
<n-spin :show="isLoading"> <n-spin :show="isLoading">
<div ref="el" class="list"> <div ref="el" class="list">
<ListItem <ListItem
v-for="(item, index) in data" :key="item.id" :selected="activeId === item.id" :list-item="item" v-for="(item, index) in data"
:key="item.id"
:selected="activeId === item.id"
:list-item="item"
:showFieldList="showFieldList"
@click="selectHandler(item.id, index)" @click="selectHandler(item.id, index)"
/> />
</div> </div>

@ -0,0 +1,486 @@
//
<script lang="ts" setup>
import { getAllfieldList, getfieldList, savefield } from "@/api/home/filter";
import { workPackageMap } from "@/config/workorder";
import { useUser } from "@/store/modules/user";
import { difference } from "lodash-es";
import { computed, defineEmits, defineProps, onMounted, ref, watch } from "vue";
import { VueDraggable } from "vue-draggable-plus";
const props = defineProps({
reviewType: {
type: Number,
default: () => 1,
require: true,
},
});
const emit = defineEmits(["onOk"]);
//
const offList = ref<any[]>([]);
//
const onList = ref<any[]>([]);
const fixList = ref<any[]>([]);
const allCount = computed(() => {
return `全部筛选(共${offList.value.length - 1}个)`;
});
const selectCount = computed(() => {
return `全部筛选(共${onList.value.length}个)`;
});
function generatList() {
const keys = Object.keys(workPackageMap);
let showList: object[] = [];
const hideList: object[] = [];
const showStr = "status";
const showKeys = showStr.split(",").map((key: string) => key.toLowerCase());
for (const key of keys) {
const name = workPackageMap[key]?.label;
const isDefault = workPackageMap[key]?.isDefault;
// Y
if (!isDefault) {
hideList.push({
id: key,
name: name || "未配置",
fix: isDefault,
checked: workPackageMap[key].isDefault,
});
}
}
showList = showKeys.reduce((acc, key) => {
const config = {
id: key,
name: workPackageMap[key].label || "未配置",
fix: workPackageMap[key].isDefault,
};
return [...acc, config];
}, []);
const fixedList = generateDefaultList();
hideList.unshift(...fixedList);
showList.unshift(...fixedList);
onList.value = showList;
offList.value = hideList;
return { showList, hideList };
}
function generateDefaultList() {
return Object.keys(workPackageMap).reduce((acc, key) => {
const { label, isDefault } = workPackageMap[key];
if (isDefault) {
const config = {
id: key,
name: label || "未配置",
fix: true,
checked: true,
};
return [...acc, config];
} else {
return acc;
}
}, []);
}
const show = ref(false);
const checkAll = ref(false);
function showModal() {
show.value = true;
}
function closeModal() {
show.value = false;
}
async function handleSumbit(e: MouseEvent) {
const userStore = useUser();
const userInfo = userStore.getUserInfo;
let userField = "";
onList.value.map((v) => {
userField += `${v.id},`;
});
userField = userField.slice(0, userField.length - 1);
savefield(props.reviewType, userInfo.id, userField);
e.preventDefault();
closeModal();
emit("onOk");
}
defineExpose({
showModal,
});
// generatList();
const selectIds = ref<string[]>([]);
function onCheckAllChange(value) {
const ids: string[] = [];
for (const item of offList.value) {
if (!item.fix) {
item.checked = value;
ids.push(item.id);
}
}
selectIds.value = value ? ids : [];
}
function onCheckChange(checked: any, item: any) {
const index = selectIds.value.indexOf(item.id);
item.checked = checked;
if (index === -1 && checked) selectIds.value.push(item.id);
else selectIds.value.splice(index, 1);
}
const showIds = computed(() => {
return onList.value.map((item) => {
return item.id;
});
});
watch(
() => selectIds.value.length,
(newVal, oldVal) => {
if (newVal === oldVal) return;
const action = newVal > oldVal ? "add" : "remove";
const diff =
action === "add"
? difference(selectIds.value, showIds.value)
: difference(showIds.value, selectIds.value);
if (diff.length === 0) return;
if (action === "add") {
for (const item of offList.value) {
if (!item.fix && diff.includes(item.id)) {
onList.value.push({
id: item.id,
name: item.name || "未配置",
fix: item.fix || false,
});
}
}
} else {
const list = onList.value;
for (let index = 0; index < list.length; index++) {
const item = list[index];
if (!item.fix && diff.includes(item.id)) {
list.splice(index, 1);
index--;
}
}
}
}
);
watch(
() => showIds.value.length,
(newVal, oldVal) => {
if (newVal === oldVal) return;
const diff = difference(selectIds.value, showIds.value);
if (diff.length === 0) return;
for (const item of offList.value) {
if (!item.fix && diff.includes(item.id)) {
const index = selectIds.value.indexOf(item.id);
item.checked = false;
selectIds.value.splice(index, 1);
}
}
}
);
function clearDragSource() {
onList.value = onList.value.filter((item) => {
return item.fix === true;
});
}
function removeHandler(id: string) {
const index = onList.value.findIndex((item) => {
return item.id === id;
});
if (index !== -1) onList.value.splice(index, 1);
}
onMounted(async () => {
const userStore = useUser();
const userInfo = userStore.getUserInfo;
let res;
res = await getAllfieldList(props.reviewType); //
const allList = res.data;
res = await getfieldList(props.reviewType, userInfo.id); //
const useList = res.data;
/**
* name 标题
* id 键值
* fix 是否默认
* checked 是否选中
*/
const userFieldFixed = useList.userFieldFixed?.split(",");
const userFieldUnFixed = useList.userFieldUnFixed?.split(",");
allList.map((v) => {
let item = {
name: v.fieldDesc,
id: v.name,
fix: v.isrequired == 2,
checked:
v.isrequired == 2 ||
Boolean(userFieldFixed?.find((v2) => v2 == v.name)) ||
Boolean(userFieldUnFixed?.find((v2) => v2 == v.name)),
};
if (item.fix) {
fixList.value.push(item);
} else {
offList.value.push(item);
}
});
offList.value.unshift(...fixList.value);
useList.userFieldFixed?.split(",").map((v) => {
let item = allList.find((v2) => v2.name == v);
if (item) {
item = {
name: item.fieldDesc,
id: item.name,
fix: item.isrequired == 2,
checked: true,
};
onList.value.push(item);
}
});
if (!onList.value.length) {
onList.value.push(...fixList.value);
}
});
</script>
<template>
<n-modal v-model:show="show" transform-origin="center">
<n-card
class="cardstyle"
:bordered="false"
size="huge"
role="dialog"
aria-modal="true"
>
<div class="wrapper">
<span class="wrapper-title">自定义任务包字段</span>
<div class="wrapper-bar">
<div class="wrapper-info">
<span :style="{ 'margin-left': '18px' }">字段信息</span>
</div>
</div>
<n-grid cols="4" class="mt-4 proCard" responsive="screen" :x-gap="24">
<n-grid-item span="3">
<NCard
:title="allCount"
class="dragcardStyle"
:segmented="{ content: true, footer: true }"
size="small"
:bordered="false"
>
<div>
<n-input placeholder="搜索关键字">
<template #suffix>
<SvgIcon size="14px" name="magnifying-1" />
</template>
</n-input>
<div class="draggable-ul">
<div class="draggable-li">
<n-checkbox
v-model:checked="checkAll"
label="全部"
@update:checked="onCheckAllChange"
/>
</div>
<div class="content">
<div
v-for="item in offList"
:key="item.id"
style="width: 170px"
:class="{ 'disable-check': item.fix }"
class="draggable-li"
>
<n-checkbox
v-model:checked="item.checked"
:label="item.name"
:disabled="item.fix"
@update:checked="onCheckChange($event, item)"
/>
</div>
</div>
</div>
</div>
</NCard>
</n-grid-item>
<n-grid-item>
<NCard
:title="selectCount"
class="dragcardStyle"
:segmented="{ content: true, footer: true }"
size="small"
:bordered="false"
>
<template #header-extra>
<span class="textbtnStyle" @click="clearDragSource"></span>
</template>
<div>
<n-input placeholder="搜索关键字">
<template #suffix>
<SvgIcon size="14px" name="magnifying-1" />
</template>
</n-input>
<VueDraggable
v-model="onList"
class="draggable-ul"
:animation="150"
group="shared"
>
<div
v-for="item in onList"
:key="item.id"
:class="{ fix: item.fix }"
class="cursor-move draggable-item"
>
<span class="ml-2">{{ item.name }}</span>
<SvgIcon
v-if="!item.fix"
size="16px"
style="display: block; margin-left: auto; cursor: pointer"
name="clear"
@click="removeHandler(item.id)"
/>
</div>
</VueDraggable>
</div>
</NCard>
</n-grid-item>
</n-grid>
</div>
<template #footer>
<div class="wrapper-footer">
<n-button type="info" @click="handleSumbit"> </n-button>
<n-button secondary style="margin-left: 15px" @click="closeModal">
取消
</n-button>
</div>
</template>
</n-card>
</n-modal>
</template>
<style lang="less" scoped>
.wrapper {
display: flex;
flex-direction: column;
&-title {
font-weight: bold;
font-size: 16px;
}
&-bar {
background-color: #e8e8e8;
width: 100%;
margin-top: 20px;
}
&-footer {
display: flex;
justify-content: flex-end;
}
&-info {
font-weight: bold;
position: relative;
&:before {
background-color: #1980ff;
content: "";
width: 5px;
border-radius: 2px;
top: 0;
bottom: 0;
position: absolute;
}
}
}
.dragcardStyle {
--n-padding-bottom: 0px !important;
--n-padding-left: 0px !important;
}
.cardstyle {
width: 820px;
--n-padding-bottom: 20px;
--n-padding-left: 24px;
}
.textbtnStyle {
cursor: pointer;
color: #1980ff;
}
.draggable-ul {
width: 100%;
overflow: hidden;
border: 1px solid #cad2dd;
border-top: 0px;
border-radius: 2px;
display: block;
.content {
display: flex;
flex-wrap: wrap;
}
.draggable-li {
padding: 10px 16px;
color: #333;
}
.draggable-item {
padding: 10px 16px;
color: #333;
display: flex;
align-items: center;
}
.disable-check {
color: gainsboro;
}
}
::v-deep(
.n-card.n-card--content-segmented > .n-card__content:not(:first-child)
) {
border: 0px;
}
::v-deep(.n-card > .n-card-header) {
--n-padding-top: 0px;
--n-padding-bottom: 12px;
}
</style>

@ -20,7 +20,7 @@ const emit = defineEmits(["onOk"]);
const offList = ref<any[]>([]); const offList = ref<any[]>([]);
// //
const onList = ref<any[]>([]); const onList = ref<any[]>([]);
//
const fixList = ref<any[]>([]); const fixList = ref<any[]>([]);
const allCount = computed(() => { const allCount = computed(() => {
@ -105,6 +105,9 @@ async function handleSumbit(e: MouseEvent) {
const userStore = useUser(); const userStore = useUser();
const userInfo = userStore.getUserInfo; const userInfo = userStore.getUserInfo;
let userField = ""; let userField = "";
fixList.value.map((v) => {
userField += `${v.id},`;
});
onList.value.map((v) => { onList.value.map((v) => {
userField += `${v.id},`; userField += `${v.id},`;
}); });
@ -213,11 +216,13 @@ function clearDragSource() {
} }
function removeHandler(id: string) { function removeHandler(id: string) {
const index = onList.value.findIndex((item) => { let index = onList.value.findIndex((item) => {
return item.id === id; return item.id === id;
}); });
if (index !== -1) onList.value.splice(index, 1); if (index !== -1) onList.value.splice(index, 1);
index = offList.value.findIndex(v=>v.id==id);
offList.value[index].checked = false;
} }
onMounted(async () => { onMounted(async () => {
@ -228,7 +233,6 @@ onMounted(async () => {
const allList = res.data; const allList = res.data;
res = await getfieldList(props.reviewType, userInfo.id); // res = await getfieldList(props.reviewType, userInfo.id); //
const useList = res.data; const useList = res.data;
/** /**
* name 标题 * name 标题
* id 键值 * id 键值
@ -237,6 +241,7 @@ onMounted(async () => {
*/ */
const userFieldFixed = useList.userFieldFixed?.split(","); const userFieldFixed = useList.userFieldFixed?.split(",");
const userFieldUnFixed = useList.userFieldUnFixed?.split(","); const userFieldUnFixed = useList.userFieldUnFixed?.split(",");
allList.map((v) => { allList.map((v) => {
let item = { let item = {
name: v.fieldDesc, name: v.fieldDesc,
@ -244,8 +249,8 @@ onMounted(async () => {
fix: v.isrequired == 2, fix: v.isrequired == 2,
checked: checked:
v.isrequired == 2 || v.isrequired == 2 ||
Boolean(userFieldFixed.find((v2) => v2 == v.name)) || Boolean(userFieldFixed?.find(v2=>v2==v.name)) ||
Boolean(userFieldUnFixed.find((v2) => v2 == v.name)), Boolean(userFieldUnFixed?.find(v2=>v2==v.name))
}; };
if (item.fix) { if (item.fix) {
fixList.value.push(item); fixList.value.push(item);
@ -263,13 +268,15 @@ onMounted(async () => {
fix: item.isrequired == 2, fix: item.isrequired == 2,
checked: true, checked: true,
}; };
selectIds.value.push(item.id);
if (!item.fix) {
onList.value.push(item); onList.value.push(item);
} }
});
if (!onList.value.length) {
onList.value.push(...fixList.value);
} }
}); });
console.log(offList.value,'offList.value');
console.log(useList, 'useList');
});
</script> </script>
<template> <template>
@ -348,6 +355,16 @@ onMounted(async () => {
<SvgIcon size="14px" name="magnifying-1" /> <SvgIcon size="14px" name="magnifying-1" />
</template> </template>
</n-input> </n-input>
<div class="draggable-ul">
<div
v-for="item in fixList"
:key="item.id"
:class="{ fix: item.fix }"
class="cursor-move draggable-item"
>
<span class="ml-2">{{ item.name }}</span>
</div>
</div>
<VueDraggable <VueDraggable
v-model="onList" v-model="onList"
class="draggable-ul" class="draggable-ul"

Loading…
Cancel
Save