| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- import { BasicColumn } from '/@/components/Table';
- import { FormSchema } from '/@/components/Table';
- import { h } from 'vue';
- import { Ref } from 'vue';
- import { StatusColorEnum } from '/@/enums/jeecgEnum';
- // 1. 颜色映射(修正原拼写错误,统一规则)
- // export const StatusColorEnum: Record<string, string> = {
- // blue: '#1890ff',
- // green: '#208840',
- // gold: '#faad14',
- // red: '#f5222d',
- // gray: '#8c8c8c',
- // black: '#000000',
- // };
- // 2. 定义生产状态映射类型(和dataQuality保持一致)
- export type ProductionStatusMap = Record<
- string | number,
- {
- label: string;
- value: number | string;
- color: string;
- }
- >;
- // 3. 生成动态表格列(接收动态状态映射)
- export function getColumns(dynamicStatusMap: Ref<ProductionStatusMap>): BasicColumn[] {
- return [
- {
- title: '煤矿编号',
- dataIndex: 'mineCode',
- width: 100,
- },
- {
- title: '所属执法处',
- dataIndex: 'managementName',
- width: 100,
- },
- {
- title: '煤矿名称',
- dataIndex: 'mineName',
- width: 200,
- },
- {
- title: '煤矿简称',
- dataIndex: 'mineNameAbbr',
- width: 100,
- ifShow: false,
- },
- {
- title: '生产状态',
- dataIndex: 'productionStatus',
- width: 100,
- customRender: ({ record }) => {
- // 空值/异常值处理
- const status = String(record.productionStatus || '');
- // 从动态映射取值,兜底未知状态
- const { label, color } = dynamicStatusMap.value[status] || {
- label: '-',
- };
- // 渲染带颜色的文字
- return h(
- 'span',
- {
- style: { color: StatusColorEnum[color] },
- },
- label
- );
- },
- },
- {
- title: '自燃倾向性',
- dataIndex: 'alarmLevel',
- width: 100,
- },
- {
- title: '接入状态',
- dataIndex: 'accessStatus',
- width: 100,
- customRender: ({ record }) => {
- // 空值/异常值处理
- const status = String(record.accessStatus || '');
- if (!status || status === 'undefined' || status === 'null') {
- return h('span', { style: { color: StatusColorEnum.black } }, '/');
- }
- const text = status === '1' ? '接入' : '未接入';
- const textColor = status === '1' ? StatusColorEnum.green : StatusColorEnum.gold;
- return h('span', { style: { color: textColor } }, text);
- },
- },
- {
- title: '在线状态',
- dataIndex: 'status',
- width: 100,
- customRender: ({ record }) => {
- const status = String(record.status || '');
- if (!status || status === 'undefined' || status === 'null') {
- return h('span', { style: { color: StatusColorEnum.black } }, '/');
- }
- const text = status === '1' ? '在线' : '离线';
- const textColor = status === '1' ? StatusColorEnum.green : StatusColorEnum.red;
- return h('span', { style: { color: textColor } }, text);
- },
- },
- {
- title: '应接数量',
- dataIndex: 'yingjieNum',
- width: 100,
- },
- {
- title: '已接数量',
- dataIndex: 'accessGoafNum',
- width: 100,
- },
- {
- title: '未接数量',
- dataIndex: 'notAccessGoafNum',
- width: 100,
- },
- ];
- }
- // 4. 生成动态搜索表单配置(接收动态下拉选项)
- export function getSearchFormSchema(dynamicStatusOptions: Ref<{ label: string; value: string | number }[]>): FormSchema[] {
- return [
- {
- field: 'mineCode',
- label: '煤矿名称',
- component: 'MineCascader',
- colProps: { span: 6 },
- },
- {
- field: 'mineNameAbbr',
- label: '煤矿简称',
- component: 'Input',
- colProps: { span: 6 },
- show: false,
- },
- {
- field: 'productionStatus',
- label: '生产状态',
- component: 'Select',
- componentProps: {
- // 动态绑定下拉选项
- options: dynamicStatusOptions,
- },
- colProps: { span: 6 },
- },
- {
- field: 'accessStatus',
- label: '接入状态',
- component: 'Select',
- componentProps: {
- options: [
- { label: '接入', value: 1 },
- { label: '未接入', value: 0 },
- ],
- },
- colProps: { span: 6 },
- },
- {
- field: 'status',
- label: '在线状态',
- component: 'Select',
- componentProps: {
- options: [
- { label: '离线', value: '0' },
- { label: '在线', value: '1' },
- ],
- },
- colProps: { span: 6 },
- },
- {
- field: 'riskLevel',
- label: '风险等级',
- component: 'Select',
- componentProps: {
- options: [
- { label: 'Ⅰ类容易自燃', value: '0' },
- { label: 'Ⅱ类自燃', value: '1' },
- { label: 'Ⅲ类不易自燃', value: '2' },
- ],
- },
- colProps: { span: 6 },
- show: false,
- },
- ];
- }
|