文件选择,枚举下拉

This commit is contained in:
暮光:城中城
2021-11-02 23:49:48 +08:00
parent 42ad4916a0
commit e99fe3bf65
3 changed files with 45 additions and 13 deletions

View File

@@ -46,7 +46,7 @@ public class LoginController {
// TODO 域账号登录,待测试
@Value("${spring.ldap.domainName:}")
private String ldapDomainName;
@Value("${spring.ldap.enable:}")
@Value("${spring.ldap.enable:false}")
private boolean ldapLoginEnable;
/**

View File

@@ -8,8 +8,26 @@
<template v-if="column.dataIndex === 'name'">
<a-input placeholder="请输入参数名" v-model:value="record.name" @change="queryParamChange(record)"></a-input>
</template>
<template v-if="column.dataIndex === 'type'">
<a-select v-if="record.key >= 10000" v-model:value="record.type">
<a-select-option value="integer">Integer</a-select-option>
<a-select-option value="string">String</a-select-option>
</a-select>
<a-tag color="pink" v-else-if="text === 'integer'">Integer</a-tag>
<a-tag color="red" v-else-if="text === 'string'">String</a-tag>
<a-tag color="green" v-else>{{text||'-'}}</a-tag>
</template>
<template v-if="column.dataIndex === 'value'">
<a-input :placeholder="record.description || '请输入参数值'" v-model:value="record.value" @change="queryParamChange(record)"></a-input>
<a-select v-if="record.enum && record.type === 'array'" v-model:value="record.value" mode="multiple" style="width: 100%;">
<a-select-option :value="enums" v-for="enums in record.enum">{{enums}}</a-select-option>
</a-select>
<a-select v-else-if="record.enum" v-model:value="record.value" style="width: 100%;">
<a-select-option :value="enums" v-for="enums in record.enum">{{enums}}</a-select-option>
</a-select>
<a-upload v-else-if="record.type==='file'" v-model:file-list="record.value" name="file" :multiple="record.type === 'array'" :before-upload="file=>{return beforeUpload(file, record)}" action="https://www.mocky.io/v2/5cc8019d300000980a055e76">
<a-button><upload-outlined></upload-outlined>选择文件</a-button>
</a-upload>
<a-input v-else :placeholder="record.description || '请输入参数值'" v-model:value="record.value" @change="queryParamChange(record)"></a-input>
</template>
<template v-if="column.dataIndex === 'action'">
<CloseOutlined v-if="!record.isLastRow" @click="queryParamRemove(record)" style="cursor: pointer;"/>
@@ -24,7 +42,7 @@
import {useStore} from 'vuex';
import { message } from 'ant-design-vue';
import {markdownIt} from 'mavon-editor'
import {CloseOutlined} from '@ant-design/icons-vue';
import {CloseOutlined, UploadOutlined} from '@ant-design/icons-vue';
import 'mavon-editor/dist/markdown/github-markdown.min.css'
import 'mavon-editor/dist/css/index.css'
@@ -34,19 +52,25 @@
type: Array,
required: true
},
showType: {
type: Boolean,
},
},
components: {
CloseOutlined
CloseOutlined, UploadOutlined
},
emits: ['update:selected'],
setup(props, { attrs, slots, emit, expose }) {
let queryParamList = ref(props.paramList);
let nextIndex = 10000;
// Query参数处理
queryParamList.value.push({name: '', value: '', key: ++nextIndex, isLastRow: true});
queryParamList.value.push({name: '', value: '', type: 'integer', key: ++nextIndex, isLastRow: true});
let queryParamSelectedRowKeys = ref([]);
queryParamList.value.forEach(item => {
item.value = item.example || '';
if ((item.enum && item.type === 'array') || item.type === 'file') {
item.value = [];
}
queryParamSelectedRowKeys.value.push(item.key);
});
emit('update:selected', queryParamSelectedRowKeys.value);
@@ -57,7 +81,7 @@
const queryParamChange = (record) => {
if (record.isLastRow) {
record.isLastRow = false;
queryParamList.value.push({name: '', value: '', key: ++nextIndex, isLastRow: true});
queryParamList.value.push({name: '', value: '', type: 'integer', key: ++nextIndex, isLastRow: true});
queryParamSelectedRowKeys.value.push(nextIndex);
emit('update:selected', queryParamSelectedRowKeys.value);
}
@@ -67,17 +91,25 @@
queryParamList.value = queryParamList.value.filter(item => item !== record);
}
};
let queryParamListColumns = ref([]);
queryParamListColumns.value.push({title: '参数名', dataIndex: 'name', width: 250});
if (props.showType) {
queryParamListColumns.value.push({title: '类型', dataIndex: 'type', width: 100});
}
queryParamListColumns.value.push({title: '参数值', dataIndex: 'value'});
queryParamListColumns.value.push({title: '', dataIndex: 'action', width: 40});
const beforeUpload = (file, record) => {
console.log(record)
return false;
};
return {
queryParamList,
queryParamSelectedRowKeys,
queryParamRowSelectionChange,
queryParamChange,
queryParamRemove,
queryParamListColumns: [
{title: '参数名', dataIndex: 'name', width: 250},
{title: '参数值', dataIndex: 'value'},
{title: '', dataIndex: 'action', width: 40},
],
queryParamListColumns,
beforeUpload,
};
},
};

View File

@@ -10,7 +10,7 @@
<a-tab-pane tab="URL参数" key="urlParam">
<ParamTable v-model:selected="urlParamChecked" :paramList="urlParamList"></ParamTable>
</a-tab-pane>
<a-tab-pane tab="请求参数" key="bodyParam">
<a-tab-pane tab="请求参数" key="bodyParam" v-if="docInfoShow.method !== 'get'">
<a-radio-group v-model:value="bodyParamType" style="margin-bottom: 5px;">
<a-radio value="none">none</a-radio>
<a-radio value="form">form-data</a-radio>
@@ -19,7 +19,7 @@
<a-radio value="binary">binary</a-radio>
</a-radio-group>
<div v-show="bodyParamType === 'form'">
<ParamTable v-model:selected="formParamChecked" :paramList="formParamList"></ParamTable>
<ParamTable v-model:selected="formParamChecked" :paramList="formParamList" showType></ParamTable>
</div>
<div v-show="bodyParamType === 'formUrlEncode'">
<ParamTable v-model:selected="formEncodeParamChecked" :paramList="formEncodeParamList"></ParamTable>