list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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. <BizUser 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. <!-- 列表 -->
  79. <s-table
  80. class="sTable"
  81. ref="table"
  82. size="small"
  83. :defaultLoadData="false"
  84. :rowKey="(record) => record.no"
  85. rowKeyName="no"
  86. :columns="columns"
  87. :data="loadData"
  88. :scroll="{ x: 2370 }"
  89. bordered>
  90. <template slot="footer" v-if="countLabel.length||countBrandLabel.length">
  91. <a-row>
  92. <a-col span="2">合计:</a-col>
  93. <a-col span="22">
  94. <a-row>
  95. <a-col span="4" v-for="item in countLabel" :key="item.key">
  96. {{ item.title }}:{{ totalData?(totalData[item.dataIndex]||totalData[item.dataIndex]==0)?toThousands(totalData[item.dataIndex]):'--':'--' }}
  97. </a-col>
  98. </a-row>
  99. <a-row>
  100. <a-col span="24" style="padding:8px;"></a-col>
  101. </a-row>
  102. <a-row>
  103. <a-col span="4" v-for="item in countBrandLabel" :key="item.key">
  104. {{ item.title }}:{{ totalData?(totalData[item.dataIndex] ||totalData[item.dataIndex]==0)?toThousands(totalData[item.dataIndex]):'--':'--' }}
  105. </a-col>
  106. </a-row>
  107. </a-col>
  108. </a-row>
  109. </template>
  110. </s-table>
  111. </a-spin>
  112. <!-- 导出提示框 -->
  113. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  114. </a-card>
  115. </template>
  116. <script>
  117. import { commonMixin } from '@/utils/mixin'
  118. import { STable, VSelect } from '@/components'
  119. import rangeDate from '@/views/common/rangeDate.vue'
  120. import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
  121. import subarea from '@/views/common/subarea.js'
  122. import reportModal from '@/views/common/reportModal.vue'
  123. import AreaList from '@/views/common/areaList.js'
  124. import BizUser from '@/views/common/bizUser.js'
  125. import { hdExportExcel } from '@/libs/exportExcel'
  126. import { salesXsjdReportTitle, reportDispatchReportList, reportDispatchReportCount, reportDispatchReportExport } from '@/api/reportData'
  127. export default {
  128. name: 'SalesPresentationList',
  129. mixins: [commonMixin],
  130. components: { STable, VSelect, rangeDate, subarea, AreaList, dealerSubareaScopeList, reportModal, BizUser },
  131. data () {
  132. return {
  133. spinning: false,
  134. advanced: true, // 高级搜索 展开/关闭
  135. showExport: false,
  136. queryParam: { // 查询条件
  137. time: [],
  138. beginDate: '',
  139. endDate: '',
  140. salesBillNo: '',
  141. 'subareaArea':{
  142. 'subareaSn': undefined,
  143. 'subareaAreaSn': undefined,
  144. 'bizUserSn': undefined
  145. },
  146. dealer: {
  147. 'dealerSn': undefined,
  148. 'provinceSn': undefined,
  149. 'citySn': undefined,
  150. 'districtSn': undefined,
  151. 'dealerLevel': undefined
  152. }
  153. },
  154. columns: [],
  155. countLabel: [],
  156. countBrandLabel:[],
  157. rules: {
  158. 'time': [{ required: true, message: '请选择备货销售日期', trigger: 'change' }]
  159. },
  160. disabled: false, // 查询、重置按钮是否可操作
  161. exportLoading: false,
  162. // 加载数据方法 必须为 Promise 对象
  163. loadData: parameter => {
  164. this.disabled = true
  165. this.spinning = true
  166. const paramsPage = Object.assign(this.queryParam, { pageNo: parameter.pageNo, pageSize: parameter.pageSize }) // 有分页
  167. return reportDispatchReportList(paramsPage).then(res => {
  168. let data
  169. if (res.status == 200) {
  170. data = res.data
  171. this.getCount(paramsPage)
  172. const no = (data.pageNo - 1) * data.pageSize
  173. for (var i = 0; i < data.list.length; i++) {
  174. data.list[i].no = no + i + 1
  175. }
  176. this.disabled = false
  177. }
  178. this.spinning = false
  179. return data
  180. })
  181. },
  182. totalData: null
  183. }
  184. },
  185. methods: {
  186. // 导出
  187. handleExport () {
  188. const _this = this
  189. this.$refs.ruleForm.validate(valid => {
  190. if (valid) {
  191. const params = _this.queryParam
  192. delete params.time
  193. _this.$store.state.app.curActionPermission = 'B_salesPresentationExport'
  194. _this.showExport = true
  195. _this.exportLoading = true
  196. _this.spinning = true
  197. hdExportExcel(reportDispatchReportExport, params, '销售交单报表', function () {
  198. _this.exportLoading = false
  199. _this.spinning = false
  200. _this.$store.state.app.curActionPermission = ''
  201. })
  202. } else {
  203. return false
  204. }
  205. })
  206. },
  207. // 总计
  208. getCount (params) {
  209. reportDispatchReportCount(params).then(res => {
  210. if (res.status == 200 && res.data) {
  211. this.totalData = res.data
  212. } else {
  213. this.totalData = null
  214. }
  215. })
  216. },
  217. handleSearch () {
  218. const _this = this
  219. this.$refs.ruleForm.validate(valid => {
  220. if (valid) {
  221. _this.$refs.table.refresh(true)
  222. } else {
  223. _this.$message.error('请选择备货销售日期')
  224. return false
  225. }
  226. })
  227. },
  228. // 创建时间 change
  229. dateChange (date) {
  230. if (date[0] && date[1]) {
  231. this.queryParam.time = date
  232. } else {
  233. this.queryParam.time = []
  234. }
  235. this.queryParam.beginDate = date[0] || ''
  236. this.queryParam.endDate = date[1] || ''
  237. },
  238. custChange (val) {
  239. this.queryParam.dealer.dealerSn = val.key
  240. },
  241. subareaChange(val){
  242. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : undefined
  243. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : undefined
  244. },
  245. // 重置
  246. resetSearchForm () {
  247. this.queryParam.time = []
  248. this.$refs.rangeDate.resetDate(this.queryParam.time)
  249. this.queryParam.beginDate = ''
  250. this.queryParam.endDate = ''
  251. this.queryParam.salesBillNo = ''
  252. this.queryParam.subareaArea = {
  253. 'subareaSn': undefined,
  254. 'subareaAreaSn': undefined,
  255. 'bizUserSn': undefined
  256. }
  257. this.queryParam.dealer = {
  258. 'dealerSn': undefined,
  259. 'provinceSn': undefined,
  260. 'citySn': undefined,
  261. 'districtSn': undefined,
  262. 'dealerLevel': undefined
  263. }
  264. this.totalData = null
  265. if (this.advanced) {
  266. this.$refs.subarea.clearData()
  267. this.$refs.areaList.clearData()
  268. }
  269. this.$refs.custList.resetForm()
  270. this.$refs.ruleForm.resetFields()
  271. this.$refs.table.clearTable()
  272. },
  273. areaChange (val) {
  274. this.queryParam.dealer.provinceSn = val[0] ? val[0] : ''
  275. this.queryParam.dealer.citySn = val[1] ? val[1] : ''
  276. this.queryParam.dealer.districtSn = val[2] ? val[2] : ''
  277. },
  278. // 获取表头
  279. async getTableTitle () {
  280. const _this = this
  281. const tableTitle = await salesXsjdReportTitle().then(res => res.data)
  282. this.columns = tableTitle.list
  283. this.countLabel = tableTitle.count.filter(item => item.title.indexOf('品牌')<0)
  284. this.countBrandLabel = tableTitle.count.filter(item => item.title.indexOf('品牌')>=0)
  285. this.columns.map(item => {
  286. let mw = 20
  287. if (item.customRender == 'amount') {
  288. mw = 15
  289. item.customRender = function (text) { return (text || text == 0) ? _this.toThousands(text) : '--' }
  290. }
  291. const w = item.title.length * mw
  292. const tw = w <= 80 && item.customRender != 'amount' ? w * 2 : (w >= 360 ? 200 : w)
  293. item.width = tw + 'px'
  294. this.tableWidth = this.tableWidth + tw
  295. })
  296. this.resetSearchForm()
  297. }
  298. },
  299. mounted () {
  300. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  301. this.getTableTitle()
  302. }
  303. },
  304. activated () {
  305. // 如果是新页签打开,则重置当前页面
  306. if (this.$store.state.app.isNewTab) {
  307. this.getTableTitle()
  308. }
  309. },
  310. beforeRouteEnter (to, from, next) {
  311. next(vm => {})
  312. }
  313. }
  314. </script>