莳松-行政管理系统
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.
ss-oa-manage-web/src/views/OKR/Management/Components/MySon.vue

121 lines
2.7 KiB

2 months ago
<template>
2 months ago
<div class="h-full flex flex-col">
2 months ago
<div class="flex items-center justify-between">
<el-row>
<el-tree-select
v-model="searchForm.nodeId"
:data="peroidList"
:props="defaultProps"
:render-after-expand="false"
:default-expand-all="false"
style="width: 400px"
2 months ago
@change="nodeChange"
2 months ago
/>
</el-row>
<el-row>
<el-button type="info" @click="handleShowOkr(searchForm.nodeId)"> 节点详情 </el-button>
2 months ago
<el-button
type="warning"
v-if="currentUserId == searchForm.creatorId"
@click="handleEditOkr(searchForm.nodeId)"
>
修改当前节点
</el-button>
2 months ago
</el-row>
</div>
<OkrTable ref="okrTableRef" canEdit />
<DialogOkr ref="dialogOkr" @edit="handleEditOkr" />
2 months ago
<DialogOkrInfo ref="dialogOkrInfo" @success="handleSearchPeroid" />
2 months ago
</div>
</template>
2 months ago
<script setup name="MySon">
2 months ago
import OkrTable from './OkrTable.vue'
import DialogOkr from './DialogOkr.vue'
2 months ago
import DialogOkrInfo from './DialogOkrInfo.vue'
import { listToTree, findNode } from '@/utils/tree'
import { useUserStore } from '@/store/modules/user'
2 months ago
import { getMySonNodeTree, getMySonOkrPage } from '@/api/okr/okr'
const props = defineProps({
userId: {
type: Number,
default: undefined
}
})
const defaultProps = {
value: 'nodeId',
label: 'nodeName',
children: 'children'
}
2 months ago
const userStore = useUserStore()
const currentUserId = userStore.getUser.id
2 months ago
const okrTableRef = ref(null)
const searchForm = ref({
nodeId: undefined
})
const peroidList = ref([])
handleSearchPeroid()
function handleSearchPeroid() {
getMySonNodeTree({ userId: props.userId }).then((resp) => {
peroidList.value = listToTree(resp.tree, {
id: 'nodeId',
pid: 'parentId',
children: 'children'
})
2 months ago
nodeChange(resp.nodeId)
2 months ago
})
}
function getOkrList() {
getMySonOkrPage({
...searchForm.value,
userId: props.userId
}).then((resp) => {
nextTick(() => {
2 months ago
okrTableRef.value.prepareData(resp)
2 months ago
})
})
}
2 months ago
function nodeChange(nodeId) {
searchForm.value.nodeId = nodeId
getOkrList()
const currentNode = findNode(peroidList.value, (node) => {
return node.nodeId == nodeId
})
searchForm.value.creatorId = currentNode.creatorId
}
2 months ago
const dialogOkr = ref(null)
function handleShowOkr(id) {
dialogOkr.value.open({
nodeId: id,
canEdit: true,
2 months ago
queryType: 2
2 months ago
})
}
2 months ago
const dialogOkrInfo = ref(null)
function handleEditOkr(nodeId = undefined) {
dialogOkr.value.close()
dialogOkrInfo.value.open('update', nodeId || searchForm.value.nodeId, 2)
}
2 months ago
</script>
<style lang="scss" scoped>
:deep(.el-overlay-dialog) {
display: flex;
justify-content: center;
align-items: center;
}
</style>