<template>
|
<filter-dialog
|
ref="table"
|
:show.sync ='showDialog'
|
:dataKey="'propId'"
|
:title="title"
|
:tableData="tableData"
|
:total="total"
|
:form="listQuery"
|
:multipleSelected="true"
|
@close="handleDialogClose"
|
@selected="handSelected"
|
:formLabel="formLabel"
|
@page-info-change="handPageInfoChange"
|
:loading="loading"
|
>
|
<template slot="condition">
|
<el-button type="primary" size="mini" @click="handleFilter">查询</el-button>
|
</template>
|
<template slot="columns">
|
<el-table-column label="属性名称" prop="propName"></el-table-column>
|
<el-table-column label="属性描述" show-overflow-tooltip>
|
<template slot-scope="scope">
|
{{scope.row.propDesc ? scope.row.propDesc : '-' }}
|
</template>
|
</el-table-column>
|
<el-table-column label="操作">
|
<template slot-scope="scope">
|
<wly-btn :type="'success'" @click="addRow(scope.row,scope.$index)">添加</wly-btn>
|
</template>
|
</el-table-column>
|
</template>
|
</filter-dialog>
|
</template>
|
<script>
|
import filterDialog from '@/components/filterDialog/filterDialog.vue'
|
import productPropMetaApi from '@/api/productmanagement/productPropMeta'
|
export default {
|
components: { filterDialog },
|
props: ['show', 'title', 'catId'],
|
data () {
|
return {
|
rows: [],
|
showDialog: false,
|
listQuery: {
|
propName: null
|
},
|
tableData: [],
|
total: 0,
|
loading: false,
|
formLabel: [
|
{
|
model: 'propName',
|
label: '属性名称',
|
type: 'input'
|
}
|
]
|
}
|
},
|
watch: {
|
/**
|
* 监控外部显示变量变化
|
* 传递到dialog组件
|
*/
|
show: function (newShow, oldShow) {
|
this.showDialog = this.show
|
},
|
/**
|
* 监控内部显示属性变化
|
* 传递到外部调用变量
|
*/
|
showDialog: function (newDialogShow, oldDialogShow) {
|
this.$emit('update:show', newDialogShow)
|
if (!newDialogShow) {
|
this.$nextTick(() => {
|
this.initForm() // 初始化表单
|
})
|
}
|
}
|
},
|
methods: {
|
/**
|
* 批量新增
|
*/
|
handleDialogClose () {
|
if (!this.rows.length) {
|
this.$message({
|
message: '请选择需要添加的属性',
|
type: 'info'
|
})
|
return
|
}
|
this.$emit('hand-selected-row-data', this.rows)
|
},
|
/**
|
* 行选中事件处理
|
* @param {*} rows 行数据
|
*/
|
handSelected (rows) {
|
this.rows = rows
|
},
|
/**
|
* 搜索条件变更处理
|
*/
|
handleFilter () {
|
this.$refs.table.changeCondition()
|
},
|
/**
|
* 初始化表单
|
*/
|
initForm () {
|
this.listQuery.propName = null
|
this.rows = []
|
},
|
/**
|
* 分页信息改变时,列表查询
|
*/
|
handPageInfoChange (pageInfo) {
|
this.queryList(pageInfo)
|
},
|
/**
|
* 查询列表
|
*/
|
queryList (pageInfo) {
|
this.loading = true
|
this.listQuery.catId = this.catId
|
productPropMetaApi.getCategoryPropList({ ...this.listQuery, ...pageInfo }, false).then(res => {
|
if (res.data) {
|
this.tableData = res.data.list
|
this.total = res.data.total
|
this.loading = false
|
} else {
|
this.tableData = []
|
this.loading = false
|
}
|
}).catch(() => {
|
this.loading = false
|
})
|
},
|
addRow (row, index) {
|
this.showDialog = false
|
this.$emit('hand-selected-row-data', row)
|
}
|
}
|
}
|
</script>
|