Browse Source

性格色彩接口对接

yjf_v3
DESKTOP-CUI7KST\HXGK 2 years ago
parent
commit
ab8c4c20d6
  1. 105
      src/api/hr/people/index.ts
  2. 9
      src/api/hr/people/type.ts
  3. 1
      src/types/components.d.ts
  4. 213
      src/views/hr/archives/basicinformation/charactercolor.vue

105
src/api/hr/people/index.ts

@ -35,6 +35,7 @@ import {
JobtitleContEdit,
CertificatesContAdd,
CertificatesContEdit,
contNumber,
} from './type';
/**
*
@ -378,149 +379,205 @@ import {
data: data
});
}
//获取性格色彩
export function getCharacterColor(data?: contNumber):any {
return request({
url: '/hrapi/staff/getPeopleColor',
method: 'post',
data: data
});
}
// 获取奖惩记录
export function getRewardsAndPunishmentsCont(data?: contId) {
return request({
url: '/hrapi/',
method: 'post',
data: data
})
}
//添加奖惩记录
export function addRewardsAndPunishmentsCont(data?: RewardsAndPunishmentsContAdd) {
return request({
url: '/hrapi/',
method: 'post',
data: data
})
}
//编辑奖惩记录
export function editRewardsAndPunishmentsCont(data?: RewardsAndPunishmentsContEdit) {
return request({
url: '/hrapi/',
method: 'post',
data: data
})
}
//编辑奖惩记录状态
export function editRewardsAndPunishmentsContState(data?: delJjlxr) {
return request({
url: '/hrapi/',
method: 'post',
data: data
})
}
//获取考评记录
export function getAppraisalrecordCont(data?: contId) {
return request({
url: '/hrapi/',
method: 'post',
data: data
})
}
//添加考评记录
export function addAppraisalrecordCont(data?: AppraisalrecordContAdd) {
return request({
url: '/hrapi/',
method: 'post',
data: data
})
}
//编辑考评记录
export function editAppraisalrecordCont(data?: AppraisalrecordContEdit) {
return request({
url: '/hrapi/',
method: 'post',
data: data
})
}
//编辑考评记录状态
export function editAppraisalrecordContState(data?: delJjlxr) {
return request({
url: '/hrapi/',
method: 'post',
data: data
})
}
//获取人才盘点
export function getTalentinventoryCont(data?: contId) {
return request({
url: '/hrapi/',
method: 'post',
data: data
})
}
//添加人才盘点
export function addTalentinventoryCont(data?: TalentinventoryContAdd) {
return request({
url: '/hrapi/',
method: 'post',
data: data
})
}
//编辑人才盘点
export function editTalentinventoryCont(data?: TalentinventoryContEdit) {
return request({
url: '/hrapi/',
method: 'post',
data: data
})
}
//编辑人才盘点状态
export function editTalentinventoryContState(data?: delJjlxr) {
return request({
url: '/hrapi/',
method: 'post',
data: data
})
}
//获取用工关系
export function getEmploymentrelationsCont(data?: contId) {
return request({
url: '/hrapi/',
method: 'post',
data: data
})
}
//添加用工关系
export function addEmploymentrelationsCont(data?: EmploymentrelationsContAdd) {
return request({
url: '/hrapi/',
method: 'post',
data: data
})
}
//编辑用工关系
export function editEmploymentrelationsCont(data?: EmploymentrelationsContEdit) {
return request({
url: '/hrapi/',
method: 'post',
data: data
})
}
//编辑用工关系状态
export function editEmploymentrelationsContState(data?: delJjlxr) {
return request({
url: '/hrapi/',
method: 'post',
data: data
})
}
//获取职称信息
export function getJobtitleCont(data?: contId) {
return request({
url: '/hrapi/',
method: 'post',
data: data
})
}
//添加职称信息
export function addJobtitleCont(data?: JobtitleContAdd) {
return request({
url: '/hrapi/',
method: 'post',
data: data
})
}
//编辑职称信息
export function editJobtitleCont(data?: JobtitleContEdit) {
return request({
url: '/hrapi/',
method: 'post',
data: data
})
}
//编辑职称信息状态
export function editJobtitleContState(data?: delJjlxr) {
return request({
url: '/hrapi/',
method: 'post',
data: data
})
}
//获取证书信息
export function getCertificatesCont(data?: contId) {
return request({
url: '/hrapi/',
method: 'post',
data: data
})
}
//添加证书信息
export function addCertificatesCont(data?: CertificatesContAdd) {
return request({
url: '/hrapi/',
method: 'post',
data: data
})
}
//编辑证书信息
export function editCertificatesCont(data?: CertificatesContEdit) {
return request({
url: '/hrapi/',
method: 'post',
data: data
})
}
//编辑证书信息状态
export function editCertificatesContState(data?: delJjlxr) {
return request({
url: '/hrapi/',
method: 'post',
data: data
})
}

9
src/api/hr/people/type.ts

@ -596,6 +596,15 @@ export interface queryPeopleCont{
tema:number // 1,
temaname:string // "长白班"
}
//根据工号获取性格色彩
export interface contNumber{
number:number;
}
export interface charactercolor{
id:string;
number:number;
color?:string;
}
//奖惩记录
export interface jiangchengjilu{

1
src/types/components.d.ts

@ -48,6 +48,7 @@ declare module '@vue/runtime-core' {
ElDropdown: typeof import('element-plus/es')['ElDropdown']
ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu']
ElEmpty: typeof import('element-plus/es')['ElEmpty']
ElForm: typeof import('element-plus/es')['ElForm']
ElFormItem: typeof import('element-plus/es')['ElFormItem']
ElHeader: typeof import('element-plus/es')['ElHeader']

213
src/views/hr/archives/basicinformation/charactercolor.vue

@ -4,73 +4,169 @@
@ 备注: 性格色彩
-->
<script lang="ts" setup>
import { ref } from "vue";
import * as echarts from "echarts";
// ref
const topTwoColours = ref<string[]>([]);
const option = {
tooltip: {
trigger: "axis",
import { ref, onMounted, onUnmounted, nextTick } from 'vue';
import * as echarts from 'echarts';
import { getCharacterColor } from '@/api/hr/people';
const props = defineProps({
tabsid: {
type: String,
default: "1",
},
radar: [
{
indicator: [
{ name: "红色", max: 100 },
{ name: "蓝色", max: 100 },
{ name: "黄色", max: 100 },
{ name: "绿色", max: 100 },
],
center: ["50%", "50%"],
radius: 90,
usercont:{
type:Object,
default(){
return {}
}
}
});
//
const chartContainer = ref<HTMLDivElement | null>(null);
let chartInstance: echarts.ECharts | null = null;
// ColourNameList
const ColourNameList = ref<string[]>([]);
const error = ref<string | null>(null);
//
let resizeObserver: ResizeObserver | null = null;
// 使number
const isReadyToInit = computed(() => {
return props.usercont.number !== undefined && props.usercont.number.trim() !== '';
});
// ECharts
const initChart = async () => {
// console.log(chartContainer.value)
//
if (chartInstance) {
chartInstance.dispose();
chartInstance = null;
}
//chartContainerDOM
if (!chartContainer.value) {
console.warn('DOM元素未找到,无法初始化图表');
return;
}
try {
// usercont.number
if (!isReadyToInit.value) {
throw new Error("员工信息未准备好,无法初始化图表");
}
//
const response = await getCharacterColor({ number: props.usercont.number });
//
chartInstance = echarts.init(chartContainer.value);
// console.log('Response:', response, chartInstance);
if (response.code === 0) {
//
const { ColourNameList: apiColourNameList, RadarColour } = response.data;
ColourNameList.value = apiColourNameList; //
// 使ColourNameList
const allColours = ["红色", "蓝色", "黄色", "绿色"];
//
updateRadarChart(chartInstance, RadarColour, allColours);
} else {
ElMessage.error(response.data.msg || '系统出错');
}
} catch (e) {
console.error(e);
}
}
//
const updateRadarChart = (chart: echarts.ECharts, radarColour: any[], colourNameList: string[]) => {
const radarOptions = createRadarOptions(radarColour, colourNameList);
chart.setOption(radarOptions);
chart.resize();
// colourNameListColourNameList便使
// ColourNameList.value = colourNameList;
}
//
const createRadarOptions = (radarColour: any[], colourNameList: string[]) => {
let maxVal = Math.max(...radarColour);
return {
tooltip: { trigger: "item" },
radar: {
indicator: colourNameList.map((color, index) => ({
name: color,
max: maxVal + 2,
min: 0 ,
})),
shape: "circle",
splitNumber: 4,
},
],
series: [
{
name: "个人性格色彩",
type: "radar",
tooltip: {
trigger: "item",
},
areaStyle: {},
data: [
{
value: [77, 55, 66, 33],
name: "性格色彩",
areaStyle: {
//
color: '#a0c3f8',
},
],
data: [{ value: radarColour,
name: "个人色彩分布"
}],
itemStyle: { color: "#3c96ff" }, //
},
],
};
onMounted(() => {
//
const values = option.series[0].data[0].value;
const colors = ["红色", "蓝色", "黄色", "绿色"];
const percentages = values.map((val) => val / 100);
const sortedColors = colors.sort(
(a, b) => percentages[colors.indexOf(b)] - percentages[colors.indexOf(a)]
);
topTwoColours.value = sortedColors.slice(0, 2);
// echarts
Promise.resolve().then(() => {
const dom = document.getElementById("myChart");
const myChart = echarts.init(dom);
window.addEventListener("resize", () => {
myChart.resize(); //
});
myChart.setOption(option);
};
}
onMounted(async () => {
//DOMecharts
await nextTick();
// console.log(chartContainer.value);
// ResizeObserver
resizeObserver = new ResizeObserver(() => {
if (chartInstance) {
chartInstance.resize();
}
});
resizeObserver.observe(chartContainer.value!); // chartContainer
});
//
watch(
() => ({
usercont: props.usercont,
tabsid: props.tabsid
}),
async (newValues) => {
const { usercont, tabsid } = newValues;
// tabsid'2'usercont.number
if (tabsid === '2' && usercont.number) {
error.value = null;
await nextTick();
await initChart();
} else if (usercont.number) {
// usercont.number
error.value = null;
await nextTick();
await initChart();
} else {
error.value = "员工信息未准备好";
}
},
{ immediate: true, deep: true }
);
// ECharts
onUnmounted(() => {
if (chartInstance) {
chartInstance.dispose();
chartInstance = null;
}
// ResizeObserver
if (resizeObserver) {
resizeObserver.disconnect();
resizeObserver = null;
}
});
//tabsid
// watch(()=>props.tabsid,(val:string)=>{
// if(val == '2'){
// initChart();
// }
// })
</script>
<template>
<div>
<div class="title">性格色彩特质</div>
<!-- 雷达图 -->
<div id="myChart" class="chart"></div>
<!-- 文字部分 -->
<div class="text-content">
<el-row>
<el-col v-for="(item, index) in topTwoColours" :key="index" :span="24">
<!-- 在模板中根据loading状态显示加载提示 -->
<div class="chart-container">
<div ref="chartContainer" class="chart"></div>
<div v-for="(item, index) in ColourNameList" :key="index">
<div v-if="item == '红色'">
<el-text type="info" class="color-title">{{ item }}<br/></el-text>
<el-text type="info">他们的优势是<br /></el-text>
@ -123,13 +219,14 @@ onMounted(() => {
<el-text type="info">没有主见</el-text>
<el-text type="info">缺乏创意<br /></el-text>
</div>
</el-col>
</el-row>
</div>
</div>
</template>
<style scoped>
.chart-container {
width: 100%;
height: 100%;
}
.title {
font-size: 18px;
font-weight: bold;

Loading…
Cancel
Save