2 changed files with 237 additions and 6 deletions
@ -0,0 +1,225 @@ |
|||
<template> |
|||
<div> |
|||
<a-modal v-model:open="visible" :title="title" @ok="handleOk" @cancel="closeModal" width="80%"> |
|||
<div style="margin: 20px"> |
|||
<a-form :model="form" layout="vertical" ref="formRef" :rules="rules"> |
|||
<a-row :gutter="[16, 16]"> |
|||
<a-col :span="12"> |
|||
<a-form-item label="项目名称" name="projectName"> |
|||
<a-input v-model:value="form.projectName" placeholder="请输入考核项目" /> |
|||
</a-form-item> |
|||
</a-col> |
|||
</a-row> |
|||
<a-row :gutter="[16, 16]"> |
|||
<a-col :span="12"> |
|||
<a-form-item label="模板名称" name="templateName"> |
|||
<a-select |
|||
v-model:value="form.templateName" |
|||
:options="templateNameOptions" |
|||
@change="templateNameChange" |
|||
placeholder="请选择模板" |
|||
:fieldNames="{ |
|||
label: 'name', |
|||
value: 'type', |
|||
options: 'options', |
|||
}" |
|||
/> |
|||
</a-form-item> |
|||
</a-col> |
|||
</a-row> |
|||
<a-row :gutter="[16, 16]"> |
|||
<a-col :span="24"> |
|||
<a-table |
|||
:dataSource="form.dataSource" |
|||
:columns="columns" |
|||
bordered |
|||
:pagination="false" |
|||
> |
|||
<template #bodyCell="{ column, record }"> |
|||
<template v-if="column && record && column.dataIndex === 'realScores'&&record.primaryIndicator!='附加分'"> |
|||
<a-input-number |
|||
v-model:value="record.realScores" |
|||
:min="0" |
|||
:max="record.scores" |
|||
/> |
|||
</template> |
|||
</template> |
|||
</a-table> |
|||
</a-col> |
|||
</a-row> |
|||
</a-form> |
|||
</div> |
|||
</a-modal> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import { computed, reactive, ref } from 'vue'; |
|||
import { getPerformancescore, getPerforman } from '../templateContent/templateContent.api'; |
|||
import { message } from 'ant-design-vue'; |
|||
export default { |
|||
setup() { |
|||
const title = ref('新增绩效考核'); |
|||
const visible = ref(false); |
|||
const formRef = ref(); |
|||
const columns = [ |
|||
{ |
|||
title: '评价维度', |
|||
width: 150, |
|||
dataIndex: 'evaluationDimension', |
|||
customRender: ({ text, record, index }) => { |
|||
const obj = { |
|||
children: text, |
|||
props: {}, |
|||
}; |
|||
if (record.evaluationLength != null && record.evaluationLength != 0) { |
|||
obj.props.rowSpan = record.evaluationLength; |
|||
} else { |
|||
obj.props.rowSpan = 0; |
|||
} |
|||
return obj; |
|||
}, |
|||
}, |
|||
{ |
|||
title: '一级指标', |
|||
dataIndex: 'primaryIndicator', |
|||
width: 150, |
|||
customRender: ({ text, record, index }) => { |
|||
const obj = { |
|||
children: text, |
|||
props: {}, |
|||
}; |
|||
if (record.primaryLength != null && record.primaryLength != 0) { |
|||
obj.props.rowSpan = record.primaryLength; |
|||
} else { |
|||
obj.props.rowSpan = 0; |
|||
} |
|||
return obj; |
|||
}, |
|||
}, |
|||
{ |
|||
title: '二级指标', |
|||
width: 150, |
|||
dataIndex: 'secondaryIndicator', |
|||
customRender: ({ text, record, index }) => { |
|||
const obj = { |
|||
children: text, |
|||
props: {}, |
|||
}; |
|||
if (record.secondaryLength != null) { |
|||
obj.props.rowSpan = record.secondaryLength; |
|||
} else { |
|||
obj.props.rowSpan = 0; |
|||
} |
|||
return obj; |
|||
}, |
|||
}, |
|||
|
|||
{ |
|||
title: '三级指标', |
|||
width: 150, |
|||
dataIndex: 'tertiaryIndicator', |
|||
customRender: ({ text, record, index }) => { |
|||
const obj = { |
|||
children: text, |
|||
props: {}, |
|||
}; |
|||
if (record.tertiaryLength != null) { |
|||
obj.props.rowSpan = record.tertiaryLength; |
|||
} else { |
|||
obj.props.rowSpan = 0; |
|||
} |
|||
return obj; |
|||
}, |
|||
}, |
|||
{ |
|||
title: '描述', |
|||
resizable: true, |
|||
ellipsis: false, |
|||
dataIndex: 'description', |
|||
}, |
|||
{ |
|||
title: '分数', |
|||
width: 80, |
|||
dataIndex: 'scores', |
|||
}, |
|||
{ |
|||
title: '评分', |
|||
width: 100, |
|||
dataIndex: 'realScores', |
|||
}, |
|||
]; |
|||
const form = reactive({ |
|||
projectName: '', |
|||
templateName: null, |
|||
dataSource: [], |
|||
}); |
|||
|
|||
const showModal = async (type, id) => { |
|||
visible.value = true; |
|||
const data = await getPerforman(); |
|||
templateNameOptions.value = data; |
|||
}; |
|||
//下拉框 |
|||
const projectNameOptions = ref([]); |
|||
const templateNameOptions = ref([]); |
|||
const templateNameChange = async (val) => { |
|||
const data = await getPerformancescore({ type: val }); |
|||
form.dataSource = data; |
|||
}; |
|||
const handleOk = () => { |
|||
// let params = {}; |
|||
// for (let i in form) { |
|||
// params[i] = form[i]; |
|||
// } |
|||
// add(params).then((_) => { |
|||
// message.success('新增成功'); |
|||
// emit('success'); |
|||
// closeModal(); |
|||
// }); |
|||
|
|||
if (form.dataSource && form.dataSource.length > 0) { |
|||
let scored = true; |
|||
for (let i = 0; i < form.dataSource.length; i++) { |
|||
if (!form.dataSource[i].realScores&&form.dataSource[i].primaryIndicator!='附加分') { |
|||
message.warning('请完成评分后再提交'); |
|||
console.log(i) |
|||
scored = false; |
|||
break; |
|||
} |
|||
} |
|||
if (scored) { |
|||
console.log(form); |
|||
} |
|||
}else{ |
|||
message.warning('请完成评分后再提交'); |
|||
} |
|||
}; |
|||
const closeModal = () => { |
|||
formRef.value.resetFields(); |
|||
form.dataSource = []; |
|||
}; |
|||
return { |
|||
visible, |
|||
title, |
|||
columns, |
|||
form, |
|||
formRef, |
|||
showModal, |
|||
handleOk, |
|||
closeModal, |
|||
projectNameOptions, |
|||
templateNameOptions, |
|||
templateNameChange, |
|||
}; |
|||
}, |
|||
}; |
|||
</script> |
|||
|
|||
<style scoped> |
|||
/* 可选样式调整 */ |
|||
.ant-modal-body { |
|||
max-width: 600px; |
|||
margin: 0 auto; |
|||
} |
|||
</style> |
Loading…
Reference in new issue