Commit 714f5989 authored by levante's avatar levante

123

parent 8e2ccf1c
......@@ -245,19 +245,24 @@ export default {
GET_BUSINESS_LIST: '/api/ifttt-center/business/system/query',
POST_ADD_BUSINESS_RECORD: '/api/ifttt-center/business/system',
DELETE_BUSINESS_RECORD: '/api/ifttt-center/business/system/delete/{id}',
PUT_BUSINESS_RECORD: '/api/ifttt-center/business/system/update/{id}',
// trigger
GET_TRIGGER_LIST: '/api/ifttt-center/trigger/query',
POST_ADD_TRIGGER_RECORD: '/api/ifttt-center/trigger',
DELETE_TRIGGER_RECORD: '/api/ifttt-center/trigger/delete/{id}',
PUT_TRIGGER_RECORD: '/api/ifttt-center/trigger/update/{id}',
// action
GET_ACTION_LIST: '/api/ifttt-center/action/query',
POST_ADD_ACTION_RECORD: '/api/ifttt-center/action',
DELETE_ACTION_RECORD: '/api/ifttt-center/action/delete/{id}',
PUT_ACTION_RECORD: '/api/ifttt-center/action/update/{id}',
// rules
GET_RULES_LIST: '/api/ifttt-center/iftttrule/query',
POST_ADD_RULE_RECORD: '/api/ifttt-center/iftttrule',
DELETE_RULE_RECORD: '/api/ifttt-center/iftttrule/delete/{id}'
DELETE_RULE_RECORD: '/api/ifttt-center/iftttrule/delete/{id}',
PUT_RULE_RECORD: '/api/ifttt-center/iftttrule/update/{id}',
GET_RULES_BY_TRIGGER_CODE: '/api/ifttt-center/iftttrule/trigger/code/{code}'
}
......@@ -23,7 +23,7 @@
}"
>
<span slot="operation" slot-scope="text, record">
<span class="actionBtn" @click="onEdit(record)">编辑</span>
<span class="actionBtn" @click="onEdit(record.id)">编辑</span>
<span class="actionBtn" @click="onDelete(record.id)">删除</span>
</span>
<span slot="no" slot-scope="text, record, index">
......@@ -35,6 +35,9 @@
v-model="isShow"
width="900px"
style="padding: 20px"
centered
destroyOnClose
@cancel="cancelModal()"
>
<template slot="footer">
<a-button key="back" @click="isShow = !isShow">
......@@ -228,6 +231,7 @@ export default {
},
],
businessOptionsList: [],
editId: null
}
},
mounted() {
......@@ -235,6 +239,25 @@ export default {
this.getBusinessOptions()
},
methods: {
onEdit(id) {
this.rowLoop = [{
name: '',
key: '',
randomNum: Math.random()
}]
this.isShow = !this.isShow
let record = this.list.find(item => item.id == id)
console.log(record)
if(!!record) {
this.editId = id
for (let i = 0; i < Object.keys(record).length; i++) {
this.form.getFieldDecorator(Object.keys(record)[i], {initialValue: Object.values(record)[i]})
}
}
},
confirmJson(rule, value, callback) {
if (!value || value == undefined) {
callback('不能为空!')
......@@ -321,6 +344,10 @@ export default {
this.selectedRowKeys = selectedRowKeys
},
onCreate() {
this.rowLoop = [{
name: '',
key: ''
}]
this.current = 0
this.form.resetFields()
this.isShow = !this.isShow
......@@ -333,22 +360,44 @@ export default {
handleNextStep() {
this.current += 1
},
cancelModal() {
this.form.resetFields()
this.current = 0
this.isShow = !this.isShow
},
handleRegisterOk() {
this.form.validateFields((err, values) => {
if (!err) {
let formContent = this.form.getFieldsValue()
if(!!this.editId) {
this.$ajax.put({
url: this.$api.PUT_ACTION_RECORD.replace('{id}', this.editId),
params: formContent
}).then(res => {
if(res.code == '200') {
this.$message.success('修改成功!')
this.cancelModal()
this.form.resetFields()
this.getList()
}
})
} else {
this.$ajax.post({
url: this.$api.POST_ADD_ACTION_RECORD,
params: formContent
}).then(res => {
if(res.code == '200') {
this.$message.success('新增成功!')
this.isShow = !this.isShow
this.cancelModal()
this.form.resetFields()
this.getList()
}
})
}
this.editId = null
} else {
this.$message.info('请填写表单所有项目!')
}
......
......@@ -23,7 +23,7 @@
}"
>
<span slot="operation" slot-scope="text, record">
<span class="actionBtn" @click="onEdit(record)">编辑</span>
<span class="actionBtn" @click="onEdit(record.id)">编辑</span>
<span class="actionBtn" @click="onDelete(record.id)">删除</span>
</span>
<span slot="no" slot-scope="text, record, index">
......@@ -35,11 +35,14 @@
v-model="isShow"
width="900px"
style="padding: 20px"
centered
@cancel='cancelModal()'
destroyOnClose
>
<a-steps :current="current" style="margin-bottom: 20px">
<a-step v-for="item in steps" :key="item.title" :title="item.title" />
</a-steps>
<div class="steps-content">
<div class="steps-content" style="height: 300px; overflow-y: scroll">
<!-- {{ steps[current].content }} -->
<a-form :form="form">
<div v-show="current == 0">
......@@ -276,7 +279,8 @@ export default {
second: '',
third: ''
}],
businessOptionsList: []
businessOptionsList: [],
editId: null,
}
},
mounted() {
......@@ -284,6 +288,46 @@ export default {
this.getBusinessOptions()
},
methods: {
cancelModal() {
this.form.resetFields()
this.current = 0
this.isShow = !this.isShow
},
onEdit(id) {
this.rowLoop = [{
name: '',
key: '',
randomNum: Math.random()
}]
this.isShow = !this.isShow
let record = this.list.find(item => item.id == id)
console.log(record)
if(!!record) {
this.editId = id
console.log(Object.keys(record))
for (let i = 0; i < Object.keys(record).length; i++) {
if(Object.keys(record)[i] !== 'args') {
this.form.getFieldDecorator(Object.keys(record)[i], {initialValue: Object.values(record)[i]})
} else {
for (let j = 0; j < Object.values(record)[i].length; j++) {
console.log(Object.values(record)[i][j])
if(j !== 0) {
this.addRow()
}
this.form.getFieldDecorator('key' + j, {initialValue: Object.values(record)[i][j].key})
this.form.getFieldDecorator('type' + j, {initialValue: Object.values(record)[i][j].type})
this.form.getFieldDecorator('name' + j, {initialValue: Object.values(record)[i][j].name})
}
}
}
}
// this.form.setFieldsValue(record)
},
initPagination() {
this.pagination.pageNo = 1
this.pagination.current = 1
......@@ -350,6 +394,10 @@ export default {
this.selectedRowKeys = selectedRowKeys
},
onCreate() {
this.rowLoop = [{
name: '',
key: ''
}]
this.current = 0
this.form.resetFields()
this.isShow = !this.isShow
......@@ -390,23 +438,37 @@ export default {
args: paramsJson
}
if(!!this.editId) {
this.$ajax.put({
url: this.$api.PUT_TRIGGER_RECORD.replace('{id}', this.editId),
params: finalParse
}).then(res => {
if(res.code == '200') {
this.$message.success('修改成功!')
this.cancelModal()
this.form.resetFields()
this.getList()
}
})
} else {
this.$ajax.post({
url: this.$api.POST_ADD_TRIGGER_RECORD,
params: finalParse
}).then(res => {
if(res.code == '200') {
this.$message.success('新增成功!')
this.isShow = !this.isShow
this.cancelModal()
this.form.resetFields()
this.getList()
}
})
}
this.editId = null
} else {
this.$message.info('请填写表单所有项目!')
}
})
console.log(finalParse)
},
addRow() {
this.rowLoop.push({
......
......@@ -24,11 +24,11 @@
{{index+1}}
</span>
</a-table>
<a-modal title="系统注册" v-model="isShow" width='900px' style="padding: 20px">
<a-modal title="系统注册" v-model="isShow" width='900px' style="padding: 20px;" destroyOnClose :centered='true' @cancel='cancelModal'>
<a-steps :current="current" style="margin-bottom: 20px">
<a-step v-for="item in steps" :key="item.title" :title="item.title" />
</a-steps>
<div class="steps-content">
<div class="steps-content" style="height: 300px; overflow-y: scroll">
<!-- {{ steps[current].content }} -->
<a-form :form='form'>
<div v-show="current == 0">
......@@ -63,6 +63,7 @@
</a-form-item>
<a-row>
{{rowLoop}}
<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">
......@@ -79,7 +80,7 @@
</a-col>
<a-col :span='1' :offset='1'>
<a-button icon='minus' @click="deleteRow(index)" />
<a-button icon='minus' v-if="index !== 0" @click="deleteRow(item.randomNum)" />
</a-col>
</a-row>
</a-col>
......@@ -109,7 +110,7 @@
</a-form>
</div>
<template slot="footer">
<a-button key="back" @click="isShow = !isShow">
<a-button key="back" @click="cancelModal()">
取消
</a-button>
<a-button v-if="current >= 1" type="primary" @click="handlePrevStep()">
......@@ -134,7 +135,8 @@ export default {
return {
rowLoop: [{
name: '',
key: ''
key: '',
randomNum: Math.random()
}],
form: this.$form.createForm(this),
current: 0,
......@@ -151,13 +153,7 @@ export default {
],
isShow: false,
selectedRowKeys: [],
list: [
{
xtbm: 'wuyeapp',
xtmc: '物业APP',
xtdz: 'http://www.962121.net'
}
],
list: [],
columns: [
{
title: '#',
......@@ -207,16 +203,49 @@ export default {
},
formStoreList: [],
businessOptionsList: [],
editId: null
}
},
mounted() {
this.getList()
},
methods: {
cancelModal() {
console.log(123)
this.form.resetFields()
this.current = 0
this.isShow = !this.isShow
},
onEdit(id) {
this.rowLoop = [{
name: '',
key: '',
randomNum: Math.random()
}]
this.isShow = !this.isShow
console.log(id)
let record = this.list.find(item => item.id == id)
this.form.setFieldsValue(record)
if(!!record) {
this.editId = id
for (let i = 0; i < Object.keys(record).length; i++) {
if(Object.keys(record)[i] !== 'data') {
this.form.getFieldDecorator(Object.keys(record)[i], {initialValue: Object.values(record)[i]})
} else {
for (let j = 0; j < Object.values(record)[i].length; j++) {
console.log(Object.values(record)[i][j])
if(j !== 0) {
this.addRow()
}
this.form.getFieldDecorator('key' + j, {initialValue: Object.values(record)[i][j].key})
this.form.getFieldDecorator('value' + j, {initialValue: Object.values(record)[i][j].value})
}
}
}
}
// this.form.setFieldsValue(record)
},
initPagination() {
this.pagination.pageNo = 1
......@@ -246,10 +275,15 @@ export default {
addRow() {
this.rowLoop.push({
name: '',
key: ''
key: '',
randomNum: Math.random()
})
},
deleteRow() {},
deleteRow(randomNum) {
// this.rowLoop.splice(index, 1)
this.rowLoop = this.rowLoop.filter(i => i.randomNum !== randomNum)
console.log(this.rowLoop)
},
getList() {
this.$ajax.post({
url: this.$api.GET_BUSINESS_LIST,
......@@ -272,6 +306,10 @@ export default {
this.selectedRowKeys = selectedRowKeys
},
onRegister() {
this.rowLoop = [{
name: '',
key: ''
}]
this.current = 0
this.form.resetFields()
this.isShow = !this.isShow
......@@ -283,8 +321,6 @@ export default {
},
handleNextStep() {
this.current += 1
let record = this.list.find(item => item.id == id)
this.form.setFieldsValue(record)
},
handleRegisterOk() {
this.form.validateFields((err, values) => {
......@@ -315,17 +351,33 @@ export default {
authTokenTimeKey: this.form.getFieldValue('authTokenTimeKey')
}
if(!!this.editId) {
this.$ajax.put({
url: this.$api.PUT_BUSINESS_RECORD.replace('{id}', this.editId),
params: finalParse
}).then(res => {
if(res.code == '200') {
this.$message.success('修改成功!')
this.cancelModal()
this.form.resetFields()
this.getList()
}
})
} else {
this.$ajax.post({
url: this.$api.POST_ADD_BUSINESS_RECORD,
params: finalParse
}).then(res => {
if(res.code == '200') {
this.$message.success('新增成功!')
this.isShow = !this.isShow
this.cancelModal()
this.form.resetFields()
this.getList()
}
})
}
this.editId = null
} else {
this.$message.info('请填写表单所有项目!')
......
......@@ -17,7 +17,7 @@
</div>
<a-table class="elevator-table portalTable" :dataSource="list" :columns="columns" size="small" :pagination="pagination" rowKey="id" :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }">
<span slot="operation" slot-scope="text, record">
<span class="actionBtn" @click="onEdit(record)">编辑</span>
<span class="actionBtn" @click="onEdit(record.id)">编辑</span>
<span class="actionBtn" @click="onDelete(record.id)">删除</span>
</span>
<span slot="no" slot-scope="text, record, index">
......@@ -36,7 +36,7 @@
<a-tag v-for="(item, index) in record.rules" :key="index">{{`{` + record.rules[index].key + `: `+ record.rules[index].value + `}`}}</a-tag>
</span>
</a-table>
<a-modal title="新建规则" v-model="isShow" width='900px' style="padding: 20px">
<a-modal title="新建规则" v-model="isShow" width='900px' style="padding: 20px" centered>
<a-form :form='form'>
<a-form-item label="触发服务" :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }">
<a-select placeholder="请选择触发服务" v-decorator="['trigger', {validateTrigger:'blur', rules: [{required: true, message: '请选择此项!'}]}]">
......@@ -50,7 +50,7 @@
</a-select>
</a-form-item>
<a-form-item label="规则字段定义" :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }">
<a-form-item label="规则字段定义key&value" :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }">
<a-textarea
v-decorator="[
'rules',
......@@ -172,9 +172,37 @@ export default {
this.getActionServiceOption()
},
methods: {
onEdit(id) {
this.isShow = !this.isShow
let record = this.list.find(item => item.id == id)
console.log(record)
if(!!record) {
this.editId = id
for (let i = 0; i < Object.keys(record).length; i++) {
if(Object.keys(record)[i] == 'trigger') {
this.form.getFieldDecorator('trigger', {'initialValue': Object.values(record)[i].id})
}
if(Object.keys(record)[i] == 'action') {
this.form.getFieldDecorator('action', {'initialValue': Object.values(record)[i].id})
}
if(Object.keys(record)[i] == 'rules') {
this.form.getFieldDecorator('rules', {'initialValue': JSON.stringify(Object.values(record)[i]).split('[').split(']')})
}
}
}
},
getTriggerServiceOption() {
this.$ajax.post({
url: this.$api.GET_TRIGGER_LIST,
params: {
'page': 1,
'size': 10000
}
}).then(res => {
if(res.code == '200') {
let result = this.$com.confirm(res, 'data.content', [])
......@@ -187,6 +215,10 @@ export default {
getActionServiceOption() {
this.$ajax.post({
url: this.$api.GET_ACTION_LIST,
params: {
'page': 1,
'size': 10000
}
}).then(res => {
if(res.code == '200') {
let result = this.$com.confirm(res, 'data.content', [])
......@@ -196,6 +228,10 @@ export default {
}
})
},
initPagination() {
this.pagination.pageNo = 1
this.pagination.current = 1
},
confirmJson(rule, value, callback) {
if (!value || value == undefined) {
callback('不能为空!')
......@@ -213,15 +249,27 @@ export default {
}
},
onDelete(id) {
this.$ajax.delete({
url: this.$api.DELETE_RULE_RECORD.replace('{id}', id)
const that = this
this.$modal.confirm({
title: '提示',
content: '确定删除该条记录吗?',
okText: '确认',
okType: 'danger',
cancelText: '取消',
onOk() {
that.$ajax.delete({
url: that.$api.DELETE_RULE_RECORD.replace('{id}', id)
}).then(res => {
if(res.code == '200') {
this.$message.success('删除成功!')
this.getList()
that.$message.success('删除成功!')
that.initPagination()
that.getList()
}
})
},
})
},
addRow() {
this.rowLoop.push({
name: '',
......@@ -231,15 +279,20 @@ export default {
deleteRow() {},
getList() {
this.$ajax.post({
url: this.$api.GET_RULES_LIST
url: this.$api.GET_RULES_LIST,
params: {
page: this.pagination.pageNo,
size: 10
}
}).then(res => {
this.list = this.$com.confirm(res, 'data.content', [])
this.pagination.total = this.$com.confirm(res, 'data.totalElements', 0)
})
},
pageChange(val) {
this.pagination.pageNo = val
this.pagination.current = val
// this.getCompanyList()
this.getList()
},
onSelectChange(selectedRowKeys) {
this.selectedRowKeys = selectedRowKeys
......@@ -261,11 +314,19 @@ export default {
this.form.validateFields((err, values) => {
if (!err) {
let formContent = this.form.getFieldsValue()
const formContent = this.form.getFieldsValue()
const trigger = this.triggerOptions.find(item => item.id == formContent.trigger)
const action = this.actionOptions.find(item => item.id == formContent.action)
this.$ajax.post({
url: this.$api.POST_ADD_RULE_RECORD,
params: formContent
params: {
rules: [JSON.parse(this.form.getFieldValue('rules'))],
trigger,
action
}
}).then(res => {
if(res.code == '200') {
this.$message.success('新增成功!')
......
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