feat: 修改bug

pull/168/head
raofuzi 1 year ago
commit 00ec4dd402

11
components.d.ts vendored

@ -10,23 +10,12 @@ declare module 'vue' {
Application: typeof import('./src/components/Application/Application.vue')['default']
BasicModal: typeof import('./src/components/Modal/BasicModal.vue')['default']
DataHeader: typeof import('./src/components/DataHeader/index.vue')['default']
NAvatar: typeof import('naive-ui')['NAvatar']
NButton: typeof import('naive-ui')['NButton']
NCard: typeof import('naive-ui')['NCard']
NCheckbox: typeof import('naive-ui')['NCheckbox']
NCollapse: typeof import('naive-ui')['NCollapse']
NCollapseItem: typeof import('naive-ui')['NCollapseItem']
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
NDatePicker: typeof import('naive-ui')['NDatePicker']
NDialogProvider: typeof import('naive-ui')['NDialogProvider']
NDivider: typeof import('naive-ui')['NDivider']
NDropdown: typeof import('naive-ui')['NDropdown']
NForm: typeof import('naive-ui')['NForm']
NFormItem: typeof import('naive-ui')['NFormItem']
NGi: typeof import('naive-ui')['NGi']
NGrid: typeof import('naive-ui')['NGrid']
NGridItem: typeof import('naive-ui')['NGridItem']
NImage: typeof import('naive-ui')['NImage']
NInput: typeof import('naive-ui')['NInput']
NMessageProvider: typeof import('naive-ui')['NMessageProvider']
NModal: typeof import('naive-ui')['NModal']

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 1.2 MiB

File diff suppressed because it is too large Load Diff

@ -1,6 +1,6 @@
<script lang="ts" setup>
import { ref, watch } from "vue";
import * as XLSX from 'xlsx';
import * as XLSX from "xlsx";
defineProps({
data: {
@ -12,13 +12,13 @@ defineProps({
default: () => [[]],
},
});
const emit = defineEmits(["showModal","getrowValue"]);
const emit = defineEmits(["showModal", "getrowValue"]);
function showActionsModal() {
emit("showModal");
}
function getrowvalue(row){
emit("getrowValue",row);
function getrowvalue(row) {
emit("getrowValue", row);
}
</script>
@ -37,13 +37,27 @@ function getrowvalue(row){
<th v-if="item && item[0]">
{{ item[0].label }}
</th>
<td v-if="item && item[0]" :class="item[0].blue ? 'blue' : ''" @click="getrowvalue(item[0])">
<td
v-if="item && item[0]"
:class="item[0].blue ? 'blue' : ''"
@click="getrowvalue(item[0])"
>
<span v-show="item[0].label == '定位信息'">
<SvgIcon class="icon" size="16" name="lctname"
/></span>
{{ item[0].value }}
</td>
<th v-if="item && item.length > 1">
{{ item[1].label }}
</th>
<td v-if="item && item.length > 1" :class="item[1].blue ? 'blue' : ''" @click="getrowvalue(item[1])">
<td
v-if="item && item.length > 1"
:class="item[1].blue ? 'blue' : ''"
@click="getrowvalue(item[1])"
>
<span v-show="item[1].label == '定位信息'">
<SvgIcon class="icon" size="16" name="lctname" />
</span>
{{ item[1].value }}
</td>
</tr>

@ -32,6 +32,9 @@ function setAsideItemName(text) {
:deep(.wrapper){
top:0
}
:deep(.ip_box){
z-index: 105;
}
.main {
display: flex;
flex-direction: row;

@ -1,10 +1,12 @@
<script lang="ts" setup>
import { cloneDeep, difference } from 'lodash-es'
import { computed, defineEmits, defineProps, onMounted, ref, watch } from 'vue'
import { VueDraggable } from 'vue-draggable-plus'
import { getAllfieldList, getfieldList, savefield } from '@/api/home/filter'
import { workPackageMap } from '@/config/workorder'
import { useUser } from '@/store/modules/user'
import { cloneDeep, difference } from "lodash-es";
import { computed, defineEmits, defineProps, onMounted, ref, watch } from "vue";
import { VueDraggable } from "vue-draggable-plus";
import { getAllfieldList, getfieldList, savefield } from "@/api/home/filter";
import { workPackageMap } from "@/config/workorder";
import { useUser } from "@/store/modules/user";
import { useMessage } from "naive-ui";
const message = useMessage();
const props = defineProps({
reviewType: {
@ -12,355 +14,344 @@ const props = defineProps({
default: () => 1,
require: true,
},
})
});
const emit = defineEmits(['onOk'])
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 offShowList = ref<any[]>([])
const onShowList = ref<any[]>([])
const fixShowList = ref<any[]>([])
const offShowList = ref<any[]>([]);
const onShowList = ref<any[]>([]);
const fixShowList = ref<any[]>([]);
const allCount = computed(() => {
return `全部字段(共${offList.value.length - 1}个)`
})
return `全部字段(共${offList.value.length - 1}个)`;
});
const selectCount = computed(() => {
return `显示字段(共${onList.value.length}个)`
})
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())
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
const name = workPackageMap[key]?.label;
const isDefault = workPackageMap[key]?.isDefault;
// Y
if (!isDefault) {
hideList.push({
id: key,
name: name || '未配置',
name: name || "未配置",
fix: isDefault,
checked: workPackageMap[key].isDefault,
})
});
}
}
showList = showKeys.reduce((acc, key) => {
const config = {
id: key,
name: workPackageMap[key].label || '未配置',
name: workPackageMap[key].label || "未配置",
fix: workPackageMap[key].isDefault,
}
return [...acc, config]
}, [])
};
return [...acc, config];
}, []);
const fixedList = generateDefaultList()
const fixedList = generateDefaultList();
hideList.unshift(...fixedList)
showList.unshift(...fixedList)
hideList.unshift(...fixedList);
showList.unshift(...fixedList);
onList.value = showList
offList.value = hideList
return { showList, hideList }
onList.value = showList;
offList.value = hideList;
return { showList, hideList };
}
function generateDefaultList() {
return Object.keys(workPackageMap).reduce((acc, key) => {
const { label, isDefault } = workPackageMap[key]
const { label, isDefault } = workPackageMap[key];
if (isDefault) {
const config = {
id: key,
name: label || '未配置',
name: label || "未配置",
fix: true,
checked: true,
}
return [...acc, config]
}
else {
return acc
};
return [...acc, config];
} else {
return acc;
}
}, [])
}, []);
}
const show = ref(false)
const show = ref(false);
const checkAll = computed(() => {
let baseNum = 0
let baseNum = 0;
offList.value.map((v) => {
if (v.fix)
baseNum += 1
})
return onList.value.length == offList.value.length - baseNum
})
if (v.fix) baseNum += 1;
});
return onList.value.length == offList.value.length - baseNum;
});
function showModal() {
show.value = true
show.value = true;
}
function closeModal() {
show.value = false
show.value = false;
}
async function handleSumbit(e: MouseEvent) {
const userStore = useUser()
const userInfo = userStore.getUserInfo
let userFieldFixed = ''
const userStore = useUser();
const userInfo = userStore.getUserInfo;
let userFieldFixed = "";
fixList.value.map((v) => {
userFieldFixed += `${v.id},`
})
userFieldFixed += `${v.id},`;
});
onList.value.map((v) => {
userFieldFixed += `${v.id},`
})
userFieldFixed = userFieldFixed.slice(0, userFieldFixed.length - 1)
savefield(props.reviewType, userInfo.id, userFieldFixed)
e.preventDefault()
closeModal()
emit('onOk')
userFieldFixed += `${v.id},`;
});
userFieldFixed = userFieldFixed.slice(0, userFieldFixed.length - 1);
savefield(props.reviewType, userInfo.id, userFieldFixed);
e.preventDefault();
closeModal();
emit("onOk");
}
defineExpose({
showModal,
})
});
// generatList();
const selectIds = ref<string[]>([])
const selectIds = ref<string[]>([]);
function onCheckAllChange(value) {
const ids: string[] = []
const ids: string[] = [];
for (const item of offList.value) {
if (!item.fix) {
item.checked = value
ids.push(item.id)
item.checked = value;
ids.push(item.id);
}
}
for (const item of offShowList.value) {
if (!item.fix)
item.checked = value
if (!item.fix) item.checked = value;
}
selectIds.value = value ? ids : []
selectIds.value = value ? ids : [];
if (value) {
offList.value.map((v) => {
if (!v.checked)
onList.value.push(v)
})
onShowList.value = cloneDeep(onList.value)
}
else {
onList.value = []
onShowList.value = []
if (!v.checked) onList.value.push(v);
});
onShowList.value = cloneDeep(onList.value);
} else {
onList.value = [];
onShowList.value = [];
}
}
function onCheckChange(checked: any, item: any) {
const index = selectIds.value.indexOf(item.id)
item.checked = checked
const currentIndex = offList.value.findIndex(v => v.id == item.id)
offList.value[currentIndex].checked = checked
if (index === -1 && checked)
selectIds.value.push(item.id)
else
selectIds.value.splice(index, 1)
const index = selectIds.value.indexOf(item.id);
if (index == -1 && selectIds.value.length >= 6) {
item.checked = false;
message.error("自定义任务卡片字段一共勾选数量不能超过6个");
return;
}
item.checked = checked;
const currentIndex = offList.value.findIndex((v) => v.id == item.id);
offList.value[currentIndex].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
})
})
return item.id;
});
});
watch(
() => selectIds.value.length,
(newVal, oldVal) => {
if (newVal === oldVal)
return
if (newVal === oldVal) return;
const action = newVal > oldVal ? 'add' : 'remove'
const diff
= action === 'add'
const action = newVal > oldVal ? "add" : "remove";
const diff =
action === "add"
? difference(selectIds.value, showIds.value)
: difference(showIds.value, selectIds.value)
: difference(showIds.value, selectIds.value);
if (diff.length === 0)
return
if (diff.length === 0) return;
if (action === 'add') {
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 || '未配置',
name: item.name || "未配置",
fix: item.fix || false,
})
});
}
}
onShowList.value = cloneDeep(onList.value)
}
else {
const list = onList.value
onShowList.value = cloneDeep(onList.value);
} else {
const list = onList.value;
for (let index = 0; index < list.length; index++) {
const item = list[index]
const item = list[index];
if (!item.fix && diff.includes(item.id)) {
list.splice(index, 1)
onShowList.value.splice(index, 1)
index--
list.splice(index, 1);
onShowList.value.splice(index, 1);
index--;
}
}
console.log(onShowList.value, list, 'onShowList')
console.log(onShowList.value, list, "onShowList");
}
},
)
}
);
watch(
() => showIds.value.length,
(newVal, oldVal) => {
if (newVal === oldVal)
return
if (newVal === oldVal) return;
const diff = difference(selectIds.value, showIds.value)
const diff = difference(selectIds.value, showIds.value);
if (diff.length === 0)
return
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)
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
})
onShowList.value = cloneDeep(onList.value)
return item.fix === true;
});
onShowList.value = cloneDeep(onList.value);
}
function removeHandler(id: string) {
let index = onList.value.findIndex((item) => {
return item.id === id
})
return item.id === id;
});
if (index !== -1) {
onList.value.splice(index, 1)
onShowList.value.splice(index, 1)
onList.value.splice(index, 1);
onShowList.value.splice(index, 1);
}
index = offList.value.findIndex(v => v.id == id)
offList.value[index].checked = false
offShowList.value = cloneDeep(offList.value)
index = offList.value.findIndex((v) => v.id == id);
offList.value[index].checked = false;
offShowList.value = cloneDeep(offList.value);
}
function initData() {
offList.value = []
onList.value = []
fixList.value = []
offShowList.value = []
onShowList.value = []
fixShowList.value = []
selectIds.value = []
offList.value = [];
onList.value = [];
fixList.value = [];
offShowList.value = [];
onShowList.value = [];
fixShowList.value = [];
selectIds.value = [];
}
async function getData(type = '') {
initData()
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
async function getData(type = "") {
initData();
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(',')
if (!type || type == 'off') {
offList.value = []
const userFieldFixed = useList?.userFieldFixed?.split(",");
const userFieldUnFixed = useList?.userFieldUnFixed?.split(",");
if (!type || type == "off") {
offList.value = [];
allList?.map((v) => {
const 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)
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);
}
if (!type || type == 'on') {
useList?.userFieldFixed?.split(',').map((v) => {
let item = allList.find(v2 => v2.name == v)
if (!type || type == "on") {
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,
}
selectIds.value.push(item.id)
if (!item.fix)
onList.value.push(item)
};
selectIds.value.push(item.id);
if (!item.fix) onList.value.push(item);
}
})
});
}
offShowList.value = cloneDeep(offList.value)
fixShowList.value = cloneDeep(fixList.value)
onShowList.value = cloneDeep(onList.value)
offShowList.value = cloneDeep(offList.value);
fixShowList.value = cloneDeep(fixList.value);
onShowList.value = cloneDeep(onList.value);
}
onMounted(() => getData())
onMounted(() => getData());
const indeterminate = computed(() => {
let baseNum = 0
let baseNum = 0;
offList.value.map((v) => {
if (v.fix)
baseNum += 1
})
if (v.fix) baseNum += 1;
});
return (
onShowList.value.length > 0
&& offShowList.value.length - baseNum > onShowList.value.length
)
})
onShowList.value.length > 0 &&
offShowList.value.length - baseNum > onShowList.value.length
);
});
function queryData(value, type) {
if (value) {
if (type == 'off') {
offShowList.value = offList.value.filter(item => item.name.includes(value))
if (type == "off") {
offShowList.value = offList.value.filter((item) => item.name.includes(value));
} else {
onShowList.value = onList.value.filter((item) => item.name.includes(value));
fixShowList.value = fixList.value.filter((item) => item.name.includes(value));
}
else {
onShowList.value = onList.value.filter(item => item.name.includes(value))
fixShowList.value = fixList.value.filter(item => item.name.includes(value))
}
}
else {
} else {
// getData(type);
if (type == 'off') {
offShowList.value = cloneDeep(offList.value)
}
else {
onShowList.value = cloneDeep(onList.value)
fixShowList.value = cloneDeep(fixList.value)
if (type == "off") {
offShowList.value = cloneDeep(offList.value);
} else {
onShowList.value = cloneDeep(onList.value);
fixShowList.value = cloneDeep(fixList.value);
}
}
}
@ -449,9 +440,7 @@ function queryData(value, type) {
<SvgIcon size="14px" name="magnifying-1" />
</template>
</n-input>
<div class="draggable-title">
系统默认
</div>
<div class="draggable-title">系统默认</div>
<div class="draggable-ul" style="border-bottom: none">
<div
v-for="item in fixShowList"
@ -462,9 +451,7 @@ function queryData(value, type) {
<span class="ml-2">{{ item.name }}</span>
</div>
</div>
<div class="draggable-title" style="border-top: none">
自定义配置
</div>
<div class="draggable-title" style="border-top: none">自定义配置</div>
<VueDraggable
v-model="onList"
class="draggable-ul"
@ -495,10 +482,15 @@ function queryData(value, type) {
</div>
<template #footer>
<div class="wrapper-footer">
<n-button type="info" @click="handleSumbit">
确定
</n-button>
<n-button secondary style="margin-left: 15px" @click="getData();closeModal()">
<n-button type="info" @click="handleSumbit"> </n-button>
<n-button
secondary
style="margin-left: 15px"
@click="
getData();
closeModal();
"
>
取消
</n-button>
</div>

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save