123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489 |
- <template>
- <div class="card-search">
- <a-form
- ref="formRef"
- name="advanced_search"
- class="ant-advanced-search-form"
- :model="searchParams"
- >
- <a-row :gutter="24">
- <a-col :span="6">
- <a-form-item label="日期" :label-col="{ span: 8 }" name="emphasisTypeId">
- <a-range-picker format="YYYY-MM-DD" :placeholder="['开始日期', '结束日期']" v-model:value="reportDate"
- @change="onRangeChange"/>
- </a-form-item>
- </a-col>
- <a-col :span="6" style="text-align: left">
- <a-button type="primary" html-type="submit" @click="onFinish">查询</a-button>
- <a-button
- style="margin: 0 8px"
- @click="
- () => {
- formRef.resetFields();
- onFinish();
- }
- ">重置
- </a-button>
- </a-col>
- </a-row>
- </a-form>
- <!-- 操作按钮 -->
- <a-row class="edit-operation" style="margin-bottom: 20px">
- <a-col :span="24" class="flex-space-between">
- <div>
- <a-radio-group v-model:value="searchType" button-style="solid" @change="searchTypeChange">
- <a-radio-button value="companyCount">各区县企业入库与走访情况统计</a-radio-button>
- <a-radio-button value="workSituationCount">各区县企业用工人数与岗位招聘人数统计</a-radio-button>
- <a-radio-button value="industryWorkSituationCount">各行业企业用工人数与岗位招聘人数统计</a-radio-button>
- </a-radio-group>
- </div>
- <div>
- </div>
- </a-col>
- </a-row>
- <!-- 数据展示 -->
- <!-- 企业入库与走访情况统计 -->
- <div v-show="searchType == 'companyCount'">
- <a-table :columns="companyCountDataTableColumns" :data-source="companyCountDataList"
- :scroll="{ x:'100%' }"
- :loading="searchLoading"
- :pagination="false"
- bordered>
- </a-table>
- </div>
- <!-- 企业用工人数与岗位招聘人数统计 -->
- <div v-show="searchType == 'workSituationCount'">
- <a-table :columns="workSituationCountDataTableColumns" :data-source="workSituationCountDataList"
- :scroll="{ x:'100%' }"
- :loading="searchLoading"
- :pagination="false"
- bordered>
- </a-table>
- </div>
- <!-- 企业用工人数与岗位招聘人数统计 -->
- <div v-show="searchType == 'industryWorkSituationCount'">
- <a-table :columns="industryWorkSituationCountDataTableColumns" :data-source="industryWorkSituationCountDataList"
- :scroll="{ x:'100%' }"
- :loading="searchLoading"
- :pagination="false"
- bordered>
- </a-table>
- </div>
- </div>
- </template>
- <script setup lang="ts">
- import {onMounted, reactive, ref} from "vue";
- import type {RangeValue} from "ant-design-vue/es/vc-picker/interface";
- import dayjs from "dayjs";
- import {getSysDictionaryList} from "@/api/system/dictionary";
- import {
- getIndustryCompanyWorkSituationCount,
- getRegionCompanyModelCompanyCount,
- getRegionCompanyWorkSituationCount
- } from "@/api/statistics";
- const searchParams = reactive({
- startDate: "",
- endDate: "",
- });
- const reportDate = ref<RangeValue<any>>();
- const searchType = ref("companyCount");
- const formRef = ref();
- const searchLoading = ref(false);
- const companyModelList = ref<Array<any>>();
- // 企业入库与走访情况统计表结构
- const companyCountDataTableColumns = ref<Array<any>>([
- {
- title: '区县', dataIndex: 'regionName', key: 'regionName', align: "center", width: 280
- },
- ]);
- const companyCountDataList = ref<Array<any>>([]);
- const companyCountKeyTemp = ref<Array<any>>([]);
- // 企业用工人数与岗位招聘人数统计表结构
- const workSituationCountDataTableColumns = ref<Array<any>>([
- {
- title: '区县', dataIndex: 'regionName', key: 'regionName', align: "center", width: 280
- },
- ]);
- const workSituationCountDataList = ref<Array<any>>([]);
- const workSituationCountKeyTemp = ref<Array<any>>([]);
- // 各行业企业用工人数与岗位招聘人数统计表结构
- const industryWorkSituationCountDataTableColumns = ref<Array<any>>([
- {
- title: '产业分类', dataIndex: 'estateCategoryName', key: 'estateCategoryName', align: "center", width: 150,
- customCell: (record, index: any) => {
- const obj = {
- colSpan: 1,
- rowSpan: 1,
- };
- if (record.estateCategoryName == '合计' || record.estateCategoryName == '小计') {
- obj.colSpan = 3;
- }
- if (index === 0 || record.estateCategoryName !== industryWorkSituationCountDataList.value[index - 1].estateCategoryName) {
- for (let i = index + 1; i < industryWorkSituationCountDataList.value.length; i++) {
- if (industryWorkSituationCountDataList.value[i].estateCategoryName == record.estateCategoryName) {
- obj.rowSpan++;
- } else {
- break;
- }
- }
- } else {
- obj.rowSpan = 0;
- }
- return obj;
- },
- }, {
- title: '所属行业', dataIndex: 'parentIndustryName', key: 'parentIndustryName', align: "center", width: 150,
- customCell: (record, index: any) => {
- const obj = {
- colSpan: 1,
- rowSpan: 1,
- };
- if (record.estateCategoryName == '合计' || record.estateCategoryName == '小计') {
- obj.colSpan = 0;
- }
- if (index === 0 || record.parentIndustryName !== industryWorkSituationCountDataList.value[index - 1].parentIndustryName) {
- for (let i = index + 1; i < industryWorkSituationCountDataList.value.length; i++) {
- if (industryWorkSituationCountDataList.value[i].parentIndustryName == record.parentIndustryName) {
- obj.rowSpan++;
- } else {
- break;
- }
- }
- } else {
- obj.rowSpan = 0;
- }
- return obj;
- },
- }, {
- title: '行业名称', dataIndex: 'industryName', key: 'industryName', align: "center", width: 200,
- customCell: (record) => {
- const obj = {
- colSpan: 1,
- rowSpan: 1,
- };
- if (record.estateCategoryName == '合计' || record.estateCategoryName == '小计') {
- obj.colSpan = 0;
- }
- return obj;
- },
- },
- ]);
- const industryWorkSituationCountDataList = ref<Array<any>>([]);
- const industryWorkSituationCountKeyTemp = ref<Array<any>>([]);
- // 时间段变更事件
- const onRangeChange = (dateString: [string, string]) => {
- searchParams.startDate = dateString != null ? dayjs(dateString[0]).format("YYYY-MM-DD") : "";
- searchParams.endDate = dateString != null ? dayjs(dateString[1]).format("YYYY-MM-DD") : "";
- onFinish();
- };
- function onFinish() {
- searchTypeChange();
- }
- // 获取企业规模
- function getCompanyModel() {
- getSysDictionaryList("CompanyModel").then((result: any) => {
- companyModelList.value = result;
- // 生成表结构
- result.forEach((item: any) => {
- const key = 'companyModel' + item.value;
- // 企业入库与走访情况统计表结构
- companyCountKeyTemp.value.push(...[key + 'Count', key + 'SigninCount']);
- companyCountDataTableColumns.value.push({
- title: item.name, dataIndex: key, key, align: "center",
- children: [
- {
- title: '入库',
- dataIndex: key + 'Count',
- key: key + 'Count',
- align: "center"
- },
- {
- title: '走访',
- dataIndex: key + 'SigninCount',
- key: key + 'SigninCount',
- align: "center"
- },
- ]
- })
- // 区县企业用工人数与岗位招聘人数统计表结构
- workSituationCountKeyTemp.value.push(...[key + 'WorkSituationCount', key + 'RecruitCount']);
- workSituationCountDataTableColumns.value.push({
- title: item.name, dataIndex: key, key, align: "center",
- children: [
- {
- title: '用工人数',
- dataIndex: key + 'WorkSituationCount',
- key: key + 'WorkSituationCount',
- align: "center"
- },
- {
- title: '岗位人数',
- dataIndex: key + 'RecruitCount',
- key: key + 'RecruitCount',
- align: "center"
- },
- ]
- })
- // 行业企业用工人数与岗位招聘人数统计表结构
- industryWorkSituationCountKeyTemp.value.push(...[key + 'WorkSituationCount', key + 'RecruitCount']);
- industryWorkSituationCountDataTableColumns.value.push({
- title: item.name, dataIndex: key, key, align: "center",
- children: [
- {
- title: '用工人数',
- dataIndex: key + 'WorkSituationCount',
- key: key + 'WorkSituationCount',
- align: "center"
- },
- {
- title: '岗位人数',
- dataIndex: key + 'RecruitCount',
- key: key + 'RecruitCount',
- align: "center"
- },
- ]
- })
- })
- });
- }
- function searchTypeChange() {
- if (searchType.value == "companyCount") {
- searchLoading.value = true;
- companyCountDataList.value = [];
- getRegionCompanyModelCompanyCount({...searchParams}).then((result: any) => {
- // 初始化合计数据
- let count = {
- regionCode: -1,
- regionName: "合计",
- }
- // 初始化字段值为O
- companyCountKeyTemp.value.forEach((key: any) => {
- count[key] = 0;
- })
- result.forEach((resItem: any) => {
- const key = 'companyModel' + resItem.companyModel;
- // 查询获取区县数据的下标,保证每个区县只存在一条数据
- const findIndex = companyCountDataList.value.findIndex((find: any) => find.regionCode == resItem.regionCode);
- if (findIndex > -1) {
- // 区县已存在,修改这条数据
- if (resItem.companyCount > 0) {
- companyCountDataList.value[findIndex][key + 'Count'] = resItem.companyCount;
- count[key + 'Count'] += resItem.companyCount;
- }
- if (resItem.signinCompanyCount > 0) {
- companyCountDataList.value[findIndex][key + 'SigninCount'] = resItem.signinCompanyCount;
- count[key + 'SigninCount'] += resItem.signinCompanyCount;
- }
- } else {
- // 不存在,新增一条数据
- const newData = {
- regionCode: resItem.regionCode,
- regionName: resItem.regionName,
- }
- companyCountKeyTemp.value.forEach((key: any) => {
- newData[key] = 0;
- })
- if (resItem.companyCount > 0) {
- newData[key + 'Count'] = resItem.companyCount;
- count[key + 'Count'] += resItem.companyCount;
- }
- if (resItem.signinCompanyCount > 0) {
- newData[key + 'SigninCount'] = resItem.signinCompanyCount;
- count[key + 'SigninCount'] += resItem.signinCompanyCount;
- }
- companyCountDataList.value.push(newData);
- }
- });
- console.log(count);
- companyCountDataList.value.push(count);
- }).finally(() => {
- searchLoading.value = false;
- })
- }
- if (searchType.value == "workSituationCount") {
- searchLoading.value = true;
- workSituationCountDataList.value = [];
- getRegionCompanyWorkSituationCount({...searchParams}).then((result: any) => {
- // 初始化合计数据
- let count = {
- regionCode: -1,
- regionName: "合计",
- }
- // 初始化字段值为O
- workSituationCountKeyTemp.value.forEach((key: any) => {
- count[key] = 0;
- });
- result.forEach((resItem: any) => {
- const key = 'companyModel' + resItem.companyModel;
- // 查询获取区县数据的下标,保证每个区县只存在一条数据
- const findIndex = workSituationCountDataList.value.findIndex((find: any) => find.regionCode == resItem.regionCode);
- if (findIndex > -1) {
- // 区县已存在,修改这条数据
- if (resItem.workSituationCount > 0) {
- workSituationCountDataList.value[findIndex][key + 'WorkSituationCount'] = resItem.workSituationCount;
- count[key + 'WorkSituationCount'] += resItem.workSituationCount;
- }
- if (resItem.recruitCount > 0) {
- workSituationCountDataList.value[findIndex][key + 'RecruitCount'] = resItem.recruitCount;
- count[key + 'RecruitCount'] += resItem.recruitCount;
- }
- } else {
- // 不存在,新增一条数据
- const newData = {
- regionCode: resItem.regionCode,
- regionName: resItem.regionName,
- }
- workSituationCountKeyTemp.value.forEach((key: any) => {
- newData[key] = 0;
- })
- if (resItem.workSituationCount > 0) {
- newData[key + 'WorkSituationCount'] = resItem.workSituationCount;
- count[key + 'WorkSituationCount'] += resItem.workSituationCount;
- }
- if (resItem.recruitCount > 0) {
- newData[key + 'RecruitCount'] = resItem.recruitCount;
- count[key + 'RecruitCount'] += resItem.recruitCount;
- }
- workSituationCountDataList.value.push(newData);
- }
- });
- workSituationCountDataList.value.push(count);
- }).finally(() => {
- searchLoading.value = false;
- })
- }
- if (searchType.value == "industryWorkSituationCount") {
- searchLoading.value = true;
- industryWorkSituationCountDataList.value = [];
- getIndustryCompanyWorkSituationCount({...searchParams}).then((result: any) => {
- // 初始化合计数据
- let count = {
- estateCategoryId: -1,
- estateCategoryName: "合计",
- parentIndustryName: "合计",
- industryName: "合计"
- }
- // 初始化字段值为O
- industryWorkSituationCountKeyTemp.value.forEach((key: any) => {
- count[key] = 0;
- });
- result.forEach((resItem: any) => {
- const key = 'companyModel' + resItem.companyModel;
- // 查询获取行业数据的下标,保证每个区县只存在一条数据
- const findIndex = industryWorkSituationCountDataList.value.findIndex((find: any) => find.industryName == resItem.industryName);
- if (findIndex > -1) {
- // 行业已存在,修改这条数据
- if (resItem.workSituationCount > 0) {
- industryWorkSituationCountDataList.value[findIndex][key + 'WorkSituationCount'] = resItem.workSituationCount;
- count[key + 'WorkSituationCount'] += resItem.workSituationCount;
- }
- if (resItem.recruitCount > 0) {
- industryWorkSituationCountDataList.value[findIndex][key + 'RecruitCount'] = resItem.recruitCount;
- count[key + 'RecruitCount'] += resItem.recruitCount;
- }
- } else {
- // 不存在,新增一条数据
- const newData = {
- parentIndustryName: resItem.parentIndustryName,
- industryName: resItem.industryName,
- }
- setEstateCategoryName(newData);
- industryWorkSituationCountKeyTemp.value.forEach((key: any) => {
- newData[key] = 0;
- })
- if (resItem.workSituationCount > 0) {
- newData[key + 'WorkSituationCount'] = resItem.workSituationCount;
- count[key + 'WorkSituationCount'] += resItem.workSituationCount;
- }
- if (resItem.recruitCount > 0) {
- newData[key + 'RecruitCount'] = resItem.recruitCount;
- count[key + 'RecruitCount'] += resItem.recruitCount;
- }
- industryWorkSituationCountDataList.value.push(newData);
- }
- });
- // 按产业分类进行排序
- industryWorkSituationCountDataList.value.sort((a, b) => a.estateCategoryId - b.estateCategoryId);
- // 统计小计数据
- calculateCategorySubtotal();
- // 在末尾添加合计数据
- industryWorkSituationCountDataList.value.push(count);
- }).finally(() => {
- searchLoading.value = false;
- })
- }
- }
- // 按一级行业名称判断所属产业
- function setEstateCategoryName(newData: any) {
- // 所属产业判断
- const categoryMap = {
- '农、林、牧、渔业': {name: '第一产业', id: 1},
- '采矿业': {name: '第二产业', id: 2},
- '制造业': {name: '第二产业', id: 2},
- '电力、热力、燃气及水生产和供应业': {name: '第二产业', id: 2},
- '建筑业': {name: '第二产业', id: 2}
- };
- if (newData.parentIndustryName && categoryMap[newData.parentIndustryName]) {
- const category = categoryMap[newData.parentIndustryName];
- newData.estateCategoryName = category.name;
- newData.estateCategoryId = category.id;
- } else {
- newData.estateCategoryName = '第三产业';
- newData.estateCategoryId = 3;
- }
- }
- // 统计小计数据
- function calculateCategorySubtotal() {
- // 初始化每个类别的计数对象
- const categorySubtotal = {
- 1: {}, // 第一产业
- 2: {}, // 第二产业
- 3: {} // 第三产业
- };
- // 初始化字段值为0
- industryWorkSituationCountKeyTemp.value.forEach((key: any) => {
- [1, 2, 3].forEach(categoryId => {
- categorySubtotal[categoryId][key] = 0;
- });
- });
- // 循环统计数据,进行小计数量的累加
- industryWorkSituationCountDataList.value.forEach((count: any) => {
- if (categorySubtotal[count.estateCategoryId]) {
- Object.keys(categorySubtotal[count.estateCategoryId]).forEach(key => {
- categorySubtotal[count.estateCategoryId][key] += count[key];
- });
- }
- });
- // 设置文本字段名称
- ['estateCategoryName', 'parentIndustryName', 'industryName'].forEach((key: any) => {
- [1, 2, 3].forEach(categoryId => {
- categorySubtotal[categoryId][key] = '小计';
- });
- });
- // 向表格插入小计数据
- [1, 2, 3].forEach(categoryId => {
- const lastIndex = industryWorkSituationCountDataList.value.map(item => item.estateCategoryId).lastIndexOf(categoryId);
- if (lastIndex !== -1) {
- industryWorkSituationCountDataList.value.splice(lastIndex + 1, 0, categorySubtotal[categoryId]);
- }
- });
- }
- onMounted(() => {
- getCompanyModel();
- onFinish();
- })
- </script>
- <style scoped>
- </style>
|