|
@@ -88,9 +88,9 @@
|
|
|
|
|
|
<el-table-column label="操作" align="center" min-width="370" class-name="small-padding fixed-width" fixed="right">
|
|
|
<template slot-scope="{row}">
|
|
|
- <el-button type="primary" size="mini" @click="handleCheck(row)"> 查看 </el-button>
|
|
|
- <el-button type="primary" size="mini" @click="handleUpdate(row)"> 编辑 </el-button>
|
|
|
- <el-button type="primary" size="mini" @click="handleCopy(row)"> 复制 </el-button>
|
|
|
+ <el-button type="primary" size="mini" @click="handleUpdate(row,'show')"> 查看 </el-button>
|
|
|
+ <el-button type="primary" size="mini" @click="handleUpdate(row,'edit')"> 编辑 </el-button>
|
|
|
+ <el-button type="primary" size="mini" @click="handleUpdate(row,'copy')"> 复制 </el-button>
|
|
|
<el-button type="primary" size="mini"> 测试 </el-button>
|
|
|
<el-button v-if="row.status!=1" size="mini" type="success" @click="handleModifyStatus(row, 1)"> 开启 </el-button>
|
|
|
<el-button v-if="row.status!=0" size="mini" type="danger" @click="handleModifyStatus(row, 0)"> 关闭 </el-button>
|
|
@@ -100,54 +100,134 @@
|
|
|
|
|
|
<pagination v-show="total>0" :total="total" :page.sync="listQuery.curIndex" :limit.sync="listQuery.pageSize" @pagination="getList" />
|
|
|
|
|
|
- <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" width="65%" @open="isNotAnyRequest">
|
|
|
+ <el-dialog v-if="dialogFormVisible" :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" width="65%">
|
|
|
+ <main class="dialog-style">
|
|
|
+ <el-form ref="ruleForm" :rules="rulesCheck" :model="ruleForm" label-width="100px" label-position="left">
|
|
|
+ <el-row v-if="isNotAnyRequest" class="set-Width">
|
|
|
+ <el-col :span="4">
|
|
|
+ <el-form-item label="条件" prop="expression1">
|
|
|
+ <el-select v-model="ruleForm.expression1" clearable placeholder="请选择表达式" style="width: 8vw;" fiterable size="medium" @change="chooseTest1">
|
|
|
+ <el-option v-for="item in expressOptions" :key="item.desc" :label="item.descChn" :value="item.desc" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="4">
|
|
|
+ <el-form-item label="" prop="expression2">
|
|
|
+ <el-input v-model="ruleForm.expression2" clearable placeholder="请输入参数" style="width: 8vw;" filterable size="medium" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="4">
|
|
|
+ <el-form-item label="" prop="judgeType">
|
|
|
+ <el-select v-model="ruleForm.judgeType" clearable placeholder="请选择运算方式" style="width: 8vw;" filterable size="medium">
|
|
|
+ <el-option v-for="item1 in operatorOptions" :key="item1.character" :label="item1.desc" :value="item1.character" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="4">
|
|
|
+ <el-form-item label="" prop="judgeValue">
|
|
|
+ <el-input v-model="ruleForm.judgeValue" clearable placeholder="请输入值" style="width: 8vw;" filterable size="medium" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
|
|
|
- <el-form ref="ruleForm" :rules="rulesCheck" :model="ruleForm" label-width="150px" style="width: 83%;">
|
|
|
- <el-row v-if="isNotAnyRequest" class="set-Width">
|
|
|
- <el-col :span="4">
|
|
|
- <el-form-item label="条件" prop="expression1">
|
|
|
- <el-select v-model="ruleForm.expression1" clearable placeholder="请选择表达式" style="width: 8vw;" fiterable size="medium" @change="chooseTest1">
|
|
|
- <el-option v-for="item in expressOptions" :key="item.desc" :label="item.descChn" :value="item.desc" />
|
|
|
- </el-select>
|
|
|
+ <el-form-item v-if="showguiz" label="条件" prop="whenScript">
|
|
|
+ <el-select v-model="ruleForm.whenScript" clearable placeholder="请选择表达式" fiterable @change="chooseTest1">
|
|
|
+ <el-option v-for="item1 in expressOptions" :key="item1.d6sc" :label="item1.descChn" :value="item1.desc" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="描述" prop="ruleDesc">
|
|
|
+ <el-input v-model="ruleForm.ruleDesc" placeholder="请输入描述" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="优先级" prop="execSort">
|
|
|
+ <el-tooltip class="item" effect="light" content="值越大,优先级越高" placement="right">
|
|
|
+ <el-input-number v-model="ruleForm.execSort" label="优先级" :min="1" :max="100" />
|
|
|
+ </el-tooltip>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="返回值" prop="returnMessage">
|
|
|
+ <el-input v-model="ruleForm.returnMessage" :autosize="{ minRows: 3, maxRows: 10}" type="textarea" :placeholder="jsonTit" />
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <section>
|
|
|
+ <el-checkbox v-model="ruleForm.isCallback" class="callback-titile">添加回调接口</el-checkbox>
|
|
|
+ <el-form-item v-if="ruleForm.isCallback" label="回调接口" prop="callbackInfo.name">
|
|
|
+ <el-autocomplete
|
|
|
+ v-model="ruleForm.callbackInfo.name"
|
|
|
+ :fetch-suggestions="searchCallback"
|
|
|
+ placeholder="请输入"
|
|
|
+ style="width: 100%"
|
|
|
+ :hide-loading="true"
|
|
|
+ @select="handleSelect"
|
|
|
+ />
|
|
|
</el-form-item>
|
|
|
- </el-col>
|
|
|
- <el-col :span="4">
|
|
|
- <el-form-item label="" prop="expression2">
|
|
|
- <el-input v-model="ruleForm.expression2" clearable placeholder="请输入参数" style="width: 8vw;" filterable size="medium" />
|
|
|
+ <el-form-item v-if="ruleForm.isCallback" label="回调延迟" prop="callbackInfo.delayTime">
|
|
|
+ <el-input-number
|
|
|
+ v-model="ruleForm.callbackInfo.delayTime"
|
|
|
+ controls-position="right"
|
|
|
+ :min="0"
|
|
|
+ /><span style="margin-left: 10px">毫秒</span>
|
|
|
</el-form-item>
|
|
|
- </el-col>
|
|
|
- <el-col :span="4">
|
|
|
- <el-form-item label="" prop="judgeType">
|
|
|
- <el-select v-model="ruleForm.judgeType" clearable placeholder="请选择运算方式" style="width: 8vw;" filterable size="medium">
|
|
|
- <el-option v-for="item1 in operatorOptions" :key="item1.character" :label="item1.desc" :value="item1.character" />
|
|
|
- </el-select>
|
|
|
+ <h2 v-if="ruleForm.isCallback">Basic</h2>
|
|
|
+ <el-form-item v-if="ruleForm.isCallback" label="接口名称" prop="callbackInfo.name">
|
|
|
+ <el-input
|
|
|
+ v-model="ruleForm.callbackInfo.name"
|
|
|
+ placeholder="请输入"
|
|
|
+ />
|
|
|
</el-form-item>
|
|
|
- </el-col>
|
|
|
- <el-col :span="4">
|
|
|
- <el-form-item label="" prop="judgeValue">
|
|
|
- <el-input v-model="ruleForm.judgeValue" clearable placeholder="请输入值" style="width: 8vw;" filterable size="medium" />
|
|
|
+ <el-form-item v-if="ruleForm.isCallback" label="请求地址" prop="callbackInfo.host">
|
|
|
+ <el-input
|
|
|
+ v-model="ruleForm.callbackInfo.host"
|
|
|
+ placeholder="请输入"
|
|
|
+ />
|
|
|
</el-form-item>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
-
|
|
|
- <el-form-item v-if="showguiz" label="条件" prop="whenScript">
|
|
|
- <el-select v-model="ruleForm.whenScript" clearable placeholder="请选择表达式" fiterable @change="chooseTest1">
|
|
|
- <el-option v-for="item1 in expressOptions" :key="item1.d6sc" :label="item1.descChn" :value="item1.desc" />
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="描述" prop="ruleDesc" style="width:52vw; white-space:nowrap;">
|
|
|
- <el-input v-model="ruleForm.ruleDesc" placeholder="请输入描述" />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="优先级" prop="execSort">
|
|
|
- <el-tooltip class="item" effect="light" content="值越大,优先级越高" placement="right">
|
|
|
- <el-input-number v-model="ruleForm.execSort" label="优先级" :min="1" :max="100" />
|
|
|
- </el-tooltip>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="返回值" prop="returnMessage" style="width:52vw;margin-top: 4%;">
|
|
|
- <el-input v-model="ruleForm.returnMessage" :autosize="{ minRows: 3, maxRows: 10}" type="textarea" :placeholder="jsonTit" />
|
|
|
- </el-form-item>
|
|
|
- </el-form>
|
|
|
-
|
|
|
+ <el-form-item v-if="ruleForm.isCallback" label="请求路径" prop="callbackInfo.url">
|
|
|
+ <el-input
|
|
|
+ v-model="ruleForm.callbackInfo.url"
|
|
|
+ placeholder="请输入"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item v-if="ruleForm.isCallback" label="请求方式" prop="callbackInfo.method">
|
|
|
+ <el-select v-model="ruleForm.callbackInfo.method" placeholder="请选择">
|
|
|
+ <el-option
|
|
|
+ v-for="item in [{ value: 'GET' }, { value: 'POST' }, { value: 'PUT' }, { value: 'DELETE' }]"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.value"
|
|
|
+ :value="item.value"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <h2 v-if="ruleForm.isCallback">Request</h2>
|
|
|
+ <el-radio-group v-if="ruleForm.isCallback" v-model="selectType" size="small">
|
|
|
+ <el-radio-button label="header" />
|
|
|
+ <el-radio-button label="params" />
|
|
|
+ <el-radio-button label="body" />
|
|
|
+ </el-radio-group>
|
|
|
+ <div v-show="selectType==='header' && ruleForm.isCallback">
|
|
|
+ <div v-for="(item,index) in headerList" :key="'header'+index" class="header-list-item">
|
|
|
+ <div>配置:</div>
|
|
|
+ <div><el-input v-model="item.key" placeholder="key" size="small" /></div>
|
|
|
+ <div><el-input v-model="item.value" placeholder="value" size="small" /></div>
|
|
|
+ <div><el-input v-model="item.desc" placeholder="描述信息" size="small" /></div>
|
|
|
+ <i class="el-icon-remove-outline" @click="removeMoules(selectType,index)" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div v-show="selectType==='params' && ruleForm.isCallback">
|
|
|
+ <div v-for="(item,index) in paramsList" :key="'params'+index" class="header-list-item">
|
|
|
+ <div>配置:</div>
|
|
|
+ <div><el-input v-model="item.key" placeholder="key" size="small" /></div>
|
|
|
+ <div><el-input v-model="item.value" placeholder="value" size="small" /></div>
|
|
|
+ <div><el-input v-model="item.desc" placeholder="描述信息" size="small" /></div>
|
|
|
+ <i class="el-icon-remove-outline" @click="removeMoules(selectType,index)" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div v-show="selectType==='body' && ruleForm.isCallback" class="request-body">
|
|
|
+ <el-input v-model="bodyObj" :autosize="{ minRows: 3, maxRows: 10}" type="textarea" placeholder="{id:1}" />
|
|
|
+ </div>
|
|
|
+ <div v-if="ruleForm.isCallback" class="add-button">
|
|
|
+ <el-button v-show="selectType!=='body'" type="primary" icon="el-icon-plus" size="small" @click="addMoules(selectType)">新增配置</el-button>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ </el-form>
|
|
|
+ </main>
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
<el-button @click="dialogFormVisible = false"> 取消 </el-button>
|
|
|
<el-button v-if="showSubmit" type="primary" @click=" dialogStatus === 'create'?createData(ruleForm):updateData(ruleForm)"> 确定 </el-button>
|
|
@@ -157,7 +237,8 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { fetchEnvInfo, fetchRuleById, fetchRuleList, createRule, updateRule, changeStatus, getHttpOp, getExpress } from '@/api/httprule'
|
|
|
+const _ = require('lodash')
|
|
|
+import { fetchEnvInfo, queryById, fetchRuleList, createRule, updateRule, changeStatus, getHttpOp, getExpress, callbackQuery } from '@/api/httprule'
|
|
|
import waves from '@/directive/waves' // waves directive
|
|
|
import { parseTime } from '@/utils'
|
|
|
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
|
|
@@ -196,7 +277,9 @@ export default {
|
|
|
minPrior: 100,
|
|
|
execSort: 1,
|
|
|
ruleDesc: '',
|
|
|
- metaRuleList: [{ operator: '', expression1: '', expression2: '', judgeType: '', judgeValue: '', and: '', or: '', prior: '', bracket: '' }]
|
|
|
+ metaRuleList: [{ operator: '', expression1: '', expression2: '', judgeType: '', judgeValue: '', and: '', or: '', prior: '', bracket: '' }],
|
|
|
+ isCallback: false,
|
|
|
+ callbackInfo: {}
|
|
|
},
|
|
|
rulesCheck: {
|
|
|
metaRuleList: [{ required: true, message: '条件不能为空', trigger: 'change' }],
|
|
@@ -207,7 +290,12 @@ export default {
|
|
|
expression1: [{ required: true, message: '请输入方法', trigger: 'change' }],
|
|
|
expression2: [{ required: true, message: '请输入运算符', trigger: 'change' }],
|
|
|
judgeType: [{ required: true, message: '请选择匹配规则', trigger: 'change' }],
|
|
|
- judgeValue: [{ required: true, message: '请选择参数', trigger: 'change' }]
|
|
|
+ judgeValue: [{ required: true, message: '请选择参数', trigger: 'change' }],
|
|
|
+ 'callbackInfo.name': [{ required: true, message: '请填写回调接口名', trigger: 'change' }],
|
|
|
+ 'callbackInfo.delayTime': [{ required: true, message: '请填写回调延迟', trigger: 'change' }],
|
|
|
+ 'callbackInfo.host': [{ required: true, message: '请填写请求地址', trigger: 'change' }],
|
|
|
+ 'callbackInfo.url': [{ required: true, message: '请填写请求路径', trigger: 'change' }],
|
|
|
+ 'callbackInfo.method': [{ required: true, message: '请填写请求方式', trigger: 'change' }]
|
|
|
},
|
|
|
tableKey: 0,
|
|
|
list: null,
|
|
@@ -248,7 +336,11 @@ export default {
|
|
|
create: '新增'
|
|
|
},
|
|
|
desc: true,
|
|
|
- dataFrom: {}
|
|
|
+ dataFrom: {},
|
|
|
+ selectType: 'header', // 当前选择的类型
|
|
|
+ headerList: [], // header配置列表
|
|
|
+ paramsList: [], // params配置列表
|
|
|
+ bodyObj: null // body配置对象
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
@@ -258,13 +350,47 @@ export default {
|
|
|
this.getExpress()
|
|
|
},
|
|
|
methods: {
|
|
|
- // getExpressOpt(index) {
|
|
|
- // if (index === 0) {
|
|
|
- // return this.expressOptions
|
|
|
- // } else {
|
|
|
- // return this.expressOptionWithutAny
|
|
|
- // }
|
|
|
- // },
|
|
|
+ searchCallback: _.debounce(async(e, cb) => {
|
|
|
+ if (!e)e = ''
|
|
|
+ const res = await callbackQuery(e)
|
|
|
+ if (res.code === 200) {
|
|
|
+ cb(res.data.map(item => {
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ value: item.name
|
|
|
+ }
|
|
|
+ }))
|
|
|
+ }
|
|
|
+ }, 500),
|
|
|
+ handleSelect(callbackInfo) { // 处理选择的回调接口
|
|
|
+ if (callbackInfo && callbackInfo.header) {
|
|
|
+ this.headerList = JSON.parse(callbackInfo.header)
|
|
|
+ delete callbackInfo.header
|
|
|
+ }
|
|
|
+ if (callbackInfo && callbackInfo.params) {
|
|
|
+ this.paramsList = JSON.parse(callbackInfo.params)
|
|
|
+ delete callbackInfo.params
|
|
|
+ }
|
|
|
+ if (callbackInfo && callbackInfo.body) {
|
|
|
+ this.bodyObj = callbackInfo.body
|
|
|
+ delete callbackInfo.body
|
|
|
+ }
|
|
|
+ this.ruleForm.callbackInfo = callbackInfo
|
|
|
+ },
|
|
|
+ addMoules(type) { // 新增配置
|
|
|
+ if (type === 'header') {
|
|
|
+ this.headerList.push({ key: '', value: '', desc: '' })
|
|
|
+ } else if (type === 'params') {
|
|
|
+ this.paramsList.push({ key: '', value: '', desc: '' })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ removeMoules(type, index) { // 移除配置
|
|
|
+ if (type === 'header') {
|
|
|
+ this.headerList.splice(index, 1)
|
|
|
+ } else if (type === 'params') {
|
|
|
+ this.paramsList.splice(index, 1)
|
|
|
+ }
|
|
|
+ },
|
|
|
chooseTest1(val) {
|
|
|
if (val === 'any') {
|
|
|
this.$set(this.ruleForm, 'whenScript', val)
|
|
@@ -277,26 +403,7 @@ export default {
|
|
|
this.isNotAnyRequest = true
|
|
|
this.showguiz = false
|
|
|
}
|
|
|
- // if (this.ruleForm.metaRuleList[0].expression1 === 'any request') {
|
|
|
- // this.isNotAnyRequest = false
|
|
|
- // this.isAnyshow = true
|
|
|
- // } else {
|
|
|
- // this.isNotAnyRequest = true
|
|
|
-
|
|
|
- // this.paramOptions.push(0,0,{ name: 'any', value: 0 })
|
|
|
- // }
|
|
|
},
|
|
|
-
|
|
|
- // chooseTest2(val) {
|
|
|
- // this.expression2 = val
|
|
|
- // },
|
|
|
- // chooseTest3(val) {
|
|
|
- // this.ruleForm.metaRuleList.judgeType = val
|
|
|
- // },
|
|
|
- // chooseTest4(val) {
|
|
|
- // this.ruleForm.metaRuleList.judgeValue = val
|
|
|
- // },
|
|
|
-
|
|
|
// 获取运算符
|
|
|
getHttpOp() {
|
|
|
getHttpOp().then(response => {
|
|
@@ -307,12 +414,6 @@ export default {
|
|
|
getExpress() {
|
|
|
getExpress().then(response => {
|
|
|
this.expressOptions = response.data
|
|
|
- // this.expressOptions.forEach((opt, index) => {
|
|
|
- // if (opt.desc === 'any request') {
|
|
|
- // return true
|
|
|
- // }
|
|
|
- // this.expressOptionWithutAny.push(opt)
|
|
|
- // })
|
|
|
})
|
|
|
},
|
|
|
prev() {
|
|
@@ -390,25 +491,13 @@ export default {
|
|
|
this.listQuery.methodStatus = this.listQuery.value
|
|
|
this.getList()
|
|
|
},
|
|
|
- // sortChange(data) {
|
|
|
- // const { prop, order } = data
|
|
|
- // if (prop === 'id') {
|
|
|
- // this.sortByID(order)
|
|
|
- // }
|
|
|
- // },
|
|
|
- // sortByID(order) {
|
|
|
- // if (order === 'ascending') {
|
|
|
- // this.listQuery.sort = '+id'
|
|
|
- // } else {
|
|
|
- // this.listQuery.sort = '-id'
|
|
|
- // }
|
|
|
- // this.handleFilter()
|
|
|
- // },
|
|
|
handleCreate() {
|
|
|
this.dialogStatus = 'create'
|
|
|
this.dialogFormVisible = true
|
|
|
this.showSubmit = true
|
|
|
- this.ruleForm = {}
|
|
|
+ this.ruleForm = {
|
|
|
+ callbackInfo: { name: null, delayTime: 0, method: 'GET' }
|
|
|
+ }
|
|
|
this.isNotAnyRequest = false
|
|
|
this.showguiz = true
|
|
|
this.$set(this.ruleForm, 'whenScript', 'any')
|
|
@@ -419,20 +508,17 @@ export default {
|
|
|
this.$refs['ruleForm'].clearValidate()
|
|
|
})
|
|
|
},
|
|
|
-
|
|
|
// 新增Data
|
|
|
createData(vel) {
|
|
|
if (typeof vel.returnMessage === 'string') {
|
|
|
this.$refs['ruleForm'].validate((valid) => {
|
|
|
if (valid) {
|
|
|
- this.dataFrom = vel
|
|
|
+ this.dataFrom = _.cloneDeep(vel)
|
|
|
this.dataFrom.creator = this.userNames
|
|
|
this.dataFrom.creatorEn = this.username
|
|
|
this.dataFrom.updator = ''
|
|
|
this.dataFrom.methodId = parseInt(this.$route.path.split('/')[4])
|
|
|
this.dataFrom.methodProtocol = 'http'
|
|
|
- this.dataFrom = vel
|
|
|
- this.dataFrom = vel
|
|
|
|
|
|
this.showguiz === false ? this.dataFrom.whenScript = '' : ''
|
|
|
this.isNotAnyRequest === false ? this.dataFrom.metaRuleList = [] : this.dataFrom.metaRuleList = [{ 'operator': '', 'expression': vel.expression1 + '.' + vel.expression2, 'judgeType': vel.judgeType, 'judgeValue': vel.judgeValue }]
|
|
@@ -441,46 +527,75 @@ export default {
|
|
|
delete this.dataFrom.judgeType
|
|
|
delete this.dataFrom.judgeValue
|
|
|
delete this.dataFrom.id
|
|
|
-
|
|
|
- createRule(this.dataFrom).then(response => {
|
|
|
- if (response.code === 200) {
|
|
|
- this.dialogFormVisible = false
|
|
|
- this.getList()
|
|
|
- this.$notify({ title: 'Success', message: response.msg, type: 'success', duration: 2000 })
|
|
|
- } else {
|
|
|
- this.$notify({ title: 'Failed', message: response.msg, type: 'error', duration: 2000 })
|
|
|
- }
|
|
|
- })
|
|
|
+ if (this.headerList.length > 0) {
|
|
|
+ this.dataFrom.callbackInfo.header = JSON.stringify(this.headerList)
|
|
|
+ }
|
|
|
+ if (this.paramsList.length > 0) {
|
|
|
+ this.dataFrom.callbackInfo.params = JSON.stringify(this.paramsList)
|
|
|
+ }
|
|
|
+ if (this.bodyObj !== null && this.bodyObj !== '') {
|
|
|
+ this.dataFrom.callbackInfo.body = this.bodyObj
|
|
|
+ }
|
|
|
+ if (!this.ruleForm.isCallback) {
|
|
|
+ this.dataFrom.callbackInfo = null
|
|
|
+ }
|
|
|
+ this.createRule()
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
+ async createRule() {
|
|
|
+ const response = await createRule(this.dataFrom)
|
|
|
+ if (response.code === 200) {
|
|
|
+ this.dialogFormVisible = false
|
|
|
+ this.getList()
|
|
|
+ this.$notify({ title: 'Success', message: response.msg, type: 'success', duration: 2000 })
|
|
|
+ } else {
|
|
|
+ this.$notify({ title: 'Failed', message: response.msg, type: 'error', duration: 2000 })
|
|
|
+ }
|
|
|
+ },
|
|
|
// 编辑Data
|
|
|
- handleUpdate(row) {
|
|
|
- var queryData = { id: row.id }
|
|
|
- fetchRuleById(queryData).then(response => {
|
|
|
- this.ruleForm = response.data.mockRuleList[0]
|
|
|
- if (this.ruleForm.whenScript !== '') {
|
|
|
- this.isNotAnyRequest = false
|
|
|
- this.showguiz = true
|
|
|
- }
|
|
|
- if (this.ruleForm.metaRuleList.length !== 0) {
|
|
|
- this.isNotAnyRequest = true
|
|
|
- this.showguiz = false
|
|
|
- for (var a of this.ruleForm.metaRuleList) {
|
|
|
- this.ruleForm.expression1 = a.expression.split('.')[0]
|
|
|
- this.ruleForm.expression2 = a.expression.split('.')[1]
|
|
|
- this.ruleForm.judgeType = a.judgeType
|
|
|
- this.ruleForm.judgeValue = a.judgeValue
|
|
|
- }
|
|
|
+ async handleUpdate(row, type) {
|
|
|
+ const response = await queryById(row.id)
|
|
|
+ this.ruleForm = response.data
|
|
|
+ if (this.ruleForm.whenScript !== '') {
|
|
|
+ this.isNotAnyRequest = false
|
|
|
+ this.showguiz = true
|
|
|
+ }
|
|
|
+ if (this.ruleForm.metaRuleList.length !== 0) {
|
|
|
+ this.isNotAnyRequest = true
|
|
|
+ this.showguiz = false
|
|
|
+ for (const a of this.ruleForm.metaRuleList) {
|
|
|
+ this.ruleForm.expression1 = a.expression.split('.')[0]
|
|
|
+ this.ruleForm.expression2 = a.expression.split('.')[1]
|
|
|
+ this.ruleForm.judgeType = a.judgeType
|
|
|
+ this.ruleForm.judgeValue = a.judgeValue
|
|
|
}
|
|
|
- this.dialogStatus = 'update'
|
|
|
- this.dialogFormVisible = true
|
|
|
- this.showSubmit = true
|
|
|
- this.$nextTick(() => {
|
|
|
- this.$refs['ruleForm'].clearValidate()
|
|
|
- })
|
|
|
+ }
|
|
|
+ const callbackInfo = this.ruleForm.callbackInfo
|
|
|
+ if (!this.ruleForm.callbackInfo) {
|
|
|
+ this.ruleForm.callbackInfo = {}
|
|
|
+ }
|
|
|
+ if (!this.ruleForm.isCallback) {
|
|
|
+ this.ruleForm.isCallback = false
|
|
|
+ }
|
|
|
+ if (callbackInfo && callbackInfo.header) {
|
|
|
+ this.headerList = JSON.parse(callbackInfo.header)
|
|
|
+ delete callbackInfo.header
|
|
|
+ }
|
|
|
+ if (callbackInfo && callbackInfo.params) {
|
|
|
+ this.paramsList = JSON.parse(callbackInfo.params)
|
|
|
+ delete callbackInfo.params
|
|
|
+ }
|
|
|
+ if (callbackInfo && callbackInfo.body) {
|
|
|
+ this.bodyObj = callbackInfo.body
|
|
|
+ delete callbackInfo.body
|
|
|
+ }
|
|
|
+ this.dialogStatus = type === 'copy' ? 'create' : 'update'
|
|
|
+ this.dialogFormVisible = true
|
|
|
+ this.showSubmit = type !== 'show'
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs['ruleForm'].clearValidate()
|
|
|
})
|
|
|
},
|
|
|
handleModifyStatus(row, status) {
|
|
@@ -498,34 +613,6 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- // 复制Data
|
|
|
- handleCopy(row) {
|
|
|
- var queryData = { id: row.id }
|
|
|
- fetchRuleById(queryData).then(response => {
|
|
|
- this.ruleForm = response.data.mockRuleList[0]
|
|
|
- if (this.ruleForm.whenScript !== '') {
|
|
|
- this.isNotAnyRequest = false
|
|
|
- this.showguiz = true
|
|
|
- }
|
|
|
- if (this.ruleForm.metaRuleList.length !== 0) {
|
|
|
- this.isNotAnyRequest = true
|
|
|
- this.showguiz = false
|
|
|
- for (var a of this.ruleForm.metaRuleList) {
|
|
|
- this.$set(this.ruleForm, 'expression1', a.expression.split('.')[0])
|
|
|
- this.$set(this.ruleForm, 'expression2', a.expression.split('.')[1])
|
|
|
- this.$set(this.ruleForm, 'judgeType', a.judgeType)
|
|
|
- this.$set(this.ruleForm, 'judgeValue', a.judgeValue)
|
|
|
- }
|
|
|
- }
|
|
|
- this.dialogStatus = 'create'
|
|
|
- this.dialogFormVisible = true
|
|
|
- this.showSubmit = true
|
|
|
- this.$nextTick(() => {
|
|
|
- this.$refs['ruleForm'].clearValidate()
|
|
|
- })
|
|
|
- })
|
|
|
- },
|
|
|
-
|
|
|
// 编辑提交
|
|
|
updateData(vel) {
|
|
|
if (typeof vel.returnMessage === 'string') {
|
|
@@ -547,28 +634,31 @@ export default {
|
|
|
delete this.dataFrom.expression2
|
|
|
delete this.dataFrom.judgeType
|
|
|
delete this.dataFrom.judgeValue
|
|
|
- // const tempData = Object.assign({}, this.ruleData)
|
|
|
- // const tempData = {
|
|
|
- // id: this.ruleForm.id,
|
|
|
- // methodId: parseInt(this.$route.path.split('/')[4]),
|
|
|
- // updator: '',
|
|
|
- // execSort: this.ruleForm.execSort,
|
|
|
- // whenScript: this.ruleForm.whenScript,
|
|
|
- // returnMessage: this.ruleForm.returnMessage,
|
|
|
- // mehtodName: this.$route.query.methodName,
|
|
|
- // methodProtocol: this.$route.query.methodProtocol,
|
|
|
- // metaRuleList: [],
|
|
|
- // ruleDesc: this.ruleForm.ruleDesc
|
|
|
- // }
|
|
|
- updateRule(this.dataFrom).then(() => {
|
|
|
- this.getList()
|
|
|
- this.dialogFormVisible = false
|
|
|
- this.$notify({ title: 'Success', message: 'Update Successfully', type: 'success', duration: 2000 })
|
|
|
- })
|
|
|
+ if (this.headerList.length > 0) {
|
|
|
+ this.dataFrom.callbackInfo.header = JSON.stringify(this.headerList)
|
|
|
+ }
|
|
|
+ if (this.paramsList.length > 0) {
|
|
|
+ this.dataFrom.callbackInfo.params = JSON.stringify(this.paramsList)
|
|
|
+ }
|
|
|
+ if (this.bodyObj !== null && this.bodyObj !== '') {
|
|
|
+ this.dataFrom.callbackInfo.body = this.bodyObj
|
|
|
+ }
|
|
|
+ if (!this.ruleForm.isCallback) {
|
|
|
+ this.dataFrom.callbackInfo = null
|
|
|
+ }
|
|
|
+ this.updateRule()
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
+ async updateRule() {
|
|
|
+ const res = await updateRule(this.dataFrom)
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.getList()
|
|
|
+ this.dialogFormVisible = false
|
|
|
+ this.$notify({ title: 'Success', message: 'Update Successfully', type: 'success', duration: 2000 })
|
|
|
+ }
|
|
|
+ },
|
|
|
formatJson(filterVal, jsonData) {
|
|
|
return jsonData.map(v => filterVal.map(j => {
|
|
|
if (j === 'timestamp') {
|
|
@@ -577,53 +667,45 @@ export default {
|
|
|
return v[j]
|
|
|
}
|
|
|
}))
|
|
|
- },
|
|
|
-
|
|
|
- // 查看
|
|
|
- handleCheck(row) {
|
|
|
- var queryData = { id: row.id }
|
|
|
- fetchRuleById(queryData).then(response => {
|
|
|
- var row_data = response.data.mockRuleList
|
|
|
- this.ruleForm = Object.assign({}, row_data[0])
|
|
|
- if (this.ruleForm.whenScript !== '') {
|
|
|
- this.isNotAnyRequest = false
|
|
|
- this.showguiz = true
|
|
|
- }
|
|
|
- if (this.ruleForm.metaRuleList.length !== 0) {
|
|
|
- this.isNotAnyRequest = true
|
|
|
- this.showguiz = false
|
|
|
- for (var a of this.ruleForm.metaRuleList) {
|
|
|
- this.ruleForm.expression1 = a.expression.split('.')[0]
|
|
|
- this.ruleForm.expression2 = a.expression.split('.')[1]
|
|
|
- this.ruleForm.judgeType = a.judgeType
|
|
|
- this.ruleForm.judgeValue = a.judgeValue
|
|
|
- }
|
|
|
- }
|
|
|
- this.dialogStatus = 'update'
|
|
|
- this.dialogFormVisible = true
|
|
|
- this.showSubmit = false
|
|
|
- this.$nextTick(() => {
|
|
|
- this.$refs['ruleForm'].clearValidate()
|
|
|
- })
|
|
|
- })
|
|
|
}
|
|
|
- // descEnter(index, row) {
|
|
|
- // this.listQuery.ruleDescSeen = true
|
|
|
- // this.desc = false
|
|
|
- // },
|
|
|
- // descLeave(row) {
|
|
|
- // this.listQuery.ruleDescSeen = false
|
|
|
- // this.desc = true
|
|
|
- // }
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
-<style>
|
|
|
-.el-notification.right{
|
|
|
+<style lang="scss" scoped>
|
|
|
+/deep/.el-notification.right{
|
|
|
position: fixed;
|
|
|
- right: 38.5%;}
|
|
|
- .set-Width .el-form-item__error {
|
|
|
- width: 90px;
|
|
|
+ right: 38.5%;
|
|
|
+ }
|
|
|
+.set-Width .el-form-item__error {
|
|
|
+ width: 90px;
|
|
|
+}
|
|
|
+.dialog-style {
|
|
|
+ padding: 20px 80px 20px 20px;
|
|
|
+ max-height: 500px;
|
|
|
+ overflow: scroll;
|
|
|
+ .callback-titile {
|
|
|
+ color: #333333;
|
|
|
+ margin-bottom: 20px;
|
|
|
+ }
|
|
|
+ .header-list-item {
|
|
|
+ display: grid;
|
|
|
+ grid-template-columns: 7% 30% 30% 30% 3%;
|
|
|
+ align-items: center;
|
|
|
+ margin: 10px 0;
|
|
|
+ div{
|
|
|
+ padding-left: 10px;
|
|
|
+ }
|
|
|
+ i {
|
|
|
+ margin: auto;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .request-body {
|
|
|
+ margin-top: 10px;
|
|
|
}
|
|
|
+ .add-button {
|
|
|
+ margin-top: 20px;
|
|
|
+ }
|
|
|
+}
|
|
|
+.dialog-style::-webkit-scrollbar {display:none}
|
|
|
</style>
|