detail.vue 8.0 KB

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