list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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. :model="queryParam">
  12. <a-row :gutter="15">
  13. <a-col :md="6" :sm="24">
  14. <a-form-model-item label="出库时间">
  15. <rangeDate ref="rangeDate" :value="time" @change="dateChange" />
  16. </a-form-model-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-model-item label="地区">
  20. <AreaList id="tireSalesDealerList-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
  21. </a-form-model-item>
  22. </a-col>
  23. <a-col :md="6" :sm="24">
  24. <a-form-item label="区域/分区">
  25. <subarea id="tireSalesDealerList-subarea" ref="subarea" @change="subareaChange"></subarea>
  26. </a-form-item>
  27. </a-col>
  28. <a-col :md="6" :sm="24">
  29. <a-form-model-item label="客户名称">
  30. <dealerSubareaScopeList ref="dealerSubareaScopeList" id="tireSalesDealerList-dealerName" @change="custChange" />
  31. </a-form-model-item>
  32. </a-col>
  33. <template v-if="advanced">
  34. <a-col :md="6" :sm="24">
  35. <a-form-model-item label="客户级别">
  36. <v-select
  37. v-model="queryParam.dealerLevel"
  38. ref="dealerLevel"
  39. id="tireSalesDealerList-dealerLevel"
  40. code="DEALER_LEVEL"
  41. placeholder="请选择客户级别"
  42. allowClear></v-select>
  43. </a-form-model-item>
  44. </a-col>
  45. <a-col :md="6" :sm="24">
  46. <a-form-model-item label="区域负责人">
  47. <BizUser v-model="queryParam.bizUserSn"></BizUser>
  48. </a-form-model-item>
  49. </a-col>
  50. <a-col :md="6" :sm="24">
  51. <a-form-model-item label="产品编码/原厂编码">
  52. <a-input id="tireSalesDealerList-productWord" v-model.trim="queryParam.productWord" allowClear placeholder="请输入产品编码/原厂编码"/>
  53. </a-form-model-item>
  54. </a-col>
  55. <a-col :md="6" :sm="24">
  56. <a-form-model-item label="产品名称">
  57. <a-input id="tireSalesDealerList-productName" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
  58. </a-form-model-item>
  59. </a-col>
  60. </template>
  61. <a-col :md="24" :sm="24" style="text-align:center;margin-bottom:10px;">
  62. <a-button
  63. style="margin-left: 5px"
  64. type="primary"
  65. @click="$refs.table.refresh(true)"
  66. :disabled="disabled"
  67. id="tireSalesDealerList-refresh">查询</a-button>
  68. <a-button
  69. style="margin-left: 8px"
  70. @click="resetSearchForm"
  71. :disabled="disabled"
  72. id="tireSalesDealerList-reset">重置</a-button>
  73. <a-button
  74. style="margin-left: 10px"
  75. type="primary"
  76. class="button-warning"
  77. @click="handleExport"
  78. :disabled="disabled"
  79. :loading="exportLoading"
  80. v-if="$hasPermissions('B_tireSalesReportExport')"
  81. id="tireSalesDealerList-export">导出</a-button>
  82. <a @click="advanced=!advanced" style="margin-left: 5px">
  83. {{ advanced ? '收起' : '展开' }}
  84. <a-icon :type="advanced ? 'up' : 'down'" />
  85. </a>
  86. </a-col>
  87. </a-row>
  88. </a-form-model>
  89. </div>
  90. </a-card>
  91. <a-card size="small" :bordered="false">
  92. <a-spin :spinning="spinning" tip="Loading...">
  93. <!-- 列表 -->
  94. <s-table
  95. class="sTable fixPagination"
  96. ref="table"
  97. size="small"
  98. :rowKey="(record) => record.no"
  99. :style="{ height: tableHeight+70+'px' }"
  100. rowKeyName="no"
  101. :columns="columns"
  102. :data="loadData"
  103. :scroll="{ y: tableHeight-30 }"
  104. :defaultLoadData="false"
  105. bordered>
  106. <template slot="addressInfo" slot-scope="text, record">
  107. {{ record.provinceName }}{{ '/'+record.cityName }}{{ '/'+record.districtName }}
  108. </template>
  109. <template slot="footer">
  110. <a-row :gutter="15">
  111. <a-col :md="4" :sm="24">订货数量:{{ (totalData && (totalData.totalbuyAmount || totalData.totalbuyAmount==0)) ? totalData.totalbuyAmount : '--' }}</a-col>
  112. <a-col :md="4" :sm="24" v-if="$hasPermissions('M_tireSalesReportList_salesPrice')">订货金额:{{ (totalData && (totalData.totalbuyPriceAmount || totalData.totalbuyPriceAmount==0)) ? toThousands(totalData.totalbuyPriceAmount): '--' }}</a-col>
  113. <a-col :md="4" :sm="24">客户现有库存数量:{{ (totalData && (totalData.totalstoreAmount || totalData.totalstoreAmount==0)) ?totalData.totalstoreAmount: '--' }}</a-col>
  114. <a-col :md="4" :sm="24">已绑质保单数量:{{ (totalData && (totalData.totalwarrantyAmount || totalData.totalwarrantyAmount==0)) ?totalData.totalwarrantyAmount: '--' }}</a-col>
  115. </a-row>
  116. </template>
  117. </s-table>
  118. </a-spin>
  119. </a-card>
  120. <!-- 导出提示框 -->
  121. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  122. </div>
  123. </template>
  124. <script>
  125. import { commonMixin } from '@/utils/mixin'
  126. import getDate from '@/libs/getDate.js'
  127. import { STable, VSelect } from '@/components'
  128. import rangeDate from '@/views/common/rangeDate.vue'
  129. import subarea from '@/views/common/subarea.js'
  130. import AreaList from '@/views/common/areaList.js'
  131. import BizUser from '@/views/common/bizUser.js'
  132. import reportModal from '@/views/common/reportModal.vue'
  133. import { hdExportExcel } from '@/libs/exportExcel'
  134. import { queryTireList, queryTireCount, excelTireOnlineExport } from '@/api/reportData'
  135. import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
  136. export default {
  137. name: 'TireSalesDealerList',
  138. mixins: [commonMixin],
  139. components: { STable, VSelect, rangeDate, subarea, AreaList, BizUser, dealerSubareaScopeList, reportModal },
  140. data () {
  141. return {
  142. spinning: false,
  143. advanced: true, // 高级搜索 展开/关闭
  144. tableHeight: 0,
  145. time: [
  146. getDate.getThreeMonthDays().starttime,
  147. getDate.getCurrMonthDays().endtime
  148. ],
  149. queryParam: { // 查询条件
  150. beginDate: getDate.getThreeMonthDays().starttime,
  151. endDate: getDate.getCurrMonthDays().endtime,
  152. provinceSn: undefined,
  153. citySn: undefined,
  154. districtSn: undefined,
  155. dealerName: '',
  156. dealerSn: '',
  157. subareaSn: undefined,
  158. subareaAreaSn: undefined,
  159. bizUserSn: undefined,
  160. productWord: '', // 产品编码/原厂编码
  161. productName: '', // 产品名称
  162. dealerLevel: undefined
  163. },
  164. disabled: false, // 查询、重置按钮是否可操作
  165. exportLoading: false,
  166. showExport: false,
  167. // 加载数据方法 必须为 Promise 对象
  168. loadData: parameter => {
  169. this.disabled = true
  170. this.spinning = true
  171. const params = Object.assign(parameter, this.queryParam)
  172. return queryTireList(params).then(res => {
  173. let data
  174. if (res.status == 200) {
  175. data = res.data
  176. const no = (data.pageNo - 1) * data.pageSize
  177. for (var i = 0; i < data.list.length; i++) {
  178. data.list[i].no = no + i + 1
  179. }
  180. this.disabled = false
  181. this.getCount(params)
  182. }
  183. this.spinning = false
  184. return data
  185. })
  186. },
  187. totalData: null
  188. }
  189. },
  190. watch: {
  191. advanced (newValue, oldValue) {
  192. const _this = this
  193. this.$nextTick(() => { // 页面渲染完成后的回调
  194. _this.setTableH()
  195. })
  196. },
  197. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  198. this.setTableH()
  199. }
  200. },
  201. computed: {
  202. columns () {
  203. const _this = this
  204. const arr = [
  205. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  206. { title: '地区', scopedSlots: { customRender: 'addressInfo' }, width: '12%', align: 'center' },
  207. { title: '区域', dataIndex: 'subareaName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  208. { title: '分区', dataIndex: 'subareaAreaName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  209. { title: '区域负责人', dataIndex: 'userNameQyfzrs', width: '7%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  210. { title: '客户名称', dataIndex: 'dealerName', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  211. { title: '客户级别', dataIndex: 'dealerLevelDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  212. { title: '产品编码', dataIndex: 'productCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  213. { title: '原厂编码', dataIndex: 'productOrgiCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  214. { title: '产品名称', dataIndex: 'productName', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  215. { title: '订货数量', dataIndex: 'buyAmount', width: '80px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  216. { title: <div>客户现有<div>库存数量</div></div>, dataIndex: 'storeAmount', width: '80px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  217. { title: <div>已绑质保单<div>数量</div></div>, dataIndex: 'warrantyAmount', width: '80px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  218. ]
  219. if (this.$hasPermissions('M_tireSalesReportList_salesPrice')) {
  220. arr.splice(11, 0, { title: '订货金额', dataIndex: 'buyPriceAmount', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  221. }
  222. return arr
  223. }
  224. },
  225. methods: {
  226. custChange (val) {
  227. this.queryParam.dealerName = val.name
  228. this.queryParam.dealerSn = val.key
  229. },
  230. // 统计
  231. getCount (params) {
  232. queryTireCount(params).then(res => {
  233. if (res.status == 200 && res.data) {
  234. this.totalData = res.data
  235. } else {
  236. this.totalData = null
  237. }
  238. })
  239. },
  240. // 地区
  241. areaChange (val) {
  242. this.queryParam.provinceSn = val[0] ? val[0] : ''
  243. this.queryParam.citySn = val[1] ? val[1] : ''
  244. this.queryParam.districtSn = val[2] ? val[2] : ''
  245. },
  246. // 下推时间 change
  247. dateChange (date) {
  248. if (date[0] && date[1]) {
  249. this.time = date
  250. } else {
  251. this.time = []
  252. }
  253. this.queryParam.beginDate = date[0] || ''
  254. this.queryParam.endDate = date[1] || ''
  255. },
  256. subareaChange (val) {
  257. this.queryParam.subareaSn = val[0] ? val[0] : undefined
  258. this.queryParam.subareaAreaSn = val[1] ? val[1] : undefined
  259. },
  260. // 重置
  261. resetSearchForm () {
  262. this.time = [
  263. getDate.getThreeMonthDays().starttime,
  264. getDate.getCurrMonthDays().endtime
  265. ]
  266. this.$refs.rangeDate.resetDate(this.time)
  267. this.queryParam.beginDate = getDate.getThreeMonthDays().starttime
  268. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  269. this.queryParam.provinceSn = undefined
  270. this.queryParam.citySn = undefined
  271. this.queryParam.districtSn = undefined
  272. this.queryParam.dealerName = ''
  273. this.queryParam.dealerSn = ''
  274. this.queryParam.subareaSn = undefined
  275. this.queryParam.subareaAreaSn = undefined
  276. this.queryParam.bizUserSn = undefined
  277. this.queryParam.productWord = undefined
  278. this.queryParam.productName = undefined
  279. this.queryParam.dealerLevel = undefined
  280. this.totalData = null
  281. this.$refs.areaList.clearData()
  282. if (this.advanced) {
  283. this.$refs.dealerSubareaScopeList.resetForm()
  284. this.$refs.subarea.clearData()
  285. }
  286. this.$refs.table.clearTable()
  287. },
  288. // 导出
  289. handleExport () {
  290. const _this = this
  291. const params = _this.queryParam
  292. _this.exportLoading = true
  293. _this.spinning = true
  294. _this.showExport = true
  295. _this.$store.state.app.curActionPermission = 'B_tireSalesReportExport'
  296. hdExportExcel(excelTireOnlineExport, params, '轮胎统计报表', function () {
  297. _this.exportLoading = false
  298. _this.spinning = false
  299. _this.$store.state.app.curActionPermission = ''
  300. })
  301. },
  302. pageInit () {
  303. const _this = this
  304. this.$nextTick(() => { // 页面渲染完成后的回调
  305. _this.setTableH()
  306. })
  307. this.resetSearchForm()
  308. },
  309. setTableH () {
  310. const tableSearchH = this.$refs.tableSearch.offsetHeight
  311. this.tableHeight = window.innerHeight - tableSearchH - 198
  312. }
  313. },
  314. mounted () {
  315. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  316. this.pageInit()
  317. }
  318. },
  319. activated () {
  320. // 如果是新页签打开,则重置当前页面
  321. if (this.$store.state.app.isNewTab) {
  322. this.pageInit()
  323. }
  324. },
  325. beforeRouteEnter (to, from, next) {
  326. next(vm => {})
  327. }
  328. }
  329. </script>