list.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <a-card size="small">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <div class="table-page-search-wrapper newTableSearchName">
  5. <a-form-model
  6. id="billingOrderReport-form"
  7. ref="ruleForm"
  8. class="form-model-con"
  9. layout="inline"
  10. :rules="rules"
  11. :model="queryParam"
  12. @keyup.enter.native="handleSearch">
  13. <a-row :gutter="15">
  14. <a-col :md="6" :sm="24">
  15. <a-form-model-item label="退货完成时间" prop="time">
  16. <rangeDate ref="rangeDate" :value="queryParam.time" @change="dateChange"/>
  17. </a-form-model-item>
  18. </a-col>
  19. <a-col :md="6" :sm="24">
  20. <a-form-model-item label="供应商名称">
  21. <supplier id="billingBackReport-supplierName" v-model="queryParam.supplier.supplierSn" @change="getSupplierName" placeholder="请输入供应商名称"></supplier>
  22. </a-form-model-item>
  23. </a-col>
  24. <a-col :md="6" :sm="24">
  25. <a-form-model-item label="采购退货单号" >
  26. <a-input id="billingBackReport-sparePartsReturnNo" v-model.trim="queryParam.sparePartsReturnNo" allowClear placeholder="请输入采购退货单号"/>
  27. </a-form-model-item>
  28. </a-col>
  29. <a-col :md="6" :sm="24">
  30. <a-form-model-item label="地区">
  31. <AreaList id="returnSlipReportList-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
  32. </a-form-model-item>
  33. </a-col>
  34. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  35. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="billingOrderReport-refresh">查询</a-button>
  36. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="billingOrderReport-reset">重置</a-button>
  37. <a-button
  38. style="margin-left: 5px"
  39. type="primary"
  40. class="button-warning"
  41. @click="handleExport"
  42. :disabled="disabled"
  43. :loading="exportLoading"
  44. v-if="$hasPermissions('B_regionTypeSalesReportExport')"
  45. id="billingOrderReport-export">导出</a-button>
  46. </a-col>
  47. </a-row>
  48. </a-form-model>
  49. </div>
  50. <!-- 列表 -->
  51. <s-table
  52. class="sTable"
  53. ref="table"
  54. size="small"
  55. :defaultLoadData="false"
  56. :rowKey="(record) => record.no"
  57. rowKeyName="no"
  58. :columns="columns"
  59. :data="loadData"
  60. :scroll="{ x: 1550 }"
  61. bordered>
  62. <template slot="footer" v-if="countLabel.length||countBrandLabel.length">
  63. <a-row>
  64. <a-col span="2">合计:</a-col>
  65. <a-col span="22">
  66. <a-row>
  67. <a-col span="4" v-for="item in countLabel" :key="item.key">
  68. {{ item.title }}:{{ totalData?(totalData[item.dataIndex]||totalData[item.dataIndex]==0)?toThousands(totalData[item.dataIndex]):'--':'--' }}
  69. </a-col>
  70. </a-row>
  71. <a-row>
  72. <a-col span="24" style="padding:8px;"></a-col>
  73. </a-row>
  74. <a-row>
  75. <a-col span="4" v-for="item in countBrandLabel" :key="item.key">
  76. {{ item.title }}:{{ totalData?(totalData[item.dataIndex] ||totalData[item.dataIndex]==0)?toThousands(totalData[item.dataIndex]):'--':'--' }}
  77. </a-col>
  78. </a-row>
  79. </a-col>
  80. </a-row>
  81. </template>
  82. </s-table>
  83. </a-spin>
  84. <!-- 导出提示框 -->
  85. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  86. </a-card>
  87. </template>
  88. <script>
  89. import { commonMixin } from '@/utils/mixin'
  90. import { STable, VSelect } from '@/components'
  91. import getDate from '@/libs/getDate.js'
  92. import rangeDate from '@/views/common/rangeDate.vue'
  93. import AreaList from '@/views/common/areaList.js'
  94. import { hdExportExcel } from '@/libs/exportExcel'
  95. import reportModal from '@/views/common/reportModal.vue'
  96. import supplier from '@/views/common/supplier.js'
  97. import { queryBillNoPage, queryBillNoCount, queryBillNoTitle, billNoExport } from '@/api/reportData.js'
  98. export default {
  99. name: 'BillingOrderReportList',
  100. mixins: [commonMixin],
  101. components: { STable, VSelect, rangeDate, reportModal, AreaList, supplier },
  102. data () {
  103. return {
  104. spinning: false,
  105. showExport: false, // 导出弹窗
  106. queryParam: {
  107. time: [
  108. getDate.getCurrMonthDays().starttime,
  109. getDate.getCurrMonthDays().endtime
  110. ],
  111. beginDate: getDate.getCurrMonthDays().starttime,
  112. endDate: getDate.getCurrMonthDays().endtime,
  113. sparePartsReturnNo: undefined,
  114. supplier: {
  115. supplierSn: undefined,
  116. supplierName: undefined,
  117. provinceSn: undefined,
  118. citySn: undefined,
  119. districtSn: undefined
  120. }
  121. },
  122. countLabel: [],
  123. countBrandLabel: [],
  124. columns: [],
  125. totalData: null,
  126. disabled: false, // 查询、重置按钮是否可操作
  127. exportLoading: false,
  128. rules: {
  129. 'time': [{ required: true, message: '请选择退货完成时间', trigger: 'change' }]
  130. },
  131. // 加载数据方法 必须为 Promise 对象
  132. loadData: parameter => {
  133. this.disabled = true
  134. this.spinning = true
  135. const params = Object.assign(parameter, this.queryParam)
  136. delete params.time
  137. return queryBillNoPage(params).then(res => {
  138. let data
  139. if (res.status == 200) {
  140. data = res.data
  141. this.getCount(params)
  142. const no = (data.pageNo - 1) * data.pageSize
  143. for (var i = 0; i < data.list.length; i++) {
  144. data.list[i].no = no + i + 1
  145. }
  146. this.disabled = false
  147. }
  148. this.spinning = false
  149. return data
  150. })
  151. }
  152. }
  153. },
  154. methods: {
  155. // 选择供应商
  156. getSupplierName (val, item) {
  157. this.queryParam.supplier.supplierName = item ? item.supplierName : undefined
  158. this.queryParam.supplier.supplierSn = val
  159. },
  160. // 总计
  161. getCount (params) {
  162. queryBillNoCount(params).then(res => {
  163. if (res.status == 200 && res.data) {
  164. this.totalData = res.data
  165. } else {
  166. this.totalData = null
  167. }
  168. })
  169. },
  170. // 退货完成时间 change
  171. dateChange (date) {
  172. if (date[0] && date[1]) {
  173. this.queryParam.time = date
  174. } else {
  175. this.queryParam.time = []
  176. }
  177. this.queryParam.beginDate = date[0] || ''
  178. this.queryParam.endDate = date[1] || ''
  179. },
  180. // 查询
  181. handleSearch () {
  182. const _this = this
  183. this.$refs.ruleForm.validate(valid => {
  184. if (valid) {
  185. _this.$refs.table.refresh(true)
  186. } else {
  187. _this.$message.error('请选择退货完成时间')
  188. return false
  189. }
  190. })
  191. },
  192. // 重置
  193. resetSearchForm () {
  194. this.$refs.ruleForm.resetFields()
  195. this.queryParam.time = [
  196. getDate.getCurrMonthDays().starttime,
  197. getDate.getCurrMonthDays().endtime
  198. ]
  199. this.$refs.rangeDate.resetDate(this.queryParam.time)
  200. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  201. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  202. this.queryParam.supplier.provinceSn = undefined
  203. this.queryParam.supplier.citySn = undefined
  204. this.queryParam.supplier.districtSn = undefined
  205. this.queryParam.sparePartsReturnNo = undefined
  206. this.queryParam.supplier.supplierName = undefined
  207. this.queryParam.supplier.supplierSn = undefined
  208. this.$refs.areaList.clearData()
  209. this.$refs.table.clearTable()
  210. },
  211. areaChange (val) {
  212. this.queryParam.supplier.provinceSn = val[0] ? val[0] : ''
  213. this.queryParam.supplier.citySn = val[1] ? val[1] : ''
  214. this.queryParam.supplier.districtSn = val[2] ? val[2] : ''
  215. },
  216. // 导出
  217. handleExport () {
  218. const _this = this
  219. this.$refs.ruleForm.validate(valid => {
  220. if (valid) {
  221. const params = _this.queryParam
  222. _this.$store.state.app.curActionPermission = 'B_billingReturn_Report'
  223. _this.showExport = true
  224. _this.exportLoading = true
  225. _this.spinning = true
  226. hdExportExcel(billNoExport, params, '开单采退单', function () {
  227. _this.exportLoading = false
  228. _this.spinning = false
  229. _this.$store.state.app.curActionPermission = ''
  230. })
  231. } else {
  232. _this.$message.error('请选择退货完成时间')
  233. return false
  234. }
  235. })
  236. },
  237. // 获取表头
  238. async getTableTitle () {
  239. const _this = this
  240. const tableTitle = await queryBillNoTitle().then(res => res.data)
  241. this.columns = tableTitle.list
  242. this.countLabel = tableTitle.count.filter(item => item.title.indexOf('品牌') < 0)
  243. this.countBrandLabel = tableTitle.count.filter(item => item.title.indexOf('品牌') >= 0)
  244. this.columns.map(item => {
  245. let mw = 40
  246. if (item.customRender == 'amount') {
  247. mw = 15
  248. item.customRender = function (text) { return (text || text == 0) ? _this.toThousands(text) : '--' }
  249. }
  250. const w = item.title.length * mw
  251. const tw = w <= 80 && item.customRender != 'amount' ? w * 2 : (w >= 360 ? 200 : w)
  252. item.width = tw + 'px'
  253. this.tableWidth = this.tableWidth + tw
  254. })
  255. this.resetSearchForm()
  256. },
  257. pageInit () {
  258. this.getTableTitle()
  259. }
  260. },
  261. mounted () {
  262. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  263. this.pageInit()
  264. }
  265. },
  266. activated () {
  267. // 如果是新页签打开,则重置当前页面
  268. if (this.$store.state.app.isNewTab) {
  269. this.pageInit()
  270. }
  271. },
  272. beforeRouteEnter (to, from, next) {
  273. next(vm => {})
  274. }
  275. }
  276. </script>