Sfoglia il codice sorgente

feat: 保障规则/保障规则子表

wanggaokun 1 anno fa
parent
commit
1193184184

+ 86 - 0
src/api/interface/als/safeRule.ts

@@ -0,0 +1,86 @@
+import { PageQuery, BaseEntity } from '@/api/interface/index'
+export interface SafeRuleVO extends BaseEntity {
+  /**
+   * 机型
+   */
+  aircraftModel: string
+
+  /**
+   * 时长
+   */
+  duration: string
+
+  /**
+   * 飞行课目
+   */
+  trainExercise: string
+
+  /**
+   * 创建人
+   */
+  createBy: number
+
+  /**
+   * 创建时间
+   */
+  createTime: string
+
+  /**
+   * 更新人
+   */
+  updateBy: number
+
+  /**
+   * 更新时间
+   */
+  updateTime: string
+}
+
+export interface SafeRuleForm {
+  /**
+   * 编号
+   */
+  id?: string | number
+
+  /**
+   * 机型
+   */
+  aircraftModel?: string
+
+  /**
+   * 时长
+   */
+  duration?: string
+
+  /**
+   * 飞行课目
+   */
+  trainExercise?: string
+}
+
+export interface SafeRuleQuery extends PageQuery {
+  /**
+   * 机型
+   */
+  aircraftModel?: string
+
+  /**
+   * 时长
+   */
+  duration?: string
+
+  /**
+   * 飞行课目
+   */
+  trainExercise?: string
+
+  /**
+   * 状态(1正常)
+   */
+  status?: string
+
+  /**
+   * 日期范围参数
+   */
+  params?: any
+}

+ 116 - 0
src/api/interface/als/safeRuleSub.ts

@@ -0,0 +1,116 @@
+import { PageQuery, BaseEntity } from '@/api/interface/index'
+export interface SafeRuleSubVO extends BaseEntity {
+  /**
+   * 编号
+   */
+  id: string | number
+
+  /**
+   * 机型
+   */
+  aircraftModel: string
+
+  /**
+   * 机组
+   */
+  aircraftGroup: string
+
+  /**
+   * 时长
+   */
+  duration: string
+
+  /**
+   * 设备
+   */
+  device: string
+
+  /**
+   * 数量
+   */
+  deviceCount: number
+
+  /**
+   * 单位
+   */
+  unit: string
+}
+
+export interface SafeRuleSubForm {
+  /**
+   * 机型
+   */
+  aircraftModel?: string
+
+  /**
+   * 机组
+   */
+  aircraftGroup?: string
+
+  /**
+   * 时长
+   */
+  duration?: string
+
+  /**
+   * 设备
+   */
+  device?: string
+
+  /**
+   * 数量
+   */
+  deviceCount?: number
+
+  /**
+   * 单位
+   */
+  unit?: string
+
+  /**
+   * 备注
+   */
+  remark?: string
+}
+
+export interface SafeRuleSubQuery extends PageQuery {
+  /**
+   * 机型
+   */
+  aircraftModel?: string
+
+  /**
+   * 机组
+   */
+  aircraftGroup?: string
+
+  /**
+   * 时长
+   */
+  duration?: string
+
+  /**
+   * 设备
+   */
+  device?: string
+
+  /**
+   * 数量
+   */
+  deviceCount?: number
+
+  /**
+   * 单位
+   */
+  unit?: string
+
+  /**
+   * 状态(1正常)
+   */
+  status?: string
+
+  /**
+   * 日期范围参数
+   */
+  params?: any
+}

+ 70 - 0
src/api/modules/als/safeRule.ts

@@ -0,0 +1,70 @@
+import http from '@/api'
+import { SafeRuleVO, SafeRuleForm, SafeRuleQuery } from '@/api/interface/als/safeRule'
+/**
+ * @name 查询保障规则列表
+ * @param query 参数
+ * @returns 返回列表
+ */
+export const listSafeRuleApi = (query: SafeRuleQuery) => {
+  return http.get<SafeRuleVO[]>('/als/safeRule/list', query, { loading: true })
+}
+
+/**
+ * @name 查询保障规则详细
+ * @param id id
+ * @returns returns
+ */
+export const getSafeRuleApi = (id: string | number) => {
+  return http.get<SafeRuleVO>(`/als/safeRule/${id}`)
+}
+
+/**
+ * @name 新增保障规则
+ * @param data data
+ * @returns returns
+ */
+export const addSafeRuleApi = (data: SafeRuleForm) => {
+  return http.post<any>('/als/safeRule', data, { loading: false })
+}
+
+/**
+ * @name 修改保障规则
+ * @param data data
+ * @returns returns
+ */
+export const updateSafeRuleApi = (data: SafeRuleForm) => {
+  return http.put<any>('/als/safeRule', data, { loading: false })
+}
+
+/**
+ * @name 删除保障规则
+ * @param id id
+ * @returns returns
+ */
+export const delSafeRuleApi = (id: string | number | Array<string | number>) => {
+  return http.delete<any>(`/als/safeRule/${id}`)
+}
+
+/**
+ * @name 下载模板
+ * @returns returns
+ */
+export const importTemplateApi = () => {
+  return http.downloadPost('/als/safeRule/importTemplate', {})
+}
+
+/**
+ * @name 导入数据
+ * @returns returns
+ */
+export const importSafeRuleDataApi = (data: any) => {
+  return http.post('/als/safeRule/importData', data)
+}
+
+/**
+ * @name 导出数据
+ * @returns returns
+ */
+export const exportSafeRuleApi = (data: any) => {
+  return http.post('/als/safeRule/export', data)
+}

+ 70 - 0
src/api/modules/als/safeRuleSub.ts

@@ -0,0 +1,70 @@
+import http from '@/api'
+import { SafeRuleSubVO, SafeRuleSubForm, SafeRuleSubQuery } from '@/api/interface/als/safeRuleSub'
+/**
+ * @name 查询保障规则子列表
+ * @param query 参数
+ * @returns 返回列表
+ */
+export const listSafeRuleSubApi = (query: SafeRuleSubQuery) => {
+  return http.get<SafeRuleSubVO[]>('/als/safeRuleSub/list', query, { loading: true })
+}
+
+/**
+ * @name 查询保障规则子详细
+ * @param id id
+ * @returns returns
+ */
+export const getSafeRuleSubApi = (id: string | number) => {
+  return http.get<SafeRuleSubVO>(`/als/safeRuleSub/${id}`)
+}
+
+/**
+ * @name 新增保障规则子
+ * @param data data
+ * @returns returns
+ */
+export const addSafeRuleSubApi = (data: SafeRuleSubForm) => {
+  return http.post<any>('/als/safeRuleSub', data, { loading: false })
+}
+
+/**
+ * @name 修改保障规则子
+ * @param data data
+ * @returns returns
+ */
+export const updateSafeRuleSubApi = (data: SafeRuleSubForm) => {
+  return http.put<any>('/als/safeRuleSub', data, { loading: false })
+}
+
+/**
+ * @name 删除保障规则子
+ * @param id id
+ * @returns returns
+ */
+export const delSafeRuleSubApi = (id: string | number | Array<string | number>) => {
+  return http.delete<any>(`/als/safeRuleSub/${id}`)
+}
+
+/**
+ * @name 下载模板
+ * @returns returns
+ */
+export const importTemplateApi = () => {
+  return http.downloadPost('/als/safeRuleSub/importTemplate', {})
+}
+
+/**
+ * @name 导入数据
+ * @returns returns
+ */
+export const importSafeRuleSubDataApi = (data: any) => {
+  return http.post('/als/safeRuleSub/importData', data)
+}
+
+/**
+ * @name 导出数据
+ * @returns returns
+ */
+export const exportSafeRuleSubApi = (data: any) => {
+  return http.post('/als/safeRuleSub/export', data)
+}

+ 193 - 0
src/views/als/safeRule/index.vue

@@ -0,0 +1,193 @@
+<template>
+  <div class="table-box">
+    <ProTable ref="proTable" :columns="columns" row-key="id" :request-api="listSafeRuleApi">
+      <!-- 表格 header 按钮 -->
+      <template #tableHeader="scope">
+        <el-button type="primary" v-auth="['als:safeRule:add']" icon="CirclePlus" @click="openDialog(1, '保障规则新增')"> 新增 </el-button>
+        <el-button type="primary" v-auth="['als:safeRule:import']" icon="Upload" plain @click="batchAdd"> 导入 </el-button>
+        <el-button type="primary" v-auth="['als:safeRule:export']" icon="Download" plain @click="downloadFile"> 导出 </el-button>
+        <el-button
+          type="danger"
+          v-auth="['als:safeRule:remove']"
+          icon="Delete"
+          plain
+          :disabled="!scope.isSelected"
+          @click="batchDelete(scope.selectedListIds)"
+        >
+          批量删除
+        </el-button>
+      </template>
+      <!-- 表格操作 -->
+      <template #operation="scope">
+        <el-button type="primary" link icon="View" v-auth="['als:safeRule:query']" @click="openDialog(3, '保障规则查看', scope.row)">
+          查看
+        </el-button>
+        <el-button type="primary" link icon="EditPen" v-auth="['als:safeRule:edit']" @click="openDialog(2, '保障规则编辑', scope.row)">
+          编辑
+        </el-button>
+        <el-button type="primary" link icon="Delete" v-auth="['als:safeRule:remove']" @click="deleteSafeRule(scope.row)"> 删除 </el-button>
+      </template>
+    </ProTable>
+    <FormDialog ref="formDialogRef" :items-options="itemsOptions" :model="model" />
+    <ImportExcel ref="dialogRef" />
+    <TaskDialog ref="taskDialogRef" />
+  </div>
+</template>
+
+<script setup lang="tsx" name="SafeRule">
+import { useHandleData } from '@/hooks/useHandleData'
+import { ElMessageBox } from 'element-plus'
+import ImportExcel from '@/components/ImportExcel/index.vue'
+import TaskDialog from '@/components/TaskDialog/index.vue'
+import FormDialog from '@/components/FormDialog/index.vue'
+import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
+import {
+  listSafeRuleApi,
+  delSafeRuleApi,
+  addSafeRuleApi,
+  updateSafeRuleApi,
+  importTemplateApi,
+  importSafeRuleDataApi,
+  exportSafeRuleApi,
+  getSafeRuleApi
+} from '@/api/modules/als/safeRule'
+
+// ProTable 实例
+const proTable = ref<ProTableInstance>()
+// 表单model
+const model = ref({})
+// 删除保障规则信息
+const deleteSafeRule = async (params: any) => {
+  await useHandleData(delSafeRuleApi, params.id, '删除【' + params.id + '】保障规则')
+  proTable.value?.getTableList()
+}
+
+// 批量删除保障规则信息
+const batchDelete = async (ids: string[]) => {
+  await useHandleData(delSafeRuleApi, ids, '删除所选保障规则信息')
+  proTable.value?.clearSelection()
+  proTable.value?.getTableList()
+}
+
+const taskDialogRef = ref<InstanceType<typeof TaskDialog> | null>(null)
+// 导出保障规则列表
+const downloadFile = async () => {
+  ElMessageBox.confirm('确认导出保障规则数据?', '温馨提示', { type: 'warning' }).then(async () => {
+    exportSafeRuleApi(proTable.value?.searchParam)
+    taskDialogRef.value?.openExportDialog()
+  })
+}
+
+// 批量添加保障规则
+const dialogRef = ref<InstanceType<typeof ImportExcel> | null>(null)
+const batchAdd = () => {
+  const params = {
+    title: '保障规则',
+    tempApi: importTemplateApi,
+    importApi: importSafeRuleDataApi,
+    getTableList: proTable.value?.getTableList
+  }
+  dialogRef.value?.acceptParams(params)
+}
+
+const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
+// 打开弹框的功能
+const openDialog = async (type: number, title: string, row?: any) => {
+  let res = { data: {} }
+  if (row?.id) {
+    res = await getSafeRuleApi(row?.id || null)
+  }
+  model.value = type == 1 ? {} : res.data
+  // 重置表单
+  setItemsOptions()
+  const params = {
+    title,
+    width: 580,
+    isEdit: type !== 3,
+    api: type == 1 ? addSafeRuleApi : updateSafeRuleApi,
+    getTableList: proTable.value?.getTableList
+  }
+  formDialogRef.value?.openDialog(params)
+}
+
+// 表格配置项
+const columns = reactive<ColumnProps<any>[]>([
+  { type: 'selection', fixed: 'left', width: 70 },
+  { prop: 'id', label: '编号' },
+  {
+    prop: 'aircraftModel',
+    label: '机型',
+    search: {
+      el: 'input'
+    },
+    width: 120
+  },
+  {
+    prop: 'duration',
+    label: '时长',
+    search: {
+      el: 'input'
+    },
+    width: 120
+  },
+  {
+    prop: 'trainExercise',
+    label: '飞行课目',
+    search: {
+      el: 'input'
+    },
+    width: 120
+  },
+  {
+    prop: 'createBy',
+    label: '创建人',
+    width: 120
+  },
+  {
+    prop: 'createTime',
+    label: '创建时间',
+    width: 120
+  },
+  {
+    prop: 'updateBy',
+    label: '更新人',
+    width: 120
+  },
+  {
+    prop: 'updateTime',
+    label: '更新时间',
+    width: 120
+  },
+  { prop: 'operation', label: '操作', width: 230, fixed: 'right' }
+])
+// 表单配置项
+let itemsOptions = reactive<ProForm.ItemsOptions[]>([])
+const setItemsOptions = () => {
+  itemsOptions = [
+    {
+      label: '机型',
+      prop: 'aircraftModel',
+      rules: [{ required: true, message: '机型不能为空', trigger: 'blur' }],
+      compOptions: {
+        placeholder: '请输入机型'
+      }
+    },
+    {
+      label: '时长',
+      prop: 'duration',
+      rules: [{ required: true, message: '时长不能为空', trigger: 'blur' }],
+      compOptions: {
+        placeholder: '请输入时长'
+      }
+    },
+    {
+      label: '飞行课目',
+      prop: 'trainExercise',
+      rules: [{ required: true, message: '飞行课目不能为空', trigger: 'blur' }],
+      compOptions: {
+        placeholder: '请输入飞行课目'
+      }
+    }
+  ]
+}
+</script>

+ 228 - 0
src/views/als/safeRuleSub/index.vue

@@ -0,0 +1,228 @@
+<template>
+  <div class="table-box">
+    <ProTable ref="proTable" :columns="columns" row-key="id" :request-api="listSafeRuleSubApi">
+      <!-- 表格 header 按钮 -->
+      <template #tableHeader="scope">
+        <el-button type="primary" v-auth="['als:safeRuleSub:add']" icon="CirclePlus" @click="openDialog(1, '保障规则子新增')"> 新增 </el-button>
+        <el-button type="primary" v-auth="['als:safeRuleSub:import']" icon="Upload" plain @click="batchAdd"> 导入 </el-button>
+        <el-button type="primary" v-auth="['als:safeRuleSub:export']" icon="Download" plain @click="downloadFile"> 导出 </el-button>
+        <el-button
+          type="danger"
+          v-auth="['als:safeRuleSub:remove']"
+          icon="Delete"
+          plain
+          :disabled="!scope.isSelected"
+          @click="batchDelete(scope.selectedListIds)"
+        >
+          批量删除
+        </el-button>
+      </template>
+      <!-- 表格操作 -->
+      <template #operation="scope">
+        <el-button type="primary" link icon="View" v-auth="['als:safeRuleSub:query']" @click="openDialog(3, '保障规则子查看', scope.row)">
+          查看
+        </el-button>
+        <el-button type="primary" link icon="EditPen" v-auth="['als:safeRuleSub:edit']" @click="openDialog(2, '保障规则子编辑', scope.row)">
+          编辑
+        </el-button>
+        <el-button type="primary" link icon="Delete" v-auth="['als:safeRuleSub:remove']" @click="deleteSafeRuleSub(scope.row)"> 删除 </el-button>
+      </template>
+    </ProTable>
+    <FormDialog ref="formDialogRef" :items-options="itemsOptions" :model="model" />
+    <ImportExcel ref="dialogRef" />
+    <TaskDialog ref="taskDialogRef" />
+  </div>
+</template>
+
+<script setup lang="tsx" name="SafeRuleSub">
+import { useHandleData } from '@/hooks/useHandleData'
+import { ElMessageBox } from 'element-plus'
+import ImportExcel from '@/components/ImportExcel/index.vue'
+import TaskDialog from '@/components/TaskDialog/index.vue'
+import FormDialog from '@/components/FormDialog/index.vue'
+import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
+import {
+  listSafeRuleSubApi,
+  delSafeRuleSubApi,
+  addSafeRuleSubApi,
+  updateSafeRuleSubApi,
+  importTemplateApi,
+  importSafeRuleSubDataApi,
+  exportSafeRuleSubApi,
+  getSafeRuleSubApi
+} from '@/api/modules/als/safeRuleSub'
+
+// ProTable 实例
+const proTable = ref<ProTableInstance>()
+// 表单model
+const model = ref({})
+// 删除保障规则子信息
+const deleteSafeRuleSub = async (params: any) => {
+  await useHandleData(delSafeRuleSubApi, params.id, '删除【' + params.id + '】保障规则子')
+  proTable.value?.getTableList()
+}
+
+// 批量删除保障规则子信息
+const batchDelete = async (ids: string[]) => {
+  await useHandleData(delSafeRuleSubApi, ids, '删除所选保障规则子信息')
+  proTable.value?.clearSelection()
+  proTable.value?.getTableList()
+}
+
+const taskDialogRef = ref<InstanceType<typeof TaskDialog> | null>(null)
+// 导出保障规则子列表
+const downloadFile = async () => {
+  ElMessageBox.confirm('确认导出保障规则子数据?', '温馨提示', { type: 'warning' }).then(async () => {
+    exportSafeRuleSubApi(proTable.value?.searchParam)
+    taskDialogRef.value?.openExportDialog()
+  })
+}
+
+// 批量添加保障规则子
+const dialogRef = ref<InstanceType<typeof ImportExcel> | null>(null)
+const batchAdd = () => {
+  const params = {
+    title: '保障规则子',
+    tempApi: importTemplateApi,
+    importApi: importSafeRuleSubDataApi,
+    getTableList: proTable.value?.getTableList
+  }
+  dialogRef.value?.acceptParams(params)
+}
+
+const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
+// 打开弹框的功能
+const openDialog = async (type: number, title: string, row?: any) => {
+  let res = { data: {} }
+  if (row?.id) {
+    res = await getSafeRuleSubApi(row?.id || null)
+  }
+  model.value = type == 1 ? {} : res.data
+  // 重置表单
+  setItemsOptions()
+  const params = {
+    title,
+    width: 580,
+    isEdit: type !== 3,
+    api: type == 1 ? addSafeRuleSubApi : updateSafeRuleSubApi,
+    getTableList: proTable.value?.getTableList
+  }
+  formDialogRef.value?.openDialog(params)
+}
+
+// 表格配置项
+const columns = reactive<ColumnProps<any>[]>([
+  { type: 'selection', fixed: 'left', width: 70 },
+  { prop: 'id', label: '编号' },
+  {
+    prop: 'aircraftModel',
+    label: '机型',
+    search: {
+      el: 'input'
+    },
+    width: 120
+  },
+  {
+    prop: 'aircraftGroup',
+    label: '机组',
+    search: {
+      el: 'input'
+    },
+    width: 120
+  },
+  {
+    prop: 'duration',
+    label: '时长',
+    search: {
+      el: 'input'
+    },
+    width: 120
+  },
+  {
+    prop: 'device',
+    label: '设备',
+    search: {
+      el: 'input'
+    },
+    width: 120
+  },
+  {
+    prop: 'deviceCount',
+    label: '数量',
+    search: {
+      el: 'input'
+    },
+    width: 120
+  },
+  {
+    prop: 'unit',
+    label: '单位',
+    search: {
+      el: 'input'
+    },
+    width: 120
+  },
+  { prop: 'operation', label: '操作', width: 230, fixed: 'right' }
+])
+// 表单配置项
+let itemsOptions = reactive<ProForm.ItemsOptions[]>([])
+const setItemsOptions = () => {
+  itemsOptions = [
+    {
+      label: '机型',
+      prop: 'aircraftModel',
+      rules: [{ required: true, message: '机型不能为空', trigger: 'blur' }],
+      compOptions: {
+        placeholder: '请输入机型'
+      }
+    },
+    {
+      label: '机组',
+      prop: 'aircraftGroup',
+      rules: [{ required: true, message: '机组不能为空', trigger: 'blur' }],
+      compOptions: {
+        placeholder: '请输入机组'
+      }
+    },
+    {
+      label: '时长',
+      prop: 'duration',
+      rules: [{ required: true, message: '时长不能为空', trigger: 'blur' }],
+      compOptions: {
+        placeholder: '请输入时长'
+      }
+    },
+    {
+      label: '设备',
+      prop: 'device',
+      rules: [{ required: true, message: '设备不能为空', trigger: 'blur' }],
+      compOptions: {
+        placeholder: '请输入设备'
+      }
+    },
+    {
+      label: '数量',
+      prop: 'deviceCount',
+      rules: [{ required: true, message: '数量不能为空', trigger: 'blur' }],
+      compOptions: {
+        placeholder: '请输入数量'
+      }
+    },
+    {
+      label: '单位',
+      prop: 'unit',
+      rules: [{ required: true, message: '单位不能为空', trigger: 'blur' }],
+      compOptions: {
+        placeholder: '请输入单位'
+      }
+    },
+    {
+      label: '备注',
+      prop: 'remark',
+      compOptions: {
+        placeholder: '请输入备注'
+      }
+    }
+  ]
+}
+</script>