stockOutDetailModal.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <a-modal
  3. centered
  4. :footer="null"
  5. :maskClosable="false"
  6. title="销售单缺货明细"
  7. v-model="isShow"
  8. @cancel="isShow=false"
  9. width="70%">
  10. <a-descriptions size="small" :column="2">
  11. <a-descriptions-item label="销售单号">
  12. {{ detailData&&detailData.salesBillNo || '--' }}
  13. <span v-if="detailData&&detailData.salesBillNoSource">(原:{{ detailData&&detailData.salesBillNoSource || '--' }})</span>
  14. </a-descriptions-item>
  15. <a-descriptions-item label="客户名称">{{ detailData&&detailData.buyerName || '--' }}</a-descriptions-item>
  16. </a-descriptions>
  17. <a-spin :spinning="spinning" tip="Loading...">
  18. <s-table
  19. class="sTable fixPagination"
  20. ref="table"
  21. size="small"
  22. :rowKey="(record) => record.no"
  23. rowKeyName="no"
  24. :columns="columns"
  25. :data="loadData"
  26. :scroll="{ y: 500 }"
  27. :showPagination="false"
  28. :defaultLoadData="false"
  29. bordered>
  30. <template slot="productCode" slot-scope="text, record">
  31. <span style="padding-right: 15px;">{{ text }}</span>
  32. <a-badge count="促" v-if="record.promotionFlag=='GIFT'" :number-style="{ backgroundColor: '#52c41a', zoom:'80%' }"></a-badge>
  33. <a-badge count="特" v-if="record.promotionFlag=='DISCOUNT'" :number-style="{ backgroundColor: '#faad14', zoom:'80%' }"></a-badge>
  34. </template>
  35. <!-- 销售价 -->
  36. <template slot="price" slot-scope="text, record">
  37. {{ toThousands(text) }}
  38. <span v-if="record.promotionFlag=='GIFT'||record.promotionFlag=='DISCOUNT'" title="原价">({{ toThousands(record.origPrice) }})</span>
  39. </template>
  40. </s-table>
  41. <div class="btn-cont" style="padding:20px 20px 0;text-align: center;">
  42. <a-button
  43. class="button-warning"
  44. type="primary"
  45. @click="handleExport"
  46. :disabled="disabled"
  47. :loading="exportLoading"
  48. id="allocateBillList-export">导出Excel</a-button>
  49. <a-button
  50. style="margin-left: 10px"
  51. class="button-warning"
  52. type="primary"
  53. @click="handleClassifyExport"
  54. :disabled="disabled"
  55. :loading="exportClassifyLoading"
  56. id="allocateBillList-export">分类导出Excel</a-button>
  57. <a-button style="margin-left: 10px" @click="isShow=false">关闭</a-button>
  58. </div>
  59. </a-spin>
  60. </a-modal>
  61. </template>
  62. <script>
  63. import { STable } from '@/components'
  64. import { commonMixin } from '@/utils/mixin'
  65. import { salesStockoutDetail, exportStockout, exportGroupStockout } from '@/api/salesDetailNew'
  66. import { hdExportExcel } from '@/libs/exportExcel'
  67. export default {
  68. name: 'StockOutDetail',
  69. mixins: [commonMixin],
  70. components: { STable },
  71. props: {
  72. openModal: {
  73. type: Boolean,
  74. default: false
  75. },
  76. salesBillSn: {
  77. type: [Number, String],
  78. default: ''
  79. },
  80. detailData: {
  81. type: Object,
  82. default: function () {
  83. return null
  84. }
  85. }
  86. },
  87. data () {
  88. const _this = this
  89. return {
  90. spinning: false,
  91. isShow: this.openModal,
  92. disabled: false,
  93. exportLoading: false,
  94. exportClassifyLoading: false,
  95. // 加载数据方法 必须为 Promise 对象
  96. loadData: parameter => {
  97. this.spinning = true
  98. this.disabled = true
  99. delete parameter.tableId
  100. delete parameter.index
  101. return salesStockoutDetail({ salesBillSn: this.salesBillSn }).then(res => {
  102. let data
  103. if (res.status == 200) {
  104. data = res.data
  105. const no = 0
  106. for (var i = 0; i < data.length; i++) {
  107. data[i].no = no + i + 1
  108. }
  109. this.disabled = false
  110. }
  111. this.spinning = false
  112. return data
  113. })
  114. }
  115. }
  116. },
  117. computed:{
  118. columns () {
  119. const _this = this
  120. const arr = [
  121. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  122. { title: '产品编码', dataIndex: 'productCode', width: '15%', align: 'center', scopedSlots: { customRender: 'productCode' } },
  123. { title: '产品名称', dataIndex: 'product.name', width: '25%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  124. { title: '原厂编码', dataIndex: 'product.origCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  125. { title: '单位', dataIndex: 'product.unit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  126. { title: '销售数量', dataIndex: 'salesQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  127. { title: '缺货数量', dataIndex: 'qty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  128. ]
  129. if (this.$hasPermissions('B_salesDetail_salesPrice')) { // 售价权限
  130. arr.splice(6, 0, { title: '销售价', dataIndex: 'price', width: '8%', align: 'right', scopedSlots: { customRender: 'price' } })
  131. arr.splice(7, 0, { title: '销售金额', dataIndex: 'salesAmount', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  132. arr.splice(8, 0, { title: '缺货金额', dataIndex: 'totalAmount', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  133. }
  134. return arr
  135. }
  136. },
  137. methods: {
  138. handleExport () {
  139. const _this = this
  140. _this.exportLoading = true
  141. _this.disabled = true
  142. _this.spinning = true
  143. hdExportExcel(exportStockout, { salesBillSn: _this.salesBillSn }, '销售单缺货产品导出', function () {
  144. _this.exportLoading = false
  145. _this.spinning = false
  146. _this.disabled = false
  147. })
  148. },
  149. handleClassifyExport () {
  150. const _this = this
  151. _this.exportClassifyLoading = true
  152. _this.disabled = true
  153. _this.spinning = true
  154. hdExportExcel(exportGroupStockout, { salesBillSn: _this.salesBillSn }, '销售单缺货产品分类导出', function () {
  155. _this.exportClassifyLoading = false
  156. _this.spinning = false
  157. _this.disabled = false
  158. })
  159. }
  160. },
  161. watch: {
  162. openModal (nVal, oVal) {
  163. this.isShow = nVal
  164. },
  165. isShow (nVal, oVal) {
  166. if (!nVal) {
  167. this.$emit('close')
  168. this.$refs.table.clearTable()
  169. } else {
  170. this.$nextTick(() => {
  171. this.$refs.table.refresh()
  172. })
  173. }
  174. }
  175. }
  176. }
  177. </script>
  178. <style>
  179. </style>