dataQuality.data.ts 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. import dayjs from 'dayjs';
  2. import { BasicColumn, FormSchema } from '/@/components/Table';
  3. // import { h } from 'vue';
  4. // import { Ref } from 'vue';
  5. // import dayjs from 'dayjs';
  6. // 1. 颜色映射(固定规则,可根据业务调整)
  7. export const colorHexMap: Record<string, string> = {
  8. blue: '#1890ff',
  9. green: '#208840',
  10. gold: '#faad14',
  11. red: '#f5222d',
  12. gray: '#8c8c8c',
  13. black: '#000000',
  14. };
  15. // 2. 定义动态映射的类型(供外部传入)
  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 const columns: BasicColumn[] = [
  26. {
  27. title: '煤矿名称',
  28. dataIndex: 'mineName',
  29. width: 250,
  30. },
  31. {
  32. title: '煤矿简称',
  33. dataIndex: 'mineNameAbbr',
  34. width: 150,
  35. // ifShow: false,
  36. },
  37. {
  38. title: '生产状态',
  39. dataIndex: 'gjMineStatus',
  40. width: 120,
  41. // customRender: ({ record }) => {
  42. // // 空值/异常值处理
  43. // const status = record.mineProStatus;
  44. // // 从动态映射中取值,兜底未知状态
  45. // const { label, color } = dynamicStatusMap.value[status] || {
  46. // label: '-',
  47. // };
  48. // return h(
  49. // 'span',
  50. // {
  51. // style: { color: colorHexMap[color] },
  52. // },
  53. // label
  54. // );
  55. // },
  56. },
  57. {
  58. title: '定义数据错误',
  59. dataIndex: 'cddyError',
  60. width: 200,
  61. },
  62. {
  63. title: '最近定义数据错误时间',
  64. dataIndex: 'lastCddyTime',
  65. width: 200,
  66. },
  67. {
  68. title: '实时数据错误',
  69. dataIndex: 'cdssError',
  70. width: 200,
  71. },
  72. {
  73. title: '最近实时数据错误时间',
  74. dataIndex: 'lastCdssTime',
  75. width: 200,
  76. },
  77. // {
  78. // title: '在线状态',
  79. // dataIndex: 'mineLinkStatus',
  80. // width: 100,
  81. // customRender: ({ record }) => {
  82. // const status = record.mineLinkStatus;
  83. // if (status === undefined || status === null) {
  84. // return h('span', { style: { color: colorHexMap.black } }, '-');
  85. // }
  86. // const text = status === 1 ? '在线' : '离线';
  87. // const textColor = status === 1 ? colorHexMap.green : colorHexMap.red;
  88. // return h('span', { style: { color: textColor } }, text);
  89. // },
  90. // },
  91. // {
  92. // title: '质量问题详情',
  93. // dataIndex: 'queJson',
  94. // width: 400,
  95. // ellipsis: true,
  96. // slots: { customRender: 'queJson' },
  97. // },
  98. // {
  99. // title: '当前状态',
  100. // dataIndex: 'isOk',
  101. // width: 100,
  102. // customRender: ({ record }) => {
  103. // const status = record.isOk;
  104. // const text = status ? '已解决' : '未解决';
  105. // const textColor = status ? colorHexMap.green : colorHexMap.red;
  106. // return h('span', { style: { color: textColor } }, text);
  107. // },
  108. // },
  109. // {
  110. // title: '处理时间',
  111. // dataIndex: 'updateTime',
  112. // width: 180,
  113. // },
  114. ];
  115. // 3. 生成表格列(支持传入动态映射)
  116. export const historyColumns: BasicColumn[] = [
  117. {
  118. title: '煤矿名称',
  119. dataIndex: 'mineName',
  120. width: 250,
  121. },
  122. {
  123. title: '错误信息',
  124. dataIndex: 'errorContent',
  125. width: 200,
  126. },
  127. {
  128. title: '起始时间',
  129. dataIndex: 'startTime',
  130. width: 200,
  131. },
  132. {
  133. title: '结束时间',
  134. dataIndex: 'endTime',
  135. width: 200,
  136. },
  137. ];
  138. // 4. 查询表单配置(下拉框改为动态options)
  139. export const searchFormSchema: FormSchema[] = [
  140. {
  141. field: 'deptId',
  142. label: '煤矿名称',
  143. component: 'MineCascader',
  144. colProps: { span: 6 },
  145. groupName: '常规查询',
  146. },
  147. // 启用生产状态下拉框(动态options)
  148. {
  149. field: 'gjMineStatus',
  150. label: '生产状态',
  151. component: 'JDictSelectTag',
  152. componentProps: {
  153. dictCode: 'mineProStatus',
  154. placeholder: '请选择生产状态',
  155. },
  156. colProps: { span: 6 },
  157. },
  158. {
  159. field: 'mineLinkStatus',
  160. label: '在线状态',
  161. component: 'Select',
  162. componentProps: {
  163. options: [
  164. { label: '离线', value: '0' },
  165. { label: '在线', value: '1' },
  166. ],
  167. },
  168. colProps: { span: 6 },
  169. groupName: '常规查询',
  170. show: false,
  171. },
  172. ];
  173. // 4. 查询表单配置(下拉框改为动态options)
  174. export const historySearchFormSchema: FormSchema[] = [
  175. {
  176. field: 'deptId',
  177. label: '煤矿名称',
  178. component: 'MineCascader',
  179. colProps: { span: 6 },
  180. groupName: '常规查询',
  181. },
  182. {
  183. field: 'startTime',
  184. label: '起始日期',
  185. component: 'DatePicker',
  186. componentProps: {
  187. showTime: true,
  188. //日期格式化,页面上显示的值
  189. format: 'YYYY-MM-DD HH:mm:ss',
  190. //返回值格式化(绑定值的格式)
  191. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  192. },
  193. defaultValue: dayjs().add(-30, 'day').format('YYYY-MM-DD 00:00:00'),
  194. colProps: { span: 6 },
  195. },
  196. {
  197. field: 'endTime',
  198. label: '结束日期',
  199. component: 'DatePicker',
  200. componentProps: {
  201. //日期格式化,页面上显示的值
  202. format: 'YYYY-MM-DD HH:mm:ss',
  203. //返回值格式化(绑定值的格式)
  204. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  205. },
  206. defaultValue: dayjs().format('YYYY-MM-DD 23:59:59'),
  207. colProps: { span: 6 },
  208. },
  209. ];
  210. export const topFormSchema: FormSchema[] = [
  211. {
  212. field: 'deptId',
  213. label: '煤矿名称',
  214. component: 'MineCascader',
  215. componentProps: {
  216. changeOnSelect: false,
  217. initFromStore: true,
  218. syncToStore: false,
  219. },
  220. required: true,
  221. rules: [{ required: true, message: '请选择煤矿名称', trigger: 'change' }],
  222. },
  223. ];
  224. /** 弹框表单配置 */
  225. export const formSchema: FormSchema[] = [
  226. {
  227. field: 'goafName',
  228. label: '工作面名称',
  229. component: 'Input',
  230. required: true,
  231. rules: [
  232. { required: true, message: '请输入工作面名称', trigger: 'blur' },
  233. { max: 100, message: '工作面名称长度不能超过100个字符', trigger: 'blur' },
  234. ],
  235. },
  236. {
  237. field: 'startTime',
  238. label: '开始时间',
  239. component: 'DatePicker',
  240. componentProps: {
  241. showTime: true,
  242. format: 'YYYY-MM-DD HH:mm:ss',
  243. },
  244. required: true,
  245. rules: [{ required: true, message: '请选择开始时间', trigger: 'blur' }],
  246. },
  247. {
  248. field: 'endTime',
  249. label: '结束时间',
  250. component: 'DatePicker',
  251. componentProps: {
  252. showTime: true,
  253. format: 'YYYY-MM-DD HH:mm:ss',
  254. },
  255. required: true,
  256. rules: [{ required: true, message: '请选择结束时间', trigger: 'blur' }],
  257. },
  258. {
  259. field: 'queCon',
  260. label: '问题描述',
  261. component: 'InputTextArea',
  262. componentProps: {
  263. rows: 4,
  264. maxlength: 500,
  265. showCount: true,
  266. },
  267. required: true,
  268. rules: [
  269. { required: true, message: '请输入问题描述', trigger: 'blur' },
  270. { max: 500, message: '问题描述长度不能超过500个字符', trigger: 'blur' },
  271. ],
  272. },
  273. // {
  274. // field: 'param',
  275. // label: '参数',
  276. // component: 'Input',
  277. // required: true,
  278. // rules: [
  279. // { required: true, message: '请输入参数', trigger: 'blur' },
  280. // { max: 200, message: '参数长度不能超过200个字符', trigger: 'blur' },
  281. // ],
  282. // },
  283. ];
  284. export const exportFormSchema: FormSchema[] = [
  285. {
  286. field: 'startTime',
  287. label: '开始时间',
  288. component: 'DatePicker',
  289. componentProps: {
  290. showTime: true,
  291. format: 'YYYY-MM-DD HH:mm:ss',
  292. },
  293. required: true,
  294. rules: [{ required: true, message: '请选择开始时间', trigger: 'blur' }],
  295. },
  296. {
  297. field: 'endTime',
  298. label: '结束时间',
  299. component: 'DatePicker',
  300. componentProps: {
  301. showTime: true,
  302. format: 'YYYY-MM-DD HH:mm:ss',
  303. },
  304. required: true,
  305. rules: [{ required: true, message: '请选择结束时间', trigger: 'blur' }],
  306. },
  307. ];