map to new back
This commit is contained in:
@@ -141,7 +141,7 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
dataClientsPresence() {
|
||||
return this.dataClients[0]?.initialization;
|
||||
return this.dataClients?.[0]?.initialization;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
@@ -184,12 +184,11 @@ export default {
|
||||
}
|
||||
},
|
||||
async fetchDataClients() {
|
||||
let response = {};
|
||||
if (this.textSearch) {
|
||||
response = await fetchWrapper.get(
|
||||
`general/person/?last_name=${this.textSearch}&limit=${
|
||||
this.limit
|
||||
}&offset=${(this.currentTablePage - 1) * this.limit}`
|
||||
const response = await fetchWrapper.get(
|
||||
`persons/?limit=${this.limit}&offset=${
|
||||
(this.currentTablePage - 1) * this.limit
|
||||
}`
|
||||
);
|
||||
this.saveDataClients(response);
|
||||
this.saveFilteredClientsCount(response);
|
||||
@@ -198,8 +197,8 @@ export default {
|
||||
length: this.calculatePageCount(this.filteredClientsCount),
|
||||
};
|
||||
} else {
|
||||
response = await fetchWrapper.get(
|
||||
`general/person/?limit=${this.limit}&offset=${
|
||||
const response = await fetchWrapper.get(
|
||||
`persons/?limit=${this.limit}&offset=${
|
||||
(this.currentTablePage - 1) * this.limit
|
||||
}`
|
||||
);
|
||||
@@ -212,18 +211,16 @@ export default {
|
||||
}
|
||||
},
|
||||
async fetchCreatedClientData() {
|
||||
fetchWrapper
|
||||
.get(`general/person/${this.createdClientId}/detail/`)
|
||||
.then((response) => {
|
||||
this.dataClients = [response];
|
||||
this.createdClientName = `${response.last_name ?? ""} ${
|
||||
response?.first_name ?? ""
|
||||
} ${response?.patronymic ?? ""}`;
|
||||
this.paginationInfo = {
|
||||
currentPage: 0,
|
||||
length: 0,
|
||||
};
|
||||
});
|
||||
fetchWrapper.get(`persons/${this.createdClientId}/`).then((response) => {
|
||||
this.dataClients = [response];
|
||||
this.createdClientName = `${response.last_name ?? ""} ${
|
||||
response?.first_name ?? ""
|
||||
} ${response?.patronymic ?? ""}`;
|
||||
this.paginationInfo = {
|
||||
currentPage: 0,
|
||||
length: 0,
|
||||
};
|
||||
});
|
||||
},
|
||||
calculatePageCount(count) {
|
||||
return Math.ceil(count / this.limit);
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
.flex.items-center.cursor-pointer(@click="changeView", v-if="!wrongData && user.password")
|
||||
img(:src="!isView ? eye_close : eye_open")
|
||||
.flex.items-center.gap-x-8px.-ml-2
|
||||
q-checkbox(@click="persist", v-model="person", type="checkbox")
|
||||
q-checkbox(v-model="person", type="checkbox")
|
||||
.flex.non-italic.font-medium.base Запомнить меня
|
||||
base-button(
|
||||
:disable="disabledButton",
|
||||
@@ -60,67 +60,49 @@ export default {
|
||||
eye_close,
|
||||
eye_open,
|
||||
authorized: true,
|
||||
user: { username: "", password: "" },
|
||||
user: {},
|
||||
userData: {},
|
||||
person: false,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
wrongData() {
|
||||
return !this.authorized && !this.user.username && !this.user.password;
|
||||
return !this.authorized;
|
||||
},
|
||||
changeType() {
|
||||
return !this.isView ? "password" : "text";
|
||||
},
|
||||
disabledButton() {
|
||||
return this.user.username && this.user.password ? false : true;
|
||||
return !(this.user.username && this.user.password);
|
||||
},
|
||||
showBorder() {
|
||||
return !this.authorized && !this.user.username && !this.user.password
|
||||
? true
|
||||
: false;
|
||||
return !this.authorized && !this.user.username && !this.user.password;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
changeView() {
|
||||
this.isView = !this.isView;
|
||||
},
|
||||
persist() {
|
||||
if (!this.person) return;
|
||||
localStorage.username = this.user.username;
|
||||
localStorage.password = this.user.password;
|
||||
},
|
||||
async auth() {
|
||||
let res = await fetchWrapper.get("auth/users/me/");
|
||||
res = await res;
|
||||
let data = await fetchWrapper.get(`accounts/users/${res.id}/detail`);
|
||||
data = await data;
|
||||
this.userData = data;
|
||||
localStorage.setItem("userData", JSON.stringify(this.userData));
|
||||
this.userData = await fetchWrapper.get("users/me");
|
||||
},
|
||||
login() {
|
||||
fetchWrapper
|
||||
.post("auth/jwt/create/", {
|
||||
username: this.user.username,
|
||||
.post("auth/login", {
|
||||
user_name: this.user.username,
|
||||
password: this.user.password,
|
||||
})
|
||||
.then((token) => {
|
||||
if (token.access) {
|
||||
localStorage.setItem("tokenAccess", token.access);
|
||||
this.auth().then(() => this.$router.push("/"));
|
||||
} else {
|
||||
this.authorized = false;
|
||||
this.user.username = "";
|
||||
this.user.password = "";
|
||||
this.$router.push("/login");
|
||||
}
|
||||
.then(() => {
|
||||
this.auth().then(() => this.$router.push("/"));
|
||||
})
|
||||
.catch(() => {
|
||||
this.authorized = false;
|
||||
this.user.username = "";
|
||||
this.user.password = "";
|
||||
this.$router.push("/login");
|
||||
});
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
if (localStorage.username) this.user.username = localStorage.username;
|
||||
if (localStorage.password) this.user.password = localStorage.password;
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user