Commit 27995879 authored by Gakki's avatar Gakki

标签功能完善

parent f279b26b
......@@ -62,8 +62,8 @@ case 'huangpu-prod':
default: // 默认环境下(开发环境)
// BASE_URL = 'http://31.0.161.39/apiv2'
// BASE_URL = 'http://211.136.105.193/apiv2'
BASE_URL = 'http://xuhui.hm.omniview.pro/api/v2'
// BASE_URL = 'http://pudong.hm.omniview.pro/api/v2'
// BASE_URL = 'http://xuhui.hm.omniview.pro/api/v2'
BASE_URL = 'http://pudong.hm.omniview.pro/api/v2'
// BASE_URL = 'http://211.136.105.193/apiv2'
MOCK_URL = 'https://yapi.omniview.pro/mock/283'
break
......@@ -201,7 +201,9 @@ export default {
get_specialInspection: '/service-documents-ddd/statistical/specialInspection', //行业督查数字
get_month_check: 'service-documents-ddd/dashboard/house/month',
GET_LABEL_LIST: MOCK_URL + '/service-customkey-ddd/label/tree', // 获取标签列表
GET_LABEL_DETAIL: MOCK_URL + '/service-customkey-ddd/label/{id}', // 查看标签详情
DELETE_SINGLE_LABEL: MOCK_URL + '/service-customkey-ddd/label/{id}', // 根据id删除某个标签
GET_LABEL_LIST: '/service-customkey-ddd/label/tree', // 获取标签列表
GET_LABEL_DETAIL: '/service-customkey-ddd/label/{id}', // 查看标签详情
DELETE_SINGLE_LABEL: '/service-customkey-ddd/label/{id}', // 根据id删除某个标签
POST_SINGLE_LABEL: '/service-customkey-ddd/label', // 新增标签
PUT_LABEL_INFO: '/service-customkey-ddd/label/{id}', // 修改标签信息
}
......@@ -3,6 +3,7 @@
<div class="routerWapper">
<div class="portalDetailTitle" v-if="$route.name=='lvot'">
<span class="title">标签维护</span>
{{currentState}}
<div class="detailOperations">
<a-button @click="backPage"> 返回 </a-button>
</div>
......@@ -23,7 +24,8 @@
<a-col :span='1'></a-col>
<a-col :span='18' class="layoutMargin layoutPadding">
<RightPanel v-if="currentState == 'create'" :trigger-type='currentState' @finish='getFinishState' />
<RightPanel v-else-if="currentState == 'loadChildLabel'" :trigger-type='currentState' :label-id='labelId' @finish='getFinishState'/>
<RightPanel v-else-if="currentState == 'loadChildLabel'" :trigger-type='currentState' :label-id='labelId' @finish='getFinishState' />
<ParentRightPanel v-else-if="currentState == 'loadParentLabel'" :trigger-type='currentState' :label-id='labelId' @finish='getFinishState' />
<EmptyRightPanel v-else />
</a-col>
</a-row>
......@@ -34,6 +36,7 @@
<script>
import RightPanel from '@/views/label/labelRightSide.vue'
import ParentRightPanel from '@/views/label/parentLabelRightPanel.vue'
import EmptyRightPanel from '@/views/label/labelRightSideEmpty.vue'
const treeData = []
......@@ -42,7 +45,8 @@ export default {
name: 'lvot',
components: {
RightPanel,
EmptyRightPanel
EmptyRightPanel,
ParentRightPanel
},
data() {
return {
......@@ -64,6 +68,7 @@ export default {
getFinishState(state) {
if(state == true) {
this.currentState = null
this.getLabelList()
}
},
getLabelList() {
......@@ -86,7 +91,7 @@ export default {
if (res.code == 200) {
let result = this.$com.confirm(res, 'data.content', [])
this.labelId = selectedKeys[0]
if(!!result.parentId) { // 为二级菜单
if(result.parentId !== '0') { // 为二级菜单
this.currentState = 'loadChildLabel'
} else { // 为一级菜单
this.currentState = 'loadParentLabel'
......
<template>
<div class="routerWapper">
<div>
{{triggerType}} - {{labelId}} - {{finish}}
<!-- {{triggerType}} - {{labelId}} - {{finish}} - {{jsonData}} -->
<a-row>
<a-col :span='1' v-if="triggerType == 'create'">
<a-button type='default' @click="backPage()">返回</a-button>
......@@ -21,13 +21,17 @@
<a-divider type='horizontal' />
<a-form :form='labelForm'>
<a-form-item label='标签名' :label-col="{span:2}" :wrapper-col="{span:14}">
<a-input v-decorator="['labelName',{validateTrigger:'blur',rules: []}]"></a-input>
<a-input v-decorator="['labelName',{validateTrigger:'blur', initialValue: jsonData.labelName?jsonData.labelName: '', rules: [{required: true, message: '请填写标签名!'}]}]"></a-input>
</a-form-item>
<a-form-item label='标签分组' :label-col="{span:2}" :wrapper-col="{span:14}">
<a-select v-decorator="['parentLabel',{validateTrigger:'blur',rules: []}]"></a-select>
<a-select v-decorator="['parentId',{validateTrigger:'blur', initialValue: jsonData.parentId?jsonData.parentId: '', rules: []}]">
<a-select-option v-for="(item, index) in parentLabelList" :key='index' :value='item.id'>
{{item.labelName}}
</a-select-option>
</a-select>
</a-form-item>
<a-form-item label='业务对象' :label-col="{span:2}" :wrapper-col="{span:14}">
<a-select v-decorator="['businessObj',{validateTrigger:'blur',rules: []}]">
<a-select v-decorator="['tableName',{validateTrigger:'blur', initialValue: jsonData.tableName?jsonData.tableName: '', rules: [{required: true, message: '请选择业务对象!'}]}]">
<a-select-option value='xq'>小区</a-select-option>
<a-select-option value='mpz'>门牌幢</a-select-option>
</a-select>
......@@ -65,10 +69,10 @@
</a-form-item>
<a-form-item>
<a-input placeholder='请输入' v-decorator="['inputOne' + index,{initialValue: item.inputOne, validateTrigger:'blur',rules: [],}]"></a-input>
<a-input style="width: 120px" placeholder='请输入' v-decorator="['inputOne' + index,{initialValue: getInitialValueOne(item.val), validateTrigger:'blur',rules: [],}]"></a-input>
</a-form-item>
<a-form-item v-if="infoSettingForm.getFieldValue('codition'+index) == 'btw'">
<a-input placeholder='请输入' v-decorator="['inputTwo' + index,{initialValue: item.inputTwo, validateTrigger:'blur',rules: []}]"></a-input>
<a-input style="width: 120px" placeholder='请输入' v-decorator="['inputTwo' + index,{initialValue: getInitialValueTwo(item.val), validateTrigger:'blur',rules: []}]"></a-input>
</a-form-item>
<a-form-item>
......@@ -104,14 +108,16 @@ export default {
selMet: ''
}]
},
jsonData: [],
jsonData: {},
deleteVisible: false,
finish: false
finish: false,
parentLabelList: []
}
},
mounted() {
console.log('得到的' + this.labelId)
this.getLabelDetail()
this.getParentLabelList()
},
props: [
'triggerType',
......@@ -135,12 +141,16 @@ export default {
},
methods: {
getLabelDetail() {
// console.log('得到的' + this.labelId)
if(!!this.labelId && this.labelId !== 'undefined') {
this.$ajax.get({
url: this.$api.DELETE_SINGLE_LABEL.replace('{id}', this.labelId),
}).then(res => {
if (res.code == 200) {
this.labelForm.setFieldsValue({
labelName: res.data.content.labelName,
parentId: res.data.content.parentId,
tableName: res.data.content.tableName
})
this.loopContent.data = res.data.content.selParams
console.log(res.data.content.selParams)
}
......@@ -149,8 +159,36 @@ export default {
this.resetFormFields()
}
},
getParentLabelList() {
this.$ajax.get({
url: this.$api.GET_LABEL_LIST,
}).then(res => {
let list = this.$com.confirm(res, 'data.content', [])
for(let i = 0; i < list.length; i++) {
this.parentLabelList.push({
'labelName': list[i].labelName,
'id': list[i].id
})
}
})
},
getInitialValueOne(val) {
if(val.indexOf(',') > -1) {
return val.split(',')[0]
} else {
return val
}
},
getInitialValueTwo(val) {
if(val.indexOf(',') > -1) {
return val.split(',')[1]
} else {
return ''
}
},
backPage(){ // 返回按钮
this.$router.back()
this.finish = true
this.$emit('finish', this.finish)
},
addInitRow() {
this.loopContent.data.push({
......@@ -181,45 +219,77 @@ export default {
this.deleteVisible = !this.deleteVisible
},
handleDeleteOk() {
this.$message.success('标签【'+ this.labelId + '】已删除!')
this.$ajax.delete({
url: this.$api.DELETE_SINGLE_LABEL.replace('{id}', this.labelId),
}).then(res => {
if (res.code == 200) {
this.$message.success('删除标签成功!')
this.finish = true
this.$emit('finish', this.finish)
}
})
this.deleteVisible = !this.deleteVisible
},
handleCancelOk() {
this.deleteVisible = !this.deleteVisible
},
resetFormFields() {
// this.loopContent.data = [{
// key: '',
// codition: 'equels',
// val: '',
// selMet: ''
// }]
this.loopContent.data = []
this.labelForm.resetFields()
},
save() {
this.jsonData = []
this.infoSettingForm.validateFields((err, values) => {
this.jsonData = {selParams: []}
this.labelForm.validateFields((err, values) => {
if(!err) {
let loopCounts = this.loopContent.data.length
let formData = this.infoSettingForm.getFieldsValue()
for(let i = 0; i < loopCounts; i++) {
this.jsonData.push({
key: formData['key'+i],
val: !formData['inputTwo' + i] ? formData['inputOne' + i] : formData['inputOne' + i] + ',' + formData['inputTwo' + i],
condition: formData['codition'+i],
relation: formData['relation' + i],
selMet: formData['selMet' + i]
})
}
console.log(JSON.stringify(this.jsonData))
this.$message.success('保存成功!')
const labelFormData = this.labelForm.getFieldsValue()
this.jsonData = Object.assign(this.jsonData, labelFormData)
this.infoSettingForm.validateFields((err1, values) => {
if(!err1) {
let loopCounts = this.loopContent.data.length
let formData = this.infoSettingForm.getFieldsValue()
for(let i = 0; i < loopCounts; i++) {
this.jsonData.selParams.push({
key: formData['key'+i],
val: !formData['inputTwo' + i] ? formData['inputOne' + i] : formData['inputOne' + i] + ',' + formData['inputTwo' + i],
codition: formData['codition'+i],
relation: formData['relation' + i],
selMet: formData['selMet' + i]
})
}
// 提交标签内容, 如果有labelId则调用put接口,反之调用post接口
if(!!this.labelId) {
this.$ajax.put({
url: this.$api.PUT_LABEL_INFO.replace('{id}', this.labelId),
params: Object.assign(this.jsonData, {id: this.labelId})
}).then(res => {
if (res.code == 200) {
this.$message.success('修改成功!')
this.resetFormFields()
this.finish = true
this.$emit('finish', this.finish)
} else {
this.$message.success('修改失败!')
}
})
} else {
this.$ajax.post({
url: this.$api.POST_SINGLE_LABEL,
params: Object.assign(this.jsonData)
}).then(res => {
if (res.code == 200) {
this.$message.success('保存成功!')
this.resetFormFields()
this.finish = true
this.$emit('finish', this.finish)
} else {
this.$message.success('保存失败!')
}
})
}
}
})
}
})
this.resetFormFields()
this.finish = true
this.$emit('finish', this.finish)
},
},
}
......
<template>
<div class="routerWapper">
{{labelId}}
<div>
<a-row>
<a-col :span='1'>
<a-button type='default' @click="backPage()">返回</a-button>
</a-col>
<a-col :span='1' :offset='1'>
<a-button type='primary' @click="save()">保存</a-button>
</a-col>
<a-col :span='19'></a-col>
</a-row>
</div>
<div>
<a-divider type='horizontal' />
<a-form :form='labelForm'>
<a-form-item label='标签名' :label-col="{span:2}" :wrapper-col="{span:14}">
<a-input v-decorator="['labelName',{validateTrigger:'blur', initialValue: '', rules: [{required: true, message: '请填写标签名!'}]}]"></a-input>
</a-form-item>
</a-form>
</div>
</div>
</template>
<script>
export default {
data() {
return {
labelForm: this.$form.createForm(this),
labelList: {},
finish: false,
}
},
props: [
'triggerType',
'labelId'
],
mounted() {
this.getLabelInfo()
},
methods: {
getLabelInfo() {
if(!!this.labelId) {
this.$ajax.get({
url: this.$api.GET_LABEL_DETAIL.replace('{id}', this.labelId),
}).then(res => {
if (res.code == 200) {
this.labelList = res.data.content
this.labelForm.setFieldsValue({
labelName: res.data.content.labelName
})
}
})
}
},
resetFormFields() {
this.labelForm.resetFields()
},
backPage(){ // 返回按钮
this.finish = true
this.$emit('finish', this.finish)
},
save() {
this.labelForm.validateFields((err1, values) => {
if(!err1) {
this.labelList.labelName = this.labelForm.getFieldValue('labelName')
this.$ajax.put({
url: this.$api.PUT_LABEL_INFO.replace('{id}', this.labelId),
params: Object.assign(this.labelList, {id: this.labelId})
}).then(res => {
if (res.code == 200) {
this.$message.success('修改成功!')
this.resetFormFields()
this.finish = true
this.$emit('finish', this.finish)
} else {
this.$message.success('修改失败!')
}
})
}
})
},
},
}
</script>
\ No newline at end of file
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