فهرست منبع

feat: 机载指令/指令上报/执行指令/指令结果返回

wanggaokun 10 ماه پیش
والد
کامیت
d1e6f6bcf4

+ 9 - 0
src/api/modules/manage/feedbackRawData.ts

@@ -18,6 +18,15 @@ export const getFeedbackRawDataApi = (id: any) => {
   return http.get<any>(`/manage/feedbackRawData/${id}`)
 }
 
+/**
+ * @name 查询反馈的源数据详细
+ * @param id id
+ * @returns returns
+ */
+export const getResultApi = (id: any) => {
+  return http.get<any>(`/manage/feedbackRawData/result/${id}`)
+}
+
 /**
  * @name 新增反馈的源数据
  * @param data data

+ 1 - 1
src/api/modules/manage/instructionInfo.ts

@@ -24,7 +24,7 @@ export const getInstructionInfoApi = (id: any) => {
  * @returns returns
  */
 export const addInstructionInfoApi = (data: any) => {
-  return http.post<any>('/manage/instructionInfo', data, { loading: false })
+  return http.post<any>('/manage/instructionInfo', data, { loading: true })
 }
 
 /**

+ 11 - 1
src/components/ProFormOld/index.vue

@@ -2,7 +2,7 @@
   <el-form @submit.prevent :model="formModel" v-bind="_options" ref="formRef">
     <el-row :gutter="5">
       <template v-for="(item, index) in fieldList" :key="index">
-        <el-col :span="item.span || 24">
+        <el-col :span="item.span || 24" v-if="show(item.show)">
           <el-form-item :rules="item.rules" :prop="[item.field]">
             <template #label>
               <el-space :size="1">
@@ -146,6 +146,16 @@ interface EmitEvent {
   (e: 'reset'): void
   (e: 'cancel'): void
 }
+
+const show = (showFunction: any) => {
+  if (!showFunction) return true
+  if (typeof showFunction == 'function') {
+    // 直接调用 showFunction 函数,并传入 formModel.value
+    return showFunction(formModel.value)
+  }
+  // 如果 showFunction 不是函数,直接返回 true 显示该表单项
+  return true
+}
 const enumMap = ref(new Map<string, { [key: string]: any }[]>())
 const setEnumMap = async ({ field, enum: enumValue }: Form.FieldItem) => {
   if (!enumValue) return

+ 5 - 6
src/components/ProTable/index.vue

@@ -7,13 +7,13 @@
     <!-- 表格头部 操作按钮 -->
     <div class="table-header">
       <div class="header-button-lf">
-        <slot name="tableHeader" :selected-list="selectedList" :selected-list-ids="selectedListIds" :is-selected="isSelected" />
+        <slot name="tableHeader" :radio="radio" :selected-list="selectedList" :selected-list-ids="selectedListIds" :is-selected="isSelected" />
       </div>
       <div v-if="toolButton" class="header-button-ri">
         <slot name="toolButton">
-          <el-button v-if="showToolButton('refresh')" :icon="Refresh" circle @click="getTableList" />
-          <el-button v-if="showToolButton('setting') && columns.length" :icon="Operation" circle @click="openColSetting" />
-          <el-button v-if="showToolButton('search') && searchColumns?.length" :icon="Search" circle @click="isShowSearch = !isShowSearch" />
+          <el-button v-if="showToolButton('refresh')" icon="Refresh" circle @click="getTableList" />
+          <el-button v-if="showToolButton('setting') && columns.length" icon="Operation" circle @click="openColSetting" />
+          <el-button v-if="showToolButton('search') && searchColumns?.length" icon="Search" circle @click="isShowSearch = !isShowSearch" />
         </slot>
       </div>
     </div>
@@ -46,7 +46,7 @@
           </template>
         </el-table-column>
         <!-- other -->
-        <TableColumn v-if="!item.type && item.prop && item.isShow" :column="item">
+        <TableColumn v-else :column="item">
           <template v-for="slot in Object.keys($slots)" #[slot]="scope">
             <slot :name="slot" v-bind="scope" />
           </template>
@@ -82,7 +82,6 @@ import { useTable } from '@/hooks/useTable'
 import { useSelection } from '@/hooks/useSelection'
 import { BreakPoint } from '@/components/Grid/interface'
 import { ColumnProps, TypeProps } from '@/components/ProTable/interface'
-import { Refresh, Operation, Search } from '@element-plus/icons-vue'
 import { handleProp } from '@/utils'
 import SearchForm from '@/components/SearchForm/index.vue'
 import Pagination from './components/Pagination.vue'

+ 18 - 0
src/stores/modules/instResult.ts

@@ -0,0 +1,18 @@
+import { defineStore } from 'pinia'
+
+export const useInstStore = defineStore('admin-inst', {
+  state: (): any => ({
+    // 机载返回结果
+    result: []
+  }),
+  getters: {
+    // 按钮权限列表
+    ResultGet: state => state.result
+  },
+  actions: {
+    // Set RouteName
+    async setResult(result: string) {
+      this.result = result
+    }
+  }
+})

+ 13 - 0
src/typings/global.d.ts

@@ -1,3 +1,16 @@
+/**
+ * 弹窗属性
+ */
+declare interface DialogOption {
+  /**
+   * 弹窗标题
+   */
+  title?: string
+  /**
+   * 是否显示
+   */
+  visible: boolean
+}
 /* Menu */
 declare namespace Menu {
   interface MenuOptions {

+ 19 - 0
src/utils/common.ts

@@ -153,3 +153,22 @@ export function mIsNumber(val) {
   if (String(val).trim().length === 0) return false
   return true
 }
+
+export const generateOrderNumber = (prefix: string): string => {
+  // 获取当前日期
+  const now = new Date()
+
+  // 格式化日期为 yyyyMMddHHmmss
+  const year = now.getFullYear().toString().padStart(4, '0')
+  const month = (now.getMonth() + 1).toString().padStart(2, '0') // 注意月份是从0开始的
+  const day = now.getDate().toString().padStart(2, '0')
+  const hours = now.getHours().toString().padStart(2, '0')
+  const minutes = now.getMinutes().toString().padStart(2, '0')
+  const seconds = now.getSeconds().toString().padStart(2, '0')
+
+  // 拼接成 yyyyMMddHHmmss
+  const dateString = `${year}${month}${day}${hours}${minutes}${seconds}`
+
+  // 返回格式化的单号
+  return `${prefix}-${dateString}`
+}

+ 5 - 0
src/utils/websocket.ts

@@ -24,6 +24,7 @@ import audioSrc from '@/assets/audio/tip.mp3'
 // import { getToken } from '@/utils/token'
 import { ElNotification } from 'element-plus'
 import useNoticeStore from '@/stores/modules/notice'
+// import useInstStore from '@/stores/modules/instResult'
 let socketUrl: any = '' // socket地址
 let websocket: any = null // websocket 实例
 let heartTime: any = null // 心跳定时器实例
@@ -139,6 +140,10 @@ export const websocketOnmessage = () => {
       useAirStore().setAirResult(result[1])
       return
     }
+    // if (e.data.indexOf('机载PHM指令') >= 0) {
+    //   useInstStore().setAirResult(e.data)
+    //   return
+    // }
     useNoticeStore().addNotice({
       message: e.data,
       read: false,

+ 1 - 1
src/views/components/result/index.vue

@@ -93,7 +93,7 @@ const handlePush = async () => {
   }
   const res = await pushApi(data)
   if (res.code == 200) {
-    ElMessage.success('执行成功')
+    ElMessage.success('上报成功')
   }
 }
 // 取消按钮,重置表单,关闭弹框

+ 38 - 44
src/views/manage/feedbackRawData/index.vue

@@ -9,38 +9,24 @@
       :data-callback="dataCallback"
     >
       <!-- 表格 header 按钮 -->
-      <template #tableHeader="scope">
-        <el-button type="primary" v-auth="['manage:feedbackRawData:add']" :icon="CirclePlus" @click="openDialog(1, '反馈的源数据新增')">
+      <template #tableHeader>
+        <!-- <el-button type="primary" v-auth="['manage:feedbackRawData:add']" :icon="CirclePlus" @click="openDialog(1, '反馈的源数据新增')">
           新增
-        </el-button>
-        <el-button type="primary" v-auth="['manage:feedbackRawData:import']" :icon="Upload" plain @click="batchAdd"> 导入 </el-button>
-        <el-button type="primary" v-auth="['manage:feedbackRawData:export']" :icon="Download" plain @click="downloadFile"> 导出 </el-button>
-        <el-button
-          type="danger"
-          v-auth="['system:user:remove']"
-          :icon="Delete"
-          plain
-          :disabled="!scope.isSelected"
-          @click="batchDelete(scope.selectedListIds)"
-        >
-          批量删除
-        </el-button>
+        </el-button> -->
+        <el-button type="primary" v-auth="['manage:feedbackRawData:export']" icon="Download" plain @click="downloadFile"> 导出 </el-button>
       </template>
       <!-- 表格操作 -->
       <template #operation="scope">
-        <el-button type="primary" link :icon="View" v-auth="['manage:feedbackRawData:query']" @click="openDialog(3, '反馈的源数据查看', scope.row)">
+        <el-button type="primary" link icon="View" v-auth="['manage:feedbackRawData:query']" @click="openDialog(3, '反馈的源数据查看', scope.row)">
           查看
         </el-button>
-        <el-button type="primary" link :icon="EditPen" v-auth="['manage:feedbackRawData:edit']" @click="openDialog(2, '反馈的源数据编辑', scope.row)">
-          编辑
-        </el-button>
-        <el-button type="primary" link :icon="Delete" v-auth="['manage:feedbackRawData:remove']" @click="deleteFeedbackRawData(scope.row)">
+        <el-button type="primary" link icon="Delete" v-auth="['manage:feedbackRawData:remove']" @click="deleteFeedbackRawData(scope.row)">
           删除
         </el-button>
       </template>
     </ProTable>
     <FormDialog ref="formDialogRef" />
-    <ImportExcel ref="dialogRef" />
+    <!-- <ImportExcel ref="dialogRef" /> -->
   </div>
 </template>
 
@@ -50,17 +36,14 @@ import { useHandleData } from '@/hooks/useHandleData'
 import { useDownload } from '@/hooks/useDownload'
 import { ElMessageBox } from 'element-plus'
 import ProTable from '@/components/ProTable/index.vue'
-import ImportExcel from '@/components/ImportExcel/index.vue'
+// import ImportExcel from '@/components/ImportExcel/index.vue'
 import FormDialog from '@/components/DialogOld/form.vue'
 import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
-import { Delete, EditPen, Download, Upload, View, CirclePlus } from '@element-plus/icons-vue'
 import {
   listFeedbackRawDataApi,
   delFeedbackRawDataApi,
   addFeedbackRawDataApi,
   updateFeedbackRawDataApi,
-  importTemplateApi,
-  importDataApi,
   exportApi,
   getFeedbackRawDataApi
 } from '@/api/modules/manage/feedbackRawData'
@@ -89,11 +72,11 @@ const deleteFeedbackRawData = async (params: any) => {
 }
 
 // 批量删除反馈的源数据信息
-const batchDelete = async (ids: string[]) => {
-  await useHandleData(delFeedbackRawDataApi, ids, '删除所选反馈的源数据信息')
-  proTable.value?.clearSelection()
-  proTable.value?.getTableList()
-}
+// const batchDelete = async (ids: string[]) => {
+//   await useHandleData(delFeedbackRawDataApi, ids, '删除所选反馈的源数据信息')
+//   proTable.value?.clearSelection()
+//   proTable.value?.getTableList()
+// }
 
 // 导出反馈的源数据列表
 const downloadFile = async () => {
@@ -103,16 +86,16 @@ const downloadFile = async () => {
 }
 
 // 批量添加反馈的源数据
-const dialogRef = ref<InstanceType<typeof ImportExcel> | null>(null)
-const batchAdd = () => {
-  const params = {
-    title: '反馈的源数据',
-    tempApi: importTemplateApi,
-    importApi: importDataApi,
-    getTableList: proTable.value?.getTableList
-  }
-  dialogRef.value?.acceptParams(params)
-}
+// const dialogRef = ref<InstanceType<typeof ImportExcel> | null>(null)
+// const batchAdd = () => {
+//   const params = {
+//     title: '反馈的源数据',
+//     tempApi: importTemplateApi,
+//     importApi: importDataApi,
+//     getTableList: proTable.value?.getTableList
+//   }
+//   dialogRef.value?.acceptParams(params)
+// }
 
 const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
 // 打开弹框的功能
@@ -138,13 +121,19 @@ const openDialog = async (type: number, title: string, row?: any) => {
 // 表格配置项
 const columns = reactive<ColumnProps<any>[]>([
   { type: 'selection', fixed: 'left', width: 70 },
+  {
+    prop: 'content',
+    label: '指令内容',
+    search: {
+      el: 'input'
+    }
+  },
   {
     prop: 'remark',
-    label: '备注',
+    label: '结果',
     search: {
       el: 'input'
-    },
-    width: 120
+    }
   },
   {
     prop: 'createTime',
@@ -157,7 +146,12 @@ let fieldList: Form.FieldItem[] = []
 const setFieldList = () => {
   fieldList = [
     {
-      label: '备注',
+      label: '指令内容',
+      field: 'content',
+      placeholder: '请输入备注'
+    },
+    {
+      label: '结果',
       field: 'remark',
       placeholder: '请输入备注'
     }

+ 27 - 15
src/views/manage/instructionInfo/index.vue

@@ -11,8 +11,8 @@
       <!-- 表格 header 按钮 -->
       <template #tableHeader="scope">
         <el-button type="primary" v-auth="['manage:instructionInfo:add']" :icon="CirclePlus" @click="openDialog(1, '指令信息新增')"> 新增 </el-button>
-        <el-button type="primary" :icon="CirclePlus" @click="connect()"> 连接 </el-button>
-        <el-button type="primary" :icon="CirclePlus" @click="openAirDialog()"> 实时结果 </el-button>
+        <el-button type="primary" :icon="CirclePlus" @click="connect()"> 重连机载PHM </el-button>
+        <el-button type="primary" :icon="CirclePlus" v-if="0" @click="openAirDialog()"> 实时结果 </el-button>
         <el-button type="primary" v-if="0" v-auth="['manage:instructionInfo:import111']" :icon="Upload" plain @click="batchAdd"> 导入 </el-button>
         <el-button type="primary" v-if="0" v-auth="['manage:instructionInfo:export111']" :icon="Download" plain @click="downloadFile">
           导出
@@ -159,7 +159,7 @@ const connect = async () => {
 }
 
 const send = async (id: any) => {
-  const res = await sendApi(id)
+  const res = await sendApi({ instId: id })
   if (res.code == 200) {
     ElMessage.success('发送成功')
   }
@@ -169,14 +169,11 @@ const send = async (id: any) => {
 const columns = reactive<ColumnProps<any>[]>([
   { type: 'selection', fixed: 'left', width: 70 },
   {
-    prop: 'attribute',
-    label: '指令',
-    tag: true,
-    enum: () => getDictsApi('air_order'),
+    prop: 'code',
+    label: '指令编码',
     search: {
-      el: 'select'
-    },
-    fieldNames: { label: 'dictLabel', value: 'dictValue' }
+      el: 'input'
+    }
   },
   {
     prop: 'content',
@@ -185,6 +182,16 @@ const columns = reactive<ColumnProps<any>[]>([
       el: 'input'
     }
   },
+  {
+    prop: 'attribute',
+    label: '指令',
+    tag: true,
+    enum: () => getDictsApi('air_order'),
+    search: {
+      el: 'select'
+    },
+    fieldNames: { label: 'dictLabel', value: 'dictValue' }
+  },
   {
     prop: 'createTime',
     label: '创建时间'
@@ -201,6 +208,16 @@ const setFieldList = () => {
     //   field: 'attribute',
     //   placeholder: '请输入指令属性'
     // },
+    {
+      label: '指令编码',
+      field: 'code',
+      placeholder: '请输入指令内容'
+    },
+    {
+      label: '指令内容',
+      field: 'content',
+      placeholder: '请输入指令内容'
+    },
     {
       label: '指令属性',
       field: 'attribute',
@@ -212,11 +229,6 @@ const setFieldList = () => {
         valueKey: 'dictValue'
       },
       placeholder: '请选择指令'
-    },
-    {
-      label: '指令内容',
-      field: 'content',
-      placeholder: '请输入指令内容'
     }
     // {
     //   label: 'XML格式文件',

+ 128 - 17
src/views/manage/orderConfig/index.vue

@@ -3,7 +3,7 @@
     <ProTable ref="proTable" :columns="columns" row-key="id" :request-api="listOrderConfigApi" :init-param="initParam" :data-callback="dataCallback">
       <!-- 表格 header 按钮 -->
       <template #tableHeader="scope">
-        <el-button type="primary" v-auth="['manage:orderConfig:add']" :icon="CirclePlus" @click="openDialog(1, '指令配置新增')"> 新增 </el-button>
+        <el-button type="primary" v-auth="['manage:orderConfig:add']" :icon="CirclePlus" @click="handleAdd()"> 新增 </el-button>
         <el-button type="primary" v-auth="['manage:orderConfig:import']" :icon="Upload" plain @click="batchAdd"> 导入 </el-button>
         <el-button type="primary" v-auth="['manage:orderConfig:export']" :icon="Download" plain @click="downloadFile"> 导出 </el-button>
         <el-button
@@ -27,6 +27,41 @@
         </el-button>
         <el-button type="primary" link :icon="Delete" v-auth="['manage:orderConfig:remove']" @click="deleteOrderConfig(scope.row)"> 删除 </el-button>
       </template>
+
+      <el-dialog v-model="dialog.visible" :title="dialog.title" destroy-on-close append-to-body width="600px">
+        <el-form ref="orderFormRef" :model="form" :rules="rules" label-width="80px">
+          <el-form-item label="指令编码" prop="orderCode">
+            <el-input v-model="form.orderCode" placeholder="请输入指令编码" />
+          </el-form-item>
+          <el-form-item label="指令名称" prop="name">
+            <el-input v-model="form.name" placeholder="请输入指令名称" />
+          </el-form-item>
+          <el-form-item label="指令类型" prop="type">
+            <el-select v-model="form.type" placeholder="请选择指令类型">
+              <el-option v-for="item in types" :key="item.dictValue" :label="item.dictLabel" :value="item.dictValue" />
+            </el-select>
+          </el-form-item>
+          <el-form-item v-if="form.type !== '10'" label="架次" prop="sortie">
+            <el-select v-model="form.sortie" placeholder="请选择架次">
+              <el-option v-for="item in sortieOptions" :key="item.sortieNumber" :label="item.sortieNumber" :value="item.sortieNumber" />
+            </el-select>
+          </el-form-item>
+          <el-form-item v-else label="维修内容" prop="instId">
+            <el-select v-model="form.instId" placeholder="请选择维修内容">
+              <el-option v-for="item in instOptions" :key="item.id" :label="item.label" :value="item.value" />
+            </el-select>
+          </el-form-item>
+          <el-form-item label="备注" prop="description">
+            <el-input v-model="form.description" type="textarea" placeholder="请输入内容"></el-input>
+          </el-form-item>
+        </el-form>
+        <template #footer>
+          <div class="dialog-footer">
+            <el-button type="primary" @click="submitForm">确 定</el-button>
+            <el-button @click="closeDialog">取 消</el-button>
+          </div>
+        </template>
+      </el-dialog>
     </ProTable>
     <FormDialog ref="formDialogRef" />
     <ImportExcel ref="dialogRef" />
@@ -35,10 +70,10 @@
 </template>
 
 <script setup lang="tsx" name="OrderConfig">
-import { ref, reactive } from 'vue'
+import { ref, reactive, onMounted } from 'vue'
 import { useHandleData } from '@/hooks/useHandleData'
 import { useDownload } from '@/hooks/useDownload'
-import { ElMessageBox } from 'element-plus'
+import { ElMessage, ElMessageBox } from 'element-plus'
 import ProTable from '@/components/ProTable/index.vue'
 import ImportExcel from '@/components/ImportExcel/index.vue'
 import FormDialog from '@/components/DialogOld/form.vue'
@@ -58,13 +93,87 @@ import {
 } from '@/api/modules/manage/orderConfig'
 import { getDictsApi } from '@/api/modules/system/dictData'
 import { listSortieAllApi } from '@/api/modules/manage/sortie'
-
+import { listInstructionInfoApi } from '@/api/modules/manage/instructionInfo'
+import { generateOrderNumber } from '@/utils/common'
 // ProTable 实例
 const proTable = ref<ProTableInstance>()
 
-// 如果表格需要初始化请求参数,直接定义传给 ProTable (之后每次请求都会自动带上该参数,此参数更改之后也会一直带上,改变此参数会自动刷新表格数据)
+let types = ref<any[]>([])
+onMounted(async () => {
+  getDictsApi('order_type').then(res => {
+    types.value = res.data
+  })
+  let sortie = await listSortieAllApi({})
+  sortieOptions.value = sortie.data
+  let inst = await listInstructionInfoApi({})
+  instOptions.value = inst.data.data.map(item => {
+    return { value: item.id, label: `${item.content}-` + (item.attribute == '1' ? '开' : '关') }
+  })
+  console.log('content', instOptions.value)
+})
+
+const initFormData = {
+  orderCode: generateOrderNumber('INST'),
+  name: '',
+  type: '',
+  instId: '',
+  sortie: '',
+  description: ''
+}
 const initParam = reactive({})
+const form = ref({ ...initFormData })
+const rules = reactive({
+  orderCode: [{ required: true, message: '指令编码不能为空', trigger: 'blur' }],
+  name: [{ required: true, message: '指令名称不能为空', trigger: 'blur' }],
+  type: [{ required: true, message: '指令类型不能为空', trigger: 'change' }],
+  sortie: [{ required: true, message: '架次不能为空', trigger: 'change' }],
+  instId: [{ required: true, message: '内容不能为空', trigger: 'change' }]
+})
+const dialog = reactive<DialogOption>({
+  visible: false,
+  title: ''
+})
 
+const orderFormRef = ref<ElFormInstance>()
+/** 新增按钮操作 */
+const handleAdd = () => {
+  form.value = { ...initFormData }
+  orderFormRef.value?.resetFields()
+  dialog.visible = true
+  dialog.title = '添加字典类型'
+}
+/** 提交按钮 */
+const submitForm = () => {
+  orderFormRef.value?.validate(async (valid: boolean) => {
+    if (valid) {
+      addOrderConfigApi(form.value).then(res => {
+        if (res.code == 200) {
+          ElMessage.success(res.msg)
+          dialog.visible = false
+          proTable.value?.getTableList()
+        } else {
+          ElMessage.error(res.msg)
+        }
+      })
+    }
+  })
+}
+
+/**
+ * 关闭用户弹窗
+ */
+const closeDialog = () => {
+  dialog.visible = false
+  resetForm()
+}
+
+/**
+ * 重置表单
+ */
+const resetForm = () => {
+  orderFormRef.value?.resetFields()
+  orderFormRef.value?.clearValidate()
+}
 // dataCallback 是对于返回的表格数据做处理,如果你后台返回的数据不是 list && total && pageNum && pageSize 这些字段,可以在这里进行处理成这些字段
 const dataCallback = (data: any) => {
   const page = proTable.value!.pageable
@@ -122,6 +231,7 @@ const batchAdd = () => {
 
 const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
 const sortieOptions = ref<any[]>([])
+const instOptions = ref<any[]>([])
 // 打开弹框的功能
 const openDialog = async (type: number, title: string, row?: any) => {
   let res = { data: {} }
@@ -150,10 +260,7 @@ const columns = reactive<ColumnProps<any>[]>([
   { type: 'selection', fixed: 'left', width: 70 },
   {
     prop: 'orderCode',
-    label: '指令编码',
-    search: {
-      el: 'input'
-    }
+    label: '指令编码'
   },
   {
     prop: 'name',
@@ -173,26 +280,30 @@ const columns = reactive<ColumnProps<any>[]>([
     prop: 'type',
     label: '指令类型',
     tag: true,
-    enum: () => getDictsApi('order_type'),
+    enum: types,
     search: {
       el: 'select'
     },
     fieldNames: { label: 'dictLabel', value: 'dictValue' }
   },
   {
-    prop: 'sortie',
-    label: '架次',
+    prop: 'instId',
+    label: '维修内容',
+    tag: true,
+    enum: instOptions,
     search: {
-      el: 'input'
+      el: 'select'
     },
+    width: 220
+  },
+  {
+    prop: 'sortie',
+    label: '内容',
     width: 120
   },
   {
     prop: 'description',
-    label: '指令描述',
-    search: {
-      el: 'input'
-    }
+    label: '指令描述'
   },
   {
     prop: 'createTime',

+ 40 - 3
src/views/manage/orderInfo/index.vue

@@ -11,6 +11,8 @@
           执行
         </el-button> -->
         <el-button type="primary" link v-auth="['manage:orderInfo:edit']" v-if="scope.row.status == '0'" @click="toExe(scope.row)"> 执行 </el-button>
+        <el-button type="primary" link v-if="scope.row.orderType == '10' && scope.row.status == '1'" @click="handlePush(scope.row)"> 上报 </el-button>
+        <el-button type="primary" link v-if="scope.row.orderType == '10'" @click="connect()"> 重连 </el-button>
       </template>
     </ProTable>
     <FormDialog ref="formDialogRef" />
@@ -25,9 +27,12 @@ import ProTable from '@/components/ProTable/index.vue'
 import FormDialog from '@/components/DialogOld/form.vue'
 import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
 import { Download } from '@element-plus/icons-vue'
-import { listOrderInfoApi, exportApi } from '@/api/modules/manage/orderInfo'
+import { listOrderInfoApi, exportApi, updateOrderInfoApi } from '@/api/modules/manage/orderInfo'
 import { getOrderConfigByCodeApi } from '@/api/modules/manage/orderConfig'
 import { getDictsApi } from '@/api/modules/system/dictData'
+import { sendApi, connectApi } from '@/api/modules/manage/instructionInfo'
+import { pushApi } from '@/api/modules/manage/sortieParameter'
+import { getResultApi } from '@/api/modules/manage/feedbackRawData'
 import { useRouter } from 'vue-router'
 const router = useRouter()
 const toExe = async (row: any) => {
@@ -38,11 +43,43 @@ const toExe = async (row: any) => {
     return
   }
   if (row.orderType == 10) {
-    router.push({ path: '/manage/instructionInfo' })
+    send(data.instId, row.id)
     return
   }
   router.push({ path: `/order/task/${data.sortie}`, query: { type: row.orderType, orderId: row.id, taskId: row.orderBatchId } })
 }
+const handlePush = async (row?: any) => {
+  const result = await getResultApi(row?.id || null)
+  if (result.code != 200 || !result.data) {
+    ElMessage.error('未返回维修测试结果,请等待')
+    return
+  }
+  let data = {
+    id: row.orderBatchId,
+    content: result.data.remark
+  }
+  const res = await pushApi(data)
+  if (res.code == 200) {
+    await updateOrderInfoApi({ id: row.id, status: '2' })
+    proTable.value?.getTableList()
+    ElMessage.success('上报成功')
+  }
+}
+const connect = async () => {
+  const res = await connectApi()
+  if (res.code == 200) {
+    ElMessage.success('机载服务端连接成功')
+  }
+}
+
+const send = async (instId: any, id: any) => {
+  const res = await sendApi({ instId, orderId: id })
+  if (res.code == 200) {
+    await updateOrderInfoApi({ id, status: '1' })
+    proTable.value?.getTableList()
+    ElMessage.success('发送成功')
+  }
+}
 
 // ProTable 实例
 const proTable = ref<ProTableInstance>()
@@ -116,6 +153,6 @@ const columns = reactive<ColumnProps<any>[]>([
     label: '创建时间',
     width: 230
   },
-  { prop: 'operation', label: '操作', width: 120 }
+  { prop: 'operation', label: '操作', width: 220 }
 ])
 </script>