mirror of
https://github.com/Dadechin/XRoomDashboardFront.git
synced 2025-07-03 08:44:35 +00:00
added team member
This commit is contained in:
parent
6aacb96992
commit
a042a56a67
|
@ -37,38 +37,46 @@
|
||||||
<div class="popUp-objects">
|
<div class="popUp-objects">
|
||||||
<form @submit.prevent="handleSubmit" autocomplete="off">
|
<form @submit.prevent="handleSubmit" autocomplete="off">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="full_name">نام و نام خانوادگی</label>
|
<label for="first_name">نام</label>
|
||||||
<input
|
<input
|
||||||
id="full_name"
|
id="first_name"
|
||||||
v-model="newUser.full_name"
|
v-model="newUser.first_name"
|
||||||
type="text"
|
type="text"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="email">ایمیل</label>
|
<label for="last_name">نام خانوادگی</label>
|
||||||
<input
|
<input
|
||||||
id="email"
|
id="last_name"
|
||||||
v-model="newUser.email"
|
v-model="newUser.last_name"
|
||||||
type="email"
|
type="text"
|
||||||
required
|
required
|
||||||
style="text-align: left;"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="phone">شماره تماس</label>
|
<label for="mobile_number">شماره تماس</label>
|
||||||
<input
|
<input
|
||||||
id="phone"
|
id="mobile_number"
|
||||||
v-model="newUser.phone"
|
v-model="newUser.mobile_number"
|
||||||
type="tel"
|
type="tel"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="job_title">عنوان شغلی</label>
|
<label for="password">رمز عبور</label>
|
||||||
<input
|
<input
|
||||||
id="job_title"
|
id="password"
|
||||||
v-model="newUser.job_title"
|
v-model="newUser.password"
|
||||||
|
type="password"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="semat">عنوان شغلی</label>
|
||||||
|
<input
|
||||||
|
id="semat"
|
||||||
|
v-model="newUser.semat"
|
||||||
type="text"
|
type="text"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
|
@ -77,21 +85,11 @@
|
||||||
<span>مدیر</span>
|
<span>مدیر</span>
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
id="is_manager"
|
id="isAdmin"
|
||||||
class="checkbox"
|
class="checkbox"
|
||||||
v-model="newUser.is_manager"
|
v-model="newUser.isAdmin"
|
||||||
/>
|
/>
|
||||||
<label for="is_manager" class="switch"></label>
|
<label for="isAdmin" class="switch"></label>
|
||||||
</div>
|
|
||||||
<div class="form-group" style="justify-content: normal;">
|
|
||||||
<span>مجوز</span>
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
id="has_permission"
|
|
||||||
class="checkbox"
|
|
||||||
v-model="newUser.has_permission"
|
|
||||||
/>
|
|
||||||
<label for="has_permission" class="switch"></label>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -104,6 +102,8 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import axios from 'axios';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'AddUserModal',
|
name: 'AddUserModal',
|
||||||
props: {
|
props: {
|
||||||
|
@ -115,34 +115,58 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
newUser: {
|
newUser: {
|
||||||
full_name: '',
|
first_name: '',
|
||||||
phone: '',
|
last_name: '',
|
||||||
email: '',
|
mobile_number: '',
|
||||||
job_title: '',
|
password: '',
|
||||||
is_manager: false,
|
semat: '',
|
||||||
has_permission: false,
|
isAdmin: false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
close() {
|
close() {
|
||||||
this.newUser = {
|
this.newUser = {
|
||||||
full_name: '',
|
first_name: '',
|
||||||
phone: '',
|
last_name: '',
|
||||||
email: '',
|
mobile_number: '',
|
||||||
job_title: '',
|
password: '',
|
||||||
is_manager: false,
|
semat: '',
|
||||||
has_permission: false,
|
isAdmin: false,
|
||||||
};
|
};
|
||||||
this.$emit('close');
|
this.$emit('close');
|
||||||
},
|
},
|
||||||
handleSubmit() {
|
handleSubmit() {
|
||||||
if (!this.newUser.full_name || !this.newUser.email || !this.newUser.phone || !this.newUser.job_title) {
|
if (!this.newUser.first_name || !this.newUser.last_name || !this.newUser.mobile_number || !this.newUser.password || !this.newUser.semat) {
|
||||||
alert('لطفاً تمام فیلدها را پر کنید.');
|
alert('لطفاً تمام فیلدها را پر کنید.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.$emit('add-user', { ...this.newUser });
|
|
||||||
|
const token = localStorage.getItem('token');
|
||||||
|
const userData = {
|
||||||
|
mobile_number: this.newUser.mobile_number,
|
||||||
|
first_name: this.newUser.first_name,
|
||||||
|
last_name: this.newUser.last_name,
|
||||||
|
semat: this.newUser.semat,
|
||||||
|
password: this.newUser.password,
|
||||||
|
isAdmin: this.newUser.isAdmin ? 'true' : 'false', // Sending as string "true" or "false"
|
||||||
|
};
|
||||||
|
|
||||||
|
axios.post('http://my.xroomapp.com:8000/add_teamMember', userData, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Token ${token}`,
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
console.log('کاربر جدید:', response.data);
|
||||||
|
alert('کاربر با موفقیت اضافه شد');
|
||||||
this.close();
|
this.close();
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error('Error adding user:', error);
|
||||||
|
alert('خطا در افزودن کاربر');
|
||||||
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -151,7 +175,7 @@ export default {
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.modal-overlay {
|
.modal-overlay {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
inset: 0; /* جایگزین top: 0; left: 0; right: 0; bottom: 0 */
|
inset: 0;
|
||||||
background: rgba(0, 0, 0, 0.5);
|
background: rgba(0, 0, 0, 0.5);
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
@ -193,7 +217,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
.popUp-header button {
|
.popUp-header button {
|
||||||
background-color: inherit; /* استفاده از inherit برای حذف تکرار #101010 */
|
background-color: inherit;
|
||||||
border: none;
|
border: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
@ -201,7 +225,7 @@ export default {
|
||||||
.popUp-title {
|
.popUp-title {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: flex-start; /* اصلاح start به flex-start برای استاندارد بودن */
|
align-items: flex-start;
|
||||||
padding: 20px 50px 20px 20px;
|
padding: 20px 50px 20px 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,7 +243,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
.popUp-objects {
|
.popUp-objects {
|
||||||
margin: 1rem auto 0; /* ترکیب margin-top و margin: auto */
|
margin: 1rem auto 0;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
background-color: #FFFFFF;
|
background-color: #FFFFFF;
|
||||||
border-radius: 16px;
|
border-radius: 16px;
|
||||||
|
@ -241,28 +265,15 @@ export default {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-group input,
|
.form-group input {
|
||||||
.form-group textarea {
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
border: 1px solid #718096;
|
border: 1px solid #718096;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
resize: none; /* برای textarea */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-group input {
|
.form-group input:focus {
|
||||||
height: 45px;
|
|
||||||
max-width: 22rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group textarea {
|
|
||||||
height: 140px;
|
|
||||||
max-width: 25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group input:focus,
|
|
||||||
.form-group textarea:focus {
|
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,16 +311,16 @@ export default {
|
||||||
/* checkbox toggler */
|
/* checkbox toggler */
|
||||||
|
|
||||||
.switch {
|
.switch {
|
||||||
position : relative ;
|
position: relative;
|
||||||
display : inline-block;
|
display: inline-block;
|
||||||
width: 60px !important;
|
width: 60px !important;
|
||||||
height: 25px;
|
height: 25px;
|
||||||
background-color: #CCCCCC;
|
background-color: #CCCCCC;
|
||||||
border-radius: 20px;
|
border-radius: 20px;
|
||||||
margin-right: 12.5rem;
|
margin-right: 12.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.switch::after {
|
.switch::after {
|
||||||
content: '';
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 20px;
|
width: 20px;
|
||||||
|
@ -324,12 +335,12 @@ export default {
|
||||||
.checkbox:checked + .switch::after {
|
.checkbox:checked + .switch::after {
|
||||||
right: 37px;
|
right: 37px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.checkbox:checked + .switch {
|
.checkbox:checked + .switch {
|
||||||
background-color: #3a57e8;
|
background-color: #3a57e8;
|
||||||
}
|
}
|
||||||
|
|
||||||
.checkbox {
|
.checkbox {
|
||||||
display : none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
Loading…
Reference in New Issue
Block a user