|
@@ -1,28 +1,30 @@
|
|
|
<template>
|
|
|
<!-- 已选配件列表 -->
|
|
|
<a-spin :spinning="spinning" tip="Loading...">
|
|
|
- <ve-table
|
|
|
- border-y
|
|
|
- v-show="!showEmpty"
|
|
|
- :scroll-width="0"
|
|
|
- :max-height="tableHeight"
|
|
|
- :show-header="showTableHead"
|
|
|
- :row-style-option="{clickHighlight: true}"
|
|
|
- :cellSelectionOption="{enable: false}"
|
|
|
- :virtual-scroll-option="{enable: true}"
|
|
|
- :columns="columns"
|
|
|
- :table-data="dataSource"
|
|
|
- row-key-field-name="id"
|
|
|
- :cell-style-option="cellStyleOption"
|
|
|
- :column-width-resize-option="columnWidthResizeOption"
|
|
|
- />
|
|
|
+ <ve-table
|
|
|
+ border-y
|
|
|
+ v-show="!showEmpty"
|
|
|
+ :scroll-width="0"
|
|
|
+ :max-height="tableHeight"
|
|
|
+ :show-header="showTableHead"
|
|
|
+ :row-style-option="{clickHighlight: true}"
|
|
|
+ :cellSelectionOption="{enable: false}"
|
|
|
+ :virtual-scroll-option="{enable: true}"
|
|
|
+ :columns="columns"
|
|
|
+ :table-data="dataSource"
|
|
|
+ row-key-field-name="id"
|
|
|
+ :cell-style-option="cellStyleOption"
|
|
|
+ :cell-span-option="cellSpanOption"
|
|
|
+ :column-width-resize-option="columnWidthResizeOption"
|
|
|
+ />
|
|
|
<div v-show="showEmpty" class="empty-data">暂无数据</div>
|
|
|
</a-spin>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import { commonMixin } from '@/utils/mixin'
|
|
|
- import { salesDetailAllList } from '@/api/salesDetailNew'
|
|
|
+ import { salesPromoQueryList } from '@/api/salesNew'
|
|
|
+ import { salesDetailAllList, salesPromoDetailCount, salesDetaiCount } from '@/api/salesDetailNew'
|
|
|
export default {
|
|
|
name: 'DetailProductList',
|
|
|
mixins: [commonMixin],
|
|
@@ -69,15 +71,25 @@
|
|
|
data () {
|
|
|
return {
|
|
|
spinning: false,
|
|
|
+ activeList: [], // 活动列表
|
|
|
dataSource: [],
|
|
|
tableHeight: this.maxHeight,
|
|
|
- cellStyleOption: {},
|
|
|
+ cellStyleOption: {
|
|
|
+ bodyCellClass: ({ row, column, rowIndex }) => {
|
|
|
+ if (row.id.indexOf('promo-')>=0 && column.field === "no") {
|
|
|
+ return "table-body-cell-no";
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
columnWidthResizeOption: {
|
|
|
// default false
|
|
|
enable: true,
|
|
|
// column resize min width
|
|
|
minWidth: 50
|
|
|
},
|
|
|
+ cellSpanOption: {
|
|
|
+ bodyCellSpan: this.bodyCellSpan,
|
|
|
+ },
|
|
|
isCityPrice: false,
|
|
|
outStockStr: '',
|
|
|
showEmpty: false,
|
|
@@ -100,10 +112,10 @@
|
|
|
ftext = '促'
|
|
|
fcolor = '#52c41a'
|
|
|
}
|
|
|
- if(record.promotionFlag == 'REGULAR'){
|
|
|
- ftext = '正'
|
|
|
- fcolor = '#108ee9'
|
|
|
- }
|
|
|
+ // if(record.promotionFlag == 'REGULAR'){
|
|
|
+ // ftext = '正'
|
|
|
+ // fcolor = '#108ee9'
|
|
|
+ // }
|
|
|
if(record.promotionFlag == 'DISCOUNT'){
|
|
|
ftext = '特'
|
|
|
fcolor = '#faad14'
|
|
@@ -116,9 +128,32 @@
|
|
|
</div>
|
|
|
)
|
|
|
}
|
|
|
-
|
|
|
+ // 编号,并且格式化活动分类行
|
|
|
+ const noFormat = function(record,data,h){
|
|
|
+ return (
|
|
|
+ <div>
|
|
|
+ {record.id.indexOf('promo-')>=0 ? (
|
|
|
+ <div class="active-title">
|
|
|
+ {record.promo?(
|
|
|
+ <div>
|
|
|
+ <strong style="margin-right:10px;font-size:14px;">{record.promo.promotion.title} ({record.promo.promotionRule.description})</strong>
|
|
|
+ <span style="margin-left:10px;color:#00aaff;cursor: pointer;" onClick={()=>_this.showDesc(record)}>
|
|
|
+ <a-icon title="查看活动详情" type="eye"/> 活动详情
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ ):(<div></div>)}
|
|
|
+ <div>
|
|
|
+ {_this.$hasPermissions('B_salesEdit_salesPrice') ? (<span>总售价:<strong>{record.total&&record.total.totalAmount||'--'}</strong>;</span>):('')}
|
|
|
+ 总款数:<strong>{record.total&&record.total.totalCategory||'--'}</strong>;
|
|
|
+ 总数量:<strong>{record.total&&record.total.totalQty||'--'}</strong>;
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ ):(<span>{data}</span>)}
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }
|
|
|
let arr= [
|
|
|
- { title: '序号', field: 'no',key: "a", width: 50, align: 'center', fixed: 'left',operationColumn: false },
|
|
|
+ { title: '序号', field: 'no',key: "a", width: 50, align: 'center', fixed: 'left',operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return noFormat(row,row[column.field],h)} },
|
|
|
{ title: '产品编码', field: 'productCode',key: "b", width: 150, align: 'center',operationColumn: false,renderBodyCell: ({ row, column, rowIndex }, h) => { return codeFormat(row,row[column.field],h)} },
|
|
|
{ title: '产品名称', field: 'productName',key: "c", width: 250, align: 'center',operationColumn: false , ellipsis: { showTitle: true },renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--'}},
|
|
|
{ title: '原厂编码', field: 'productOrigCode',key: "d", width: 150, align: 'center',operationColumn: false,ellipsis: { showTitle: true },renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--'} },
|
|
@@ -165,62 +200,111 @@
|
|
|
watch: {
|
|
|
showCityPrice(newValue, oldValue){
|
|
|
this.isCityPrice = newValue
|
|
|
- },
|
|
|
- salesBillSn(newValue, oldValue){
|
|
|
-
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- // 获取表格数据
|
|
|
- getTableData(){
|
|
|
+ // 合并活动分类单元格
|
|
|
+ bodyCellSpan({ row, column, rowIndex }) {
|
|
|
+ if (row.id.indexOf('promo-')>=0) {
|
|
|
+ if(column.field=='no'){
|
|
|
+ return {
|
|
|
+ rowspan: 1,
|
|
|
+ colspan: 17,
|
|
|
+ };
|
|
|
+ }else{
|
|
|
+ return {
|
|
|
+ rowspan: 0,
|
|
|
+ colspan: 0,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 查看活动详情
|
|
|
+ showDesc(e,item){
|
|
|
+
|
|
|
+ },
|
|
|
+ // 获取销售单参与的活动列表
|
|
|
+ pageInit(){
|
|
|
+ salesPromoQueryList({ salesBillSn: this.salesBillSn }).then(res => {
|
|
|
+ if(res.status == 200){
|
|
|
+ this.activeList = res.data || []
|
|
|
+ }
|
|
|
+ this.$nextTick(()=>{
|
|
|
+ this.searchTable()
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ async searchTable(){
|
|
|
+ this.dataSource = []
|
|
|
+ this.disabled = true
|
|
|
this.spinning = true
|
|
|
+ // 参数
|
|
|
const params = {
|
|
|
salesBillSn: this.salesBillSn,
|
|
|
showStock: this.showStock,
|
|
|
warehouseSn: this.warehouseSn
|
|
|
}
|
|
|
- // 活动列表
|
|
|
- if(this.promo){
|
|
|
- params.promoRuleSn = this.promo.promoRuleSn
|
|
|
- params.promoSn = this.promo.promoSn
|
|
|
- params.salesPromoSn = this.promo.salesPromoSn
|
|
|
+ // 正常产品
|
|
|
+ const proList = await salesDetailAllList(params).then(res => res.data)
|
|
|
+ const norTotal = await salesDetaiCount(params).then(res => res.data)
|
|
|
+ let listData = [{
|
|
|
+ id: 'promo-normal',
|
|
|
+ total: norTotal
|
|
|
+ },...proList]
|
|
|
+
|
|
|
+ // 循环获取活动产品
|
|
|
+ const active = this.activeList
|
|
|
+ for(let i=0;i<active.length;i++){
|
|
|
+ const promo = active[i]
|
|
|
+ const activeParams = {
|
|
|
+ promoRuleSn: promo.promoRuleSn,
|
|
|
+ promoSn: promo.promoSn,
|
|
|
+ salesPromoSn: promo.salesPromoSn,
|
|
|
+ ...params
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取活动产品列表
|
|
|
+ const aclist = await salesDetailAllList(activeParams).then(res => res.data)
|
|
|
+ // 获取活动产品统计
|
|
|
+ const acTotal = await salesPromoDetailCount(activeParams).then(res => res.data)
|
|
|
+ const retList = [{
|
|
|
+ id: 'promo-'+i,
|
|
|
+ promo: promo,
|
|
|
+ total: acTotal
|
|
|
+ },...aclist]
|
|
|
+ listData = aclist&&aclist.length ? listData.concat(retList) : listData
|
|
|
}
|
|
|
- salesDetailAllList(params).then(res => {
|
|
|
- let data
|
|
|
- if (res.status == 200) {
|
|
|
- data = res.data
|
|
|
- const no = 0
|
|
|
- this.outStockStr = ''
|
|
|
- let str = ''
|
|
|
- for (var i = 0; i < data.length; i++) {
|
|
|
- data[i].no = no + i + 1
|
|
|
- const productCode = (data[i].productEntity && data[i].productEntity.code) || (data[i].dealerProductEntity && data[i].dealerProductEntity.code)
|
|
|
- const productName = (data[i].productEntity && data[i].productEntity.name) || (data[i].dealerProductEntity && data[i].dealerProductEntity.name)
|
|
|
- const productOrigCode = (data[i].productEntity && data[i].productEntity.origCode) || (data[i].dealerProductEntity && data[i].dealerProductEntity.origCode)
|
|
|
- const productOrigUnit = (data[i].productEntity && data[i].productEntity.unit) || (data[i].dealerProductEntity && data[i].dealerProductEntity.unit)
|
|
|
- data[i].productCode = productCode || '--'
|
|
|
- data[i].productName = productName || '--'
|
|
|
- data[i].productOrigCode = productOrigCode == ' ' ? '--' : productOrigCode
|
|
|
- data[i].productOrigUnit = productOrigUnit || '--'
|
|
|
- if (data[i].unpushedQty && (Number(data[i].stockQty) < Number(data[i].unpushedQty))) {
|
|
|
- str += data[i].productCode + '、'
|
|
|
- }
|
|
|
- }
|
|
|
- if (str.length > 0) {
|
|
|
- str = str.substr(0, str.length - 1)
|
|
|
- this.outStockStr = '产品编号为:' + str + '的产品库存不足;'
|
|
|
- }
|
|
|
- this.showEmpty = data.length <= 0
|
|
|
- this.tableHeight = (this.showEmpty ? 30 : this.maxHeight) + 'px'
|
|
|
- if(!this.showEmpty && data.length < 10){
|
|
|
- this.tableHeight = 'auto'
|
|
|
- }
|
|
|
- this.spinning = false
|
|
|
- this.dataSource = data
|
|
|
- this.showTableHead = this.showHeader
|
|
|
+
|
|
|
+ console.log(listData)
|
|
|
+ this.dataSource = listData
|
|
|
+
|
|
|
+ // 格式化数据
|
|
|
+ let f = 0
|
|
|
+ this.outStockStr = ''
|
|
|
+ let str = ''
|
|
|
+ this.dataSource.map((item,i) => {
|
|
|
+ if(item.id.indexOf('promo-')>=0){f = f - 1}
|
|
|
+ item.no = i + 1 + f
|
|
|
+ const productCode = (item.productEntity && item.productEntity.code) || (item.dealerProductEntity && item.dealerProductEntity.code)
|
|
|
+ const productName = (item.productEntity && item.productEntity.name) || (item.dealerProductEntity && item.dealerProductEntity.name)
|
|
|
+ const productOrigCode = (item.productEntity && item.productEntity.origCode) || (item.dealerProductEntity && item.dealerProductEntity.origCode)
|
|
|
+ const productOrigUnit = (item.productEntity && item.productEntity.unit) || (item.dealerProductEntity && item.dealerProductEntity.unit)
|
|
|
+ item.productCode = productCode || '--'
|
|
|
+ item.productName = productName || '--'
|
|
|
+ item.productOrigCode = productOrigCode == ' ' ? '--' : productOrigCode
|
|
|
+ item.productOrigUnit = productOrigUnit || '--'
|
|
|
+ if (item.unpushedQty && (Number(item.stockQty) < Number(item.unpushedQty))) {
|
|
|
+ str += item.productCode + '、'
|
|
|
}
|
|
|
})
|
|
|
- }
|
|
|
+ if (str.length > 0) {
|
|
|
+ str = str.substr(0, str.length - 1)
|
|
|
+ this.outStockStr = '产品编号为:' + str + '的产品库存不足;'
|
|
|
+ }
|
|
|
+ this.tableHeight = (this.showEmpty ? 200 : this.maxHeight) + 'px'
|
|
|
+ this.spinning = false
|
|
|
+ this.disabled = false
|
|
|
+ },
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
@@ -231,4 +315,17 @@
|
|
|
text-align: center;
|
|
|
padding: 20px;
|
|
|
}
|
|
|
+ .ve-table-body-td{
|
|
|
+ .active-title{
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ padding: 10px;
|
|
|
+ background: #f3f8fa;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .ve-table .ve-table-container .ve-table-content-wrapper table.ve-table-content tbody.ve-table-body tr.ve-table-body-tr td.table-body-cell-no,
|
|
|
+ .ve-table .ve-table-container .ve-table-content-wrapper table.ve-table-content tbody.ve-table-body tr.ve-table-expand-tr td.table-body-cell-no{
|
|
|
+ padding: 0;
|
|
|
+ }
|
|
|
</style>
|