Merge branch 'ASTRA-46' into 'master'

[WIP] Добавил выбор категорий и их отправку на форме контактов, исправил...

See merge request andrusyakka/urban-couscous!319
This commit is contained in:
Vasiliy Gavrilin
2023-04-19 14:18:42 +00:00
4 changed files with 133 additions and 89 deletions

View File

@@ -9,18 +9,22 @@
size="18px", size="18px",
style="color: var(--font-dark-blue-color)" style="color: var(--font-dark-blue-color)"
) )
.flex.flex-col(:style="{height: '457px'}") .field.flex.flex-col.overflow-y-scroll
.flex.items-center.h-10.gap-x-1(v-for="benefit in benefitData", :key="benefit.id") .flex.items-center(
v-for="benefit in benefitData",
:key="benefit.id",
:style="{alignItems: benefit.name.length > 28 ? 'start' : 'center'}"
)
q-checkbox( q-checkbox(
v-model="selected" v-model="selected",
:val="benefit", :val="benefit",
:style="{border: 'none', sidth: '36px'}", :style="{border: 'none', width: '36px'}",
size="32px" size="32px"
) )
.name.flex.h-10.items-center {{benefit.name}} .name.flex.items-center.font-medium.text-xm {{benefit.name}}
.buttons-group.flex.py-4.px-8.justify-center .buttons-group.flex.py-4.px-8.justify-center
base-button.text-base.font-semibold(outlined :size="40" @click="closeModalCategories") Отменить base-button.text-base.font-semibold(outlined, :size="40", @click="closeModalCategories") Отменить
base-button.text-base.font-semibold(:size="40") Сохранить base-button.text-base.font-semibold(:size="40", @click="saveCategories(selected[0])") Сохранить
.right-side.flex.px-14.font-bold.relative .right-side.flex.px-14.font-bold.relative
q-icon(name="app:icon-cancel").text-sm.absolute.top-4.right-4.cursor-pointer(@click="closeModalCategories") q-icon(name="app:icon-cancel").text-sm.absolute.top-4.right-4.cursor-pointer(@click="closeModalCategories")
.flex.py-10.gap-y-6.flex-col(v-if="selected.length > 0 && selected[0]?.name !== 'Без льготы'") .flex.py-10.gap-y-6.flex-col(v-if="selected.length > 0 && selected[0]?.name !== 'Без льготы'")
@@ -53,6 +57,7 @@ export default {
benefitData: Array, benefitData: Array,
shiftSelected: Function, shiftSelected: Function,
closeModalCategories: Function, closeModalCategories: Function,
saveCategories: Function,
}, },
data() { data() {
return { return {
@@ -81,6 +86,7 @@ export default {
}, },
}; };
</script> </script>
<style lang="sass" scoped> <style lang="sass" scoped>
.selection-wrapper .selection-wrapper
width: 895px width: 895px
@@ -90,7 +96,16 @@ export default {
width: 364px width: 364px
padding: 32px 28px 0px padding: 32px 28px 0px
.field
height: 457px
margin-right: -12px
&::-webkit-scrollbar
width: 4px
.name .name
min-height: 40px
padding-top: 4px
padding-bottom: 4px
border-bottom: 1px solid var(--bg-light-grey) border-bottom: 1px solid var(--bg-light-grey)
width: 268px width: 268px

View File

@@ -36,20 +36,24 @@
v-model="basic[photoId][field.key]" v-model="basic[photoId][field.key]"
:confirm-upload="confirmChangePhoto" :confirm-upload="confirmChangePhoto"
) )
.flex.w-full.h-10.relative(v-else-if="field.type === 'select'") .flex.h-10.relative(v-else-if="field.type === 'select'")
.flex(@click="showModalCategories = true") .flex(@click="openModalCategories")
q-field.items-center.cursor-pointer( q-field.items-center.cursor-pointer(
standout, standout,
:disable="!isEdit", :disable="!isEdit",
:outlined="isEdit" :outlined="isEdit",
) {{basic[insurance.insuranceKey][field.key]}} ) {{selectCategory(basic[insurance.insuranceKey][field.key])}}
base-modal( base-modal(
default-padding, default-padding,
hide-header, hide-header,
v-model="showModalCategories", v-model="showModalCategories",
title="Категории" title="Категории"
) )
base-category-selection(:benefit-data="benefitData" :close-modal-categories="closeModalCategories") base-category-selection(
:benefit-data="benefitData",
:close-modal-categories="closeModalCategories",
:save-categories="saveCategories"
)
.flex.font-medium.text-smm.absolute.top-10( .flex.font-medium.text-smm.absolute.top-10(
v-if="basic?.benefit[insurance?.discount]", v-if="basic?.benefit[insurance?.discount]",
:style="{color: 'var(--font-grey-color)'}" :style="{color: 'var(--font-grey-color)'}"
@@ -62,11 +66,12 @@
base-input( base-input(
v-model="basic[insurance.insuranceKey][field.key]", v-model="basic[insurance.insuranceKey][field.key]",
@update:model-value="checkChangeInput", @update:model-value="checkChangeInput",
:mask="field?.inputMask",
:disabled="!isEdit", :disabled="!isEdit",
:standout="!isEdit", :standout="!isEdit",
:outlined="isEdit", :outlined="isEdit",
:type="field.type", :type="field.type",
:width="300", :width="278",
text-color="black" text-color="black"
) )
</template> </template>
@@ -80,7 +85,6 @@ import { fetchWrapper } from "@/shared/fetchWrapper";
import BaseInput from "@/components/base/BaseInput.vue"; import BaseInput from "@/components/base/BaseInput.vue";
import BaseModal from "@/components/base/BaseModal.vue"; import BaseModal from "@/components/base/BaseModal.vue";
import BaseUploadPhoto from "@/components/base/BaseUploadPhoto.vue"; import BaseUploadPhoto from "@/components/base/BaseUploadPhoto.vue";
import { getRequestChangeData } from "@/shared/utils/wrapperRequestChangeData";
import BaseCategorySelection from "@/components/base/BaseCategorySelection.vue"; import BaseCategorySelection from "@/components/base/BaseCategorySelection.vue";
export default { export default {
@@ -119,6 +123,19 @@ export default {
}), }),
}, },
methods: { methods: {
selectCategory(str) {
return str && str.length > 30
? str.substr(0, 30) + "..."
: !str
? "Выберите категорию"
: str;
},
saveCategories(obj) {
this.showModalCategories = false;
this.basic.benefit.id = obj.id;
this.basic.benefit.name = obj.name;
this.isCheckChange = true;
},
changeModal(id) { changeModal(id) {
this.photoId = id; this.photoId = id;
this.showModal = true; this.showModal = true;
@@ -126,6 +143,9 @@ export default {
closeModalCategories() { closeModalCategories() {
this.showModalCategories = false; this.showModalCategories = false;
}, },
openModalCategories() {
if (this.isEdit) this.showModalCategories = true;
},
checkChangeInput() { checkChangeInput() {
this.isCheckChange = this.isCheckChange =
JSON.stringify(this.initDataBasic) !== JSON.stringify(this.basic) JSON.stringify(this.initDataBasic) !== JSON.stringify(this.basic)
@@ -140,46 +160,72 @@ export default {
let insuranceDMS = this.basic.insuranceDMS; let insuranceDMS = this.basic.insuranceDMS;
let insuranceOMS = this.basic.insuranceOMS; let insuranceOMS = this.basic.insuranceOMS;
let personal = this.basic.personalData; let personal = this.basic.personalData;
// let benefit = this.basic.benefit; let benefit = this.basic.benefit;
const insuranceFormDataDMS = new FormData(); const insuranceFormDataDMS = new FormData();
const insuranceFormDataOMS = new FormData(); const insuranceFormDataOMS = new FormData();
const benefitFormData = new FormData();
if (insuranceDMS.series && insuranceDMS.number) {
for (let key in insuranceDMS) {
if (insuranceDMS[key] && key !== "photo" && key !== "id")
insuranceFormDataDMS.append(key, insuranceDMS[key]);
}
}
if ( if (
insuranceDMS.photo.file && insuranceDMS.photo.file &&
insuranceDMS.photo.photo !== this.initDataBasic.insuranceDMS.photo.photo insuranceDMS.photo.photo !== this.initDataBasic.insuranceDMS.photo.photo
) )
insuranceFormDataDMS.append("photo", insuranceDMS.photo.file[0]); insuranceFormDataDMS.append("photo", insuranceDMS.photo.file[0]);
if (insuranceDMS.series) if (insuranceOMS.series && insuranceOMS.number) {
insuranceFormDataDMS.append("series", insuranceDMS.series); for (let key in insuranceOMS) {
if (insuranceOMS[key] && key !== "photo" && key !== "id")
if (insuranceDMS.number) insuranceFormDataOMS.append(key, insuranceOMS[key]);
insuranceFormDataDMS.append("number", insuranceDMS.number); }
}
if ( if (
insuranceOMS.photo.file && insuranceOMS.photo.file &&
insuranceOMS.photo.photo !== this.initDataBasic.insuranceOMS.photo.photo insuranceOMS.photo.photo !== this.initDataBasic.insuranceOMS.photo.photo
) )
insuranceFormDataOMS.append("photo", insuranceOMS.photo.file[0]); insuranceFormDataOMS.append("photo", insuranceOMS.photo.file[0]);
if (insuranceOMS.series)
insuranceFormDataOMS.append("series", insuranceOMS.series);
if (insuranceOMS.number)
insuranceFormDataOMS.append("number", insuranceOMS.number);
const request = Object.keys(this.basic).map((key) => { const request = Object.keys(this.basic).map((key) => {
if ( if (
key === "insuranceDMS" && key === "insuranceDMS" &&
(this.initDataBasic.insuranceDMS.series || !insuranceDMS?.id &&
this.initDataBasic.insuranceDMS.number) && insuranceDMS.series &&
this.isCheckChange insuranceDMS.number
) { ) {
insuranceFormDataDMS.append( insuranceFormDataDMS.append("title", "DMS");
"organization", insuranceFormDataDMS.append("person", personal.id);
insuranceDMS.organization return fetchWrapper.post(
`general/insurance_policy/create/`,
insuranceFormDataDMS,
"formData"
); );
}
if (
key === "insuranceOMS" &&
!insuranceOMS?.id &&
insuranceOMS.series &&
insuranceOMS.number
) {
insuranceFormDataOMS.append("title", "OMS");
insuranceFormDataOMS.append("person", personal.id);
return fetchWrapper.post(
`general/insurance_policy/create/`,
insuranceFormDataOMS,
"formData"
);
}
if (
key === "insuranceDMS" &&
insuranceDMS.id &&
(insuranceDMS.number ||
insuranceDMS.series ||
insuranceDMS.photo.file)
) {
insuranceFormDataDMS.append("title", "DMS"); insuranceFormDataDMS.append("title", "DMS");
return fetchWrapper.post( return fetchWrapper.post(
`general/insurance_policy/${insuranceDMS.id}/update/`, `general/insurance_policy/${insuranceDMS.id}/update/`,
@@ -189,14 +235,11 @@ export default {
} }
if ( if (
key === "insuranceOMS" && key === "insuranceOMS" &&
(this.initDataBasic.insuranceOMS.series || insuranceOMS.id &&
this.initDataBasic.insuranceOMS.number) && (insuranceOMS.number ||
this.isCheckChange insuranceOMS.series ||
insuranceOMS.photo.file)
) { ) {
insuranceFormDataOMS.append(
"organization",
insuranceOMS.organization
);
insuranceFormDataOMS.append("title", "OMS"); insuranceFormDataOMS.append("title", "OMS");
return fetchWrapper.post( return fetchWrapper.post(
`general/insurance_policy/${insuranceOMS.id}/update/`, `general/insurance_policy/${insuranceOMS.id}/update/`,
@@ -204,47 +247,21 @@ export default {
"formData" "formData"
); );
} }
if (key === "benefit" && benefit.id) {
fetchWrapper.post(`general/person/${personal.id}/update/`, {
benefit: benefit.id,
});
if ( if (
key === "insuranceDMS" && benefit.photo.file &&
!( benefit.photo.photo !== this.initDataBasic.benefit.photo.photo
this.initDataBasic.insuranceDMS.series ||
this.initDataBasic.insuranceDMS.number
)
) { ) {
delete insuranceDMS.photo; benefitFormData.append("photo_benefit", benefit.photo.file[0]);
let createInsuranceDMS = { return fetchWrapper.post(
person: personal.id, `general/person/${personal.id}/update/`,
title: "DMS", benefitFormData,
...insuranceDMS, "formData"
};
return getRequestChangeData(
createInsuranceDMS,
insuranceDMS,
{},
"insurance_policy",
insuranceDMS.id
); );
} }
if (
key === "insuranceOMS" &&
!(
this.initDataBasic.insuranceOMS.series ||
this.initDataBasic.insuranceOMS.number
)
) {
delete insuranceOMS.photo;
let createInsuranceOMS = {
person: personal.id,
title: "OMS",
...insuranceOMS,
};
return getRequestChangeData(
createInsuranceOMS,
insuranceOMS,
{},
"insurance_policy",
insuranceOMS.id
);
} }
}); });
return request; return request;
@@ -283,16 +300,13 @@ export default {
<style lang="sass" scoped> <style lang="sass" scoped>
.q-field :deep(.q-field__control) .q-field :deep(.q-field__control)
min-height: 40px min-height: 40px
min-width: 302px width: 302px
align-items: center align-items: center
background: rgba(0, 0, 0, 0.05) background: rgba(0, 0, 0, 0.05)
color: var(--font-dark-blue-color) color: var(--font-dark-blue-color)
.select
width: 324px
.avatar-field .avatar-field
min-width: 324px min-width: 302px
.avatar .avatar
height: 100% height: 100%

View File

@@ -246,11 +246,13 @@ export const baseInsuranceForm = [
key: "series", key: "series",
label: "Серия", label: "Серия",
type: "text", type: "text",
inputMask: "######",
}, },
{ {
key: "number", key: "number",
label: "Номер", label: "Номер",
type: "text", type: "text",
inputMask: "##########",
}, },
{ {
key: "photo", key: "photo",
@@ -267,11 +269,13 @@ export const baseInsuranceForm = [
key: "series", key: "series",
label: "Серия", label: "Серия",
type: "text", type: "text",
inputMask: "######",
}, },
{ {
key: "number", key: "number",
label: "Номер", label: "Номер",
type: "text", type: "text",
inputMask: "##########",
}, },
{ {
key: "photo", key: "photo",
@@ -290,6 +294,11 @@ export const baseInsuranceForm = [
label: "Категория", label: "Категория",
type: "select", type: "select",
}, },
{
key: "photo",
label: "Документы",
type: "avatar",
},
], ],
}, },
]; ];

View File

@@ -46,8 +46,8 @@ const state = () => ({
organization: null, organization: null,
}, },
benefit: { benefit: {
id: null,
name: null, name: null,
discount: null,
photo: null, photo: null,
}, },
}, },
@@ -128,7 +128,13 @@ const getters = {
}, },
benefit: { benefit: {
name: person?.benefit?.name, name: person?.benefit?.name,
discount: person?.benefit?.discount, id: person?.benefit?.id,
photo: person?.photo_benefit
? {
photo: rootState.getUrl + person?.photo_benefit,
file: null,
}
: {},
}, },
}; };
}, },