|
|
|
@ -28,21 +28,24 @@ |
|
|
|
|
v-model="form.parentId" |
|
|
|
|
:data="parentNodeList" |
|
|
|
|
check-strictly |
|
|
|
|
:props="{ value: 'id', label: 'label', children: 'children' }" |
|
|
|
|
:props="{ value: 'nodeId', label: 'nodeName', children: 'children' }" |
|
|
|
|
:render-after-expand="false" |
|
|
|
|
placeholder="父节点" |
|
|
|
|
clearable |
|
|
|
|
:disabled="!!form.nodeId" |
|
|
|
|
@change="handleChangeParent" |
|
|
|
|
/> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
<el-col :span="4" :offset="0"> |
|
|
|
|
<el-form-item prop="name"> |
|
|
|
|
<el-input v-model="form.name" placeholder="请输入节点名称" /> |
|
|
|
|
<el-form-item prop="nodeName"> |
|
|
|
|
<el-input v-model="form.nodeName" placeholder="请输入节点名称" /> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
<el-col :span="4" :offset="0"> |
|
|
|
|
<el-form-item prop="createTime"> |
|
|
|
|
<el-form-item prop="startTime"> |
|
|
|
|
<el-date-picker |
|
|
|
|
v-model="form.createTime" |
|
|
|
|
v-model="form.startTime" |
|
|
|
|
type="date" |
|
|
|
|
format="YYYY-MM-DD" |
|
|
|
|
value-format="YYYY-MM-DD" |
|
|
|
@ -67,6 +70,8 @@ |
|
|
|
|
v-model="form.executor" |
|
|
|
|
placeholder="选择执行人,可多选" |
|
|
|
|
multiple |
|
|
|
|
collapse-tags |
|
|
|
|
collapse-tags-tooltip |
|
|
|
|
clearable |
|
|
|
|
filterable |
|
|
|
|
> |
|
|
|
@ -74,16 +79,17 @@ |
|
|
|
|
v-for="item in userOptions" |
|
|
|
|
:key="item.id" |
|
|
|
|
:label="item.name" |
|
|
|
|
:value="item.id" |
|
|
|
|
:value="item.id + ''" |
|
|
|
|
:disabled="item.status == 1" |
|
|
|
|
/> |
|
|
|
|
</el-select> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
<el-col :span="4" :offset="0"> |
|
|
|
|
<el-form-item prop="persission"> |
|
|
|
|
<el-select v-model="form.persission" placeholder="选择权限" clearable filterable> |
|
|
|
|
<el-option label="公开" :value="0" /> |
|
|
|
|
<el-option label="仅上级可见" :value="1" /> |
|
|
|
|
<el-form-item prop="dataScope"> |
|
|
|
|
<el-select v-model="form.dataScope" placeholder="选择权限" clearable filterable> |
|
|
|
|
<el-option label="公开" :value="1" /> |
|
|
|
|
<el-option label="仅上级可见" :value="2" /> |
|
|
|
|
</el-select> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
@ -91,8 +97,8 @@ |
|
|
|
|
</el-form> |
|
|
|
|
<div class="relative"> |
|
|
|
|
<el-button |
|
|
|
|
v-if="okrKey === 'okr'" |
|
|
|
|
style="position: absolute; right: 10px; top: 10px" |
|
|
|
|
v-if="okrKey == 'okr'" |
|
|
|
|
style="position: absolute; right: 10px; top: 10px; z-index: 9" |
|
|
|
|
type="primary" |
|
|
|
|
size="small" |
|
|
|
|
@click="addObjective" |
|
|
|
@ -100,8 +106,8 @@ |
|
|
|
|
添加目标 |
|
|
|
|
</el-button> |
|
|
|
|
<el-button |
|
|
|
|
v-else-if="okrKey === 'childNode'" |
|
|
|
|
style="position: absolute; right: 10px; top: 10px" |
|
|
|
|
v-else-if="okrKey == 'childNode'" |
|
|
|
|
style="position: absolute; right: 10px; top: 10px; z-index: 9" |
|
|
|
|
type="primary" |
|
|
|
|
size="small" |
|
|
|
|
@click="addChildNode" |
|
|
|
@ -114,63 +120,75 @@ |
|
|
|
|
<div |
|
|
|
|
class="flex items-center w-full" |
|
|
|
|
v-for="(item, i) in objectList" |
|
|
|
|
:key="item.id" |
|
|
|
|
:key="item.objectiveId" |
|
|
|
|
> |
|
|
|
|
<div class="flex-1 w-100px"> |
|
|
|
|
<div class="flex items-center"> |
|
|
|
|
<el-tag type="success" class="mr-10px">O{{ i + 1 }}</el-tag> |
|
|
|
|
<el-input v-model="item.name" placeholder="目标名称" class="flex-1 w-150px" /> |
|
|
|
|
<el-input |
|
|
|
|
v-model="item.objectiveName" |
|
|
|
|
placeholder="目标名称" |
|
|
|
|
class="flex-1 w-150px" |
|
|
|
|
:disabled="!!item.objectiveId" |
|
|
|
|
/> |
|
|
|
|
<el-select |
|
|
|
|
v-model="item.objExecutor" |
|
|
|
|
v-model="item.executor" |
|
|
|
|
placeholder="选择执行人,可多选" |
|
|
|
|
multiple |
|
|
|
|
clearable |
|
|
|
|
filterable |
|
|
|
|
style="min-width: 240px; margin-left: 10px" |
|
|
|
|
style="width: 240px; margin-left: 10px" |
|
|
|
|
> |
|
|
|
|
<el-option |
|
|
|
|
v-for="it in userOptions" |
|
|
|
|
:key="it.id" |
|
|
|
|
:label="it.name" |
|
|
|
|
:value="it.id" |
|
|
|
|
:value="it.id + ''" |
|
|
|
|
:disabled="it.status == 1" |
|
|
|
|
/> |
|
|
|
|
</el-select> |
|
|
|
|
<el-select |
|
|
|
|
v-model="item.persission" |
|
|
|
|
v-model="item.dataScope" |
|
|
|
|
placeholder="选择权限" |
|
|
|
|
clearable |
|
|
|
|
filterable |
|
|
|
|
style="width: 120px; margin-left: 10px" |
|
|
|
|
> |
|
|
|
|
<el-option label="公开" :value="0" /> |
|
|
|
|
<el-option label="仅上级可见" :value="1" /> |
|
|
|
|
<el-option label="公开" :value="1" /> |
|
|
|
|
<el-option label="仅上级可见" :value="2" /> |
|
|
|
|
</el-select> |
|
|
|
|
<div class="ml-10px"> |
|
|
|
|
<el-button type="primary" text @click="AddKR">新增关键成果</el-button> |
|
|
|
|
<el-button type="danger" text @click="removeObj">删除目标</el-button> |
|
|
|
|
<el-button type="primary" text @click="AddKR(i)">新增关键成果</el-button> |
|
|
|
|
<el-button type="danger" text @click="removeObj(i)">删除目标</el-button> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<div style="background: #f0f3fa; padding-bottom: 15px"> |
|
|
|
|
<div class="ml-50px" v-for="(kr, index) in item.children" :key="kr.id"> |
|
|
|
|
<div |
|
|
|
|
class="ml-50px" |
|
|
|
|
v-for="(kr, index) in item.keyResults" |
|
|
|
|
:key="kr.keyResultId" |
|
|
|
|
> |
|
|
|
|
<div class="flex flex-1 items-center pb-5px pt-5px"> |
|
|
|
|
<el-tag class="mr-10px">KR{{ index + 1 }}</el-tag> |
|
|
|
|
<el-select |
|
|
|
|
v-model="kr.id" |
|
|
|
|
placeholder="选择或输入" |
|
|
|
|
v-model="kr.keyResultName" |
|
|
|
|
placeholder="选择或输入关键成果" |
|
|
|
|
filterable |
|
|
|
|
:props="{ value: 'id', label: 'name' }" |
|
|
|
|
:props="{ value: 'keyResultId', label: 'keyResultName' }" |
|
|
|
|
allow-create |
|
|
|
|
:reserve-keyword="false" |
|
|
|
|
class="flex-1 w-150px" |
|
|
|
|
> |
|
|
|
|
<el-option |
|
|
|
|
v-for="it in item.children" |
|
|
|
|
:key="it.id" |
|
|
|
|
:label="it.name" |
|
|
|
|
:value="it.id" |
|
|
|
|
v-for="it in krOptions" |
|
|
|
|
:key="it.keyResultId" |
|
|
|
|
:label="it.keyResultName" |
|
|
|
|
:value="it.keyResultId" |
|
|
|
|
/> |
|
|
|
|
</el-select> |
|
|
|
|
<el-button type="danger" text @click="removeKR">删除关键成果</el-button> |
|
|
|
|
<el-button type="danger" text @click="removeKR(i, index)"> |
|
|
|
|
删除关键成果 |
|
|
|
|
</el-button> |
|
|
|
|
</div> |
|
|
|
|
<div class="mt-5px flex items-center"> |
|
|
|
|
<el-tree-select |
|
|
|
@ -180,47 +198,51 @@ |
|
|
|
|
check-strictly |
|
|
|
|
clearable |
|
|
|
|
filterable |
|
|
|
|
style="width: 200px" |
|
|
|
|
node-key="sourceId" |
|
|
|
|
placeholder="请选择渠道" |
|
|
|
|
/> |
|
|
|
|
<el-radio-group v-model="kr.targetType" class="ml-10px"> |
|
|
|
|
<el-radio-button label="value">目标值</el-radio-button> |
|
|
|
|
<el-radio-button label="radio">是/否</el-radio-button> |
|
|
|
|
<el-radio-group v-model="kr.resultType" class="ml-10px"> |
|
|
|
|
<el-radio-button :value="1">目标值</el-radio-button> |
|
|
|
|
<el-radio-button :value="2">是/否</el-radio-button> |
|
|
|
|
</el-radio-group> |
|
|
|
|
|
|
|
|
|
<el-input |
|
|
|
|
v-if="kr.targetType === 'value'" |
|
|
|
|
v-model="kr.targetNum" |
|
|
|
|
v-if="kr.resultType == 1" |
|
|
|
|
v-model="kr.targetValue" |
|
|
|
|
type="number" |
|
|
|
|
placeholder="目标值" |
|
|
|
|
class="ml-10px" |
|
|
|
|
style="width: 100px" |
|
|
|
|
style="width: 120px" |
|
|
|
|
/> |
|
|
|
|
|
|
|
|
|
<el-select |
|
|
|
|
v-model="kr.objExecutor" |
|
|
|
|
v-model="kr.executor" |
|
|
|
|
placeholder="选择执行人,可多选" |
|
|
|
|
multiple |
|
|
|
|
clearable |
|
|
|
|
filterable |
|
|
|
|
style="min-width: 240px; margin-left: 10px" |
|
|
|
|
collapse-tags |
|
|
|
|
collapse-tags-tooltip |
|
|
|
|
style="width: 240px; margin-left: 10px" |
|
|
|
|
> |
|
|
|
|
<el-option |
|
|
|
|
v-for="it in userOptions" |
|
|
|
|
:key="it.id" |
|
|
|
|
:label="it.name" |
|
|
|
|
:value="it.id" |
|
|
|
|
:value="it.id + ''" |
|
|
|
|
:disabled="it.status == 1" |
|
|
|
|
/> |
|
|
|
|
</el-select> |
|
|
|
|
<el-select |
|
|
|
|
v-model="kr.persission" |
|
|
|
|
v-model="kr.dataScope" |
|
|
|
|
placeholder="选择权限" |
|
|
|
|
clearable |
|
|
|
|
filterable |
|
|
|
|
style="width: 120px; margin-left: 10px" |
|
|
|
|
> |
|
|
|
|
<el-option label="公开" :value="0" /> |
|
|
|
|
<el-option label="仅上级可见" :value="1" /> |
|
|
|
|
<el-option label="公开" :value="1" /> |
|
|
|
|
<el-option label="仅上级可见" :value="2" /> |
|
|
|
|
</el-select> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
@ -234,13 +256,13 @@ |
|
|
|
|
<el-table :data="childNodeList"> |
|
|
|
|
<el-table-column label="名称"> |
|
|
|
|
<template #default="{ row }"> |
|
|
|
|
<el-input v-model="row.name" placeholder="子节点名称" /> |
|
|
|
|
<el-input v-model="row.nodeName" placeholder="子节点名称" /> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column label="开始日期" width="160px"> |
|
|
|
|
<template #default="{ row }"> |
|
|
|
|
<el-date-picker |
|
|
|
|
v-model="row.createTime" |
|
|
|
|
v-model="row.startTime" |
|
|
|
|
type="date" |
|
|
|
|
format="YYYY-MM-DD" |
|
|
|
|
value-format="YYYY-MM-DD" |
|
|
|
@ -263,9 +285,9 @@ |
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column label="权限" width="160px"> |
|
|
|
|
<template #default="{ row }"> |
|
|
|
|
<el-select v-model="row.permission" placeholder="请选择" style="width: 130px"> |
|
|
|
|
<el-option label="公开" :value="0" /> |
|
|
|
|
<el-option label="仅上级可见" :value="1" /> |
|
|
|
|
<el-select v-model="row.dataScope" placeholder="请选择" style="width: 130px"> |
|
|
|
|
<el-option label="公开" :value="1" /> |
|
|
|
|
<el-option label="仅上级可见" :value="2" /> |
|
|
|
|
</el-select> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
@ -283,7 +305,8 @@ |
|
|
|
|
v-for="item in userOptions" |
|
|
|
|
:key="item.id" |
|
|
|
|
:label="item.name" |
|
|
|
|
:value="item.id" |
|
|
|
|
:value="item.id + ''" |
|
|
|
|
:disabled="item.status == 1" |
|
|
|
|
/> |
|
|
|
|
</el-select> |
|
|
|
|
</template> |
|
|
|
@ -303,6 +326,16 @@ |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
<script setup name="DialogOkrInfo"> |
|
|
|
|
import { |
|
|
|
|
getAllNodeTree, |
|
|
|
|
getOkrNodeDetail, |
|
|
|
|
createOkrNode, |
|
|
|
|
updateOkrNode, |
|
|
|
|
getAllOkrPage |
|
|
|
|
} from '@/api/okr/okr' |
|
|
|
|
import { listToTree } from '@/utils/tree' |
|
|
|
|
import { getEmployeeSimpleList } from '@/api/pers/employee' |
|
|
|
|
|
|
|
|
|
const { t } = useI18n() // 国际化 |
|
|
|
|
const message = useMessage() // 消息弹窗 |
|
|
|
|
|
|
|
|
@ -322,39 +355,20 @@ const formType = ref('create') |
|
|
|
|
|
|
|
|
|
const form = ref({}) |
|
|
|
|
const formLoading = ref(false) |
|
|
|
|
const rules = ref({}) |
|
|
|
|
const rules = ref({ |
|
|
|
|
nodeName: { required: true, message: '节点名称不可为空', trigger: 'blur' }, |
|
|
|
|
startTime: { required: true, message: '开始日期不可为空', trigger: 'change' }, |
|
|
|
|
endTime: { required: true, message: '截止日期不可为空', trigger: 'change' } |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
const okrKey = ref('okr') |
|
|
|
|
|
|
|
|
|
const parentNodeList = ref([ |
|
|
|
|
{ |
|
|
|
|
id: 1, |
|
|
|
|
label: '寻驾全年目标', |
|
|
|
|
children: [ |
|
|
|
|
{ id: 2, label: '1月' }, |
|
|
|
|
{ id: 3, label: '2月' }, |
|
|
|
|
{ id: 4, label: '3月' }, |
|
|
|
|
{ id: 5, label: '4月' }, |
|
|
|
|
{ id: 6, label: '5月' }, |
|
|
|
|
{ id: 7, label: '6月' }, |
|
|
|
|
{ id: 8, label: '7月' }, |
|
|
|
|
{ id: 9, label: '8月' }, |
|
|
|
|
{ id: 10, label: '9月' }, |
|
|
|
|
{ id: 11, label: '10月' }, |
|
|
|
|
{ id: 12, label: '11月' }, |
|
|
|
|
{ id: 13, label: '12月' } |
|
|
|
|
] |
|
|
|
|
} |
|
|
|
|
]) |
|
|
|
|
const parentNodeList = ref([]) |
|
|
|
|
|
|
|
|
|
const childNodeList = ref([{}]) |
|
|
|
|
const childNodeList = ref([]) |
|
|
|
|
|
|
|
|
|
const userOptions = ref([ |
|
|
|
|
{ id: 1, name: '张三' }, |
|
|
|
|
{ id: 2, name: '李四' }, |
|
|
|
|
{ id: 3, name: '王五' }, |
|
|
|
|
{ id: 4, name: '赵六' } |
|
|
|
|
]) |
|
|
|
|
const userOptions = ref([]) |
|
|
|
|
const krOptions = ref([]) |
|
|
|
|
const defaultProps = { |
|
|
|
|
children: 'children', |
|
|
|
|
label: 'sourceName', |
|
|
|
@ -362,151 +376,51 @@ const defaultProps = { |
|
|
|
|
isLeaf: 'leaf' |
|
|
|
|
} |
|
|
|
|
const sourceOptions = ref([]) |
|
|
|
|
const objectList = ref([ |
|
|
|
|
{ |
|
|
|
|
nodeId: 2, |
|
|
|
|
name: '1月销售任务概述,例:销售额100万,成交率15%', |
|
|
|
|
objExecutor: [1, 2], |
|
|
|
|
id: 'a1', |
|
|
|
|
children: [ |
|
|
|
|
{ |
|
|
|
|
id: 'a1-1', |
|
|
|
|
name: '销售额', |
|
|
|
|
isSystem: true, |
|
|
|
|
targetNum: 10000, |
|
|
|
|
targetValue: false, |
|
|
|
|
targetType: 'value' |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
id: 'a1-2', |
|
|
|
|
name: '成交数', |
|
|
|
|
isSystem: true, |
|
|
|
|
targetNum: 10000, |
|
|
|
|
targetValue: false, |
|
|
|
|
targetType: 'value' |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
id: 'a1-3', |
|
|
|
|
name: '成交率', |
|
|
|
|
isSystem: true, |
|
|
|
|
targetNum: 10000, |
|
|
|
|
targetValue: false, |
|
|
|
|
targetType: 'value' |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
id: 'a1-4', |
|
|
|
|
name: '本月抖音运营投入相较上月少10%', |
|
|
|
|
isSystem: false, |
|
|
|
|
targetNum: 0, |
|
|
|
|
targetValue: false, |
|
|
|
|
targetType: 'radio' |
|
|
|
|
} |
|
|
|
|
] |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
nodeId: 3, |
|
|
|
|
name: '1月运营目标', |
|
|
|
|
objExecutor: [1, 2], |
|
|
|
|
id: 'a2', |
|
|
|
|
children: [ |
|
|
|
|
{ |
|
|
|
|
id: 'a2-1', |
|
|
|
|
name: '销售额', |
|
|
|
|
isSystem: true, |
|
|
|
|
targetNum: 10000, |
|
|
|
|
targetValue: false, |
|
|
|
|
targetType: 'value' |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
id: 'a2-2', |
|
|
|
|
name: '成交数', |
|
|
|
|
isSystem: true, |
|
|
|
|
targetNum: 10000, |
|
|
|
|
targetValue: false, |
|
|
|
|
targetType: 'value' |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
id: 'a1-3', |
|
|
|
|
name: '成交率', |
|
|
|
|
isSystem: true, |
|
|
|
|
targetNum: 10000, |
|
|
|
|
targetValue: false, |
|
|
|
|
targetType: 'value' |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
id: 'a1-4', |
|
|
|
|
name: '本月抖音运营投入相较上月少10%', |
|
|
|
|
isSystem: false, |
|
|
|
|
targetNum: 0, |
|
|
|
|
targetValue: false, |
|
|
|
|
targetType: 'radio' |
|
|
|
|
} |
|
|
|
|
] |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
nodeId: 4, |
|
|
|
|
name: '1月主播任务', |
|
|
|
|
objExecutor: [1, 2], |
|
|
|
|
id: 'a3', |
|
|
|
|
children: [ |
|
|
|
|
{ |
|
|
|
|
id: 'a3-1', |
|
|
|
|
name: '销售额', |
|
|
|
|
isSystem: true, |
|
|
|
|
targetNum: 10000, |
|
|
|
|
targetValue: false, |
|
|
|
|
targetType: 'value' |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
id: 'a3-2', |
|
|
|
|
name: '成交数', |
|
|
|
|
isSystem: true, |
|
|
|
|
targetNum: 10000, |
|
|
|
|
targetValue: false, |
|
|
|
|
targetType: 'value' |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
id: 'a3-3', |
|
|
|
|
name: '成交率', |
|
|
|
|
isSystem: true, |
|
|
|
|
targetNum: 10000, |
|
|
|
|
targetValue: false, |
|
|
|
|
targetType: 'value' |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
id: 'a3-4', |
|
|
|
|
name: '本月抖音运营投入相较上月少10%', |
|
|
|
|
isSystem: false, |
|
|
|
|
targetNum: 0, |
|
|
|
|
targetValue: false, |
|
|
|
|
targetType: 'radio' |
|
|
|
|
} |
|
|
|
|
] |
|
|
|
|
} |
|
|
|
|
]) |
|
|
|
|
const objectList = ref([]) |
|
|
|
|
|
|
|
|
|
async function open(type, val) { |
|
|
|
|
function open(type, val) { |
|
|
|
|
show.value = true |
|
|
|
|
title.value = type == 'update' ? '修改Okr' : '新增Okr' |
|
|
|
|
formType.value = type |
|
|
|
|
resetForm() |
|
|
|
|
getEmployeeSimpleList().then((data) => { |
|
|
|
|
userOptions.value = data |
|
|
|
|
}) |
|
|
|
|
getAllNodeTree().then((resp) => { |
|
|
|
|
parentNodeList.value = listToTree(resp.tree, { |
|
|
|
|
id: 'nodeId', |
|
|
|
|
pid: 'parentId', |
|
|
|
|
children: 'children' |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
if (val) { |
|
|
|
|
formLoading.value = true |
|
|
|
|
try { |
|
|
|
|
// form.value = await KpiApi.getKpiDetail(val) |
|
|
|
|
getOkrNodeDetail(val).then((resp) => { |
|
|
|
|
form.value = resp |
|
|
|
|
if (resp.objectives) { |
|
|
|
|
objectList.value = resp.objectives.map((item) => ({ |
|
|
|
|
...item, |
|
|
|
|
keyResults: item.keyResults || [] |
|
|
|
|
})) |
|
|
|
|
} else { |
|
|
|
|
objectList.value = [] |
|
|
|
|
} |
|
|
|
|
childNodeList.value = [...resp.children] |
|
|
|
|
}) |
|
|
|
|
} finally { |
|
|
|
|
formLoading.value = false |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// getOptions() |
|
|
|
|
} |
|
|
|
|
function resetForm() { |
|
|
|
|
form.value = { |
|
|
|
|
parentId: '', |
|
|
|
|
name: '', |
|
|
|
|
createTime: '', |
|
|
|
|
endTime: '', |
|
|
|
|
executor: [] |
|
|
|
|
parentId: undefined, |
|
|
|
|
nodeName: undefined, |
|
|
|
|
startTime: undefined, |
|
|
|
|
endTime: undefined, |
|
|
|
|
executor: [], |
|
|
|
|
dataScope: 1 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -518,26 +432,36 @@ const emit = defineEmits(['success', 'close']) // 定义 success 事件,用于 |
|
|
|
|
|
|
|
|
|
function addObjective() { |
|
|
|
|
objectList.value.push({ |
|
|
|
|
name: '', |
|
|
|
|
objExecutor: [], |
|
|
|
|
children: [] |
|
|
|
|
objectiveName: '', |
|
|
|
|
executor: [], |
|
|
|
|
keyResults: [], |
|
|
|
|
dataScope: 1 |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function AddKR() { |
|
|
|
|
objectList.value.push({ |
|
|
|
|
name: '', |
|
|
|
|
objExecutor: [], |
|
|
|
|
children: [] |
|
|
|
|
function AddKR(idx) { |
|
|
|
|
if (!objectList.value[idx].keyResults) { |
|
|
|
|
objectList.value[idx].keyResults = [] |
|
|
|
|
} |
|
|
|
|
const obj = objectList.value[idx] |
|
|
|
|
objectList.value[idx].keyResults.push({ |
|
|
|
|
keyResultName: undefined, |
|
|
|
|
resultType: 1, |
|
|
|
|
source: undefined, |
|
|
|
|
targetValue: undefined, |
|
|
|
|
process: undefined, |
|
|
|
|
currentValue: undefined, |
|
|
|
|
executor: obj.executor, |
|
|
|
|
dataScope: obj.dataScope |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function removeObj() { |
|
|
|
|
objectList.value.pop() |
|
|
|
|
function removeObj(idx) { |
|
|
|
|
objectList.value.splice(idx, 1) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function removeKR() { |
|
|
|
|
objectList.value.pop() |
|
|
|
|
function removeKR(oIdx, krIdx) { |
|
|
|
|
objectList.value[oIdx].keyResults.splice(krIdx, 1) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function addChildNode() { |
|
|
|
@ -548,6 +472,23 @@ function removeChildNode(idx) { |
|
|
|
|
childNodeList.value.splice(idx, 1) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 读取父节点的OKR,并展示出来 |
|
|
|
|
function handleChangeParent() { |
|
|
|
|
// 通过父节点Id,查询父节点的okr,需要继承 |
|
|
|
|
if (form.value.parentId) { |
|
|
|
|
getAllOkrPage({ nodeId: form.value.parentId }).then((resp) => { |
|
|
|
|
objectList.value = resp |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function getLastDayOfMonth(year, month) { |
|
|
|
|
// 创建一个日期对象,将月份设置为指定月份的下一个月,日期设置为 0 |
|
|
|
|
const date = new Date(year, month + 1, 0) |
|
|
|
|
// 返回该日期对象的日期部分,即指定年月的最后一天 |
|
|
|
|
return date.getDate() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async function handleSave() { |
|
|
|
|
// 校验表单 |
|
|
|
|
if (!formRef.value) return |
|
|
|
@ -556,11 +497,47 @@ async function handleSave() { |
|
|
|
|
// 提交请求 |
|
|
|
|
formLoading.value = true |
|
|
|
|
try { |
|
|
|
|
form.value.objectives = objectList.value |
|
|
|
|
form.value.children = childNodeList.value |
|
|
|
|
if (formType.value === 'create') { |
|
|
|
|
// await KpiApi.createKpi(form.value) |
|
|
|
|
// 创建的是一级节点,且子节点为空时,自动新增12个月子节点,并且每月添加4周的周子节点 |
|
|
|
|
if (!form.value.parentId) { |
|
|
|
|
if (form.value.children.length == 0) { |
|
|
|
|
const defaultTime = new Date(form.value.startTime) |
|
|
|
|
for (let month = 0; month < 12; month++) { |
|
|
|
|
form.value.children.push({ |
|
|
|
|
nodeName: `${month + 1}月`, |
|
|
|
|
startTime: `${defaultTime.getFullYear()}-${String(month + 1).padStart(2, '0')}-01`, |
|
|
|
|
endTime: `${defaultTime.getFullYear()}-${String(month + 1).padStart( |
|
|
|
|
2, |
|
|
|
|
'0' |
|
|
|
|
)}-${getLastDayOfMonth(defaultTime.getFullYear(), month)}`, |
|
|
|
|
children: [ |
|
|
|
|
{ |
|
|
|
|
nodeName: `第${month + 1}月第1周`, |
|
|
|
|
children: [] |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
nodeName: `第${month + 1}月第2周`, |
|
|
|
|
children: [] |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
nodeName: `第${month + 1}月第3周`, |
|
|
|
|
children: [] |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
nodeName: `第${month + 1}月第3周`, |
|
|
|
|
children: [] |
|
|
|
|
} |
|
|
|
|
] |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
await createOkrNode(form.value) |
|
|
|
|
message.success(t('common.createSuccess')) |
|
|
|
|
} else { |
|
|
|
|
// await KpiApi.updateKpi(form.value) |
|
|
|
|
await updateOkrNode(form.value) |
|
|
|
|
message.success(t('common.updateSuccess')) |
|
|
|
|
} |
|
|
|
|
show.value = false |
|
|
|
|