浏览代码

文件管理接口调试

zhangfu 3 年之前
父节点
当前提交
df6b4a0ebb

+ 3 - 2
public/js/config.js

@@ -7,7 +7,8 @@ window.global_config = {
   // BASE_URL: 'http://172.16.0.22:10143'
   // BASE_URL: 'http://221.224.53.27:10144',
   //  BASE_URL:'http://172.16.0.14:10143',
-  BASE_URL: 'http://172.16.0.135:10180' //沪上阿姨
+  // BASE_URL: 'http://172.16.0.135:8083' //沪上阿姨
+  BASE_URL: 'http://172.16.100.40:8083'
   //  BASE_URL:'http://172.16.0.107:10143',
   // BASE_URL: 'http://172.16.0.36:10143' //吴国建
   // BASE_URL:'http://172.16.0.114:10143' //胡志豪
@@ -15,4 +16,4 @@ window.global_config = {
   // BASE_URL:'http://221.224.53.27:20008'
   // BASE_URL: 'http://172.16.0.245:10143'
   // BASE_URL: 'http://101.200.220.128:8081'
-}
+}

+ 32 - 10
src/assets/styles/element.less

@@ -298,18 +298,22 @@ input[maxlength='32']:not([disabled]) {
     font-weight: bold;
   }
 }
+
 .el-menu-item,
 .el-menu-item [class^=el-icon-] {
   font-size: 20px;
   color: #A5A5A5 !important;
   font-weight: 400;
 }
-.el-menu-item{
+
+.el-menu-item {
   padding-left: 42px !important;
 }
-.el-menu-item.is-active{
+
+.el-menu-item.is-active {
   padding-left: 0 !important;
 }
+
 .el-menu-item.is-active,
 .el-menu-item.is-active [class^=el-icon-] {
   color: #F4453E !important;
@@ -321,19 +325,37 @@ input[maxlength='32']:not([disabled]) {
   border-bottom-right-radius: 4px;
   margin-right: 38px;
 }
-.el-radio__input.is-checked .el-radio__inner{
+
+.el-radio__input.is-checked .el-radio__inner {
   background: #F4453E;
   border-color: #F4453E;
 }
-.el-radio__inner:hover{
+
+.el-radio__inner:hover,
+.el-select .el-input.is-focus .el-input__inner,
+.el-input__inner:focus {
   border-color: #F4453E;
 }
-.el-input__inner:focus{
-  border-color: #F4453E;
+
+.el-radio__input.is-checked+.el-radio__label {
+  color: #F4453E;
 }
-.el-radio__input.is-checked+.el-radio__label{
+
+.el-loading-spinner .path {
+  stroke: #F4453E;
+}
+.el-upload-list__item.is-success .el-upload-list__item-name:focus, .el-upload-list__item.is-success .el-upload-list__item-name:hover{
   color: #F4453E;
+  i{
+    color: #F4453E;
+    cursor: pointer;
+    transition: all .5s cubic-bezier(.55,0,.1,1)
+  }
 }
-.el-loading-spinner .path{
-  stroke:#F4453E;
-}
+// .el-upload-list__item:hover{
+//   background-color:#F4453E ;
+//   .el-upload-list__item-name,.el-upload-list__item-name i{
+//     color: #fff;
+//   }
+  
+// }

+ 0 - 1
src/components/FileUpload.vue

@@ -75,7 +75,6 @@ export default {
     }
   },
   created() {
-    console.log(this.typeList)
   },
   methods: {
     handleAvatarSuccess(res) {

+ 0 - 6
src/layout/components/Navbar.vue

@@ -12,9 +12,6 @@
           <i class="el-icon-arrow-down el-icon--right"></i>
         </span>
         <el-dropdown-menu slot="dropdown" trigger="click" style="width: 160px">
-          <el-dropdown-item @click.native="changePassword">
-            修改密码
-          </el-dropdown-item>
           <el-dropdown-item @click.native="logout">退出</el-dropdown-item>
         </el-dropdown-menu>
       </el-dropdown>
@@ -51,9 +48,6 @@ export default {
         this.$router.push('/')
       })
     },
-    changePassword() {
-      this.cgpwdVisible = true
-    }
   }
 }
 </script>

+ 0 - 1
src/layout/components/Sidebar/menu.vue

@@ -29,7 +29,6 @@ export default {
     }
   },
   mounted () {
-    console.log(this.$router)
     this.setActiveMenu(this.routesData)
   },
   methods: {

+ 10 - 0
src/pages/classification/edit.vue

@@ -5,6 +5,7 @@
     width="33%"
     :before-close="handleClose"
     append-to-body
+    v-loading.fullscreen.lock="fullscreenLoading"
   >
     <el-form label-width="100px" :model="form" ref="form" :rules="rules">
       <el-form-item label="分类名称:" prop="name">
@@ -70,6 +71,7 @@ export default {
       }
     }
     return {
+      fullscreenLoading:false,
       dialogVisible: false,
       classString: {},
       form: {
@@ -92,6 +94,7 @@ export default {
         status: 0,
         role: [{ value: '' }]
       }
+      this.$refs['form'].resetFields()
     },
     openClose(val) {
       if (val) {
@@ -139,6 +142,7 @@ export default {
     submit(formName) {
       this.$refs[formName].validate(valid => {
         if (valid) {
+          this.fullscreenLoading = true
           let role = []
           this.form.role.forEach(item => {
             role.push(item.value)
@@ -161,7 +165,10 @@ export default {
         if (data.code == 0) {
           this.handleClose()
           this.$message.success(data.message)
+          this.fullscreenLoading = false
         }
+      }).catch(()=>{
+        this.fullscreenLoading = false
       })
     },
     /**
@@ -173,7 +180,10 @@ export default {
         if (data.code == 0) {
           this.handleClose()
           this.$message.success(data.message)
+          this.fullscreenLoading = false
         }
+      }).catch(()=>{
+        this.fullscreenLoading = false
       })
     }
   }

+ 16 - 2
src/pages/classification/index.vue

@@ -185,6 +185,7 @@ export default {
      * @method 列表数据
      * **/
     tableDataList() {
+      this.tableData = []
       this.fullscreenLoading = true
       let code = {
         name: this.form.name,
@@ -211,8 +212,21 @@ export default {
           this.fullscreenLoading = false
         })
     },
-    handleSizeChange() {},
-    handleCurrentChange() {},
+    /**
+     * @method 分页条数
+     * **/ 
+    handleSizeChange(val) {
+      this.form.pageNum = 1
+      this.form.pageSize = val
+      this.tableDataList()
+    },
+    /**
+     * @method 分页
+     * **/ 
+    handleCurrentChange(val) {
+      this.form.pageNum = val
+      this.tableDataList()
+    },
     // 编辑
     edit(val) {
       let code = {

+ 32 - 5
src/pages/fileManagement/detail.vue

@@ -21,7 +21,7 @@
         >
         </el-table-column>
         <el-table-column
-          prop="name"
+          prop="docUrl"
           align="center"
           show-overflow-tooltip
           label="链接地址"
@@ -88,10 +88,37 @@ export default {
      * @method 下载
      * **/
     download(val) {
-      let url = `/api/file/exportExcel/{type}`
-      let params = this.form
-      let fileName = '产品信息库'
-      this.$pubFun.exportOperation(url, params, 'get', fileName)
+      fetch(val.docUrl, {
+        method: 'get',
+        responseType: 'arraybuffer'
+      })
+        .then(function (res) {
+          if (res.status !== 200) {
+            return res.json()
+          }
+          return res.arrayBuffer()
+        })
+        .then(blobRes => {
+          // 生成 Blob 对象,设置 type 等信息
+          const e = new Blob([blobRes], {
+            type: 'application/octet-stream',
+            'Content-Disposition': 'attachment'
+          })
+          // 将 Blob 对象转为 url
+          let formName = val.name + '.pdf'
+          const link = window.URL.createObjectURL(e)
+          this.handleFileDownload(link, formName)
+        })
+        .catch(err => {
+          console.error(err)
+        })
+    },
+    handleFileDownload(url, filename) {
+      // 创建 a 标签
+      let a = document.createElement('a')
+      a.href = url
+      a.download = filename
+      a.click()
     }
   }
 }

+ 23 - 5
src/pages/fileManagement/edit.vue

@@ -4,6 +4,7 @@
     :visible.sync="dialogVisible"
     width="33%"
     :before-close="handleClose"
+     v-loading.fullscreen.lock="fullscreenLoading"
   >
     <el-form :model="form" ref="form" :rules="rules" label-width="100px">
       <el-form-item label="分类名称:" prop="typeId">
@@ -14,8 +15,8 @@
           @change="classifyChange"
         >
           <el-option
-            v-for="item in classifyList"
-            :key="item.value"
+            v-for="(item,index) in classifyList"
+            :key="index"
             :label="item.name"
             :value="item.typeId"
           >
@@ -71,6 +72,7 @@ import * as api from '@/api/api'
 export default {
   data() {
     return {
+      fullscreenLoading:false,
       dialogVisible: false,
       form: {
         docUrl: '',
@@ -116,6 +118,7 @@ export default {
       if (val) {
         this.refList = val
         if (val.id) {
+          this.visbleChange(true)
           this.details()
         }
       }
@@ -128,6 +131,7 @@ export default {
       api.GET('/doc/getDetail', { id: this.refList.id }).then(data => {
         if (data.code == 0) {
           this.form = data.data
+          this.fileList = [{name:this.form.name,url:this.form.docUrl}]
         }
       })
     },
@@ -162,10 +166,14 @@ export default {
       }
       api.IMPORT('/api/file/local/upload', files).then(data => {
         if (data.code == 0) {
+          data.data.name = data.data.fileName
+          this.fileList = [data.data]
           this.form.docUrl = data.data.url
           this.form.fileSize = data.data.size
           this.$message.success('上传成功')
         }
+      }).catch(()=>{
+        this.fileList = []
       })
     },
     /**
@@ -179,7 +187,9 @@ export default {
     /**
      * @method 上传成功
      * **/
-    handleSuccess() {},
+    handleSuccess(file,fileList) {
+      console.log(file,fileList)
+    },
     /**
      * @method 文件删除
      * **/
@@ -205,6 +215,7 @@ export default {
     addList(formName) {
       this.$refs[formName].validate(valid => {
         if (valid) {
+          this.fullscreenLoading = true
           let code = {
             docUrl: this.form.docUrl,
             linkUrl: this.form.linkUrl,
@@ -225,18 +236,25 @@ export default {
         if (data.code == 0) {
           this.$message.success(data.message)
           this.handleClose()
+          this.fullscreenLoading = false
         }
+      }).catch(()=>{
+        this.fullscreenLoading = false
       })
     },
     /**
      * @method 编辑文件
      * **/
-    editfile() {
-      api.PUT('/doc/updateDoc').then(data => {
+    editfile(val) {
+      val.id = this.form.id
+      api.PUT('/doc/updateDoc',val).then(data => {
         if (data.code == 0) {
           this.$message.success(data.message)
           this.handleClose()
+          this.fullscreenLoading = false
         }
+      }).catch(()=>{
+        this.fullscreenLoading = false
       })
     }
   }

+ 44 - 8
src/pages/fileManagement/index.vue

@@ -12,17 +12,26 @@
         :addList="true"
       >
         <el-form-item class="header_top_form" label="分类名称:">
-          <el-input
+          <el-select
             clearable
-            v-model.trim="form.name"
-            placeholder="请输入"
             size="small"
-          ></el-input>
+            placeholder="请选择"
+            v-model="form.typeId"
+            @visible-change="visbleChange"
+          >
+            <el-option
+              v-for="(item, index) in classifyList"
+              :key="index"
+              :label="item.name"
+              :value="item.typeId"
+            >
+            </el-option>
+          </el-select>
         </el-form-item>
         <el-form-item class="header_top_form" label="文件名称:">
           <el-input
             clearable
-            v-model.trim="form.fileName"
+            v-model.trim="form.name"
             placeholder="请输入"
             size="small"
           ></el-input>
@@ -190,7 +199,8 @@ export default {
         start: '',
         status: '',
         typeId: ''
-      }
+      },
+      classifyList: []
     }
   },
   mounted() {
@@ -198,6 +208,18 @@ export default {
   },
   methods: {
     /**
+     * @method 分类下拉列表
+     * **/
+    visbleChange(val) {
+      if (val) {
+        api.POST('/doc/type/dropList').then(data => {
+          if (data.code == 0) {
+            this.classifyList = data.data
+          }
+        })
+      }
+    },
+    /**
      * @method 搜索
      * **/
     search() {
@@ -208,6 +230,7 @@ export default {
      * @method 列表数据
      * **/
     listDataInit() {
+      this.tableData = []
       this.fullscreenLoading = true
       let code = {
         name: this.form.name,
@@ -235,8 +258,21 @@ export default {
           this.fullscreenLoading = false
         })
     },
-    handleSizeChange() {},
-    handleCurrentChange() {},
+    /**
+     * @method 条数分页
+     * **/
+    handleSizeChange(val) {
+      this.form.pageNum = 1
+      this.form.pageSize = val
+      this.listDataInit()
+    },
+    /**
+     * @method 分页
+     * **/
+    handleCurrentChange(val) {
+      this.form.pageNum = val
+      this.listDataInit()
+    },
     /**
      * @method 新增
      * **/

+ 19 - 7
src/pages/userManagement/detail.vue

@@ -4,10 +4,13 @@
     :visible.sync="dialogVisible"
     width="33%"
     :before-close="handleClose"
+    v-loading.fullscreen.lock="fullscreenLoading"
   >
     <el-form :model="number" ref="number" :rules="rules" label-width="100px">
       <el-form-item label prop="password">
-        <template slot="label" class="status"><span>密&#8195;&emsp;码</span>:</template>
+        <template slot="label" class="status"
+          ><span>密&#8195;&emsp;码</span>:</template
+        >
         <el-input
           placeholder="请输入"
           v-model.trim="number.password"
@@ -40,6 +43,7 @@ export default {
       }
     }
     return {
+      fullscreenLoading: false,
       dialogVisible: false,
       number: {
         password: ''
@@ -55,6 +59,7 @@ export default {
       this.number.password = ''
       this.dialogVisible = false
       this.$parent.search()
+      this.$refs['number'].resetFields()
     },
     openClose(val) {
       this.dialogVisible = true
@@ -66,16 +71,23 @@ export default {
     submit(formName) {
       this.$refs[formName].validate(valid => {
         if (valid) {
+          this.fullscreenLoading = true
           let code = {
             id: this.id,
             password: this.number.password
           }
-          api.PUT('/user/resetPassword', code).then(res => {
-            if (res.code == 0) {
-              this.handleClose()
-              this.$message.success(res.data)
-            }
-          })
+          api
+            .PUT('/user/resetPassword', code)
+            .then(res => {
+              if (res.code == 0) {
+                this.handleClose()
+                this.$message.success(res.data)
+                this.fullscreenLoading = false
+              }
+            })
+            .catch(() => {
+              this.fullscreenLoading = false
+            })
         }
       })
     }

+ 10 - 0
src/pages/userManagement/edit.vue

@@ -4,6 +4,7 @@
     :visible.sync="dialogVisible"
     width="33%"
     :before-close="handleClose"
+     v-loading.fullscreen.lock="fullscreenLoading"
   >
     <el-form ref="form" :model="form" label-width="100px" :rules="rules">
       <el-form-item prop="account">
@@ -58,6 +59,7 @@ export default {
       }
     }
     return {
+      fullscreenLoading:false,
       dialogVisible: false,
       radio: '',
       title: '',
@@ -87,6 +89,7 @@ export default {
         status: '',
         userId: ''
       }
+      this.$refs['form'].resetFields()
     },
     openClose(val) {
       this.title = val.title
@@ -105,6 +108,7 @@ export default {
     addList(formName) {
       this.$refs[formName].validate(valid => {
         if (valid) {
+          this.fullscreenLoading = true
           let code = {
             account: this.form.account,
             name: this.form.name,
@@ -138,7 +142,10 @@ export default {
         if (data.code == 0) {
           this.handleClose()
           this.$message.success(data.message)
+          this.fullscreenLoading = false
         }
+      }).catch(()=>{
+        this.fullscreenLoading = false
       })
     },
     /**
@@ -150,7 +157,10 @@ export default {
         if (data.code == 0) {
           this.handleClose()
           this.$message.success(data.message)
+          this.fullscreenLoading = false
         }
+      }).catch(()=>{
+        this.fullscreenLoading = false
       })
     }
   }

+ 1 - 0
src/pages/userManagement/index.vue

@@ -169,6 +169,7 @@ export default {
      * @method 用户数据列表
      * **/
     listDataInit() {
+      this.tableData = []
       this.fullscreenLoading = true
       let code = {
         account: this.form.account,

+ 4 - 4
src/utils/pubFun.js

@@ -42,20 +42,20 @@ let pubFun = {
                 if (typeof window.navigator.msSaveBlob !== 'undefined') {
                   window.navigator.msSaveBlob(
                     new Blob([response], {
-                      type: 'application/vnd.ms-excel'
+                      type: 'application/pdf'
                     }),
-                    fileName + '.xlsx'
+                    fileName + '.pdf'
                   )
                 } else {
                   let url = window.URL.createObjectURL(
                     new Blob([response], {
-                      type: 'application/vnd.ms-excel'
+                      type: 'application/pdf'
                     })
                   )
                   let link = document.createElement('a')
                   link.style.display = 'none'
                   link.href = url
-                  link.setAttribute('download', fileName + '.xlsx')
+                  link.setAttribute('download', fileName + '.pdf')
                   document.body.appendChild(link)
                   link.click()
                   document.body.removeChild(link)