detail.vue 9.2 KB

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