Merge pull request #173 from dderbentsov/UC-98
WIP Сделала запрет на удаление более 1го клиента
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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",
|
||||
@@ -93,8 +93,10 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
updateDataClient() {
|
||||
if (this.dataClients.find(({ id }) => id === this.deletedRowId)) {
|
||||
if (this.dataClients.length === 1) this.currentTablePage -= 1;
|
||||
else this.fetchDataClients();
|
||||
}
|
||||
},
|
||||
saveDataClients(data) {
|
||||
this.dataClients = data.results;
|
||||
|
||||
@@ -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;
|
||||
@@ -189,8 +198,10 @@ export default {
|
||||
},
|
||||
changeCountdown() {
|
||||
if (this.countdown === 0) {
|
||||
this.deleteClient().then(() => {
|
||||
this.updateDataClient();
|
||||
this.stopTimer();
|
||||
this.deleteClient().then(() => this.updateDataClient());
|
||||
});
|
||||
} else {
|
||||
this.countdown -= 1;
|
||||
}
|
||||
@@ -284,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
|
||||
@@ -483,9 +503,12 @@ export default {
|
||||
photo: this.client.photo,
|
||||
};
|
||||
},
|
||||
/*beforeUnmount() {
|
||||
beforeUnmount() {
|
||||
if (this.timer) {
|
||||
this.deleteClient();
|
||||
this.stopTimer();
|
||||
},*/
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -515,7 +538,7 @@ export default {
|
||||
.row-overlay
|
||||
background: transparent
|
||||
position: absolute
|
||||
z-index: 100
|
||||
z-index: 10
|
||||
width: 100%
|
||||
height: 100%
|
||||
.row-overlay-color
|
||||
|
||||
Reference in New Issue
Block a user