detail.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <div class="allocateBillDetail-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="allocateBillDetail-back" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="allocateBillDetail-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. <a-button
  9. v-if="isEdit"
  10. type="primary"
  11. size="small"
  12. style="background-color: #1890ff;margin-left: 20px;border: #1890ff;"
  13. id="allocateBillDetail-edit-btn"
  14. @click.stop="handleEdit">编辑</a-button>
  15. </template>
  16. <!-- 操作区,位于 title 行的行尾 -->
  17. <template v-if="$hasPermissions('B_transferOut_print')" slot="extra">
  18. <a-button key="2" id="allocateBillDetail-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
  19. <a-button key="1" type="primary" id="allocateBillDetail-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
  20. </template>
  21. </a-page-header>
  22. <a-card size="small" :bordered="false" class="allocateBillDetail-cont">
  23. <a-collapse :activeKey="['1']">
  24. <a-collapse-panel key="1" header="基础信息">
  25. <a-descriptions :column="3">
  26. <a-descriptions-item label="调往对象">{{ (basicInfoData&&basicInfoData.targetName) || '--' }}</a-descriptions-item>
  27. <a-descriptions-item label="调拨单号">{{ (basicInfoData&&basicInfoData.allocateNo) || '--' }}</a-descriptions-item>
  28. <a-descriptions-item label="调拨类型">{{ (basicInfoData&&basicInfoData.allocateTypeName) || '--' }}</a-descriptions-item>
  29. <a-descriptions-item label="业务状态">{{ (basicInfoData&&basicInfoData.stateDictValue) || '--' }}</a-descriptions-item>
  30. <a-descriptions-item label="备注">{{ (basicInfoData&&basicInfoData.remark) || '--' }}</a-descriptions-item>
  31. </a-descriptions>
  32. </a-collapse-panel>
  33. </a-collapse>
  34. </a-card>
  35. <a-card size="small" :bordered="false" class="allocateBillDetail-cont">
  36. <!-- 总计 -->
  37. <a-alert type="info" showIcon style="margin-bottom:15px">
  38. <div slot="message">总数量:<strong>{{ (productTotal&&productTotal.totalQty) || 0 }}</strong> ,总成本(¥):<strong>{{ (productTotal&&productTotal.totalCost) || 0 }}</strong> ,总售价(¥):<strong>{{ (productTotal&&productTotal.totalPrice) || 0 }}</strong></div>
  39. </a-alert>
  40. <!-- 列表 -->
  41. <s-table
  42. class="sTable"
  43. ref="table"
  44. size="small"
  45. :rowKey="(record) => record.id"
  46. :columns="columns"
  47. :data="loadData"
  48. :scroll="{ x: 1335 }"
  49. bordered>
  50. </s-table>
  51. </a-card>
  52. </a-spin>
  53. <!-- 打印 -->
  54. <div id="print"></div>
  55. </div>
  56. </template>
  57. <script>
  58. import { STable, VSelect } from '@/components'
  59. import { getOperationalPrecision } from '@/libs/tools.js'
  60. import { allocateBillDetailList, allocateBillDetail, allocateBillDetailCount, allocateBillDetailPrint } from '@/api/allocateBill'
  61. export default {
  62. components: { STable, VSelect },
  63. data () {
  64. return {
  65. spinning: false,
  66. // 表头
  67. columns: [
  68. { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
  69. { title: '产品编码', dataIndex: 'productEntity.code', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  70. { title: '产品名称', dataIndex: 'productEntity.name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  71. { title: '原厂编码', dataIndex: 'productEntity.origCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  72. { title: '单位', dataIndex: 'productEntity.unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  73. { title: '成本价', dataIndex: 'cost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  74. { title: '售价', dataIndex: 'price', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  75. { title: '调出数量', dataIndex: 'qty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  76. { title: '成本小计(¥)', dataIndex: 'costSubtotal', width: 115, align: 'center' },
  77. { title: '售价小计(¥)', dataIndex: 'priceSubtotal', width: 100, align: 'center' }
  78. ],
  79. // 加载数据方法 必须为 Promise 对象
  80. loadData: parameter => {
  81. return allocateBillDetailList(Object.assign(parameter, { allocateSn: this.$route.params.sn })).then(res => {
  82. const data = res.data
  83. const no = (data.pageNo - 1) * data.pageSize
  84. for (var i = 0; i < data.list.length; i++) {
  85. data.list[i].no = no + i + 1
  86. // 成本小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
  87. data.list[i].costSubtotal = getOperationalPrecision(data.list[i].cost, data.list[i].qty)
  88. data.list[i].priceSubtotal = getOperationalPrecision(data.list[i].price, data.list[i].qty)
  89. }
  90. this.localDataSource = data.list
  91. return data
  92. })
  93. },
  94. basicInfoData: null, // 基本信息
  95. productTotal: null, // 合计
  96. localDataSource: []
  97. }
  98. },
  99. computed: {
  100. isEdit () {
  101. return (this.basicInfoData && this.basicInfoData.state == 'WAIT_SUBMIT') || (this.basicInfoData && this.basicInfoData.state == 'WAIT_AUDIT')
  102. }
  103. },
  104. methods: {
  105. // 返回列表
  106. handleBack () {
  107. this.$router.push({ path: '/allocationManagement/transferOut/list' })
  108. },
  109. // 基本信息
  110. getDetail () {
  111. allocateBillDetail({ sn: this.$route.params.sn }).then(res => {
  112. if (res.status == 200) {
  113. this.basicInfoData = res.data
  114. } else {
  115. this.basicInfoData = null
  116. }
  117. })
  118. },
  119. // 合计
  120. getDetailCount () {
  121. allocateBillDetailCount({ allocateSn: this.$route.params.sn }).then(res => {
  122. if (res.status == 200) {
  123. this.productTotal = res.data
  124. } else {
  125. this.productTotal = null
  126. }
  127. })
  128. },
  129. // 编辑
  130. handleEdit () {
  131. this.$router.push({ path: `/allocationManagement/transferOut/edit/${this.basicInfoData.allocateSn}/${this.basicInfoData.targetName}/${this.basicInfoData.dealerLevel}` })
  132. },
  133. // 打印预览/快捷打印
  134. handlePrint (type) {
  135. const _this = this
  136. _this.spinning = true
  137. allocateBillDetailPrint({ sn: this.$route.params.sn, isPreview: type == 'preview' ? 1 : 0 }).then(res => {
  138. _this.spinning = false
  139. if (res.type == 'application/json') {
  140. var reader = new FileReader()
  141. reader.addEventListener('loadend', function () {
  142. const obj = JSON.parse(reader.result)
  143. _this.$notification.error({
  144. message: '提示',
  145. description: obj.message
  146. })
  147. })
  148. reader.readAsText(res)
  149. } else {
  150. this.print(res, type)
  151. }
  152. })
  153. },
  154. print (data, type) {
  155. if (!data) {
  156. return
  157. }
  158. const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
  159. document.getElementById('print').innerHTML = '<iframe id="printf" name="printf" src="' + url + '" hidden></iframe>'
  160. if (type == 'preview') { // 预览
  161. window.open(url)
  162. } else if (type == 'print') { // 打印
  163. window.frames['printf'].focus()
  164. window.frames['printf'].print()
  165. }
  166. }
  167. },
  168. beforeRouteEnter (to, from, next) {
  169. next(vm => {
  170. vm.getDetail()
  171. vm.getDetailCount()
  172. })
  173. }
  174. }
  175. </script>
  176. <style lang="less">
  177. .allocateBillDetail-wrap{
  178. .allocateBillDetail-back{
  179. margin-bottom: 10px;
  180. }
  181. .allocateBillDetail-cont{
  182. margin-bottom: 10px;
  183. }
  184. }
  185. </style>