list.vue 11 KB

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