detail.vue 6.5 KB

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