Zmodyfikuj pliki aplikacji Vue.js printer-posnet.ts oraz printer-posnet-card.vue, aby były przystosowane do przesyłania danych do ASP.NET zgodnie z PrinterPosnetDto.cs.

///  PrinterPosnetDto.cs

public class PrinterPosnetDto : EntityDto<Guid>
{
    public string Name { get; set; }

    public string Model { get; set; }

    public string IpAddress { get; set; }

    public string Port { get; set; }

    public bool IsActive { get; set; }

    public int Target { get; set; }

    public int TenantId { get; set; }

    public long OrganizationUnitId { get; set; }

    public string OrganizationUnitName { get; set; }
}

/// printer-posnet.ts

import { GenericEntity } from "@/views/commerce/common/named-item";
import PrinterPosnetStatus from "@/views/commerce/printers-posnet/printer-posnet-status";
import PrinterPosnetTarget from "@/views/commerce/printers-posnet/printer-posnet-target";
import type { SelectPanelOption } from "@/components/action-buttons/select-panel-option";

export default class PrinterPosnet extends GenericEntity implements SelectPanelOption {
  id: string;
  orgUnitId: number;
  name: string | null;
  target: PrinterPosnetTarget = PrinterPosnetTarget.instance.reception;
  status: PrinterPosnetStatus = PrinterPosnetStatus.empty();
  ipAddress: string | null = null;

  public static fromDto(dto: any): PrinterPosnet {
    const entity = new PrinterPosnet();
    entity.readDto(dto);
    return entity;
  }

  public static empty(): PrinterPosnet {
    const entity = new PrinterPosnet();
    entity.id = "";
    entity.orgUnitId = 0;
    entity.name = null;
    entity.ipAddress = null;
    return entity;
  }

  protected readDto(dto: any) {
    super.readDto(dto);
    this.id = dto.id;
    this.orgUnitId = dto.orgUnitId;
    this.name = dto.name;
    this.target = PrinterPosnetTarget.getById(dto.target);
    this.status = dto.status ? PrinterPosnetStatus.fromDto(dto.status) : PrinterPosnetStatus.empty();
    this.ipAddress = dto.ipAddress;
    this.model = dto.model;
  }

  get displayName() {
    if (this.name) return `${this.name} (${this.id})`;
    return this.id;
  }

  get dto(): any {
    return {
      id: this.id,
      orgUnitId: this.orgUnitId,
      name: this.name,
      target: this.target.id,
      status: this.status,
      ipAddress: this.ipAddress,
      model: this.model
    };
  }
}

/// printer-posnet-card.vue

<template>
    <titled-card :title="title" toolbar close-button @close="discard">
      <loading-container
        :is-loaded="isLoaded"
        fluid
        class="ma-1 pa-0 pr-3"
        style="min-width: min(700px, 95vw)">
        <v2-form :validator="formRef">
          <v-row dense>
            <v-col>
              <v2-text-field
                v-model="model.name"
                :rules="nameRules"
                :readonly="readonly"
                class="mb-2"
                label="Nazwa" />
            </v-col>
            <v-col>
              <v2-text-field
                v-model="model.model"
                :rules="modelRules"
                :readonly="readonly"
                class="mb-2"
                label="Model" />
            </v-col>
          </v-row>

          <v-row dense>
            <v-col>
              <v2-text-field
                v-model="model.ipAddress"
                :rules="ipAddressRules"
                :readonly="readonly"
                class="mb-2"
                label="Adres IP" />
            </v-col>
            <v-col>
              <v2-autocomplete
                v-model="model.target.id"
                :items="printerTargets"
                :readonly="readonly"
                label="Cel"
                placeholder="Wybierz z listy" />
            </v-col>
          </v-row>

          <v-row dense>
            <v-col>
              <v2-select
                v-model="model.status.id"
                :items="printerStatuses"
                :readonly="readonly"
                label="Status"
                placeholder="Wybierz status" />
            </v-col>
            <v-col>
              <v2-text-field
                v-model="model.orgUnitId"
                :rules="orgUnitIdRules"
                :readonly="readonly"
                class="mb-2"
                label="Jednostka Organizacyjna ID" />
            </v-col>
          </v-row>

          <v-row justify="end">
            <v-col cols="auto">
              <submit-discard-async-buttons :submit="submit" @discard="discard" />
            </v-col>
          </v-row>
        </v2-form>
      </loading-container>
    </titled-card>
  </template>

  <script lang="ts">
  import { computed, defineComponent, onMounted, ref } from "@vue/composition-api";
  import LoadingContainer from "@/components/loading/loading-container.vue";
  import SubmitDiscardAsyncButtons from "@/components/action-buttons/submit-discard-async-buttons.vue";
  import axios from "@/lib/axios";
  import TitledCard from "@/components/simple/titled-card.vue";
  import { RulesUtils } from "@/lib/rules-utils";
  import PrinterPosnetTarget from "@/views/commerce/printers-posnet/printer-posnet-target";
  import PrinterPosnetStatus from "@/views/commerce/printers-posnet/printer-posnet-status";
  import V2Form from "@/compatibility-layer/components/v2-form.vue";
  import V2TextField from "@/compatibility-layer/components/v2-text-field.vue";
  import V2Autocomplete from "@/compatibility-layer/components/v2-autocomplete.vue";
  import V2Select from "@/compatibility-layer/components/v2-select.vue";
  import V2FormValidator from "@/compatibility-layer/components/v2-form-validator";

  const PrinterPosnetCard = defineComponent({
    components: {
      TitledCard,
      SubmitDiscardAsyncButtons,
      V2Autocomplete,
      V2TextField,
      V2Form,
      V2Select,
      LoadingContainer
    },

    props: {
      value: {
        type: String,
        required: false,
        default: null
      },

      readonly: {
        type: Boolean,
        required: false,
        default: false
      }
    },

    emits: ["close"],

    setup(props, context) {
      const isLoaded = ref(false);
      const model = ref(props.value ? new PrinterPosnet() : PrinterPosnet.empty());
      const formRef = ref(V2FormValidator.create());

      const printerTargets = ref(PrinterPosnetTarget.All);
      const printerStatuses = ref(PrinterPosnetStatus.All);

      onMounted(async () => {
        await loadData();
      });

      const loadData = async () => {
        if (props.value) {
          const response = await axios.get("/api/services/app/PrinterPosnet/GetPrinter", {
            params: { id: props.value }
          });
          model.value = PrinterPosnet.fromDto(response.data.result);
        }

        isLoaded.value = true;
      };

      const isNew = computed(() => !props.value);

      const submit = async () => {
        if (!formRef.value.validate()) return;

        if (isNew.value) {
          await axios.post("/api/services/app/PrinterPosnet/CreatePrinter", model.value.dto);
        } else {
          await axios.put("/api/services/app/PrinterPosnet/UpdatePrinter", model.value.dto);
        }

        context.emit("close", true);
      };

      const title = computed(() => {
        const prefix = "Zarządzanie Drukarkami Posnet";
        const suffix = isNew.value ? "Nowa drukarka" : `Edycja drukarki: ${model.value.name}`;
        return `${prefix} - ${suffix}`;
      });

      const nameRules = RulesUtils.MandatoryString(128);
      const modelRules = RulesUtils.MandatoryString(64);
      const ipAddressRules = [
        v => /^(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)$/.test(v) || "Niepoprawny adres IP"
      ];
      const orgUnitIdRules = [
        v => (!!v && Number(v) > 0) || "Niepoprawne ID jednostki organizacyjnej"
      ];

      return {
        isLoaded,
        model,
        formRef,
        submit,
        discard: () => context.emit("close", false),
        nameRules,
        modelRules,
        ipAddressRules,
        orgUnitIdRules,
        printerTargets: printerTargets.value,
        printerStatuses: printerStatuses.value,
        title
      };
    }
  });

  export default PrinterPosnetCard;
  </script>