index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <div class="main-box">
  3. <TreeFilter title="机型机号" :is-all="false" :data="treeFilterData" :default-value="'0'" @change="changeTreeFilter" />
  4. <div class="table-box">
  5. <ProTable ref="proTable" :columns="columns" row-key="id" :request-api="listDataImportApi" :init-param="initParam">
  6. <!-- 表格 header 按钮 -->
  7. <template #tableHeader="scope">
  8. <el-button type="primary" v-auth="['als:dataImport:add']" @click="openDialog(1, '数据导入信息新增')"> 导入 </el-button>
  9. <el-button
  10. type="danger"
  11. v-auth="['als:dataImport:remove']"
  12. icon="Delete"
  13. plain
  14. :disabled="!scope.isSelected"
  15. @click="batchDelete(scope.selectedListIds)"
  16. >
  17. 批量删除
  18. </el-button>
  19. </template>
  20. <!-- 表格操作 -->
  21. <template #operation="scope">
  22. <el-button type="primary" link icon="View" v-auth="['als:dataImport:query']" @click="openDialog(3, '数据导入信息查看', scope.row)">
  23. 查看
  24. </el-button>
  25. <el-button type="primary" link icon="EditPen" v-auth="['als:dataImport:edit']" @click="openDialog(2, '数据导入信息编辑', scope.row)">
  26. 编辑
  27. </el-button>
  28. <el-button type="primary" link icon="Delete" v-auth="['als:dataImport:remove']" @click="deleteDataImport(scope.row)"> 删除 </el-button>
  29. </template>
  30. </ProTable>
  31. <FormDialog ref="formDialogRef" :items-options="itemsOptions" :model="model" />
  32. </div>
  33. </div>
  34. </template>
  35. <script setup lang="tsx" name="DataImport">
  36. import { useHandleData } from '@/hooks/useHandleData'
  37. import FormDialog from '@/components/FormDialog/index.vue'
  38. import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
  39. import { listDataImportApi, delDataImportApi, addDataImportApi, updateDataImportApi, getDataImportApi } from '@/api/modules/als/dataImport'
  40. import { treeSelectApi } from '@/api/modules/als/aircraft'
  41. import { selectSortieApi } from '@/api/modules/als/sortie'
  42. const { proxy } = getCurrentInstance() as ComponentInternalInstance
  43. const { sys_common_status, common_type } = toRefs<any>(proxy?.useDict('sys_common_status', 'common_type'))
  44. onMounted(() => {
  45. getTreeFilter()
  46. })
  47. // ProTable 实例
  48. const proTable = ref<ProTableInstance>()
  49. // 表单model
  50. const model = ref({})
  51. let initParam = reactive({ aircraftId: '' })
  52. let treeFilterData = ref<any>([])
  53. let treeOptions = ref<any>([])
  54. const getTreeFilter = async () => {
  55. const { data } = await treeSelectApi()
  56. treeOptions.value = data
  57. treeFilterData.value.push({
  58. id: '0',
  59. label: '所有机型',
  60. parentId: '',
  61. children: data
  62. })
  63. }
  64. // 树形筛选切换
  65. const changeTreeFilter = (val: string) => {
  66. proTable.value!.pageable.pageNum = 1
  67. initParam.aircraftId = val === '0' ? '' : val
  68. }
  69. // 删除数据导入信息信息
  70. const deleteDataImport = async (params: any) => {
  71. await useHandleData(delDataImportApi, params.id, '删除【' + params.id + '】数据导入信息')
  72. proTable.value?.getTableList()
  73. }
  74. // 批量删除数据导入信息信息
  75. const batchDelete = async (ids: string[]) => {
  76. await useHandleData(delDataImportApi, ids, '删除所选数据导入信息信息')
  77. proTable.value?.clearSelection()
  78. proTable.value?.getTableList()
  79. }
  80. const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
  81. // 打开弹框的功能
  82. const openDialog = async (type: number, title: string, row?: any) => {
  83. let res = { data: {} }
  84. if (row?.id) {
  85. res = await getDataImportApi(row?.id || null)
  86. }
  87. model.value = type == 1 ? {} : res.data
  88. // 重置表单
  89. setItemsOptions()
  90. const params = {
  91. title,
  92. width: 580,
  93. isEdit: type !== 3,
  94. api: type == 1 ? addDataImportApi : updateDataImportApi,
  95. getTableList: proTable.value?.getTableList
  96. }
  97. formDialogRef.value?.openDialog(params)
  98. }
  99. // 表格配置项
  100. const columns = reactive<ColumnProps<any>[]>([
  101. { type: 'selection', fixed: 'left', width: 70 },
  102. {
  103. prop: 'ossId',
  104. label: '文件编号',
  105. search: {
  106. el: 'input'
  107. },
  108. width: 120
  109. },
  110. {
  111. prop: 'source',
  112. label: '数据源',
  113. tag: true,
  114. enum: common_type,
  115. search: {
  116. el: 'select'
  117. }
  118. },
  119. {
  120. prop: 'sortieNo',
  121. label: '架次号',
  122. search: {
  123. el: 'input'
  124. },
  125. width: 120
  126. },
  127. {
  128. prop: 'aircraftNo',
  129. label: '机号',
  130. width: 120
  131. },
  132. {
  133. prop: 'flightDate',
  134. label: '飞行日期',
  135. search: {
  136. el: 'date-picker',
  137. props: { type: 'date', valueFormat: 'YYYY-MM-DD' }
  138. },
  139. width: 120
  140. },
  141. {
  142. prop: 'status',
  143. label: '状态',
  144. tag: true,
  145. enum: sys_common_status,
  146. search: {
  147. el: 'tree-select'
  148. }
  149. },
  150. {
  151. prop: 'createByName',
  152. label: '创建人',
  153. width: 120
  154. },
  155. {
  156. prop: 'createTime',
  157. label: '创建时间',
  158. width: 120
  159. },
  160. {
  161. prop: 'updateByName',
  162. label: '更新人',
  163. width: 120
  164. },
  165. {
  166. prop: 'updateTime',
  167. label: '更新时间',
  168. width: 120
  169. },
  170. { prop: 'operation', label: '操作', width: 230, fixed: 'right' }
  171. ])
  172. // 表单配置项
  173. let itemsOptions = reactive<ProForm.ItemsOptions[]>([])
  174. const setItemsOptions = () => {
  175. itemsOptions = [
  176. {
  177. label: '数据源',
  178. prop: 'source',
  179. rules: [{ required: true, message: '数据源不能为空', trigger: 'change' }],
  180. compOptions: {
  181. elTagName: 'select',
  182. enum: common_type.value,
  183. placeholder: '请选择数据源'
  184. }
  185. },
  186. {
  187. label: '机号',
  188. prop: 'aircraftId',
  189. rules: [{ required: true, message: '机号不能为空', trigger: 'change' }],
  190. compOptions: {
  191. elTagName: 'tree-select',
  192. enum: treeOptions.value,
  193. valueKey: 'id',
  194. placeholder: '请选择机号'
  195. }
  196. },
  197. {
  198. label: '架次号',
  199. prop: 'sortieNo',
  200. rules: [{ required: true, message: '架次号不能为空', trigger: 'blur' }],
  201. compOptions: {
  202. elTagName: 'select',
  203. enum: selectSortieApi,
  204. valueKey: 'id',
  205. labelKey: 'sortieNo',
  206. placeholder: '请输入架次号'
  207. }
  208. },
  209. {
  210. label: '数据导入',
  211. prop: 'ossId',
  212. rules: [{ required: true, message: '机号不能为空', trigger: 'blur' }],
  213. compOptions: {
  214. elTagName: 'file-upload-s3',
  215. placeholder: '请输入机号'
  216. }
  217. }
  218. ]
  219. }
  220. </script>