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'] Application: typeof import('./src/components/Application/Application.vue')['default']
BasicModal: typeof import('./src/components/Modal/BasicModal.vue')['default'] BasicModal: typeof import('./src/components/Modal/BasicModal.vue')['default']
DataHeader: typeof import('./src/components/DataHeader/index.vue')['default'] DataHeader: typeof import('./src/components/DataHeader/index.vue')['default']
NAvatar: typeof import('naive-ui')['NAvatar']
NButton: typeof import('naive-ui')['NButton'] NButton: typeof import('naive-ui')['NButton']
NCard: typeof import('naive-ui')['NCard']
NCheckbox: typeof import('naive-ui')['NCheckbox'] NCheckbox: typeof import('naive-ui')['NCheckbox']
NCollapse: typeof import('naive-ui')['NCollapse']
NCollapseItem: typeof import('naive-ui')['NCollapseItem']
NConfigProvider: typeof import('naive-ui')['NConfigProvider'] NConfigProvider: typeof import('naive-ui')['NConfigProvider']
NDatePicker: typeof import('naive-ui')['NDatePicker']
NDialogProvider: typeof import('naive-ui')['NDialogProvider'] NDialogProvider: typeof import('naive-ui')['NDialogProvider']
NDivider: typeof import('naive-ui')['NDivider']
NDropdown: typeof import('naive-ui')['NDropdown']
NForm: typeof import('naive-ui')['NForm'] NForm: typeof import('naive-ui')['NForm']
NFormItem: typeof import('naive-ui')['NFormItem'] 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'] NInput: typeof import('naive-ui')['NInput']
NMessageProvider: typeof import('naive-ui')['NMessageProvider'] NMessageProvider: typeof import('naive-ui')['NMessageProvider']
NModal: typeof import('naive-ui')['NModal'] 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> <script lang="ts" setup>
import { ref, watch } from "vue"; import { ref, watch } from "vue";
import * as XLSX from 'xlsx'; import * as XLSX from "xlsx";
defineProps({ defineProps({
data: { data: {
@ -12,13 +12,13 @@ defineProps({
default: () => [[]], default: () => [[]],
}, },
}); });
const emit = defineEmits(["showModal","getrowValue"]); const emit = defineEmits(["showModal", "getrowValue"]);
function showActionsModal() { function showActionsModal() {
emit("showModal"); emit("showModal");
} }
function getrowvalue(row){ function getrowvalue(row) {
emit("getrowValue",row); emit("getrowValue", row);
} }
</script> </script>
@ -37,13 +37,27 @@ function getrowvalue(row){
<th v-if="item && item[0]"> <th v-if="item && item[0]">
{{ item[0].label }} {{ item[0].label }}
</th> </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 }} {{ item[0].value }}
</td> </td>
<th v-if="item && item.length > 1"> <th v-if="item && item.length > 1">
{{ item[1].label }} {{ item[1].label }}
</th> </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 }} {{ item[1].value }}
</td> </td>
</tr> </tr>

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

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

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