|
@@ -0,0 +1,270 @@
|
|
|
+<template>
|
|
|
+ <CusDialog
|
|
|
+ :show="show"
|
|
|
+ :title="titleCpt"
|
|
|
+ @onClose="$emit('update:show', false)"
|
|
|
+ width="90%"
|
|
|
+ height="90%"
|
|
|
+ @onSubmit="onSubmit"
|
|
|
+ :loading="state.loading"
|
|
|
+ >
|
|
|
+ <div class="__cus-dialog-form">
|
|
|
+ <CusForm ref="ref_form" label-width="100px">
|
|
|
+ <CusFormColumn
|
|
|
+ :span="8"
|
|
|
+ required
|
|
|
+ label="数据服务名称"
|
|
|
+ label-width="120px"
|
|
|
+ v-model:param="state.form.themeName"
|
|
|
+ />
|
|
|
+ <CusFormColumn
|
|
|
+ :span="8"
|
|
|
+ required
|
|
|
+ label="归属插件"
|
|
|
+ v-model:param="state.form.themeType"
|
|
|
+ link="select"
|
|
|
+ :options="DictionaryStore.themeTypeList"
|
|
|
+ />
|
|
|
+ <CusFormColumn
|
|
|
+ :span="8"
|
|
|
+ required
|
|
|
+ label="插件类型"
|
|
|
+ v-model:param="state.form.themeState"
|
|
|
+ link="select"
|
|
|
+ :options="DictionaryStore.themeStatusList"
|
|
|
+ :disabled="true"
|
|
|
+ />
|
|
|
+ <CusFormColumn
|
|
|
+ :span="24"
|
|
|
+ required
|
|
|
+ v-model:param="state.form.themeName"
|
|
|
+ >
|
|
|
+ <template #prepend>
|
|
|
+ <el-select v-model="state.form.xx" placeholder="Select" style="width: 115px">
|
|
|
+ <template v-for="item in DictionaryStore.requestTypeList">
|
|
|
+ <el-option :label="item.dictLabel" :value="item.dictValue" />
|
|
|
+ </template>
|
|
|
+ </el-select>
|
|
|
+ </template>
|
|
|
+ </CusFormColumn>
|
|
|
+ </CusForm>
|
|
|
+ <CusTab :tabs="state.params.options" type="type1" v-model:param="state.params.tab"/>
|
|
|
+ <div class="params-content">
|
|
|
+ <template v-if="state.params.tab == 1">
|
|
|
+ <div class="request-params">
|
|
|
+ <CusButton type="main" title="新增" style="margin: 0 auto 10px 0;" @click="state.params.requestParams.data.push({key: '', type: '1', value: '', valueTable: []})"/>
|
|
|
+ <CusTable
|
|
|
+ :data="state.params.requestParams.data"
|
|
|
+ :table-head="state.params.requestParams.tableHead"
|
|
|
+ :no-page="true"
|
|
|
+ >
|
|
|
+ <template #key-column-value="{scope}">
|
|
|
+ <CusFormColumn
|
|
|
+ class="__cus-table-form-column"
|
|
|
+ :span="24"
|
|
|
+ v-model:param="scope.row.key"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <template #type-column-value="{scope}">
|
|
|
+ <CusFormColumn
|
|
|
+ class="__cus-table-form-column"
|
|
|
+ :span="24"
|
|
|
+ v-model:param="scope.row.type"
|
|
|
+ link="select"
|
|
|
+ :options="DictionaryStore.requestParamsList"
|
|
|
+ :clearable="false"
|
|
|
+ @change="(val) => (scope.row.value = '', scope.row.valueTable = [])"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <template #value-column-value="{scope}">
|
|
|
+ <CusFormColumn
|
|
|
+ class="__cus-table-form-column"
|
|
|
+ :span="24"
|
|
|
+ v-model:param="scope.row.value"
|
|
|
+ :readonly="scope.row.type == 3"
|
|
|
+ @click="onClickComplexParams(scope.row, scope.$index)"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <template #label-column-value="{scope}">
|
|
|
+ <CusFormColumn
|
|
|
+ class="__cus-table-form-column"
|
|
|
+ :span="24"
|
|
|
+ v-model:param="scope.row.label"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <template #do-column-value="{scope}">
|
|
|
+ <CusButton type="table-del" @click="state.params.requestParams.data.splice(scope.$index, 1)"/>
|
|
|
+ </template>
|
|
|
+ </CusTable>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <template v-else-if="state.params.tab == 2"></template>
|
|
|
+ <template v-else-if="state.params.tab == 3"></template>
|
|
|
+ <template v-else-if="state.params.tab == 4"></template>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <complexParams v-model:show="state.complexParams.show" :transfer="state.complexParams.transfer" @complex="getComplex"/>
|
|
|
+ </CusDialog>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup lang="ts">
|
|
|
+import {computed, getCurrentInstance, nextTick, reactive, ref, watch} from "vue";
|
|
|
+import {useDictionaryStore} from "@/stores";
|
|
|
+import {ElMessage, ElMessageBox} from "element-plus";
|
|
|
+import complexParams from './complex-params.vue'
|
|
|
+
|
|
|
+const emit = defineEmits(['update:show', 'refresh'])
|
|
|
+const {proxy} = getCurrentInstance()
|
|
|
+const DictionaryStore = useDictionaryStore()
|
|
|
+const props = defineProps({
|
|
|
+ show: {default: false},
|
|
|
+ transfer: {}
|
|
|
+ })
|
|
|
+const state: any = reactive({
|
|
|
+ form: {},
|
|
|
+ loading: false,
|
|
|
+ params: {
|
|
|
+ tab: 1,
|
|
|
+ options: [
|
|
|
+ {name: 'Request Params', value: 1},
|
|
|
+ {name: 'Request Headers', value: 2},
|
|
|
+ {name: 'Request Body', value: 3},
|
|
|
+ {name: 'Response Body', value: 4},
|
|
|
+ ],
|
|
|
+ requestParams: {
|
|
|
+ tableHead: [
|
|
|
+ {value: "key", label: "键名"},
|
|
|
+ {value: "type", label: "类型", width: 160},
|
|
|
+ {value: "value", label: `取值(动态取值:\${变量名})`},
|
|
|
+ {value: "label", label: "含义"},
|
|
|
+ {value: "do", label: "操作", width: 120, fixed: 'right'},
|
|
|
+ ],
|
|
|
+ data: []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ complexParams: {
|
|
|
+ show: false,
|
|
|
+ transfer: {},
|
|
|
+ index: 0
|
|
|
+ }
|
|
|
+})
|
|
|
+const ref_form = ref()
|
|
|
+const titleCpt = computed(() => {
|
|
|
+ let t = ''
|
|
|
+ switch (props.transfer.mode) {
|
|
|
+ case 'add': t = '新增外部服务'
|
|
|
+ break
|
|
|
+ case 'edit': t = '编辑外部服务'
|
|
|
+ break
|
|
|
+ }
|
|
|
+ return t
|
|
|
+})
|
|
|
+const onSubmit = () => {
|
|
|
+ console.log(state.params.requestParams.data)
|
|
|
+ let flag = state.params.requestParams.data.every(v => proxy.$util.isValue(v.key) && proxy.$util.isValue(v.value))
|
|
|
+ if (!flag) {
|
|
|
+ ElMessage.error('请完善Request Params参数信息!')
|
|
|
+ state.params.tab = 1
|
|
|
+ return
|
|
|
+ }
|
|
|
+ ref_form.value.submit().then(() => {
|
|
|
+ ElMessageBox.confirm("是否提交?", "提示", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning",
|
|
|
+ } as any).then(() => {
|
|
|
+ state.loading = true
|
|
|
+ // const params = JSON.parse(JSON.stringify(state.form))
|
|
|
+ // if (params.themeType == '2') {
|
|
|
+ // params.themeParam = params.themeParam.join(',')
|
|
|
+ // }
|
|
|
+ // if (props.transfer.mode === 'add') {
|
|
|
+ // sysThemeAdd(params).then(res => {
|
|
|
+ // ElMessage.success('新增成功!')
|
|
|
+ // emit('update:show', false)
|
|
|
+ // emit('refresh')
|
|
|
+ // state.loading = false
|
|
|
+ // }).catch(() => {
|
|
|
+ // state.loading = false
|
|
|
+ // })
|
|
|
+ // } else if (props.transfer.mode === 'edit') {
|
|
|
+ // sysThemeUpdate(params).then(res => {
|
|
|
+ // ElMessage.success('编辑成功!')
|
|
|
+ // emit('update:show', false)
|
|
|
+ // emit('refresh')
|
|
|
+ // state.loading = false
|
|
|
+ // }).catch(() => {
|
|
|
+ // state.loading = false
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ }).catch(() => {})
|
|
|
+ }).catch((e) => {
|
|
|
+ ElMessage({
|
|
|
+ message: e[0].message,
|
|
|
+ grouping: true,
|
|
|
+ type: 'warning',
|
|
|
+ })
|
|
|
+ })
|
|
|
+}
|
|
|
+const initDetail = () => {
|
|
|
+ state.loading = true
|
|
|
+ // sysThemeFind(props.transfer.id).then(res => {
|
|
|
+ // state.form = res.data
|
|
|
+ // if (state.form.themeType == '2') {
|
|
|
+ // state.form.themeParam = state.form.themeParam.split(',')
|
|
|
+ // }
|
|
|
+ // state.loading = false
|
|
|
+ // })
|
|
|
+}
|
|
|
+const onClickComplexParams = (row, index) => {
|
|
|
+ if (row.type == 3) {
|
|
|
+ state.complexParams.transfer = {
|
|
|
+ value: row.value,
|
|
|
+ valueTable: row.valueTable,
|
|
|
+ index: index
|
|
|
+ }
|
|
|
+ state.complexParams.show = true
|
|
|
+ }
|
|
|
+}
|
|
|
+const getComplex = ({str, table}) => {
|
|
|
+ state.params.requestParams.data[state.complexParams.transfer.index].value = str
|
|
|
+ state.params.requestParams.data[state.complexParams.transfer.index].valueTable = table
|
|
|
+}
|
|
|
+watch(() => props.show, (n) => {
|
|
|
+ if (n) {
|
|
|
+ state.loading = false
|
|
|
+ initDictionary()
|
|
|
+ // if (props.transfer.mode === 'add') {
|
|
|
+ // state.form = {}
|
|
|
+ // } else {
|
|
|
+ // initDetail()
|
|
|
+ // }
|
|
|
+ // nextTick(() => {
|
|
|
+ // ref_form.value.reset()
|
|
|
+ // })
|
|
|
+ }
|
|
|
+})
|
|
|
+const initDictionary = () => {
|
|
|
+ DictionaryStore.initDict('request_type')
|
|
|
+ DictionaryStore.initDict('request_params')
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.__cus-dialog-form {
|
|
|
+ height: 100%;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+}
|
|
|
+.params-content {
|
|
|
+ flex: 1;
|
|
|
+ margin-top: 20px;
|
|
|
+ overflow: hidden;
|
|
|
+ .request-params {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|