Merge pull request #173 from dderbentsov/UC-98
WIP Сделала запрет на удаление более 1го клиента
This commit is contained in:
@@ -392,7 +392,7 @@ export default {
|
|||||||
}
|
}
|
||||||
if (this.infoClient.basic.full_name.split(" ").length < 3) {
|
if (this.infoClient.basic.full_name.split(" ").length < 3) {
|
||||||
this.addErrrorNotification(
|
this.addErrrorNotification(
|
||||||
"Не корректное ФИО клиента",
|
"Некорректное ФИО клиента",
|
||||||
"Пожалуйста, введите ФИО клиента правильно"
|
"Пожалуйста, введите ФИО клиента правильно"
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -8,20 +8,37 @@
|
|||||||
.button.keep-redaction.flex.gap-x-3
|
.button.keep-redaction.flex.gap-x-3
|
||||||
.icon-star-off.icon
|
.icon-star-off.icon
|
||||||
span На ведение
|
span На ведение
|
||||||
.button.delete.flex.gap-x-3(@click="transmitDeleteClient")
|
.button.delete.flex.gap-x-3(
|
||||||
|
@click="transmitDeleteClient",
|
||||||
|
:style="{'opacity': disabledDelete && '0.7'}"
|
||||||
|
)
|
||||||
.icon-basket.icon-delete
|
.icon-basket.icon-delete
|
||||||
span Удалить
|
span Удалить
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import TheNotificationProvider from "@/components/Notifications/TheNotificationProvider";
|
||||||
|
import { addNotification } from "@/components/Notifications/notificationContext";
|
||||||
export default {
|
export default {
|
||||||
name: "ClientsActionPopup",
|
name: "ClientsActionPopup",
|
||||||
|
components: { TheNotificationProvider },
|
||||||
props: {
|
props: {
|
||||||
openChangeData: Function,
|
openChangeData: Function,
|
||||||
|
disabledDelete: Boolean,
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
transmitDeleteClient() {
|
transmitDeleteClient() {
|
||||||
this.$emit("delete-client");
|
if (!this.disabledDelete) this.$emit("delete-client");
|
||||||
|
else this.addWarningNotification();
|
||||||
|
},
|
||||||
|
addWarningNotification() {
|
||||||
|
addNotification(
|
||||||
|
new Date().getTime(),
|
||||||
|
"Сейчас нельзя удалить клиента",
|
||||||
|
"Для удаления дождитесь текущего удаления клиента или переключите страницу",
|
||||||
|
"warning",
|
||||||
|
5000
|
||||||
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -34,7 +51,7 @@ export default {
|
|||||||
border-radius: 4px 0 4px 4px
|
border-radius: 4px 0 4px 4px
|
||||||
background-color: var(--default-white)
|
background-color: var(--default-white)
|
||||||
box-shadow: var(--default-shadow)
|
box-shadow: var(--default-shadow)
|
||||||
z-index: 1
|
z-index: 11
|
||||||
.keep-redaction
|
.keep-redaction
|
||||||
color: var(--font-dark-blue-color)
|
color: var(--font-dark-blue-color)
|
||||||
.icon
|
.icon
|
||||||
@@ -49,7 +66,7 @@ export default {
|
|||||||
height: 8px
|
height: 8px
|
||||||
border-top-left-radius: 100%
|
border-top-left-radius: 100%
|
||||||
background-color: var(--default-white)
|
background-color: var(--default-white)
|
||||||
z-index: 2
|
z-index: 12
|
||||||
overflow: hidden
|
overflow: hidden
|
||||||
.icon-delete
|
.icon-delete
|
||||||
color: var(--btn-red-color)
|
color: var(--btn-red-color)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
:is-check="marked.includes(client.id)",
|
:is-check="marked.includes(client.id)",
|
||||||
:check="selectedCheck",
|
:check="selectedCheck",
|
||||||
:client="client",
|
:client="client",
|
||||||
:row-overlay="deletedRowId === client.id",
|
:deleted-client-id="deletedRowId",
|
||||||
:update-data-client="updateDataClient",
|
:update-data-client="updateDataClient",
|
||||||
@delete-client="deleteClientHandler",
|
@delete-client="deleteClientHandler",
|
||||||
@recover-client="clearDeletedRowId",
|
@recover-client="clearDeletedRowId",
|
||||||
@@ -93,8 +93,10 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
updateDataClient() {
|
updateDataClient() {
|
||||||
|
if (this.dataClients.find(({ id }) => id === this.deletedRowId)) {
|
||||||
if (this.dataClients.length === 1) this.currentTablePage -= 1;
|
if (this.dataClients.length === 1) this.currentTablePage -= 1;
|
||||||
else this.fetchDataClients();
|
else this.fetchDataClients();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
saveDataClients(data) {
|
saveDataClients(data) {
|
||||||
this.dataClients = data.results;
|
this.dataClients = data.results;
|
||||||
|
|||||||
@@ -81,6 +81,7 @@
|
|||||||
clients-action-popup(
|
clients-action-popup(
|
||||||
v-if="isOpenPopup",
|
v-if="isOpenPopup",
|
||||||
:open-change-data="openChangeData",
|
:open-change-data="openChangeData",
|
||||||
|
:disabled-delete="!!deletedClientId && !rowOverlay",
|
||||||
@delete-client="transmitDeleteClient"
|
@delete-client="transmitDeleteClient"
|
||||||
)
|
)
|
||||||
client-detail-info-wrapper(
|
client-detail-info-wrapper(
|
||||||
@@ -119,6 +120,8 @@ import ClientDetailInfoWrapper from "@/pages/clients/components/ClientDetailInfo
|
|||||||
import BaseButton from "@/components/base/BaseButton";
|
import BaseButton from "@/components/base/BaseButton";
|
||||||
import { fetchWrapper } from "@/shared/fetchWrapper";
|
import { fetchWrapper } from "@/shared/fetchWrapper";
|
||||||
import { column } from "@/pages/clients/utils/tableConfig";
|
import { column } from "@/pages/clients/utils/tableConfig";
|
||||||
|
import TheNotificationProvider from "@/components/Notifications/TheNotificationProvider";
|
||||||
|
import { addNotification } from "@/components/Notifications/notificationContext";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "ClientsTableRow",
|
name: "ClientsTableRow",
|
||||||
@@ -135,6 +138,7 @@ export default {
|
|||||||
TableCellBodyNetworks,
|
TableCellBodyNetworks,
|
||||||
TableCellBodyMeeting,
|
TableCellBodyMeeting,
|
||||||
ClientDetailInfoWrapper,
|
ClientDetailInfoWrapper,
|
||||||
|
TheNotificationProvider,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -170,10 +174,15 @@ export default {
|
|||||||
check: Function,
|
check: Function,
|
||||||
isCheck: Boolean,
|
isCheck: Boolean,
|
||||||
client: Object,
|
client: Object,
|
||||||
rowOverlay: Boolean,
|
deletedClientId: String,
|
||||||
updateDataClient: Function,
|
updateDataClient: Function,
|
||||||
url: String,
|
url: String,
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
rowOverlay() {
|
||||||
|
return this.deletedClientId === this.client.id;
|
||||||
|
},
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
stopTimer() {
|
stopTimer() {
|
||||||
if (this.countdown !== 0) this.countdown = 0;
|
if (this.countdown !== 0) this.countdown = 0;
|
||||||
@@ -189,8 +198,10 @@ export default {
|
|||||||
},
|
},
|
||||||
changeCountdown() {
|
changeCountdown() {
|
||||||
if (this.countdown === 0) {
|
if (this.countdown === 0) {
|
||||||
|
this.deleteClient().then(() => {
|
||||||
|
this.updateDataClient();
|
||||||
this.stopTimer();
|
this.stopTimer();
|
||||||
this.deleteClient().then(() => this.updateDataClient());
|
});
|
||||||
} else {
|
} else {
|
||||||
this.countdown -= 1;
|
this.countdown -= 1;
|
||||||
}
|
}
|
||||||
@@ -284,12 +295,21 @@ export default {
|
|||||||
},
|
},
|
||||||
transmitDeleteClient() {
|
transmitDeleteClient() {
|
||||||
this.isOpenDetailInfo = false;
|
this.isOpenDetailInfo = false;
|
||||||
this.$emit("delete-client", this.dataClient.id);
|
this.$emit("delete-client", this.client.id);
|
||||||
},
|
},
|
||||||
async deleteClient() {
|
async deleteClient() {
|
||||||
await fetchWrapper.del(`general/person/${this.dataClient.id}/delete/`);
|
await fetchWrapper.del(`general/person/${this.client.id}/delete/`);
|
||||||
|
this.addSuccessNotification();
|
||||||
this.handleUnFocusPopup();
|
this.handleUnFocusPopup();
|
||||||
this.$emit("update-clients");
|
},
|
||||||
|
addSuccessNotification() {
|
||||||
|
addNotification(
|
||||||
|
new Date().getTime(),
|
||||||
|
"Клиент Успешно удален",
|
||||||
|
"",
|
||||||
|
"success",
|
||||||
|
5000
|
||||||
|
);
|
||||||
},
|
},
|
||||||
fetchClientDetail(id) {
|
fetchClientDetail(id) {
|
||||||
fetchWrapper
|
fetchWrapper
|
||||||
@@ -483,9 +503,12 @@ export default {
|
|||||||
photo: this.client.photo,
|
photo: this.client.photo,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
/*beforeUnmount() {
|
beforeUnmount() {
|
||||||
|
if (this.timer) {
|
||||||
|
this.deleteClient();
|
||||||
this.stopTimer();
|
this.stopTimer();
|
||||||
},*/
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -515,7 +538,7 @@ export default {
|
|||||||
.row-overlay
|
.row-overlay
|
||||||
background: transparent
|
background: transparent
|
||||||
position: absolute
|
position: absolute
|
||||||
z-index: 100
|
z-index: 10
|
||||||
width: 100%
|
width: 100%
|
||||||
height: 100%
|
height: 100%
|
||||||
.row-overlay-color
|
.row-overlay-color
|
||||||
|
|||||||
Reference in New Issue
Block a user