detail.vue 14 KB

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