Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Прайсы - код и id на фронт #3240

Merged
merged 7 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2651,13 +2651,16 @@ def update_price(request):
current_price = None
if request_data["id"] == -1:
if request_data.get("typePrice") == "Работодатель":
current_price = PriceName(title=request_data["title"], date_start=request_data["start"], date_end=request_data["end"], company_id=request_data["company"])
current_price = PriceName(title=request_data["title"], symbol_code=request_data["code"], date_start=request_data["start"], date_end=request_data["end"],
company_id=request_data["company"])
Wellheor1 marked this conversation as resolved.
Show resolved Hide resolved
Wellheor1 marked this conversation as resolved.
Show resolved Hide resolved
elif request_data.get("typePrice") == "Заказчик":
hospital = Hospitals.objects.filter(pk=int(request_data["company"])).first()
current_price = PriceName(title=request_data["title"], date_start=request_data["start"], date_end=request_data["end"], hospital=hospital, subcontract=True)
current_price = PriceName(title=request_data["title"], symbol_code=request_data["code"], date_start=request_data["start"], date_end=request_data["end"], hospital=hospital,
subcontract=True)
Wellheor1 marked this conversation as resolved.
Show resolved Hide resolved
Wellheor1 marked this conversation as resolved.
Show resolved Hide resolved
Wellheor1 marked this conversation as resolved.
Show resolved Hide resolved
elif request_data.get("typePrice") == "Внешний исполнитель":
hospital = Hospitals.objects.filter(pk=int(request_data["company"])).first()
current_price = PriceName(title=request_data["title"], date_start=request_data["start"], date_end=request_data["end"], hospital=hospital, external_performer=True)
current_price = PriceName(title=request_data["title"], symbol_code=request_data["code"], date_start=request_data["start"], date_end=request_data["end"], hospital=hospital,
external_performer=True)
Wellheor1 marked this conversation as resolved.
Show resolved Hide resolved
Wellheor1 marked this conversation as resolved.
Show resolved Hide resolved
Wellheor1 marked this conversation as resolved.
Show resolved Hide resolved
Wellheor1 marked this conversation as resolved.
Show resolved Hide resolved
if current_price:
current_price.save()
Log.log(
Expand All @@ -2669,6 +2672,7 @@ def update_price(request):
else:
current_price = PriceName.objects.get(pk=request_data["id"])
current_price.title = request_data["title"]
current_price.symbol_code = request_data["code"]
current_price.date_start = request_data["start"]
current_price.date_end = request_data["end"]
if request_data.get("typePrice") == "Заказчик" or request_data.get("typePrice") == "Работодатель":
Expand All @@ -2694,6 +2698,7 @@ def copy_price(request):
current_price = PriceName.objects.get(pk=request_data["id"])
new_price = PriceName(
title=f"{current_price.title} - новый прайс",
symbol_code=f"{current_price.symbol_code} - новый",
date_start=current_price.date_start,
date_end=current_price.date_end,
company=current_price.company,
Expand Down
11 changes: 10 additions & 1 deletion contracts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,16 @@ def as_json(price):
else:
company_title = ""
company_id = ""
json_data = {"id": price.id, "title": price.title, "start": price.date_start, "end": price.date_end, "company": company_id, "companyTitle": company_title, "uuid": str(price.uuid)}
json_data = {
"id": price.id,
"title": price.title,
"code": price.symbol_code,
"start": price.date_start,
"end": price.date_end,
"company": company_id,
"companyTitle": company_title,
"uuid": str(price.uuid),
}
return json_data

@staticmethod
Expand Down
30 changes: 28 additions & 2 deletions l2-frontend/src/construct/ConstructPrice.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<col width="240">
<col width="120">
<col width="120">
<col width="120">
<col>
<col
v-if="priceIsActive"
Expand All @@ -31,6 +32,9 @@
<th class="text-center">
<strong>Название</strong>
</th>
<th class="text-center">
<strong>Код</strong>
</th>
<th class="text-center">
<strong>Дата начала</strong>
</th>
Expand All @@ -51,6 +55,13 @@
:disabled="!priceIsActive"
>
</td>
<td class="border">
<input
v-model="priceData.code"
class="form-control"
:disabled="!priceIsActive"
>
</td>
<td class="border">
<input
v-model="priceData.start"
Expand Down Expand Up @@ -116,12 +127,20 @@
v-if="priceIsSelected"
class="height-row border"
>
<td class="border text-center">
<strong>ID</strong>
</td>
<td
class="padding-left"
>
{{ priceData.id }}
</td>
<td class="border text-center">
<strong>UUID</strong>
</td>
<td
class=" padding-left"
:colspan="priceIsActive ? 4 : 3"
class="padding-left"
:colspan="priceIsActive ? 3 : 2"
>
{{ priceData.uuid }}
</td>
Expand Down Expand Up @@ -379,7 +398,9 @@ export default {
selectedPrice() {
if (!this.selectedPrice) {
this.priceData = {
id: -1,
title: '',
code: '',
start: '',
end: '',
company: null,
Expand Down Expand Up @@ -454,6 +475,7 @@ export default {
const { ok, message } = await this.$api('update-price', {
id: this.selectedPrice,
title: this.priceData.title,
code: this.priceData.code,
start: this.priceData.start,
end: this.priceData.end,
company: this.priceData.company,
Expand All @@ -471,6 +493,7 @@ export default {
const { ok, message } = await this.$api('update-price', {
id: -1,
title: this.priceData.title,
code: this.priceData.code,
start: this.priceData.start,
end: this.priceData.end,
company: this.priceData.company,
Expand All @@ -481,10 +504,13 @@ export default {
this.$root.$emit('msg', 'ok', 'Прайс добавлен');
await this.getPrices();
this.priceData = {
id: -1,
title: '',
code: '',
start: '',
end: '',
company: null,
uuid: '',
};
} else {
this.$root.$emit('msg', 'error', message);
Expand Down
Loading