list.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="tireSalesReportList-wrap searchBoxNormal">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper" ref="tableSearch">
  6. <a-form-model
  7. id="tireSalesReportList-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-item label="产品名称">
  22. <a-input id="inventoryQueryList-productName" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
  23. </a-form-item>
  24. </a-col>
  25. <a-col :md="6" :sm="24">
  26. <a-form-item label="产品编码">
  27. <a-input id="inventoryQueryList-productCode" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
  28. </a-form-item>
  29. </a-col>
  30. <template v-if="advanced">
  31. <a-col :md="6" :sm="24">
  32. <a-form-item label="唯一码">
  33. <a-input id="inventoryQueryList-productOrigCode" v-model.trim="queryParam.productOrigCode" allowClear placeholder="请输入唯一码"/>
  34. </a-form-item>
  35. </a-col>
  36. <a-col :md="6" :sm="24">
  37. <a-form-model-item label="售出状态">
  38. <v-select
  39. v-model="queryParam.dealerLevel"
  40. ref="dealerLevel"
  41. id="salesOrderTotalList-dealerLevel"
  42. code="DEALER_LEVEL"
  43. placeholder="请选择售出状态"
  44. allowClear></v-select>
  45. </a-form-model-item>
  46. </a-col>
  47. <a-col :md="6" :sm="24">
  48. <a-form-model-item label="地区">
  49. <AreaList id="chooseCustomer-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
  50. </a-form-model-item>
  51. </a-col>
  52. <a-col :md="6" :sm="24">
  53. <a-form-item label="所在区域">
  54. <subarea id="allocateBillList-subarea" ref="subarea" @change="subareaChange"></subarea>
  55. </a-form-item>
  56. </a-col>
  57. <a-col :md="6" :sm="24">
  58. <a-form-model-item label="客户名称">
  59. <a-input
  60. id="salesOrderTotalList-dealerName"
  61. v-model.trim="queryParam.dealerName"
  62. allowClear
  63. placeholder="请输入客户名称" />
  64. </a-form-model-item>
  65. </a-col>
  66. <a-col :md="6" :sm="24">
  67. <a-form-item label="当前所在客户">
  68. <a-input id="inventoryQueryList-productOrigCode" v-model.trim="queryParam.productOrigCode" allowClear placeholder="请输入客户名称"/>
  69. </a-form-item>
  70. </a-col>
  71. </template>
  72. <a-col :md="6" :sm="24">
  73. <a-button
  74. style="margin-left: 5px"
  75. type="primary"
  76. @click="handleSearch"
  77. :disabled="disabled"
  78. id="salesOrderTotalList-refresh">查询</a-button>
  79. <a-button
  80. style="margin-left: 8px"
  81. @click="resetSearchForm"
  82. :disabled="disabled"
  83. id="salesOrderTotalList-reset">重置</a-button>
  84. <a-button
  85. style="margin-left: 10px"
  86. type="primary"
  87. class="button-warning"
  88. @click="handleExport"
  89. :disabled="disabled"
  90. :loading="exportLoading"
  91. v-if="$hasPermissions('B_salesOrderTotalExport')"
  92. id="salesOrderTotalList-export">导出</a-button>
  93. <a @click="advanced=!advanced" style="margin-left: 5px">
  94. {{ advanced ? '收起' : '展开' }}
  95. <a-icon :type="advanced ? 'up' : 'down'" />
  96. </a>
  97. </a-col>
  98. </a-row>
  99. </a-form-model>
  100. </div>
  101. </a-card>
  102. <a-card size="small" :bordered="false">
  103. <a-spin :spinning="spinning" tip="Loading...">
  104. <!-- 统计 -->
  105. <div class="tongji-bar" style="margin-bottom:10px">
  106. 总销售款数:<strong>{{ totalData&&(totalData.totalCategory || totalData.totalCategory==0) ? totalData.totalCategory : '0' }}</strong>;
  107. 总销售数量:<strong>{{ totalData&&(totalData.totalQty || totalData.totalQty==0) ? totalData.totalQty : '--' }}</strong>;
  108. 总销售金额:<strong>{{ totalData&&(totalData.totalPushedAmount || totalData.totalPushedAmount==0) ? toThousands(totalData.totalPushedAmount) : '--' }}</strong>;
  109. 已售出数量(从客户系统销售出库):<strong>{{ totalData&&(totalData.totalQty || totalData.totalQty==0) ? totalData.totalQty : '--' }}</strong>;
  110. 已售出金额:<strong>{{ totalData&&(totalData.totalPushedAmount || totalData.totalPushedAmount==0) ? toThousands(totalData.totalPushedAmount) : '--' }}</strong>;
  111. 未售出数量:<strong>{{ totalData&&(totalData.totalQty || totalData.totalQty==0) ? totalData.totalQty : '--' }}</strong>;
  112. 未售出金额:<strong>{{ totalData&&(totalData.totalPushedAmount || totalData.totalPushedAmount==0) ? toThousands(totalData.totalPushedAmount) : '--' }}</strong>;
  113. </div>
  114. <!-- 列表 -->
  115. <s-table
  116. class="sTable fixPagination"
  117. ref="table"
  118. size="small"
  119. :rowKey="(record) => record.salesBillNo"
  120. :style="{ height: tableHeight+70+'px' }"
  121. rowKeyName="salesBillNo"
  122. :columns="columns"
  123. :data="loadData"
  124. :scroll="{ y: tableHeight-10 }"
  125. :defaultLoadData="false"
  126. bordered>
  127. </s-table>
  128. </a-spin>
  129. <!-- 导出提示框 -->
  130. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  131. </a-card>
  132. </div>
  133. </template>
  134. <script>
  135. import {
  136. commonMixin
  137. } from '@/utils/mixin'
  138. import getDate from '@/libs/getDate.js'
  139. import {
  140. STable,
  141. VSelect
  142. } from '@/components'
  143. import rangeDate from '@/views/common/rangeDate.vue'
  144. import subarea from '@/views/common/subarea.js'
  145. import custList from '@/views/common/custList.vue'
  146. import reportModal from '@/views/common/reportModal.vue'
  147. import AreaList from '@/views/common/areaList.js'
  148. import {
  149. hdExportExcel
  150. } from '@/libs/exportExcel'
  151. import {
  152. userQueryList
  153. } from '@/api/power-user'
  154. import {
  155. reportSalesBillList,
  156. reportSalesBillCount,
  157. reportSalesBillExport
  158. } from '@/api/reportData'
  159. export default {
  160. name: 'SalesOrderTotalList',
  161. mixins: [commonMixin],
  162. components: {
  163. STable,
  164. VSelect,
  165. rangeDate,
  166. custList,
  167. subarea,
  168. reportModal,
  169. AreaList
  170. },
  171. data () {
  172. return {
  173. spinning: false,
  174. advanced: true, // 高级搜索 展开/关闭
  175. tableHeight: 0,
  176. showExport: false,
  177. queryParam: { // 查询条件
  178. time: [
  179. getDate.getCurrMonthDays().starttime,
  180. getDate.getCurrMonthDays().endtime
  181. ],
  182. beginDate: getDate.getCurrMonthDays().starttime,
  183. endDate: getDate.getCurrMonthDays().endtime,
  184. salesBillNo: '',
  185. dealerName: '',
  186. dealerLevel: undefined,
  187. operatorSn: undefined,
  188. subareaArea: {
  189. subareaSn: undefined,
  190. subareaAreaSn: undefined
  191. },
  192. dealerProvinceSn: undefined
  193. },
  194. rules: {
  195. 'time': [{
  196. required: true,
  197. message: '请选择销售日期',
  198. trigger: 'change'
  199. }]
  200. },
  201. disabled: false, // 查询、重置按钮是否可操作
  202. exportLoading: false,
  203. // 加载数据方法 必须为 Promise 对象
  204. loadData: parameter => {
  205. this.disabled = true
  206. this.spinning = true
  207. const params = Object.assign(parameter, this.queryParam)
  208. return reportSalesBillList(params).then(res => {
  209. let data
  210. if (res.status == 200) {
  211. data = res.data
  212. this.getCount(params)
  213. const no = (data.pageNo - 1) * data.pageSize
  214. for (var i = 0; i < data.list.length; i++) {
  215. data.list[i].no = no + i + 1
  216. }
  217. this.disabled = false
  218. }
  219. this.spinning = false
  220. return data
  221. })
  222. },
  223. totalData: null,
  224. operatorList: [], // 操作员下拉数据
  225. addrProvinceList: [] // 省下拉
  226. }
  227. },
  228. computed: {
  229. columns () {
  230. const _this = this
  231. const arr = [
  232. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  233. { title: '地区', dataIndex: 'salesBillNo', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  234. { title: '区域', dataIndex: 'createDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  235. { title: '分区', dataIndex: 'auditDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  236. { title: '客户名称', dataIndex: 'dealerName', width: '12%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  237. { title: '商户类型', dataIndex: 'dealerLevelDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  238. { title: '商户级别', dataIndex: 'directDealerName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  239. { title: '产品编码', dataIndex: 'indirectDealerName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  240. { title: '产品名称', dataIndex: 'totalQty', width: '12%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  241. { title: '唯一码', dataIndex: 'giftQty', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  242. // { title: '售价(开单金额)', dataIndex: 'totalRealSaleAmount', width: '12%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  243. { title: '出库时间', dataIndex: 'giftQty', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  244. { title: '客户出库日期', dataIndex: 'giftQty', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  245. { title: '当前所在客户', dataIndex: 'giftQty', width: '12%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  246. { title: '销售状态', dataIndex: 'giftQty', width: '10%', align: 'center', customRender: function (text) { return text || '--' } }
  247. ]
  248. if (this.$hasPermissions('M_salesOrderTotalList_salesPrice')) {
  249. arr.splice(10, 0, { title: '售价(开单金额)', dataIndex: 'totalRealSaleAmount', width: '12%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  250. }
  251. return arr
  252. }
  253. },
  254. watch: {
  255. advanced (newValue, oldValue) {
  256. const _this = this
  257. this.$nextTick(() => { // 页面渲染完成后的回调
  258. _this.setTableH()
  259. })
  260. },
  261. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  262. this.setTableH()
  263. }
  264. },
  265. methods: {
  266. // 盘点库存日期
  267. handleStock () {
  268. this.$message.info('无盘点区间的起始/终止时间,请自行选择日期区间查询!')
  269. },
  270. // 总计
  271. getCount (params) {
  272. reportSalesBillCount(params).then(res => {
  273. if (res.status == 200 && res.data) {
  274. this.totalData = res.data
  275. } else {
  276. this.totalData = null
  277. }
  278. })
  279. },
  280. handleSearch () {
  281. const _this = this
  282. this.$refs.ruleForm.validate(valid => {
  283. if (valid) {
  284. _this.$refs.table.refresh(true)
  285. } else {
  286. _this.$message.error('请选择销售日期')
  287. return false
  288. }
  289. })
  290. },
  291. // 创建时间 change
  292. dateChange (date) {
  293. if (date[0] && date[1]) {
  294. this.queryParam.time = date
  295. } else {
  296. this.queryParam.time = []
  297. }
  298. this.queryParam.beginDate = date[0] || ''
  299. this.queryParam.endDate = date[1] || ''
  300. },
  301. custChange (val) {
  302. this.queryParam.dealerSn = val.key
  303. },
  304. subareaChange (val) {
  305. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : undefined
  306. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : undefined
  307. },
  308. // 重置
  309. resetSearchForm () {
  310. this.queryParam.time = [
  311. getDate.getCurrMonthDays().starttime,
  312. getDate.getCurrMonthDays().endtime
  313. ]
  314. this.$refs.rangeDate.resetDate(this.queryParam.time)
  315. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  316. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  317. this.queryParam.salesBillNo = ''
  318. this.queryParam.dealerName = ''
  319. this.queryParam.dealerLevel = undefined
  320. this.queryParam.operatorSn = undefined
  321. this.queryParam.subareaArea.subareaSn = undefined
  322. this.queryParam.subareaArea.subareaAreaSn = undefined
  323. this.queryParam.dealerProvinceSn = undefined
  324. this.totalData = null
  325. if (this.advanced) {
  326. this.$refs.subarea.clearData()
  327. }
  328. this.$refs.ruleForm.resetFields()
  329. this.$refs.table.clearTable()
  330. },
  331. // 导出
  332. handleExport () {
  333. const _this = this
  334. this.$refs.ruleForm.validate(valid => {
  335. if (valid) {
  336. const params = _this.queryParam
  337. _this.$store.state.app.curActionPermission = 'B_salesOrderTotalExport'
  338. _this.showExport = true
  339. _this.exportLoading = true
  340. _this.spinning = true
  341. hdExportExcel(reportSalesBillExport, params, '销售(开单统计)报表', function () {
  342. _this.exportLoading = false
  343. _this.spinning = false
  344. _this.$store.state.app.curActionPermission = ''
  345. })
  346. } else {
  347. return false
  348. }
  349. })
  350. },
  351. filterOption (input, option) {
  352. return (
  353. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  354. )
  355. },
  356. // 操作员
  357. getUserList () {
  358. userQueryList({}).then(res => {
  359. if (res.status == 200) {
  360. this.operatorList = res.data
  361. } else {
  362. this.operatorList = []
  363. }
  364. })
  365. },
  366. pageInit () {
  367. const _this = this
  368. _this.getUserList()
  369. this.$nextTick(() => { // 页面渲染完成后的回调
  370. _this.setTableH()
  371. })
  372. },
  373. setTableH () {
  374. const tableSearchH = this.$refs.tableSearch.offsetHeight
  375. this.tableHeight = window.innerHeight - tableSearchH - 226
  376. }
  377. },
  378. mounted () {
  379. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  380. this.pageInit()
  381. this.resetSearchForm()
  382. }
  383. },
  384. activated () {
  385. // 如果是新页签打开,则重置当前页面
  386. if (this.$store.state.app.isNewTab) {
  387. this.pageInit()
  388. this.resetSearchForm()
  389. }
  390. },
  391. beforeRouteEnter (to, from, next) {
  392. next(vm => {})
  393. }
  394. }
  395. </script>