Browse Source

用户同步子系统

lizhenhao 1 năm trước cách đây
mục cha
commit
297333a98c

+ 14 - 0
src/api/sys/UserService.js

@@ -138,4 +138,18 @@ export default class UserService {
       method: 'post'
     })
   }
+  checkIsSyncFailed (userId) {
+    return request({
+      url: '/sys/user/checkIsSyncFailed',
+      method: 'get',
+      params: {userId: userId}
+    })
+  }
+  pushUserSync (data) {
+    return request({
+      url: '/sys/user/pushUserSync',
+      method: 'post',
+      data: data
+    })
+  }
 }

+ 5 - 3
src/views/modules/roster/RosterList.vue

@@ -93,7 +93,7 @@
         <vxe-toolbar :refresh="{query: refreshList}" import export custom>
           <template #buttons>
             <el-button v-if="hasPermission('roster:base:add')" type="primary" size="small" icon="el-icon-plus" @click="add()">新建</el-button>
-            <el-button v-if="hasPermission('roster:base:del')" type="danger"   size="small" icon="el-icon-delete" @click="del()" :disabled="$refs.rosterTable && $refs.rosterTable.getCheckboxRecords().length === 0" plain>删除</el-button>
+<!--            <el-button v-if="hasPermission('roster:base:del')" type="danger"   size="small" icon="el-icon-delete" @click="del()" :disabled="$refs.rosterTable && $refs.rosterTable.getCheckboxRecords().length === 0" plain>删除</el-button>-->
             <el-button v-if="hasPermission('roster:base:import')" size="small"  @click="template()" plain>模板下载</el-button>
             <el-button v-if="showButton" type="primary" size="small" icon="el-icon-arrow-down" @click="showTabs()" plain>展示分类</el-button>
             <el-button v-if="disableButton" type="primary" size="small" icon="el-icon-arrow-up" @click="disableTabs()" plain>收起分类</el-button>
@@ -364,6 +364,8 @@
                 }
                 this.refreshList()
                 this.loading = false
+              }).catch(() => {
+                this.loading = false
               })
             })
           }
@@ -398,7 +400,7 @@
         this.$dictUtils.getDictList('worker_type').forEach(item => {
           this.workerTypeList.push(item)
         })
-        this.workerTypeList.push({'label': '游客', 'value': '7'})
+        // this.workerTypeList.push({'label': '游客', 'value': '7'})
       },
       showTabs () {
         this.addTabs()
@@ -494,7 +496,7 @@
               })
             })
           } else {
-            this.$message.success('没有需要推送的数据')
+            this.$message.success('没有获取到需要推送的数据')
             this.refreshList()
           }
         }).catch(() => {

+ 24 - 9
src/views/modules/sys/user/UserForm.vue

@@ -341,18 +341,33 @@ export default {
           //   var manageOfficeIds = this.form.treeData.toString()
           //   this.inputForm.manageOfficeIds = manageOfficeIds
           // }
-          this.loading = true
-          this.userService.save(this.inputForm).then(({data}) => {
-            this.loading = false
-            this.visible = false
-            this.$message.success(data)
-            this.$emit('refreshDataList')
-          }).catch(() => {
-            this.loading = false
-          })
+          if (this.commonJS.isNotEmpty(this.inputForm.id)) {
+            this.userService.checkIsSyncFailed(this.inputForm.id).then(({data}) => {
+              if (this.commonJS.isNotEmpty(data) && !data.success) {
+                // 不允许保存
+                this.$message.warning(data.message + ',请重新推送后再进行尝试')
+                this.loading = false
+              } else {
+                this.doSubmitTrue()
+              }
+            })
+          } else {
+            this.doSubmitTrue()
+          }
         }
       })
     },
+    doSubmitTrue () {
+      this.loading = true
+      this.userService.save(this.inputForm).then(({data}) => {
+        this.loading = false
+        this.visible = false
+        this.$message.success(data)
+        this.$emit('refreshDataList')
+      }).catch(() => {
+        this.loading = false
+      })
+    },
     validatePass2  (rule, value, callback) {
       if (value !== this.inputForm.newPassword) {
         callback(new Error('两次输入密码不一致!'))

+ 76 - 29
src/views/modules/sys/user/UserList.vue

@@ -51,7 +51,7 @@
               <template #buttons>
                 <el-button v-if="hasPermission('sys:user:add')" type="primary" size="small" icon="el-icon-plus" @click="add()">新建</el-button>
                 <el-button v-if="hasPermission('sys:user:edit')" type="warning" size="small" icon="el-icon-edit-outline" @click="edit()" :disabled="$refs.userTable && $refs.userTable.getCheckboxRecords().length !== 1" plain>修改</el-button>
-                <el-button v-if="hasPermission('sys:user:del')" type="danger"   size="small" icon="el-icon-delete" @click="del()" :disabled="$refs.userTable && $refs.userTable.getCheckboxRecords().length === 0" plain>删除</el-button>
+<!--                <el-button v-if="hasPermission('sys:user:del')" type="danger"   size="small" icon="el-icon-delete" @click="del()" :disabled="$refs.userTable && $refs.userTable.getCheckboxRecords().length === 0" plain>删除</el-button>-->
                 <el-button v-if="hasPermission('sys:user:import')"  type="default" @click="downloadTpl()" size="small">下载模板</el-button>
 <!--                <el-button size="small" @click="updateAllUser">同步花名册</el-button>-->
               </template>
@@ -87,41 +87,42 @@
                   >
                 <vxe-column type="seq" width="60" title="序号"></vxe-column>
                 <vxe-column type="checkbox"  width="40px"></vxe-column>
-                <vxe-column  title="头像" field="photo">
+                <vxe-column  title="头像" field="photo" align="center">
                     <template slot-scope="scope">
                       <img :src="scope.row.photo === ''?'/static/img/avatar.png':scope.row.photo" style="height:35px"/>
                     </template>
                 </vxe-column>
-                <vxe-column  title="登录名" field="loginName" sortable>
+                <vxe-column  title="登录名" field="loginName" align="center" sortable>
                   <template slot-scope="scope">
-                    <el-link  type="primary" :underline="false" v-if="hasPermission('sys:user:edit')" @click="edit(scope.row.id)">{{scope.row.loginName}}</el-link>
-                    <el-link  type="primary" :underline="false" v-else-if="hasPermission('sys:user:view')"  @click="view(scope.row.id,)">{{scope.row.loginName}}</el-link>
+<!--                    <el-link  type="primary" :underline="false" v-if="hasPermission('sys:user:edit')" @click="edit(scope.row.id)">{{scope.row.loginName}}</el-link>-->
+                    <el-link  type="primary" :underline="false" v-if="hasPermission('sys:user:view')"  @click="view(scope.row.id,)">{{scope.row.loginName}}</el-link>
                     <span v-else>{{scope.row.loginName}}</span>
                   </template>
                 </vxe-column>
 
-                <vxe-column  title="姓名" field="name" sortable></vxe-column>
-                <vxe-column  title="集团" field="companyDTO.name" sortable>
+                <vxe-column  title="姓名" field="name" align="center" sortable></vxe-column>
+                <vxe-column  title="集团" field="companyDTO.name" align="center" sortable>
                   <template slot-scope="scope">
                     <el-tag>{{scope.row.companyDTO && scope.row.companyDTO.name}}</el-tag>
                   </template>
                 </vxe-column>
-                <vxe-column  title="部门" field="officeDTO.name" sortable>
+                <vxe-column  title="部门" field="officeDTO.name" align="center" sortable>
                   <template slot-scope="scope">
                     <el-tag>{{scope.row.officeDTO && scope.row.officeDTO.name}}</el-tag>
                   </template>
                 </vxe-column>
-                <vxe-column  title="状态" field="loginFlag" sortable>
+                <vxe-column  title="状态" field="loginFlag" align="center" sortable>
                   <template slot-scope="scope">
                     <el-tag v-if="scope.row.loginFlag === '1'" size="small" type="success">正常</el-tag>
                     <el-tag v-else-if="scope.row.loginFlag === '0'" size="small" type="danger">禁用</el-tag>
                   </template>
                 </vxe-column>
-                <vxe-column title="操作" width="200px" fixed="right" align="center">
+                <vxe-column title="操作" width="130px" fixed="right" align="center">
                   <template slot-scope="scope">
-                    <el-button v-if="hasPermission('sys:user:view')" type="text" size="small" icon="el-icon-view" @click="view(scope.row.id)">查看</el-button>
-                    <el-button v-if="hasPermission('sys:user:edit')" type="text" size="small" icon="el-icon-edit" @click="edit(scope.row.id)">修改</el-button>
-                    <el-button v-if="hasPermission('sys:user:del')" type="text" size="small" icon="el-icon-delete" @click="del(scope.row.id)">删除</el-button>
+<!--                    <el-button v-if="hasPermission('sys:user:view')" type="text" size="small"  @click="view(scope.row.id)">查看</el-button>-->
+                    <el-button v-if="hasPermission('sys:user:edit') && (commonJS.isEmpty(scope.row.pushFailed) || scope.row.pushFailed)" type="text" size="small"  @click="edit(scope.row.id)">修改</el-button>
+                    <el-button v-if="hasPermission('sys:user:del') && (commonJS.isEmpty(scope.row.pushFailed) || scope.row.pushFailed)" type="text" size="small"  @click="del(scope.row.id)">删除</el-button>
+                    <el-button v-if="hasPermission('sys:user:edit') && !scope.row.pushFailed" type="text"  size="small" @click="pushData(scope.row.id)">推送</el-button>
                   </template>
                 </vxe-column>
               </vxe-table>
@@ -268,23 +269,34 @@
       },
       // 删除
       del (id) {
-        let ids = id || this.$refs.userTable.getCheckboxRecords().map(item => {
-          return item.id
-        }).join(',')
-        this.$confirm(`确定删除所选项吗?`, '提示', {
-          confirmButtonText: '确定',
-          cancelButtonText: '取消',
-          type: 'warning'
-        }).then(() => {
-          this.loading = true
-          this.userService.delete(ids).then(({data}) => {
-            this.loading = false
-            this.$message.success({dangerouslyUseHTMLString: true,
-              message: data})
+        this.userService.checkIsSyncFailed(id).then(({data}) => {
+          if (this.commonJS.isNotEmpty(data) && !data.success) {
+            // 不允许删除
+            this.$message.warning(data.message + ',请重新推送后再进行尝试')
             this.refreshList()
-          }).catch(() => {
-            this.loading = false
-          })
+          } else {
+            let ids = id || this.$refs.userTable.getCheckboxRecords().map(item => {
+              return item.id
+            }).join(',')
+            this.$confirm(`删除用户数据时会同时删除关联的花名册数据以及子系统数据,确定删除吗?`, '提示', {
+              confirmButtonText: '确定',
+              cancelButtonText: '取消',
+              type: 'warning'
+            }).then(() => {
+              this.loading = true
+              this.userService.delete(ids).then(({data}) => {
+                this.loading = false
+                if (data.success) {
+                  this.$message.success({dangerouslyUseHTMLString: true, message: data.message})
+                } else {
+                  this.$message.warning({dangerouslyUseHTMLString: true, message: data.message})
+                }
+                this.refreshList()
+              }).catch(() => {
+                this.loading = false
+              })
+            })
+          }
         })
       },
       // 下载模板
@@ -353,6 +365,41 @@
       },
       updateAllUser () {
         this.userService.updateAllUser()
+      },
+      pushData (userId) {
+        this.loading = true
+        this.userService.checkIsSyncFailed(userId).then(({data}) => {
+          this.loading = false
+          if (this.commonJS.isNotEmpty(data) && !data.success) {
+            this.$confirm(data.message + ',是否重新推送', '提示', {
+              confirmButtonText: '重新推送',
+              cancelButtonText: '取消',
+              type: 'warning'
+            }).then(() => {
+              this.loading = true
+              let param = {
+                id: userId
+              }
+              this.userService.pushUserSync(param).then(({data}) => {
+                if (data) {
+                  this.$message.success('推送数据到子系统成功')
+                } else {
+                  this.$message.error('推送数据到子系统失败,请稍后再进行尝试')
+                }
+                this.loading = false
+                this.refreshList()
+              }).catch(() => {
+                this.loading = false
+                this.refreshList()
+              })
+            })
+          } else {
+            this.$message.success('没有获取到需要推送的数据')
+            this.refreshList()
+          }
+        }).catch(() => {
+          this.loading = false
+        })
       }
     }
   }