detail.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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" style="color: #ed1c24;">优惠金额:<strong>{{ detail && (detail.discountAmount || detail.discountAmount==0) ? detail.discountAmount.toFixed(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. <a-badge v-if="showConvertPromoGIftQty && record.convertPromoGiftsFlag && record.convertPromoGiftsFlag==1" count="转" :number-style="{ backgroundColor: '#ff0000', zoom:'80%',marginLeft:'5px' }"></a-badge>
  84. </template>
  85. <!-- 采购数量 -->
  86. <template slot="origqty" slot-scope="text, record">
  87. <div>{{ text }}</div>
  88. <div v-if="record.origqty">原采购数量:{{ record.origqty }}</div>
  89. </template>
  90. <!-- 已取消数量 -->
  91. <template slot="outOfStockNum" slot-scope="text, record">
  92. <span>{{ record.outOfStockNum }}</span>
  93. </template>
  94. <!-- 采购单价 -->
  95. <template slot="unitPrice" slot-scope="text, record">
  96. <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>
  97. <span v-else>{{ toThousands(record.price) }}</span>
  98. </template>
  99. <!-- 采购金额 -->
  100. <template slot="amount" slot-scope="text, record">
  101. <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>
  102. <span v-else>{{ toThousands(record.discountedAmount) }}</span>
  103. </template>
  104. <!-- 转采购额数量 -->
  105. <template slot="customTitle1">
  106. <a-tooltip>
  107. <template slot="title">
  108. 即促销产品转采购额的数量,订单完结后会进行费用报销
  109. </template>
  110. 转采购额数量<a-icon type="question-circle" />
  111. </a-tooltip>
  112. </template>
  113. <!-- 转采购额金额 -->
  114. <template slot="customTitle2">
  115. <a-tooltip>
  116. <template slot="title">
  117. 即促销产品转采购额金额,促销产品转采购额数量*销售价
  118. </template>
  119. 转采购额金额<a-icon type="question-circle" />
  120. </a-tooltip>
  121. </template>
  122. </s-table>
  123. </a-collapse-panel>
  124. </a-collapse>
  125. </a-card>
  126. </a-spin>
  127. </div>
  128. </template>
  129. <script>
  130. import { commonMixin } from '@/utils/mixin'
  131. import { STable, VSelect } from '@/components'
  132. import { purchaseDetailBySn, purchaseDetailPrint, purchaseDetailExport, purchaseExportDetail } from '@/api/purchase'
  133. import { purchaseDetailList } from '@/api/purchaseDetail'
  134. import Print from '@/views/common/print.vue'
  135. import { hdPrint, downloadExcel } from '@/libs/JGPrint'
  136. export default {
  137. name: 'PurchaseDetail',
  138. components: { STable, VSelect, Print },
  139. mixins: [commonMixin],
  140. props: {
  141. outBizSn: { // 有值则为弹框,无值则为页面
  142. type: [Number, String],
  143. default: ''
  144. }
  145. },
  146. data () {
  147. return {
  148. spinning: false,
  149. isShowSalesFlag: false,
  150. // 加载数据方法 必须为 Promise 对象
  151. loadData: parameter => {
  152. this.disabled = true
  153. return purchaseDetailList(Object.assign(parameter, { purchaseBillSn: this.outBizSn || this.$route.params.sn, orderBy: 'product_type.FIRST_CHAR,dealer_product.CODE' })).then(res => {
  154. let data
  155. if (res.status == 200) {
  156. data = res.data
  157. const no = (data.pageNo - 1) * data.pageSize
  158. for (var i = 0; i < data.list.length; i++) {
  159. data.list[i].no = no + i + 1
  160. }
  161. this.isShowSalesFlag = data.list.some(con => { return con.promotionFlag != 0 })
  162. this.localDataSource = data.list
  163. this.disabled = false
  164. }
  165. return data
  166. })
  167. },
  168. detail: null, // 详情数据
  169. localDataSource: [],
  170. printerType: 'NEEDLE' // 打印机类型
  171. }
  172. },
  173. computed: {
  174. showConvertPromoGIftQty(){
  175. const c = this.detail ? this.detail.totalConvertPromoGiftsQty : 0
  176. const a = this.detail ? (this.detail.totalPutQty + this.detail.totalWaitPutQty + this.detail.totalCancelQty + c) : 0
  177. const b = this.detail ? this.detail.totalQty : 0
  178. return this.detail && c>0 && a == b
  179. },
  180. columns () {
  181. const _this = this
  182. const arr = [
  183. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  184. { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: '14%', align: 'center', scopedSlots: { customRender: 'code' } },
  185. { title: '产品名称', dataIndex: 'dealerProductEntity.name', width: '18%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  186. { title: '原厂编码', dataIndex: 'dealerProductEntity.origCode', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  187. { title: '单位', dataIndex: 'dealerProductEntity.unit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  188. // { title: '采购单价', dataIndex: 'discountedPrice', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  189. // { title: '采购金额', dataIndex: 'discountedAmount', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  190. { title: '采购数量', dataIndex: 'qty', width: '7%', align: 'center', scopedSlots: { customRender: 'origqty' } },
  191. // { title: '审核订单金额', dataIndex: 'pushedAmount', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  192. { title: '审核订单数量', dataIndex: 'pushedQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  193. { title: '已取消数量', dataIndex: 'cancelQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  194. ]
  195. if (this.$hasPermissions('M_ShowAllCost')) {
  196. arr.splice(5, 0, { title: '采购单价', dataIndex: 'price', width: '7%', align: 'right', scopedSlots: { customRender: 'unitPrice' } })
  197. arr.splice(6, 0, { title: '采购金额', dataIndex: 'discountedAmount', width: '7%', align: 'right', scopedSlots: { customRender: 'amount' } })
  198. arr.splice(8, 0, { title: '审核订单金额', dataIndex: 'pushedAmount', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } })
  199. }
  200. if(this.showConvertPromoGIftQty){
  201. arr.push({ slots: { title: 'customTitle1' }, dataIndex: 'convertPromoGiftsQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  202. arr.push({ slots: { title: 'customTitle2' }, dataIndex: 'convertPromoGiftsAmount', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } })
  203. }
  204. return arr
  205. }
  206. },
  207. methods: {
  208. // 返回列表
  209. handleBack () {
  210. if (this.$route.query.pageType) {
  211. this.$router.push({ name: this.$route.query.pageType })
  212. } else {
  213. this.$router.push({ name: 'purchaseOrderList' })
  214. }
  215. },
  216. // 详情
  217. getDetail () {
  218. purchaseDetailBySn({ sn: this.outBizSn || this.$route.params.sn }).then(res => {
  219. if (res.status == 200) {
  220. const dataInfo = res.data
  221. if (dataInfo.totalOrigAmount && dataInfo.totalAmount) {
  222. dataInfo.discountAmount = dataInfo.totalOrigAmount - dataInfo.totalAmount
  223. } else {
  224. dataInfo.discountAmount = null
  225. }
  226. this.detail = dataInfo
  227. } else {
  228. this.detail = null
  229. }
  230. })
  231. },
  232. // 打印预览/快捷打印
  233. handlePrint (type, printerType) {
  234. const _this = this
  235. _this.spinning = true
  236. let url = purchaseDetailPrint
  237. let params = { sn: this.outBizSn || this.$route.params.sn, type: printerType }
  238. if (type == 'export') { // 导出
  239. url = purchaseDetailExport
  240. params = { sn: this.outBizSn || this.$route.params.sn }
  241. }
  242. // 打印或导出
  243. hdPrint(printerType, type, url, params, '采购单', function () {
  244. _this.spinning = false
  245. })
  246. },
  247. // 导出产品
  248. handleExportProduct () {
  249. const _this = this
  250. _this.spinning = true
  251. purchaseExportDetail({ sn: this.outBizSn || this.$route.params.sn }).then(res => {
  252. _this.spinning = false
  253. if (res.type == 'application/json') {
  254. var reader = new FileReader()
  255. reader.addEventListener('loadend', function () {
  256. const obj = JSON.parse(reader.result)
  257. _this.$notification.error({
  258. message: '提示',
  259. description: obj.message
  260. })
  261. })
  262. reader.readAsText(res)
  263. } else {
  264. downloadExcel(res, '采购产品')
  265. }
  266. })
  267. }
  268. },
  269. mounted () {
  270. if (!this.$store.state.app.isNewTab || this.outBizSn) { // 页签刷新时调用
  271. this.$refs.table.refresh(true)
  272. this.getDetail()
  273. }
  274. },
  275. activated () {
  276. console.log(this.$store.state.app.isNewTab, !this.$store.state.app.isNewSubTab)
  277. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  278. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  279. this.$refs.table.refresh(true)
  280. this.getDetail()
  281. }
  282. },
  283. beforeRouteEnter (to, from, next) {
  284. next(vm => {})
  285. }
  286. }
  287. </script>
  288. <style lang="less">
  289. .purchaseOrderDetail-cont{
  290. margin-bottom: 10px;
  291. .timeline-box{
  292. margin-top: 30px;
  293. .auxiliary-txt{
  294. color: #808695;
  295. }
  296. }
  297. }
  298. .purchaseOrderDetail-wrap{
  299. .billno{
  300. font-size: 16px;
  301. font-weight: bold;
  302. margin: 0 15px;
  303. }
  304. }
  305. </style>