detail.vue 17 KB

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