list.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="tireSalesDealerList-wrap searchBoxNormal">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper" ref="tableSearch">
  6. <a-form-model
  7. id="tireSalesDealerList-form"
  8. ref="ruleForm"
  9. class="form-model-con"
  10. layout="inline"
  11. :rules="rules"
  12. :model="queryParam">
  13. <a-row :gutter="15">
  14. <a-col :md="6" :sm="24">
  15. <a-form-model-item label="日期" prop="time">
  16. <rangeDate ref="rangeDate" :showTime="false" :today="false" :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. <AreaList id="tireSalesDealerList-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
  22. </a-form-model-item>
  23. </a-col>
  24. <a-col :md="6" :sm="24">
  25. <a-form-item label="区域/分区">
  26. <subarea id="tireSalesDealerList-subarea" ref="subarea" @change="subareaChange"></subarea>
  27. </a-form-item>
  28. </a-col>
  29. <template v-if="advanced">
  30. <a-col :md="6" :sm="24">
  31. <a-form-model-item label="客户名称">
  32. <dealerSubareaScopeList ref="dealerSubareaScopeList" id="tireSalesDealerList-dealerName" @change="custChange" />
  33. </a-form-model-item>
  34. </a-col>
  35. <a-col :md="6" :sm="24">
  36. <a-form-model-item label="客户级别">
  37. <v-select
  38. v-model="queryParam.dealerLevel"
  39. ref="dealerLevel"
  40. id="tireSalesDealerList-dealerLevel"
  41. code="DEALER_LEVEL"
  42. placeholder="请选择客户级别"
  43. allowClear></v-select>
  44. </a-form-model-item>
  45. </a-col>
  46. <a-col :md="6" :sm="24">
  47. <a-form-model-item label="区域负责人">
  48. <BizUser v-model="queryParam.subareaArea.bizUserSn"></BizUser>
  49. </a-form-model-item>
  50. </a-col>
  51. </template>
  52. <a-col :md="6" :sm="24">
  53. <a-button
  54. style="margin-left: 5px"
  55. type="primary"
  56. @click="handleSearch"
  57. :disabled="disabled"
  58. id="tireSalesDealerList-refresh">查询</a-button>
  59. <a-button
  60. style="margin-left: 8px"
  61. @click="resetSearchForm"
  62. :disabled="disabled"
  63. id="tireSalesDealerList-reset">重置</a-button>
  64. <a-button
  65. style="margin-left: 10px"
  66. type="primary"
  67. class="button-warning"
  68. @click="handleExport"
  69. :disabled="disabled"
  70. :loading="exportLoading"
  71. v-if="$hasPermissions('B_tireReportExport')"
  72. id="tireSalesDealerList-export">导出</a-button>
  73. <a @click="advanced=!advanced" style="margin-left: 5px">
  74. {{ advanced ? '收起' : '展开' }}
  75. <a-icon :type="advanced ? 'up' : 'down'" />
  76. </a>
  77. </a-col>
  78. </a-row>
  79. </a-form-model>
  80. </div>
  81. </a-card>
  82. <a-card size="small" :bordered="false">
  83. <a-spin :spinning="spinning" tip="Loading...">
  84. <!-- 列表 -->
  85. <s-table
  86. class="sTable fixPagination"
  87. ref="table"
  88. size="small"
  89. :rowKey="(record) => record.no"
  90. :style="{ height: tableHeight+70+'px' }"
  91. rowKeyName="no"
  92. :columns="columns"
  93. :data="loadData"
  94. :scroll="{x:2200, y: tableHeight-110 }"
  95. :defaultLoadData="false"
  96. bordered>
  97. <template slot="addressInfo" slot-scope="text, record">
  98. {{ record.dealerEntity.provinceName }}{{ '/'+record.dealerEntity.cityName }}{{ '/'+record.dealerEntity.districtName }}
  99. </template>
  100. <template slot="footer">
  101. <a-row :gutter="15">
  102. <a-col :md="4" :sm="24">总部订货数量:{{ (totalData && (totalData.sysOrderQty || totalData.sysOrderQty==0)) ? totalData.sysOrderQty : '--' }}</a-col>
  103. <a-col :md="4" :sm="24" v-if="$hasPermissions('M_tireSalesReportList_salesPrice')">总部订货金额:{{ (totalData && (totalData.sysOrderAmount || totalData.sysOrderAmount==0)) ? toThousands(totalData.sysOrderAmount): '--' }}</a-col>
  104. <a-col :md="4" :sm="24">上级订货数量:{{ (totalData && (totalData.upOrderQty || totalData.upOrderQty==0)) ?totalData.upOrderQty: '--' }}</a-col>
  105. <a-col :md="4" :sm="24" v-if="$hasPermissions('M_tireSalesReportList_salesPrice')">上级订货金额:{{ (totalData && (totalData.upOrderAmount || totalData.upOrderAmount==0)) ? toThousands(totalData.upOrderAmount): '--' }}</a-col>
  106. <a-col :md="4" :sm="24">跨地区订货数量:{{ (totalData && (totalData.crossRegionQty || totalData.crossRegionQty==0)) ?totalData.crossRegionQty: '--' }}</a-col>
  107. <a-col :md="4" :sm="24" v-if="$hasPermissions('M_tireSalesReportList_salesPrice')">跨地区订货金额:{{ (totalData && (totalData.crossRegionAmount || totalData.crossRegionAmount==0)) ? toThousands(totalData.crossRegionAmount): '--' }}</a-col>
  108. <a-col :md="4" :sm="24">累计入库数量:{{ (totalData && (totalData.putQty || totalData.putQty==0)) ?totalData.putQty: '--' }}</a-col>
  109. <a-col :md="4" :sm="24" v-if="$hasPermissions('M_tireSalesReportList_salesPrice')">累计入库金额:{{ (totalData && (totalData.putAmount || totalData.putAmount==0)) ? toThousands(totalData.putAmount): '--' }}</a-col>
  110. <a-col :md="4" :sm="24">退货数量:{{ (totalData && (totalData.returnQty || totalData.returnQty==0)) ?totalData.returnQty: '--' }}</a-col>
  111. <a-col :md="4" :sm="24" v-if="$hasPermissions('M_tireSalesReportList_salesPrice')">退货金额:{{ (totalData && (totalData.returnAmount || totalData.returnAmount==0)) ? toThousands(totalData.returnAmount): '--' }}</a-col>
  112. <a-col :md="4" :sm="24">客户现有库存数量:{{ (totalData &&totalData.rptDealerStockVO && (totalData.rptDealerStockVO.totalStockQty || totalData.rptDealerStockVO.totalStockQty==0)) ?totalData.rptDealerStockVO.totalStockQty: '--' }}</a-col>
  113. <a-col :md="4" :sm="24" v-if="$hasPermissions('M_tireSalesReportList_salesPrice')">客户现有库存金额:{{ (totalData&&totalData.rptDealerStockVO && (totalData.rptDealerStockVO.totalStockAmount || totalData.rptDealerStockVO.totalStockAmount==0)) ? toThousands(totalData.rptDealerStockVO.totalStockAmount): '--' }}</a-col>
  114. <a-col :md="4" :sm="24">出库加盟商数量:{{ (totalData && (totalData.outQtyDealer || totalData.outQtyDealer==0)) ?totalData.outQtyDealer: '--' }}</a-col>
  115. <a-col :md="4" :sm="24" v-if="$hasPermissions('M_tireSalesReportList_salesPrice')">出库加盟商金额:{{ (totalData && (totalData.outAmountDealer || totalData.outAmountDealer==0)) ? toThousands(totalData.outAmountDealer): '--' }}</a-col>
  116. <a-col :md="4" :sm="24">出库终端数量:{{ (totalData && (totalData.outQtyTerminal || totalData.outQtyTerminal==0)) ?totalData.outQtyTerminal: '--' }}</a-col>
  117. <a-col :md="4" :sm="24" v-if="$hasPermissions('M_tireSalesReportList_salesPrice')">出库终端金额:{{ (totalData && (totalData.outAmountTerminal || totalData.outAmountTerminal==0)) ? toThousands(totalData.outAmountTerminal): '--' }}</a-col>
  118. <a-col :md="4" :sm="24">累计出库数量:{{ (totalData && (totalData.outQty || totalData.outQty==0)) ?totalData.outQty: '--' }}</a-col>
  119. <a-col :md="4" :sm="24" v-if="$hasPermissions('M_tireSalesReportList_salesPrice')">累计出库金额:{{ (totalData && (totalData.outAmount || totalData.outAmount==0)) ? toThousands(totalData.outAmount): '--' }}</a-col>
  120. <a-col :md="4" :sm="24">已绑质保单数量:{{ (totalData&&totalData.rptDealerStockVO && (totalData.rptDealerStockVO.totalWarrantyQty || totalData.rptDealerStockVO.totalWarrantyQty==0)) ?totalData.rptDealerStockVO.totalWarrantyQty: '--' }}</a-col>
  121. </a-row>
  122. </template>
  123. </s-table>
  124. </a-spin>
  125. </a-card>
  126. <!-- 导出提示框 -->
  127. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  128. </div>
  129. </template>
  130. <script>
  131. import { commonMixin } from '@/utils/mixin'
  132. import { STable, VSelect } from '@/components'
  133. import rangeDate from '@/views/common/rangeDate.vue'
  134. import subarea from '@/views/common/subarea.js'
  135. import AreaList from '@/views/common/areaList.js'
  136. import BizUser from '@/views/common/bizUser.js'
  137. import reportModal from '@/views/common/reportModal.vue'
  138. import { hdExportExcel } from '@/libs/exportExcel'
  139. import { tireReportList, queryTireCount, tireListExport } from '@/api/reportData'
  140. import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
  141. export default {
  142. name: 'TireSalesDealerList',
  143. mixins: [commonMixin],
  144. components: { STable, VSelect, rangeDate, subarea, AreaList, BizUser, dealerSubareaScopeList, reportModal },
  145. data () {
  146. return {
  147. spinning: false,
  148. advanced: true, // 高级搜索 展开/关闭
  149. tableHeight: 0,
  150. queryParam: { // 查询条件
  151. time: [],
  152. bizBeginDate: '',
  153. bizEndDate: '',
  154. provinceSn: undefined,
  155. citySn: undefined,
  156. districtSn: undefined,
  157. dealerLevel: undefined,
  158. dealerName: undefined,
  159. dealerSn: undefined,
  160. subareaArea: {// 区域分区
  161. subareaSn: undefined,
  162. subareaAreaSn: undefined,
  163. bizUserSn: undefined // 区域负责人
  164. }
  165. },
  166. disabled: false, // 查询、重置按钮是否可操作
  167. exportLoading: false,
  168. showExport: false,
  169. rules: {
  170. 'time': [{ required: true, message: '请选择日期', trigger: 'change' }]
  171. },
  172. // 加载数据方法 必须为 Promise 对象
  173. loadData: parameter => {
  174. this.disabled = true
  175. this.spinning = true
  176. const oldParams = Object.assign(parameter, this.queryParam)
  177. const params = JSON.parse(JSON.stringify(oldParams))
  178. delete params.time
  179. return tireReportList(params).then(res => {
  180. let data
  181. if (res.status == 200 && res.data) {
  182. data = res.data
  183. const no = (data.pageNo - 1) * data.pageSize
  184. for (var i = 0; i < data.list.length; i++) {
  185. data.list[i].no = no + i + 1
  186. }
  187. this.disabled = false
  188. this.getCount(params)
  189. }
  190. this.spinning = false
  191. return data
  192. })
  193. },
  194. totalData: null
  195. }
  196. },
  197. watch: {
  198. advanced (newValue, oldValue) {
  199. const _this = this
  200. this.$nextTick(() => { // 页面渲染完成后的回调
  201. _this.setTableH()
  202. })
  203. },
  204. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  205. this.setTableH()
  206. }
  207. },
  208. computed: {
  209. columns () {
  210. const _this = this
  211. const arr = [
  212. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  213. { title: '地区', scopedSlots: { customRender: 'addressInfo' }, width: '12%', align: 'center' },
  214. { title: '区域', dataIndex: 'subareaArea.subareaName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  215. { title: '分区', dataIndex: 'subareaArea.subareaAreaName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  216. { title: '区域负责人', dataIndex: 'bizUserName', width: '9%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  217. { title: '客户名称', dataIndex: 'dealerEntity.dealerName', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  218. { title: '客户级别', dataIndex: 'dealerEntity.dealerLevelDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  219. { title: '任务数量', dataIndex: 'dealerEntity.taskNum', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  220. // { title: '授信金额', dataIndex: 'dealerEntity.dealerLevelDictValue', width: '8%', align: 'right', customRender: function (text) { return text || '--' } },
  221. { title: '总部订货数量', dataIndex: 'sysOrderQty', width: '80px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  222. // { title: '总部订货金额', dataIndex: 'sysOrderAmount', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  223. { title: '上级订货数量', dataIndex: 'upOrderQty', width: '80px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  224. // { title: '上级订货金额', dataIndex: 'upOrderAmount', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  225. { title: '跨地区订货数量', dataIndex: 'crossRegionQty', width: '80px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  226. // { title: '跨地区订货金额', dataIndex: 'crossRegionAmount', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  227. { title: '累计入库数量', dataIndex: 'putQty', width: '80px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  228. // { title: '累计入库金额', dataIndex: 'putAmount', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  229. { title: '退货数量', dataIndex: 'returnQty', width: '80px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  230. // { title: '退货金额', dataIndex: 'returnAmount', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  231. { title: '客户现有库存数量', dataIndex: 'rptDealerStockVO.totalStockQty', width: '80px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  232. // { title: '客户现有库存金额', dataIndex: 'dealerLevelDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  233. { title: '出库加盟商数量', dataIndex: 'outQtyDealer', width: '80px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  234. // { title: '出库加盟商金额', dataIndex: 'outAmountDealer', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  235. { title: '出库终端数量', dataIndex: 'outQtyTerminal', width: '80px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  236. // { title: '出库终端金额', dataIndex: 'outAmountTerminal', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  237. { title: '累计出库数量', dataIndex: 'outQty', width: '80px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  238. // { title: '累计出库金额', dataIndex: 'outAmount', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  239. { title: <div>已绑质保单<div>数量</div></div>, dataIndex: 'rptDealerStockVO.totalWarrantyQty', width: '80px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  240. ]
  241. if (this.$hasPermissions('M_tireSalesReportList_salesPrice')) {
  242. arr.splice(8, 0, { title: '授信金额', dataIndex: 'dealerEntity.taskAmount', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  243. arr.splice(10, 0, { title: '总部订货金额', dataIndex: 'sysOrderAmount', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  244. arr.splice(12, 0, { title: '上级订货金额', dataIndex: 'upOrderAmount', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  245. arr.splice(14, 0, { title: '跨地区订货金额', dataIndex: 'crossRegionAmount', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  246. arr.splice(16, 0, { title: '累计入库金额', dataIndex: 'putAmount', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  247. arr.splice(18, 0, { title: '退货金额', dataIndex: 'returnAmount', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  248. arr.splice(20, 0, { title: '客户现有库存金额', dataIndex: 'rptDealerStockVO.totalStockAmount', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  249. arr.splice(22, 0, { title: '出库加盟商金额', dataIndex: 'outAmountDealer', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  250. arr.splice(24, 0, { title: '出库终端金额', dataIndex: 'outAmountTerminal', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  251. arr.splice(26, 0, { title: '累计出库金额', dataIndex: 'outAmount', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  252. }
  253. return arr
  254. }
  255. },
  256. methods: {
  257. // 查询
  258. handleSearch () {
  259. const _this = this
  260. this.$refs.ruleForm.validate(valid => {
  261. if (valid) {
  262. _this.$refs.table.refresh(true)
  263. } else {
  264. _this.$message.error('请选择日期')
  265. return false
  266. }
  267. })
  268. },
  269. custChange (val) {
  270. this.queryParam.dealerName = val.name
  271. this.queryParam.dealerSn = val.key
  272. },
  273. // 统计
  274. getCount (params) {
  275. queryTireCount(params).then(res => {
  276. if (res.status == 200 && res.data) {
  277. this.totalData = res.data
  278. } else {
  279. this.totalData = null
  280. }
  281. })
  282. },
  283. // 地区
  284. areaChange (val) {
  285. this.queryParam.provinceSn = val[0] ? val[0] : undefined
  286. this.queryParam.citySn = val[1] ? val[1] : undefined
  287. this.queryParam.districtSn = val[2] ? val[2] : undefined
  288. },
  289. // 日期选择 change
  290. dateChange (date) {
  291. if (date[0] && date[1]) {
  292. this.queryParam.time = date
  293. } else {
  294. this.queryParam.time = []
  295. }
  296. this.queryParam.bizBeginDate = date[0] ? date[0].replace(/-/g, '') : ''
  297. this.queryParam.bizEndDate = date[1] ? date[1].replace(/-/g, '') : ''
  298. },
  299. subareaChange (val) {
  300. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : undefined
  301. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : undefined
  302. },
  303. // 重置
  304. resetSearchForm () {
  305. this.queryParam.time = []
  306. this.$refs.rangeDate.resetDate()
  307. this.queryParam.bizBeginDate = ''
  308. this.queryParam.bizEndDate = ''
  309. this.queryParam.provinceSn = undefined
  310. this.queryParam.citySn = undefined
  311. this.queryParam.districtSn = undefined
  312. this.queryParam.dealerName = undefined
  313. this.queryParam.dealerSn = undefined
  314. this.queryParam.subareaArea.subareaSn = undefined
  315. this.queryParam.subareaArea.subareaAreaSn = undefined
  316. this.queryParam.subareaArea.bizUserSn = undefined
  317. this.queryParam.dealerLevel = undefined
  318. this.totalData = null
  319. this.$refs.areaList.clearData()
  320. if (this.advanced) {
  321. this.$refs.dealerSubareaScopeList.resetForm()
  322. }
  323. this.$refs.subarea.clearData()
  324. this.$refs.table.clearTable()
  325. },
  326. // 导出
  327. handleExport () {
  328. const _this = this
  329. this.$refs.ruleForm.validate(valid => {
  330. if (valid) {
  331. _this.exportList()
  332. } else {
  333. _this.$message.error('请选择日期')
  334. return false
  335. }
  336. })
  337. },
  338. // 导出
  339. exportList () {
  340. const _this = this
  341. const params = JSON.parse(JSON.stringify(_this.queryParam))
  342. _this.exportLoading = true
  343. _this.spinning = true
  344. _this.showExport = true
  345. _this.$store.state.app.curActionPermission = 'B_tireReportExport'
  346. params.exportFlag = 0
  347. delete params.time
  348. hdExportExcel(tireListExport, params, '轮胎统计报表', function () {
  349. _this.exportLoading = false
  350. _this.spinning = false
  351. _this.$store.state.app.curActionPermission = ''
  352. })
  353. },
  354. pageInit () {
  355. const _this = this
  356. this.$nextTick(() => { // 页面渲染完成后的回调
  357. _this.setTableH()
  358. })
  359. },
  360. setTableH () {
  361. const tableSearchH = this.$refs.tableSearch.offsetHeight
  362. this.tableHeight = window.innerHeight - tableSearchH - 276
  363. }
  364. },
  365. mounted () {
  366. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  367. this.pageInit()
  368. }
  369. },
  370. activated () {
  371. // 如果是新页签打开,则重置当前页面
  372. if (this.$store.state.app.isNewTab) {
  373. this.pageInit()
  374. }
  375. },
  376. beforeRouteEnter (to, from, next) {
  377. next(vm => {})
  378. }
  379. }
  380. </script>