修复一些问题

master
toesbieya 6 years ago
parent e18a2c7154
commit 3a29fba599
  1. 1
      vue/src/layout/component/Page/index.vue
  2. 13
      vue/src/mixin/tablePageMixin.js
  3. 23
      vue/src/util/vue.js
  4. 1
      vue/src/view/system/customer/indexPage.vue
  5. 1
      vue/src/view/system/supplier/indexPage.vue

@ -67,6 +67,7 @@ export default {
display: flex;
flex-direction: column;
flex: 1;
position: relative;
overflow: hidden;
background-color: #f0f2f5;

@ -4,6 +4,7 @@
* */
import AbstractPagination from '@/component/abstract/Pagination'
import AbstractTable from '@/component/abstract/Table'
import {findComponentByTag} from "@/util/vue"
const mixin = {
components: {AbstractPagination, AbstractTable},
@ -33,7 +34,7 @@ const mixin = {
watch: {
row(v) {
!v && this.$refs.table && this.$refs.table.setCurrentRow()
!v && this.$_getElTableInstance().setCurrentRow()
},
tablePageNeedSearchMap: {
@ -47,9 +48,17 @@ const mixin = {
},
methods: {
$_getElTableInstance() {
if (!this.$_elTableInstance) {
this.$_elTableInstance = findComponentByTag(this, 'el-table')
}
return this.$_elTableInstance
},
rowClick(row) {
if (this.row === row) {
this.$refs.table.setCurrentRow()
this.$_getElTableInstance().setCurrentRow()
this.row = null
}
else this.row = row

@ -0,0 +1,23 @@
/**
* 根据组件标签名称获取组件实例
* 使用广度优先搜索
*
* @param instance 从哪个组件实例开始查找一般是this
* @param tag 要查找的组件的标签名称
*/
export function findComponentByTag(instance, tag) {
if (!instance || !tag) return
const queue = [instance]
while (queue.length > 0) {
const item = queue.shift()
const {$options, $children} = item
if ($options._componentTag === tag) return item
if (Array.isArray($children)) {
queue.push(...$children)
}
}
}

@ -164,6 +164,7 @@ export default {
},
add() {
this.row = null
this.type = 'add'
this.editDialog = true
},

@ -164,6 +164,7 @@ export default {
},
add() {
this.row = null
this.type = 'add'
this.editDialog = true
},

Loading…
Cancel
Save