diff --git a/api-test/frontend/src/business/automation/scenario/variable/EditCsv.vue b/api-test/frontend/src/business/automation/scenario/variable/EditCsv.vue index 67c850b9d3..174a87b078 100644 --- a/api-test/frontend/src/business/automation/scenario/variable/EditCsv.vue +++ b/api-test/frontend/src/business/automation/scenario/variable/EditCsv.vue @@ -13,7 +13,7 @@ :placeholder="$t('commons.input_content')" :autosize="{ minRows: 2, maxRows: 10 }" :rows="2" - size="small" /> + size="small"/> @@ -22,7 +22,7 @@ {{ $t('variables.add_file') }} - + @@ -44,7 +44,7 @@ {{ $t('variables.delimiter') }} - + @@ -53,15 +53,16 @@ - - + +
{{ $t('variables.csv_message') }}
- + -
+
{{ $t('commons.more_operator') }} - + @@ -138,34 +140,45 @@ - +
- - - - - + + + + +
- + {{ $t('commons.confirm') }} {{ $t('commons.cancel') }} + >{{ $t('commons.cancel') }} - + {{ $t('commons.delete') }}
@@ -182,7 +195,7 @@ placement="top-start" slot="label"> {{ $t('api_test.request.headers') }} + >{{ $t('api_test.request.headers') }}
{{ headers.length - 1 }} @@ -196,19 +209,22 @@
- - + +
@@ -227,19 +243,18 @@ import MsEditCounter from './EditCounter'; import MsEditRandom from './EditRandom'; import MsEditListValue from './EditListValue'; import MsEditCsv from './EditCsv'; -import {downloadFile, getUUID} from 'metersphere-frontend/src/utils'; +import { downloadFile, getUUID } from 'metersphere-frontend/src/utils'; import MsApiKeyValue from '../../../definition/components/ApiKeyValue'; import BatchAddParameter from '../../../definition/components/basis/BatchAddParameter'; -import {KeyValue} from '../../../definition/model/ApiTestModel'; -import {REQUEST_HEADERS} from 'metersphere-frontend/src/utils/constants'; +import { KeyValue } from '../../../definition/model/ApiTestModel'; +import { REQUEST_HEADERS } from 'metersphere-frontend/src/utils/constants'; -import {diff} from 'jsondiffpatch'; +import { diff } from 'jsondiffpatch'; import MsTable from 'metersphere-frontend/src/components/table/MsTable'; import MsTableColumn from 'metersphere-frontend/src/components/table/MsTableColumn'; -import {getCustomTableHeader, getCustomTableWidth} from 'metersphere-frontend/src/utils/tableUtils'; +import { getCustomTableHeader, getCustomTableWidth } from 'metersphere-frontend/src/utils/tableUtils'; import VariableImport from '@/business/automation/scenario/variable/VariableImport'; -import {hasPermissions} from 'metersphere-frontend/src/utils/permission'; - +import { hasPermissions } from 'metersphere-frontend/src/utils/permission'; export default { name: 'MsVariableList', @@ -424,7 +439,7 @@ export default { } }, handleClick(command) { - this.editData = {delimiter: ',', quotedData: 'false'}; + this.editData = { delimiter: ',', quotedData: 'false' }; this.editData.type = command; this.addParameters(this.editData); }, @@ -490,10 +505,10 @@ export default { if (messages !== '') { this.$alert( this.$t('api_test.scenario.variables') + - '【' + - messages.substr(0, messages.length - 1) + - '】' + - this.$t('load_test.param_is_duplicate') + '【' + + messages.substr(0, messages.length - 1) + + '】' + + this.$t('load_test.param_is_duplicate') ); } }); @@ -502,7 +517,6 @@ export default { this.visible = false; }, close() { - this.visible = false; let saveVariables = []; this.variables.forEach((item) => { item.hidden = undefined; @@ -510,6 +524,11 @@ export default { item.showMore = false; saveVariables.push(item); } + if (item.type === 'CSV' && item.files.length === 0) { + this.$warning(this.$t('api_test.variable') + item.name + ' ' + this.$t('api_test.automation.csv_warning')); + this.visible = true; + return; + } }); this.selectVariable = ''; this.searchType = ''; @@ -517,16 +536,18 @@ export default { this.editData = {}; if ( (diff(JSON.parse(JSON.stringify(this.variables)), this.variablesOld) || - diff(JSON.parse(JSON.stringify(this.headers)), this.headersOld)) - && hasPermissions('PROJECT_API_SCENARIO:READ+EDIT', + diff(JSON.parse(JSON.stringify(this.headers)), this.headersOld)) && + hasPermissions( + 'PROJECT_API_SCENARIO:READ+EDIT', 'PROJECT_API_SCENARIO:READ+CREATE', - 'PROJECT_API_SCENARIO:READ+COPY') + 'PROJECT_API_SCENARIO:READ+COPY' + ) ) { this.$emit('setVariables', saveVariables, this.headers); } }, addVariable() { - this.editData = {delimiter: ',', quotedData: 'false', files: []}; + this.editData = { delimiter: ',', quotedData: 'false', files: [] }; this.editData.type = this.selectType; this.showDelete = false; if (this.editData.type === 'CSV' && this.$refs.csv) {