windPointManage.data.ts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. import type { BasicColumn } from '/@/components/Table';
  2. import type { FormSchema } from '/@/components/Table';
  3. import { h } from 'vue';
  4. import { StatusColorEnum } from '/@/enums/jeecgEnum';
  5. import { useMineDepartmentStore } from '/@/store/modules/mine';
  6. import { getWindrectList, getWindrectRegulation, getGoafList } from './windPointManage.api';
  7. /** 按矿编码(fax)在组织树中匹配部门名称,未匹配时回退显示原编码 */
  8. export function renderMineNameByFax(mineCode: string): string {
  9. if (!mineCode) return '-';
  10. const mine = useMineDepartmentStore().findDepart((n) => n.fax === mineCode, useMineDepartmentStore().getDepartTree);
  11. return mine?.departName || mineCode;
  12. }
  13. /** 煤矿编号(MineCascader)提交校验:必须选到矿井(叶子节点 isLeaf=true)。
  14. * 单条自包含规则承担必填与叶子校验,不再叠加 schema 级 required(避免 FormItem 额外前置必填规则);
  15. * 空值时按 required 的 message 提示,非空但非叶子时提示选择具体矿井。 */
  16. export function mineLeafDynamicRules() {
  17. return [
  18. {
  19. required: true,
  20. message: '请选择煤矿',
  21. validator: (_: any, value?: string) => {
  22. const dept = useMineDepartmentStore().findDepartById(value);
  23. if (dept && !dept.isLeaf) return Promise.reject('请选择具体矿井');
  24. return Promise.resolve();
  25. },
  26. },
  27. ];
  28. }
  29. /** 注册测风地点管理表格列 */
  30. export const pointColumns: BasicColumn[] = [
  31. {
  32. title: '煤矿名称',
  33. dataIndex: 'mineCode',
  34. width: 140,
  35. fixed: 'left',
  36. customRender: ({ text }) => h('span', renderMineNameByFax(String(text ?? ''))),
  37. },
  38. {
  39. title: '区域名称',
  40. dataIndex: 'name',
  41. width: 150,
  42. fixed: 'left',
  43. },
  44. {
  45. title: '层级',
  46. dataIndex: 'level',
  47. width: 100,
  48. customRender: ({ text }) => {
  49. const map: Record<number, string> = {
  50. 0: '进风井',
  51. 1: '矿井进风',
  52. 2: '采区进风',
  53. 3: '采区用风',
  54. 4: '采区回风',
  55. 5: '矿井回风',
  56. 6: '回风井',
  57. };
  58. return map[text] || text;
  59. },
  60. },
  61. {
  62. title: '需风量', // (m³/min)
  63. dataIndex: 'airVolume',
  64. width: 100,
  65. },
  66. {
  67. title: '风量', // (m³/min)
  68. dataIndex: 'm3Volume',
  69. width: 100,
  70. },
  71. // {
  72. // title: '规程值',
  73. // dataIndex: 'regulationId',
  74. // width: 90,
  75. // },
  76. {
  77. title: '测风设备',
  78. dataIndex: 'windrectId',
  79. width: 100,
  80. customRender({ record }) {
  81. return h('span', record.windrectId ? '已绑定' : '未绑定');
  82. },
  83. },
  84. {
  85. title: '创建时间',
  86. dataIndex: 'createTime',
  87. width: 150,
  88. },
  89. // {
  90. // title: '状态',
  91. // dataIndex: 'status',
  92. // width: 80,
  93. // customRender: ({ text }) => {
  94. // const val = text ?? 'active';
  95. // const color = val === 'active' ? StatusColorEnum.green : StatusColorEnum.gray;
  96. // const label = val === 'active' ? '在用' : '停用';
  97. // return h('span', { style: { color } }, label);
  98. // },
  99. // },
  100. ];
  101. /** 上传测风装置表格列(Windrect) */
  102. export const windrectColumns: BasicColumn[] = [
  103. // {
  104. // title: '设备编码',
  105. // dataIndex: 'deviceCode',
  106. // width: 130,
  107. // fixed: 'left',
  108. // },
  109. {
  110. title: '设备位置',
  111. dataIndex: 'devicePos',
  112. width: 200,
  113. },
  114. {
  115. title: '矿井名称',
  116. dataIndex: 'mineName',
  117. width: 160,
  118. },
  119. {
  120. title: '状态',
  121. dataIndex: 'status',
  122. width: 100,
  123. customRender: ({ text }) => {
  124. const normal = String(text) === '1';
  125. const color = normal ? StatusColorEnum.green : StatusColorEnum.red;
  126. const label = normal ? '在线' : '离线';
  127. return h('span', { style: { color, fontWeight: 'bold' } }, label);
  128. },
  129. },
  130. // {
  131. // title: '创建时间',
  132. // dataIndex: 'createTime',
  133. // width: 160,
  134. // },
  135. ];
  136. /** 新增/编辑 MineArea 表单 */
  137. export const formSchema: FormSchema[] = [
  138. {
  139. label: 'id',
  140. field: 'id',
  141. component: 'Input',
  142. show: false,
  143. },
  144. {
  145. label: '煤矿编号',
  146. field: 'mineCode',
  147. component: 'MineCascader',
  148. // 必选到矿井(叶子):必填与 isLeaf 校验由 mineLeafDynamicRules 单条规则承担
  149. dynamicRules: mineLeafDynamicRules,
  150. // 编辑态(已有 id)禁用矿编码,避免误改归属矿井;新增态保持可选
  151. ifShow: ({ values }) => !values.id,
  152. // 切换煤矿时清空已选测风设备,避免绑定到其他矿的设备
  153. componentProps: ({ formActionType }) => ({
  154. placeholder: '请输入煤矿编号',
  155. changeOnSelect: true,
  156. initFromStore: false,
  157. syncFromStore: false,
  158. onChange: () => {
  159. formActionType.setFieldsValue({ windrectId: undefined });
  160. },
  161. }),
  162. },
  163. {
  164. label: '层级',
  165. field: 'level',
  166. component: 'Select',
  167. required: true,
  168. componentProps: {
  169. placeholder: '请选择层级',
  170. options: [
  171. { label: '进风井', value: 0 },
  172. { label: '矿井进风', value: 1 },
  173. { label: '采区进风', value: 2 },
  174. { label: '采区用风', value: 3 },
  175. { label: '采区回风', value: 4 },
  176. { label: '矿井回风', value: 5 },
  177. { label: '回风井', value: 6 },
  178. ],
  179. },
  180. },
  181. {
  182. label: '巷道分类',
  183. field: 'regulationId',
  184. component: 'ApiSelect',
  185. required: true,
  186. componentProps: {
  187. api: getWindrectRegulation,
  188. labelField: 'name',
  189. valueField: 'id',
  190. placeholder: '请选择巷道分类',
  191. },
  192. },
  193. {
  194. label: '测风设备',
  195. field: 'windrectId',
  196. component: 'ApiSelect',
  197. // 与「煤矿编号」联动:按选中矿(MineCascader 值为部门 id)过滤本矿测风设备;
  198. // ApiSelect 深度监听 params 变化,切矿后自动重新请求
  199. componentProps: ({ formModel }) => ({
  200. api: getWindrectList,
  201. labelField: 'devicePos',
  202. valueField: 'id',
  203. placeholder: '请输入测风设备',
  204. searchable: true,
  205. params: formModel?.mineCode ? { deptId: formModel.mineCode } : {},
  206. }),
  207. },
  208. {
  209. label: '供风区域',
  210. field: 'goafList',
  211. component: 'ApiSelect',
  212. // 与「煤矿编号」联动:按选中矿(MineCascader 值为部门 id)过滤本矿供风区域(采空区),可多选;
  213. // 未选矿时返回空列表,避免 getGoafList 缺少必填 deptId 的无效请求;切矿后自动重新加载
  214. componentProps: ({ formModel }) => ({
  215. api: () => (formModel?.mineCode ? getGoafList({ deptId: formModel.mineCode }) : Promise.resolve([])),
  216. labelField: 'name',
  217. valueField: 'id',
  218. mode: 'multiple',
  219. placeholder: '请选择供风区域(可多选)',
  220. placement: 'topLeft',
  221. }),
  222. },
  223. {
  224. label: '测风地点名称',
  225. field: 'name',
  226. required: true,
  227. component: 'Input',
  228. componentProps: {
  229. placeholder: '请输入矿井名称',
  230. },
  231. },
  232. {
  233. label: '需风量(m³/min)',
  234. field: 'airVolume',
  235. component: 'InputNumber',
  236. componentProps: {
  237. placeholder: '请输入需风量',
  238. min: 0,
  239. style: 'width: 100%',
  240. },
  241. },
  242. ];
  243. /* ====== 判识模型管理(暂注释,待接口就绪后恢复)======
  244. /* 判识模型参数配置表格列
  245. export const modelConfigColumns: BasicColumn[] = [
  246. {
  247. title: '判识指标',
  248. dataIndex: 'paramName',
  249. width: 200,
  250. fixed: 'left',
  251. },
  252. {
  253. title: '判别条件',
  254. dataIndex: 'paramFormula',
  255. width: 150,
  256. },
  257. {
  258. title: '阈值参数',
  259. dataIndex: 'paramKey',
  260. width: 150,
  261. },
  262. {
  263. title: '阈值参数',
  264. dataIndex: 'currentValue',
  265. width: 120,
  266. edit: true,
  267. editComponent: 'Input',
  268. },
  269. {
  270. title: '默认值',
  271. dataIndex: 'defaultValue',
  272. width: 120,
  273. },
  274. {
  275. title: '当前值',
  276. dataIndex: 'value',
  277. width: 120,
  278. },
  279. {
  280. title: '权重',
  281. dataIndex: 'weight',
  282. width: 120,
  283. },
  284. ];
  285. /* 判识模型参数编辑表单(与 modelConfigColumns 字段对齐)
  286. export const modelConfigFormSchema: FormSchema[] = [
  287. {
  288. label: '判识指标',
  289. field: 'paramName',
  290. component: 'Input',
  291. componentProps: { disabled: true },
  292. },
  293. {
  294. label: '判别条件',
  295. field: 'paramFormula',
  296. component: 'Input',
  297. componentProps: { placeholder: '请输入判别条件' },
  298. },
  299. {
  300. label: '阈值参数',
  301. field: 'paramKey',
  302. required: true,
  303. component: 'Input',
  304. componentProps: { placeholder: '请输入阈值参数字段名' },
  305. },
  306. {
  307. label: '阈值参数值',
  308. field: 'currentValue',
  309. required: true,
  310. component: 'Input',
  311. componentProps: { placeholder: '请输入阈值参数值' },
  312. },
  313. {
  314. label: '默认值',
  315. field: 'defaultValue',
  316. component: 'Input',
  317. componentProps: { placeholder: '请输入默认值' },
  318. },
  319. {
  320. label: '当前值',
  321. field: 'value',
  322. component: 'Input',
  323. componentProps: { placeholder: '请输入当前值' },
  324. },
  325. {
  326. label: '权重',
  327. field: 'weight',
  328. component: 'InputNumber',
  329. componentProps: { placeholder: '请输入权重', min: 0, max: 1, step: 0.01, style: 'width:100%' },
  330. },
  331. {
  332. label: '单位',
  333. field: 'unit',
  334. component: 'Input',
  335. componentProps: { placeholder: '请输入单位' },
  336. },
  337. {
  338. label: '说明',
  339. field: 'description',
  340. component: 'InputTextArea',
  341. componentProps: { placeholder: '请输入说明', rows: 3 },
  342. },
  343. ];
  344. /* 判识模型默认配置数据
  345. export const defaultModelConfigs = [
  346. {
  347. paramName: '风速上限',
  348. paramKey: 'windSpeedUpperLimit',
  349. currentValue: '6.0',
  350. defaultValue: '6.0',
  351. unit: 'm/s',
  352. description: '实测风速超过此值即触发风速超限报警',
  353. },
  354. {
  355. paramName: '风量不足裕度',
  356. paramKey: 'volumeLowMargin',
  357. currentValue: '20',
  358. defaultValue: '20',
  359. unit: '%',
  360. description: '实测风量低于标准风量×(1-裕度)即触发风量不足报警',
  361. },
  362. {
  363. paramName: '缺失点位报警数',
  364. paramKey: 'missingPointAlarm',
  365. currentValue: '1',
  366. defaultValue: '1',
  367. unit: '个',
  368. description: '上传测风点数少于注册测风点数超过此值即触发报警',
  369. },
  370. {
  371. paramName: '关联异常点数',
  372. paramKey: 'relatedAbnormalPoints',
  373. currentValue: '2',
  374. defaultValue: '2',
  375. unit: '个',
  376. description: '同一区域多个测风点同时异常超过此值即触发关联异常报警',
  377. },
  378. {
  379. paramName: '综合判识阈值',
  380. paramKey: 'compositeThreshold',
  381. currentValue: '0.60',
  382. defaultValue: '0.60',
  383. unit: '',
  384. description: '加权风险得分达到此值判定为"疑似"隐蔽工作面',
  385. },
  386. {
  387. paramName: '采区风量差值异常周期',
  388. paramKey: 'diffAbnormalCycles',
  389. currentValue: '3',
  390. defaultValue: '3',
  391. unit: '个测风周期',
  392. description: '差值持续为正且超过此测风周期数即触发异常',
  393. },
  394. {
  395. paramName: '采区有效风量率警戒线',
  396. paramKey: 'effectiveRateWarning',
  397. currentValue: '70',
  398. defaultValue: '70',
  399. unit: '%',
  400. description: '采区有效风量率低于此值即触发预警',
  401. },
  402. ];
  403. */