<template>
|
<filter-dialog ref="table" :show.sync="showDialog" :title="title" :tableData="tableData"
|
:total="total" :form="listQuery" :formLabel="formLabel"
|
@page-info-change="handPageInfoChange" @selected="handSelected"
|
@close="handleDialogClose" :loading="loading" :multipleSelected="multipleSelected"
|
class="form_Sel_style productSelected" dialogWidth="955px">
|
<template slot="condition">
|
<el-col :span="8" :offset="0">
|
<el-form-item style="display: none;">
|
<input type="text">
|
</el-form-item>
|
<el-form-item>
|
<el-button type="primary" size="mini" @click="handleFilter">查询</el-button>
|
</el-form-item>
|
</el-col>
|
</template>
|
<template slot="columns">
|
<el-table-column label="商品名称" prop="spuName" show-overflow-tooltip></el-table-column>
|
<el-table-column label="商品主编码" prop="spuNum"></el-table-column>
|
<el-table-column label="商品规格" prop="brandName">
|
<template slot-scope="scope">
|
<div class="prodSkuInfos" v-for="skuItem in scope.row.skuInfos" :key="skuItem.shopSkuId">
|
<div class="skuinfoText">
|
<el-tooltip class="item" effect="dark"
|
:content="skuItem.skuProps.length ? getProdSpecs(skuItem) : '-'"
|
placement="left-start">
|
<span class="prodSpecs">
|
{{ skuItem.skuProps.length ? getProdSpecs(skuItem) : '-' }}
|
</span>
|
</el-tooltip>
|
<wly-btn v-show="singleShopSkuId" @click="addSingleSkuId(scope.row,skuItem.shopSkuId)"
|
:type="'success'"
|
:disabled="skuItem.shopSkuId === form.shopSkuId && scope.row.spuId === form.spuId">添加
|
</wly-btn>
|
</div>
|
</div>
|
</template>
|
</el-table-column>
|
<slot></slot>
|
</template>
|
</filter-dialog>
|
</template>
|
<script>
|
import filterDialog from '@/components/filterDialog/filterDialog.vue'
|
import productApi from '@/api/product'
|
export default {
|
components: { filterDialog },
|
props: {
|
show: {
|
type: Boolean,
|
default: false
|
},
|
title: {
|
type: String,
|
default: null
|
},
|
multipleSelected: {
|
type: Boolean,
|
default: true
|
},
|
/**
|
* 选择单个规格
|
*/
|
singleShopSkuId: {
|
type: Boolean,
|
default: false
|
},
|
form: {
|
type: Object,
|
default: function() {
|
return {}
|
}
|
}
|
},
|
data() {
|
return {
|
showDialog: false,
|
listQuery: {
|
spuName: null,
|
spuStatus: 1
|
},
|
tableData: [],
|
total: 0,
|
loading: false,
|
formLabel: [
|
{
|
model: 'spuName',
|
label: '商品名称',
|
type: 'input',
|
sm: 8,
|
labelWidth: '90px'
|
}
|
],
|
selectedRows: null
|
}
|
},
|
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: {
|
/**
|
* 获取商品规格
|
*/
|
getProdSpecs(item) {
|
item.prodSpecs = item.skuProps.map(item => item.propValueName).join('/')
|
return item.prodSpecs
|
},
|
/**
|
* 当选择单个skuid时
|
*/
|
addSingleSkuId(row, shopSkuId) {
|
this.selectedRows = row
|
this.selectedRows.shopSkuId = shopSkuId
|
this.handleDialogClose()
|
},
|
/**
|
* '获取选中的数据
|
*/
|
handSelected(rows) {
|
this.selectedRows = rows
|
},
|
/**
|
* 弹出框关闭事件处理
|
*/
|
handleDialogClose() {
|
if (this.selectedRows) {
|
this.$emit('hand-selected-row-data', this.selectedRows)
|
}
|
},
|
/**
|
* 搜索条件变更处理
|
*/
|
handleFilter() {
|
this.$refs.table.changeCondition()
|
},
|
/**
|
* 初始化表单
|
*/
|
initForm() {
|
this.listQuery = {
|
brandName: null,
|
spuStatus: 1
|
}
|
},
|
/**
|
* 分页信息改变时,列表查询
|
*/
|
handPageInfoChange(pageInfo) {
|
this.queryList(pageInfo)
|
},
|
/**
|
* 查询列表
|
*/
|
queryList(pageInfo) {
|
this.loading = true
|
this.listQuery.bizId = 'B02'
|
productApi
|
.getList({ ...this.listQuery, ...pageInfo }, false)
|
.then((res) => {
|
if (res.data) {
|
this.tableData = res.data.list
|
this.total = res.data.total
|
this.loading = false
|
} else {
|
this.loading = false
|
}
|
})
|
.catch(() => {
|
this.loading = false
|
})
|
}
|
}
|
}
|
</script>
|
<style lang="scss">
|
.form_Sel_style {
|
.el-form-item__content {
|
margin-left: 0 !important;
|
}
|
}
|
.productSelected {
|
.prodSkuInfos {
|
margin-bottom: 10px;
|
|
.skuinfoText {
|
.prodSpecs {
|
display: inline-block;
|
max-width: 170px;
|
white-space: nowrap;
|
overflow: hidden;
|
text-overflow: ellipsis;
|
-o-text-overflow: ellipsis;
|
position: relative;
|
top: 8px;
|
}
|
|
.el-button {
|
float: right;
|
}
|
}
|
}
|
}
|
</style>
|