index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <template>
  2. <div class="table-box">
  3. <ProTable
  4. ref="proTable"
  5. :columns="columns"
  6. row-key="id"
  7. :request-api="listSortieParameterApi"
  8. :init-param="initParam"
  9. :data-callback="dataCallback"
  10. >
  11. <!-- 表格 header 按钮 -->
  12. <template #tableHeader>
  13. <el-button type="primary" :icon="Download" @click="openDialog(4, '在线下载')"> 在线下载 </el-button>
  14. <el-button type="primary" :icon="Download" @click="openDownDialog()"> 离线下载 </el-button>
  15. <!-- <UploadFile icon="Download"></UploadFile> -->
  16. </template>
  17. <!-- 表格操作 -->
  18. <template #operation="scope">
  19. <el-button type="primary" link :icon="View" v-auth="['manage:dataDown:query']" @click="openDialog(3, '数据下载结果查看', scope.row)">
  20. 查看
  21. </el-button>
  22. <el-button type="primary" link :icon="Delete" v-auth="['manage:deepIsolationModel:remove']" @click="deleteDataDown(scope.row)">
  23. 删除
  24. </el-button>
  25. </template>
  26. </ProTable>
  27. <FormDialogOld ref="formDialogRef" />
  28. <FormDialog ref="downDialogRef" />
  29. </div>
  30. </template>
  31. <script setup lang="tsx" name="DataDownResult">
  32. import { ref, reactive } from 'vue'
  33. import { useRouter } from 'vue-router'
  34. import ProTable from '@/components/ProTable/index.vue'
  35. import { useHandleData } from '@/hooks/useHandleData'
  36. import FormDialogOld from '@/components/DialogOld/form.vue'
  37. import FormDialog from '@/components/FormDialog/index.vue'
  38. import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
  39. import { Download, View, Delete } from '@element-plus/icons-vue'
  40. import { listSortieParameterApi, getSortieParameterApi, delSortieParameterApi } from '@/api/modules/manage/sortieParameter'
  41. import { listAircraftAllApi } from '@/api/modules/manage/aircraft'
  42. import { getDictsApi } from '@/api/modules/system/dictData'
  43. import { listSortieAllApi } from '@/api/modules/manage/sortie'
  44. import { dataDownApi, dataUploadApi } from '@/api/modules/manage/dataDown'
  45. // import { ElMessage } from 'element-plus'
  46. const router = useRouter()
  47. // 跳转详情页
  48. const toDetail = (row: { sortieNo: any }) => {
  49. router.push({ path: `/manage/detail/index`, query: { sortieNo: row.sortieNo } })
  50. }
  51. // ProTable 实例
  52. const proTable = ref<ProTableInstance>()
  53. // 如果表格需要初始化请求参数,直接定义传给 ProTable (之后每次请求都会自动带上该参数,此参数更改之后也会一直带上,改变此参数会自动刷新表格数据)
  54. const initParam = reactive({ type: 0 })
  55. // dataCallback 是对于返回的表格数据做处理,如果你后台返回的数据不是 list && total && pageNum && pageSize 这些字段,可以在这里进行处理成这些字段
  56. const dataCallback = (data: any) => {
  57. const page = proTable.value!.pageable
  58. return {
  59. list: data.data,
  60. total: data.total,
  61. pageNum: page.pageNum,
  62. pageSize: page.pageSize
  63. }
  64. }
  65. // 删除下载结果信息
  66. const deleteDataDown = async (params: any) => {
  67. await useHandleData(delSortieParameterApi, params.id, `删除【${params.id}】下载结果`)
  68. proTable.value?.getTableList()
  69. }
  70. const formDialogRef = ref<InstanceType<typeof FormDialogOld> | null>(null)
  71. const sortieOptions = ref<any[]>([])
  72. const sortie = async () => {
  73. const res = await listSortieAllApi({})
  74. sortieOptions.value = res.data
  75. }
  76. sortie()
  77. // const aircraftOptions = ref<any[]>([])
  78. // const aircraft = async () => {
  79. // const res = await listAircraftAllApi({})
  80. // aircraftOptions.value = res.data
  81. // }
  82. // aircraft()
  83. // 打开弹框的功能
  84. const openDialog = async (type: number, title: string, row?: any) => {
  85. let res = { data: {} }
  86. if (row?.id) {
  87. res = await getSortieParameterApi(row?.id || null)
  88. }
  89. // 在线数据下载
  90. if (type == 4) {
  91. setOnlineDownFieldList()
  92. } else if (type == 5) {
  93. setOfflineDownFieldList()
  94. } else {
  95. // 重置表单
  96. setFieldList()
  97. }
  98. const params = {
  99. title,
  100. width: 480,
  101. top: '30vh',
  102. labelWidth: 80,
  103. isEdit: type !== 3,
  104. fieldList: fieldList,
  105. model: type == 1 ? {} : res.data,
  106. getTableList: proTable.value?.getTableList
  107. }
  108. if ([4, 5].includes(type)) {
  109. params['api'] = dataDownApi
  110. }
  111. formDialogRef.value?.openDialog(params)
  112. }
  113. const downDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
  114. // 打开弹框的功能
  115. const openDownDialog = async () => {
  116. // 离线数据下载
  117. let model = {
  118. fileList: [],
  119. sortieNo: '',
  120. sourceType: '2'
  121. }
  122. setItemsOptions()
  123. const params = {
  124. title: '离线数据',
  125. width: 480,
  126. top: '30vh',
  127. labelWidth: 80,
  128. isEdit: true,
  129. itemsOptions: itemsOptions,
  130. model,
  131. api: dataUploadApi,
  132. getTableList: proTable.value?.getTableList
  133. }
  134. downDialogRef.value?.openDialog(params)
  135. }
  136. // 表格配置项
  137. const columns = reactive<ColumnProps<any>[]>([
  138. { type: 'selection', fixed: 'left', width: 70 },
  139. {
  140. prop: 'batchNo',
  141. label: '批次号',
  142. search: {
  143. el: 'input'
  144. }
  145. },
  146. {
  147. prop: 'sortieNo',
  148. label: '架次号',
  149. search: {
  150. el: 'input'
  151. },
  152. render: scope => {
  153. return (
  154. <el-button type="primary" link onClick={() => toDetail(scope.row)}>
  155. {scope.row.sortieNo}
  156. </el-button>
  157. )
  158. }
  159. },
  160. {
  161. prop: 'source',
  162. label: '数据源',
  163. tag: true,
  164. enum: () => getDictsApi('data_source'),
  165. search: {
  166. el: 'select'
  167. },
  168. fieldNames: { label: 'dictLabel', value: 'dictValue' }
  169. },
  170. {
  171. prop: 'dataPath',
  172. label: '数据路径',
  173. search: {
  174. el: 'input'
  175. }
  176. },
  177. {
  178. prop: 'createTime',
  179. label: '创建时间'
  180. },
  181. { prop: 'operation', label: '操作', width: 230 }
  182. ])
  183. // 表单配置项
  184. let fieldList: Form.FieldItem[] = []
  185. const setFieldList = () => {
  186. fieldList = [
  187. {
  188. label: '批次号',
  189. field: 'batchNo'
  190. },
  191. {
  192. label: '架次号',
  193. field: 'sortieNo'
  194. },
  195. {
  196. label: '数据源',
  197. field: 'source'
  198. },
  199. {
  200. label: '下载方式',
  201. field: 'type'
  202. },
  203. {
  204. label: '数据路径',
  205. field: 'dataPath'
  206. }
  207. ]
  208. }
  209. const enumData = [
  210. {
  211. label: '机载PHM',
  212. value: '1'
  213. },
  214. {
  215. label: '数链仿真系统',
  216. value: '0'
  217. }
  218. ]
  219. // 在线下载表单项
  220. const setOnlineDownFieldList = () => {
  221. fieldList = [
  222. {
  223. label: '数据源',
  224. field: 'sourceType',
  225. type: 'radio',
  226. enum: enumData,
  227. options: {
  228. labelKey: 'label',
  229. valueKey: 'value'
  230. }
  231. },
  232. {
  233. label: '架次',
  234. field: 'sortieNo',
  235. span: 20,
  236. enum: sortieOptions.value,
  237. type: 'select',
  238. clearable: true,
  239. options: {
  240. labelKey: 'sortieNumber',
  241. valueKey: 'sortieNumber',
  242. filterable: true,
  243. allowCreate: true
  244. },
  245. placeholder: '请选择架次'
  246. },
  247. {
  248. label: '机号',
  249. field: 'aircraftNumber',
  250. span: 20,
  251. enum: listAircraftAllApi,
  252. type: 'select',
  253. clearable: true,
  254. options: {
  255. labelKey: 'number',
  256. valueKey: 'number'
  257. },
  258. placeholder: '请选择架次'
  259. }
  260. ]
  261. }
  262. // 在线下载表单项
  263. const setOfflineDownFieldList = () => {
  264. fieldList = [
  265. {
  266. label: '数据源',
  267. field: 'sourceType',
  268. type: 'radio',
  269. enum: enumData,
  270. options: {
  271. labelKey: 'label',
  272. valueKey: 'value'
  273. }
  274. },
  275. {
  276. label: '架次',
  277. field: 'sortie',
  278. enum: sortieOptions.value,
  279. type: 'select',
  280. clearable: true,
  281. options: {
  282. labelKey: 'sortieNumber',
  283. valueKey: 'sortieNumber',
  284. filterable: true,
  285. allowCreate: true
  286. },
  287. placeholder: '请选择架次'
  288. }
  289. ]
  290. }
  291. // 表单配置项
  292. let itemsOptions: ProForm.ItemsOptions[] = []
  293. const setItemsOptions = () => {
  294. itemsOptions = [
  295. {
  296. label: '文件上传',
  297. prop: 'fileList',
  298. rules: [{ required: true, message: '文件不能为空', trigger: 'blur' }],
  299. compOptions: {
  300. elTagName: 'file-upload'
  301. }
  302. },
  303. {
  304. label: '架次',
  305. prop: 'sortieNo',
  306. rules: [{ required: true, message: '架次不能为空', trigger: 'blur' }],
  307. compOptions: {
  308. elTagName: 'select',
  309. placeholder: '请选择架次',
  310. enum: sortieOptions.value,
  311. labelKey: 'sortieNumber',
  312. valueKey: 'sortieNumber',
  313. filterable: true,
  314. allowCreate: true
  315. }
  316. },
  317. {
  318. label: '备注',
  319. prop: 'remark',
  320. compOptions: {
  321. type: 'textarea',
  322. placeholder: '请输入内容'
  323. }
  324. }
  325. ]
  326. }
  327. </script>