detail.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <div class="warehouseAllocationDetail-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="warehouseAllocationDetail-back" :style="{ padding: !outBizSn ? '16px 24px' : '0px 24px' }" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle" v-if="!outBizSn">
  7. <a id="warehouseAllocationDetail-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. <a-button
  9. v-if="warehouse&&warehouse.stateDictValue!='已完结'&&$hasPermissions('B_warehouseAllocationEdit')"
  10. type="primary"
  11. size="small"
  12. style="background-color: #1890ff;margin-left: 20px;border: #1890ff;"
  13. id="warehouseAllocationEdit-btn"
  14. @click.stop="handleEdit">
  15. 编辑
  16. </a-button>
  17. </template>
  18. </a-page-header>
  19. <!-- 基础信息 -->
  20. <a-card size="small" :bordered="false" class="warehouseAllocationDetail-cont">
  21. <a-collapse :activeKey="['1']">
  22. <a-collapse-panel key="1" header="基础信息">
  23. <a-descriptions :column="3">
  24. <a-descriptions-item label="调出仓库">{{ (warehouse&&warehouse.outWarehouseName) || '--' }}</a-descriptions-item>
  25. <a-descriptions-item label="调入仓库">{{ (warehouse&&warehouse.putWarehouseName) || '--' }}</a-descriptions-item>
  26. <a-descriptions-item label="调拨单号">{{ (warehouse&&warehouse.allocationWarehouseNo) || '--' }}</a-descriptions-item>
  27. <a-descriptions-item label="关联单号">{{ (warehouse&&warehouse.relevanceNo) || '--' }}</a-descriptions-item>
  28. <a-descriptions-item label="单据状态">{{ (warehouse&&warehouse.stateDictValue) || '--' }}</a-descriptions-item>
  29. <a-descriptions-item label="备注">{{ (warehouse&&warehouse.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="warehouseAllocationDetail-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. <div style="display: inline-block;" v-if="$hasPermissions('M_ShowAllCost')">
  41. ,总成本: <strong>{{ productTotal&&(productTotal.productTotalCost || productTotal.productTotalCost==0) ? '¥'+productTotal.productTotalCost : '--' }}</strong>
  42. </div>
  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. bordered>
  54. <!-- 产品类别 -->
  55. <template slot="productType" slot-scope="text, record">
  56. <a-tooltip placement="top">
  57. <template slot="title">
  58. <span>{{ record.productTypeName }}</span>
  59. </template>
  60. {{ record.productTypeName3 }}
  61. </a-tooltip>
  62. </template>
  63. <!-- 成本小计 -->
  64. <template slot="totalCost" slot-scope="text, record">
  65. <span>{{ (record.allocationCost * record.allocationQty) || 0 }}</span>
  66. </template>
  67. </s-table>
  68. </a-card>
  69. </a-spin>
  70. </div>
  71. </template>
  72. <script>
  73. import { commonMixin } from '@/utils/mixin'
  74. import { STable, VSelect } from '@/components'
  75. import { allocWarehouseDetailSn, allocWarehouseDetailCount, allocWarehouseDetailList } from '@/api/allocWarehouse.js'
  76. export default {
  77. name: 'AllocWarehouseDetail',
  78. components: { STable, VSelect },
  79. mixins: [commonMixin],
  80. props: {
  81. outBizSn: { // 有值则为弹框,无值则为页面
  82. type: [Number, String],
  83. default: ''
  84. }
  85. },
  86. data () {
  87. return {
  88. spinning: false,
  89. exportLoading: false, // 导出loading
  90. warehouse: null, // 基础信息
  91. productTotal: null,
  92. // 加载数据方法 必须为 Promise 对象
  93. loadData: parameter => {
  94. this.disabled = true
  95. this.spinning = true
  96. return allocWarehouseDetailList(Object.assign(parameter, { allocationWarehouseSn: this.outBizSn || this.$route.params.sn })).then(res => {
  97. let data
  98. if (res.status == 200) {
  99. data = res.data
  100. this.getProduceTotal()
  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. }
  105. this.disabled = false
  106. }
  107. this.spinning = false
  108. return data
  109. })
  110. }
  111. }
  112. },
  113. computed: {
  114. columns () {
  115. const arr = [
  116. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  117. { title: '产品编码', dataIndex: 'productCode', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  118. { title: '产品名称', dataIndex: 'productName', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  119. { title: '原厂编码', dataIndex: 'productOrigCode', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  120. { title: '类别', scopedSlots: { customRender: 'productType' }, width: '14%', align: 'center' },
  121. { title: '数量', dataIndex: 'allocationQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  122. { title: '单位', dataIndex: 'productUnit', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  123. // { title: '成本小计(¥)', dataIndex: 'totalAllocationCost', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  124. { title: '调出仓位', dataIndex: 'outWarehouseLocationName', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  125. { title: '调入仓位', dataIndex: 'putWarehouseLocationName', width: '11%', align: 'center', customRender: function (text) { return text || '--' } }
  126. ]
  127. if (this.$hasPermissions('M_ShowAllCost')) {
  128. arr.splice(7, 0, { title: '成本小计(¥)', dataIndex: 'totalAllocationCost', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  129. }
  130. return arr
  131. }
  132. },
  133. methods: {
  134. // 返回列表
  135. handleBack () {
  136. this.$router.push({ path: '/allocationManagement/warehouseAllocation/list' })
  137. },
  138. // 新增/编辑
  139. handleEdit () {
  140. this.$router.push({ path: `/allocationManagement/warehouseAllocation/edit/${this.warehouse.id}/${this.warehouse.allocationWarehouseSn}` })
  141. },
  142. // 查询基础信息
  143. getHouse () {
  144. allocWarehouseDetailSn({ sn: this.outBizSn || this.$route.params.sn }).then(res => {
  145. if (res.status == 200) {
  146. this.warehouse = res.data
  147. // this.queryParam.outWarehouseSn = res.data.outWarehouseSn
  148. } else {
  149. this.warehouse = null
  150. }
  151. })
  152. },
  153. // 已选产品总计查询
  154. getProduceTotal () {
  155. allocWarehouseDetailCount({ allocationWarehouseSn: this.outBizSn || this.$route.params.sn }).then(res => {
  156. if (res.status == 200) {
  157. this.productTotal = res.data
  158. } else {
  159. this.productTotal = null
  160. }
  161. })
  162. }
  163. },
  164. mounted () {
  165. if (!this.$store.state.app.isNewTab || this.outBizSn) { // 页签刷新 或 为弹框时调用
  166. // this.$refs.table.refresh(true)
  167. this.getHouse()
  168. }
  169. },
  170. activated () {
  171. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  172. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  173. // this.$refs.table.refresh(true)
  174. this.getHouse()
  175. }
  176. },
  177. beforeRouteEnter (to, from, next) {
  178. next(vm => {})
  179. }
  180. }
  181. </script>
  182. <style lang="less">
  183. .warehouseAllocationDetail-cont, .warehouseAllocationDetail-back{
  184. margin-bottom: 10px;
  185. }
  186. </style>