Pārlūkot izejas kodu

接口调试完成

chenying 4 gadi atpakaļ
vecāks
revīzija
1f6bcf2c63

+ 3 - 1
src/utils/httpRequest.js

@@ -17,7 +17,9 @@ const http = axios.create({
  * 请求拦截
  */
 http.interceptors.request.use(config => {
-  config.headers['Authorization'] = 'bearer ' + Vue.cookie.get('token') // 请求头带上token
+  if (Vue.cookie.get('token')) {
+    config.headers['Authorization'] = 'bearer ' + Vue.cookie.get('token') // 请求头带上token
+  }
   return config
 }, error => {
   return Promise.reject(error)

+ 1 - 1
src/views/modules/org/org-add-or-update.vue

@@ -62,7 +62,7 @@
             { required: true, message: '机构名称不能为空', trigger: 'blur' }
           ],
           parentName: [
-            { required: true, message: '上级机构不能为空', trigger: 'blur' }
+            { required: true, message: '上级机构不能为空', trigger: 'change' }
           ]
         },
         menuListTreeProps: {

+ 8 - 7
src/views/modules/sys/log.vue

@@ -104,17 +104,18 @@
       getDataList () {
         this.dataListLoading = true
         this.$http({
-          url: this.$http.adornUrl('/sys/log/list'),
+          url: this.$http.adornUrl('/log-service/log/list'),
           method: 'get',
           params: this.$http.adornParams({
-            'page': this.pageIndex,
-            'limit': this.pageSize,
-            'key': this.dataForm.key
+            'current': this.pageIndex,
+            'size': this.pageSize,
+            'username': this.dataForm.key,
+            'operation': this.dataForm.key
           })
         }).then(({data}) => {
-          if (data && data.code === 0) {
-            this.dataList = data.page.list
-            this.totalPage = data.page.totalCount
+          if (data && data.code === '200') {
+            this.dataList = data.data.records
+            this.totalPage = Number(data.data.pages)
           } else {
             this.dataList = []
             this.totalPage = 0

+ 24 - 16
src/views/modules/sys/menu-add-or-update.vue

@@ -78,7 +78,6 @@
 </template>
 
 <script>
-  import { treeDataTranslate } from '@/utils'
   import Icon from '@/icons'
   export default {
     data () {
@@ -118,7 +117,7 @@
         menuList: [],
         menuListTreeProps: {
           label: 'name',
-          children: 'children'
+          children: 'list'
         }
       }
     },
@@ -129,11 +128,15 @@
       init (id) {
         this.dataForm.id = id || 0
         this.$http({
-          url: this.$http.adornUrl('/sys/menu/select'),
+          url: this.$http.adornUrl('/user-service/menu/tree'),
           method: 'get',
           params: this.$http.adornParams()
         }).then(({data}) => {
-          this.menuList = treeDataTranslate(data.menuList, 'menuId')
+          if (data.code === '200') {
+            this.menuList = data.data
+          } else {
+            this.$message.error(data.msg)
+          }
         }).then(() => {
           this.visible = true
           this.$nextTick(() => {
@@ -146,19 +149,23 @@
           } else {
             // 修改
             this.$http({
-              url: this.$http.adornUrl(`/sys/menu/info/${this.dataForm.id}`),
+              url: this.$http.adornUrl(`/user-service/menu/info/${this.dataForm.id}`),
               method: 'get',
               params: this.$http.adornParams()
             }).then(({data}) => {
-              this.dataForm.id = data.menu.menuId
-              this.dataForm.type = data.menu.type
-              this.dataForm.name = data.menu.name
-              this.dataForm.parentId = data.menu.parentId
-              this.dataForm.url = data.menu.url
-              this.dataForm.perms = data.menu.perms
-              this.dataForm.orderNum = data.menu.orderNum
-              this.dataForm.icon = data.menu.icon
-              this.menuListTreeSetCurrentNode()
+              if (data.code === '200') {
+                this.dataForm.id = data.data.menuId
+                this.dataForm.type = Number(data.data.type)
+                this.dataForm.name = data.data.name
+                this.dataForm.parentId = data.data.parentId
+                this.dataForm.url = data.data.url
+                this.dataForm.perms = data.data.perms
+                this.dataForm.orderNum = data.data.orderNum
+                this.dataForm.icon = data.data.icon
+                this.menuListTreeSetCurrentNode()
+              } else {
+                this.$message.error(data.msg)
+              }
             })
           }
         })
@@ -182,10 +189,11 @@
         this.$refs['dataForm'].validate((valid) => {
           if (valid) {
             this.$http({
-              url: this.$http.adornUrl(`/sys/menu/${!this.dataForm.id ? 'save' : 'update'}`),
+              url: this.$http.adornUrl(`/user-service/menu/${!this.dataForm.id ? 'save' : 'update'}`),
               method: 'post',
               data: this.$http.adornData({
                 'menuId': this.dataForm.id || undefined,
+                'appCode': 'ERP-SYSTEM',
                 'type': this.dataForm.type,
                 'name': this.dataForm.name,
                 'parentId': this.dataForm.parentId,
@@ -195,7 +203,7 @@
                 'icon': this.dataForm.icon
               })
             }).then(({data}) => {
-              if (data && data.code === 0) {
+              if (data && data.code === '200') {
                 this.$message({
                   message: '操作成功',
                   type: 'success',

+ 8 - 6
src/views/modules/sys/menu.vue

@@ -84,7 +84,6 @@
 
 <script>
   import AddOrUpdate from './menu-add-or-update'
-  import { treeDataTranslate } from '@/utils'
   export default {
     data () {
       return {
@@ -105,11 +104,14 @@
       getDataList () {
         this.dataListLoading = true
         this.$http({
-          url: this.$http.adornUrl('/sys/menu/list'),
+          url: this.$http.adornUrl('/user-service/menu/tree'),
           method: 'get',
           params: this.$http.adornParams()
         }).then(({data}) => {
-          this.dataList = treeDataTranslate(data, 'menuId')
+          if (data.code === '200') {
+            this.dataList = JSON.parse(JSON.stringify(data.data).replace(/"list":/g, '"children":').replace(/"children":null/g, '"children":[]'))
+            console.log(this.dataList)
+          }
           this.dataListLoading = false
         })
       },
@@ -128,11 +130,11 @@
           type: 'warning'
         }).then(() => {
           this.$http({
-            url: this.$http.adornUrl(`/sys/menu/delete/${id}`),
-            method: 'post',
+            url: this.$http.adornUrl(`/user-service/menu/delete?menuId=${id}`),
+            method: 'DELETE',
             data: this.$http.adornData()
           }).then(({data}) => {
-            if (data && data.code === 0) {
+            if (data && data.code === '200') {
               this.$message({
                 message: '操作成功',
                 type: 'success',

+ 68 - 14
src/views/modules/sys/role-add-or-update.vue

@@ -7,9 +7,33 @@
       <el-form-item label="角色名称" prop="roleName">
         <el-input v-model="dataForm.roleName" placeholder="角色名称"></el-input>
       </el-form-item>
+      <el-form-item label="通用角色" size="mini" prop="isCommon">
+        <el-radio-group v-model="dataForm.isCommon">
+          <el-radio :label="false">否</el-radio>
+          <el-radio :label="true">是</el-radio>
+        </el-radio-group>
+      </el-form-item>
       <el-form-item label="备注" prop="remark">
         <el-input v-model="dataForm.remark" placeholder="备注"></el-input>
       </el-form-item>
+      <el-form-item label="所属机构" prop="orgId">
+        <el-popover
+          ref="menuListPopover"
+          placement="bottom-start"
+          trigger="click">
+          <el-tree
+            :data="orgList"
+            :props="orgListTreeProps"
+            node-key="menuId"
+            ref="menuListTree"
+            @current-change="menuListTreeCurrentChangeHandle"
+            :default-expand-all="true"
+            :highlight-current="true"
+            :expand-on-click-node="false">
+          </el-tree>
+        </el-popover>
+        <el-input v-model="dataForm.orgName" v-popover:menuListPopover :readonly="true" placeholder="点击选择所属机构" class="menu-list__input"></el-input>
+      </el-form-item>
       <el-form-item size="mini" label="授权">
         <el-tree
           :data="menuList"
@@ -29,24 +53,34 @@
 </template>
 
 <script>
-  import { treeDataTranslate } from '@/utils'
   export default {
     data () {
       return {
         visible: false,
         menuList: [],
+        orgList: [],
         menuListTreeProps: {
+          label: 'name',
+          children: 'list'
+        },
+        orgListTreeProps: {
           label: 'name',
           children: 'children'
         },
         dataForm: {
           id: 0,
           roleName: '',
-          remark: ''
+          remark: '',
+          isCommon: false,
+          orgId: '',
+          orgName: ''
         },
         dataRule: {
           roleName: [
             { required: true, message: '角色名称不能为空', trigger: 'blur' }
+          ],
+          orgId: [
+            { required: true, message: '所属机构不能为空', trigger: 'change' }
           ]
         },
         tempKey: -666666 // 临时key, 用于解决tree半选中状态项不能传给后台接口问题. # 待优化
@@ -56,11 +90,23 @@
       init (id) {
         this.dataForm.id = id || 0
         this.$http({
-          url: this.$http.adornUrl('/sys/menu/list'),
+          url: this.$http.adornUrl('/user-service/menu/tree'),
           method: 'get',
           params: this.$http.adornParams()
         }).then(({data}) => {
-          this.menuList = treeDataTranslate(data, 'menuId')
+          if (data.code === '200') {
+            this.menuList = data.data
+          }
+        }).then(() => {
+          this.$http({
+            url: this.$http.adornUrl('/user-service/org/queryTree'),
+            method: 'get',
+            params: this.$http.adornParams()
+          }).then(({data}) => {
+            if (data.code === '200') {
+              this.orgList = data.data
+            }
+          })
         }).then(() => {
           this.visible = true
           this.$nextTick(() => {
@@ -70,38 +116,46 @@
         }).then(() => {
           if (this.dataForm.id) {
             this.$http({
-              url: this.$http.adornUrl(`/sys/role/info/${this.dataForm.id}`),
+              url: this.$http.adornUrl(`/user-service/role/info/${this.dataForm.id}`),
               method: 'get',
               params: this.$http.adornParams()
             }).then(({data}) => {
-              if (data && data.code === 0) {
-                this.dataForm.roleName = data.role.roleName
-                this.dataForm.remark = data.role.remark
-                var idx = data.role.menuIdList.indexOf(this.tempKey)
+              if (data && data.code === '200') {
+                this.dataForm.roleName = data.data.roleName
+                this.dataForm.remark = data.data.remark
+                this.dataForm.isCommon = data.data.isCommon
+                this.dataForm.orgId = data.data.orgId
+                var idx = data.data.menuIdList.indexOf(this.tempKey)
                 if (idx !== -1) {
-                  data.role.menuIdList.splice(idx, data.role.menuIdList.length - idx)
+                  data.data.menuIdList.splice(idx, data.data.menuIdList.length - idx)
                 }
-                this.$refs.menuListTree.setCheckedKeys(data.role.menuIdList)
+                this.$refs.menuListTree.setCheckedKeys(data.data.menuIdList)
               }
             })
           }
         })
       },
+      menuListTreeCurrentChangeHandle (data, node) {
+        this.dataForm.orgId = data.orgId
+        this.dataForm.orgName = data.name
+      },
       // 表单提交
       dataFormSubmit () {
         this.$refs['dataForm'].validate((valid) => {
           if (valid) {
             this.$http({
-              url: this.$http.adornUrl(`/sys/role/${!this.dataForm.id ? 'save' : 'update'}`),
+              url: this.$http.adornUrl(`/user-service/role/${!this.dataForm.id ? 'save' : 'update'}`),
               method: 'post',
               data: this.$http.adornData({
                 'roleId': this.dataForm.id || undefined,
                 'roleName': this.dataForm.roleName,
                 'remark': this.dataForm.remark,
+                'isCommon': this.dataForm.isCommon,
+                'orgId': this.dataForm.orgId,
                 'menuIdList': [].concat(this.$refs.menuListTree.getCheckedKeys(), [this.tempKey], this.$refs.menuListTree.getHalfCheckedKeys())
               })
             }).then(({data}) => {
-              if (data && data.code === 0) {
+              if (data && data.code === '200') {
                 this.$message({
                   message: '操作成功',
                   type: 'success',
@@ -112,7 +166,7 @@
                   }
                 })
               } else {
-                this.$message.error(data.msg)
+                this.$message.error(data.msg || '系统错误,请联系管理员')
               }
             })
           }

+ 9 - 9
src/views/modules/sys/role.vue

@@ -102,17 +102,17 @@
       getDataList () {
         this.dataListLoading = true
         this.$http({
-          url: this.$http.adornUrl('/sys/role/list'),
+          url: this.$http.adornUrl('/user-service/role/list'),
           method: 'get',
           params: this.$http.adornParams({
-            'page': this.pageIndex,
-            'limit': this.pageSize,
+            'current': this.pageIndex,
+            'size': this.pageSize,
             'roleName': this.dataForm.roleName
           })
         }).then(({data}) => {
-          if (data && data.code === 0) {
-            this.dataList = data.page.list
-            this.totalPage = data.page.totalCount
+          if (data && data.code === '200') {
+            this.dataList = data.data.records
+            this.totalPage = Number(data.data.pages)
           } else {
             this.dataList = []
             this.totalPage = 0
@@ -153,11 +153,11 @@
           type: 'warning'
         }).then(() => {
           this.$http({
-            url: this.$http.adornUrl('/sys/role/delete'),
-            method: 'post',
+            url: this.$http.adornUrl('/user-service/role/delete'),
+            method: 'DELETE',
             data: this.$http.adornData(ids, false)
           }).then(({data}) => {
-            if (data && data.code === 0) {
+            if (data && data.code === '200') {
               this.$message({
                 message: '操作成功',
                 type: 'success',

+ 11 - 11
src/views/modules/sys/user-add-or-update.vue

@@ -111,11 +111,11 @@
       init (id) {
         this.dataForm.id = id || 0
         this.$http({
-          url: this.$http.adornUrl('/sys/role/select'),
+          url: this.$http.adornUrl('/user-service/role/listAll'),
           method: 'get',
           params: this.$http.adornParams()
         }).then(({data}) => {
-          this.roleList = data && data.code === 0 ? data.list : []
+          this.roleList = data && data.code === 0 ? data.data : []
         }).then(() => {
           this.visible = true
           this.$nextTick(() => {
@@ -124,17 +124,17 @@
         }).then(() => {
           if (this.dataForm.id) {
             this.$http({
-              url: this.$http.adornUrl(`/sys/user/info/${this.dataForm.id}`),
+              url: this.$http.adornUrl(`/user-service/user/info/${this.dataForm.id}`),
               method: 'get',
               params: this.$http.adornParams()
             }).then(({data}) => {
               if (data && data.code === 0) {
-                this.dataForm.userName = data.user.username
-                this.dataForm.salt = data.user.salt
-                this.dataForm.email = data.user.email
-                this.dataForm.mobile = data.user.mobile
-                this.dataForm.roleIdList = data.user.roleIdList
-                this.dataForm.status = data.user.status
+                this.dataForm.userName = data.data.username
+                this.dataForm.salt = data.data.salt
+                this.dataForm.email = data.data.email
+                this.dataForm.mobile = data.data.mobile
+                this.dataForm.roleIdList = data.data.roleIdList
+                this.dataForm.status = data.data.status
               }
             })
           }
@@ -145,7 +145,7 @@
         this.$refs['dataForm'].validate((valid) => {
           if (valid) {
             this.$http({
-              url: this.$http.adornUrl(`/sys/user/${!this.dataForm.id ? 'save' : 'update'}`),
+              url: this.$http.adornUrl(`/user-service/user/${!this.dataForm.id ? 'save' : 'update'}`),
               method: 'post',
               data: this.$http.adornData({
                 'userId': this.dataForm.id || undefined,
@@ -158,7 +158,7 @@
                 'roleIdList': this.dataForm.roleIdList
               })
             }).then(({data}) => {
-              if (data && data.code === 0) {
+              if (data && data.code === '200') {
                 this.$message({
                   message: '操作成功',
                   type: 'success',

+ 8 - 8
src/views/modules/sys/user.vue

@@ -118,17 +118,17 @@
       getDataList () {
         this.dataListLoading = true
         this.$http({
-          url: this.$http.adornUrl('/sys/user/list'),
+          url: this.$http.adornUrl('/user-service/user/list'),
           method: 'get',
           params: this.$http.adornParams({
-            'page': this.pageIndex,
-            'limit': this.pageSize,
+            'current': this.pageIndex,
+            'size': this.pageSize,
             'username': this.dataForm.userName
           })
         }).then(({data}) => {
-          if (data && data.code === 0) {
-            this.dataList = data.page.list
-            this.totalPage = data.page.totalCount
+          if (data && data.code === '200') {
+            this.dataList = data.data.records
+            this.totalPage = Number(data.data.pages)
           } else {
             this.dataList = []
             this.totalPage = 0
@@ -169,11 +169,11 @@
           type: 'warning'
         }).then(() => {
           this.$http({
-            url: this.$http.adornUrl('/sys/user/delete'),
+            url: this.$http.adornUrl('/user-service/user/delete'),
             method: 'post',
             data: this.$http.adornData(userIds, false)
           }).then(({data}) => {
-            if (data && data.code === 0) {
+            if (data && data.code === '200') {
               this.$message({
                 message: '操作成功',
                 type: 'success',