123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385 |
- <template>
- <!-- 已选配件列表 -->
- <a-spin :spinning="spinning" tip="Loading...">
- <div :style="{position:'relative'}">
- <!-- 总计 -->
- <div style="padding:5px 0;" v-if="activeList.length && countData">
- 总款数:<strong>{{ countData&&(countData.totalCategory || countData.totalCategory==0) ? countData.totalCategory : 0 }}</strong>;
- 总数量:<strong>{{ countData&&(countData.totalQty || countData.totalQty==0) ? countData.totalQty : 0 }}</strong>;
- <span v-if="$hasPermissions('B_salesDetail_salesPrice')">总金额:<strong>{{ countData&&(countData.totalAmount || countData.totalAmount==0) ? toThousands(countData.totalAmount) : '0.00' }}</strong>;</span>
- </div>
- <div else style="padding:5px 0;"></div>
- <ve-table
- border-y
- :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"
- :column-width-resize-option="columnWidthResizeOption"
- />
- <div v-show="showEmpty" class="empty-data"><a-empty description="暂无产品" :image="simpleImage"/></div>
- </div>
- <!-- 活动规则详情 -->
- <detailModal :openModal="openDetailModal" pageType="salesPage" :itemSn="detailSn" @close="closeDetailModal"></detailModal>
- </a-spin>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import { Empty } from 'ant-design-vue'
- import detailModal from '@/views/promotionRulesManagement/dealerPromotions/detailModal.vue'
- import { salesDetailAllList, salesDetailExtPromoList, salesDetaiCount } from '@/api/salesDetailNew'
- export default {
- name: 'DetailProductList',
- mixins: [commonMixin],
- components: { detailModal },
- props: {
- newLoading: Boolean, // loading
- detailData: { // 详情信息
- type: Object,
- default: function () { return null }
- },
- // 正常 or 活动 产品列表
- type: {
- type: String,
- default: 'normal'
- },
- // 活动规则详情
- promo: {
- type: Object,
- default: function () { return null }
- },
- // 表格id
- id: {
- type: String,
- default: ''
- },
- // 仓库sn
- warehouseSn: {
- type: String,
- default: ''
- },
- // 是否促销产品
- promoFlag: {
- type: String,
- default: ''
- },
- // 销售单sn
- salesBillSn: {
- type: String,
- default: ''
- },
- // 是否显示城市价格
- showCityPrice: {
- type: Boolean,
- default: false
- },
- // 权限码
- authCode: {
- type: String,
- default: ''
- },
- // 最大高度
- maxHeight: {
- type: [String, Number],
- default: '300'
- },
- // 是否显示表格头部
- showHeader: {
- type: Boolean,
- default: true
- },
- activeList: { // 参与的活动列表
- type: Array,
- default: () => []
- }
- },
- data () {
- return {
- spinning: false,
- openDetailModal: false, // 活动规则详情弹框
- detailSn: null, // 活动规则详情sn
- dataSource: [], // 列表原始数据
- tableHeight: this.maxHeight, // 表格高度
- // 表格列可拖曳
- columnWidthResizeOption: {
- // default false
- enable: true,
- // column resize min width
- minWidth: 50
- },
- isCityPrice: false, // 是否显示市级价
- outStockStr: '', // 产品库存不足提示信息
- showEmpty: false, // 是否显示空数据图片
- showTableHead: true, // 是否显示表格头部
- colspanNums: 13, // 单元格合并列数
- hasOutStockOfActive: false, // 产品是否存在缺货
- simpleImage: Empty.PRESENTED_IMAGE_SIMPLE, // 空图片
- showStockCol: false, // 显示第三方库存
- hasJGtire: false, // 是否轮胎产品
- countData: null
- }
- },
- computed: {
- columns () {
- const _this = this
- // 价格单元格
- const priceFormat = function (data) {
- return _this.toThousands(data) || '--'
- }
- // 数字单元格
- const numsFormat = function (data) {
- return data || data == 0 ? data : '--'
- }
- // 编号
- const codeFormat = function (record, data, h) {
- return (
- <div>
- <span style="padding-right: 10px;">{data}</span>
- {record.promotionFlag.indexOf('GIFT') >= 0 ? <a-badge count="促" numberStyle={{ backgroundColor: '#52c41a', zoom: '0.7' }}/> : ''}
- {record.promotionFlag.indexOf('DISCOUNT') >= 0 ? <a-badge count="特" numberStyle={{ backgroundColor: '#faad14', zoom: '0.7' }}/> : ''}
- {record.promotionFlag.indexOf('GATE') >= 0 ? <a-badge count="槛" numberStyle={{ backgroundColor: '#108ee9', zoom: '0.7' }}/> : ''}
- {record.promotionFlag.indexOf('REGULAR') >= 0 ? <a-badge count="正" numberStyle={{ backgroundColor: '#ff5500', zoom: '0.7' }}/> : ''}
- {record.convertPromoGiftsQty ? (<a-badge count="转" numberStyle={{ backgroundColor: '#ffaa00', zoom: '0.7' }}></a-badge>) : ''}
- {(Number(record.stockQty || 0) < Number(record.unpushedQty || 0)) && _this.showStock ? <a-badge count="缺" numberStyle={{ zoom: '0.7' }}/> : ''}
- </div>
- )
- }
- // 显示折扣价
- const discountPriceFormat = function (record, data, h) {
- return (
- <div>
- {_this.toThousands(data)}
- {record.promotionFlag == 'GIFT' || record.promotionFlag == 'DISCOUNT' ? (
- <span title="原价">({ _this.toThousands(record.origPrice)})</span>
- ) : ''}
- </div>
- )
- }
- // 列定义
- let arr = [
- { title: '序号', field: 'no', key: 'a', width: 50, align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } },
- { title: '产品编码', field: 'productCode', key: 'b', width: 150, align: 'left', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return codeFormat(row, row[column.field], h) } },
- { title: '产品名称', field: 'productName', key: 'c', width: 250, align: 'left', operationColumn: false, ellipsis: { showTitle: true }, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } },
- { title: '原厂编码', field: 'productOrigCode', key: 'd', width: 150, align: 'left', operationColumn: false, ellipsis: { showTitle: true }, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } },
- { title: '出库仓库', field: 'warehouseName', key: 'e', width: 100, align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } }
- ]
- // 如果是活动产品列表
- if (this.type == 'active') {
- arr.splice(3, 0, {
- title: '规则数量',
- field: 'rulesNums',
- key: '4',
- width: 60,
- align: 'center',
- operationColumn: false,
- renderBodyCell: ({ row, column, rowIndex }, h) => {
- return (
- row.promoRuleSnList
- ? <a-popover placement="right">
- <template slot="content">
- {row.promoRuleSnList.map(item => {
- return (
- <div
- id={'dispacth-ruleDetail-' + row.productSn}
- title="点击查看详情"
- style="padding:5px 0;cursor: pointer;"
- onClick={() => _this.showRuleDetail(item)}
- >{ _this.activeRuleFilter(item) }</div>
- )
- })}
- </template>
- <a-button type="link" id={'dispacth-ruleSn-' + row.productSn} size="small" class="button-info">{row.promoRuleNum}<span style="zoom:0.6;color: #666;">个∨</span></a-button>
- </a-popover> : '--'
- )
- }
- })
- }
- // 计算可合并单元格数
- if (this.$hasPermissions(this.authCode + '_costPrice')) { // 成本价权限
- arr.push({ title: '成本价', field: 'showCost', width: 80, key: 'f', align: 'right', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return priceFormat(row[column.field]) } })
- }
- arr = arr.concat([
- { title: '单位', field: 'productOrigUnit', key: 'g', width: 80, align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } },
- { title: '销售数量', field: 'qty', width: 80, key: 'h', align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field]) } }
- ])
- if (this.$hasPermissions(this.authCode + '_provincePrice')) {
- arr.push({ title: '省级价', field: 'provincePrice', width: 80, key: 'i', align: 'right', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return priceFormat(row[column.field]) } })
- }
- // 是否勾选市级价格
- if (this.isCityPrice) {
- arr.push({ title: '市级价', field: 'cityPrice', width: 80, key: 'j', align: 'right', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return priceFormat(row[column.field]) } })
- if (this.$hasPermissions(this.authCode + '_salesPrice')) { // 售价权限
- arr.push({ title: '销售价', field: 'price', width: 100, key: 'k', align: 'right', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return discountPriceFormat(row, row[column.field], h) } })
- }
- } else {
- if (this.$hasPermissions(this.authCode + '_salesPrice')) { // 售价权限
- arr.push({ title: '销售价', field: 'price', width: 100, key: 'l', align: 'right', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return discountPriceFormat(row, row[column.field], h) } })
- }
- }
- // 审核,需用到库存
- if (this.showStock) {
- arr.push({ title: '库存', field: 'stockQty', width: 80, key: 'm', align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field]) } })
- if (this.showStockCol) {
- arr.push({ title: '第三方库存', field: 'thirdStockQty', width: 80, key: 'mm', align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field]) } })
- }
- }
- arr = arr.concat([
- { title: '待下推数', field: 'unpushedQty', width: 80, key: 'o', align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field]) } },
- { title: '已下推数', field: 'pushedQty', width: 80, key: 'p', align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field]) } }
- ])
- arr.push({ title: '已取消数', field: 'cancelQty', width: 80, key: 'q', align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return numsFormat(row[column.field]) } })
- return arr
- },
- // 是否有可转采购额
- hasConvertPromoGifts () {
- return this.detailData && this.detailData.totalConvertPromoGiftsQty
- },
- // 是否显示库存列
- showStock () {
- return this.detailData && (this.detailData.billStatus == 'WAIT_AUDIT' || this.detailData.billStatus == 'HQ_CHANGE') && this.$hasPermissions('B_salesAudit')
- }
- },
- watch: {
- // 是否显示城市价格变化时
- showCityPrice (newValue, oldValue) {
- this.isCityPrice = newValue
- }
- },
- methods: {
- // 参与规则名称
- activeRuleFilter (val) {
- const row = this.activeList.length && this.activeList.find(item => item.promoRuleSn == val)
- return row ? row.promotion.description + '-' + row.promotionRule.description : ''
- },
- // 查看参与规则详情
- showRuleDetail (promoRuleSn) {
- this.detailSn = promoRuleSn
- this.openDetailModal = true
- },
- // 关闭详情弹窗
- closeDetailModal () {
- this.detailSn = null
- this.openDetailModal = false
- },
- // 获取销售单参与的活动列表
- pageInit () {
- this.searchTable()
- },
- // 显示第三方库存
- showThreeStock () {
- this.showStockCol = true
- },
- // 查询表格数据
- async searchTable () {
- this.dataSource = []
- this.disabled = true
- this.spinning = true
- // 参数
- const params = {
- salesBillSn: this.salesBillSn,
- showStock: this.showStock,
- warehouseSn: this.warehouseSn,
- promotionFlag: this.promoFlag == '' ? undefined : this.promoFlag
- }
- // 查询正常产品明细列表
- const normalList = this.type == 'normal' ? await salesDetailAllList(params).then(res => res.data) : []
- this.countData = this.type == 'normal' ? await salesDetaiCount(params).then(res => res.data) : null
- // 查询活动产品明细列表
- const activeList = this.type == 'active' ? await salesDetailExtPromoList({ salesPromoSnSet: [], ...params }).then(res => res.data) : []
- // 赋值
- this.dataSource = this.type == 'normal' ? normalList : activeList
- // 没用数据,则不显示当前表格
- if (this.dataSource.length == 0) {
- this.$emit('hideTable', true)
- }
- // 格式化数据
- let f = 0
- let str = ''
- this.outStockStr = ''
- 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)
- const productBrand = (item.productEntity && item.productEntity.productBrandName) || (item.dealerProductEntity && item.dealerProductEntity.productBrandName)
- const productType3 = (item.productEntity && item.productEntity.productTypeName3) || (item.dealerProductEntity && item.dealerProductEntity.productTypeName3)
- item.productCode = productCode || '--'
- item.productName = productName || '--'
- item.productOrigCode = productOrigCode == ' ' ? '--' : productOrigCode
- item.productOrigUnit = productOrigUnit || '--'
- item.epushedQty = Number(item.pushedQty) - Number(item.pushQty)
- // 判断是否缺货
- if (item.unpushedQty && (Number(item.stockQty) < Number(item.unpushedQty))) {
- str += item.productCode + '、'
- // 参与促销活动产品是否缺货
- if (item.promotionFlag != 0) {
- this.hasOutStockOfActive = true
- }
- }
- // 判断是否有箭冠轮胎产品
- if (productBrand && productBrand.indexOf('箭冠') >= 0 && productBrand && productType3.indexOf('轮胎') >= 0) {
- this.hasJGtire = true
- }
- })
- // 是否有缺货明细
- if (str.length > 0) {
- str = str.substr(0, str.length - 1)
- this.outStockStr = '产品编号为:' + str + '的产品库存不足;'
- }
- const listLen = this.dataSource.length
- this.showEmpty = listLen <= 0
- // 高度自适应
- if (this.maxHeight == 'auto') {
- this.tableHeight = (listLen + 1) * 30
- this.tableHeight = this.tableHeight > 300 ? 300 : this.tableHeight
- } else {
- this.tableHeight = this.maxHeight
- }
- this.spinning = false
- this.disabled = false
- }
- }
- }
- </script>
- <style lang="less">
- .empty-data{
- color: #999;
- text-align: center;
- padding: 20px;
- position: absolute;
- bottom: 50px;
- width: 100%;
- }
- .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;
- }
- .ve-table .ve-table-container .ve-table-content-wrapper{
- border-bottom: 1px solid #ddd;
- }
- </style>
|