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