WIP Сделала запрет на удаление более 1го клиента

This commit is contained in:
Daria Golova
2022-12-02 19:45:54 +03:00
parent 1db2ca2113
commit d52f3064e3
3 changed files with 46 additions and 11 deletions

View File

@@ -8,20 +8,37 @@
.button.keep-redaction.flex.gap-x-3
.icon-star-off.icon
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
span Удалить
</template>
<script>
import TheNotificationProvider from "@/components/Notifications/TheNotificationProvider";
import { addNotification } from "@/components/Notifications/notificationContext";
export default {
name: "ClientsActionPopup",
components: { TheNotificationProvider },
props: {
openChangeData: Function,
disabledDelete: Boolean,
},
methods: {
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
background-color: var(--default-white)
box-shadow: var(--default-shadow)
z-index: 1
z-index: 11
.keep-redaction
color: var(--font-dark-blue-color)
.icon
@@ -49,7 +66,7 @@ export default {
height: 8px
border-top-left-radius: 100%
background-color: var(--default-white)
z-index: 2
z-index: 12
overflow: hidden
.icon-delete
color: var(--btn-red-color)

View File

@@ -16,7 +16,7 @@
:is-check="marked.includes(client.id)",
:check="selectedCheck",
:client="client",
:row-overlay="deletedRowId === client.id",
:deleted-client-id="deletedRowId",
:update-data-client="updateDataClient",
@delete-client="deleteClientHandler",
@recover-client="clearDeletedRowId",

View File

@@ -81,6 +81,7 @@
clients-action-popup(
v-if="isOpenPopup",
:open-change-data="openChangeData",
:disabled-delete="!!deletedClientId && !rowOverlay",
@delete-client="transmitDeleteClient"
)
client-detail-info-wrapper(
@@ -119,6 +120,8 @@ import ClientDetailInfoWrapper from "@/pages/clients/components/ClientDetailInfo
import BaseButton from "@/components/base/BaseButton";
import { fetchWrapper } from "@/shared/fetchWrapper";
import { column } from "@/pages/clients/utils/tableConfig";
import TheNotificationProvider from "@/components/Notifications/TheNotificationProvider";
import { addNotification } from "@/components/Notifications/notificationContext";
export default {
name: "ClientsTableRow",
@@ -135,6 +138,7 @@ export default {
TableCellBodyNetworks,
TableCellBodyMeeting,
ClientDetailInfoWrapper,
TheNotificationProvider,
},
data() {
return {
@@ -170,10 +174,15 @@ export default {
check: Function,
isCheck: Boolean,
client: Object,
rowOverlay: Boolean,
deletedClientId: String,
updateDataClient: Function,
url: String,
},
computed: {
rowOverlay() {
return this.deletedClientId === this.client.id;
},
},
methods: {
stopTimer() {
if (this.countdown !== 0) this.countdown = 0;
@@ -286,12 +295,21 @@ export default {
},
transmitDeleteClient() {
this.isOpenDetailInfo = false;
this.$emit("delete-client", this.dataClient.id);
this.$emit("delete-client", this.client.id);
},
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.$emit("update-clients");
},
addSuccessNotification() {
addNotification(
new Date().getTime(),
"Клиент Успешно удален",
"",
"success",
5000
);
},
fetchClientDetail(id) {
fetchWrapper
@@ -487,7 +505,7 @@ export default {
},
beforeUnmount() {
if (this.timer) {
this.deleteClient().then(() => this.updateDataClient());
this.deleteClient();
this.stopTimer();
}
},
@@ -520,7 +538,7 @@ export default {
.row-overlay
background: transparent
position: absolute
z-index: 100
z-index: 10
width: 100%
height: 100%
.row-overlay-color