stockOutDetailModal.vue 6.8 KB

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