sc
This commit is contained in:
@@ -81,3 +81,12 @@ export const getDefaultOkrOptions = () => {
|
||||
headers: { 'instance-id': 1016 }
|
||||
})
|
||||
}
|
||||
|
||||
// 更新OKR进度
|
||||
export const updateOkrProgress = (data) => {
|
||||
return request.put({
|
||||
url: '/admin-api/okr/node/progress/update',
|
||||
data,
|
||||
headers: { 'instance-id': 1016 }
|
||||
})
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
:default-expand-all="false"
|
||||
check-strictly
|
||||
style="width: 400px"
|
||||
@change="getOkrList"
|
||||
@change="nodeChange"
|
||||
/>
|
||||
<el-button class="ml-10px" type="primary" @click="handleAddNode">新建节点</el-button>
|
||||
</el-row>
|
||||
@@ -23,7 +23,7 @@
|
||||
</el-row>
|
||||
</div>
|
||||
|
||||
<OkrTable ref="okrTableRef" />
|
||||
<OkrTable ref="okrTableRef" :canEdit="isCurrentLeafNode" />
|
||||
<DialogOkr ref="dialogOkr" @edit="handleEditOkr" />
|
||||
<DialogOkrInfo ref="dialogOkrInfo" @success="handleSearchPeroid" />
|
||||
</div>
|
||||
@@ -35,7 +35,7 @@ import DialogOkrInfo from './DialogOkrInfo.vue'
|
||||
import DialogOkr from './DialogOkr.vue'
|
||||
|
||||
import { getAllNodeTree, getAllOkrPage } from '@/api/okr/okr'
|
||||
import { listToTree } from '@/utils/tree'
|
||||
import { listToTree, findNode } from '@/utils/tree'
|
||||
|
||||
const message = useMessage()
|
||||
|
||||
@@ -56,6 +56,10 @@ onMounted(() => {
|
||||
handleSearchPeroid()
|
||||
})
|
||||
|
||||
// 当前是否是叶子节点
|
||||
// 如果不是叶子节点,则表格数据不可修改
|
||||
const isCurrentLeafNode = ref(false)
|
||||
|
||||
function handleSearchPeroid() {
|
||||
getAllNodeTree().then((resp) => {
|
||||
peroidList.value = listToTree(resp.tree, {
|
||||
@@ -63,11 +67,23 @@ function handleSearchPeroid() {
|
||||
pid: 'parentId',
|
||||
children: 'children'
|
||||
})
|
||||
searchForm.value.nodeId = resp.nodeId
|
||||
getOkrList()
|
||||
nodeChange(resp.nodeId)
|
||||
})
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
function getOkrList() {
|
||||
getAllOkrPage(searchForm.value).then((resp) => {
|
||||
const list = resp
|
||||
@@ -88,8 +104,10 @@ function handleEditOkr() {
|
||||
}
|
||||
|
||||
function handleUpdateProcess() {
|
||||
message.success('更新进度成功')
|
||||
getOkrList()
|
||||
okrTableRef.value.updateProcess(searchForm.value.nodeId).then(() => {
|
||||
message.success('更新成功')
|
||||
getOkrList()
|
||||
})
|
||||
}
|
||||
|
||||
const dialogOkr = ref(null)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<span class="text-14px ml-0.25">ork落地</span>
|
||||
<div class="ml-20px text-14px">
|
||||
<span>【节点】</span>
|
||||
<span>{{ nodeInfo.nodeName }}</span>
|
||||
<span>{{ nodeInfo.allNodeName }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
@@ -248,7 +248,7 @@
|
||||
v-for="item in nodeRecords"
|
||||
:key="item.recordId"
|
||||
placement="bottom"
|
||||
:timestamp="formatDate(item.createTime)"
|
||||
:timestamp="formatDate(item.createTime, 'YYYY-MM-DD HH:mm:ss')"
|
||||
color="#30d1fc"
|
||||
>
|
||||
<div>{{ item.creator }}</div>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-if="show"
|
||||
v-model="show"
|
||||
width="900px"
|
||||
class="dialog-okr"
|
||||
@@ -178,6 +177,7 @@
|
||||
allow-create
|
||||
:reserve-keyword="false"
|
||||
class="flex-1 w-150px"
|
||||
@change="krChange(i, index)"
|
||||
>
|
||||
<el-option
|
||||
v-for="it in krOptions"
|
||||
@@ -493,6 +493,18 @@ function getLastDayOfMonth(year, month) {
|
||||
return date.getDate()
|
||||
}
|
||||
|
||||
function krChange(idx, krIdx) {
|
||||
const kr = objectList.value[idx].keyResults[krIdx]
|
||||
if (kr.keyResultName) {
|
||||
const obj = krOptions.value.find((item) => item.value == kr.keyResultName)
|
||||
if (obj) {
|
||||
kr.isSys = true
|
||||
} else {
|
||||
kr.isSys = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSave() {
|
||||
// 校验表单
|
||||
if (!formRef.value) return
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
</span>
|
||||
<div class="flex items-center mt-10px ml-50px">
|
||||
<span>当前进度:</span>
|
||||
<span v-if="row.isSys">{{ row.currentValue }}</span>
|
||||
<span v-if="row.isSys || !props.canEdit">{{ row.currentValue }}</span>
|
||||
<el-input
|
||||
v-else-if="row.resultType == 1"
|
||||
v-model="row.currentValue"
|
||||
@@ -59,8 +59,17 @@
|
||||
</template>
|
||||
|
||||
<script setup name="OkrTable">
|
||||
import { updateOkrProgress } from '@/api/okr/okr'
|
||||
|
||||
const emit = defineEmits(['rowClick'])
|
||||
|
||||
const props = defineProps({
|
||||
canEdit: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
})
|
||||
|
||||
const okrList = ref([])
|
||||
const helpList = ref([])
|
||||
|
||||
@@ -80,6 +89,11 @@ function prepareData(list) {
|
||||
obj.children = item.keyResults.map((child) => {
|
||||
let kr = {
|
||||
id: child.keyResultId,
|
||||
keyResultId: child.keyResultId,
|
||||
objectiveId: child.objectiveId,
|
||||
nodeId: child.nodeId,
|
||||
isSys: child.isSys,
|
||||
processId: child.id,
|
||||
name: child.keyResultName,
|
||||
progress: child.progress,
|
||||
executorName: child.executorName,
|
||||
@@ -96,9 +110,9 @@ function prepareData(list) {
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
prepareData
|
||||
prepareData,
|
||||
updateProcess
|
||||
})
|
||||
|
||||
function getHeight(row, index) {
|
||||
if (helpList.value.length - 1 == index || helpList.value[index + 1].type == '目标') {
|
||||
return '22px'
|
||||
@@ -112,6 +126,25 @@ function handleExpand(row, expanded) {
|
||||
expandedRows.value[row.id] = !expanded
|
||||
}
|
||||
|
||||
function updateProcess(nodeId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
let arr = []
|
||||
okrList.value.map((item) => {
|
||||
arr = [...arr, ...(item.children || []).map((it) => ({ ...it, id: it.processId }))]
|
||||
})
|
||||
updateOkrProgress({
|
||||
nodeId,
|
||||
keyResultProgressList: arr
|
||||
}).then((resp) => {
|
||||
resolve(resp)
|
||||
})
|
||||
} catch (error) {
|
||||
reject(error)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function handleRowClick(row) {
|
||||
emit('rowClick', row)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user