You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
324 lines
7.2 KiB
324 lines
7.2 KiB
<script lang="ts" setup>
|
|
import { debounce } from 'lodash-es'
|
|
import {
|
|
computed,
|
|
defineEmits,
|
|
defineOptions,
|
|
inject,
|
|
nextTick,
|
|
onMounted,
|
|
onUnmounted,
|
|
ref,
|
|
unref,
|
|
watch,
|
|
} from 'vue'
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
import CustomFieldModalVue from '../modal/CustomFieldModal.vue'
|
|
import WorkSheetList from './WorkSheetList.vue'
|
|
import { getAllfieldList, getfieldList } from '@/api/home/filter'
|
|
import { useWindowSizeFn } from '@/hooks/event/useWindowSizeFn'
|
|
import { useUser } from '@/store/modules/user'
|
|
import { useWorkOrder } from '@/store/modules/workOrder'
|
|
import { getViewportOffset } from '@/utils/domUtils'
|
|
|
|
defineOptions({ name: 'AsideContent' })
|
|
const emit = defineEmits(['ApprovalOver'])
|
|
const route = useRoute()
|
|
const router = useRouter()
|
|
const searchContent = route.query.searchContent
|
|
console.log(searchContent)
|
|
const collapse = ref(false)
|
|
const workStore = useWorkOrder()
|
|
const filterModalRef = ref(null)
|
|
const packageListRef = ref<HTMLDivElement | null>(null)
|
|
// 展示字段
|
|
const showFieldList = ref<any[]>([])
|
|
const searchInputRef = ref<HTMLInputElement>()
|
|
const reviewType = 1
|
|
const dicts = ref<any>([])
|
|
function collapseHandler() {
|
|
collapse.value = !collapse.value
|
|
}
|
|
const mousetrap = inject('mousetrap') as any
|
|
mousetrap.bind('[', collapseHandler)
|
|
|
|
const searchKeyword = ref(searchContent || '')
|
|
|
|
const asideWidth = computed(() => {
|
|
return collapse.value ? 0 : 308
|
|
})
|
|
|
|
const asideStyle = computed(() => {
|
|
return {
|
|
width: `${asideWidth.value}px`,
|
|
}
|
|
})
|
|
|
|
const collapseIcon = computed(() => {
|
|
return collapse.value ? 'expand-cir' : 'collapse-cir'
|
|
})
|
|
|
|
const listHeight = ref(700)
|
|
|
|
function computeListHeight() {
|
|
const listEl = document.querySelector('.work-sheet-list')!
|
|
const { bottomIncludeBody } = getViewportOffset(listEl)
|
|
const height = bottomIncludeBody
|
|
listHeight.value = height - 25
|
|
}
|
|
|
|
const listStyle = computed(() => {
|
|
return {
|
|
height: `${listHeight.value}px`,
|
|
}
|
|
})
|
|
|
|
useWindowSizeFn(computeListHeight, 280)
|
|
function handleKeydown(event) {
|
|
if (event.key === 's')
|
|
setShowSearch(true)
|
|
}
|
|
|
|
async function getshowFieldList() {
|
|
showFieldList.value = []
|
|
const userStore = useUser()
|
|
const userInfo = userStore.getUserInfo
|
|
let res
|
|
res = await getAllfieldList(reviewType) // 所有筛选项目
|
|
const allList = res.data
|
|
dicts.value = 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)
|
|
}
|
|
return v
|
|
})
|
|
}
|
|
else {
|
|
// 若为首次获取 则赋默认值
|
|
allList.map((v) => {
|
|
if (v.isrequired == 2) {
|
|
const item = {
|
|
name: v.fieldDesc,
|
|
id: v.name,
|
|
fix: v.isrequired == 2,
|
|
checked: true,
|
|
}
|
|
showFieldList.value.push(item)
|
|
}
|
|
return v
|
|
})
|
|
}
|
|
}
|
|
|
|
onMounted(() => {
|
|
nextTick(() => {
|
|
computeListHeight()
|
|
window.addEventListener('keydown', handleKeydown)
|
|
|
|
getshowFieldList()
|
|
})
|
|
})
|
|
onUnmounted(() => {
|
|
window.removeEventListener('keydown', handleKeydown)
|
|
})
|
|
const asideEnter = ref(false)
|
|
|
|
const showCollapse = computed(() => {
|
|
return collapse.value ? true : asideEnter.value
|
|
})
|
|
|
|
function showFilter() {
|
|
const modal = unref(filterModalRef)! as any
|
|
modal.showModal()
|
|
}
|
|
|
|
watch(
|
|
() => workStore.immersion,
|
|
() => {
|
|
collapse.value = true
|
|
},
|
|
)
|
|
|
|
const showSearch = ref(false)
|
|
|
|
function setShowSearch(value: boolean) {
|
|
showSearch.value = value
|
|
if (value === false) {
|
|
(packageListRef.value as any).search('')
|
|
searchKeyword.value = ''
|
|
if (!searchContent)
|
|
return router.replace(route.path)
|
|
|
|
nextTick(() => {
|
|
searchInputRef.value?.focus()
|
|
})
|
|
}
|
|
}
|
|
|
|
const inputHandler = debounce((word) => {
|
|
searchKeyword.value = word;
|
|
(packageListRef.value as any).search(word)
|
|
}, 500)
|
|
|
|
function ApprovalOver(packageId) {
|
|
emit('ApprovalOver', packageId)
|
|
}
|
|
|
|
if (searchContent) {
|
|
showSearch.value = true
|
|
inputHandler(searchContent)
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div
|
|
class="aside"
|
|
:style="asideStyle"
|
|
@mouseenter="asideEnter = true"
|
|
@mouseleave="asideEnter = false"
|
|
>
|
|
<div v-show="showCollapse" class="aside-collapse">
|
|
<div class="aside-collapse-btn" @click="collapseHandler">
|
|
<SvgIcon :name="collapseIcon" size="40" />
|
|
</div>
|
|
</div>
|
|
<div class="aside-header">
|
|
<div v-show="!showSearch" class="warpper">
|
|
<div class="left">
|
|
<svg-icon name="all-worksheet" size="32" />
|
|
<!-- j -->
|
|
<span style="margin-left: 8px; color: #333333">所有任务包</span>
|
|
</div>
|
|
<div class="right">
|
|
|
|
<SvgIcon
|
|
style="cursor: pointer; margin-left: 10px"
|
|
size="18"
|
|
name="magnifying-1"
|
|
@click="setShowSearch(true)"
|
|
/>
|
|
|
|
<SvgIcon
|
|
style="cursor: pointer; margin-left: 10px"
|
|
size="18"
|
|
name="filter"
|
|
@click="showFilter"
|
|
/>
|
|
</div>
|
|
</div>
|
|
<div v-show="showSearch" class="warpper">
|
|
<n-input
|
|
ref="searchInputRef"
|
|
v-model:value="searchKeyword"
|
|
style="flex: 1; height: 32px"
|
|
placeholder="请输入任务包名称"
|
|
@input="inputHandler"
|
|
>
|
|
<template #suffix>
|
|
<SvgIcon size="14px" name="magnifying-1" />
|
|
</template>
|
|
</n-input>
|
|
<SvgIcon
|
|
size="16px"
|
|
style="margin-left: 6px; cursor: pointer"
|
|
name="clear"
|
|
@click="setShowSearch(false)"
|
|
/>
|
|
</div>
|
|
</div>
|
|
<WorkSheetList
|
|
ref="packageListRef"
|
|
class="work-sheet-list"
|
|
:show-field-list="showFieldList"
|
|
:dicts="dicts"
|
|
@approval-over="ApprovalOver"
|
|
/>
|
|
<CustomFieldModalVue
|
|
ref="filterModalRef"
|
|
:review-type="1"
|
|
@on-ok="getshowFieldList"
|
|
/>
|
|
</div>
|
|
</template>
|
|
|
|
<style lang="less" scoped>
|
|
.aside {
|
|
display: flex;
|
|
position: relative;
|
|
flex-direction: column;
|
|
background: #fff;
|
|
border: 1px solid rgb(239, 239, 245);
|
|
border-radius: 3px;
|
|
box-sizing: border-box;
|
|
margin-left: 16px;
|
|
|
|
&-header {
|
|
padding: 12px 16px;
|
|
width: 100%;
|
|
display: table;
|
|
overflow: hidden;
|
|
|
|
.warpper {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
|
|
.left {
|
|
display: flex;
|
|
align-items: center;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.right {
|
|
display: flex;
|
|
align-items: center;
|
|
overflow: hidden;
|
|
}
|
|
}
|
|
|
|
&-divider {
|
|
margin-left: 16px;
|
|
width: 292px;
|
|
height: 1px;
|
|
background-color: #e8e8e8;
|
|
}
|
|
|
|
&-collapse {
|
|
width: 2px;
|
|
height: 100%;
|
|
background: #507afd;
|
|
position: absolute;
|
|
right: -2px;
|
|
top: 0;
|
|
}
|
|
|
|
&-collapse-btn {
|
|
position: absolute;
|
|
cursor: pointer;
|
|
width: 40px;
|
|
height: 40px;
|
|
top: calc(15%);
|
|
right: -20px;
|
|
z-index: 10;
|
|
}
|
|
}
|
|
</style>
|