list.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <div class="jg-page-wrap customerReportList-wrap">
  3. <a-card size="small" :bordered="false" class="table-page-search-wrapper">
  4. <!-- 搜索条件 -->
  5. <a-form-model
  6. id="salesOutofStockReport-form"
  7. ref="ruleForm"
  8. class="form-model-con"
  9. layout="inline"
  10. :model="queryParam"
  11. :rules="rules"
  12. :labelCol="labelCol"
  13. :wrapperCol="wrapperCol"
  14. @keyup.enter.native="handleSearch" >
  15. <a-row :gutter="15">
  16. <a-col :md="6" :sm="24">
  17. <a-form-model-item label="创建时间" prop="time">
  18. <rangeDate ref="rangeDate" @change="dateChange" />
  19. </a-form-model-item>
  20. </a-col>
  21. <a-col :md="6" :sm="24">
  22. <a-form-model-item label="客户名称">
  23. <custList id="salesOutofStockReport-buyerName" ref="custSatelliteList" @change="custSatelliteChange"></custList>
  24. </a-form-model-item>
  25. </a-col>
  26. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  27. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="salesOutofStockReport-refresh">查询</a-button>
  28. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="salesOutofStockReport-reset">重置</a-button>
  29. <a-button
  30. style="margin-left: 5px"
  31. type="primary"
  32. class="button-warning"
  33. @click="handleExport"
  34. :disabled="disabled"
  35. :loading="exportLoading"
  36. v-if="$hasPermissions('B_isSalesOosExport')"
  37. id="salesOutofStockReport-export">导出</a-button>
  38. </a-col>
  39. </a-row>
  40. </a-form-model>
  41. <!-- 列表 -->
  42. <s-table
  43. class="sTable"
  44. ref="table"
  45. size="small"
  46. :rowKey="(record) => record.id"
  47. :columns="columns"
  48. :data="loadData"
  49. :defaultLoadData="false"
  50. bordered>
  51. <!-- 操作 -->
  52. <template slot="action" slot-scope="text, record">
  53. <a-button
  54. size="small"
  55. type="link"
  56. class="button-success"
  57. v-if="$hasPermissions('B_isSalesOosDetail')"
  58. @click="handleDetail(record)"
  59. >详情</a-button>
  60. <span v-else>--</span>
  61. </template>
  62. </s-table>
  63. </a-spin>
  64. </a-card>
  65. <!-- 详情 -->
  66. <detail-modal :openModal="openDetailModal" ref="detailModal" @close="openDetailModal = false" />
  67. </div>
  68. </template>
  69. <script>
  70. import { commonMixin } from '@/utils/mixin'
  71. import { STable, VSelect } from '@/components'
  72. import rangeDate from '@/views/common/rangeDate.vue'
  73. import { downloadExcel } from '@/libs/JGPrint.js'
  74. import custList from '@/views/common/custList.vue'
  75. import detailModal from './detailModal.vue'
  76. import { salesOosQueryList, salesOosExport } from '@/api/reportData'
  77. export default {
  78. components: { STable, VSelect, rangeDate, custList, detailModal },
  79. mixins: [commonMixin],
  80. data () {
  81. return {
  82. spinning: false,
  83. labelCol: { span: 8 },
  84. wrapperCol: { span: 16 },
  85. queryParam: { // 查询条件
  86. time: [],
  87. beginDate: '',
  88. endDate: '',
  89. targetName: undefined, // 客户名称
  90. targetSn: undefined // 客户sn
  91. },
  92. openDetailModal: false, // 详情弹窗
  93. disabled: false, // 查询、重置按钮是否可操作
  94. exportLoading: false,
  95. // 加载数据方法 必须为 Promise 对象
  96. loadData: parameter => {
  97. this.disabled = true
  98. const params = Object.assign(parameter, this.queryParam)
  99. this.spinning = true
  100. delete params.time
  101. return salesOosQueryList(params).then(res => {
  102. let data
  103. if (res.status == 200) {
  104. data = res.data
  105. const no = (data.pageNo - 1) * data.pageSize
  106. for (var i = 0; i < data.list.length; i++) {
  107. data.list[i].no = no + i + 1
  108. }
  109. this.disabled = false
  110. }
  111. this.spinning = false
  112. return data
  113. })
  114. },
  115. rules: {
  116. 'time': [{ required: true, message: '请选择审核时间', trigger: 'change' }]
  117. }
  118. }
  119. },
  120. computed: {
  121. columns () {
  122. const _this = this
  123. const arr = [
  124. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  125. { title: '创建时间', dataIndex: 'createDate', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  126. { title: '销售单号', dataIndex: 'salesBillNo', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  127. { title: '客户名称', dataIndex: 'targetName', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  128. { title: '缺货款数', dataIndex: 'totalCategory', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  129. { title: '缺货数量', dataIndex: 'totalQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  130. { title: '缺货金额', dataIndex: 'totalAmount', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  131. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  132. ]
  133. return arr
  134. }
  135. },
  136. methods: {
  137. // 查询
  138. handleSearch () {
  139. this.$refs.ruleForm.validate(valid => {
  140. if (valid) {
  141. this.$refs.table.refresh(true)
  142. } else {
  143. this.$message.info('请选择创建时间')
  144. return false
  145. }
  146. })
  147. },
  148. // 查看详情
  149. handleDetail (row) {
  150. this.openDetailModal = true
  151. const _this = this
  152. this.$nextTick(() => {
  153. _this.$refs.detailModal.getDetail(row)
  154. })
  155. },
  156. // 创建时间 change
  157. dateChange (date) {
  158. this.queryParam.time = date
  159. this.queryParam.beginDate = date[0] || ''
  160. this.queryParam.endDate = date[1] || ''
  161. },
  162. custSatelliteChange (v, row) {
  163. if (row && row.customerSn) {
  164. this.queryParam.targetSn = row.dealerSn
  165. this.queryParam.targetName = row.customerName
  166. } else {
  167. this.queryParam.targetName = v
  168. this.queryParam.targetSn = undefined
  169. }
  170. },
  171. // 重置
  172. resetSearchForm () {
  173. this.$refs.rangeDate.resetDate()
  174. this.queryParam.time = []
  175. this.queryParam.beginDate = ''
  176. this.queryParam.endDate = ''
  177. this.queryParam.targetName = undefined
  178. this.queryParam.targetSn = undefined
  179. this.$refs.ruleForm.resetFields()
  180. this.$refs.custSatelliteList.resetForm()
  181. this.$refs.table.clearTable()
  182. },
  183. // 导出
  184. handleExport () {
  185. const _this = this
  186. this.$refs.ruleForm.validate(valid => {
  187. if (valid) {
  188. const params = _this.queryParam
  189. _this.exportLoading = true
  190. _this.spinning = true
  191. salesOosExport(params).then(res => {
  192. downloadExcel(res, '销售缺货报表')
  193. _this.exportLoading = false
  194. _this.spinning = false
  195. })
  196. } else {
  197. this.$message.info('请选择创建时间')
  198. return false
  199. }
  200. })
  201. },
  202. beforeRouteEnter (to, from, next) {
  203. next(vm => {})
  204. }
  205. }
  206. }
  207. </script>