detail.vue 8.6 KB

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