Skip to content

Commit

Permalink
Merge pull request #3240 from mikhailprivalov/code-and-id-in-price
Browse files Browse the repository at this point in the history
Прайсы - код и id на фронт
  • Loading branch information
urchinpro authored Nov 29, 2023
2 parents ea7a644 + febd52b commit 037a4f8
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 6 deletions.
14 changes: 11 additions & 3 deletions api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2655,13 +2655,19 @@ 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"]
)
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
)
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
)
if current_price:
current_price.save()
Log.log(
Expand All @@ -2673,6 +2679,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 @@ -2698,6 +2705,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 @@ -68,7 +68,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

0 comments on commit 037a4f8

Please sign in to comment.