浏览代码

feat(软件包管理): 静态页面的开发

完成编辑添加api开发,以及权限操作的开发。待接口对接
wyoujia 1 年之前
父节点
当前提交
8c7ba6861a

+ 54 - 4
admin.ui.plus-master/src/api/admin/deviceAuthorization/softwarePackageManagementApi.ts

@@ -1,7 +1,7 @@
 import {ContentType, HttpClient, RequestParams} from "/@/api/admin/http-client";
 import {
   softwarePackageManagement_DtoResult,
-  softwarePackageManagement_PageInput
+  softwarePackageManagement_PageInput, softwarePackageManagement_TableData
 } from "/@/api/admin/deviceAuthorization/softwarePackageManagementDto";
 import {oilSdkAuthorPageOutput, oilSdkTableModel} from "/@/api/admin/deviceAuthorization/oilSdkAuthorDto";
 
@@ -38,7 +38,9 @@ export class SoftwarePackageManagementApi<SecurityDataType = unknown> extends Ht
               numberOfDownloads: 1234,
               remark: 'tast',
               releaseTime: '2020-10-21',
-              uploadTime: '2020-10-21'
+              uploadTime: '2020-10-21',
+              downloadUrl:'upload/2023/10/27/653b8909-14d2-7870-0097-10007db02419.json',
+              fileName:'22.json'
             },{
               guid: 2,
               date: '2020-10-22',
@@ -51,7 +53,9 @@ export class SoftwarePackageManagementApi<SecurityDataType = unknown> extends Ht
               numberOfDownloads: 3214,
               remark: 'test',
               releaseTime: '2020-10-22',
-              uploadTime: '2020-10-22'
+              uploadTime: '2020-10-22',
+              downloadUrl:'',
+              fileName:'22.json'
             },{
               guid: 3,
               date: '2020-10-23',
@@ -64,7 +68,9 @@ export class SoftwarePackageManagementApi<SecurityDataType = unknown> extends Ht
               numberOfDownloads: 4321,
               remark: 'tast',
               releaseTime: '2020-10-23',
-              uploadTime: '2020-10-23'
+              uploadTime: '2020-10-23',
+              downloadUrl:'',
+              fileName:'22.json'
             }]
           }
         })
@@ -80,4 +86,48 @@ export class SoftwarePackageManagementApi<SecurityDataType = unknown> extends Ht
     //   query:query,
     //   ...params
     // })
+
+  /**
+   * No description
+   *
+   * @tags
+   * @name getPageData
+   * @summary 分页查询
+   * @request GET:
+   * @secure
+   */
+  updateData = (data:softwarePackageManagement_TableData) => {
+    return new Promise(resolve => {
+      setTimeout(() => {
+        resolve({
+          success: true,
+          code: 200,
+          msg: '',
+          data: {}
+        })
+      },this.timer)
+    })
+  }
+
+  /**
+   * No description
+   *
+   * @tags
+   * @name getPageData
+   * @summary 分页查询
+   * @request GET:
+   * @secure
+   */
+  addData = (data:softwarePackageManagement_TableData) => {
+    return new Promise(resolve => {
+      setTimeout(() => {
+        resolve({
+          success: true,
+          code: 200,
+          msg: '',
+          data: {}
+        })
+      },this.timer)
+    })
+  }
 }

+ 4 - 0
admin.ui.plus-master/src/api/admin/deviceAuthorization/softwarePackageManagementDto.ts

@@ -52,6 +52,10 @@ export  interface softwarePackageManagement_TableData{
   releaseTime?: string | null
   /**上传日期*/
   uploadTime?: string | null
+  /**下载地址*/
+  downloadUrl?: string | null
+  /**文件名*/
+  fileName?: string | null
 }
 
 /**

+ 88 - 0
admin.ui.plus-master/src/components/my-upload-file/index.vue

@@ -0,0 +1,88 @@
+<template>
+  <el-upload
+    class="upload-demo"
+    v-model:file-list="fileList"
+    drag
+    :headers="{ Authorization:  'Bearer ' + useUserInfoStores.getToken()}"
+    :action='baseUrl+"/api/admin/file/upload-file"'
+    :on-success="handleAvatarSuccess"
+    :before-upload="beforeAvatarUpload"
+  >
+    <el-icon class="el-icon--upload"><upload-filled /></el-icon>
+    <div class="el-upload__text">
+      将文件拖到此处/<em>点击上传</em>
+    </div>
+    <template #tip>
+      <div class="el-upload__tip">
+        软件包上传
+      </div>
+    </template>
+  </el-upload>
+</template>
+
+<script setup lang="ts">
+import {UploadFilled} from "@element-plus/icons-vue";
+import { useUserInfo } from '/@/stores/userInfo'
+import {ElMessage, UploadProps, UploadUserFile} from "element-plus";
+import {onMounted, ref, watch} from "vue";
+
+const useUserInfoStores = useUserInfo()
+
+
+//接受父组件的传值
+const props = defineProps({
+  file:{} as any
+})
+
+const emits = defineEmits(['onUpload'])
+
+// eslint-disable-next-line vue/no-dupe-keys
+const file = ref(props.file)
+
+
+// const isShow = ref(props.isShow)
+
+const fileList = ref<UploadUserFile[]>([])
+
+
+const baseUrl = import.meta.env.VITE_API_URL
+
+watch(() => props.file.fileUrl, (val)=> {
+  file.value.fileUrl = val
+  if(file.value.fileUrl) {
+    fileList.value = [{name:file.value.fileName,url:file.value.fileUrl} as UploadUserFile]
+  }else{
+    fileList.value = []
+  }
+})
+watch(() => props.file.fileName, (val)=> file.value.fileName = val)
+
+const handleAvatarSuccess: UploadProps['onSuccess'] = (
+  response,
+) => {
+  const res = response?.data
+  fileList.value = [{name:res.fileName+res.extension,url:res.linkUrl}]
+  file.value.fileUrl = res.fileDirectory +'/'+ res.fileGuid + res.extension
+  file.value.fileName = res.fileName+res.extension
+  emits('onUpload',file.value)
+}
+
+const beforeAvatarUpload: UploadProps['beforeUpload'] = (rawFile) => {
+  if (rawFile.size / 1024 / 1024 > 10) {
+    ElMessage.error('文件超过10MB!')
+    return false
+  }
+  return true
+}
+
+onMounted(()=>{
+  if(file.value.fileUrl) fileList.value = [{name:file.value.fileName,url:file.value.fileUrl} as UploadUserFile]
+})
+
+
+
+</script>
+
+<style scoped lang="scss">
+
+</style>

+ 35 - 47
admin.ui.plus-master/src/views/admin/authorize/softwarePackageManagement/components/form-edit.vue

@@ -9,31 +9,31 @@
                label-width="80px">
         <el-row :gutter="35">
           <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
-            <el-form-item label="软件类型">
+            <el-form-item label="软件类型" prop="softwareType">
               <el-select  v-model="formData.editData.softwareType" placeholder="请选择软件类型" >
                 <el-option v-for="(value, key) in softwareType" :key="key" :label="value[1].name"  :value="Number(value[1].value)" />
               </el-select>
             </el-form-item>
           </el-col>
           <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
-            <el-form-item label="设备类型">
+            <el-form-item label="设备类型" prop="equipmentType">
               <el-select  v-model="formData.editData.equipmentType" placeholder="请选择设备类型" >
                 <el-option v-for="(value, key) in equipmentType" :key="key" :label="value[1].name"  :value="Number(value[1].value)" />
               </el-select>
             </el-form-item>
           </el-col>
           <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
-            <el-form-item label="软件包名" prop="sn">
+            <el-form-item label="软件包名" prop="softwareName">
               <el-input v-model="formData.editData.softwareName" placeholder="请输入软件包名" clearable></el-input>
             </el-form-item>
           </el-col>
           <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
-            <el-form-item label="版本" prop="key">
+            <el-form-item label="版本" prop="version">
               <el-input v-model="formData.editData.version" placeholder="请输入版本" clearable></el-input>
             </el-form-item>
           </el-col>
           <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
-            <el-form-item label="说明" prop="key">
+            <el-form-item label="说明" prop="explain">
               <el-input v-model="formData.editData.explain" placeholder="请输入说明" rows="6" clearable type="textarea"></el-input>
             </el-form-item>
           </el-col>
@@ -43,22 +43,7 @@
             </el-form-item>
           </el-col>
         </el-row>
-        <el-upload
-          class="upload-demo"
-          drag
-          action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15"
-          multiple
-        >
-          <el-icon class="el-icon--upload"><upload-filled /></el-icon>
-          <div class="el-upload__text">
-              将文件拖到此处/<em>点击上传</em>
-          </div>
-          <template #tip>
-            <div class="el-upload__tip">
-              软件包上传
-            </div>
-          </template>
-        </el-upload>
+        <MyUploadFile  :file="{fileUrl:formData.editData.downloadUrl,fileName:formData.editData.fileName}"  @onUpload="onUpload"/>
       </el-form>
       <template #footer>
         <span class="dialog-footer">
@@ -71,11 +56,14 @@
 </template>
 
 <script setup lang="ts">
-import {reactive, ref, watch} from "vue";
+import {defineAsyncComponent, reactive, ref, watch} from "vue";
 import {FormRules} from "element-plus";
+import eventBus from "/@/utils/mitt";
 import {softwarePackageManagement_TableData} from "/@/api/admin/deviceAuthorization/softwarePackageManagementDto";
 import {useGlobalCacheStore} from "/@/stores/globalCacheStore";
-import {UploadFilled} from "@element-plus/icons-vue";
+import {SoftwarePackageManagementApi} from "/@/api/admin/deviceAuthorization/softwarePackageManagementApi";
+
+const MyUploadFile = defineAsyncComponent(() => import('/@/components/my-upload-file/index.vue'))
 
 /**获取全局缓存*/
 const globalCacheStore = useGlobalCacheStore()
@@ -89,6 +77,7 @@ enum Form {
   UPDATE
 }
 
+
 /**数据对象 */
 const formData = reactive({
   loading: false,
@@ -117,7 +106,9 @@ const rules = reactive<FormRules>({
   ],
 })
 
-
+/**
+ * 表单对象
+ */
 const formRef = ref()
 
 const openDialog = (val) => {
@@ -150,35 +141,32 @@ watch(() => formData.isShowDialog,(newVal) => {
   if(newVal) formRef.value?.resetFields()
 })
 
+const onUpload = (val) => {
+  formData.editData.downloadUrl = val.fileUrl
+  formData.editData.fileName = val.fileName
+}
+
 const onSubmit =  () => {
   formRef.value.validate(async (valid: boolean) =>{
     if(!valid) return
 
     formData.loading = true
+    let res = {} as any
     console.log(formData.editData)
-
-    // // eslint-disable-next-line @typescript-eslint/no-unused-vars,no-unused-vars
-    // const { projectName, state, ...newData} = formData.editData
-    // let res = {} as any
-    // if(formData.formType === Form.UPDATE){
-    //   res = await new OilSdkAuthorAPI().updateForm({project: formData.editData.projectName, state: formData.editData.state === '正常' ? 1 : 0 ?? 0,  ...newData},{ showSuccessMessage: true }).catch(() => {
-    //     formData.loading = false
-    //   })
-    // }else if(formData.formType === Form.ADD){
-    //   res = await new OilSdkAuthorAPI().addForm({project: formData.editData.projectName, state: formData.editData.state === '正常' ? 1 : 0 ?? 0,  ...newData},{ showSuccessMessage: true }).catch(() => {
-    //     formData.loading = false
-    //   })
-    // }else {
-    //   formData.loading = false
-    //   return
-    // }
-    //
-    // if(res?.success){
-    //   console.log('2')
-    //   eventBus.emit('refreshView')
-    //   formData.isShowDialog = false
-    //   formData.editData = {} as oilSdkTableModel
-    // }
+    if(formData.formType === Form.UPDATE){
+      res = await new SoftwarePackageManagementApi().updateData(formData.editData)
+    }else if(formData.formType === Form.ADD){
+      res = await new SoftwarePackageManagementApi().updateData(formData.editData)
+    }else {
+      formData.loading = false
+      return
+    }
+
+    if(res?.success){
+      eventBus.emit('refreshView')
+      formData.isShowDialog = false
+      formData.editData = {} as softwarePackageManagement_TableData
+    }
 
     formData.loading = false
   })

+ 66 - 3
admin.ui.plus-master/src/views/admin/authorize/softwarePackageManagement/index.vue

@@ -70,10 +70,21 @@
                 </span>
               </template>
             </el-table-column>
-            <el-table-column label="操作"  fixed="right" header-align="center" align="center">
-              <template #default="{ row }">
+            <el-table-column label="操作"  fixed="right" header-align="center" align="center" class="right-operation" width="140">
+              <template #default="{ row }" >
                 <el-link
                   class="my-el-link mr12 ml12"
+                  v-if="row.state === 0"
+                  type="primary"
+                  icon="ele-Upload"
+                  size="small"
+                  @click="onRelease(row)"
+                  :underline="false"
+                  target="_blank"
+                >发布</el-link>
+                <el-link
+                  class="my-el-link mr12 ml12"
+                  v-if="row.state === 0"
                   type="primary"
                   icon="ele-Edit"
                   size="small"
@@ -81,6 +92,36 @@
                   :underline="false"
                   target="_blank"
                 >编辑</el-link>
+                <el-link
+                  class="my-el-link mr12 ml12"
+                  v-if="row.state === 1"
+                  type="primary"
+                  icon="ele-Download"
+                  size="small"
+                  @click="onDownload(row)"
+                  :underline="false"
+                  target="_blank"
+                >下载</el-link>
+                <el-link
+                  class="my-el-link mr12 ml12"
+                  v-if="row.state === 1"
+                  type="primary"
+                  icon="ele-WarningFilled"
+                  size="small"
+                  @click="onFailure(row)"
+                  :underline="false"
+                  target="_blank"
+                >失效</el-link>
+                <el-link
+                  class="my-el-link mr12 ml12"
+                  v-if="row.state !== 0"
+                  type="primary"
+                  icon="ele-Tickets"
+                  size="small"
+                  @click="onDownloadRecord(row)"
+                  :underline="false"
+                  target="_blank"
+                >下载记录</el-link>
               </template>
             </el-table-column>
           </el-table>
@@ -261,6 +302,26 @@ const editTableData = (row) => {
   editDialogRef.value.openDialog(row)
 }
 
+/**发布*/
+const onRelease = (row) => {
+  alert('发布')
+}
+
+/**下载*/
+const onDownload = (row) => {
+  alert('下载')
+}
+
+/**失效*/
+const onFailure = (row) => {
+  alert('失效')
+}
+
+/**下载记录*/
+const onDownloadRecord = (row) => {
+  alert('下载记录')
+}
+
 /**页条数变化*/
 const onSizeChange = () => {
   init()
@@ -290,5 +351,7 @@ const getColor = (val,row) => {
 </script>
 
 <style scoped lang="scss">
-
+.el-link{
+  padding: 5px;
+}
 </style>