Commit b2ffe876 by cwq0219
2 parents 6c08f039 d6d172f9
<template>
<div class="default businessGD">
<div class="default businessGD" style="overflow-y: auto;" :style="{height: parseInt(this.$client_height() - 14) + 'px'}">
<div class="m-b10">
<gl-button
class="newButton"
......@@ -13,47 +13,56 @@
>添加商户</gl-button>
</div>
<div>
<gl-table
style="width: 808px;display: inline-block;"
class="m-b10"
:table="tableData"
v-loading="tableLoading"
>
<gl-table-column
align="center"
v-for="(i, index) in tableData.column"
:key="index"
:label='i.label'
:prop='i.prop'
:width='i.width'
>
<template slot-scope="scope">
<template v-if='i.prop === "merchantName"'>
<a
@click="merchantDetail(scope.scope.row.merchantId)"
class="el-button el-button--text"
>{{tableData.data[scope.scope.$index][i.prop]}}</a>
<div class="merchantTable">
<gl-table
class="m-b10"
:table="tableData"
v-loading="tableLoading">
<gl-table-column
align="center"
v-for="(i, index) in tableData.column"
:key="index"
:label='i.label'
:prop='i.prop'
:width='i.width'>
<template slot-scope="scope">
<template v-if='i.prop === "merchantName"'>
<a
@click="merchantDetail(scope.scope.row.merchantId)"
class="el-button el-button--text"
>{{tableData.data[scope.scope.$index][i.prop]}}</a>
</template>
<template v-else-if='i.prop === "parentMerchantName"'>
<a
@click="merchantDetail(scope.scope.row.parentMerchantId)"
class="el-button el-button--text"
>{{tableData.data[scope.scope.$index][i.prop]}}</a>
</template>
<template v-else>
{{tableData.data[scope.scope.$index][i.prop]}}
</template>
</template>
<template v-else-if='i.prop === "parentMerchantName"'>
<a
@click="merchantDetail(scope.scope.row.parentMerchantId)"
class="el-button el-button--text"
>{{tableData.data[scope.scope.$index][i.prop]}}</a>
</template>
<template v-else>
{{tableData.data[scope.scope.$index][i.prop]}}
</template>
</template>
</gl-table-column>
</gl-table>
<div style="width: 350px;display: inline-block;height: 500px;overflow-y: auto;">
</gl-table-column>
</gl-table>
<gl-pagination
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="pageNum"
:page-sizes="[10,20,30,40]"
:page-size="pageSize"
layout="total, sizes, ->, prev, pager, next, jumper"
:total="total">
</gl-pagination>
</div>
<div style="width: 350px;display: inline-block;">
<!-- <gl-form-item label="商户:" prop="merchantId"> -->
<gl-input
<!-- <gl-input
v-model="searchResult.merchantName"
placeholder="请输入内容"
></gl-input>
<!-- <gl-select
></gl-input> -->
<gl-select
v-model="searchResult.merchantName"
filterable
remote
......@@ -71,7 +80,7 @@
:label="item.merchantName"
:value="item.merchantId">
</gl-option>
</gl-select> -->
</gl-select>
<gl-button
class="newButton"
type="primary"
......@@ -82,25 +91,15 @@
<!-- <gl-input v-model="searchTree" placeholder="请输入内容"></gl-input> -->
<gl-tree
:style="{height: parseInt(this.$client_height() - 140) + 'px'}"
style="overflow-x: auto"
style="overflow-y: auto;position: relative;"
:data="dataTree"
:props="defaultProps"
:render-content="renderContent"
node-key='merchantId'
ref="tree"
></gl-tree>
</div>
<gl-pagination
style="width: 808px;"
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="pageNum"
:page-sizes="[10,20,30,40]"
:page-size="pageSize"
layout="total, sizes, ->, prev, pager, next, jumper"
:total="total"
>
</gl-pagination>
</div>
<gl-dialog
title="高级搜索"
......@@ -234,10 +233,10 @@
>
</gl-option>
</gl-select>
<span
<!-- <span
v-show="errorBags.has('merchantId')"
class="error"
>{{ errorBags.first('merchantId') }}</span>
>{{ errorBags.first('merchantId') }}</span> -->
</gl-form-item>
</gl-form>
<div
......@@ -395,7 +394,8 @@ export default {
loading: false,
searchResult: {}, // 搜索结果的对象
allTree: [],
target: []
target: [],
lastSearch: ''
}
},
created() {
......@@ -419,6 +419,7 @@ export default {
this.eventBus = this.$root.eventBus
// gettree
const params = {}
// params.groupId = this.groupId
params.method = groupDetailMethods.GetTree
request.req(params).then(res => {
console.log(res)
......@@ -577,58 +578,81 @@ export default {
},
// 查询
searchMerchant() {
this.searchResult.merchantId = 205
// console.log(this.$refs.tree.$children[0])
console.log(this.lastSearch.style ? this.lastSearch.style.backgroundColor : null)
this.lastSearch.style ? this.lastSearch.style.backgroundColor = '#ffffff' : null
console.log(this.lastSearch)
this.searchResult.merchantId = 11221 + Math.round(Math.random() * 100 + 10)
console.log(this.searchResult.merchantId)
console.log(this.$refs.tree.$children[0])
// console.log(this.$refs.tree.$children[0].store._getAllNodes())
// console.log(this.$refs.tree.$children[0].$el.childNodes[0].__vue__.getNodeKey(this.$refs.tree.$children[0].store._getAllNodes()[1]))
this.allTree = this.$refs.tree.$children[0].store._getAllNodes()
let result = ''
console.log(this.allTree)
this.allTree.forEach(element => {
if (element.key === this.searchResult.merchantId) {
// console.log(element)
result = element
}
})
console.log(result.key)
this.searchChildren(this.$refs.tree.$children[0].store._getAllNodes(), result.key)
const rootList = this.$refs.tree.$children[0].$children
// const sencondList = []
console.log(rootList)
console.log(this.target)
rootList.forEach(i => {
if (i.node.key === this.target[0].key) {
console.log(i.$children)
// sencondList = i.$children
i.$children.forEach(j => {
console.log(j)
// if (j.node.key === this.target[1].key) {
// console.log(j)
// }
})
// for (const j in sencondList) {
// }
}
})
// for (const i in rootList) {
// if (rootList[i].node.key === this.target[0].key) {
// console.log(rootList[i])
// const sencondList = rootList[i].$children
// // for (const j in sencondList) {
// // }
// // console.log(typeof (sencondList))
// console.log(rootList)
// console.log(this.target)
this.cycle(rootList, this.target[0])
// rootList.forEach(i => {
// if (i.node.key === this.target[0].key) {
// this.$nextTick(() => {
// i.$children.forEach(j => {
// if (j.node.key === this.target[1].key) {
// j.$children.forEach(n => {
// if (n.node.key === this.target[2].key) {
// this.$nextTick(() => {
// console.log(n, n.$el.offsetTop)
// this.$refs.tree.$el.scrollTop = n.$el.offsetTop - n.$el.offsetHeight
// n.$el.style.background = '#f5f7fa'
// })
// }
// })
// }
// })
// })
// }
// if (rootList[i].children && rootList[i].children[1]) {
// console.log(rootList[i].children[1])
// }
// {if (rootList[i].children && rootList[i].children.length === 2) {
// console.log(rootList[i])
// }}
// }
// })
},
cycle(arr, target) {
this.$nextTick(() => {
arr.forEach(i => {
if (i.node.key === target.key && target.level === this.target.length) {
const top = i.$el.offsetTop
this.$nextTick(() => {
setTimeout(() => {
this.$set(this.$refs.tree.$el, 'scrollTop', top - i.$el.offsetHeight / 2)
// #f5f7fa
i.$el.children[0].style['background-color'] = '#eee'
console.log(i.$el.children[0])
this.lastSearch = i.$el.children[0]
// console.log(i.node)
// this.$refs.tree.$children[0].store.setCurrentNode(i.node)
// console.log(this.$refs.tree.$children[0].store.getCurrentNode())
}, 200)
})
} else if (i.node.key === target.key) {
this.cycle(i.$children, this.target[target.level])
}
})
})
},
searchChildren(data, id) {
data.forEach(el => {
// console.log(el.store.getCurrentNode())
if (el.key === id) {
this.$set(el, 'expanded', true)
this.searchParent(el)
} else {
this.$set(el, 'expanded', false)
}
})
},
......@@ -640,6 +664,14 @@ export default {
} else {
this.target[0] = e
}
},
renderContent(h, { node, data, store }) {
return (
<span class='custom-tree-node'>
<span>{node.label}</span>
<span style='padding: 0 5px;'>-</span>
<span>{node.data.merchantTypeName}</span>
</span>)
}
}
}
......@@ -653,10 +685,19 @@ export default {
}
}
}
.businessGD a {
.businessGD {
a {
/* color: #0000FF; */
text-decoration: underline;
text-decoration: underline;
}
.merchantTable {
width: 800px;
float: left;
margin-right: 20px
}
}
// .tableImg{
// width: 36px;
// height: 36px;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!