caiaa1 hai 1 ano
pai
achega
2f02f14edc

+ 1 - 1
mock/dict.js

@@ -1,7 +1,7 @@
 module.exports = [
   // user login
   {
-    url: '/sysDict/type/system_type',
+    url: '/sysDict/type/app',
     type: 'get',
     response: config => {
       return {

+ 1 - 0
src/api/file.js

@@ -4,6 +4,7 @@ export function uploadFile(type, data) {
   return request({
     url: `fileMge/upload/${type}`,
     method: 'post',
+    headers: { 'Content-Type': 'multipart/form-data' },
     data: data
   })
 }

+ 17 - 5
src/components/Upload/UploadFile.vue

@@ -3,9 +3,12 @@
     <el-upload
       :ref="refName"
       :name="aliasName"
+      :show-file-list="showFileList"
+      list-type="picture"
       action=""
       :http-request="httpRequest"
-      :show-file-list="false"
+      :on-success="onSuccess"
+      :on-error="onError"
     >
       <el-button icon="el-icon-upload2">{{ btnText }}</el-button>
     </el-upload>
@@ -25,6 +28,18 @@ export default {
     fileType: {
       type: String,
       default: 'default'
+    },
+    showFileList: {
+      type: Boolean,
+      default: false
+    },
+    onSuccess: {
+      type: Function,
+      default() {}
+    },
+    onError: {
+      type: Function,
+      default() {}
     }
   },
   data() {
@@ -46,15 +61,12 @@ export default {
       this.aliasName += _uploadId_
       _uploadId_++
     },
-    onChange(file, fileList) {
-      debugger
-    },
     httpRequest(options) {
       const formData = new FormData()
       formData.append('file', options.file)
       uploadFile(this.fileType, formData).then(res => {
         if (options.onSuccess && res.data) {
-          options.onSuccess(res.data.url)
+          options.onSuccess(res.data)
         } else {
           options.onError(new Error('Upload Failed: ' + res.data))
         }

+ 45 - 25
src/views/system/components/SystemDetail.vue

@@ -69,14 +69,15 @@
         <el-row>
           <el-col :span="12">
             <el-form-item label="label" required>
-              <upload-file :file-type="system" :on-success="uploadSuccess" />
+              <upload-file file-type="1" show-file-list :on-success="uploadSuccess" :on-error="uploadError" />
+              <el-input v-model="formData.icon" />
             </el-form-item>
           </el-col>
         </el-row>
       </el-form>
       <div slot="footer">
         <el-button @click="close">Cancel</el-button>
-        <el-button v-if="routeType !== 'VIEW'" type="primary" @click="saveSystem">Confirm</el-button>
+        <el-button v-if="routeType !== 'VIEW'" type="primary" @click="saveSystem('editForm')">Confirm</el-button>
       </div>
     </el-dialog>
   </div>
@@ -100,12 +101,22 @@ export default {
   },
   data() {
     return {
-      dictSysType: 'system_type',
       // dialog
       visible: false,
       routeType: '',
       title: 'Edit',
-      formData: {},
+      formData: {
+        id: null,
+        appType: null,
+        systemName: '',
+        systemNumber: '',
+        shortName: '',
+        deptName: '',
+        url: '',
+        activeFlag: '',
+        policeCategory: '',
+        icon: ''
+      },
       // select:
       orgData: [],
       policeCategoryData: [],
@@ -122,10 +133,15 @@ export default {
   methods: {
     // Upload
     uploadSuccess(data) {
-      console.log(data)
+      this.formData['icon'] = data.url
     },
     uploadError(error) {
-      console.log(error)
+      this.$message.error({
+        type: 'error',
+        duration: 0,
+        showClose: true,
+        message: error.message
+      })
     },
     /**
      * 加载dialog
@@ -133,30 +149,34 @@ export default {
     open(type, data) {
       this.routeType = type
       this.title = type === 'ADD' ? 'Add' : type === 'VIEW' ? 'View' : 'Edit'
-      this.formData = isObject(data) ? data : {}
+      this.formData = isObject(data) ? data : { 'appType': '', 'systemName': '', 'icon': '' }
       this.visible = true
     },
     close() {
       this.visible = false
     },
-    saveSystem() {
-      this.loading = true
-      pushSaveSystem().then(res => {
-        this.loading = false
-        this.visible = false
-        this.$message({
-          type: 'success',
-          message: 'Save Successfully!'
-        })
-      }).catch(error => {
-        console.log(error)
-        this.loading = false
-        this.$message.error({
-          type: 'error',
-          duration: 0,
-          showClose: true,
-          message: error.message
-        })
+    saveSystem(formName) {
+      this.$refs[formName].validate((valid) => {
+        if (valid) {
+          this.loading = true
+          pushSaveSystem(this.formData).then(res => {
+            this.loading = false
+            this.visible = false
+            this.$message({
+              type: 'success',
+              message: 'Save Successfully!'
+            })
+          }).catch(error => {
+            console.log(error)
+            this.loading = false
+            this.$message.error({
+              type: 'error',
+              duration: 0,
+              showClose: true,
+              message: error.message
+            })
+          })
+        }
       })
     }
   }

+ 2 - 2
src/views/system/index.vue

@@ -92,7 +92,7 @@ export default {
   data() {
     return {
       // type
-      dictType: 'system_type',
+      dictType: 'app_type',
       typeData: [],
       // table
       current: 1,
@@ -140,7 +140,7 @@ export default {
     getTablelist() {
       this.loading = true
       const params = {
-        current: this.current,
+        page: this.current,
         size: this.size,
         params: {
           delFlag: 0,