123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581 |
- <template>
- <div class="salesNewEdit-wrap">
- <a-spin :spinning="spinning" tip="Loading...">
- <a-page-header :ghost="false" :backIcon="false" @back="handleBack" >
- <!-- 自定义的二级文字标题 -->
- <template slot="subTitle">
- <a id="salesEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
- <span style="margin: 0 15px;color: #666;font-weight: bold;">单号:{{ detailData&&detailData.salesBillNo }}</span>
- <span v-if="detailData&&detailData.salesBillNoSource">(原:{{ detailData&&detailData.salesBillNoSource || '--' }})</span>
- <span style="margin: 0 10px;color: #666;">客户名称:{{ detailData&&detailData.buyerName }}</span>
- <a-button type="link" size="small" class="button-default" @click="showDetail=!showDetail">
- <a-icon :type="showDetail ? 'eye-invisible' : 'eye'"/> {{ showDetail?'隐藏':'查看' }}信息
- </a-button>
- </template>
- </a-page-header>
- <!-- 单据详情 -->
- <a-card size="small" :bordered="false" class="salesEdit-cont" v-show="showDetail">
- <div style="padding: 10px;">
- <a-descriptions size="small" :column="3">
- <a-descriptions-item label="客户名称">{{ detailData&&detailData.buyerName || '--' }}</a-descriptions-item>
- <a-descriptions-item label="收货地址" :span="2">{{ shippingAddress||'--' }}</a-descriptions-item>
- <a-descriptions-item label="收货人">{{ detailData&&detailData.salesBillExtEntity&&detailData.salesBillExtEntity.consigneeName || '--' }}</a-descriptions-item>
- <a-descriptions-item label="收货电话">{{ detailData&&detailData.salesBillExtEntity&&detailData.salesBillExtEntity.consigneeTel || '--' }}</a-descriptions-item>
- <a-descriptions-item label="收款方式">{{ detailData&&detailData.settleStyleSnDictValue || '--' }}</a-descriptions-item>
- <a-descriptions-item label="审核时间">{{ detailData&&detailData.auditDate || '--' }}</a-descriptions-item>
- <a-descriptions-item label="业务状态">{{ detailData&&detailData.billStatusDictValue || '--' }}</a-descriptions-item>
- <a-descriptions-item label="财务状态">{{ detailData&&detailData.financialStatusDictValue || '--' }}</a-descriptions-item>
- <a-descriptions-item label="改单时间" v-if="detailData&&detailData.salesBillSource=='PURCHASE'&&detailData.submitDate">{{ detailData.submitDate }}</a-descriptions-item>
- <a-descriptions-item label="最新提交时间" v-if="detailData&&detailData.salesBillSource=='SALES'&&detailData.submitDate">{{ detailData.submitDate }}</a-descriptions-item>
- <a-descriptions-item label="备注" :span="3">{{ detailData&&detailData.remarks || '--' }}</a-descriptions-item>
- </a-descriptions>
- </div>
- </a-card>
- <!-- 正常产品 -->
- <a-card size="small" :bordered="false" class="salesEdit-cont" v-if="salesBillSn">
- <div style="padding: 10px;">
- <productNormalList
- ref="productNormalList"
- @refash="refashTableData"
- @spinning="e=>spinning=e"
- @openCpModal="openProductModal"
- @allThreeStock="searchAllThreeStock"
- @addActive="addActive"
- :showTotal="showTotal"
- :hasActive="activeList.length>0"
- :detailData="detailData"
- :warehouseSn="warehouseSn"
- :salesBillSn="salesBillSn"></productNormalList>
- </div>
- </a-card>
- <!-- 活动统计列表 -->
- <a-card
- size="small"
- :bordered="false"
- title="活动产品"
- class="salesEdit-cont"
- v-if="activeList.length"
- >
- <activeStatisticsList
- ref="activeTjList"
- @openCpModal="openProductModal"
- @refash="refashTableData"
- @selected="getActiveProduct"
- :activeList="activeList"
- :warehouseSn="warehouseSn"
- :salesBillSn="salesBillSn"
- ></activeStatisticsList>
- <div style="padding:0 10px 10px;">
- <productList
- ref="productActiveList"
- :activeList="activeList"
- :detailData="detailData"
- :salesBillSn="salesBillSn"
- :salesPromoSnSet="salesPromoSnSet"
- @showRuleDetail="showRuleDetail"
- @refash="refashTableData"
- @upActive="upActive">
- </productList>
- </div>
- </a-card>
- </a-spin>
- <!-- 底部栏 -->
- <div class="affix-cont">
- <div class="footer-price">
- <div></div>
- <div v-if="detailData">
- <div class="totalPrice">总售价:¥<span>{{ toThousands(detailData.totalAmount) }}</span></div>
- <div>
- 产品总款数:<strong style="margin-right: 10px;"> {{ detailData.totalCategory }} </strong>
- 总数量:<strong style="margin-right: 10px;"> {{ detailData.totalQty }} </strong>
- <!-- 总售价:¥<strong> {{ toThousands(detailData.totalOrigAmount) }}</strong> -->
- <span style="margin:0 10px;" v-if="detailData.totalDiscountAmount">优惠金额:¥-<strong>{{ Number(detailData.totalDiscountAmount).toFixed(2) }}</strong></span>
- <a-popover title="优惠明细" @visibleChange="(visible)=>{visible&&getPromYhDetail()}">
- <a-button shape="round" size="small" v-if="detailData.totalDiscountAmount">优惠明细</a-button>
- <div slot="content">
- <div v-if="yhDetail">
- <div
- class="yhdetail"
- style="min-width:300px;margin-bottom: 5px;"
- v-for="(item,index) in yhDetail.promoMapList"
- :key="index">
- <div class="yhdetail-h" style="font-weight: bold;font-size:14px;">{{ item.description }}</div>
- <div
- style="padding-left:10px;"
- v-for="(sitem,sindex) in item.promoRuleMapList"
- :key="sindex"
- v-if="sitem.lossAmount"
- >
- <div style="display: flex;justify-content: space-between;">
- <span>{{ sitem.promotionRuleTypeDictValue }}:</span>
- <strong>¥{{ toThousands(sitem.lossAmount) }}</strong>
- </div>
- <div class="yhdetail-d" style="color:#999;">{{ sitem.description }}</div>
- </div>
- </div>
- <div class="yhdetail" style="display: flex;justify-content: space-between;">
- <span style="font-weight: bold;font-size:14px;">优惠金额:</span>
- <span style="font-weight: bold;font-size:18px;">¥{{ Number(yhDetail.totalLossAmount).toFixed(2) }}</span>
- </div>
- </div>
- <div style="text-align: center;padding: 20px;" v-else>
- 正在加载...
- </div>
- </div>
- </a-popover>
- </div>
- </div>
- </div>
- <div>
- <a-button
- size="large"
- style="padding: 0 40px;"
- :disabled="spinning"
- type="primary"
- class="button-primary"
- @click="submitResult()"
- id="productInfoList-handleSubmit">提交</a-button>
- </div>
- </div>
- <!-- 添加产品 -->
- <chooseProduct
- ref="chooseProduct"
- :openModal="showCpModal"
- @close="closeProductModal"
- @addProduct="insterProduct">
- </chooseProduct>
- <!-- 新活动窗口 -->
- <newPromoModal
- :show="showNewActiveModal"
- :salesBillSn="salesBillSn"
- :newActiveList="newActiveList"
- @ok="showNewActiveOk"
- ></newPromoModal>
- <!-- 特价活动排序 -->
- <discountSortModal :show="showDiscountSortModal" :activeList="discountActiveList" @ok="showDiscountSortOk"></discountSortModal>
- <!-- 提交时校验销售价低于成本价提示 -->
- <vaildPriceModal
- ref="vaildPriceModal"
- modalType="1"
- :openModal="openVaildPriceModal"
- :dataObj="tempData"
- @close="openVaildPriceModal=false"
- @ok="vaildPriceOk"></vaildPriceModal>
- </div>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import productList from './comps/productList.vue'
- import productNormalList from './comps/productNormalList.vue'
- import activeStatisticsList from './comps/activeStatisticsList.vue'
- import chooseProduct from './comps/chooseProduct.vue'
- import newPromoModal from './newPromoModal.vue'
- import discountSortModal from './discountSortModal.vue'
- import vaildPriceModal from './vaildPriceModal.vue'
- import { salesChangePromo } from '@/api/salesDetailNew'
- import {
- salesDetailBySn,
- salesPromoQueryCount,
- salesWriteSubmit,
- salesPromoQueryStatisticsList,
- salesPromoDiscountSort,
- salesQueryUnPartPromo,
- salesPromoValidaSubmit,
- getThirdStockQty } from '@/api/salesNew'
- export default {
- name: 'SalesNewEdit',
- mixins: [commonMixin],
- components: {
- productList,
- chooseProduct,
- productNormalList,
- newPromoModal,
- activeStatisticsList,
- discountSortModal,
- vaildPriceModal
- },
- data () {
- return {
- spinning: false,
- activeList: [], // 活动列表
- newActiveList: [], // 新活动列表
- salesBillSn: null, // 销售单sn
- detailData: { discountAmount: 0, id: null, salesBillSn: '' }, // 订单基础数据
- warehouseSn: undefined, // 仓库sn
- // 有价格变更前后总金额
- updataData: {
- totalRealAmount: '',
- totalAmount: ''
- },
- showDetail: false, // 显示详细基本信息
- showCpModal: false, // 添加产品弹框
- cpCurRefId: 'productList-active-list', // 活动产品列表ref
- disabledActiveOption: null, // 禁用活动选项
- yhDetail: null, // 优惠明细
- showNewActiveModal: false, // 新活动弹框
- salesPromoSnSet: [], // 当前勾选的活动sn
- showDiscountSortModal: false, // 特价活动排序弹框
- discountActiveList: [], // 可叠加的特价活动列表
- openVaildPriceModal: false, // 销售价低于成本价提示弹窗
- tempData: null// 销售价低于成本价 弹窗列表数据
- }
- },
- computed: {
- // 是否显示统计信息
- showTotal () {
- return this.activeList.length > 0
- },
- // 详细地址
- shippingAddress () {
- const shippingAddrProvinceName = this.detailData && this.detailData.salesBillExtEntity && this.detailData.salesBillExtEntity.shippingAddrProvinceName ? this.detailData.salesBillExtEntity.shippingAddrProvinceName : ''
- const shippingAddrCityName = this.detailData && this.detailData.salesBillExtEntity && this.detailData.salesBillExtEntity.shippingAddrCityName ? this.detailData.salesBillExtEntity.shippingAddrCityName : ''
- const shippingAddrCountyName = this.detailData && this.detailData.salesBillExtEntity && this.detailData.salesBillExtEntity.shippingAddrCountyName ? this.detailData.salesBillExtEntity.shippingAddrCountyName : ''
- const shippingAddr = this.detailData && this.detailData.salesBillExtEntity && this.detailData.salesBillExtEntity.shippingAddr ? this.detailData.salesBillExtEntity.shippingAddr : ''
- if (!shippingAddrProvinceName && !shippingAddrCityName && !shippingAddrCountyName && !shippingAddr) {
- return '--'
- } else {
- return shippingAddrProvinceName + shippingAddrCityName + shippingAddrCountyName + shippingAddr
- }
- }
- },
- methods: {
- // 返回
- handleBack () {
- this.$router.push({ name: 'salesQueryNewList', query: { closeLastOldTab: true } })
- },
- // 销售单详情
- getOrderDetail (flag, callback) {
- this.spinning = true
- salesDetailBySn({ salesBillSn: this.$route.params.sn }).then(res => {
- this.spinning = false
- if (res.status == 200) {
- this.detailData = res.data
- this.detailData.totalDiscountAmount = Number(this.detailData.totalOrigAmount || 0) - Number(this.detailData.totalAmount || 0)
- if (callback) { callback() }
- }
- if (flag) {
- // 获取活动列表
- this.getActiveList()
- }
- })
- },
- // 查看参与规则明细
- showRuleDetail (sn) {
- this.$refs.activeTjList.showDesc({ promoRuleSn: sn })
- },
- // 优惠明细查看
- getPromYhDetail () {
- salesPromoQueryCount({ salesBillSn: this.$route.params.sn }).then(res => {
- if (res.status == 200) {
- this.yhDetail = res.data
- }
- })
- },
- // 刷新所有第三方库存
- searchAllThreeStock () {
- this.spinning = true
- getThirdStockQty({ salesBillSn: this.$route.params.sn }).then(res => {
- if (res.status == 200) {
- // 刷新正常活动产品列表
- this.$refs.productNormalList.searchThreeStockOk()
- // 刷新所有活动产品列表
- this.$refs.productActiveList.searchThreeStockOk()
- }
- this.spinning = false
- })
- },
- // 获取销售单参与的活动列表
- async getActiveList () {
- // 已参与活动列表
- const list = await salesPromoQueryStatisticsList({ salesBillSn: this.$route.params.sn }).then(res => res.data || [])
- this.activeList = list.filter(item => item.promotion && item.promotionRule)
- // 触发活动统计查询变量
- this.$nextTick(() => {
- this.$refs.activeTjList.hasInit = false
- })
- setTimeout(() => {
- // 刷新正常产品列表
- this.$refs.productNormalList.resetSearchForm()
- // 刷新活动产品列表
- this.$refs.productActiveList.resetSearchForm()
- }, 500)
- },
- // 获取是否有新活动,
- async getNewActive () {
- const hasNewActive = await salesQueryUnPartPromo({ salesBillSn: this.$route.params.sn, enabledFlag: '1' }).then(res => res.data)
- if (hasNewActive.length) {
- this.newActiveList = hasNewActive
- // 有则弹出弹框确认
- this.showNewActiveModal = true
- } else {
- // 获取销售单详情
- this.getOrderDetail(true)
- }
- },
- // 新活动弹框确认后
- showNewActiveOk (type) {
- this.showNewActiveModal = false
- // 特价规则排序
- if (type == 1) {
- this.getSalesPromoDiscountSort()
- } else {
- // 取消加入新活动
- this.getOrderDetail(true)
- }
- },
- // 特价规则排序列表
- getSalesPromoDiscountSort () {
- this.spinning = true
- salesPromoDiscountSort({ salesBillSn: this.$route.params.sn }).then(res => {
- if (res.status == 200) {
- this.discountActiveList = res.data
- this.showDiscountSortModal = true
- }
- this.spinning = false
- })
- },
- // 特价规则排序完成或取消排序
- showDiscountSortOk () {
- this.showDiscountSortModal = false
- this.getOrderDetail(true)
- },
- // 打开选择产品弹框
- openProductModal (type, promo) {
- this.$refs.chooseProduct.pageInit(this.detailData, promo, type)
- this.showCpModal = true
- },
- // 添加产品后,关闭弹框
- closeProductModal (type) {
- this.showCpModal = false
- },
- // 获取指定活动的产品列表
- getActiveProduct (active) {
- this.salesPromoSnSet = active
- },
- // 添加活动产品成功的回调,刷新产品列表
- refashTableData (type) {
- console.log(type, 'refashTableData')
- // 如果是活动产品
- if (type == 'promo') {
- // 刷新正常产品列表
- this.$refs.productNormalList.resetSearchForm()
- this.$refs.chooseProduct.onClose()
- } else if (type == 'normal') { // 如果是正常产品
- // 刷新活动产品列表
- this.$refs.productActiveList.resetSearchForm()
- } else {
- // 刷新正常产品列表
- this.$refs.productNormalList.resetSearchForm()
- // 刷新活动产品列表
- this.$refs.productActiveList.resetSearchForm()
- }
- // 重新获取详情信息
- this.getOrderDetail(false)
- },
- // 确定新增产品到列表,
- insterProduct (row, promo, promoProductClz, cptype) {
- // 正常产品
- if (promoProductClz == 0) {
- this.$refs.productNormalList.saveNewProduct(row, promo)
- } else {
- // 活动产品对象
- if (cptype == 1) {
- this.$refs.productActiveList.saveNewProduct(row, promo, promoProductClz)
- }
- if (cptype == 2) {
- this.$refs.productActiveList.accumulateProduct(row, promo, promoProductClz)
- }
- }
- },
- // 正常产品参与活动
- addActive (data, params) {
- const promo = data.split('-')
- const newSn = this.activeList.find(item => item.promoRuleSn == promo[1])
- const newSalesPromoSn = newSn && newSn.salesPromoSn || ''
- salesChangePromo({
- salesPromoSn: newSalesPromoSn,
- promoRuleSn: promo[1],
- ...params
- }).then(res => {
- if (res.status == 200) {
- // 刷新正常活动
- this.$refs.productNormalList.addAcitveSuccess()
- // 刷新活动统计
- this.$refs.activeTjList.refashRow(newSn, 1)
- // 刷新详情统计
- this.refashTableData('normal')
- }
- })
- },
- // 更换活动
- upActive (params) {
- salesChangePromo(params).then(res => {
- if (res.status == 200) {
- // 刷新活动产品
- this.$refs.productActiveList.upAcitveSuccess()
- // 刷新活动统计
- this.$refs.activeTjList.refashRow('', 1)
- // 刷新详情统计
- this.refashTableData('promo')
- }
- })
- },
- // 提交销售单
- async submitResult () {
- const _this = this
- const data = { salesBillSn: _this.salesBillSn }
- // 校验活动规则
- const vaildActive = await salesPromoValidaSubmit({ salesBillSn: this.salesBillSn }).then(res => res.data)
- const a = vaildActive.filter(item => item.type == 1) // 不可提交
- const b = vaildActive.filter(item => item.type == 0) // 可跳过继续提交
- const d = vaildActive.filter(item => item.type == 'audit') // 售价是否低于参考成本价
- // 弹出不符合规则弹框,不可提交
- if (a.length) {
- this.$info({
- title: '提示',
- centered: true,
- class: 'confirm-center',
- okText: '关闭',
- width: 600,
- content: <div style="padding-top:15px;">
- <ol>
- {a.map(item => (
- <li style="padding:3px 0;">{item.message}</li>
- ))}
- </ol>
- <div style="padding:10px 0;text-align:center"><strong>请按照以上提示修改后再提交</strong></div>
- </div>
- })
- this.spinning = false
- } else {
- // 弹出确认提示信息,可跳过继续提交
- if (b.length) {
- this.$confirm({
- title: '提示',
- centered: true,
- class: 'confirm-center',
- okText: '提交',
- width: 600,
- content: <div style="padding-top:15px;">
- <ol>
- {b.map(item => (
- <li style="padding:3px 0;">{item.message}</li>
- ))}
- </ol>
- </div>,
- onOk () {
- _this.submitOrder(data)
- }
- })
- _this.spinning = false
- } else if (d.length) {
- _this.spinning = false
- _this.tempData = d
- _this.openVaildPriceModal = true
- } else {
- _this.submitOrder(data)
- }
- }
- },
- // 校验销售价低于成本价提示成功,关闭弹窗
- vaildPriceOk () {
- this.tempData = null
- this.openVaildPriceModal = false
- },
- // 提交销售单
- async submitOrder (data) {
- this.spinning = true
- const res = await salesWriteSubmit(data)
- if (res.status == 200) {
- this.handleBack()
- this.$message.success(res.message)
- }
- this.spinning = false
- },
- // 页面初始化
- pageInit () {
- this.salesBillSn = this.$route.params.sn
- this.warehouseSn = this.$route.params.sn ? this.$route.params.wSn : ''
- // 是否有新活动
- this.getNewActive()
- }
- },
- mounted () {
- if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
- this.pageInit()
- }
- },
- activated () {
- // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
- if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
- this.pageInit()
- }
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {})
- }
- }
- </script>
- <style lang="less">
- .salesNewEdit-wrap{
- position: relative;
- height: 100%;
- padding-bottom: 65px;
- box-sizing: border-box;
- >.ant-spin-nested-loading{
- overflow-y: auto;
- height: 100%;
- }
- .salesEdit-cont{
- margin: 6px 0;
- }
- .redStyle{
- font-weight: bold;
- color: red;
- }
- .ellipsisCon{
- display: flex;
- justify-content: space-between;
- align-items: center;
- .ellipsisText{
- width: 100%;
- overflow: hidden;
- text-overflow: ellipsis;
- display: box;
- display: -webkit-box;
- -webkit-line-clamp: 1;
- -webkit-box-orient: vertical;
- }
- }
- .ant-card-small > .ant-card-body {
- padding: 0!important;
- }
- .affix-cont{
- padding: 6px 12px;
- text-align: right;
- display: flex;
- justify-content: space-between;
- align-items: center;
- .footer-price{
- flex-grow:1;
- display: flex;
- justify-content: flex-end;
- align-items: center;
- > div{
- padding: 0 15px;
- }
- .totalPrice{
- span{
- font-weight: bold;
- color: red;
- font-size: 20px;
- }
- }
- }
- }
- }
- </style>
|