123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 |
- <template>
- <div class="purchaseOrderDetail-wrap">
- <a-spin :spinning="spinning" tip="Loading...">
- <a-page-header :ghost="false" :backIcon="false" @back="handleBack" class="purchaseOrderDetail-cont" :style="{ padding: !outBizSn ? '16px 24px' : '0px 24px' }">
- <!-- 自定义的二级文字标题 -->
- <template slot="subTitle">
- <a id="purchaseOrderDetail-back-btn" href="javascript:;" @click="handleBack" v-if="!outBizSn"><a-icon type="left" /> 返回列表</a>
- <span class="billno">单号:{{ detail&&detail.purchaseBillNo }}</span>
- <a-tag color="blue" v-if="detail&&detail.billStatusDictValue">{{ detail&&detail.billStatusDictValue }}</a-tag>
- <a-tag color="orange" v-if="detail&&detail.financialStatusDictValue">{{ detail&&detail.financialStatusDictValue }}</a-tag>
- <span class="billno" v-if="detail&&detail.purchaseBillNoSource" style="font-size: 14px;margin: 0;">(原:{{ detail&&detail.purchaseBillNoSource }})</span>
- </template>
- <!-- 操作区,位于 title 行的行尾 -->
- <template slot="extra">
- <Print v-if="$hasPermissions('B_purchasePrint')" :disabled="localDataSource.length==0" @handlePrint="handlePrint"></Print>
- <a-button
- key="1"
- v-if="$hasPermissions('B_purchaseExportProduct') && (detail&&(detail.billStatus=='AUDIT_PASS' || detail.billStatus=='CANCEL' || detail.billStatus=='WAIT_PUT_WAREHOUSE' || detail.billStatus=='WAIT_PUT_WAREHOUSE_AUDIT' || detail.billStatus=='FINISH'))"
- type="primary"
- class="button-info"
- id="purchaseOrderDetail-export-btn"
- :disabled="localDataSource.length==0"
- @click="handleExportProduct()">导出审核订单产品</a-button>
- </template>
- </a-page-header>
- <!-- 基础信息 -->
- <a-card size="small" :bordered="false" class="purchaseOrderDetail-cont">
- <a-collapse :activeKey="['1']">
- <a-collapse-panel key="1" header="基础信息">
- <a-descriptions :column="3">
- <a-descriptions-item label="供应商">{{ (detail&&detail.purchaseTargetName) || '--' }}</a-descriptions-item>
- <a-descriptions-item label="订单类型">{{ detail&&detail.orderTypeDictValue || '--' }}</a-descriptions-item>
- <a-descriptions-item label="支付方式">{{ (detail&&detail.settleStyleSnDictValue) || '--' }}</a-descriptions-item>
- <a-descriptions-item label="采购员工" v-if="detail&&detail.purchaseBillSource=='PURCHASE'">{{ detail&&detail.operatorName || '--' }}</a-descriptions-item>
- <a-descriptions-item label="收货人">{{ detail&&detail.consigneeName || '--' }}<span v-if="detail&&detail.consigneeTel">({{ detail&&detail.consigneeTel }})</span></a-descriptions-item>
- <a-descriptions-item label="收货地址">
- <div v-if="detail&&(detail.shippingAddressProvinceName || detail.shippingAddressCityName || detail.shippingAddressCountyName || detail.shippingAddress)">
- {{ detail&&detail.shippingAddressProvinceName || '' }}
- {{ detail&&detail.shippingAddressCityName || '' }}
- {{ detail&&detail.shippingAddressCountyName || '' }}
- {{ detail&&detail.shippingAddress || '' }}
- </div>
- <span v-else>--</span>
- </a-descriptions-item>
- <a-descriptions-item label="备注">{{ (detail&&detail.remarks) || '--' }}</a-descriptions-item>
- </a-descriptions>
- </a-collapse-panel>
- </a-collapse>
- </a-card>
- <!-- 产品详情 -->
- <a-card size="small" :bordered="false" class="purchaseOrderDetail-cont">
- <a-collapse :activeKey="['1']">
- <a-collapse-panel key="1" header="产品详情">
- <!-- 总计 -->
- <a-alert type="info" style="margin-bottom:10px">
- <div slot="message">
- 产品款数:<strong>{{ detail && (detail.totalCategory || detail.totalCategory==0) ? detail.totalCategory : '--' }}</strong>,
- 采购数量合计:<strong>{{ detail && (detail.totalQty || detail.totalQty==0) ? detail.totalQty : '--' }}</strong>,
- 审核订单数量:<strong>{{ detail && (detail.totalPushedQty || detail.totalPushedQty==0) ? detail.totalPushedQty : '--' }}</strong>,
- 已取消数量:<strong>{{ detail && (detail.totalCancelQty || detail.totalCancelQty==0) ? detail.totalCancelQty : '--' }}</strong>,
- <div style="display: inline-block;" v-if="$hasPermissions('M_ShowAllCost')">
- 采购金额合计:<strong>{{ detail && (detail.discountedAmount || detail.discountedAmount==0) ? toThousands(detail.discountedAmount,2) : '--' }}</strong>,
- 审核订单金额:<strong>{{ detail && (detail.totalPushedAmount || detail.totalPushedAmount==0) ? toThousands(detail.totalPushedAmount,2) : '--' }}</strong>,
- 已取消金额:<strong>{{ detail && (detail.totalCancelAmount || detail.totalCancelAmount==0) ? toThousands(detail.totalCancelAmount,2) : '--' }}</strong>,
- <span v-if="isShowSalesFlag" style="color: #ed1c24;">优惠金额:<strong>{{ detail && (detail.discountAmount || detail.discountAmount==0) ? detail.discountAmount.toFixed(2) : '--' }}</strong></span>
- </div>
- </div>
- </a-alert>
- <!-- 列表 -->
- <s-table
- class="sTable"
- ref="table"
- size="small"
- :rowKey="(record) => record.id"
- :columns="columns"
- :data="loadData"
- :defaultLoadData="false"
- bordered>
- <!-- 产品编码 -->
- <template slot="code" slot-scope="text, record">
- <span>{{ record.dealerProductEntity.code }}</span>
- <a-badge v-if="record.promotionFlag && record.promotionFlag=='GIFT'" count="促" :number-style="{ backgroundColor: '#52c41a', zoom:'80%',marginLeft:'5px' }"></a-badge>
- <a-badge v-if="record.promotionFlag && record.promotionFlag=='DISCOUNT'" count="特" :number-style="{ backgroundColor: '#faad14', zoom:'80%',marginLeft:'5px' }"></a-badge>
- <a-badge v-if="showConvertPromoGIftQty && record.convertPromoGiftsFlag && record.convertPromoGiftsQty>0" count="转" :number-style="{ backgroundColor: '#006eff', zoom:'80%',marginLeft:'5px' }"></a-badge>
- </template>
- <!-- 采购数量 -->
- <template slot="origqty" slot-scope="text, record">
- <div>{{ text }}</div>
- <div v-if="record.origqty">原采购数量:{{ record.origqty }}</div>
- </template>
- <!-- 已取消数量 -->
- <template slot="outOfStockNum" slot-scope="text, record">
- <span>{{ record.outOfStockNum }}</span>
- </template>
- <!-- 采购单价 -->
- <template slot="unitPrice" slot-scope="text, record">
- <span v-if="record.promotionFlag && (record.promotionFlag=='GIFT' || record.promotionFlag=='DISCOUNT')">{{ record.price||record.price==0? toThousands(record.price): '--' }}{{ record.origPrice ? '(' + toThousands(record.origPrice) + ')' : '' }}</span>
- <span v-else>{{ toThousands(record.price) }}</span>
- </template>
- <!-- 采购金额 -->
- <template slot="amount" slot-scope="text, record">
- <span v-if="record.promotionFlag && (record.promotionFlag=='GIFT' || record.promotionFlag=='DISCOUNT')">{{ record.discountedAmount||record.discountedAmount==0?toThousands(record.discountedAmount) : '--' }}{{ record.totalOrigAmount ? '(' + toThousands(record.totalOrigAmount) + ')' : '' }}</span>
- <span v-else>{{ toThousands(record.discountedAmount) }}</span>
- </template>
- <!-- 转采购额数量 -->
- <template slot="customTitle1">
- <a-tooltip>
- <template slot="title">
- 即促销产品转采购额的数量,订单完结后会进行费用报销
- </template>
- 转采购额数量<a-icon type="question-circle" />
- </a-tooltip>
- </template>
- <!-- 转采购额金额 -->
- <template slot="customTitle2">
- <a-tooltip>
- <template slot="title">
- 即促销产品转采购额金额,促销产品转采购额数量*销售价
- </template>
- 转采购额金额<a-icon type="question-circle" />
- </a-tooltip>
- </template>
- </s-table>
- </a-collapse-panel>
- </a-collapse>
- </a-card>
- </a-spin>
- </div>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import { STable, VSelect } from '@/components'
- import { purchaseDetailBySn, purchaseDetailPrint, purchaseDetailExport, purchaseExportDetail } from '@/api/purchase'
- import { purchaseDetailList } from '@/api/purchaseDetail'
- import Print from '@/views/common/print.vue'
- import { hdPrint, downloadExcel } from '@/libs/JGPrint'
- export default {
- name: 'PurchaseDetail',
- components: { STable, VSelect, Print },
- mixins: [commonMixin],
- props: {
- outBizSn: { // 有值则为弹框,无值则为页面
- type: [Number, String],
- default: ''
- }
- },
- data () {
- return {
- spinning: false,
- isShowSalesFlag: false, // 是否显示优惠金额
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.disabled = true
- return purchaseDetailList(Object.assign(parameter, { purchaseBillSn: this.outBizSn || this.$route.params.sn, orderBy: 'product_type.FIRST_CHAR,dealer_product.CODE' })).then(res => {
- let data
- if (res.status == 200) {
- data = res.data
- const no = (data.pageNo - 1) * data.pageSize
- for (var i = 0; i < data.list.length; i++) {
- data.list[i].no = no + i + 1
- }
- this.isShowSalesFlag = data.list.some(con => { return con.promotionFlag != 0 })
- this.localDataSource = data.list
- this.disabled = false
- }
- return data
- })
- },
- detail: null, // 详情数据
- localDataSource: [], // 原始数据
- printerType: 'NEEDLE' // 打印机类型
- }
- },
- computed: {
- // 是否显示转标志
- showConvertPromoGIftQty () {
- const c = this.detail ? this.detail.totalConvertPromoGiftsQty : 0
- const a = this.detail ? (this.detail.totalPutQty + this.detail.totalWaitPutQty + this.detail.totalCancelQty + c) : 0
- const b = this.detail ? this.detail.totalQty : 0
- return this.detail && c > 0 && a == b
- },
- columns () {
- const _this = this
- const arr = [
- { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
- { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: '14%', align: 'center', scopedSlots: { customRender: 'code' } },
- { title: '产品名称', dataIndex: 'dealerProductEntity.name', width: '18%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '原厂编码', dataIndex: 'dealerProductEntity.origCode', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '单位', dataIndex: 'dealerProductEntity.unit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
- // { title: '采购单价', dataIndex: 'discountedPrice', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- // { title: '采购金额', dataIndex: 'discountedAmount', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '采购数量', dataIndex: 'qty', width: '7%', align: 'center', scopedSlots: { customRender: 'origqty' } },
- // { title: '审核订单金额', dataIndex: 'pushedAmount', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '审核订单数量', dataIndex: 'pushedQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '已取消数量', dataIndex: 'cancelQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
- ]
- // 成本权限
- if (this.$hasPermissions('M_ShowAllCost')) {
- arr.splice(5, 0, { title: '采购单价', dataIndex: 'price', width: '7%', align: 'right', scopedSlots: { customRender: 'unitPrice' } })
- arr.splice(6, 0, { title: '采购金额', dataIndex: 'discountedAmount', width: '7%', align: 'right', scopedSlots: { customRender: 'amount' } })
- arr.splice(8, 0, { title: '审核订单金额', dataIndex: 'pushedAmount', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } })
- }
- // 是否转促销品
- if (this.showConvertPromoGIftQty) {
- arr.push({ slots: { title: 'customTitle1' }, dataIndex: 'convertPromoGiftsQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
- arr.push({ slots: { title: 'customTitle2' }, dataIndex: 'convertPromoGiftsAmount', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } })
- }
- return arr
- }
- },
- methods: {
- // 返回列表
- handleBack () {
- if (this.$route.query.pageType) {
- this.$router.push({ name: this.$route.query.pageType })
- } else {
- this.$router.push({ name: 'purchaseOrderList' })
- }
- },
- // 详情
- getDetail () {
- purchaseDetailBySn({ sn: this.outBizSn || this.$route.params.sn }).then(res => {
- if (res.status == 200) {
- const dataInfo = res.data
- if (dataInfo.totalOrigAmount && dataInfo.totalAmount) {
- dataInfo.discountAmount = dataInfo.totalOrigAmount - dataInfo.totalAmount
- } else {
- dataInfo.discountAmount = null
- }
- this.detail = dataInfo
- } else {
- this.detail = null
- }
- })
- },
- // 打印预览/快捷打印
- handlePrint (type, printerType) {
- const _this = this
- _this.spinning = true
- let url = purchaseDetailPrint
- let params = { sn: this.outBizSn || this.$route.params.sn, type: printerType }
- if (type == 'export') { // 导出
- url = purchaseDetailExport
- params = { sn: this.outBizSn || this.$route.params.sn }
- }
- // 打印或导出
- hdPrint(printerType, type, url, params, '采购单', function () {
- _this.spinning = false
- })
- },
- // 导出产品
- handleExportProduct () {
- const _this = this
- _this.spinning = true
- purchaseExportDetail({ sn: this.outBizSn || this.$route.params.sn }).then(res => {
- _this.spinning = false
- if (res.type == 'application/json') {
- var reader = new FileReader()
- reader.addEventListener('loadend', function () {
- const obj = JSON.parse(reader.result)
- _this.$notification.error({
- message: '提示',
- description: obj.message
- })
- })
- reader.readAsText(res)
- } else {
- downloadExcel(res, '采购产品')
- }
- })
- }
- },
- mounted () {
- if (!this.$store.state.app.isNewTab || this.outBizSn) { // 页签刷新时调用
- this.$refs.table.refresh(true)
- this.getDetail()
- }
- },
- activated () {
- // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
- if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
- this.$refs.table.refresh(true)
- this.getDetail()
- }
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {})
- }
- }
- </script>
- <style lang="less">
- .purchaseOrderDetail-cont{
- margin-bottom: 10px;
- .timeline-box{
- margin-top: 30px;
- .auxiliary-txt{
- color: #808695;
- }
- }
- }
- .purchaseOrderDetail-wrap{
- .billno{
- font-size: 16px;
- font-weight: bold;
- margin: 0 15px;
- }
- }
- </style>
|