프로젝트

49. 계약(연동)

uni5948 2022. 2. 9. 11:37

49. 계약(연동)

48. 계약(백엔드 수정) 연동

  • 백엔드 연동
<script>
    import axios from 'axios';
    export default {
        async created(){
            const url = `/REST/scoutone?sno=${this.sno}`;
            const headers = {"Content-Type":"application/json",
                    token : this.token};
            const response = await axios.get(url,{headers});
            // console.log(response);
            this.scout = response.data.scout;
            this.player = response.data.scout.player;
            this.agent = response.data.scout.player.agent;

            //팀 목록 조회
            const url2 = "/REST/teamall";
            const response2 = await axios.get(url2, {headers});
            // console.log(response2);
            this.teams = response2.data.team;
        },
        methods:{
더보기
            async handleDelete(){
                    const result = confirm("스카우트 목록에서 삭제하시겠습니까?");
                    console.log(result);
                    if(result){
                        const url = `/REST/scoutdelete?sno=${this.sno}`;
                        const headers = {"Content-Type":"application/json",
                            token : this.token};
                        const response = await axios.delete(url,{headers});
                        console.log(response);
                        alert("삭제되었습니다.");
                        this.$router.push({name:'ScoutList'}); //성공 시 ScoutList로 이동
                    }
                    else{
                        alert("취소되었습니다.");
                    }
            },
         
            async handleContract(){
                const url = `/REST/contractinsert?sno=${this.sno}`;
                const headers = {"Content-Type":"application/json",
                            token : this.token};
                const body = new FormData();
                    body.append("scout", this.sno);
                    body.append("playerprice", this.player.playerprice);
                    body.append("team", this.team);
                const response = await axios.post(url,body,{headers});
                console.log(response);
                 if(response.data.status === 200){
                    alert("계약에 성공했습니다.");
                    this.$router.push({name:'ScoutList'}); //성공 시 ScoutList로 이동
                }
                else{
                    alert("계약에 실패했습니다.")
                }
            }
        },
        data(){
            return{
                //세션 스토리지에서 토큰 읽기
                token : sessionStorage.getItem("TOKEN"),
                sno : this.$route.query.sno,
                scout : '',
                player : '',
                team : '',
                agent : '',
                teams : []
            }
        }
    }
</script>

<style scoped>

</style>
  • 계약 구현

player20 선수 계약하기

1. 기존 선수의 몸 값, 소속 팀 확인

기존 선수의 몸 값, 소속 팀 확인

2. 계약하기

 

계약하기
선수 정보 변경 확인
계약 db 저장 성공
스카우트 정보 수정 성공

계약이 완료되면 스카우트 리스트 화면으로 이동하고 스카우트 정보의 유저 정보를 지워 리스트 화면에서 보이지 않도록 한다.

스카우트 리스트 화면 이동

'프로젝트' 카테고리의 다른 글

51. 팀 별 선수 조회  (0) 2022.02.28
50. 팀 목록 조회  (0) 2022.02.24
48. 계약(백엔드 수정)  (0) 2022.02.09
47. 계약(화면 구현)  (0) 2022.02.07
46. 스카우트 목록 삭제  (0) 2022.02.05