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 .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)

View File

@@ -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",

View File

@@ -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;
@@ -286,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
@@ -487,7 +505,7 @@ export default {
}, },
beforeUnmount() { beforeUnmount() {
if (this.timer) { if (this.timer) {
this.deleteClient().then(() => this.updateDataClient()); this.deleteClient();
this.stopTimer(); this.stopTimer();
} }
}, },
@@ -520,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