|
|
|
@ -1,4 +1,4 @@ |
|
|
|
|
import { Component, Prop, Vue } from 'vue-property-decorator' |
|
|
|
|
import { Component, Prop, Vue, Watch } from 'vue-property-decorator' |
|
|
|
|
import VueClipboard from 'vue-clipboard2' |
|
|
|
|
import { Registers } from '@/classes/DTO/Registers' |
|
|
|
|
import httpClient from '@/api/Main/HttpClient' |
|
|
|
@ -6,15 +6,51 @@ import { MockConfiguration } from '@/api/Main/Schemas/AddMockSchema' |
|
|
|
|
|
|
|
|
|
Vue.use(VueClipboard) |
|
|
|
|
|
|
|
|
|
export enum Mode { |
|
|
|
|
ADD = 'add', |
|
|
|
|
UPDATE = 'update', |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Component |
|
|
|
|
export default class Mocks extends Vue { |
|
|
|
|
@Prop() |
|
|
|
|
personalCode!: string |
|
|
|
|
|
|
|
|
|
mode: Mode = Mode.ADD |
|
|
|
|
registers = new Registers() |
|
|
|
|
register2Id: Record<string, string> = {} |
|
|
|
|
|
|
|
|
|
mounted () { |
|
|
|
|
console.log('mounted') |
|
|
|
|
console.log('mounted', this.personalCode) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Watch('personalCode', { immediate: true }) |
|
|
|
|
onPersonalCodeChanged (value: string, oldValue: string) { |
|
|
|
|
this.mode = Mode.ADD |
|
|
|
|
httpClient.mockConfigurations({ personalCode: this.personalCode }) |
|
|
|
|
.then((data: any) => { |
|
|
|
|
for (const mockConfiguration of data.data) { |
|
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
this.registers[mockConfiguration.code] = mockConfiguration.value |
|
|
|
|
this.register2Id[mockConfiguration.code] = mockConfiguration.id |
|
|
|
|
this.mode = Mode.UPDATE |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
onXteeMtaChanged () { |
|
|
|
|
if (this.register2Id.xtee_mta === 'undefined') { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
httpClient.changeMockValueConfiguration({ |
|
|
|
|
id: this.register2Id.xtee_mta, |
|
|
|
|
value: this.registers.xtee_mta |
|
|
|
|
}) |
|
|
|
|
.then((data: any) => { |
|
|
|
|
console.log('updateMock') |
|
|
|
|
console.log(data) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
saveMocks () { |
|
|
|
@ -23,6 +59,7 @@ export default class Mocks extends Vue { |
|
|
|
|
const mockConfiguration = new MockConfiguration() |
|
|
|
|
mockConfiguration.personalCode = this.personalCode |
|
|
|
|
mockConfiguration.code = serviceCode |
|
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
mockConfiguration.value = this.registers[serviceCode] |
|
|
|
|
if (!mockConfiguration.value) { |
|
|
|
|