Browse Source

Transfer team
转让团队

star7th 5 years ago
parent
commit
730690bee2

+ 40 - 0
server/Application/Api/Controller/TeamController.class.php

@@ -77,6 +77,46 @@ class TeamController extends BaseController {
         }
     }
 
+    //转让团队
+    public function attorn(){
+        $login_user = $this->checkLogin();
+
+        $username = I("username");
+        $team_id = I("team_id/d");
+        $password = I("password");
+
+        $team  = D("Team")->where("id = '$team_id' and uid = '$login_user[uid]' ")->find();
+
+        if (!$team) {
+            $this->sendError(10101);
+            return ;
+        }
+
+        if(! D("User")-> checkLogin($login_user['username'],$password)){
+            $this->sendError(10208);
+            return ;
+        }
+
+        $member = D("User")->where(" username = '%s' ",array($username))->find();
+
+        if (!$member) {
+            $this->sendError(10209);
+            return ;
+        }
+        $data = array() ;
+        $data['username'] = $member['username'] ;
+        $data['uid'] = $member['uid'] ;
+        D("Team")->where(" id = '$team_id' ")->save($data);
+
+        //读取出该团队下的所有项目,准备转让
+        $items = D("TeamItem")->where(" team_id = '$team_id' ")->select() ;
+        foreach ($items as $key => $value) {
+            D("Item")->where(" item_id = '$value[item_id]' ")->save($data);
+        }
+
+        $this->sendResult($return);
+    }
+
 
 
 

+ 53 - 0
web_src/src/components/team/Index.vue

@@ -39,6 +39,8 @@
                 <el-button @click="$router.push({path:'/team/member/'+scope.row.id})" type="text" size="small">{{$t('member')}}</el-button>
                 <el-button @click="$router.push({path:'/team/item/'+scope.row.id})"  type="text" size="small">{{$t('team_item')}}</el-button>
                 <el-button @click="edit(scope.row)" type="text" size="small">{{$t('edit')}}</el-button>
+                <br>
+                <el-button @click="attornDialog(scope.row)" type="text" size="small">{{$t('attorn')}}</el-button>
                 <el-button @click="deleteTeam(scope.row.id)" type="text" size="small">{{$t('delete')}}</el-button>
               </template>
             </el-table-column>
@@ -58,6 +60,27 @@
                 <el-button type="primary" @click="MyFormSubmit" >{{$t('confirm')}}</el-button>
               </div>
             </el-dialog>
+
+
+            <el-dialog :visible.sync="dialogAttornVisible" :modal="false" width="300px" :close-on-click-modal="false" >
+              <el-form >
+                  <el-form-item label="" >
+                    <el-input  :placeholder="$t('attorn_username')" auto-complete="new-password" v-model="attornForm.username"></el-input>
+                  </el-form-item>
+                  <el-form-item label="" >
+                    <el-input type="password" auto-complete="new-password" :placeholder="$t('input_login_password')"  v-model="attornForm.password" ></el-input>
+                  </el-form-item>
+              </el-form>
+             <p class="tips">
+                {{$t('attornTeamTips')}}
+            </p>
+              <div slot="footer" class="dialog-footer">
+                <el-button @click="dialogAttornVisible = false">{{$t('cancel')}}</el-button>
+                <el-button type="primary" @click="attorn" >{{$t('attorn')}}</el-button>
+              </div>
+            </el-dialog>
+
+
     </el-container>
 
     <Footer> </Footer>
@@ -79,6 +102,12 @@ export default {
       list:[],
       dialogFormVisible:false,
       dialogMemberVisible:false,
+      dialogAttornVisible:false,
+      attornForm :{
+        team_id:'',
+        username:'',
+        password:''
+      }
     }
   }, 
   methods: {
@@ -161,6 +190,30 @@ export default {
       },
       goback(){
         this.$router.push({path:"/item/index"})
+      },
+      attornDialog(row){
+        this.attornForm.team_id = row.id; 
+        this.dialogAttornVisible = true ;
+      },
+      attorn(){
+        var that = this ;
+        var url = DocConfig.server+'/api/team/attorn';
+
+        var params = new URLSearchParams();
+        params.append('team_id',  this.attornForm.team_id);
+        params.append('username', this.attornForm.username);
+        params.append('password',this.attornForm.password );
+
+        that.axios.post(url, params)
+          .then(function (response) {
+            if (response.data.error_code === 0 ) {
+              that.dialogAttornVisible = false;
+              that.geList();
+            }else{
+              that.$alert(response.data.error_message);
+            }
+            
+          });
       }
   },
 

+ 5 - 4
web_src/static/lang/en.js

@@ -93,7 +93,7 @@ exports.default = {
     'open_api' : 'open api',
     'info_item_domain':"Personal domain name",
     'visit_password':"Password",
-    'visit_password_description':"(Optional: private project required)",
+    'visit_password_description':"(Optional: private item required)",
     "add_member" :"Add member",
     "authority" :"Authority",
     "add_time" :"Add time",
@@ -107,11 +107,10 @@ exports.default = {
     "confirm_delete" :"Confirm to delete",
     "attorn" :"Attorn",
     "archive" :"Archive",
-    "attorn" :"Attorn",
     "attorn_tips":"You can attorn item(s) to other user(s)",
-    "archive_tips":"After archiving, the project will become read-only, and no more changes / additions can be made. If you want to edit it again, copy it to the new project and then edit it",
+    "archive_tips":"After archiving, the item will become read-only, and no more changes / additions can be made. If you want to edit it again, copy it to the new project and then edit it",
     "delete_tips":"After deleting it, it can not be restored!",
-    "attorn_username" :"Username of project receiver",
+    "attorn_username" :"Username of receiver",
     "archive_tips2":"Note: After archiving a project, the project will no longer be able to add and modify content and will not be able to unarchive. If you want to modify the content again, you can copy the project and modify it on the basis of the new project. The way to copy a project is to choose to copy from an existing project when you create the project.",
     "success_jump" :"The operation is successful! Skipping...",
     "reset_token":"Reset token",
@@ -329,4 +328,6 @@ exports.default = {
     "qiniu":"qiniu",
     "oss_domain":"domain(optional)",
 
+    "attornTeamTips":"All items owned by the team will also be transferred to he/her",
+
 };

+ 3 - 2
web_src/static/lang/zh-CN.js

@@ -110,11 +110,10 @@ exports.default = {
     "confirm_delete" :"确认删除吗?",
     "attorn" :"转让",
     "archive" :"归档",
-    "attorn" :"转让",
     "attorn_tips":"你可以将项目转让给他人",
     "archive_tips":"归档后,项目将变为只读,无法再修改/新增内容。如果要重新编辑,请复制到新项目后编辑",
     "delete_tips":"删除后将不可恢复!",
-    "attorn_username" :"项目接受者用户名",
+    "attorn_username" :"接受者用户名",
     "archive_tips2":"说明: 归档项目后,项目将无法再新增和修改内容,并且无法取消归档状态。 如想再次修改内容,可复制本项目,在新的项目基础上修改。复制项目的方法是,在创建项目的时候,选择从已有项目里复制。",
     "success_jump" :"操作成功!正在跳转...",
     "reset_token":"重新生成api_token",
@@ -337,5 +336,7 @@ exports.default = {
     "qiniu":"七牛云",
     "oss_domain":"oss绑定域名(选填)",
 
+    "attornTeamTips":"转让团队后,该团队下拥有的所有项目也会一并转让给对方",
+
     
 };