serviceFreightDetailList.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="sfdetail-wrap searchBoxNormal">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper" ref="tableSearch">
  6. <a-form-model
  7. id="sfdetail-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 prop="time">
  16. <div style="display: inline;" slot="label">
  17. <a-popover placement="top">
  18. <template slot="content">
  19. <p>1、销售单(非转单)下推时间</p>
  20. <p>2、销售单(转单)转单完结时间</p>
  21. <p>3、销售退货单客服确认时间</p>
  22. </template>
  23. 查询日期 <a-icon type="question-circle" />
  24. </a-popover>
  25. </div>
  26. <rangeDate
  27. ref="rangeDate"
  28. :value="queryParam.time"
  29. id="sfdetail-time"
  30. @change="dateChange" />
  31. </a-form-model-item>
  32. </a-col>
  33. <a-col :md="6" :sm="24">
  34. <a-form-item label="记账主体">
  35. <custList id="sfdetail-belongDealer" dataAuthFlag="0" placeholder="请输入记账主体" ref="belongDealer" @change="belongDealerChange" />
  36. </a-form-item>
  37. </a-col>
  38. <a-col :md="6" :sm="24">
  39. <a-form-item label="业务单号">
  40. <a-input id="sfdetail-bizNo" v-model.trim="queryParam.bizNo" allowClear placeholder="请输入业务单号"/>
  41. </a-form-item>
  42. </a-col>
  43. <template v-if="advanced">
  44. <a-col :md="6" :sm="24">
  45. <a-form-model-item label="客户名称">
  46. <custList id="sfdetail-custName" dataAuthFlag="0" placeholder="请输入客户名称" ref="custList" @change="custChange" />
  47. </a-form-model-item>
  48. </a-col>
  49. <a-col :md="6" :sm="24">
  50. <a-form-model-item label="业务类型">
  51. <v-select
  52. v-model="queryParam.bizType"
  53. ref="bizType"
  54. id="sfdetail-bizType"
  55. code="SUBSIDY_BIZ_TYPE"
  56. placeholder="请选择业务类型"
  57. allowClear></v-select>
  58. </a-form-model-item>
  59. </a-col>
  60. <a-col :md="6" :sm="24">
  61. <a-form-item label="发货经销商">
  62. <custList id="sfdetail-transferDealerSn" dataAuthFlag="0" placeholder="请输入发货经销商" ref="dealerTireScopeList" @change="custTireChange" />
  63. </a-form-item>
  64. </a-col>
  65. <a-col :md="6" :sm="24">
  66. <a-form-model-item label="轮胎省仓">
  67. <v-select
  68. v-model="queryParam.belongProvinceFlag"
  69. id="sfdetail-belongProvinceFlag"
  70. code="Flag"
  71. placeholder="请选择轮胎省仓"
  72. allowClear></v-select>
  73. </a-form-model-item>
  74. </a-col>
  75. <a-col :md="6" :sm="24">
  76. <a-form-item label="所在区域">
  77. <subarea id="sfdetail-subarea" ref="subarea" @change="subareaChange"></subarea>
  78. </a-form-item>
  79. </a-col>
  80. <a-col :md="6" :sm="24">
  81. <a-form-model-item label="地区">
  82. <AreaList id="sfdetail-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
  83. </a-form-model-item>
  84. </a-col>
  85. </template>
  86. <a-col :md="6" :sm="24">
  87. <a-button
  88. type="primary"
  89. @click="handleSearch"
  90. :disabled="disabled"
  91. id="sfdetail-refresh">查询</a-button>
  92. <a-button
  93. style="margin-left: 8px"
  94. @click="resetSearchForm"
  95. :disabled="disabled"
  96. id="sfdetail-reset">重置</a-button>
  97. <a-button
  98. style="margin-left: 10px"
  99. type="primary"
  100. class="button-warning"
  101. @click="handleExport"
  102. :disabled="disabled"
  103. :loading="exportLoading"
  104. v-if="$hasPermissions('M_tireSubsidyExport')"
  105. id="sfdetail-export">导出</a-button>
  106. <a @click="advanced=!advanced" style="margin-left: 5px">
  107. {{ advanced ? '收起' : '展开' }}
  108. <a-icon :type="advanced ? 'up' : 'down'" />
  109. </a>
  110. </a-col>
  111. </a-row>
  112. </a-form-model>
  113. </div>
  114. </a-card>
  115. <a-card size="small" :bordered="false">
  116. <a-spin :spinning="spinning" tip="Loading...">
  117. <!-- 列表 -->
  118. <s-table
  119. class="sTable fixPagination"
  120. ref="table"
  121. size="small"
  122. :rowKey="(record) => record.no"
  123. rowKeyName="no"
  124. :style="{ height: tableHeight+70+'px' }"
  125. :columns="columns"
  126. :data="loadData"
  127. :scroll="{ y: tableHeight-120}"
  128. :defaultLoadData="false"
  129. bordered>
  130. <template slot="footer">
  131. <a-row :gutter="15">
  132. <a-col :md="6" :sm="24">服务费金额:{{ (totalData && (totalData.subsidyServiceAmount || totalData.subsidyServiceAmount==0)) ? toThousands(totalData.subsidyServiceAmount): '--' }}</a-col>
  133. <a-col :md="6" :sm="24">运费补贴金额:{{ (totalData && (totalData.subsidyShippingAmount || totalData.subsidyShippingAmount==0)) ? toThousands(totalData.subsidyShippingAmount): '--' }}</a-col>
  134. </a-row>
  135. </template>
  136. </s-table>
  137. </a-spin>
  138. </a-card>
  139. </div>
  140. </template>
  141. <script>
  142. import { commonMixin } from '@/utils/mixin'
  143. import { hdExportExcel } from '@/libs/exportExcel'
  144. import moment from 'moment'
  145. import getDate from '@/libs/getDate.js'
  146. // 组件
  147. import { STable, VSelect } from '@/components'
  148. import rangeDate from '@/views/common/rangeDate.vue'
  149. import subarea from '@/views/common/subarea.js'
  150. import AreaList from '@/views/common/areaList.js'
  151. import custList from '@/views/common/custList.vue'
  152. // 接口
  153. import { subsidyDetailList, subsidyDetailCount, subsidyDetailExport } from '@/api/reportData'
  154. export default {
  155. name: 'ServiceFreightDetailList',
  156. mixins: [commonMixin],
  157. components: { STable, VSelect, rangeDate, subarea, AreaList, custList },
  158. data () {
  159. return {
  160. spinning: false,
  161. disabled: false, // 查询、重置按钮是否可操作
  162. advanced: false, // 高级搜索 展开/关闭
  163. tableHeight: 0, // 表格高度
  164. exportLoading: false, // 导出按钮加载状态
  165. // 查询条件
  166. queryParam: {
  167. time: [
  168. moment(getDate.getCurrMonthDays().starttime, 'YYYY-MM-DD'),
  169. moment(getDate.getCurrMonthDays().endtime, 'YYYY-MM-DD')
  170. ], // 日期
  171. beginDate: getDate.getCurrMonthDays().starttime, // 开始时间
  172. endDate: getDate.getCurrMonthDays().endtime, // 结束时间
  173. bizNo: undefined, // 业务单号
  174. bizType: undefined, // 业务类型
  175. belongProvinceFlag: undefined, // 是否轮胎省仓
  176. subareaArea: {
  177. subareaSn: undefined, // 区域
  178. subareaAreaSn: undefined // 分区
  179. },
  180. dealer: {
  181. provinceSn: undefined,
  182. citySn: undefined,
  183. districtSn: undefined
  184. },
  185. belongDealerSn: undefined,
  186. transferDealerSn: undefined,
  187. dealerSn: undefined
  188. },
  189. totalData: null, // 合计
  190. showOutDetail: false, // 出库明细弹窗
  191. rules: {
  192. 'time': [{ required: true, message: '请选择查询日期', trigger: 'change' }]
  193. },
  194. // 加载数据方法 必须为 Promise 对象
  195. loadData: parameter => {
  196. this.disabled = true
  197. this.spinning = true
  198. const oldParams = Object.assign(parameter, this.queryParam)
  199. const params = JSON.parse(JSON.stringify(oldParams))
  200. delete params.time
  201. // 获取列表数据 有分页
  202. return subsidyDetailList(params).then(res => {
  203. let data
  204. if (res.status == 200) {
  205. data = res.data
  206. // 计算表格序号
  207. const no = (data.pageNo - 1) * data.pageSize
  208. for (var i = 0; i < data.list.length; i++) {
  209. data.list[i].no = no + i + 1
  210. }
  211. this.disabled = false
  212. // 获取统计数据
  213. this.getCount(params)
  214. }
  215. this.spinning = false
  216. return data
  217. })
  218. }
  219. }
  220. },
  221. watch: {
  222. advanced (newValue, oldValue) {
  223. const _this = this
  224. this.$nextTick(() => { // 页面渲染完成后的回调
  225. _this.setTableH()
  226. })
  227. },
  228. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  229. this.setTableH()
  230. }
  231. },
  232. computed: {
  233. columns () {
  234. const _this = this
  235. const arr = [
  236. { title: '序号', dataIndex: 'no', width: '40px', align: 'center' },
  237. { title: '业务单号', dataIndex: 'bizNo', width: '100px', align: 'center', customRender: function (text) { return text || '--' } },
  238. { title: '区域', dataIndex: 'subareaArea.subareaName', width: '80px', align: 'center', customRender: function (text) { return text || '--' } },
  239. { title: '分区', dataIndex: 'subareaArea.subareaAreaName', width: '80px', align: 'center', customRender: function (text) { return text || '--' } },
  240. { title: '省份', dataIndex: 'provinceName', width: '80px', align: 'center', customRender: function (text) { return text || '--' } },
  241. { title: '记账主体', dataIndex: 'belongDealerName', width: '150px', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  242. { title: '轮胎省仓', dataIndex: 'belongProvinceFlagDictValue', width: '80px', align: 'center', customRender: function (text) { return text || '--' } },
  243. { title: '销售数量', dataIndex: 'bizQty', width: '80px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  244. { title: '销售金额', dataIndex: 'bizAmount', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  245. { title: '服务费比例', dataIndex: 'subsidyServiceDiff', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text * 100) + '%' : '--') } },
  246. { title: '服务费金额', dataIndex: 'subsidyServiceAmount', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  247. { title: '运费补贴', dataIndex: 'subsidyShippingDiff', width: '80px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  248. { title: '运费补贴金额', dataIndex: 'subsidyShippingAmount', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  249. { title: '客户名称', dataIndex: 'dealerName', width: '150px', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  250. { title: '发货经销商', dataIndex: 'transferDealerName', width: '150px', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  251. { title: '业务类型', dataIndex: 'bizTypeDictValue', width: '100px', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true }
  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. // 日期选择 change
  270. dateChange (date) {
  271. if (date[0] && date[1]) {
  272. this.queryParam.time = date
  273. } else {
  274. this.queryParam.time = []
  275. }
  276. this.queryParam.beginDate = date[0]
  277. this.queryParam.endDate = date[1]
  278. },
  279. // 选择发货经销商
  280. custTireChange (val) {
  281. this.queryParam.transferDealerName = val.name
  282. this.queryParam.transferDealerSn = val.key
  283. },
  284. // 记账主体
  285. belongDealerChange (val) {
  286. this.queryParam.belongDealerName = val.name
  287. this.queryParam.belongDealerSn = val.key
  288. },
  289. // 客户名称 change
  290. custChange (val) {
  291. this.queryParam.dealerName = val.name
  292. this.queryParam.dealerSn = val.key
  293. },
  294. // 统计
  295. getCount (params) {
  296. subsidyDetailCount(params).then(res => {
  297. if (res.status == 200 && res.data) {
  298. this.totalData = res.data
  299. } else {
  300. this.totalData = null
  301. }
  302. })
  303. },
  304. // 地区省份
  305. areaChange (val) {
  306. this.queryParam.dealer.provinceSn = val[0] ? val[0] : undefined
  307. this.queryParam.dealer.citySn = val[1] ? val[1] : undefined
  308. this.queryParam.dealer.districtSn = val[2] ? val[2] : undefined
  309. },
  310. // 区域分区 change
  311. subareaChange (val) {
  312. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : undefined
  313. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : undefined
  314. },
  315. // 重置
  316. resetSearchForm () {
  317. this.queryParam.time = [
  318. moment(getDate.getCurrMonthDays().starttime, 'YYYY-MM-DD'),
  319. moment(getDate.getCurrMonthDays().endtime, 'YYYY-MM-DD')
  320. ]
  321. this.$refs.rangeDate.resetDate(this.queryParam.time)
  322. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  323. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  324. this.queryParam.bizNo = undefined
  325. this.queryParam.bizType = undefined
  326. this.queryParam.belongDealerSn = undefined
  327. this.queryParam.transferDealerSn = undefined
  328. this.queryParam.dealerSn = undefined
  329. this.queryParam.belongProvinceFlag = undefined
  330. this.queryParam.dealer.provinceSn = undefined
  331. this.queryParam.dealer.citySn = undefined
  332. this.queryParam.dealer.districtSn = undefined
  333. this.queryParam.subareaArea.subareaSn = undefined
  334. this.queryParam.subareaArea.subareaAreaSn = undefined
  335. if (this.advanced) {
  336. this.$refs.dealerTireScopeList.resetForm()
  337. this.$refs.belongDealer.resetForm()
  338. this.$refs.custList.resetForm()
  339. this.$refs.subarea.clearData()
  340. this.$refs.areaList.clearData()
  341. }
  342. this.totalData = null
  343. this.$refs.table.clearTable()
  344. this.$refs.ruleForm.resetFields()
  345. },
  346. // 导出 必填判断
  347. handleExport () {
  348. const _this = this
  349. this.$refs.ruleForm.validate(valid => {
  350. if (valid) {
  351. _this.exportList()
  352. } else {
  353. _this.$message.error('请选择查询时间')
  354. return false
  355. }
  356. })
  357. },
  358. // 导出
  359. exportList () {
  360. const _this = this
  361. const params = JSON.parse(JSON.stringify(_this.queryParam))
  362. _this.exportLoading = true
  363. _this.spinning = true
  364. hdExportExcel(subsidyDetailExport, params, '轮胎服务费运费明细报表-', function () {
  365. _this.exportLoading = false
  366. _this.spinning = false
  367. })
  368. },
  369. // 初始化
  370. pageInit () {
  371. this.$nextTick(() => { // 页面渲染完成后的回调
  372. this.setTableH()
  373. })
  374. this.resetSearchForm()
  375. },
  376. // 计算表格高度
  377. setTableH () {
  378. const tableSearchH = this.$refs.tableSearch.offsetHeight
  379. this.tableHeight = window.innerHeight - tableSearchH - 280
  380. }
  381. },
  382. mounted () {
  383. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  384. this.pageInit()
  385. }
  386. },
  387. activated () {
  388. // 如果是新页签打开,则重置当前页面
  389. if (this.$store.state.app.isNewTab) {
  390. this.pageInit()
  391. }
  392. }
  393. }
  394. </script>