index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. <template>
  2. <div class="card content-box-c">
  3. <div class="steps-c">
  4. <el-steps :active="active" align-center>
  5. <el-step title="数据选择" description="数据选择" />
  6. <el-step title="测试性模型选择" description="测试性模型选择" />
  7. <el-step title="增强诊断" description="增强诊断" />
  8. <el-step title="结果展示" description="结果展示" />
  9. </el-steps>
  10. </div>
  11. <div class="steps-box">
  12. <ProForm ref="formRef" :items-options="itemsOptions" :model="model" :form-options="_formOptions">
  13. <template #dataId>
  14. <ProTable
  15. ref="proTable"
  16. :columns="sortieColumns"
  17. :tool-button="false"
  18. :request-auto="false"
  19. row-key="id"
  20. :is-show-search="false"
  21. :init-param="initParam"
  22. :request-api="listSortieParameterAllApi"
  23. :pagination="false"
  24. height="300"
  25. @row-click="rowClick"
  26. >
  27. </ProTable>
  28. </template>
  29. <template #faultCode>
  30. <ProTable
  31. ref="proTable2"
  32. :columns="warningColumns"
  33. :tool-button="false"
  34. row-key="id"
  35. :is-show-search="false"
  36. :request-api="getWarningListApi"
  37. max-height="500"
  38. :init-param="initParam"
  39. :data-callback="dataCallback"
  40. @row-click="rowClickWarning"
  41. >
  42. </ProTable>
  43. </template>
  44. <template #dataParams="{ formModel }">
  45. <el-transfer
  46. v-model="formModel.dataParams"
  47. @change="change"
  48. :data="parameterList"
  49. filterable
  50. filter-placeholder="请输入参数名称"
  51. :titles="['所有参数', '选中参数']"
  52. >
  53. </el-transfer>
  54. </template>
  55. </ProForm>
  56. <div class="card content-box-c" v-if="active === 4">结果......</div>
  57. </div>
  58. <div class="step-footer">
  59. <el-button @click="pre" v-show="active > 1">上一步</el-button>
  60. <el-button type="primary" @click="next" v-show="active < 3">下一步</el-button>
  61. <el-button type="primary" v-show="[2, 3].includes(active)" @click="onSubmit()">提交</el-button>
  62. </div>
  63. </div>
  64. </template>
  65. <script setup lang="ts" name="reasoning">
  66. import { ref, reactive, onMounted } from 'vue'
  67. import ProForm from '@/components/ProForm/index.vue'
  68. import ProTable from '@/components/ProTable/index.vue'
  69. import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
  70. import type { TableColumnCtx } from 'element-plus/es/components/table/src/table-column/defaults'
  71. import { updateModelInfoApi } from '@/api/modules/manage/modelInfo'
  72. import { listSortieParameterAllApi, getWarningListApi, modelListAllApi, getSortieParamsApi } from '@/api/modules/manage/sortieParameter'
  73. import { listSortieAllApi } from '@/api/modules/manage/sortie'
  74. import { getDictsApi } from '@/api/modules/system/dictData'
  75. // import { useRoute } from 'vue-router'
  76. import { nextTick } from 'vue'
  77. // const route = useRoute()
  78. onMounted(() => {
  79. exeTypeChange()
  80. })
  81. const optionsModel = ref<any[]>([])
  82. const formRef = ref<InstanceType<typeof ProForm> | null>(null)
  83. let active = ref(1)
  84. let model = ref({})
  85. let activeModel = reactive({})
  86. let parameterList = ref<any[]>([])
  87. const proTable2 = ref<ProTableInstance>()
  88. const proTable = ref<ProTableInstance>()
  89. const dataCallback = (data: any) => {
  90. const page = proTable2.value!.pageable
  91. return {
  92. list: data.data,
  93. total: data.total,
  94. pageNum: page.pageNum,
  95. pageSize: page.pageSize
  96. }
  97. }
  98. const getTableList = (sortieNo: string) => {
  99. initParam.sortieNo = sortieNo
  100. initParam.types = getTypes()
  101. }
  102. const getTypes = () => {
  103. return [0]
  104. }
  105. // 参数初始化
  106. const initParam = reactive({ sortieNo: formRef.value?.formModel.sortieNo || '=', types: [] as any })
  107. // 单击行
  108. const rowClick = async (row: any, column: TableColumnCtx<any>) => {
  109. if (column.property == 'radio') {
  110. formRef.value!.formModel.sortieNo = row.sortieNo
  111. formRef.value!.formModel.batchNo = row.batchNo
  112. formRef.value!.formModel.dataId = row.id
  113. const res = await getSortieParamsApi(row.id)
  114. parameterList.value = res.data.map(el => {
  115. return { key: el, label: el }
  116. })
  117. }
  118. }
  119. const rowClickWarning = async (row: any, column: TableColumnCtx<any>) => {
  120. if (column.property == 'radio') {
  121. formRef.value!.formModel.faultCode = row.faultCode
  122. }
  123. }
  124. const exeTypeEnum = [
  125. { value: '3', label: '虚警抑制' },
  126. { value: '4', label: '深度隔离' },
  127. { value: '5', label: '地面诊断' }
  128. ]
  129. // 选择诊断类型后触发
  130. const exeTypeChange = async (val?: any) => {
  131. const typeValue = getModelType(val)
  132. if (!typeValue) {
  133. optionsModel.value = []
  134. formRef.value!.proFormRef?.resetFields('modelObj')
  135. formRef.value!.formModel.modelObj = undefined
  136. formRef.value!.formModel.dataParams = []
  137. } else {
  138. const res = await modelListAllApi({ type: typeValue })
  139. optionsModel.value = res.data
  140. }
  141. setItemsOptions()
  142. }
  143. const getModelType = val => {
  144. if (active.value === 3) return val || formRef.value!.formModel.exeType
  145. else return 7
  146. }
  147. // 选择模型后触发
  148. const modelChange = async () => {
  149. const val = formRef.value!.formModel.modelObj || {}
  150. formRef.value!.formModel.dataParams = JSON.parse(val.dataParams || '[]')
  151. // 测试性模型
  152. if (active.value === 2) {
  153. formRef.value!.formModel.testModelId = val.id
  154. }
  155. // 增强诊断型模型
  156. if (active.value === 3) {
  157. formRef.value!.formModel.modelId = val.id
  158. }
  159. }
  160. // 下一步
  161. const next = () => {
  162. formRef.value!.proFormRef?.validate(valid => {
  163. if (valid) {
  164. formRef.value!.proFormRef?.clearValidate()
  165. activeModel[active.value] = Object.assign({}, formRef.value?.formModel)
  166. if (active.value++ > 4) return
  167. else {
  168. nextTick(() => {
  169. if (activeModel[active.value]) formRef.value!.formModel = Object.assign({}, activeModel[active.value])
  170. exeTypeChange()
  171. modelChange()
  172. })
  173. }
  174. }
  175. })
  176. }
  177. // 上一步
  178. const pre = () => {
  179. activeModel[active.value] = Object.assign({}, formRef.value?.formModel)
  180. if (active.value-- < 1) return
  181. nextTick(() => {
  182. exeTypeChange()
  183. modelChange()
  184. if (activeModel[active.value]) formRef.value!.formModel = Object.assign({}, activeModel[active.value])
  185. if (formRef.value?.formModel.sortieNo) {
  186. getTableList(formRef.value?.formModel.sortieNo)
  187. }
  188. })
  189. }
  190. const _formOptions = {
  191. hasFooter: false
  192. }
  193. // 步长选择
  194. const stepEnum = [
  195. { value: 1, label: '1帧/秒' },
  196. { value: 2, label: '2帧/秒' },
  197. { value: 5, label: '5帧/秒' },
  198. { value: 10, label: '10帧/秒' }
  199. ]
  200. const onSubmit = () => {
  201. active.value = 4
  202. console.log('formRef.value', formRef.value)
  203. }
  204. const change = (val: any) => {
  205. const data = {
  206. id: formRef.value?.formModel.value.modelId,
  207. dataParams: JSON.stringify(val)
  208. }
  209. updateModelInfoApi(data)
  210. }
  211. let itemsOptions = ref<ProForm.ItemsOptions[]>([])
  212. const setItemsOptions = () => {
  213. itemsOptions.value = [
  214. {
  215. label: '架次选择',
  216. prop: 'sortieNo',
  217. span: 12,
  218. rules: [{ required: true, message: '架次不能为空', trigger: 'blur' }],
  219. show: () => {
  220. return active.value === 1
  221. },
  222. compOptions: {
  223. elTagName: 'select',
  224. clearable: true,
  225. placeholder: '请架次选择',
  226. enum: listSortieAllApi,
  227. labelKey: 'sortieNumber',
  228. valueKey: 'sortieNumber',
  229. filterable: true,
  230. onChange: value => {
  231. if (value) getTableList(value)
  232. }
  233. }
  234. },
  235. {
  236. label: '步长',
  237. prop: 'step',
  238. span: 12,
  239. rules: [{ required: true, message: '步长不能为空', trigger: 'change' }],
  240. show: () => {
  241. return active.value === 1
  242. },
  243. compOptions: {
  244. elTagName: 'select',
  245. clearable: true,
  246. placeholder: '请选择步长',
  247. enum: stepEnum
  248. }
  249. },
  250. {
  251. label: '数据列表',
  252. prop: 'dataId',
  253. span: 24,
  254. rules: [{ required: true, message: '请选择数据', trigger: 'change' }],
  255. show: () => {
  256. return active.value === 1
  257. },
  258. compOptions: {
  259. elTagName: 'slot'
  260. }
  261. },
  262. {
  263. label: '诊断类型',
  264. prop: 'exeType',
  265. rules: [{ required: true, message: '诊断类型不能为空', trigger: 'blur' }],
  266. show: () => {
  267. return [3].includes(active.value)
  268. },
  269. compOptions: {
  270. elTagName: 'radio-group',
  271. placeholder: '请诊断类型',
  272. enum: exeTypeEnum,
  273. onChange: () => {
  274. exeTypeChange()
  275. }
  276. }
  277. },
  278. {
  279. label: '警告列表',
  280. prop: 'faultCode',
  281. span: 24,
  282. rules: [{ required: true, message: '请选择数据', trigger: 'change' }],
  283. show: () => {
  284. return formRef.value?.formModel.exeType === '3'
  285. },
  286. compOptions: {
  287. elTagName: 'slot'
  288. }
  289. },
  290. {
  291. label: '选择模型',
  292. prop: 'modelObj',
  293. rules: [{ required: true, message: '模型不能为空', trigger: 'change' }],
  294. show: () => {
  295. return [2, 3].includes(active.value)
  296. },
  297. compOptions: {
  298. style: {
  299. width: '50%'
  300. },
  301. elTagName: 'select',
  302. clearable: true,
  303. placeholder: '请选择模型',
  304. enum: optionsModel.value,
  305. labelKey: 'name',
  306. valueKey: 'col',
  307. onChange: () => {
  308. modelChange()
  309. }
  310. }
  311. },
  312. {
  313. label: '参数列表',
  314. prop: 'dataParams',
  315. span: 12,
  316. rules: [{ required: true, message: '参数不能为空', trigger: 'change' }],
  317. show: () => {
  318. return [2, 3].includes(active.value)
  319. },
  320. compOptions: {
  321. elTagName: 'slot'
  322. }
  323. }
  324. ]
  325. }
  326. // 架次数据
  327. const sortieColumns = reactive<ColumnProps<any>[]>([
  328. { type: 'radio', fixed: 'left', width: 70, prop: 'radio' },
  329. {
  330. prop: 'sortieNo',
  331. label: '架次号'
  332. },
  333. {
  334. prop: 'batchNo',
  335. label: '批次号'
  336. },
  337. {
  338. prop: 'type',
  339. label: '数据类型',
  340. tag: true,
  341. enum: () => getDictsApi('data_type'),
  342. search: {
  343. el: 'select'
  344. },
  345. fieldNames: { label: 'dictLabel', value: 'dictValue' }
  346. }
  347. ])
  348. // 虚警列表
  349. const warningColumns = reactive<ColumnProps<any>[]>([
  350. { type: 'radio', fixed: 'left', width: 70, prop: 'radio' },
  351. {
  352. prop: 'sortieNo',
  353. label: '架次号'
  354. },
  355. {
  356. prop: 'faultName',
  357. label: '故障名称'
  358. },
  359. {
  360. prop: 'faultCode',
  361. label: '警告代码'
  362. }
  363. ])
  364. </script>
  365. <style scoped lang="scss">
  366. @import './index.scss';
  367. </style>