Настроил добавление для ранее существующего кода
This commit is contained in:
parent
0ebbee5e23
commit
93e78e2b77
@ -27,45 +27,50 @@ export default class Mocks extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Watch('personalCode', { immediate: true })
|
@Watch('personalCode', { immediate: true })
|
||||||
onPersonalCodeChanged (value: string, oldValue: string) {
|
onPersonalCodeChanged () {
|
||||||
|
this.refreshMocks()
|
||||||
|
}
|
||||||
|
|
||||||
|
refreshMocks () {
|
||||||
this.mode === Mode.UPDATE && httpClient.mockConfigurations({ personalCode: this.personalCode })
|
this.mode === Mode.UPDATE && httpClient.mockConfigurations({ personalCode: this.personalCode })
|
||||||
.then((data: any) => {
|
.then((data: any) => {
|
||||||
|
const existServiceKeys = []
|
||||||
for (const mockConfiguration of data.data) {
|
for (const mockConfiguration of data.data) {
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.registers[mockConfiguration.code] = mockConfiguration.value
|
this.registers[mockConfiguration.code] = mockConfiguration.value
|
||||||
this.register2Id[mockConfiguration.code] = mockConfiguration.id
|
this.register2Id[mockConfiguration.code] = mockConfiguration.id
|
||||||
|
existServiceKeys.push(mockConfiguration.code)
|
||||||
|
}
|
||||||
|
for (const serviceCode in this.registers) {
|
||||||
|
if (existServiceKeys.indexOf(serviceCode) > -1) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
||||||
|
// @ts-ignore
|
||||||
|
this.registers[serviceCode] = ''
|
||||||
|
delete this.register2Id[serviceCode]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onXteeMtaChanged () {
|
async onServiceChanged (serviceKey: string) {
|
||||||
if (this.mode !== Mode.UPDATE) {
|
if (this.mode !== Mode.UPDATE) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (this.register2Id.xtee_mta === 'undefined') {
|
if (typeof this.register2Id[serviceKey] === 'undefined') {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
||||||
|
// @ts-ignore
|
||||||
|
await this.saveMock(this.personalCode, serviceKey, Number(this.registers[serviceKey]))
|
||||||
|
await this.refreshMocks()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
httpClient.changeMockValueConfiguration({
|
|
||||||
id: this.register2Id.xtee_mta,
|
|
||||||
value: this.registers.xtee_mta
|
|
||||||
})
|
|
||||||
.then((data: any) => {
|
|
||||||
console.log('updateMock')
|
|
||||||
console.log(data)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
onRiaChanged () {
|
|
||||||
if (this.mode !== Mode.UPDATE) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (this.register2Id.ria === 'undefined') {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
httpClient.changeMockValueConfiguration({
|
httpClient.changeMockValueConfiguration({
|
||||||
id: this.register2Id.ria,
|
id: this.register2Id[serviceKey],
|
||||||
value: this.registers.ria
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
||||||
|
// @ts-ignore
|
||||||
|
value: this.registers[serviceKey]
|
||||||
})
|
})
|
||||||
.then((data: any) => {
|
.then((data: any) => {
|
||||||
console.log('updateMock')
|
console.log('updateMock')
|
||||||
@ -94,4 +99,19 @@ export default class Mocks extends Vue {
|
|||||||
console.log(data)
|
console.log(data)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
saveMock (personalCode: string, serviceCode: string, value: number): Promise<any> {
|
||||||
|
const mockConfigurations: MockConfiguration[] = []
|
||||||
|
const mockConfiguration = new MockConfiguration()
|
||||||
|
mockConfiguration.personalCode = personalCode
|
||||||
|
mockConfiguration.code = serviceCode
|
||||||
|
mockConfiguration.value = value
|
||||||
|
mockConfiguration.active = 'true'
|
||||||
|
mockConfigurations.push(mockConfiguration)
|
||||||
|
return httpClient.addMockConfigurations({ items: mockConfigurations })
|
||||||
|
.then((data: any) => {
|
||||||
|
console.log('saveMocks')
|
||||||
|
console.log(data)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<div>XTEE MTA</div>
|
<div>XTEE MTA</div>
|
||||||
<div>
|
<div>
|
||||||
<select class="option-select" v-model="registers.xtee_mta" @change="onXteeMtaChanged">
|
<select class="option-select" v-model="registers.xtee_mta" @change="onServiceChanged('xtee_mta')">
|
||||||
<option value="-1">-</option>
|
<option value="-1">-</option>
|
||||||
<option value="0">Не замокано (делать запрос)</option>
|
<option value="0">Не замокано (делать запрос)</option>
|
||||||
<option value="1">Выписка на хороший доход</option>
|
<option value="1">Выписка на хороший доход</option>
|
||||||
@ -20,7 +20,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<div>XTEE RIA</div>
|
<div>XTEE RIA</div>
|
||||||
<div>
|
<div>
|
||||||
<select class="option-select" v-model="registers.ria" @change="onRiaChanged">
|
<select class="option-select" v-model="registers.ria" @change="onServiceChanged('ria')">
|
||||||
<option value="-1">-</option>
|
<option value="-1">-</option>
|
||||||
<option value="0">Не замокано (делать запрос)</option>
|
<option value="0">Не замокано (делать запрос)</option>
|
||||||
<option value="1">Успешный запрос</option>
|
<option value="1">Успешный запрос</option>
|
||||||
|
Loading…
Reference in New Issue
Block a user