list.vue 12 KB

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