list.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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="salesReturnReportList-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="salesReturnReportList-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="salesReturnReportList-refresh">查询</a-button>
  28. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="salesReturnReportList-reset">重置</a-button>
  29. </a-col>
  30. </a-row>
  31. </a-form-model>
  32. <!-- 列表 -->
  33. <s-table
  34. class="sTable"
  35. ref="table"
  36. size="small"
  37. :rowKey="(record) => record.id"
  38. :columns="columns"
  39. :data="loadData"
  40. :defaultLoadData="false"
  41. bordered>
  42. <!-- 操作 -->
  43. <template slot="action" slot-scope="text, record">
  44. <a-button
  45. size="small"
  46. type="link"
  47. class="button-success"
  48. @click="handleDetail(record)"
  49. >详情</a-button>
  50. </template>
  51. </s-table>
  52. </a-spin>
  53. </a-card>
  54. <!-- 详情 -->
  55. <detail-modal :openModal="openDetailModal" ref="detailModal" @close="openDetailModal = false" />
  56. </div>
  57. </template>
  58. <script>
  59. import { commonMixin } from '@/utils/mixin'
  60. import { STable, VSelect } from '@/components'
  61. import rangeDate from '@/views/common/rangeDate.vue'
  62. import { downloadExcel } from '@/libs/JGPrint.js'
  63. import custList from '@/views/common/custList.vue'
  64. import detailModal from './detailModal.vue'
  65. import { reportSalesReturnPageList, reportSalesReturnBillTotal, reportSalesReturnExport } from '@/api/reportData'
  66. export default {
  67. components: { STable, VSelect, rangeDate, custList, detailModal },
  68. mixins: [commonMixin],
  69. data () {
  70. return {
  71. spinning: false,
  72. labelCol: { span: 8 },
  73. wrapperCol: { span: 16 },
  74. advanced: false, // 高级搜索 展开/关闭
  75. tableHeight: 0,
  76. queryParam: { // 查询条件
  77. time: [],
  78. beginDate: '',
  79. endDate: '',
  80. buyerNameCurrent: undefined, // 客户名称
  81. buyerSnCurrent: undefined, // 客户sn
  82. salesReturnNo: ''
  83. },
  84. openDetailModal: true,
  85. rules: {
  86. 'time': [{ required: true, message: '请选择审核时间', trigger: 'change' }]
  87. },
  88. disabled: false, // 查询、重置按钮是否可操作
  89. exportLoading: false,
  90. // 加载数据方法 必须为 Promise 对象
  91. loadData: parameter => {
  92. this.disabled = true
  93. const params = Object.assign(parameter, this.queryParam)
  94. this.spinning = true
  95. delete params.time
  96. return reportSalesReturnPageList(params).then(res => {
  97. let data
  98. if (res.status == 200) {
  99. data = res.data
  100. // 总计
  101. this.getCount(params)
  102. const no = (data.pageNo - 1) * data.pageSize
  103. for (var i = 0; i < data.list.length; i++) {
  104. data.list[i].no = no + i + 1
  105. data.list[i].inStockQty = data.list[i].totalQty
  106. }
  107. this.disabled = false
  108. }
  109. this.spinning = false
  110. return data
  111. })
  112. },
  113. totalData: null // 合计
  114. }
  115. },
  116. computed: {
  117. columns () {
  118. const _this = this
  119. const arr = [
  120. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  121. { title: '创建时间', dataIndex: 'auditTime', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  122. { title: '销售单号', dataIndex: 'salesReturnNo', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  123. { title: '客户名称', dataIndex: 'buyerName', width: '15%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  124. { title: '缺货次数', dataIndex: 'totalCategory', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  125. { title: '缺货数量', dataIndex: 'totalQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  126. { title: '缺货金额', dataIndex: 'totalAmount', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  127. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  128. ]
  129. return arr
  130. }
  131. },
  132. methods: {
  133. // 查看详情
  134. handleDetail (row) {
  135. this.openDetailModal = true
  136. },
  137. // 合计
  138. getCount (params) {
  139. reportSalesReturnBillTotal(params).then(res => {
  140. if (res.status == 200) {
  141. this.totalData = res.data
  142. } else {
  143. this.totalData = null
  144. }
  145. })
  146. },
  147. // 创建时间 change
  148. dateChange (date) {
  149. this.queryParam.time = date
  150. this.queryParam.beginDate = date[0] || ''
  151. this.queryParam.endDate = date[1] || ''
  152. },
  153. // 查询
  154. handleSearch () {
  155. this.$refs.ruleForm.validate(valid => {
  156. if (valid) {
  157. this.$refs.table.refresh(true)
  158. } else {
  159. console.log('error submit!!')
  160. return false
  161. }
  162. })
  163. },
  164. custSatelliteChange (v, row) {
  165. if (row && row.customerSn) {
  166. this.queryParam.buyerSnCurrent = row.customerSn
  167. this.queryParam.buyerNameCurrent = undefined
  168. } else {
  169. this.queryParam.buyerNameCurrent = v
  170. this.queryParam.buyerSnCurrent = undefined
  171. }
  172. },
  173. // 重置
  174. resetSearchForm () {
  175. this.$refs.rangeDate.resetDate()
  176. this.queryParam.time = []
  177. this.queryParam.beginDate = ''
  178. this.queryParam.endDate = ''
  179. this.queryParam.salesReturnNo = ''
  180. this.queryParam.buyerNameCurrent = undefined
  181. this.queryParam.buyerSnCurrent = undefined
  182. this.$refs.custSatelliteList.resetForm()
  183. this.$refs.ruleForm.resetFields()
  184. this.totalData = null
  185. this.$refs.table.clearTable()
  186. },
  187. // 导出
  188. handleExport () {
  189. const _this = this
  190. this.$refs.ruleForm.validate(valid => {
  191. if (valid) {
  192. const params = _this.queryParam
  193. params.showCost = this.$hasPermissions('M_ShowAllCost') ? '1' : '0'
  194. _this.exportLoading = true
  195. _this.spinning = true
  196. reportSalesReturnExport(params).then(res => {
  197. downloadExcel(res, '销售退货报表')
  198. _this.exportLoading = false
  199. _this.spinning = false
  200. })
  201. } else {
  202. console.log('error submit!!')
  203. return false
  204. }
  205. })
  206. },
  207. pageInit () {}
  208. },
  209. mounted () {
  210. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  211. this.pageInit()
  212. this.resetSearchForm()
  213. }
  214. },
  215. activated () {
  216. // 如果是新页签打开,则重置当前页面
  217. if (this.$store.state.app.isNewTab) {
  218. this.pageInit()
  219. this.resetSearchForm()
  220. }
  221. },
  222. beforeRouteEnter (to, from, next) {
  223. next(vm => {})
  224. }
  225. }
  226. </script>