<template>
|
<div>
|
<list-condition-template ref="table" :tableData="tableData" :total="total" @page-info-change="handlePageInfoChange">
|
<template slot="operationSection">
|
<el-button size="mini" type="success" @click="addItem">添加属性</el-button>
|
</template>
|
<template slot="columns">
|
<el-table-column label="属性名称" width="200px" prop="propName" show-overflow-tooltip>
|
</el-table-column>
|
<el-table-column label="属性值单位" width="100px" prop="propUnit" show-overflow-tooltip>
|
<template slot-scope="scope">
|
{{scope.row.propUnit ? scope.row.propUnit: '-' }}
|
</template>
|
</el-table-column>
|
<el-table-column label="属性值" :formatter="getPropValue" show-overflow-tooltip>
|
</el-table-column>
|
<el-table-column label="属性描述" width="300px" prop="propDesc" show-overflow-tooltip>
|
<template slot-scope="scope">
|
{{scope.row.propDesc ? scope.row.propDesc: '-' }}
|
</template>
|
</el-table-column>
|
<el-table-column label="操作" :width="`${(4 * $store.getters.colSize)+15}px`">
|
<template slot-scope="scope">
|
<wly-btn @click="propEdit(scope.row,1)">详情</wly-btn>
|
<wly-btn :type="'primary'" @click="editInfo(scope.row)">编辑</wly-btn>
|
<wly-btn :type="'warning'" @click="propEdit(scope.row,2)" >属性值管理</wly-btn>
|
<wly-btn :type="'danger'" @click="deleteItem(scope.row)" >删除</wly-btn>
|
</template>
|
</el-table-column>
|
</template>
|
</list-condition-template>
|
<product-prop-meta-info :show.sync="show" :row="row" title="编辑属性"></product-prop-meta-info>
|
<el-dialog :visible.sync="propDialogVisible" @close="closeDialog" :title="title" :close-on-click-modal="false" :modal-append-to-body="false" v-if="propDialogVisible">
|
<prop-value-components ref="propForm" :propForm="propForm"></prop-value-components>
|
<div slot="footer" class="dialog-footer">
|
<el-button size="mini" @click="closeDialog">关闭</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
</template>
|
<script>
|
import productPropMetaApi from '@/api/productmanagement/productPropMeta'
|
import productPropMetaInfo from '@/views/productPropMeta/info.vue'
|
import { objectCopy } from '@/utils/objectCopyHelper'
|
import propValueComponents from '@/views/productPropMeta/components/propValueComponents.vue'
|
import productPropMetaValueApi from '@/api/productmanagement/productPropMetaValue'
|
export default {
|
components: { productPropMetaInfo, propValueComponents },
|
data () {
|
return {
|
tableData: [],
|
show: false,
|
title: null,
|
row: {},
|
dialogVisible: false,
|
form: {},
|
propDialogVisible: false,
|
propForm: {},
|
total: 0
|
}
|
},
|
/*
|
* 数据变化后刷新列表
|
*/
|
activated () {
|
this.queryList(this.$refs.table.getPageInfo())
|
},
|
methods: {
|
// 删除
|
deleteItem (row) {
|
this.$confirm('是否删除此属性', '删除', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(async () => {
|
try {
|
const res = await productPropMetaApi.deleteItem({ propId: row.propId })
|
if (res.code === '0') {
|
this.$message({
|
message: '删除成功',
|
type: 'success'
|
})
|
this.$refs.table.changeCondition() // 查询列表
|
}
|
} catch (error) {
|
}
|
})
|
},
|
closeDialog () {
|
this.propDialogVisible = false
|
if (this.$refs.propForm.flag) {
|
this.$refs.table.changeCondition()
|
}
|
},
|
/**
|
* 获取属性值
|
*/
|
getPropValue (row) {
|
let str = null
|
str = row.ecProductPropMetaValueList.map(item => { return item.propValue }).join(',')
|
return str
|
},
|
/**
|
* '分页信息改变时查询列表
|
*/
|
handlePageInfoChange (pageInfo) {
|
this.queryList(pageInfo)
|
},
|
/**
|
* 点击查询按钮
|
*/
|
queryData () {
|
this.$refs.table.changeCondition()
|
},
|
/**
|
* 属性值编辑、详情
|
*/
|
propEdit (row, val) {
|
productPropMetaValueApi.getList({ propId: row.propId, pageSize: 0 }).then(res => {
|
if (val === 1) {
|
this.title = '属性详情'
|
row.tag = 1
|
} else {
|
this.title = '属性值管理'
|
row.tag = 2
|
}
|
this.propDialogVisible = true
|
this.propForm = row
|
this.propForm.list = res.data.list
|
})
|
},
|
/**
|
* 编辑
|
*/
|
editInfo (row) {
|
this.show = true
|
this.row = objectCopy(row)
|
},
|
/**
|
* 查询列表
|
*/
|
queryList (pageInfo = { pageNum: 1, pageSize: 10 }) {
|
productPropMetaApi.getList(pageInfo).then(res => {
|
this.tableData = res.data.list
|
this.total = res.data.total
|
})
|
},
|
/**
|
* 跳转到新增页面
|
*/
|
addItem () {
|
this.show = true
|
this.title = '添加属性'
|
}
|
}
|
}
|
</script>
|