Skip to content

Commit

Permalink
Merge pull request #3398 from mikhailprivalov/constuct-laboratory-v5
Browse files Browse the repository at this point in the history
Конструктор лаборатории - v5
  • Loading branch information
urchinpro authored Jan 20, 2024
2 parents 980d0bd + 79302eb commit b946f53
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 60 deletions.
10 changes: 5 additions & 5 deletions directory/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,16 +677,16 @@ def update_lab_research(research_data):
current_fractions = None
fraction_title = fraction["title"].strip() if fraction["title"] else ''
ecp_id = fraction["ecpId"].strip() if fraction["ecpId"] else ''
unit_id = fraction["unitId"] if fraction["unitId"] != -1 else None
unit_id = fraction.get("unitId", None)
ref_m, ref_f = Fractions.convert_ref(fraction["refM"], fraction["refF"], True)
if fractions:
current_fractions = fractions.filter(pk=fraction["id"]).first()
if current_fractions:
current_fractions.title = fraction_title
current_fractions.ecp_id = fraction["ecpId"].strip()
current_fractions.fsli = fraction["fsli"]
current_fractions.ecp_id = ecp_id
current_fractions.fsli = fraction.get("fsli", None)
current_fractions.sort_weight = fraction["order"]
current_fractions.unit_id = fraction["unitId"]
current_fractions.unit_id = unit_id
current_fractions.variants_id = fraction.get("variantsId", None)
current_fractions.formula = fraction["formula"]
current_fractions.ref_m = ref_m
Expand Down Expand Up @@ -1088,7 +1088,7 @@ def get_units():
result = [
{
"id": unit.pk,
"label": unit.title,
"label": f'{unit.short_title}{unit.title} - {unit.code}',
}
for unit in Unit.objects.filter(hide=False)
]
Expand Down
61 changes: 57 additions & 4 deletions l2-frontend/src/construct/ConstructLaboratory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
@changeVisibility="changeVisibility"
@edit="edit"
@add="add"
@editRelationTube="editRelation"
/>
<div
v-if="filteredResearchTubes.length === 0"
Expand All @@ -49,6 +50,44 @@
@updateResearch="getTubes"
/>
</div>
<Modal
v-if="showModal"
ref="modal"
margin-top="30px"
margin-left-right="auto"
max-width="1500px"
height="700px"
show-footer="true"
white-bg="true"
width="100%"
@close="hideModal"
>
<span slot="header">Настройка ёмкости ({{ editTubeId }}) </span>
<div
slot="body"
>
<iframe
id="myframe"
width="1470"
height="605"
:src="`/ui/construct/related-tube/${editTubeId}`"
/>
</div>
<div slot="footer">
<div class="row">
<div class="col-xs-10" />
<div class="col-xs-2">
<button
class="btn btn-primary-nb btn-blue-nb"
type="button"
@click="hideModal"
>
Закрыть
</button>
</div>
</div>
</div>
</Modal>
</div>
</template>

Expand All @@ -65,6 +104,7 @@ import * as actions from '@/store/action-types';
import api from '@/api';
import ResearchDetail from '@/construct/ResearchDetail.vue';
import ResearchesGroup from '@/construct/ResearchesGroup.vue';
import Modal from '@/ui-cards/Modal.vue';
const store = useStore();
const root = getCurrentInstance().proxy.$root;
Expand Down Expand Up @@ -92,9 +132,6 @@ const getTubes = async () => {
const { result } = await api('construct/laboratory/get-tubes', { department_id: department.value });
await store.dispatch(actions.DEC_LOADING);
researchTubes.value = result;
currentResearch.value = {
pk: null, order: 1, departmentId: department.value, tubes: null,
};
};
const edit = ({ researchPk }) => {
Expand Down Expand Up @@ -182,6 +219,22 @@ const getRefbooks = async () => {
refBooks.value = result;
};
const showModal = ref(false);
const editTubeId = ref(-1);
const editRelation = ({ relationId }) => {
editTubeId.value = relationId;
showModal.value = true;
};
const modal = ref(null);
const hideModal = () => {
getTubes();
showModal.value = false;
if (modal.value) {
modal.value.$el.style.display = 'none';
}
};
onMounted(() => {
getDepartments();
getRefbooks();
Expand All @@ -192,7 +245,7 @@ onMounted(() => {
<style scoped lang="scss">
.two-col {
display: grid;
grid-template-columns: minmax(200px, 450px) minmax(150px, auto);
grid-template-columns: minmax(200px, 380px) minmax(150px, auto);
margin-bottom: 5px;
height: calc(100vh - 36px);
}
Expand Down
28 changes: 19 additions & 9 deletions l2-frontend/src/construct/FractionsGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
v-tippy
:title="fraction.title"
class="form-control fraction-input"
placeholder="Введите название фракции"
placeholder="Введите название"
>
</td>
<td class="padding-td">
Expand Down Expand Up @@ -88,6 +88,13 @@
>
{{ node.raw.id || fraction.fsli }}
</div>
<label
slot="option-label"
slot-scope="{ node }"
v-tippy
:title="node.label"
class="fsli-options"
> {{ node.label }}</label>
</Treeselect>
</td>
<td>
Expand Down Expand Up @@ -152,14 +159,10 @@ const sortedFractions = computed(() => {
});
const minMaxOrder = computed(() => {
let min = 0;
let max = 0;
let min = sortedFractions.value[0].order;
let max = sortedFractions.value[0].order;
for (const fraction of sortedFractions.value) {
if (min === 0) {
min = fraction.order;
} else {
min = Math.min(min, fraction.order);
}
min = Math.min(min, fraction.order);
max = Math.max(max, fraction.order);
}
return { min, max };
Expand Down Expand Up @@ -194,7 +197,7 @@ const getFsli = async ({ action, searchQuery, callback }) => {
callback(
null,
data.map(i => (
{ id: i.code_fsli, label: `${i.title}-${i.short_title}-${i.sample}-${i.synonym}-${i.nmu}` }
{ id: i.code_fsli, label: `${i.code_fsli} ${i.title}-${i.short_title}-${i.sample}-${i.synonym} ${i.nmu}` }
)),
);
}
Expand Down Expand Up @@ -297,4 +300,11 @@ const addFraction = () => {
display: flex;
width: 30px;
}
.fsli-options {
font-size: 12px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
margin-bottom: 0
}
</style>
81 changes: 59 additions & 22 deletions l2-frontend/src/construct/ResearchDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,22 @@
:key="idx"
class="flex ref-row"
>
<input
v-model="refM.age"
class="form-control reference-input-left"
>
<input
v-model="refM.value"
class="form-control reference-input-right"
>
<div>
<label>Возраст</label>
<input
v-model="refM.age"
class="form-control reference-input-left"
>
</div>
<div>
<label>Значение</label>
<input
v-model="refM.value"
class="form-control reference-input-right"
>
</div>
<button
class="reference-button-right transparent-button "
class="reference-button-right transparent-button ref-button"
@click="deleteRef(idx, 'm')"
>
<i class="fa fa-times" />
Expand All @@ -212,16 +218,22 @@
:key="idx"
class="flex ref-row"
>
<input
v-model="refF.age"
class="form-control reference-label-left"
>
<input
v-model="refF.value"
class="form-control reference-label-right"
>
<div>
<label>Возраст</label>
<input
v-model="refF.age"
class="form-control reference-input-left"
>
</div>
<div>
<label>Значение</label>
<input
v-model="refF.value"
class="form-control reference-input-right"
>
</div>
<button
class="transparent-button reference-button-right"
class="transparent-button reference-button-right ref-button"
@click="deleteRef(idx, 'f')"
>
<i class="fa fa-times" />
Expand All @@ -247,8 +259,28 @@
v-model="selectedTubes"
value-format="object"
class="treeselect-34px"
placeholder="Выберите ёмкость"
:options="props.refBooks.tubes"
/>
>
<div
slot="value-label"
slot-scope="{ node }"
>
<ColorTitled
:title="node.label"
:color="node.raw.color"
/>
</div>
<div
slot="option-label"
slot-scope="{ node }"
>
<ColorTitled
:title="node.label"
:color="node.raw.color"
/>
</div>
</Treeselect>
</div>
<div>
<button
Expand Down Expand Up @@ -284,6 +316,7 @@ import * as actions from '@/store/action-types';
import api from '@/api';
import FractionsGroup from '@/construct/FractionsGroup.vue';
import { refBook } from '@/construct/ConstructLaboratory.vue';
import ColorTitled from '@/ui-cards/ColorTitled.vue';
const store = useStore();
Expand Down Expand Up @@ -348,7 +381,7 @@ interface researchData {
const selectedTubes = ref({
id: -1,
label: '',
label: 'Выберите ёмкость',
color: '',
});
const researchShortTitle = ref('');
Expand Down Expand Up @@ -448,6 +481,7 @@ const updateResearch = async () => {
await store.dispatch(actions.DEC_LOADING);
if (ok) {
root.$emit('msg', 'ok', 'Обновлено');
await getResearch();
emit('updateResearch');
} else {
root.$emit('msg', 'error', 'Ошибка');
Expand Down Expand Up @@ -548,7 +582,7 @@ const deleteRef = (idx: number, refKey: string) => {
.research-fractions {
display: grid;
position: relative;
grid-template-columns: repeat(auto-fit, minmax(200px, auto) minmax(150px, 350px));
grid-template-columns: repeat(auto-fit, minmax(200px, auto) minmax(150px, 290px));
height: calc(100vh - 365px);
}
.fraction-group {
Expand Down Expand Up @@ -606,7 +640,7 @@ const deleteRef = (idx: number, refKey: string) => {
.transparent-button {
background-color: transparent;
align-self: stretch;
align-self: flex-end;
color: #434A54;
border: 1px solid #AAB2BD;
border-radius: 4px;
Expand All @@ -622,4 +656,7 @@ const deleteRef = (idx: number, refKey: string) => {
.ref-row {
margin-bottom: 2px;
}
.ref-button {
padding: 6px 6px;
}
</style>
Loading

0 comments on commit b946f53

Please sign in to comment.