detail.vue 8.7 KB

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