detail.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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.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>
  48. </a-collapse-panel>
  49. </a-collapse>
  50. </a-card>
  51. <a-card size="small" :bordered="false" class="pages-wrap">
  52. <!-- alert -->
  53. <a-alert type="info" style="margin-bottom: 10px;">
  54. <div style="display: flex;align-items: center;justify-content: space-between;" slot="message">
  55. <div>
  56. 总款数:<strong>{{ detailData&&(detailData.totalCategory || detailData.totalCategory==0) ? detailData.totalCategory : '--' }}</strong>;
  57. 总数量:<strong>{{ detailData&&(detailData.totalQty || detailData.totalQty==0) ? detailData.totalQty : '--' }}</strong>;
  58. 总赠品数量:<strong>{{ detailData&&(detailData.giftQty || detailData.giftQty==0) ? detailData.giftQty : '--' }}</strong>;
  59. 急件总款数:<strong>{{ detailData&&(detailData.oosCategory || detailData.oosCategory==0) ? detailData.oosCategory : '--' }}</strong>;
  60. 急件总数量:<strong>{{ detailData&&(detailData.oosQty || detailData.oosQty==0) ? detailData.oosQty : '--' }}</strong>;<br/>
  61. 总售价:<strong>{{ detailData&&(detailData.totalAmount || detailData.totalAmount==0) ? toThousands(detailData.totalAmount) : '--' }}</strong>;
  62. <template v-if="showCost">
  63. 总成本:<strong>{{ detailData&&(detailData.totalCost || detailData.totalCost==0) ? toThousands(detailData.totalCost) : '--' }}</strong>;
  64. 总毛利:<strong>{{ detailData&&(detailData.grossProfit || detailData.grossProfit==0) ? toThousands(detailData.grossProfit) : '--' }}</strong>;
  65. </template>
  66. 折后总售价:<strong>{{ detailData&&(detailData.discountedAmount || detailData.discountedAmount==0) ? toThousands(detailData.discountedAmount) : '--' }}</strong>;
  67. 折扣:<strong>{{ detailData&&(detailData.discountRate || detailData.discountRate==0) ? detailData.discountRate+'%' : '--' }}</strong>;
  68. 折扣金额:<strong>{{ detailData&&(detailData.discountAmount || detailData.discountAmount==0) ? toThousands(detailData.discountAmount) : '--' }}</strong>;
  69. </div>
  70. <div>
  71. <a-checkbox v-model="showCost" v-if="$hasPermissions('M_ShowAllCost')" id="salesQuery-cost">成本价</a-checkbox>
  72. </div>
  73. </div>
  74. </a-alert>
  75. <!-- 列表 -->
  76. <s-table
  77. class="sTable"
  78. ref="table"
  79. size="small"
  80. :rowKey="(record) => record.id"
  81. :columns="columns"
  82. :data="loadData"
  83. :defaultLoadData="false"
  84. bordered>
  85. <div slot="costTitle">
  86. <a-tooltip placement="top">
  87. <template slot="title">
  88. 系统中不同批次的产品,成本价可能不同,此值是按照实际出库批次的成本计算得到。
  89. </template>
  90. <span style="margin-right: 5px;">实际总成本</span> <a-icon type="question-circle" />
  91. </a-tooltip>
  92. </div>
  93. <!-- 产品编码 -->
  94. <template slot="productCode" slot-scope="text, record">
  95. <div v-if="detailData">
  96. <div v-if="isOwerEdit">
  97. <a-badge count="急" v-if="record.oosFlag == 1">
  98. <div style="padding-right: 15px;">{{ text }}</div>
  99. </a-badge>
  100. <span v-else>{{ text }}</span>
  101. </div>
  102. <div v-else>
  103. <a-badge count="急" v-if="isAudit&&record.oosFlag == 1">
  104. <div style="padding-right: 15px;">{{ text }}</div>
  105. </a-badge>
  106. <a-badge count="缺" v-else-if="!isAudit&&(!record.currentStockQty || record.currentStockQty < record.qty)">
  107. <div style="padding-right: 15px;">{{ text }}</div>
  108. </a-badge>
  109. <span v-else>{{ text }}</span>
  110. </div>
  111. </div>
  112. </template>
  113. <!-- 操作 -->
  114. <template slot="action" slot-scope="text, record">
  115. <a-button size="small" type="link" v-if="record.oosFlag == 0 && (isOwerEdit || isAudit)" class="button-primary" @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 { STable, VSelect } from '@/components'
  129. import { salesDetailBySn, salesDetailPrint, salesDetailExport } from '@/api/sales'
  130. import { salesDetailList } from '@/api/salesDetail'
  131. import outInDetialModal from '@/views/common/outInDetialModal.vue'
  132. import Print from '@/views/common/print.vue'
  133. import { hdPrint } from '@/libs/JGPrint'
  134. export default {
  135. name: 'SalesDetail',
  136. components: { STable, VSelect, Print, outInDetialModal },
  137. mixins: [commonMixin],
  138. props: {
  139. outBizSn: { // 有值则为弹框,无值则为页面
  140. type: [Number, String],
  141. default: ''
  142. }
  143. },
  144. data () {
  145. return {
  146. showPage: false,
  147. spinning: false,
  148. disabled: false,
  149. showCost: false,
  150. printOrgCode: false, // 打印原创编码
  151. printAllName: false, // 打印全部名称
  152. showOutInModal: false,
  153. // 加载数据方法 必须为 Promise 对象
  154. loadData: parameter => {
  155. this.disabled = true
  156. return salesDetailList(Object.assign(parameter, { salesBillSn: this.outBizSn || this.$route.params.sn, orderBy: 'sales_bill_detail.CREATE_DATE desc' })).then(res => {
  157. let data
  158. if (res.status == 200) {
  159. data = res.data
  160. const no = (data.pageNo - 1) * data.pageSize
  161. for (var i = 0; i < data.list.length; i++) {
  162. data.list[i].no = no + i + 1
  163. const productCode = (data.list[i].productEntity && data.list[i].productEntity.code) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.code)
  164. const productName = (data.list[i].productEntity && data.list[i].productEntity.name) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.name)
  165. const productOrigCode = (data.list[i].productEntity && data.list[i].productEntity.origCode) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.origCode) || '--'
  166. const productOrigUnit = (data.list[i].productEntity && data.list[i].productEntity.unit) || (data.list[i].dealerProductEntity && data.list[i].dealerProductEntity.unit)
  167. data.list[i].productCode = productCode || '--'
  168. data.list[i].productName = productName || '--'
  169. data.list[i].productOrigCode = productOrigCode || '--'
  170. data.list[i].productOrigUnit = productOrigUnit || '--'
  171. data.list[i].warehouseName = data.list[i].warehouseEntity && data.list[i].warehouseEntity.name || '--'
  172. data.list[i].warehouseLocationName = data.list[i].warehouseLocationEntity && data.list[i].warehouseLocationEntity.name || '--'
  173. // 售价小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
  174. data.list[i].salePriceSubtotal = getOperationalPrecision(data.list[i].price, data.list[i].qty)
  175. }
  176. this.localDataSource = data.list
  177. this.disabled = false
  178. }
  179. return data
  180. })
  181. },
  182. localDataSource: [],
  183. detailData: null // 详情数据
  184. }
  185. },
  186. computed: {
  187. // 是否自建单据
  188. isOwerEdit () {
  189. return this.detailData && this.detailData.sourceType == 'SALES'
  190. },
  191. // 是否审核通过
  192. isAudit () {
  193. return this.detailData ? (this.detailData.billStatus == 'WAIT_OUT_WAREHOUSE' || this.detailData.billStatus == 'FINISH') : false
  194. },
  195. columns () {
  196. const _this = this
  197. const arr = [
  198. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  199. { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: '9%', scopedSlots: { customRender: 'productCode' }, align: 'center' },
  200. { title: '产品名称', dataIndex: 'productName', width: '13%', align: 'left', customRender: function (text) { return text || '--' } },
  201. { title: '原厂编码', dataIndex: 'productOrigCode', width: '9%', align: 'center', customRender: function (text) { return text && text != ' ' ? text : '--' } },
  202. { title: '售价', dataIndex: 'price', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  203. { title: '折后售价', dataIndex: 'discountedPrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  204. { title: '销售数量', dataIndex: 'qty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  205. { title: '单位', dataIndex: 'productOrigUnit', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  206. { title: '售价小计', dataIndex: 'totalAmount', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  207. { title: '折后小计', dataIndex: 'discountedAmount', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  208. { title: '折扣金额', dataIndex: 'discountAmount', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  209. // { title: '仓库', dataIndex: 'warehouseName', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  210. // { title: '仓位', dataIndex: 'warehouseLocationName', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  211. { title: '是否急件', dataIndex: 'oosFlagDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  212. { title: '操作', scopedSlots: { customRender: 'action' }, width: '7%', align: 'center' }
  213. ]
  214. // 实际总成本
  215. if (this.showCost) {
  216. arr.splice(11, 0, { slots: { title: 'costTitle' }, dataIndex: 'totalCost', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  217. } else {
  218. arr.splice(11, 1)
  219. }
  220. // 下级创建,不显示仓库仓位
  221. if (!this.isOwerEdit) {
  222. arr.splice(this.showCost ? 12 : 11, 0, { title: '库存数量', dataIndex: 'currentStockQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  223. } else {
  224. arr.splice(this.showCost ? 12 : 11, 0, { title: '仓库', dataIndex: 'warehouseName', width: '7%', align: 'center', customRender: function (text) { return text || '--' } })
  225. arr.splice(this.showCost ? 13 : 12, 0, { title: '仓位', dataIndex: 'warehouseLocationName', width: '7%', align: 'center', customRender: function (text) { return text || '--' } })
  226. }
  227. return arr
  228. }
  229. },
  230. methods: {
  231. // 打印预览/快捷打印
  232. handlePrint (type, printerType) {
  233. const _this = this
  234. _this.spinning = true
  235. let url = salesDetailPrint
  236. const params = { sn: this.outBizSn || this.$route.params.sn, printOrgCode: this.printOrgCode ? 1 : 0, printAllName: this.printAllName ? 1 : 0, remarksShowFlag: 0, priceFlag: 1 }
  237. if (type == 'export') { // 导出
  238. url = salesDetailExport
  239. }
  240. // 打印或导出
  241. hdPrint(printerType, type, url, params, '销售单', function () {
  242. _this.spinning = false
  243. })
  244. },
  245. // 返回
  246. handleBack () {
  247. this.$router.push({ path: '/salesManagement/salesQuery/list' })
  248. },
  249. // 编辑
  250. handleEdit () {
  251. const row = this.detailData
  252. this.$router.push({ name: 'salesEdit', params: { id: row.id, sn: row.salesBillSn, priceType: row.priceType } })
  253. },
  254. // 详情
  255. getDetail () {
  256. salesDetailBySn({ salesBillSn: this.outBizSn || this.$route.params.sn }).then(res => {
  257. if (res.status == 200) {
  258. this.detailData = res.data
  259. } else {
  260. this.detailData = null
  261. }
  262. })
  263. },
  264. // 出入库明细
  265. handleViewDetail (row) {
  266. this.showOutInModal = true
  267. this.$refs.outInDetialModal.getData(row)
  268. },
  269. pageInit () {
  270. const vm = this
  271. vm.$nextTick(() => {
  272. vm.spinning = false
  273. vm.disabled = false
  274. // 是否默认打印原厂编码
  275. vm.printOrgCode = localStorage.getItem('printOrgCode-' + this.$store.state.user.info.orgId) == 'true'
  276. vm.printAllName = localStorage.getItem('printAllName-' + this.$store.state.user.info.orgId) == 'true'
  277. vm.$refs.table.refresh(true)
  278. vm.getDetail()
  279. })
  280. }
  281. },
  282. watch: {
  283. printOrgCode (newValue, oldValue) {
  284. localStorage.setItem('printOrgCode-' + this.$store.state.user.info.orgId, newValue)
  285. },
  286. printAllName (newValue, oldValue) {
  287. localStorage.setItem('printAllName-' + this.$store.state.user.info.orgId, newValue)
  288. }
  289. },
  290. mounted () {
  291. if (!this.$store.state.app.isNewTab || this.outBizSn) { // 页签刷新时调用
  292. this.showPage = true
  293. this.pageInit()
  294. }
  295. },
  296. activated () {
  297. this.showPage = true
  298. this.pageInit()
  299. },
  300. beforeRouteEnter (to, from, next) {
  301. next(vm => {
  302. })
  303. }
  304. }
  305. </script>
  306. <style lang="less">
  307. .salesDetail-wrap{
  308. .salesDetail-cont{
  309. margin-bottom: 6px;
  310. }
  311. }
  312. </style>