Commit 0d965ac4 authored by levante's avatar levante

123

parent 714f5989
...@@ -146,10 +146,11 @@ ...@@ -146,10 +146,11 @@
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="2" offset="1"> <a-col :span="2" offset="1">
<!-- {{item}} -->
<a-button <a-button
v-if="index + 1 == rowLoop.length" v-if="index + 1 == rowLoop.length"
icon="minus" icon="minus"
@click="deleteRow()" @click="deleteRow(item.randomNum)"
></a-button> ></a-button>
<a-button <a-button
v-if="index + 1 == rowLoop.length" v-if="index + 1 == rowLoop.length"
...@@ -275,9 +276,10 @@ export default { ...@@ -275,9 +276,10 @@ export default {
}, },
formStoreList: [], formStoreList: [],
rowLoop: [{ rowLoop: [{
first: '', key: '',
second: '', type: '',
third: '' name: '',
randomNum: Math.random()
}], }],
businessOptionsList: [], businessOptionsList: [],
editId: null, editId: null,
...@@ -295,8 +297,9 @@ export default { ...@@ -295,8 +297,9 @@ export default {
}, },
onEdit(id) { onEdit(id) {
this.rowLoop = [{ this.rowLoop = [{
name: '',
key: '', key: '',
type: '',
name: '',
randomNum: Math.random() randomNum: Math.random()
}] }]
this.isShow = !this.isShow this.isShow = !this.isShow
...@@ -396,7 +399,9 @@ export default { ...@@ -396,7 +399,9 @@ export default {
onCreate() { onCreate() {
this.rowLoop = [{ this.rowLoop = [{
name: '', name: '',
key: '' type: '',
key: '',
randomNum: Math.random()
}] }]
this.current = 0 this.current = 0
this.form.resetFields() this.form.resetFields()
...@@ -474,10 +479,13 @@ export default { ...@@ -474,10 +479,13 @@ export default {
this.rowLoop.push({ this.rowLoop.push({
key: '', key: '',
type: '', type: '',
name: '' name: '',
randomNum: Math.random()
}) })
}, },
deleteRow() {} deleteRow(randomNum) {
this.rowLoop = this.rowLoop.filter(i => i.randomNum !== randomNum)
}
} }
} }
</script> </script>
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
</a-form-item> </a-form-item>
<a-form-item label="系统地址" :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }"> <a-form-item label="系统地址" :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }">
<a-input v-decorator="['url', {validateTrigger:'blur', rules: [{required: true, message: '请填写此项!'}]}]" /> <a-input v-decorator="['url', {validateTrigger:'blur', rules: [{required: true, message: '请填写此项!'}, {validator: formatValidate}]}]" />
</a-form-item> </a-form-item>
</div> </div>
<div v-show="current == 1"> <div v-show="current == 1">
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
</a-form-item> </a-form-item>
<a-row> <a-row>
{{rowLoop}} <!-- {{rowLoop}} -->
<a-col :span='5' style="text-align: right; color: black">授权参数:</a-col> <a-col :span='5' style="text-align: right; color: black">授权参数:</a-col>
<a-col :span='19'> <a-col :span='19'>
<a-row v-for="(item, index) in rowLoop" :key="index"> <a-row v-for="(item, index) in rowLoop" :key="index">
...@@ -210,6 +210,14 @@ export default { ...@@ -210,6 +210,14 @@ export default {
this.getList() this.getList()
}, },
methods: { methods: {
formatValidate(type, value, callback) {
console.log(type, value)
const filter = /^[A-Za-z]:[\w]+$/i
if(!filter.test(value)){
callback('请输入正确的路径!')
}
},
cancelModal() { cancelModal() {
console.log(123) console.log(123)
this.form.resetFields() this.form.resetFields()
...@@ -282,7 +290,6 @@ export default { ...@@ -282,7 +290,6 @@ export default {
deleteRow(randomNum) { deleteRow(randomNum) {
// this.rowLoop.splice(index, 1) // this.rowLoop.splice(index, 1)
this.rowLoop = this.rowLoop.filter(i => i.randomNum !== randomNum) this.rowLoop = this.rowLoop.filter(i => i.randomNum !== randomNum)
console.log(this.rowLoop)
}, },
getList() { getList() {
this.$ajax.post({ this.$ajax.post({
......
...@@ -36,8 +36,8 @@ ...@@ -36,8 +36,8 @@
<a-tag v-for="(item, index) in record.rules" :key="index">{{`{` + record.rules[index].key + `: `+ record.rules[index].value + `}`}}</a-tag> <a-tag v-for="(item, index) in record.rules" :key="index">{{`{` + record.rules[index].key + `: `+ record.rules[index].value + `}`}}</a-tag>
</span> </span>
</a-table> </a-table>
<a-modal title="新建规则" v-model="isShow" width='900px' style="padding: 20px" centered> <a-modal title="新建规则" v-model="isShow" width='900px' style="padding: 20px" centered destroyOnClose @cancel='cancelModal()'>
<a-form :form='form'> <a-form :form='form' style="height: 300px; overflow-y: scroll">
<a-form-item label="触发服务" :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }"> <a-form-item label="触发服务" :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }">
<a-select placeholder="请选择触发服务" v-decorator="['trigger', {validateTrigger:'blur', rules: [{required: true, message: '请选择此项!'}]}]"> <a-select placeholder="请选择触发服务" v-decorator="['trigger', {validateTrigger:'blur', rules: [{required: true, message: '请选择此项!'}]}]">
<a-select-option v-for="(item) in triggerOptions" :key="item.id">{{item.name}}</a-select-option> <a-select-option v-for="(item) in triggerOptions" :key="item.id">{{item.name}}</a-select-option>
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</a-select> </a-select>
</a-form-item> </a-form-item>
<a-form-item label="规则字段定义key&value" :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }"> <!-- <a-form-item label="规则字段定义" :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }">
<a-textarea <a-textarea
v-decorator="[ v-decorator="[
'rules', 'rules',
...@@ -58,15 +58,62 @@ ...@@ -58,15 +58,62 @@
validateTrigger: 'blur', validateTrigger: 'blur',
rules: [ rules: [
{ required: true, message: '请填写此项!' }, { required: true, message: '请填写此项!' },
{validator: confirmJson} { validator: confirmJson}
] ]
} }
]" ]"
/> />
</a-form-item> -->
<a-row>
<a-col :span='5' style="text-align: right; color: black">规则字段定义:</a-col>
<a-col :span='19'>
<a-row v-for="(item, index) in rowLoop" :key="index">
<a-col :span="7">
<a-form-item>
<a-input
v-decorator="[
'key' + index,
{
validateTrigger: 'blur',
rules: [{ required: true, message: '请填写此项!' }]
}
]"
/>
</a-form-item> </a-form-item>
</a-col>
<a-col :span="7" offset="1">
<a-form-item>
<a-input
v-decorator="[
'value' + index,
{
validateTrigger: 'blur',
rules: [{ required: true, message: '请填写此项!' }]
}
]"
/>
</a-form-item>
</a-col>
<a-col :span="4" offset="1">
<a-button
v-if="index + 1 == rowLoop.length"
icon="minus"
@click="deleteRow(item.randomNum)"
></a-button>
<a-button
v-if="index + 1 == rowLoop.length"
icon="plus"
@click="addRow()"
></a-button>
</a-col>
</a-row>
</a-col>
</a-row>
</a-form> </a-form>
<template slot="footer"> <template slot="footer">
<a-button key="back" @click="isShow = !isShow"> <a-button key="back" @click="cancelModal()">
取消 取消
</a-button> </a-button>
<a-button type="primary" @click="handleRegisterOk()"> <a-button type="primary" @click="handleRegisterOk()">
...@@ -84,8 +131,9 @@ export default { ...@@ -84,8 +131,9 @@ export default {
data() { data() {
return { return {
rowLoop: [{ rowLoop: [{
name: '', key: '',
key: '' value: '',
randomNum: Math.random()
}], }],
form: this.$form.createForm(this), form: this.$form.createForm(this),
current: 0, current: 0,
...@@ -136,7 +184,6 @@ export default { ...@@ -136,7 +184,6 @@ export default {
{ {
title: '规则字段定义', title: '规则字段定义',
dataIndex: 'rules', dataIndex: 'rules',
align: 'center',
key: 'rules', key: 'rules',
scopedSlots: { scopedSlots: {
customRender: 'rules', customRender: 'rules',
...@@ -163,7 +210,8 @@ export default { ...@@ -163,7 +210,8 @@ export default {
}, },
formStoreList: [], formStoreList: [],
triggerOptions: [], triggerOptions: [],
actionOptions: [] actionOptions: [],
editId: null
} }
}, },
mounted() { mounted() {
...@@ -191,9 +239,20 @@ export default { ...@@ -191,9 +239,20 @@ export default {
} }
if(Object.keys(record)[i] == 'rules') { if(Object.keys(record)[i] == 'rules') {
this.form.getFieldDecorator('rules', {'initialValue': JSON.stringify(Object.values(record)[i]).split('[').split(']')}) for (let j = 0; j < Object.values(record)[i].length; j++) {
if(j !== 0) {
this.addRow()
}
console.log(Object.values(record)[i][j].key)
this.form.getFieldDecorator('key' + j, {'initialValue': Object.values(record)[i][j].key})
this.form.getFieldDecorator('value' + j, {'initialValue': Object.values(record)[i][j].value})
} }
} }
// if(Object.keys(record)[i] == 'rules') {
// this.form.getFieldDecorator('rules', {'initialValue': JSON.stringify(Object.values(record)[i])})
// }
}
} }
}, },
getTriggerServiceOption() { getTriggerServiceOption() {
...@@ -228,6 +287,16 @@ export default { ...@@ -228,6 +287,16 @@ export default {
} }
}) })
}, },
cancelModal() {
console.log(123)
this.rowLoop = [{
key: '',
value: '',
randomNum: Math.random()
}],
this.form.resetFields()
this.isShow = !this.isShow
},
initPagination() { initPagination() {
this.pagination.pageNo = 1 this.pagination.pageNo = 1
this.pagination.current = 1 this.pagination.current = 1
...@@ -238,6 +307,8 @@ export default { ...@@ -238,6 +307,8 @@ export default {
} else if(typeof value == 'string') { } else if(typeof value == 'string') {
try { try {
let obj=JSON.parse(value) let obj=JSON.parse(value)
console.log(obj)
if(typeof obj == 'object' && obj ){ if(typeof obj == 'object' && obj ){
callback() callback()
} else { } else {
...@@ -272,11 +343,14 @@ export default { ...@@ -272,11 +343,14 @@ export default {
}, },
addRow() { addRow() {
this.rowLoop.push({ this.rowLoop.push({
name: '', key: '',
key: '' value: '',
randomNum: Math.random()
}) })
}, },
deleteRow() {}, deleteRow(randomNum) {
this.rowLoop = this.rowLoop.filter(i => i.randomNum !== randomNum)
},
getList() { getList() {
this.$ajax.post({ this.$ajax.post({
url: this.$api.GET_RULES_LIST, url: this.$api.GET_RULES_LIST,
...@@ -320,10 +394,36 @@ export default { ...@@ -320,10 +394,36 @@ export default {
const action = this.actionOptions.find(item => item.id == formContent.action) const action = this.actionOptions.find(item => item.id == formContent.action)
let paramsJson = []
for (let i = 0; i < this.rowLoop.length; i++) {
paramsJson.push({
key: formContent['key' + i],
value: formContent['value' + i]
})
}
if(!!this.editId) {
this.$ajax.put({
url: this.$api.PUT_RULE_RECORD.replace('{id}', this.editId),
params: {
rules: paramsJson,
trigger,
action
}
}).then(res => {
if(res.code == '200') {
this.$message.success('修改成功!')
this.cancelModal()
this.form.resetFields()
this.getList()
}
})
} else {
this.$ajax.post({ this.$ajax.post({
url: this.$api.POST_ADD_RULE_RECORD, url: this.$api.POST_ADD_RULE_RECORD,
params: { params: {
rules: [JSON.parse(this.form.getFieldValue('rules'))], rules: paramsJson,
trigger, trigger,
action action
} }
...@@ -335,6 +435,9 @@ export default { ...@@ -335,6 +435,9 @@ export default {
this.getList() this.getList()
} }
}) })
}
this.editId = null
} else { } else {
this.$message.info('请填写表单所有项目!') this.$message.info('请填写表单所有项目!')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment