detail.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <div class="chainTransferOutDetail-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="chainTransferOutDetail-cont" :style="{ padding: !outBizSn ? '16px 24px' : '0px 24px' }" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle" v-if="!outBizSn">
  7. <a id="chainTransferOutDetail-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. <a-button
  9. v-if="isEdit&&$hasPermissions('B_allocLinkageOutEdit')"
  10. type="primary"
  11. size="small"
  12. style="background-color: #1890ff;margin-left: 20px;border: #1890ff;"
  13. id="chainTransferOutDetail-edit-btn"
  14. @click.stop="handleEdit">编辑</a-button>
  15. </template>
  16. <!-- 操作区,位于 title 行的行尾 -->
  17. <template slot="extra" v-if="outBizSn ? $hasPermissions('B_outboundOrderDetail') : $hasPermissions('B_allocLinkageOutPrint')">
  18. <Print :disabled="localDataSource.length==0" :showExport="false" @handlePrint="handlePrint"></Print>
  19. </template>
  20. </a-page-header>
  21. <!-- 基础信息 -->
  22. <a-card size="small" :bordered="false" class="chainTransferOutDetail-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.putTenantName) || '--' }}</a-descriptions-item>
  27. <a-descriptions-item label="调出单号">{{ (basicInfoData&&basicInfoData.allocationLinkageOutNo) || '--' }}</a-descriptions-item>
  28. <a-descriptions-item label="业务状态">{{ (basicInfoData&&basicInfoData.stateDictValue) || '--' }}</a-descriptions-item>
  29. <a-descriptions-item label="财务状态">{{ (basicInfoData&&basicInfoData.settleStateDictValue) || '--' }}</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. <!-- 产品详情 -->
  36. <a-card size="small" :bordered="false" class="chainTransferOutDetail-cont">
  37. <a-collapse :activeKey="['1']">
  38. <a-collapse-panel key="1" header="产品详情">
  39. <!-- 总计 -->
  40. <a-alert type="info" style="margin-bottom:10px">
  41. <div slot="message">
  42. 总款数 <strong>{{ (productTotal&&(productTotal.productTotalCategory || productTotal.productTotalCategory==0)) ? productTotal.productTotalCategory : '--' }}</strong> ,
  43. 总数量 <strong>{{ (productTotal&&(productTotal.productTotalQty || productTotal.productTotalQty==0)) ? productTotal.productTotalQty : '--' }}</strong> ,
  44. 总成本 <strong>{{ (productTotal&&(productTotal.productTotalCost || productTotal.productTotalCost==0)) ? '¥'+productTotal.productTotalCost : '--' }}</strong>
  45. </div>
  46. </a-alert>
  47. <!-- 列表 -->
  48. <s-table
  49. class="sTable"
  50. ref="table"
  51. size="small"
  52. :rowKey="(record) => record.id"
  53. :columns="columns"
  54. :data="loadData"
  55. :defaultLoadData="false"
  56. bordered>
  57. </s-table>
  58. </a-collapse-panel>
  59. </a-collapse>
  60. </a-card>
  61. </a-spin>
  62. </div>
  63. </template>
  64. <script>
  65. import { STable, VSelect } from '@/components'
  66. import { getOperationalPrecision } from '@/libs/tools.js'
  67. import { allocLinkageOutDetailSn, allocLinkageOutDetailList, allocLinkageOutDetailCount, allocLinkageOutDetailPrint } from '@/api/allocLinkageOut'
  68. import Print from '@/views/common/print.vue'
  69. import { hdPrint } from '@/libs/JGPrint'
  70. export default {
  71. components: { STable, VSelect, Print },
  72. props: {
  73. outBizSn: { // 有值则为弹框,无值则为页面
  74. type: [Number, String],
  75. default: ''
  76. }
  77. },
  78. data () {
  79. return {
  80. spinning: false,
  81. // 表头
  82. columns: [
  83. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  84. { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  85. { title: '产品名称', dataIndex: 'dealerProductEntity.name', width: '20%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  86. { title: '原厂编码', dataIndex: 'dealerProductEntity.origCode', width: '17%', align: 'center', customRender: function (text) { return text || '--' } },
  87. { title: '成本价', dataIndex: 'outCost', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  88. { title: '调出仓库', dataIndex: 'warehouseName', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  89. { title: '调出数量', dataIndex: 'outQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  90. { title: '成本小计(¥)', dataIndex: 'costSubtotal', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  91. ],
  92. // 加载数据方法 必须为 Promise 对象
  93. loadData: parameter => {
  94. this.disabled = true
  95. const params = Object.assign(parameter, { allocationLinkageOutSn: this.outBizSn || this.$route.params.sn })
  96. return allocLinkageOutDetailList(params).then(res => {
  97. let data
  98. if (res.status == 200) {
  99. data = res.data
  100. this.getDetailCount(params)
  101. const no = (data.pageNo - 1) * data.pageSize
  102. for (var i = 0; i < data.list.length; i++) {
  103. data.list[i].no = no + i + 1
  104. // 成本小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
  105. data.list[i].costSubtotal = getOperationalPrecision(data.list[i].outCost, data.list[i].outQty)
  106. }
  107. this.disabled = false
  108. this.localDataSource = data.list
  109. }
  110. return data
  111. })
  112. },
  113. basicInfoData: null, // 基本信息
  114. productTotal: null, // 合计
  115. localDataSource: []
  116. }
  117. },
  118. computed: {
  119. isEdit () {
  120. return ((this.basicInfoData && this.basicInfoData.state == 'WAIT_SUBMIT') || (this.basicInfoData && this.basicInfoData.state == 'WAIT_AUDIT')) && this.$hasPermissions('B_allocLinkageOutEdit')
  121. }
  122. },
  123. methods: {
  124. // 返回列表
  125. handleBack () {
  126. this.$router.push({ path: '/allocationManagement/chainTransferOut/list', query: { closeLastOldTab: true } })
  127. },
  128. // 基本信息
  129. getDetail () {
  130. allocLinkageOutDetailSn({ sn: this.outBizSn || this.$route.params.sn }).then(res => {
  131. if (res.status == 200) {
  132. this.basicInfoData = res.data
  133. } else {
  134. this.basicInfoData = null
  135. }
  136. })
  137. },
  138. // 合计
  139. getDetailCount (params) {
  140. allocLinkageOutDetailCount(params).then(res => {
  141. if (res.status == 200) {
  142. this.productTotal = res.data
  143. } else {
  144. this.productTotal = null
  145. }
  146. })
  147. },
  148. // 编辑
  149. handleEdit () {
  150. this.$router.push({ path: `/allocationManagement/chainTransferOut/edit/${this.basicInfoData.id}/${this.basicInfoData.allocationLinkageOutSn}` })
  151. },
  152. // 打印预览/快捷打印
  153. handlePrint (type, printerType) {
  154. const _this = this
  155. _this.spinning = true
  156. const url = allocLinkageOutDetailPrint
  157. const params = { sn: this.outBizSn || this.$route.params.sn, type: printerType }
  158. // 打印或导出
  159. hdPrint(printerType, type, url, params, '', function () {
  160. _this.spinning = false
  161. })
  162. }
  163. },
  164. mounted () {
  165. if (!this.$store.state.app.isNewTab || this.outBizSn) { // 页签刷新 或 为弹框时调用
  166. this.getDetail()
  167. this.$refs.table.refresh(true)
  168. }
  169. },
  170. activated () {
  171. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  172. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  173. this.getDetail()
  174. this.$refs.table.refresh(true)
  175. }
  176. },
  177. beforeRouteEnter (to, from, next) {
  178. next(vm => {})
  179. }
  180. }
  181. </script>
  182. <style lang="less">
  183. .chainTransferOutDetail-cont{
  184. margin-bottom: 10px;
  185. }
  186. </style>