detail.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <template>
  2. <div class="purchaseOrderDetail-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" @back="handleBack" class="purchaseOrderDetail-cont" :style="{ padding: !outBizSn ? '16px 24px' : '0px 24px' }">
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="purchaseOrderDetail-back-btn" href="javascript:;" @click="handleBack" v-if="!outBizSn"><a-icon type="left" /> 返回列表</a>
  8. <span class="billno">单号:{{ detail&&detail.purchaseBillNo }}</span>
  9. <a-tag color="blue" v-if="detail&&detail.billStatusDictValue">{{ detail&&detail.billStatusDictValue }}</a-tag>
  10. <a-tag color="orange" v-if="detail&&detail.financialStatusDictValue">{{ detail&&detail.financialStatusDictValue }}</a-tag>
  11. <span class="billno" v-if="detail&&detail.purchaseBillNoSource" style="font-size: 14px;margin: 0;">(原:{{ detail&&detail.purchaseBillNoSource }})</span>
  12. </template>
  13. <!-- 操作区,位于 title 行的行尾 -->
  14. <template slot="extra">
  15. <Print v-if="$hasPermissions('B_purchasePrint')" :disabled="localDataSource.length==0" @handlePrint="handlePrint"></Print>
  16. <a-button
  17. key="1"
  18. 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'))"
  19. type="primary"
  20. class="button-info"
  21. id="purchaseOrderDetail-export-btn"
  22. :disabled="localDataSource.length==0"
  23. @click="handleExportProduct()">导出审核订单产品</a-button>
  24. </template>
  25. </a-page-header>
  26. <!-- 基础信息 -->
  27. <a-card size="small" :bordered="false" class="purchaseOrderDetail-cont">
  28. <a-collapse :activeKey="['1']">
  29. <a-collapse-panel key="1" header="基础信息">
  30. <a-descriptions :column="3">
  31. <a-descriptions-item label="供应商">{{ (detail&&detail.purchaseTargetName) || '--' }}</a-descriptions-item>
  32. <a-descriptions-item label="订单类型">{{ detail&&detail.orderTypeDictValue || '--' }}</a-descriptions-item>
  33. <a-descriptions-item label="支付方式">{{ (detail&&detail.settleStyleSnDictValue) || '--' }}</a-descriptions-item>
  34. <a-descriptions-item label="采购员工" v-if="detail&&detail.purchaseBillSource=='PURCHASE'">{{ detail&&detail.operatorName || '--' }}</a-descriptions-item>
  35. <a-descriptions-item label="收货人">{{ detail&&detail.consigneeName || '--' }}<span v-if="detail&&detail.consigneeTel">({{ detail&&detail.consigneeTel }})</span></a-descriptions-item>
  36. <a-descriptions-item label="收货地址">
  37. <div v-if="detail&&(detail.shippingAddressProvinceName || detail.shippingAddressCityName || detail.shippingAddressCountyName || detail.shippingAddress)">
  38. {{ detail&&detail.shippingAddressProvinceName || '' }}
  39. {{ detail&&detail.shippingAddressCityName || '' }}
  40. {{ detail&&detail.shippingAddressCountyName || '' }}
  41. {{ detail&&detail.shippingAddress || '' }}
  42. </div>
  43. <span v-else>--</span>
  44. </a-descriptions-item>
  45. <a-descriptions-item label="备注">{{ (detail&&detail.remarks) || '--' }}</a-descriptions-item>
  46. </a-descriptions>
  47. </a-collapse-panel>
  48. </a-collapse>
  49. </a-card>
  50. <!-- 产品详情 -->
  51. <a-card size="small" :bordered="false" class="purchaseOrderDetail-cont">
  52. <a-collapse :activeKey="['1']">
  53. <a-collapse-panel key="1" header="产品详情">
  54. <!-- 总计 -->
  55. <a-alert type="info" style="margin-bottom:10px">
  56. <div slot="message">
  57. 产品款数:<strong>{{ detail && (detail.totalCategory || detail.totalCategory==0) ? detail.totalCategory : '--' }}</strong>,
  58. 采购数量合计:<strong>{{ detail && (detail.totalQty || detail.totalQty==0) ? detail.totalQty : '--' }}</strong>,
  59. 审核订单数量:<strong>{{ detail && (detail.totalPushedQty || detail.totalPushedQty==0) ? detail.totalPushedQty : '--' }}</strong>,
  60. 已取消数量:<strong>{{ detail && (detail.totalCancelQty || detail.totalCancelQty==0) ? detail.totalCancelQty : '--' }}</strong>,
  61. <div style="display: inline-block;" v-if="$hasPermissions('M_ShowAllCost')">
  62. 采购金额合计:<strong>{{ detail && (detail.discountedAmount || detail.discountedAmount==0) ? toThousands(detail.discountedAmount,2) : '--' }}</strong>,
  63. 审核订单金额:<strong>{{ detail && (detail.totalPushedAmount || detail.totalPushedAmount==0) ? toThousands(detail.totalPushedAmount,2) : '--' }}</strong>,
  64. 已取消金额:<strong>{{ detail && (detail.totalCancelAmount || detail.totalCancelAmount==0) ? toThousands(detail.totalCancelAmount,2) : '--' }}</strong>,
  65. <span v-if="isShowSalesFlag" style="color: #ed1c24;">优惠金额:<strong>{{ detail && (detail.discountAmount || detail.discountAmount==0) ? detail.discountAmount.toFixed(2) : '--' }}</strong></span>
  66. </div>
  67. </div>
  68. </a-alert>
  69. <!-- 列表 -->
  70. <s-table
  71. class="sTable"
  72. ref="table"
  73. size="small"
  74. :rowKey="(record) => record.id"
  75. :columns="columns"
  76. :data="loadData"
  77. :defaultLoadData="false"
  78. bordered>
  79. <!-- 产品编码 -->
  80. <template slot="code" slot-scope="text, record">
  81. <span>{{ record.dealerProductEntity.code }}</span>
  82. <a-badge v-if="record.promotionFlag && record.promotionFlag=='GIFT'" count="促" :number-style="{ backgroundColor: '#52c41a', zoom:'80%',marginLeft:'5px' }"></a-badge>
  83. <a-badge v-if="record.promotionFlag && record.promotionFlag=='DISCOUNT'" count="特" :number-style="{ backgroundColor: '#faad14', zoom:'80%',marginLeft:'5px' }"></a-badge>
  84. <a-badge v-if="showConvertPromoGIftQty && record.convertPromoGiftsFlag && record.convertPromoGiftsQty>0" count="转" :number-style="{ backgroundColor: '#006eff', zoom:'80%',marginLeft:'5px' }"></a-badge>
  85. </template>
  86. <!-- 采购数量 -->
  87. <template slot="origqty" slot-scope="text, record">
  88. <div>{{ text }}</div>
  89. <div v-if="record.origqty">原采购数量:{{ record.origqty }}</div>
  90. </template>
  91. <!-- 已取消数量 -->
  92. <template slot="outOfStockNum" slot-scope="text, record">
  93. <span>{{ record.outOfStockNum }}</span>
  94. </template>
  95. <!-- 采购单价 -->
  96. <template slot="unitPrice" slot-scope="text, record">
  97. <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>
  98. <span v-else>{{ toThousands(record.price) }}</span>
  99. </template>
  100. <!-- 采购金额 -->
  101. <template slot="amount" slot-scope="text, record">
  102. <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>
  103. <span v-else>{{ toThousands(record.discountedAmount) }}</span>
  104. </template>
  105. <!-- 转采购额数量 -->
  106. <template slot="customTitle1">
  107. <a-tooltip>
  108. <template slot="title">
  109. 即促销产品转采购额的数量,订单完结后会进行费用报销
  110. </template>
  111. 转采购额数量<a-icon type="question-circle" />
  112. </a-tooltip>
  113. </template>
  114. <!-- 转采购额金额 -->
  115. <template slot="customTitle2">
  116. <a-tooltip>
  117. <template slot="title">
  118. 即促销产品转采购额金额,促销产品转采购额数量*销售价
  119. </template>
  120. 转采购额金额<a-icon type="question-circle" />
  121. </a-tooltip>
  122. </template>
  123. </s-table>
  124. </a-collapse-panel>
  125. </a-collapse>
  126. </a-card>
  127. </a-spin>
  128. </div>
  129. </template>
  130. <script>
  131. import { commonMixin } from '@/utils/mixin'
  132. import { STable, VSelect } from '@/components'
  133. import { purchaseDetailBySn, purchaseDetailPrint, purchaseDetailExport, purchaseExportDetail } from '@/api/purchase'
  134. import { purchaseDetailList } from '@/api/purchaseDetail'
  135. import Print from '@/views/common/print.vue'
  136. import { hdPrint, downloadExcel } from '@/libs/JGPrint'
  137. export default {
  138. name: 'PurchaseDetail',
  139. components: { STable, VSelect, Print },
  140. mixins: [commonMixin],
  141. props: {
  142. outBizSn: { // 有值则为弹框,无值则为页面
  143. type: [Number, String],
  144. default: ''
  145. }
  146. },
  147. data () {
  148. return {
  149. spinning: false,
  150. isShowSalesFlag: false, // 是否显示优惠金额
  151. // 加载数据方法 必须为 Promise 对象
  152. loadData: parameter => {
  153. this.disabled = true
  154. return purchaseDetailList(Object.assign(parameter, { purchaseBillSn: this.outBizSn || this.$route.params.sn, orderBy: 'product_type.FIRST_CHAR,dealer_product.CODE' })).then(res => {
  155. let data
  156. if (res.status == 200) {
  157. data = res.data
  158. const no = (data.pageNo - 1) * data.pageSize
  159. for (var i = 0; i < data.list.length; i++) {
  160. data.list[i].no = no + i + 1
  161. }
  162. this.isShowSalesFlag = data.list.some(con => { return con.promotionFlag != 0 })
  163. this.localDataSource = data.list
  164. this.disabled = false
  165. }
  166. return data
  167. })
  168. },
  169. detail: null, // 详情数据
  170. localDataSource: [], // 原始数据
  171. printerType: 'NEEDLE' // 打印机类型
  172. }
  173. },
  174. computed: {
  175. // 是否显示转标志
  176. showConvertPromoGIftQty () {
  177. const c = this.detail ? this.detail.totalConvertPromoGiftsQty : 0
  178. const a = this.detail ? (this.detail.totalPutQty + this.detail.totalWaitPutQty + this.detail.totalCancelQty + c) : 0
  179. const b = this.detail ? this.detail.totalQty : 0
  180. return this.detail && c > 0 && a == b
  181. },
  182. columns () {
  183. const _this = this
  184. const arr = [
  185. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  186. { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: '14%', align: 'center', scopedSlots: { customRender: 'code' } },
  187. { title: '产品名称', dataIndex: 'dealerProductEntity.name', width: '18%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  188. { title: '原厂编码', dataIndex: 'dealerProductEntity.origCode', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  189. { title: '单位', dataIndex: 'dealerProductEntity.unit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  190. // { title: '采购单价', dataIndex: 'discountedPrice', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  191. // { title: '采购金额', dataIndex: 'discountedAmount', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  192. { title: '采购数量', dataIndex: 'qty', width: '7%', align: 'center', scopedSlots: { customRender: 'origqty' } },
  193. // { title: '审核订单金额', dataIndex: 'pushedAmount', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  194. { title: '审核订单数量', dataIndex: 'pushedQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  195. { title: '已取消数量', dataIndex: 'cancelQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  196. ]
  197. // 成本权限
  198. if (this.$hasPermissions('M_ShowAllCost')) {
  199. arr.splice(5, 0, { title: '采购单价', dataIndex: 'price', width: '7%', align: 'right', scopedSlots: { customRender: 'unitPrice' } })
  200. arr.splice(6, 0, { title: '采购金额', dataIndex: 'discountedAmount', width: '7%', align: 'right', scopedSlots: { customRender: 'amount' } })
  201. arr.splice(8, 0, { title: '审核订单金额', dataIndex: 'pushedAmount', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } })
  202. }
  203. // 是否转促销品
  204. if (this.showConvertPromoGIftQty) {
  205. arr.push({ slots: { title: 'customTitle1' }, dataIndex: 'convertPromoGiftsQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  206. arr.push({ slots: { title: 'customTitle2' }, dataIndex: 'convertPromoGiftsAmount', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } })
  207. }
  208. return arr
  209. }
  210. },
  211. methods: {
  212. // 返回列表
  213. handleBack () {
  214. if (this.$route.query.pageType) {
  215. this.$router.push({ name: this.$route.query.pageType })
  216. } else {
  217. this.$router.push({ name: 'purchaseOrderList' })
  218. }
  219. },
  220. // 详情
  221. getDetail () {
  222. purchaseDetailBySn({ sn: this.outBizSn || this.$route.params.sn }).then(res => {
  223. if (res.status == 200) {
  224. const dataInfo = res.data
  225. if (dataInfo.totalOrigAmount && dataInfo.totalAmount) {
  226. dataInfo.discountAmount = dataInfo.totalOrigAmount - dataInfo.totalAmount
  227. } else {
  228. dataInfo.discountAmount = null
  229. }
  230. this.detail = dataInfo
  231. } else {
  232. this.detail = null
  233. }
  234. })
  235. },
  236. // 打印预览/快捷打印
  237. handlePrint (type, printerType) {
  238. const _this = this
  239. _this.spinning = true
  240. let url = purchaseDetailPrint
  241. let params = { sn: this.outBizSn || this.$route.params.sn, type: printerType }
  242. if (type == 'export') { // 导出
  243. url = purchaseDetailExport
  244. params = { sn: this.outBizSn || this.$route.params.sn }
  245. }
  246. // 打印或导出
  247. hdPrint(printerType, type, url, params, '采购单', function () {
  248. _this.spinning = false
  249. })
  250. },
  251. // 导出产品
  252. handleExportProduct () {
  253. const _this = this
  254. _this.spinning = true
  255. purchaseExportDetail({ sn: this.outBizSn || this.$route.params.sn }).then(res => {
  256. _this.spinning = false
  257. if (res.type == 'application/json') {
  258. var reader = new FileReader()
  259. reader.addEventListener('loadend', function () {
  260. const obj = JSON.parse(reader.result)
  261. _this.$notification.error({
  262. message: '提示',
  263. description: obj.message
  264. })
  265. })
  266. reader.readAsText(res)
  267. } else {
  268. downloadExcel(res, '采购产品')
  269. }
  270. })
  271. }
  272. },
  273. mounted () {
  274. if (!this.$store.state.app.isNewTab || this.outBizSn) { // 页签刷新时调用
  275. this.$refs.table.refresh(true)
  276. this.getDetail()
  277. }
  278. },
  279. activated () {
  280. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  281. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  282. this.$refs.table.refresh(true)
  283. this.getDetail()
  284. }
  285. },
  286. beforeRouteEnter (to, from, next) {
  287. next(vm => {})
  288. }
  289. }
  290. </script>
  291. <style lang="less">
  292. .purchaseOrderDetail-cont{
  293. margin-bottom: 10px;
  294. .timeline-box{
  295. margin-top: 30px;
  296. .auxiliary-txt{
  297. color: #808695;
  298. }
  299. }
  300. }
  301. .purchaseOrderDetail-wrap{
  302. .billno{
  303. font-size: 16px;
  304. font-weight: bold;
  305. margin: 0 15px;
  306. }
  307. }
  308. </style>