minesInfo.data.ts 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. import { BasicColumn } from '/@/components/Table';
  2. import { FormSchema } from '/@/components/Table';
  3. import { h } from 'vue';
  4. import { Ref } from 'vue';
  5. import { StatusColorEnum } from '/@/enums/jeecgEnum';
  6. // 1. 颜色映射(修正原拼写错误,统一规则)
  7. // export const StatusColorEnum: Record<string, string> = {
  8. // blue: '#1890ff',
  9. // green: '#208840',
  10. // gold: '#faad14',
  11. // red: '#f5222d',
  12. // gray: '#8c8c8c',
  13. // black: '#000000',
  14. // };
  15. // 2. 定义生产状态映射类型(和dataQuality保持一致)
  16. export type ProductionStatusMap = Record<
  17. string | number,
  18. {
  19. label: string;
  20. value: number | string;
  21. color: string;
  22. }
  23. >;
  24. // 3. 生成动态表格列(接收动态状态映射)
  25. export function getColumns(dynamicStatusMap: Ref<ProductionStatusMap>): BasicColumn[] {
  26. return [
  27. {
  28. title: '煤矿编号',
  29. dataIndex: 'mineCode',
  30. width: 100,
  31. },
  32. {
  33. title: '所属执法处',
  34. dataIndex: 'managementName',
  35. width: 100,
  36. },
  37. {
  38. title: '煤矿名称',
  39. dataIndex: 'mineName',
  40. width: 200,
  41. },
  42. {
  43. title: '煤矿简称',
  44. dataIndex: 'mineNameAbbr',
  45. width: 100,
  46. ifShow: false,
  47. },
  48. {
  49. title: '生产状态',
  50. dataIndex: 'productionStatus',
  51. width: 100,
  52. customRender: ({ record }) => {
  53. // 空值/异常值处理
  54. const status = String(record.productionStatus || '');
  55. // 从动态映射取值,兜底未知状态
  56. const { label, color } = dynamicStatusMap.value[status] || {
  57. label: '-',
  58. };
  59. // 渲染带颜色的文字
  60. return h(
  61. 'span',
  62. {
  63. style: { color: StatusColorEnum[color] },
  64. },
  65. label
  66. );
  67. },
  68. },
  69. {
  70. title: '自燃倾向性',
  71. dataIndex: 'alarmLevel',
  72. width: 100,
  73. },
  74. {
  75. title: '接入状态',
  76. dataIndex: 'accessStatus',
  77. width: 100,
  78. customRender: ({ record }) => {
  79. // 空值/异常值处理
  80. const status = String(record.accessStatus || '');
  81. if (!status || status === 'undefined' || status === 'null') {
  82. return h('span', { style: { color: StatusColorEnum.black } }, '/');
  83. }
  84. const text = status === '1' ? '接入' : '未接入';
  85. const textColor = status === '1' ? StatusColorEnum.green : StatusColorEnum.gold;
  86. return h('span', { style: { color: textColor } }, text);
  87. },
  88. },
  89. {
  90. title: '在线状态',
  91. dataIndex: 'status',
  92. width: 100,
  93. customRender: ({ record }) => {
  94. const status = String(record.status || '');
  95. if (!status || status === 'undefined' || status === 'null') {
  96. return h('span', { style: { color: StatusColorEnum.black } }, '/');
  97. }
  98. const text = status === '1' ? '在线' : '离线';
  99. const textColor = status === '1' ? StatusColorEnum.green : StatusColorEnum.red;
  100. return h('span', { style: { color: textColor } }, text);
  101. },
  102. },
  103. {
  104. title: '应接数量',
  105. dataIndex: 'yingjieNum',
  106. width: 100,
  107. },
  108. {
  109. title: '已接数量',
  110. dataIndex: 'accessGoafNum',
  111. width: 100,
  112. },
  113. {
  114. title: '未接数量',
  115. dataIndex: 'notAccessGoafNum',
  116. width: 100,
  117. },
  118. ];
  119. }
  120. // 4. 生成动态搜索表单配置(接收动态下拉选项)
  121. export function getSearchFormSchema(dynamicStatusOptions: Ref<{ label: string; value: string | number }[]>): FormSchema[] {
  122. return [
  123. {
  124. field: 'mineCode',
  125. label: '煤矿名称',
  126. component: 'MineCascader',
  127. colProps: { span: 6 },
  128. },
  129. {
  130. field: 'mineNameAbbr',
  131. label: '煤矿简称',
  132. component: 'Input',
  133. colProps: { span: 6 },
  134. show: false,
  135. },
  136. {
  137. field: 'productionStatus',
  138. label: '生产状态',
  139. component: 'Select',
  140. componentProps: {
  141. // 动态绑定下拉选项
  142. options: dynamicStatusOptions,
  143. },
  144. colProps: { span: 6 },
  145. },
  146. {
  147. field: 'accessStatus',
  148. label: '接入状态',
  149. component: 'Select',
  150. componentProps: {
  151. options: [
  152. { label: '接入', value: 1 },
  153. { label: '未接入', value: 0 },
  154. ],
  155. },
  156. colProps: { span: 6 },
  157. },
  158. {
  159. field: 'status',
  160. label: '在线状态',
  161. component: 'Select',
  162. componentProps: {
  163. options: [
  164. { label: '离线', value: '0' },
  165. { label: '在线', value: '1' },
  166. ],
  167. },
  168. colProps: { span: 6 },
  169. },
  170. {
  171. field: 'riskLevel',
  172. label: '风险等级',
  173. component: 'Select',
  174. componentProps: {
  175. options: [
  176. { label: 'Ⅰ类容易自燃', value: '0' },
  177. { label: 'Ⅱ类自燃', value: '1' },
  178. { label: 'Ⅲ类不易自燃', value: '2' },
  179. ],
  180. },
  181. colProps: { span: 6 },
  182. show: false,
  183. },
  184. ];
  185. }