|
@@ -2,20 +2,19 @@
|
|
|
<div class="app-container">
|
|
|
<el-header style="height:auto;!improtant">
|
|
|
<div class="filter-container" style="padding-bottom: 20px;!improtant">
|
|
|
- <el-input v-model="listQuery.ruleDesc" placeholder="名称" style="width:130px;margin:0 -1.5px;" class="filter-item" @keyup.enter.native="handleFilter" />
|
|
|
- <el-input v-model="listQuery.execSort" placeholder="优先级" style="width:130px;margin:0 -1.5px;" class="filter-item" @keyup.enter.native="handleFilter" />
|
|
|
- <el-select v-model="listQuery.status" class="filter-item" filterable clearable placeholder="状态" style="width:130px;margin:0 -1.5px;">
|
|
|
- <el-option v-for="item1 in ruleStatus" :key="item1.key" :label="item1.display_name" :value="item1.key" />
|
|
|
+ <el-input v-model="listQuery.ruleDesc" placeholder="规则描述" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter" />
|
|
|
+ <el-input v-model="listQuery.execSort" placeholder="优先级" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter" />
|
|
|
+ <!-- <el-input-number v-model="listQuery.execSort" label="优先级" :min="1" :max="100" /> -->
|
|
|
+ <el-select v-model="listQuery.status" class="filter-item" filterable clearable placeholder="状态">
|
|
|
+ <el-option v-for="item in ruleStatus" :key="item.key" :label="item.display_name" :value="item.key" />
|
|
|
</el-select>
|
|
|
+ <!-- <el-input v-model="listQuery.interfaceName" placeholder="接口类" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter" /> -->
|
|
|
<el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">
|
|
|
搜索
|
|
|
</el-button>
|
|
|
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="handleCreate">
|
|
|
新增
|
|
|
</el-button>
|
|
|
- <el-checkbox v-model="showRules" class="filter-item" style="margin-left:15px;" @change="tableKey=tableKey+1">
|
|
|
- 显示规则
|
|
|
- </el-checkbox>
|
|
|
<el-checkbox v-model="showReviewer" class="filter-item" style="margin-left:15px;" @change="tableKey=tableKey+1">
|
|
|
显示返回值
|
|
|
</el-checkbox>
|
|
@@ -39,25 +38,31 @@
|
|
|
<span>{{ scope.row.id }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
+ <el-table-column label="规则描述" prop="id" sortable="custom" align="center" min-width="80px">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <span v-show="desc">{{ scope.row.ruleDesc|lengthFilter }}</span>
|
|
|
+ <!--<span v-show="listQuery.ruleDescSeen">{{ scope.row.ruleDesc}}</span>-->
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
<el-table-column label="接口ID" min-width="80px" align="center">
|
|
|
<!-- <template slot-scope="scope"> -->
|
|
|
<span>{{ this.$route.path.split('/')[3] }}</span>
|
|
|
<!-- </template> -->
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="方法协议" min-width="150px" align="center">
|
|
|
- <!-- <template slot-scope="scope"> -->
|
|
|
- <span>{{ this.$route.query.methodProtocol }}</span>
|
|
|
- <!-- </template> -->
|
|
|
- </el-table-column>
|
|
|
- <!-- <el-table-column label="规则" min-min-width="60px">
|
|
|
- <template slot-scope="{row}">
|
|
|
- <span>{{ row.whenScript }}</span> -->
|
|
|
- //<!-- <el-tag>{{ row.type | typeFilter }}</el-tag> -->
|
|
|
- <!-- </template>
|
|
|
- </el-table-column> -->
|
|
|
- <el-table-column label="规则描述" min-width="110px" align="center">
|
|
|
+ <!--<el-table-column label="方法协议" min-width="150px" align="center">-->
|
|
|
+ <!--<!– <template slot-scope="scope"> –>-->
|
|
|
+ <!--<span>{{ this.$route.query.methodProtocol }}</span>-->
|
|
|
+ <!--<!– </template> –>-->
|
|
|
+ <!--</el-table-column>-->
|
|
|
+ <!--<el-table-column label="规则" min-min-width="60px">-->
|
|
|
+ <!--<template slot-scope="{row}">-->
|
|
|
+ <!--<span>{{ row.whenScript }}</span>-->
|
|
|
+ <!--<!– <el-tag>{{ row.type | typeFilter }}</el-tag> –>-->
|
|
|
+ <!--</template>-->
|
|
|
+ <!--</el-table-column>-->
|
|
|
+ <el-table-column label="优先级" min-width="110px" align="center">
|
|
|
<template slot-scope="scope">
|
|
|
- <span>{{ scope.row.ruleDesc }}</span>
|
|
|
+ <span>{{ scope.row.execSort }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="http请求URL" min-width="110px" align="center">
|
|
@@ -77,11 +82,6 @@
|
|
|
</el-tag>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column v-if="showRules" label="规则" min-width="110px" align="center">
|
|
|
- <template slot-scope="scope">
|
|
|
- <span style="color:red;">{{ scope.row.metaRuleList }}</span>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
<el-table-column v-if="showReviewer" label="返回值" min-width="110px" align="center">
|
|
|
<template slot-scope="scope">
|
|
|
<span style="color:red;">{{ scope.row.returnMessage }}</span>
|
|
@@ -89,13 +89,13 @@
|
|
|
</el-table-column>
|
|
|
<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="handleUpdate(row,'check')">
|
|
|
+ <el-button type="primary" size="mini" @click="handleCheck(row)">
|
|
|
查看
|
|
|
</el-button>
|
|
|
- <el-button type="primary" size="mini" @click="handleUpdate(row,'update')">
|
|
|
+ <el-button type="primary" size="mini" @click="handleUpdate(row)">
|
|
|
编辑
|
|
|
</el-button>
|
|
|
- <el-button type="primary" size="mini" @click="handleUpdate(row,'copy')">
|
|
|
+ <el-button type="primary" size="mini" @click="handleCopy(row)">
|
|
|
复制
|
|
|
</el-button>
|
|
|
<el-button type="primary" size="mini">
|
|
@@ -111,116 +111,30 @@
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
<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="85%" @open="returnMessageData">
|
|
|
-
|
|
|
- <el-form ref="ruleForm" :rules="rule" :model="ruleForm" label-width="150px" style="width: 830px;">
|
|
|
- <table>
|
|
|
- <tr>
|
|
|
- <el-form-item label="规则描述" prop="ruleDesc" style="margin-left:0.5%;">
|
|
|
- <el-input v-model="rules.ruleDesc" clearable placeholder="输入规则描述" style="width:130px;margin:0 -3.5px;" filterable size="medium" />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item
|
|
|
- v-if="isAnyRequest === true"
|
|
|
- label="规则"
|
|
|
- prop="whenScript"
|
|
|
- :rules="{required: false, message: '请选择规则表达式', trigger: 'blur'}"
|
|
|
->
|
|
|
- <el-select v-model="rules.whenScript" clearable placeholder="请选择规则表达式" style="width:130px;margin: 0 1% -2.5 5.5px;" fiterable @change="chooseTest">
|
|
|
- <el-option v-for="item in getExpressOpt(0)" :key="item.desc" :label="item.descChn" :value="item.desc" />
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- <div style="margin-left:14%;">
|
|
|
- <el-form-item v-for="(item, index) in ruleForm.metaRuleList" ref="key" :key="index" label-width="0">
|
|
|
- <template>
|
|
|
- <div v-show="index == 0 ? false : isNotAnyRequest" style="margin: -6% -30% 1% 21%;">
|
|
|
- <el-divider>
|
|
|
- <el-button-group>
|
|
|
- <el-button ref="and" :style="styleBtn" circle plain size="mini" @click="changeAnd(index)">{{ and }}</el-button>
|
|
|
- <el-button ref="or" circle plain size="mini" @click="changeOr(index)">{{ or }}</el-button>
|
|
|
- </el-button-group>
|
|
|
-
|
|
|
- <!-- <div :class="{red: !isshow,blue: isshow}" @click="isshow=!isshow">并且</div>
|
|
|
- <div :class="{red: !isshow,blue: isshow}" @click="isshow=!isshow">或者</div> -->
|
|
|
- <!-- <div style="border:1px solid #000; border-radius:50% 0 0 50%;text-align:center;line-height:26px;">并且</div> -->
|
|
|
-
|
|
|
- </el-divider>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <el-row ref="priorBackgroup" :gutter="2" style="width: 140%;white-space:nowrap;">
|
|
|
- <el-col :span="3">
|
|
|
- <el-form-item>
|
|
|
- <el-tooltip class="item" visible-arrow="false" effect="light" content="连续勾选可以优先计算" placement="left-start">
|
|
|
- <el-checkbox v-if="isNotAnyRequest === true" ref="priorCheck" v-model="item.prior" :disabled="priorDistabledStatus(index)" style="margin-right: 0 8% 10% 0%;" size="mini" @change="priorChanged(index)">规则{{ index+1 }}</el-checkbox>
|
|
|
- </el-tooltip>
|
|
|
- <!-- <el-checkbox ref="priorCheck" :disabled="checkDisabled(index)" style="margin-right: 0 8% 10% 0%;" size="mini" v-model="item.prior" v-if="isNotAnyRequest === true" >规则{{index+1}}</el-checkbox> -->
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <!-- <div v-show="isAnyShow==true">规则</div> -->
|
|
|
- <div v-if="isNotAnyRequest === true" style="margin:0 22px;">
|
|
|
- <el-col :span="5">
|
|
|
- <el-form-item
|
|
|
- style="color:red; white-space:nowrap;"
|
|
|
- :prop="'metaRuleList.' + index + '.expression1'"
|
|
|
- :rules="{required: true, message: '请选择规则表达式', trigger: 'blur'}"
|
|
|
- >
|
|
|
- <el-select v-if="isNotAnyRequest" v-model="item.expression1" clearable placeholder="请选择表达式" style="width:130px;margin: 0 1% 1% -15.8%;" fiterable size="medium" @change="chooseTest1">
|
|
|
- <el-option v-for="item in getExpressOpt(index)" :key="item.desc" :label="item.descChn" :value="item.desc" />
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <el-col :span="5">
|
|
|
- <el-form-item :prop="'metaRuleList.' + index + '.expression2'" :rules="{required: true, message: '请输入参数', trigger: 'blur'}">
|
|
|
- <el-input v-model="item.expression2" clearable placeholder="请输入参数" style="width:130px;margin:0 -10.5px;" filterable size="medium" @change="chooseTest2" />
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <el-col :span="5">
|
|
|
- <el-form-item :prop="'metaRuleList.' + index + '.judgeType'" :rules="{required: true, message: '请选择运算方式', trigger: 'blur'}">
|
|
|
- <el-select v-model="item.judgeType" clearable placeholder="请选择运算方式" style="width:130px;margin:0 -1.5px;" filterable size="medium" @change="chooseTest3">
|
|
|
- <el-option v-for="item in operatorOptions" :key="item.character" :label="item.desc" :value="item.character" />
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <el-col :span="5">
|
|
|
- <el-form-item
|
|
|
- :prop="'metaRuleList.' + index + '.judgeValue'"
|
|
|
- :rules="{required: true, message: '请输入值', trigger: 'blur'}"
|
|
|
- >
|
|
|
- <el-input v-model="item.judgeValue" clearable placeholder="请输入值" style="width:130px;margin:0 6.5px;" filterable size="medium" @change="chooseTest4" />
|
|
|
- <el-button v-if="index == 0 && isNotAnyRequest==true" icon="el-icon-plus" type="success" size="mini" circle @click="addList()" />
|
|
|
- <el-button v-show="index == 0 ? false : isNotAnyRequest" icon="el-icon-minus" type="danger" size="mini" circle @click="delList(index)" />
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- </div>
|
|
|
-
|
|
|
- </el-row>
|
|
|
- </el-form-item>
|
|
|
- </div>
|
|
|
-
|
|
|
- </tr>
|
|
|
- </table>
|
|
|
+ <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" width="65%" @open="returnMessageData">
|
|
|
+ <el-form ref="ruleDataForm" :rules="roleDataRules" :model="ruleData" label-position="left" label-width="120px" style="width: 500px; margin-left:80px;">
|
|
|
+ <el-form-item label="规则" prop="whenScript">
|
|
|
+ <el-input v-model="ruleData.whenScript" placeholder="any" disabled />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="规则描述" prop="ruleDesc">
|
|
|
+ <el-input v-model="ruleData.ruleDesc" placeholder="请输入规则详情" />
|
|
|
+ </el-form-item>
|
|
|
<el-form-item label="优先级" prop="execSort">
|
|
|
- <el-input-number v-model="rules.execSort" label="优先级" :min="1" :max="100" title="值越大,优先级越高" />
|
|
|
+ <el-input-number v-model="ruleData.execSort" label="优先级" :min="1" :max="100" title="值越大,优先级越高" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="返回值" prop="returnMessage">
|
|
|
- <el-input v-model="rules.returnMessage" size:large :autosize="{ minRows: 3, maxRows: 20}" type="textarea" :placeholder="jsonTit" />
|
|
|
+ <el-input v-model="ruleData.returnMessage" :autosize="{ minRows: 3, maxRows: 10}" type="textarea" :placeholder="jsonTit" />
|
|
|
</el-form-item>
|
|
|
-
|
|
|
</el-form>
|
|
|
-
|
|
|
- <el-form label-width="150px" style="width: 880px;" />
|
|
|
-
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
<el-button @click="dialogFormVisible = false">
|
|
|
取消
|
|
|
</el-button>
|
|
|
- <el-button v-if="showSubmit" type="primary" @click="dialogStatus==='update'?updateData() : createData()">
|
|
|
+ <el-button v-if="showSubmit" type="primary" @click="dialogStatus==='create'?createData():updateData()">
|
|
|
确定
|
|
|
</el-button>
|
|
|
-
|
|
|
</div>
|
|
|
-
|
|
|
</el-dialog>
|
|
|
-
|
|
|
<el-dialog :visible.sync="dialogPvVisible" title="Reading statistics">
|
|
|
<el-table :data="pvData" border fit highlight-current-row style="width: 100%">
|
|
|
<el-table-column prop="key" label="Channel" />
|
|
@@ -234,16 +148,19 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { fetchEnvInfo, fetchRuleById, fetchRuleList, createRule, updateRule, changeStatus, getHttpOp, getExpress } from '@/api/httprule'
|
|
|
+import { fetchEnvInfo, fetchRuleById, fetchRuleList, createRule, updateRule, changeStatus } 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
|
|
|
+
|
|
|
// var envSelections = []
|
|
|
+
|
|
|
const ruleStatus = [
|
|
|
{ key: 1, display_name: '已开启' },
|
|
|
{ key: 0, display_name: '未开启' },
|
|
|
{ key: '', display_name: '全部显示' }
|
|
|
]
|
|
|
+
|
|
|
export default {
|
|
|
name: 'Httprule',
|
|
|
components: { Pagination },
|
|
@@ -256,67 +173,20 @@ export default {
|
|
|
0: 'danger'
|
|
|
}
|
|
|
return statusMap[status]
|
|
|
+ },
|
|
|
+ lengthFilter(value) {
|
|
|
+ if (value.length >= 20) {
|
|
|
+ return value.slice(0, 20) + '...'
|
|
|
+ }
|
|
|
+ return value
|
|
|
}
|
|
|
+
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- Id: '',
|
|
|
- num: 0,
|
|
|
- item: {},
|
|
|
- activeColor: '#000',
|
|
|
- back: '#FFFFFF',
|
|
|
- backColor: '#FFFFFF',
|
|
|
- active: '#000',
|
|
|
- // andButton:"&&",
|
|
|
- // orButton:"",
|
|
|
- firstIndex: 1,
|
|
|
- isshow: true,
|
|
|
- // isAnyshow: false,
|
|
|
- isNotAnyRequest: true,
|
|
|
- btnRequest: true,
|
|
|
- expression: '',
|
|
|
- expression1: '',
|
|
|
- expression2: '',
|
|
|
- btnReception: {},
|
|
|
- isAnyRequest: false,
|
|
|
- chooseIndex: 'reset',
|
|
|
- userNames: localStorage.getItem('realname'),
|
|
|
styleObj: {
|
|
|
'color': 'rgba(0, 0, 0, 0.726)'
|
|
|
},
|
|
|
- styleBtn: {
|
|
|
- 'color': '#FFFFFF',
|
|
|
- 'background': '#409EFF'
|
|
|
- },
|
|
|
- ruleForm: {
|
|
|
- maxPrior: -1,
|
|
|
- minPrior: 100,
|
|
|
- execSort: '',
|
|
|
- ruleDesc: '',
|
|
|
- metaRuleList: [{ operator: '', expression: '', judgeType: '', judgeValue: '', and: '', or: '', prior: '', bracket: '' }]
|
|
|
- },
|
|
|
- metaRuleListCache: [],
|
|
|
- rules: {
|
|
|
- execSort: '',
|
|
|
- ruleDesc: ''
|
|
|
- // metaRuleList: [{ operator: '', expression: '', judgeType: '', judgeValue: '' }]
|
|
|
- },
|
|
|
-
|
|
|
- evaluators: [],
|
|
|
- rule: {
|
|
|
- expression1: [
|
|
|
- { required: true, message: '请输入方法', trigger: 'blur' }
|
|
|
- ],
|
|
|
- expression2: [
|
|
|
- { required: true, message: '请输入运算符', trigger: 'blur' }
|
|
|
- ],
|
|
|
- judgeType: [
|
|
|
- { required: true, message: '请选择匹配规则', trigger: 'change' }
|
|
|
- ],
|
|
|
- judgeValue: [
|
|
|
- { required: true, message: '请选择参数', trigger: 'change' }
|
|
|
- ]
|
|
|
- },
|
|
|
tableKey: 0,
|
|
|
list: null,
|
|
|
total: 0,
|
|
@@ -326,52 +196,45 @@ export default {
|
|
|
listQuery: {
|
|
|
curIndex: 1,
|
|
|
pageSize: 20,
|
|
|
- // whenScript: 'any',
|
|
|
+ whenScript: '',
|
|
|
methodId: 0,
|
|
|
execSort: null,
|
|
|
status: null,
|
|
|
methodName: '',
|
|
|
methodProtocol: 'http',
|
|
|
- formLabelWidths: '7px',
|
|
|
- paramtions: {}
|
|
|
+ ruleDesc: '',
|
|
|
+ ruleDescSeen: ''
|
|
|
},
|
|
|
showSubmit: true,
|
|
|
jsonTit: `{ 'code': 200, 'data': { 'crowdComposition': 'U_866', 'campaignId': 789, 'id': 4606, 'class': 'com.didi.prado.config.api.dto.CampaignCrowdDTO'}}`,
|
|
|
- // sortOptions: [{ label: 'ID Ascending', key: '+id' }, { label: 'ID Descending', key: '-id' }],
|
|
|
- // operatorOption: [{ name: '等于', value: "=" }, { name: '大于', value: ">" }, { name: '小于', value: "<" }, { name: '不等于', value: "!=" }],
|
|
|
- operatorOptions: [],
|
|
|
- expressOptions: [],
|
|
|
- expressOptionWithoutAny: [],
|
|
|
- // paramOptions:[{ name: 'any', value: 0 }, { name: 'param', value: 1 },{ name: 'param2', value: 2 }],
|
|
|
+ sortOptions: [{ label: 'ID Ascending', key: '+id' }, { label: 'ID Descending', key: '-id' }],
|
|
|
statusOptions: ['published', 'draft', 'deleted'],
|
|
|
showReviewer: false,
|
|
|
- showRules: false,
|
|
|
ruleData: {
|
|
|
- // methodId: 0,
|
|
|
- // updator: '',
|
|
|
- // methodName: '',
|
|
|
- // execSort: 1,
|
|
|
- // whenScript: '',
|
|
|
- // returnMessage: '',
|
|
|
- // curIndex: 1,
|
|
|
- // pageSize: 20,
|
|
|
- // methodProtocol: 'http'
|
|
|
+ methodId: 0,
|
|
|
+ updator: '',
|
|
|
+ methodName: '',
|
|
|
+ execSort: 1,
|
|
|
+ whenScript: '',
|
|
|
+ ruleDesc: '',
|
|
|
+ returnMessage: '',
|
|
|
+ curIndex: 1,
|
|
|
+ pageSize: 20,
|
|
|
+ methodProtocol: 'http'
|
|
|
},
|
|
|
-
|
|
|
dialogFormVisible: false,
|
|
|
dialogStatus: '',
|
|
|
textMap: {
|
|
|
update: '编辑',
|
|
|
- create: '新增规则',
|
|
|
- check: '查看',
|
|
|
- copy: '复制'
|
|
|
+ create: '新增规则'
|
|
|
},
|
|
|
dialogPvVisible: false,
|
|
|
pvData: [],
|
|
|
roleDataRules: {
|
|
|
whenScript: [{ required: true, message: '规则不能为空', trigger: 'change' }],
|
|
|
execSort: [{ required: true, message: '优先级1-100', trigger: 'change' }],
|
|
|
- returnMessage: [{ required: true, message: '不能为空', trigger: 'change' }]
|
|
|
+ returnMessage: [{ required: true, message: '不能为空', trigger: 'change' }],
|
|
|
+ ruleDesc: [{ required: true, message: '规则描述不能为空', trigger: 'change' }]
|
|
|
// interfaceName: [{ required: true, message: '接口名称不能为空', trigger: 'change' }],
|
|
|
// serviceVersion: [{ required: true, message: '服务版本不能为空', trigger: 'change' }],
|
|
|
// protocol: [{ required: true, message: '请选择协议类型', trigger: 'change' }],
|
|
@@ -381,183 +244,14 @@ export default {
|
|
|
// returnDataStructure: [{ required: true, message: '返回值类型不能为空', trigger: 'change' }]
|
|
|
},
|
|
|
downloadLoading: false,
|
|
|
- sty: { color: '#FFFFFF', background: 'red' },
|
|
|
- stys: { color: '#FFFFFF', background: 'red' },
|
|
|
- or: '或者',
|
|
|
- and: '并且'
|
|
|
+ desc: true
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
this.getList()
|
|
|
this.getFormatJsonStrFromStringRule(this.jsonTit)
|
|
|
- this.getHttpOp()
|
|
|
- this.getExpress()
|
|
|
},
|
|
|
methods: {
|
|
|
- getExpressOpt(index) {
|
|
|
- if (index === 0) {
|
|
|
- return this.expressOptions
|
|
|
- } else {
|
|
|
- return this.expressOptionWithoutAny
|
|
|
- }
|
|
|
- },
|
|
|
- // 优先计算
|
|
|
- queryCel() {
|
|
|
- this.$confirm('确定优先计算吗?', '提示', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning'
|
|
|
- }).then(() => {
|
|
|
- this.$message({
|
|
|
- type: 'success',
|
|
|
- message: '优先计算成功!'
|
|
|
- })
|
|
|
- }).catch(() => {
|
|
|
- this.$message({
|
|
|
- type: 'info',
|
|
|
- message: '已取消优先计算'
|
|
|
- })
|
|
|
- })
|
|
|
- },
|
|
|
- // 改变逻辑button
|
|
|
- changeAnd(index) {
|
|
|
- this.$refs.and[index].$el.style.color = '#FFFFFF'
|
|
|
- this.$refs.and[index].$el.style.background = '#409EFF'
|
|
|
- this.$refs.or[index].$el.style.color = '#606266'
|
|
|
- this.$refs.or[index].$el.style.background = '#FFFFFF'
|
|
|
-
|
|
|
- this.ruleForm.metaRuleList[index].operator = '&&'
|
|
|
- console.log(this.ruleForm.metaRuleList[index].operator)
|
|
|
- },
|
|
|
- changeOr(index) {
|
|
|
- this.$refs.or[index].$el.style.color = '#FFFFFF'
|
|
|
- this.$refs.or[index].$el.style.background = '#409EFF'
|
|
|
- this.$refs.and[index].$el.style.color = '#606266'
|
|
|
- this.$refs.and[index].$el.style.background = '#FFFFFF'
|
|
|
- this.ruleForm.metaRuleList[index].operator = '||'
|
|
|
- },
|
|
|
- updateStyle() {
|
|
|
- // i从1开始,因为第一个不显示
|
|
|
- for (let i = 1, len = this.ruleForm.metaRuleList.length; i < len; i++) {
|
|
|
- // 操作符颜色
|
|
|
- if (this.ruleForm.metaRuleList[i].operator === '||') {
|
|
|
- this.changeOr(i)
|
|
|
- } else {
|
|
|
- this.changeAnd(i)
|
|
|
- }
|
|
|
- // 优先级背景
|
|
|
- this.priorChanged(i)
|
|
|
- }
|
|
|
- },
|
|
|
- addList(index) {
|
|
|
- // this.num===index
|
|
|
- if (this.ruleForm.metaRuleList.length >= 10) {
|
|
|
- alert('不准再加啦')
|
|
|
- return
|
|
|
- }
|
|
|
- this.ruleForm.metaRuleList.push({ operator: '&&' })
|
|
|
- },
|
|
|
- delList(index) {
|
|
|
- this.num === index
|
|
|
- this.ruleForm.metaRuleList.splice(index, 1)
|
|
|
- console.log(this.num)
|
|
|
- console.log(index)
|
|
|
- },
|
|
|
- chooseTest(val) {
|
|
|
- console.log('chooseTest:' + val)
|
|
|
- this.isNotAnyRequest = true
|
|
|
- this.isAnyRequest = false
|
|
|
- this.ruleForm.metaRuleList = this.metaRuleListCache
|
|
|
- this.ruleForm.metaRuleList[0].expression1 = val
|
|
|
- // this.ruleForm.metaRuleList.push({'expression1': val })
|
|
|
- delete this.rules.whenScript
|
|
|
- // this.paramOptions.push(0,0,{ name: 'any', value: 0 })
|
|
|
- },
|
|
|
- chooseTest1(val) {
|
|
|
- this.expression1 = val
|
|
|
- console.log(val)
|
|
|
- if (this.ruleForm.metaRuleList[0].expression1 === 'any') {
|
|
|
- this.rules.whenScript = 'any'
|
|
|
- this.isAnyRequest = true
|
|
|
- this.isNotAnyRequest = false
|
|
|
- this.metaRuleListCache = this.ruleForm.metaRuleList
|
|
|
- this.ruleForm.metaRuleList = []
|
|
|
- // this.isAnyshow = true
|
|
|
- } else {
|
|
|
- this.isNotAnyRequest = true
|
|
|
- this.isAnyRequest = false
|
|
|
-
|
|
|
- // 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 => {
|
|
|
- this.operatorOptions = response.data
|
|
|
- })
|
|
|
- },
|
|
|
- // 获取规则表达式
|
|
|
- getExpress() {
|
|
|
- getExpress().then(response => {
|
|
|
- this.expressOptions = response.data
|
|
|
- this.expressOptions.forEach((opt, index) => {
|
|
|
- if (opt.desc === 'any') {
|
|
|
- return true
|
|
|
- }
|
|
|
- this.expressOptionWithoutAny.push(opt)
|
|
|
- })
|
|
|
- })
|
|
|
- },
|
|
|
- // 根据index和maxPrior,minPrior状态决定复选框是否被禁用
|
|
|
- priorDistabledStatus(index) {
|
|
|
- var maxMin = this.findMaxMinOfMetaList()
|
|
|
- var min = maxMin.min
|
|
|
- var max = maxMin.max
|
|
|
- if (max === -1 || // 初始状态,一个都没勾选
|
|
|
- index === min || index === min - 1 || index === max || index === max + 1) {
|
|
|
- return false // 置白
|
|
|
- } else {
|
|
|
- return true // 置灰
|
|
|
- }
|
|
|
- },
|
|
|
- // 优先级计算----直接用disable来判断,改变maxPrior,minPrior状态驱动展示变化,见priorDistabledStatus方法
|
|
|
- priorChanged(index) {
|
|
|
- console.log('priorChanged ' + index)
|
|
|
- console.log(this.$refs)
|
|
|
- console.log('max ' + this.ruleForm.maxPrior + ' min ' + this.ruleForm.minPrior)
|
|
|
- // this.$refs.priorBackgroup[index].$el.style.color = '#FFFFFF'
|
|
|
- if (this.ruleForm.metaRuleList[index].prior === true) {
|
|
|
- this.$refs.priorBackgroup[index].$el.style.background = '#F4F4F5'
|
|
|
- } else {
|
|
|
- this.$refs.priorBackgroup[index].$el.style.background = '#FFFFFF'
|
|
|
- }
|
|
|
- },
|
|
|
- findMaxMinOfMetaList() {
|
|
|
- var maxMin = {
|
|
|
- max: -1,
|
|
|
- min: -1
|
|
|
- }
|
|
|
- for (let i = 0, len = this.ruleForm.metaRuleList.length; i < len; i++) {
|
|
|
- if (this.ruleForm.metaRuleList[i].prior === true) {
|
|
|
- maxMin.max = i
|
|
|
- if (maxMin.min === -1) {
|
|
|
- maxMin.min = i
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return maxMin
|
|
|
- },
|
|
|
prev() {
|
|
|
this.$router.go(-1)
|
|
|
},
|
|
@@ -572,7 +266,7 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
returnMessageData() {
|
|
|
- this.getFormatJsonStrFromStringRule1(this.rules.returnMessage)
|
|
|
+ this.getFormatJsonStrFromStringRule1(this.ruleData.returnMessage)
|
|
|
},
|
|
|
getFormatJsonStrFromStringRule: function(jsonStr) {
|
|
|
var res = ''
|
|
@@ -614,10 +308,10 @@ export default {
|
|
|
res += ele
|
|
|
}
|
|
|
// eslint-disable-next-line no-return-assign
|
|
|
- return this.rules.returnMessage = res
|
|
|
+ return this.ruleData.returnMessage = res
|
|
|
},
|
|
|
updateEnvChannel(v) {
|
|
|
- this.rules.envChannel = v
|
|
|
+ this.ruleData.envChannel = v
|
|
|
this.envSelections = []
|
|
|
fetchEnvInfo(v).then(response => {
|
|
|
for (var sel of response.data) {
|
|
@@ -648,24 +342,15 @@ export default {
|
|
|
this.handleFilter()
|
|
|
},
|
|
|
resetServiceData() {
|
|
|
- this.rules = {
|
|
|
+ this.ruleData = {
|
|
|
methodId: 0,
|
|
|
updator: '',
|
|
|
execSort: 1,
|
|
|
whenScript: '',
|
|
|
returnMessage: '',
|
|
|
- metaRuleList: [],
|
|
|
curIndex: 1,
|
|
|
pageSize: 20
|
|
|
}
|
|
|
- this.ruleForm = {
|
|
|
- maxPrior: -1,
|
|
|
- minPrior: 100,
|
|
|
- execSort: '',
|
|
|
- ruleDesc: '',
|
|
|
- metaRuleList: [{ operator: '', expression: '', judgeType: '', judgeValue: '', and: '', or: '', prior: '', bracket: '' }]
|
|
|
- }
|
|
|
- this.metaRuleListCache = []
|
|
|
},
|
|
|
handleCreate() {
|
|
|
this.resetServiceData()
|
|
@@ -673,121 +358,53 @@ export default {
|
|
|
this.dialogFormVisible = true
|
|
|
this.showSubmit = true
|
|
|
this.$nextTick(() => {
|
|
|
- this.$refs['ruleForm'].clearValidate()
|
|
|
+ this.$refs['ruleDataForm'].clearValidate()
|
|
|
})
|
|
|
},
|
|
|
- copyAndDecorateMetaRuleFromRuleForm() {
|
|
|
- var maxMin = this.findMaxMinOfMetaList()
|
|
|
- var copiedMetaRuleList = []
|
|
|
- for (let i = 0, len = this.ruleForm.metaRuleList.length; i < len; i++) {
|
|
|
- var r = this.ruleForm.metaRuleList[i]
|
|
|
- var copiedRule = { 'judgeType': r.judgeType, 'judgeValue': r.judgeValue, 'operator': r.operator }
|
|
|
- copiedRule.expression = r.expression1 + '.' + r.expression2
|
|
|
- if (i === maxMin.min) {
|
|
|
- copiedRule.operator = r.operator + '('
|
|
|
- }
|
|
|
- if (i === (maxMin.max + 1)) {
|
|
|
- copiedRule.operator = ')' + r.operator
|
|
|
- }
|
|
|
- copiedMetaRuleList.push(copiedRule)
|
|
|
- }
|
|
|
- if (maxMin.max === (this.ruleForm.metaRuleList.length - 1)) {
|
|
|
- copiedMetaRuleList.push({ 'operator': ')' })
|
|
|
- }
|
|
|
- return copiedMetaRuleList
|
|
|
- },
|
|
|
- createOrUpdate(createFlag, remoteFunc) {
|
|
|
- const shouldJson = this.rules.returnMessage
|
|
|
+ createData() {
|
|
|
+ const shouldJson = this.ruleData.returnMessage
|
|
|
+ console.log('dasdsadsad' + typeof (shouldJson))
|
|
|
+ if (this.ruleData.whenScript === '') { this.ruleData.whenScript = 'any' }
|
|
|
if (typeof shouldJson === 'string') {
|
|
|
- this.$refs['ruleForm'].validate((valid) => {
|
|
|
+ this.$refs['ruleDataForm'].validate((valid) => {
|
|
|
if (valid) {
|
|
|
- // delete this.rules.id
|
|
|
- // 任意请求
|
|
|
- if (this.rules.whenScript === 'any') {
|
|
|
- delete this.rules.metaRuleList
|
|
|
- } else {
|
|
|
- // 正常请求
|
|
|
- this.rules.metaRuleList = this.copyAndDecorateMetaRuleFromRuleForm()
|
|
|
- }
|
|
|
- this.rules.methodId = parseInt(this.$route.path.split('/')[3])
|
|
|
- this.rules.methodProtocol = 'http'
|
|
|
- this.rules.updator = this.userNames
|
|
|
- remoteFunc(this.rules)
|
|
|
- }
|
|
|
- }
|
|
|
- )
|
|
|
- }
|
|
|
- },
|
|
|
- createData(vel) {
|
|
|
- this.createOrUpdate('create', (data) => {
|
|
|
- createRule(this.rules).then(response => {
|
|
|
- if (response.code === 200) {
|
|
|
- this.dialogFormVisible = false
|
|
|
- this.getList()
|
|
|
- this.$notify({
|
|
|
- title: 'Success',
|
|
|
- message: 'Created Successfully',
|
|
|
- type: 'success',
|
|
|
- duration: 2000
|
|
|
- })
|
|
|
- } else {
|
|
|
- this.$notify({
|
|
|
- title: 'Failed',
|
|
|
- message: 'Created Failed',
|
|
|
- type: 'error',
|
|
|
- duration: 2000
|
|
|
+ delete this.ruleData.id
|
|
|
+ this.ruleData.methodProtocol = 'http'
|
|
|
+ this.ruleData.methodId = parseInt(this.$route.path.split('/')[3])
|
|
|
+ createRule(this.ruleData).then(response => {
|
|
|
+ console.log(this.ruleData)
|
|
|
+ if (response.code === 200) {
|
|
|
+ this.dialogFormVisible = false
|
|
|
+ this.getList()
|
|
|
+ this.$notify({
|
|
|
+ title: 'Success',
|
|
|
+ message: 'Created Successfully',
|
|
|
+ type: 'success',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.$notify({
|
|
|
+ title: 'Failed',
|
|
|
+ message: 'Created Failed',
|
|
|
+ type: 'error',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
- })
|
|
|
+ }
|
|
|
},
|
|
|
- handleUpdate(row, status) {
|
|
|
- fetchRuleById({ id: row.id }).then(response => {
|
|
|
- if (response.code !== 200) {
|
|
|
- this.$message({
|
|
|
- message: row.id.toString() + ' 操作失败!',
|
|
|
- type: 'danger'
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- this.resetServiceData()
|
|
|
- this.dialogStatus = status
|
|
|
- this.showSubmit = status !== 'check'
|
|
|
- this.dialogFormVisible = true
|
|
|
+ handleUpdate(row) {
|
|
|
+ var queryData = { id: row.id }
|
|
|
+ fetchRuleById(queryData).then(response => {
|
|
|
var row_data = response.data.mockRuleList
|
|
|
- var m = row_data[0].metaRuleList
|
|
|
- this.ruleForm.metaRuleList = []
|
|
|
- for (let i = 0, len = m.length; i < len; i++) {
|
|
|
- // 括号在最后时特殊处理
|
|
|
- var metaRule = m[i]
|
|
|
- if (metaRule.operator === ')') {
|
|
|
- this.ruleForm.metaRuleList[i - 1].prior = true
|
|
|
- continue
|
|
|
- }
|
|
|
- // 优先级处理
|
|
|
- var prior = false
|
|
|
- if (metaRule.operator.indexOf('(') !== -1) {
|
|
|
- prior = true
|
|
|
- }
|
|
|
- if (metaRule.operator.indexOf(')') !== -1) {
|
|
|
- this.ruleForm.metaRuleList[i - 1].prior = true
|
|
|
- }
|
|
|
- metaRule.operator = metaRule.operator.replace(/\(|\)/, '')
|
|
|
- // 分割表达式
|
|
|
- var exp = metaRule.expression.split('.')
|
|
|
- this.ruleForm.metaRuleList.push({ 'prior': prior, 'operator': metaRule.operator, 'expression1': exp[0], 'expression2': exp[1], 'judgeType': metaRule.judgeType, 'judgeValue': metaRule.judgeValue })
|
|
|
- console.log(this.ruleForm.metaRuleList[i])
|
|
|
- }
|
|
|
- this.rules = Object.assign({}, row_data[0])
|
|
|
- if (status === 'copy') {
|
|
|
- delete this.rules.id
|
|
|
- }
|
|
|
-
|
|
|
- // 校验个样式更新清理
|
|
|
+ this.ruleData = Object.assign({}, row_data[0])
|
|
|
+ this.dialogStatus = 'update'
|
|
|
+ this.dialogFormVisible = true
|
|
|
+ this.showSubmit = true
|
|
|
this.$nextTick(() => {
|
|
|
- this.$refs['ruleForm'].clearValidate()
|
|
|
- // 更新优先级和操作符的样式
|
|
|
- this.updateStyle()
|
|
|
+ this.$refs['ruleDataForm'].clearValidate()
|
|
|
})
|
|
|
})
|
|
|
},
|
|
@@ -811,18 +428,51 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ handleCopy(row) {
|
|
|
+ // this.ruleData = {
|
|
|
+ // // id: row.id,
|
|
|
+ // customName: row.customName,
|
|
|
+ // httpUrl: row.httpUrl,
|
|
|
+ // execSort: row.execSort,
|
|
|
+ // whenScript: row.whenScript,
|
|
|
+ // methodProtocol: row.methodProtocol,
|
|
|
+ // status: row.status,
|
|
|
+ // returnMessage: row.returnMessage
|
|
|
+ // }
|
|
|
+ this.ruleData = Object.assign({}, row) // copy obj
|
|
|
+ this.ruleData.timestamp = new Date(this.ruleData.timestamp)
|
|
|
+ this.dialogStatus = 'create'
|
|
|
+ this.dialogFormVisible = true
|
|
|
+ this.showSubmit = true
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs['ruleDataForm'].clearValidate()
|
|
|
+ })
|
|
|
+ },
|
|
|
updateData() {
|
|
|
- this.createOrUpdate('update', (data) => {
|
|
|
- updateRule(data).then(() => {
|
|
|
- this.getList()
|
|
|
- this.dialogFormVisible = false
|
|
|
- this.$notify({
|
|
|
- title: 'Success',
|
|
|
- message: 'Update Successfully',
|
|
|
- type: 'success',
|
|
|
- duration: 2000
|
|
|
+ this.$refs['ruleDataForm'].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ // const tempData = Object.assign({}, this.ruleData)
|
|
|
+ const tempData = {
|
|
|
+ id: this.ruleData.id,
|
|
|
+ methodId: parseInt(this.$route.path.split('/')[3]),
|
|
|
+ updator: '',
|
|
|
+ execSort: this.ruleData.execSort,
|
|
|
+ whenScript: this.ruleData.whenScript,
|
|
|
+ returnMessage: this.ruleData.returnMessage,
|
|
|
+ mehtodName: this.$route.query.methodName,
|
|
|
+ methodProtocol: this.$route.query.methodProtocol
|
|
|
+ }
|
|
|
+ updateRule(tempData).then(() => {
|
|
|
+ this.getList()
|
|
|
+ this.dialogFormVisible = false
|
|
|
+ this.$notify({
|
|
|
+ title: 'Success',
|
|
|
+ message: 'Update Successfully',
|
|
|
+ type: 'success',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
})
|
|
|
- })
|
|
|
+ }
|
|
|
})
|
|
|
},
|
|
|
formatJson(filterVal, jsonData) {
|
|
@@ -833,44 +483,36 @@ export default {
|
|
|
return v[j]
|
|
|
}
|
|
|
}))
|
|
|
+ },
|
|
|
+ handleCheck(row) {
|
|
|
+ var queryData = { id: row.id }
|
|
|
+ fetchRuleById(queryData).then(response => {
|
|
|
+ console.log('aaaaaaaaa' + response)
|
|
|
+ var row_data = response.data.mockRuleList
|
|
|
+ this.ruleData = Object.assign({}, row_data[0])
|
|
|
+ this.dialogStatus = 'update'
|
|
|
+ this.dialogFormVisible = true
|
|
|
+ this.showSubmit = false
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs['ruleDataForm'].clearValidate()
|
|
|
+ })
|
|
|
+ })
|
|
|
}
|
|
|
+ // descEnter() {
|
|
|
+ // console.log('1111')
|
|
|
+ // this.listQuery.ruleDescSeen = true
|
|
|
+ // },
|
|
|
+ // descLeave() {
|
|
|
+ // this.listQuery.ruleDescSeen = false
|
|
|
+ // }
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
-<style scoped>
|
|
|
+<style>
|
|
|
.el-notification.right{
|
|
|
position: fixed;
|
|
|
- right: 38.5%;}
|
|
|
-
|
|
|
-.continer div{
|
|
|
-display:none;/*默认隐藏*/
|
|
|
-}
|
|
|
-.continer:hover div{
|
|
|
-display:initial;/*当鼠标hover时展示*/
|
|
|
-}
|
|
|
-
|
|
|
-.cardBackground{
|
|
|
- background-color: #e3e4e54a;
|
|
|
- border-top: 1px solid #ddd;
|
|
|
- border-bottom: 1px solid #ddd;
|
|
|
- }
|
|
|
-.red {
|
|
|
- color: red;
|
|
|
- font-size: 14px;
|
|
|
- }
|
|
|
- .blue {
|
|
|
- color: blue;
|
|
|
- font-size: 14px;
|
|
|
- }
|
|
|
- .liBackground {
|
|
|
- background-color: #409EFF;
|
|
|
+ right: 38.5%;
|
|
|
}
|
|
|
-
|
|
|
- .sty { color: 'red';background: '#FFFFFF'; }
|
|
|
- .stys { color: '#FFFFFF'; background: 'red'; }
|
|
|
-/* .el-col {
|
|
|
- white-space:nowrap;
|
|
|
-} */
|
|
|
-
|
|
|
</style>
|
|
|
+
|