detail.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <template>
  2. <div v-if="showPage" class="salesDetail-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="salesDetail-cont" :style="{ padding: !outBizSn ? '16px 24px' : '0px 24px' }">
  5. <template slot="subTitle" v-if="!outBizSn">
  6. <a href="javascript:;" @click="handleBack"><a-icon type="left"></a-icon> 返回列表</a>
  7. <a style="margin: 0 10px 0 20px;color: #666;font-size: 14px;font-weight: 600;">单号:{{ detailData&&detailData.salesBillNo || '--' }}</a>
  8. <a-button
  9. v-if="(detailData&&detailData.sourceType!='CHILD_PURCHASE'&&detailData.billStatus!='AUDIT_REJECT'&&detailData.billStatus !== 'CANCEL' && detailData.billStatus !== 'FINISH' && detailData.billStatus != 'WAIT_OUT_WAREHOUSE')&&$hasPermissions('B_salesEdit')"
  10. type="primary"
  11. size="small"
  12. style="background-color: #1890ff;margin-left: 20px;border: #1890ff;"
  13. id="salesDetail-edit-btn"
  14. @click.stop="handleEdit">编辑</a-button>
  15. </template>
  16. <template slot="extra" v-if="outBizSn ? $hasPermissions('B_outboundOrderDetail') : $hasPermissions('B_salesPrint')">
  17. <a-checkbox v-model="printAllName" :checked="printAllName" id="salesQuery-printAllName">打印完整产品名称</a-checkbox>
  18. <a-checkbox v-model="printOrgCode" :checked="printOrgCode" id="salesQuery-printOrgCode">打印原厂编码</a-checkbox>
  19. <Print :disabled="localDataSource.length==0" @handlePrint="handlePrint"></Print>
  20. </template>
  21. </a-page-header>
  22. <!-- 基础信息 -->
  23. <a-card size="small" :bordered="false" class="salesDetail-cont">
  24. <a-collapse :activeKey="['1']">
  25. <a-collapse-panel key="1" header="基础信息">
  26. <a-descriptions size="small" :column="3">
  27. <a-descriptions-item label="客户名称">{{ detailData&&detailData.buyerNameCurrent?detailData.buyerName?detailData.buyerName==detailData.buyerNameCurrent?detailData.buyerNameCurrent:detailData.buyerNameCurrent+'('+detailData.buyerName+')':detailData.buyerNameCurrent:'--' }}</a-descriptions-item>
  28. <a-descriptions-item label="客户地址" :span="2">
  29. <div v-if="detailData&&(detailData.shippingAddressProvinceName || detailData.shippingAddressCityName || detailData.shippingAddressCountyName || detailData.shippingAddress)">
  30. {{ detailData&&detailData.shippingAddressProvinceName || '' }}
  31. {{ detailData&&detailData.shippingAddressCityName || '' }}
  32. {{ detailData&&detailData.shippingAddressCountyName || '' }}
  33. {{ detailData&&detailData.shippingAddress || '' }}
  34. </div>
  35. <span v-else>--</span>
  36. </a-descriptions-item>
  37. <a-descriptions-item label="收款方式">{{ detailData&&detailData.settleStyleSnDictValue || '--' }}</a-descriptions-item>
  38. <a-descriptions-item label="联系电话">{{ detailData&&detailData.consigneeTel || '--' }}</a-descriptions-item>
  39. <a-descriptions-item label="备注">{{ detailData&&detailData.remarks || '--' }}</a-descriptions-item>
  40. <a-descriptions-item label="销售单号">{{ detailData&&detailData.salesBillNo || '--' }}</a-descriptions-item>
  41. <a-descriptions-item label="制单人">{{ detailData&&detailData.operatorName || '--' }}</a-descriptions-item>
  42. <a-descriptions-item label="业务员">{{ detailData&&detailData.salesManName || '--' }}</a-descriptions-item>
  43. <a-descriptions-item label="来源">{{ detailData&&detailData.sourceTypeDictValue || '--' }}</a-descriptions-item>
  44. <a-descriptions-item label="下级采购单号" v-if="detailData&&detailData.sourceType=='PURCHASE'">{{ detailData&&detailData.purchaseBillNo || '--' }}</a-descriptions-item>
  45. <a-descriptions-item label="业务状态">{{ detailData&&detailData.billStatusDictValue || '--' }}</a-descriptions-item>
  46. <a-descriptions-item label="财务状态">{{ detailData&&detailData.financialStatusDictValue || '--' }}</a-descriptions-item>
  47. <a-descriptions-item label="采购单号" v-if="detailData&&detailData.sourceType!='SALES'">{{ detailData.purchaseBillNo || '--' }}</a-descriptions-item>
  48. <a-descriptions-item label="收货状态" v-if="detailData&&detailData.sourceType!='TEMPORARY_DISPATCHING'&&detailData.sourceType!='SALES'&&detailData.billStatus=='FINISH'">{{ detailData.receiptStatusDictValue || '--' }}</a-descriptions-item>
  49. </a-descriptions>
  50. </a-collapse-panel>
  51. </a-collapse>
  52. </a-card>
  53. <a-card size="small" :bordered="false" class="pages-wrap">
  54. <!-- alert -->
  55. <a-alert type="info" style="margin-bottom: 10px;">
  56. <div style="display: flex;align-items: center;justify-content: space-between;" slot="message">
  57. <div>
  58. 总款数:<strong>{{ detailData&&(detailData.totalCategory || detailData.totalCategory==0) ? detailData.totalCategory : '--' }}</strong>;
  59. 总数量:<strong>{{ detailData&&(detailData.totalQty || detailData.totalQty==0) ? detailData.totalQty : '--' }}</strong>;
  60. 总赠品数量:<strong>{{ detailData&&(detailData.giftQty || detailData.giftQty==0) ? detailData.giftQty : '--' }}</strong>;
  61. 急件总款数:<strong>{{ detailData&&(detailData.oosCategory || detailData.oosCategory==0) ? detailData.oosCategory : '--' }}</strong>;
  62. 急件总数量:<strong>{{ detailData&&(detailData.oosQty || detailData.oosQty==0) ? detailData.oosQty : '--' }}</strong>;<br/>
  63. 总售价:<strong>{{ detailData&&(detailData.totalAmount || detailData.totalAmount==0) ? toThousands(detailData.totalAmount) : '--' }}</strong>;
  64. <template v-if="showCost">
  65. 总成本:<strong>{{ detailData&&(detailData.totalCost || detailData.totalCost==0) ? toThousands(detailData.totalCost) : '--' }}</strong>;
  66. 总毛利:<strong>{{ detailData&&(detailData.grossProfit || detailData.grossProfit==0) ? toThousands(detailData.grossProfit) : '--' }}</strong>;
  67. </template>
  68. 折后总售价:<strong>{{ detailData&&(detailData.discountedAmount || detailData.discountedAmount==0) ? toThousands(detailData.discountedAmount) : '--' }}</strong>;
  69. 折扣:<strong>{{ detailData&&(detailData.discountRate || detailData.discountRate==0) ? detailData.discountRate+'%' : '--' }}</strong>;
  70. 折扣金额:<strong>{{ detailData&&(detailData.discountAmount || detailData.discountAmount==0) ? toThousands(detailData.discountAmount) : '--' }}</strong>;
  71. <span v-if="detailData&&detailData.sourceType&&detailData.sourceType==='XPRH_PURCHASE'"> 返券金额:<strong>{{ detailData&&(detailData.totalGiveAmount || detailData.totalGiveAmount==0) ? toThousands(detailData.totalGiveAmount) : '--' }}</strong>;</span>
  72. </div>
  73. <div>
  74. <hideCellMenus placeholder="显示" :defHiddenKes="colsArr" v-model="showCell"></hideCellMenus>
  75. </div>
  76. </div>
  77. </a-alert>
  78. <!-- 列表 -->
  79. <s-table
  80. class="sTable"
  81. ref="table"
  82. size="small"
  83. :rowKey="(record) => record.id"
  84. :columns="columns"
  85. :data="loadData"
  86. :defaultLoadData="false"
  87. bordered>
  88. <div slot="costTitle">
  89. <a-tooltip placement="top">
  90. <template slot="title">
  91. 系统中不同批次的产品,成本价可能不同,此值是按照实际出库批次的成本计算得到。
  92. </template>
  93. <span style="margin-right: 5px;">实际总成本</span> <a-icon type="question-circle" />
  94. </a-tooltip>
  95. </div>
  96. <!-- 产品编码 -->
  97. <template slot="productCode" slot-scope="text, record">
  98. <div v-if="detailData">
  99. <span>{{ text }}</span>
  100. <a-badge count="急" v-if="(isOwerEdit&&record.oosFlag == 1) || (!isOwerEdit&&isAudit&&record.oosFlag == 1)" :number-style="{ zoom:'80%',marginLeft:'5px' }"></a-badge>
  101. <a-badge count="缺" v-if="!isOwerEdit&&!isAudit&&(!record.currentStockQty || record.currentStockQty < record.qty)" :number-style="{ zoom:'80%',marginLeft:'5px' }"></a-badge>
  102. <a-badge count="赠" v-if="record.promoProductType=='GIFT_PRODUCT'" :number-style="{ backgroundColor: '#52c41a', zoom:'80%',marginLeft:'5px' }"></a-badge>
  103. <a-badge count="券" v-if="record.promoProductType=='TICKET_PRODUCT'" :number-style="{ backgroundColor: '#FF5500', zoom:'80%',marginLeft:'5px' }"></a-badge>
  104. <a-badge count="特" v-if="record.promoProductType=='SPECIAL_PRODUCT'" :number-style="{ backgroundColor: '#FED714',zoom:'80%',marginLeft:'5px' }"></a-badge>
  105. </div>
  106. </template>
  107. <!-- 操作 -->
  108. <template slot="action" slot-scope="text, record">
  109. <a-button
  110. :id="'salesQuery-cost-'+record.productSn"
  111. size="small"
  112. type="link"
  113. v-if="record.oosFlag == 0 && (isOwerEdit || isAudit)"
  114. class="button-primary"
  115. @click="handleViewDetail(record)">出库明细</a-button>
  116. <span v-else>--</span>
  117. </template>
  118. </s-table>
  119. <!-- 出入库明细 -->
  120. <outInDetialModal ref="outInDetialModal" outBizType="SALES" :openModal="showOutInModal" @close="showOutInModal=false"></outInDetialModal>
  121. </a-card>
  122. </a-spin>
  123. </div>
  124. </template>
  125. <script>
  126. import { commonMixin } from '@/utils/mixin'
  127. import { getOperationalPrecision } from '@/libs/tools.js'
  128. import { hdPrint } from '@/libs/JGPrint'
  129. // 组件
  130. import { STable, VSelect } from '@/components'
  131. import outInDetialModal from '@/views/common/outInDetialModal.vue'
  132. import Print from '@/views/common/print.vue'
  133. import hideCellMenus from '@/views/common/hideCellMenus'
  134. // 接口
  135. import { salesDetailBySn, salesDetailPrint, salesDetailExport } from '@/api/sales'
  136. import { salesDetailList } from '@/api/salesDetail'
  137. export default {
  138. name: 'SalesDetail',
  139. components: { STable, VSelect, Print, outInDetialModal, hideCellMenus },
  140. mixins: [commonMixin],
  141. props: {
  142. outBizSn: { // 有值则为弹框,无值则为页面
  143. type: [Number, String],
  144. default: ''
  145. }
  146. },
  147. data () {
  148. return {
  149. showPage: false, // 是否显示组件
  150. spinning: false, // 加载动画
  151. disabled: false, // 禁用按钮
  152. showCost: false, // 是否显示成本价
  153. printOrgCode: false, // 打印原创编码
  154. printAllName: false, // 打印全部名称
  155. showOutInModal: false, // 出库弹框
  156. // 加载数据方法 必须为 Promise 对象
  157. loadData: parameter => {
  158. this.disabled = true
  159. return salesDetailList(Object.assign(parameter, { salesBillSn: this.outBizSn || this.$route.params.sn, orderBy: 'sales_bill_detail.CREATE_DATE desc' })).then(res => {
  160. let data
  161. if (res.status == 200) {
  162. data = res.data
  163. const no = (data.pageNo - 1) * data.pageSize
  164. for (var i = 0; i < data.list.length; i++) {
  165. data.list[i].no = no + i + 1
  166. const productCode = (data.list[i].productEntity && data.list[i].productEntity.code) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.code)
  167. const productName = (data.list[i].productEntity && data.list[i].productEntity.name) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.name)
  168. const productOrigCode = (data.list[i].productEntity && data.list[i].productEntity.origCode) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.origCode) || '--'
  169. const productOrigUnit = (data.list[i].productEntity && data.list[i].productEntity.unit) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.unit)
  170. data.list[i].productCode = productCode || '--'
  171. data.list[i].productName = productName || '--'
  172. data.list[i].productOrigCode = productOrigCode || '--'
  173. data.list[i].productOrigUnit = productOrigUnit || '--'
  174. data.list[i].warehouseName = data.list[i].warehouseEntity && data.list[i].warehouseEntity.name || '--'
  175. data.list[i].warehouseLocationName = data.list[i].warehouseLocationEntity && data.list[i].warehouseLocationEntity.name || '--'
  176. // 售价小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
  177. data.list[i].salePriceSubtotal = getOperationalPrecision(data.list[i].price, data.list[i].qty)
  178. }
  179. this.localDataSource = data.list
  180. this.disabled = false
  181. }
  182. return data
  183. })
  184. },
  185. localDataSource: [], // 原始列表数据
  186. detailData: null, // 详情数据
  187. colsArr: [
  188. {
  189. title: '成本价',
  190. key: 'totalCost',
  191. disabled: false,
  192. checked: false
  193. },
  194. {
  195. title: '返券金额',
  196. key: 'giveAmount',
  197. disabled: !(this.detailData && this.detailData.sourceType && this.detailData.sourceType === 'XPRH_PURCHASE'),
  198. checked: false
  199. }
  200. ],
  201. showCell: []// 已选要显示的列
  202. }
  203. },
  204. computed: {
  205. // 是否自建单据
  206. isOwerEdit () {
  207. return this.detailData && this.detailData.sourceType == 'SALES'
  208. },
  209. // 是否审核通过
  210. isAudit () {
  211. return this.detailData ? (this.detailData.billStatus == 'WAIT_OUT_WAREHOUSE' || this.detailData.billStatus == 'FINISH') : false
  212. },
  213. // 列字段
  214. columns () {
  215. const _this = this
  216. const arr = [
  217. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  218. { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: '9%', scopedSlots: { customRender: 'productCode' }, align: 'center' },
  219. { title: '产品名称', dataIndex: 'productName', width: '13%', align: 'left', customRender: function (text) { return text || '--' } },
  220. { title: '原厂编码', dataIndex: 'productOrigCode', width: '9%', align: 'center', customRender: function (text) { return text && text != ' ' ? text : '--' } },
  221. { title: '售价', dataIndex: 'price', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  222. { title: '折后售价', dataIndex: 'discountedPrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  223. { title: '销售数量', dataIndex: 'qty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  224. { title: '单位', dataIndex: 'productOrigUnit', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  225. { title: '售价小计', dataIndex: 'totalAmount', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  226. { title: '折后小计', dataIndex: 'discountedAmount', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  227. { title: '折扣金额', dataIndex: 'discountAmount', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  228. { slots: { title: 'costTitle' }, dataIndex: 'totalCost', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  229. { title: <a-tooltip placement="bottom" title='返券金额以销售单完结时的活动规则为准'>返券金额&nbsp;<a-icon type="question-circle" /></a-tooltip>, dataIndex: 'giveAmount', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  230. ]
  231. // 下级创建,不显示仓库仓位
  232. if (!this.isOwerEdit) {
  233. arr.push({ title: '库存数量', dataIndex: 'currentStockQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  234. } else {
  235. arr.push({ title: '仓库', dataIndex: 'warehouseName', width: '7%', align: 'center', customRender: function (text) { return text || '--' } })
  236. arr.push({ title: '仓位', dataIndex: 'warehouseLocationName', width: '7%', align: 'center', customRender: function (text) { return text || '--' } })
  237. }
  238. arr.push({ title: '是否急件', dataIndex: 'oosFlagDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } })
  239. arr.push({ title: '操作', scopedSlots: { customRender: 'action' }, width: '7%', align: 'center' })
  240. return arr.filter(item => !_this.showCell.includes(item.dataIndex))
  241. }
  242. },
  243. methods: {
  244. // 打印预览/快捷打印
  245. handlePrint (type, printerType) {
  246. const _this = this
  247. _this.spinning = true
  248. let url = salesDetailPrint
  249. const params = { sn: this.outBizSn || this.$route.params.sn, printOrgCode: this.printOrgCode ? 1 : 0, printAllName: this.printAllName ? 1 : 0, remarksShowFlag: 0, priceFlag: 1, printNo: 1 }
  250. if (type == 'export') { // 导出
  251. url = salesDetailExport
  252. }
  253. // 打印或导出
  254. hdPrint(printerType, type, url, params, '销售单', function () {
  255. _this.spinning = false
  256. })
  257. },
  258. // 返回
  259. handleBack () {
  260. this.$router.push({ path: '/salesManagement/salesQuery/list' })
  261. },
  262. // 编辑
  263. handleEdit () {
  264. const row = this.detailData
  265. this.$router.push({ name: 'salesEdit', params: { id: row.id, sn: row.salesBillSn, priceType: row.priceType } })
  266. },
  267. // 详情
  268. getDetail () {
  269. salesDetailBySn({ salesBillSn: this.outBizSn || this.$route.params.sn }).then(res => {
  270. if (res.status == 200) {
  271. this.detailData = res.data
  272. } else {
  273. this.detailData = null
  274. }
  275. })
  276. },
  277. // 出入库明细
  278. handleViewDetail (row) {
  279. this.showOutInModal = true
  280. this.$refs.outInDetialModal.getData(row)
  281. },
  282. // 页面初始化
  283. pageInit () {
  284. const vm = this
  285. vm.$nextTick(() => {
  286. vm.spinning = false
  287. vm.disabled = false
  288. // 是否默认打印原厂编码
  289. vm.printOrgCode = localStorage.getItem('printOrgCode-' + this.$store.state.user.info.orgId) == 'true'
  290. vm.printAllName = localStorage.getItem('printAllName-' + this.$store.state.user.info.orgId) == 'true'
  291. // 查询列表
  292. vm.$refs.table.refresh(true)
  293. // 获取单据详情
  294. vm.getDetail()
  295. })
  296. }
  297. },
  298. watch: {
  299. // 是否默认打印原厂编码
  300. printOrgCode (newValue, oldValue) {
  301. localStorage.setItem('printOrgCode-' + this.$store.state.user.info.orgId, newValue)
  302. },
  303. // 是否默认打印所有名称
  304. printAllName (newValue, oldValue) {
  305. localStorage.setItem('printAllName-' + this.$store.state.user.info.orgId, newValue)
  306. }
  307. },
  308. mounted () {
  309. if (!this.$store.state.app.isNewTab || this.outBizSn) { // 页签刷新时调用
  310. this.showPage = true
  311. this.pageInit()
  312. }
  313. },
  314. activated () {
  315. this.showPage = true
  316. this.pageInit()
  317. },
  318. beforeRouteEnter (to, from, next) {
  319. next(vm => {
  320. })
  321. }
  322. }
  323. </script>
  324. <style lang="less">
  325. .salesDetail-wrap{
  326. .salesDetail-cont{
  327. margin-bottom: 6px;
  328. }
  329. }
  330. </style>