莳松-行政管理系统
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/AllTarget.vue

139 lines
3.4 KiB

1 month ago
<template>
<div>
<div class="flex items-center justify-between">
<el-row>
4 weeks ago
<el-tree-select
v-model="searchForm.nodeId"
:data="peroidList"
:props="defaultProps"
:render-after-expand="false"
4 weeks ago
:default-expand-all="false"
check-strictly
4 weeks ago
style="width: 400px"
3 weeks ago
@change="nodeChange"
4 weeks ago
/>
1 month ago
<el-button class="ml-10px" type="primary" @click="handleAddNode">新建节点</el-button>
</el-row>
<el-row>
4 weeks ago
<el-button type="info" @click="handleShowOkr(searchForm.nodeId)"> 节点详情 </el-button>
2 weeks ago
<el-button
type="warning"
v-if="currentUserId == searchForm.creatorId"
@click="handleEditOkr(searchForm.nodeId)"
>
1 month ago
修改当前节点
</el-button>
2 weeks ago
<el-button
type="success"
v-if="searchForm.executor?.includes(currentUserId)"
@click="handleUpdateProcess"
>更新进度</el-button
>
1 month ago
</el-row>
</div>
3 weeks ago
<OkrTable ref="okrTableRef" :canEdit="isCurrentLeafNode" />
1 month ago
<DialogOkr ref="dialogOkr" @edit="handleEditOkr" />
4 weeks ago
<DialogOkrInfo ref="dialogOkrInfo" @success="handleSearchPeroid" />
1 month ago
</div>
</template>
<script setup name="AllTarget">
import OkrTable from './OkrTable.vue'
import DialogOkrInfo from './DialogOkrInfo.vue'
import DialogOkr from './DialogOkr.vue'
4 weeks ago
import { getAllNodeTree, getAllOkrPage } from '@/api/okr/okr'
3 weeks ago
import { listToTree, findNode } from '@/utils/tree'
2 weeks ago
import { useUserStore } from '@/store/modules/user'
4 weeks ago
1 month ago
const message = useMessage()
2 weeks ago
const userStore = useUserStore()
const currentUserId = userStore.getUser.id
1 month ago
4 weeks ago
const defaultProps = {
value: 'nodeId',
label: 'nodeName',
children: 'children'
}
1 month ago
const okrTableRef = ref(null)
const searchForm = ref({
4 weeks ago
nodeId: undefined
1 month ago
})
const peroidList = ref([])
2 weeks ago
handleSearchPeroid()
1 month ago
3 weeks ago
// 当前是否是叶子节点
// 如果不是叶子节点,则表格数据不可修改
const isCurrentLeafNode = ref(false)
4 weeks ago
function handleSearchPeroid() {
getAllNodeTree().then((resp) => {
peroidList.value = listToTree(resp.tree, {
id: 'nodeId',
pid: 'parentId',
children: 'children'
})
3 weeks ago
nodeChange(resp.nodeId)
4 weeks ago
})
1 month ago
}
3 weeks ago
function nodeChange(nodeId) {
searchForm.value.nodeId = nodeId
getOkrList()
const currentNode = findNode(peroidList.value, (node) => {
return node.nodeId == nodeId
})
if (!currentNode.children || currentNode.children.length == 0) {
isCurrentLeafNode.value = true
} else {
isCurrentLeafNode.value = false
}
}
4 weeks ago
function getOkrList() {
getAllOkrPage(searchForm.value).then((resp) => {
const list = resp
nextTick(() => {
okrTableRef.value.prepareData(list)
})
1 month ago
})
}
const dialogOkrInfo = ref(null)
function handleAddNode() {
dialogOkrInfo.value.open('create', null)
}
function handleEditOkr() {
dialogOkr.value.close()
4 weeks ago
dialogOkrInfo.value.open('update', searchForm.value.nodeId)
1 month ago
}
function handleUpdateProcess() {
3 weeks ago
okrTableRef.value.updateProcess(searchForm.value.nodeId).then(() => {
message.success('更新成功')
getOkrList()
})
1 month ago
}
const dialogOkr = ref(null)
4 weeks ago
function handleShowOkr(id) {
3 weeks ago
dialogOkr.value.open({
nodeId: id,
canEdit: isCurrentLeafNode.value
})
4 weeks ago
}
1 month ago
</script>
<style lang="scss" scoped>
:deep(.el-overlay-dialog) {
display: flex;
justify-content: center;
align-items: center;
}
</style>