detailModal.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <a-modal
  3. centered
  4. class="bulkWarehousingOrder-basicInfo-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="详情"
  8. v-model="isShow"
  9. @cancel="isShow=false"
  10. :width="960">
  11. <!-- <div style="padding: 0 12px;text-align: right;">
  12. <a-button id="bulkWarehousingOrderDetail-preview-btn" style="margin-right: 15px;">打印预览</a-button>
  13. <a-button type="primary" id="bulkWarehousingOrderDetail-print-btn">快速打印</a-button>
  14. </div> -->
  15. <!-- 基础信息 -->
  16. <a-card size="small" :bordered="false" class="bulkWarehousingOrderDetail-cont">
  17. <a-collapse :activeKey="['1']">
  18. <a-collapse-panel key="1">
  19. <template slot="header">
  20. 基础信息
  21. </template>
  22. <a-descriptions :column="3">
  23. <a-descriptions-item label="供应商">{{ (productTotal&&productTotal.supplierName) || '--' }}</a-descriptions-item>
  24. <a-descriptions-item label="入库类型">{{ (productTotal&&productTotal.sparePartsTypeDictValue) || '--' }}</a-descriptions-item>
  25. <a-descriptions-item label="入库单号">{{ (productTotal&&productTotal.sparePartsNo) || '--' }}</a-descriptions-item>
  26. </a-descriptions>
  27. </a-collapse-panel>
  28. </a-collapse>
  29. </a-card>
  30. <a-card size="small" :bordered="false" class="bulkWarehousingOrderDetail-cont">
  31. <!-- 总计 -->
  32. <a-alert type="info" style="margin-bottom:10px">
  33. <div slot="message">
  34. 入库数量 <strong>{{ (productTotal&&(productTotal.totalQty || productTotal.totalQty==0)) ? productTotal.totalQty : '--' }}</strong> ,
  35. <span v-if="$hasPermissions('B_isShowCost')">入库金额 <strong>{{ (productTotal&&(productTotal.totalPrice || productTotal.totalPrice==0)) ? productTotal.totalPrice : '--' }}</strong></span>
  36. </div>
  37. </a-alert>
  38. <!-- 列表 -->
  39. <s-table
  40. class="sTable"
  41. ref="table"
  42. size="small"
  43. :rowKey="(record) => record.id"
  44. :columns="columns"
  45. :data="loadData"
  46. bordered>
  47. <!-- 产品名称 -->
  48. <template slot="productName" slot-scope="text, record">
  49. {{ record.productName }}
  50. <a-tag color="red" v-if="record.giftFlag==1">赠品</a-tag>
  51. </template>
  52. </s-table>
  53. </a-card>
  54. <div class="btn-cont">
  55. <a-button id="bulkWarehousingOrder-basicInfo-modal-back" @click="isShow = false" style="margin-left: 15px;">返回列表</a-button>
  56. </div>
  57. </a-modal>
  58. </template>
  59. <script>
  60. import { STable, VSelect } from '@/components'
  61. import { getOperationalPrecision } from '@/libs/tools.js'
  62. import { sparePartsDetailList, sparePartsPageCount } from '@/api/spareParts'
  63. export default {
  64. name: 'BulkWarehousingOrderDetailModal',
  65. components: { STable, VSelect },
  66. props: {
  67. openModal: { // 弹框显示状态
  68. type: Boolean,
  69. default: false
  70. },
  71. itemSn: {
  72. type: [Number, String],
  73. default: ''
  74. }
  75. },
  76. data () {
  77. return {
  78. isShow: this.openModal, // 是否打开弹框
  79. // 加载数据方法 必须为 Promise 对象
  80. loadData: parameter => {
  81. return sparePartsDetailList(Object.assign(parameter, { sparePartsSn: this.itemSn })).then(res => {
  82. let data
  83. if (res.status == 200) {
  84. data = res.data
  85. this.getDetailCount(Object.assign(parameter, { sparePartsSn: this.itemSn }))
  86. const no = (data.pageNo - 1) * data.pageSize
  87. for (var i = 0; i < data.list.length; i++) {
  88. data.list[i].no = no + i + 1
  89. // 小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
  90. data.list[i].subtotal = getOperationalPrecision(data.list[i].productCost || 0, data.list[i].productQty)
  91. }
  92. }
  93. return data
  94. })
  95. },
  96. productTotal: null // 合计
  97. }
  98. },
  99. computed: {
  100. columns () {
  101. const arr = [
  102. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  103. { title: '产品编码', dataIndex: 'productCode', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  104. { title: '产品名称', scopedSlots: { customRender: 'productName' }, width: '40%', align: 'center', ellipsis: true },
  105. { title: '单位', dataIndex: 'unit', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  106. { title: '入库数量', dataIndex: 'productQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  107. // { title: '入库单价', dataIndex: 'productCost',width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  108. { title: '小计', dataIndex: 'subtotal', width: '12%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  109. ]
  110. if (this.$hasPermissions('B_isShowCost')) { // 成本价权限
  111. arr.splice(5, 0, { title: '入库单价', dataIndex: 'productCost', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  112. }
  113. return arr
  114. }
  115. },
  116. methods: {
  117. // 返回列表
  118. handleBack () {
  119. this.$router.push({ path: '/purchasingManagement/bulkWarehousingOrder/list', query: { closeLastOldTab: true } })
  120. },
  121. // 合计
  122. getDetailCount (params) {
  123. sparePartsPageCount(params).then(res => {
  124. if (res.status == 200) {
  125. this.productTotal = res.data
  126. } else {
  127. this.productTotal = null
  128. }
  129. })
  130. }
  131. },
  132. watch: {
  133. // 父页面传过来的弹框状态
  134. openModal (newValue, oldValue) {
  135. this.isShow = newValue
  136. },
  137. // 重定义的弹框状态
  138. isShow (newValue, oldValue) {
  139. if (!newValue) {
  140. this.$emit('close')
  141. }
  142. },
  143. itemSn (newValue, oldValue) {
  144. if (this.isShow && newValue) {
  145. const _this = this
  146. setTimeout(() => {
  147. _this.$refs.table.refresh(true)
  148. }, 200)
  149. }
  150. }
  151. }
  152. }
  153. </script>
  154. <style lang="less">
  155. .bulkWarehousingOrder-basicInfo-modal{
  156. .ant-modal-body {
  157. padding: 10px 10px 20px;
  158. }
  159. .btn-cont {
  160. text-align: center;
  161. margin: 5px 0 10px;
  162. }
  163. }
  164. </style>