黎有为 1 rok pred
rodič
commit
8d7c5d2ede

+ 12 - 0
src/services/baseInfo.js

@@ -70,4 +70,16 @@ export function DeleteTclass(tClassId) {
     method: "post",
     data: { tClassId }
   })
+}
+
+export function UploadFileApi(file) {
+  const customHeaders = {
+    "Content-Type": "multipart/form-data",
+  }
+  return request({
+    url: '/upload/fileUpload',
+    method: "post",
+    data: file,
+    headers: customHeaders
+  })
 }

+ 7 - 0
src/utils/data/select-data.js

@@ -259,7 +259,14 @@ export const DataSourceArr = createEnum([
   { label: '服务', value: 'DATA_SERVER' },
 ])
 
+// 文件型数据库类型
 export const ConvergeFileType = createEnum([
   { label: 'FTP', value: 1 },
   { label: 'SFTP', value: 2 },
+])
+
+// 文件类型
+export const FileType = createEnum([
+  { label: 'SHP', value: 'shp' },
+  { label: 'SLPK', value: 'slpk' }
 ])

+ 49 - 16
src/views/dataSource/Detail.vue

@@ -2,13 +2,15 @@
   <div id="res-cata-detail" class="detail-default">
     <div class="detail-header">
       <div class="d-title">
-        <span v-if="route.params.type==='add'">新增</span>
-        <span v-else-if="route.params.type==='detail'">详情</span>
-        <span v-else-if="route.params.type==='edit'">编辑</span>
+        <span v-if="route.params.type === 'add'">新增</span>
+        <span v-else-if="route.params.type === 'detail'">详情</span>
+        <span v-else-if="route.params.type === 'edit'">编辑</span>
       </div>
       <div class="d-btns">
-        <el-button class="btn-default primary" type="primary" v-if="route.params.type==='add'" @click="handleSave()">发布</el-button>
-        <el-button class="btn-default primary" type="primary" v-if="route.params.type==='edit'" @click="handleSave()">保存</el-button>
+        <el-button class="btn-default primary" type="primary" v-if="route.params.type === 'add'"
+          @click="handleSave()">发布</el-button>
+        <el-button class="btn-default primary" type="primary" v-if="route.params.type === 'edit'"
+          @click="handleSave()">保存</el-button>
         <el-button class="btn-default" @click="handleClose">关闭</el-button>
       </div>
     </div>
@@ -18,17 +20,30 @@
         <my-form :form-data="form.basicInfo" class="form-detail" ref="basicInfo"></my-form>
         <span class="detail-part-title">详细信息</span>
         <my-form :form-data="selectedFormData" class="form-detail" ref="extentInfo"></my-form>
+        <span class="detail-part-title">文件上传</span>
+        <el-form-item label="文件类型">
+          <el-select v-model="fileType" placeholder="请选择">
+            <el-option v-for="item in FileType" :key="item.value" :label="item.label" :value="item.value" />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="文件上传">
+          <el-upload v-model:file-list="fileList" class="upload-demo" :before-upload="beforeFileUpload"
+            :http-request="uploadFile" drag multiple>
+            <el-button type="primary">Click to upload</el-button>
+          </el-upload>
+        </el-form-item>
       </div>
     </div>
   </div>
 </template>
 
 <script setup>
+import { ElMessage } from 'element-plus'
 import { computed, onBeforeMount, reactive, ref } from 'vue'
 import { useRoute, useRouter } from 'vue-router'
-import { ConvergeFileType, DatabaseTypeArr, DataTypeArr } from '../../utils/data/select-data'
 import MyForm from '../../components/Form.vue'
-import { AddSource, EditSource, GetSourceDetail } from '../../services/baseInfo'
+import { AddSource, EditSource, GetSourceDetail, UploadFileApi } from '../../services/baseInfo'
+import { ConvergeFileType, DataTypeArr, DatabaseTypeArr, FileType } from '../../utils/data/select-data'
 
 const route = useRoute()
 const router = useRouter()
@@ -60,7 +75,7 @@ const form = reactive({
 
 const selectedFormData = computed(calculateFormData)
 
-function calculateFormData () {
+function calculateFormData() {
   const type = form.basicInfo.find(item => item.fieldName === 'sourceType').value
   if (type === '1') {
     return form.DBExtentInfo
@@ -73,7 +88,7 @@ function calculateFormData () {
   }
 }
 
-function handleClose () {
+function handleClose() {
   router.push({
     name: 'DataSourceManage',
   })
@@ -81,8 +96,9 @@ function handleClose () {
 
 const basicInfo = ref(null)
 const extentInfo = ref(null)
+const fileType = ref(FileType)
 
-function handleSave () {
+function handleSave() {
   Promise.all([basicInfo.value.validateForm(), extentInfo.value.validateForm()]).then(valid => {
     if (valid.findIndex(val => val === false) === -1) {
       // 校验通过
@@ -115,6 +131,28 @@ function handleSave () {
   })
 }
 
+const fileList = ref([])
+
+const beforeFileUpload = (uploadFile) => {
+  if (!uploadFile.name.endsWith(fileType.value)) {
+    ElMessage.error('文件格式错误')
+    return false
+  }
+  return true
+}
+
+const uploadFile = (fileObject) => {
+  const formData = new FormData()
+  formData.append('file', fileObject.file)
+  formData.append('type', fileType.label)
+  UploadFileApi(formData).then(res => {
+    if (res.code == '200' && res.success) {
+      ElMessage({ type: 'success', message: '上传成功' })
+      fileList.value.push(res.data)
+    }
+  })
+}
+
 onBeforeMount(() => {
   // eslint-disable-next-line no-debugger
   if (route.params.type !== 'add') {
@@ -133,9 +171,4 @@ onBeforeMount(() => {
 
 </script>
 
-<style scoped lang="scss">
-#res-cata-detail {
-
-}
-
-</style>
+<style scoped lang="scss"></style>

+ 108 - 94
src/views/taskManage/dialog/ConvergeAdd.vue

@@ -1,17 +1,17 @@
 <template>
   <el-dialog title="数据汇聚" v-model="innerVisible" :modal-append-to-body='false' class="dialog-default" width="30%">
-    <el-form :model="convergeItemForm" label-width="100px">
+    <el-form :model="convergeItemForm" label-width="100px" label-position="right">
       <el-row>
-        <el-form-item label="汇聚模式">
+        <el-form-item label="汇聚模式" required ="true">
           <el-select v-model="convergeItemForm.type" placeholder="汇聚模式" @change="aggregateModelChange">
-            <el-option v-for="item in dataTypeArr" :key="item.value" :label="item.label" :value="item.value"/>
+            <el-option v-for="item in dataTypeArr" :key="item.value" :label="item.label" :value="item.value" />
           </el-select>
         </el-form-item>
       </el-row>
       <el-row>
-        <el-form-item label="前置源">
+        <el-form-item label="前置源" required ="true">
           <el-select v-model="convergeItemForm.sourceId" placeholder="前置源" @change="sourceIdChange">
-            <el-option v-for="item in sourceArr" :key="item.value" :label="item.label" :value="item.value"/>
+            <el-option v-for="item in sourceArr" :key="item.value" :label="item.label" :value="item.value" />
           </el-select>
         </el-form-item>
       </el-row>
@@ -19,25 +19,39 @@
         <el-row>
           <el-form-item label="前置库">
             <el-select v-model="convergeItemForm.database" placeholder="前置库" @change="databaseChange">
-              <el-option v-for="item in sourceData" :key="item.SCHEMANAME" :label="item.SCHEMANAME" :value="item.SCHEMANAME"/>
+              <el-option v-for="item in sourceData" :key="item.SCHEMANAME" :label="item.SCHEMANAME"
+                :value="item.SCHEMANAME" />
             </el-select>
           </el-form-item>
         </el-row>
         <el-row>
           <el-form-item label="前置表">
             <el-select v-model="convergeItemForm.table" placeholder="前置表">
-              <el-option v-for="item in (((sourceData.find(item=>item.SCHEMANAME===convergeItemForm.database))||{}).CHILD)||[]" :key="item.TABLENAME" :label="item.TABLENAME" :value="item.TABLENAME"/>
+              <el-option
+                v-for="item in (((sourceData.find(item => item.SCHEMANAME === convergeItemForm.database)) || {}).CHILD) || []"
+                :key="item.TABLENAME" :label="item.TABLENAME" :value="item.TABLENAME" />
             </el-select>
           </el-form-item>
         </el-row>
       </template>
-<!--      <template v-if="convergeItemForm.type === '3'">-->
-<!--        <el-row>-->
-<!--          <el-form-item label="文件名">-->
-<!--            <el-input class="width-80" v-model="convergeItemForm.fileName" label="文件名"/>-->
-<!--          </el-form-item>-->
-<!--        </el-row>-->
-<!--      </template>-->
+      <template v-if="convergeItemForm.type === '3'">
+        <el-row>
+          <el-form-item label="文件路径" required ="true" style="width: 59%">
+            <el-input v-model="convergeItemForm.fileName" label="文件名" />
+          </el-form-item>
+        </el-row>
+        <el-form-item label="读取规则" required ="true">
+          <el-radio-group v-model="convergeItemForm.fileType">
+            <el-radio :label="1">最新文件</el-radio>
+            <el-radio :label="2">最新文件+文件名关键词</el-radio>
+          </el-radio-group>
+        </el-form-item>
+        <el-row>
+          <el-form-item label="关键词" style="width: 59%">
+            <el-input v-model="convergeItemForm.fileKeyword" label="关键词" />
+          </el-form-item>
+        </el-row>
+      </template>
     </el-form>
     <template #footer>
       <el-button class="btn-default" @click="innerVisible = false">取 消</el-button>
@@ -47,96 +61,96 @@
 </template>
 
 <script>
-  import vModelDialog from "../../../utils/vModelDialog";
-  import { DataTypeArr } from "../../../utils/data/select-data";
-  import { GetSourceArr, GetDatabase } from "../../../services/baseCata";
+import { GetDatabase, GetSourceArr } from "../../../services/baseCata";
+import { DataTypeArr } from "../../../utils/data/select-data";
+import vModelDialog from "../../../utils/vModelDialog";
 
-  export default {
-    name: "ConvergeAdd",
-    mixins: [vModelDialog],
-    props: ['convergeItemForm'],
-    computed:{
-      dataTypeArr() {
-        return DataTypeArr
-      }
+export default {
+  name: "ConvergeAdd",
+  mixins: [vModelDialog],
+  props: ['convergeItemForm'],
+  computed: {
+    dataTypeArr() {
+      return DataTypeArr
+    }
+  },
+  data() {
+    return {
+      sourceArr: [],
+      databaseArr: [],
+      fileArr: [],
+      webservicesArr: [],
+      sourceData: []
+    }
+  },
+  mounted() {
+    this.getSourceArr()
+  },
+  methods: {
+    getSourceArr() {
+      this.databaseArr = []
+      this.fileArr = []
+      this.webservicesArr = []
+      GetSourceArr().then(res => {
+        if (res.code === 200) {
+          res.data.databases.forEach(item => {
+            this.databaseArr.push({ value: item.sourceId, label: item.sourceName })
+          })
+          res.data.files.forEach(item => {
+            this.fileArr.push({ value: item.sourceId, label: item.sourceName })
+          })
+          res.data.webservices.forEach(item => {
+            this.webservicesArr.push({ value: item.sourceId, label: item.sourceName })
+          })
+        }
+      })
     },
-    data(){
-      return {
-        sourceArr: [],
-        databaseArr: [],
-        fileArr: [],
-        webservicesArr: [],
-        sourceData:[]
-      }
+    saveConvergeData() {
+      this.innerVisible = false
+      this.convergeItemForm.sourceName = (this.sourceArr.find(item => item.value === this.convergeItemForm.sourceId) || {}).label
+      this.$emit("saveConvergeData", this.convergeItemForm)
     },
-    mounted() {
-      this.getSourceArr()
+    aggregateModelChange(value) {
+      if (value === '1') {
+        this.sourceArr = this.databaseArr
+        delete this.convergeItemForm.fileName
+      } else if (value === '2') {
+        this.sourceArr = this.webservicesArr
+        delete this.convergeItemForm.database
+        delete this.convergeItemForm.table
+        delete this.convergeItemForm.fileName
+      } else if (value === '3') {
+        this.sourceArr = this.fileArr
+        delete this.convergeItemForm.database
+        delete this.convergeItemForm.table
+      }
+      this.convergeItemForm.sourceId = ''
+      this.sourceData = []
     },
-    methods:{
-      getSourceArr() {
-        this.databaseArr = []
-        this.fileArr = []
-        this.webservicesArr = []
-        GetSourceArr().then(res => {
+    sourceIdChange(value) {
+      delete this.convergeItemForm.database
+      delete this.convergeItemForm.table
+      if (this.convergeItemForm.type !== "1") {
+        this.sourceData = []
+        return
+      }
+      if (value !== undefined || value !== '') {
+        GetDatabase(value).then((res) => {
           if (res.code === 200) {
-            res.data.databases.forEach(item => {
-              this.databaseArr.push({value: item.sourceId, label: item.sourceName})
-            })
-            res.data.files.forEach(item => {
-              this.fileArr.push({value: item.sourceId, label: item.sourceName})
-            })
-            res.data.webservices.forEach(item => {
-              this.webservicesArr.push({value: item.sourceId, label: item.sourceName})
-            })
+            this.sourceData = res.data || []
+          } else {
+            this.sourceData = []
           }
         })
-      },
-      saveConvergeData(){
-        this.innerVisible = false
-        this.convergeItemForm.sourceName = (this.sourceArr.find(item => item.value === this.convergeItemForm.sourceId) || {}).label
-        this.$emit("saveConvergeData", this.convergeItemForm)
-      },
-      aggregateModelChange(value) {
-        if (value === '1') {
-          this.sourceArr = this.databaseArr
-          delete this.convergeItemForm.fileName
-        } else if (value === '2') {
-          this.sourceArr = this.webservicesArr
-          delete this.convergeItemForm.database
-          delete this.convergeItemForm.table
-          delete this.convergeItemForm.fileName
-        } else if (value === '3') {
-          this.sourceArr = this.fileArr
-          delete this.convergeItemForm.database
-          delete this.convergeItemForm.table
-        }
-        this.convergeItemForm.sourceId = ''
-        this.sourceData = []
-      },
-      sourceIdChange(value){
-        delete this.convergeItemForm.database
-        delete this.convergeItemForm.table
-        if(this.convergeItemForm.type!=="1"){
-          this.sourceData = []
-          return
-        }
-        if (value!==undefined||value!==''){
-          GetDatabase(value).then((res)=>{
-            if (res.code===200){
-              this.sourceData = res.data || []
-            }else {
-              this.sourceData = []
-            }
-          })
-        }
-      },
-      databaseChange(){
-        delete this.convergeItemForm.table
       }
+    },
+    databaseChange() {
+      delete this.convergeItemForm.table
     }
   }
+}
 </script>
 
-<style scoped>
+<style lang="scss" scoped>
 
-</style>
+</style>