list.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <template>
  2. <a-card size="small" :bordered="false" class="salesOrderTotalList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper">
  6. <a-form-model
  7. id="salesOrderTotalList-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. <rangeDateTime ref="rangeDate" :value="queryParam.time" @change="dateChange" />
  18. </a-form-model-item>
  19. </a-col>
  20. <a-col :md="5" :sm="24">
  21. <a-form-model-item label="销售单号">
  22. <a-input id="salesOrderTotalList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入销售单号"/>
  23. </a-form-model-item>
  24. </a-col>
  25. <a-col :md="5" :sm="24">
  26. <a-form-model-item label="客户名称">
  27. <a-input id="salesOrderTotalList-dealerName" v-model.trim="queryParam.dealerName" allowClear placeholder="请输入客户名称"/>
  28. </a-form-model-item>
  29. </a-col>
  30. <template v-if="advanced">
  31. <a-col :md="6" :sm="24">
  32. <a-form-model-item label="客户级别">
  33. <v-select
  34. v-model="queryParam.dealerLevel"
  35. ref="dealerLevel"
  36. id="salesOrderTotalList-dealerLevel"
  37. code="DEALER_LEVEL"
  38. placeholder="请选择客户级别"
  39. allowClear></v-select>
  40. </a-form-model-item>
  41. </a-col>
  42. <a-col :md="6" :sm="24">
  43. <a-form-model-item label="操作员">
  44. <a-select
  45. id="salesOrderTotalList-creatorId"
  46. allowClear
  47. v-model="queryParam.creatorId"
  48. placeholder="请选择操作员"
  49. :showSearch="true"
  50. option-filter-prop="children"
  51. :filter-option="filterOption">
  52. <a-select-option v-for="item in operatorList" :key="item.sn" :value="item.sn">{{ item.name }}</a-select-option>
  53. </a-select>
  54. </a-form-model-item>
  55. </a-col>
  56. <a-col :md="5" :sm="24">
  57. <a-form-model-item label="所在区域">
  58. <subarea id="salesOrderTotalList-subareaSn" v-model="queryParam.subareaSn"></subarea>
  59. </a-form-model-item>
  60. </a-col>
  61. <a-col :md="5" :sm="24">
  62. <a-form-model-item label="地区">
  63. <a-form-model-item prop="dealerProvinceSn" style="margin: 0;">
  64. <a-select v-model="queryParam.dealerProvinceSn" allowClear placeholder="请选择省">
  65. <a-select-option v-for="item in addrProvinceList" :value="item.id" :key="item.id + 'a'">{{ item.name }}</a-select-option>
  66. </a-select>
  67. </a-form-model-item>
  68. </a-form-model-item>
  69. </a-col>
  70. </template>
  71. <a-col :md="8" :sm="24" style="margin-bottom: 10px;">
  72. <a-button
  73. type="primary"
  74. class="button-info"
  75. size="small"
  76. @click="handleStock"
  77. id="salesOrderTotalList-stockDate">盘点区间日期</a-button>
  78. <a-button style="margin-left: 5px" type="primary" @click="handleSearch" :disabled="disabled" id="salesOrderTotalList-refresh">查询</a-button>
  79. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="salesOrderTotalList-reset">重置</a-button>
  80. <a-button
  81. style="margin-left: 10px"
  82. type="primary"
  83. class="button-warning"
  84. @click="handleExport"
  85. :disabled="disabled"
  86. :loading="exportLoading"
  87. v-if="$hasPermissions('B_salesOrderTotalExport')"
  88. id="salesOrderTotalList-export">导出</a-button>
  89. <a @click="advanced=!advanced" style="margin-left: 5px">
  90. {{ advanced ? '收起' : '展开' }}
  91. <a-icon :type="advanced ? 'up' : 'down'"/>
  92. </a>
  93. </a-col>
  94. </a-row>
  95. </a-form-model>
  96. </div>
  97. <!-- 列表 -->
  98. <s-table
  99. class="sTable"
  100. ref="table"
  101. size="small"
  102. :rowKey="(record) => record.id"
  103. :columns="columns"
  104. :data="loadData"
  105. :scroll="{ x: 1990 }"
  106. :defaultLoadData="false"
  107. bordered>
  108. <template slot="footer">
  109. <a-row :gutter="15">
  110. <a-col :md="4" :sm="24">数量:{{ (totalData && (totalData.totalQty || totalData.totalQty==0)) ? totalData.totalQty : '--' }}</a-col>
  111. <a-col :md="4" :sm="24" v-if="$hasPermissions('B_isShowPrice')">实售价:{{ (totalData && (totalData.totalRealSaleAmount || totalData.totalRealSaleAmount==0)) ? totalData.totalRealSaleAmount : '--' }}</a-col>
  112. <a-col :md="4" :sm="24" v-if="$hasPermissions('B_isShowPrice')">开单价:{{ (totalData && (totalData.totalAmount || totalData.totalAmount==0)) ? totalData.totalAmount : '--' }}</a-col>
  113. <a-col :md="4" :sm="24" v-if="$hasPermissions('B_isShowCost')">成本:{{ (totalData && (totalData.totalCost || totalData.totalCost==0)) ? totalData.totalCost : '--' }}</a-col>
  114. <a-col :md="4" :sm="24" v-if="$hasPermissions('B_isShowCost')">毛利:{{ (totalData && (totalData.grossProfit || totalData.grossProfit==0)) ? totalData.grossProfit : '--' }}</a-col>
  115. <a-col :md="4" :sm="24" v-if="$hasPermissions('B_isShowPrice')">返利:{{ (totalData && (totalData.rebateAmount || totalData.rebateAmount==0)) ? totalData.rebateAmount : '--' }}</a-col>
  116. <a-col :md="4" :sm="24" v-if="$hasPermissions('B_isShowPrice')">折扣金额:{{ (totalData && (totalData.totalDiscountAmount || totalData.totalDiscountAmount==0)) ? totalData.totalDiscountAmount : '--' }}</a-col>
  117. <a-col :md="4" :sm="24" v-if="$hasPermissions('B_isShowPrice')">折后金额:{{ (totalData && (totalData.totalDiscountedAmount || totalData.totalDiscountedAmount==0)) ? totalData.totalDiscountedAmount : '--' }}</a-col>
  118. </a-row>
  119. </template>
  120. </s-table>
  121. </a-spin>
  122. </a-card>
  123. </template>
  124. <script>
  125. import getDate from '@/libs/getDate.js'
  126. import { STable, VSelect } from '@/components'
  127. import rangeDateTime from '@/views/common/rangeDateTime.vue'
  128. import subarea from '@/views/common/subarea.js'
  129. import custList from '@/views/common/custList.vue'
  130. import { getArea } from '@/api/data'
  131. import { hdExportExcel } from '@/libs/exportExcel'
  132. import { userQueryList } from '@/api/power-user'
  133. import { reportSalesBillList, reportSalesBillCount, reportSalesBillExport } from '@/api/reportData'
  134. export default {
  135. components: { STable, VSelect, rangeDateTime, custList, subarea },
  136. data () {
  137. return {
  138. spinning: false,
  139. advanced: false, // 高级搜索 展开/关闭
  140. tableHeight: 0,
  141. queryParam: { // 查询条件
  142. time: [
  143. getDate.getCurrMonthDays().starttime + ' 00:00:00',
  144. getDate.getCurrMonthDays().endtime + ' 23:59:59'
  145. ],
  146. beginDate: getDate.getCurrMonthDays().starttime + ' 00:00:00',
  147. endDate: getDate.getCurrMonthDays().endtime + ' 23:59:59',
  148. salesBillNo: '',
  149. dealerName: '',
  150. dealerLevel: undefined,
  151. creatorId: undefined,
  152. subareaSn: undefined,
  153. dealerProvinceSn: undefined
  154. },
  155. rules: {
  156. 'time': [{ required: true, message: '请选择销售日期', trigger: 'change' }]
  157. },
  158. disabled: false, // 查询、重置按钮是否可操作
  159. exportLoading: false,
  160. // 加载数据方法 必须为 Promise 对象
  161. loadData: parameter => {
  162. this.disabled = true
  163. this.spinning = true
  164. const params = Object.assign(parameter, this.queryParam)
  165. return reportSalesBillList(params).then(res => {
  166. let data
  167. if (res.status == 200) {
  168. data = res.data
  169. this.getCount(params)
  170. const no = (data.pageNo - 1) * data.pageSize
  171. for (var i = 0; i < data.list.length; i++) {
  172. data.list[i].no = no + i + 1
  173. }
  174. this.disabled = false
  175. }
  176. this.spinning = false
  177. return data
  178. })
  179. },
  180. totalData: null,
  181. operatorList: [], // 操作员下拉数据
  182. addrProvinceList: [] // 省下拉
  183. }
  184. },
  185. computed: {
  186. columns () {
  187. const arr = [
  188. { title: '销售单号', dataIndex: 'salesBillNo', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  189. { title: '开单日期', dataIndex: 'createDate', width: 130, align: 'center', customRender: function (text) { return text || '--' } },
  190. { title: '销售日期', dataIndex: 'auditDate', width: 130, align: 'center', customRender: function (text) { return text || '--' } },
  191. { title: '客户名称', dataIndex: 'dealerName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  192. { title: '客户级别', dataIndex: 'dealerLevelDictValue', width: 120, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  193. { title: '直接绑定客户名称', dataIndex: 'directDealerName', width: 120, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  194. { title: '间接绑定客户名称', dataIndex: 'indirectDealerName', width: 120, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  195. { title: '总数量', dataIndex: 'totalQty', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  196. // { title: '实售价', dataIndex: 'totalRealSaleAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  197. // { title: '开单价', dataIndex: 'totalAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  198. // { title: '成本价', dataIndex: 'totalCost', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  199. // { title: '毛利', dataIndex: 'grossProfit', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  200. // { title: '省级价', dataIndex: 'totalProvinceAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  201. // { title: '市级价', dataIndex: 'totalCityAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  202. // { title: '特约加盟店价', dataIndex: 'totalSpecialAmount', width: 90, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  203. // { title: '直接差价', dataIndex: 'directRebateAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  204. // { title: '间接差价', dataIndex: 'indirectRebateAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  205. // { title: '返利', dataIndex: 'rebateAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  206. // { title: '折扣金额', dataIndex: 'totalDiscountAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  207. // { title: '折后金额', dataIndex: 'totalDiscountedAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  208. { title: '操作员', dataIndex: 'operatorName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true }
  209. ]
  210. if (this.$hasPermissions('B_isShowCost')) { // 成本价权限
  211. const ind = this.$hasPermissions('B_isShowPrice') ? 10 : 8
  212. arr.splice(ind, 0, { title: '成本价', dataIndex: 'totalCost', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  213. arr.splice(ind + 1, 0, { title: '毛利', dataIndex: 'grossProfit', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  214. }
  215. if (this.$hasPermissions('B_isShowPrice')) { // 售价权限
  216. const ind = this.$hasPermissions('B_isShowCost') ? 12 : 10
  217. arr.splice(8, 0, { title: '实售价', dataIndex: 'totalRealSaleAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  218. arr.splice(9, 0, { title: '开单价', dataIndex: 'totalAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  219. arr.splice(ind, 0, { title: '省级价', dataIndex: 'totalProvinceAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  220. arr.splice(ind + 1, 0, { title: '市级价', dataIndex: 'totalCityAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  221. arr.splice(ind + 2, 0, { title: '特约加盟店价', dataIndex: 'totalSpecialAmount', width: 90, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  222. arr.splice(ind + 3, 0, { title: '直接差价', dataIndex: 'directRebateAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  223. arr.splice(ind + 4, 0, { title: '间接差价', dataIndex: 'indirectRebateAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  224. arr.splice(ind + 5, 0, { title: '返利', dataIndex: 'rebateAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  225. arr.splice(ind + 6, 0, { title: '折扣金额', dataIndex: 'totalDiscountAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  226. arr.splice(ind + 7, 0, { title: '折后金额', dataIndex: 'totalDiscountedAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  227. }
  228. return arr
  229. }
  230. },
  231. methods: {
  232. // 盘点库存日期
  233. handleStock () {
  234. this.$message.info('无盘点区间的起始/终止时间,请自行选择日期区间查询!')
  235. },
  236. // 总计
  237. getCount (params) {
  238. reportSalesBillCount(params).then(res => {
  239. if (res.status == 200 && res.data) {
  240. this.totalData = res.data
  241. } else {
  242. this.totalData = null
  243. }
  244. })
  245. },
  246. handleSearch () {
  247. const _this = this
  248. this.$refs.ruleForm.validate(valid => {
  249. if (valid) {
  250. _this.$refs.table.refresh(true)
  251. } else {
  252. return false
  253. }
  254. })
  255. },
  256. // 创建时间 change
  257. dateChange (date) {
  258. if (date[0] && date[1]) {
  259. this.queryParam.time = date
  260. } else {
  261. this.queryParam.time = []
  262. }
  263. this.queryParam.beginDate = date[0] || ''
  264. this.queryParam.endDate = date[1] || ''
  265. },
  266. custChange (val) {
  267. this.queryParam.dealerSn = val.key
  268. },
  269. // 重置
  270. resetSearchForm () {
  271. this.queryParam.time = [
  272. getDate.getCurrMonthDays().starttime + ' 00:00:00',
  273. getDate.getCurrMonthDays().endtime + ' 23:59:59'
  274. ]
  275. this.$refs.rangeDate.resetDate(this.queryParam.time)
  276. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime + ' 00:00:00'
  277. this.queryParam.endDate = getDate.getCurrMonthDays().endtime + ' 23:59:59'
  278. this.queryParam.salesBillNo = ''
  279. this.queryParam.dealerName = ''
  280. this.queryParam.dealerLevel = undefined
  281. this.queryParam.creatorId = undefined
  282. this.queryParam.subareaSn = undefined
  283. this.queryParam.dealerProvinceSn = undefined
  284. this.totalData = null
  285. this.$refs.ruleForm.resetFields()
  286. this.$refs.table.clearTable()
  287. },
  288. // 导出
  289. handleExport () {
  290. const _this = this
  291. this.$refs.ruleForm.validate(valid => {
  292. if (valid) {
  293. const params = _this.queryParam
  294. _this.exportLoading = true
  295. _this.spinning = true
  296. hdExportExcel(reportSalesBillExport, params, '销售(开单统计)报表', function () {
  297. _this.exportLoading = false
  298. _this.spinning = false
  299. })
  300. } else {
  301. return false
  302. }
  303. })
  304. },
  305. filterOption (input, option) {
  306. return (
  307. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  308. )
  309. },
  310. // 操作员
  311. getUserList () {
  312. userQueryList({}).then(res => {
  313. if (res.status == 200) {
  314. this.operatorList = res.data
  315. } else {
  316. this.operatorList = []
  317. }
  318. })
  319. },
  320. // 省/市/区
  321. getArea (leve, sn) {
  322. let params
  323. if (leve == 'province') {
  324. params = { type: '2' }
  325. } else {
  326. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  327. }
  328. getArea(params).then(res => {
  329. if (res.status == 200) {
  330. if (leve == 'province') {
  331. this.addrProvinceList = res.data || []
  332. } else if (leve == 'city') {
  333. this.addrCityList = res.data || []
  334. } else if (leve == 'district') {
  335. this.addrDistrictList = res.data || []
  336. }
  337. } else {
  338. if (leve == 'province') {
  339. this.addrProvinceList = []
  340. } else if (leve == 'city') {
  341. this.addrCityList = []
  342. } else if (leve == 'district') {
  343. this.addrDistrictList = []
  344. }
  345. }
  346. })
  347. },
  348. pageInit () {
  349. this.getUserList()
  350. this.getArea('province')
  351. }
  352. },
  353. mounted () {
  354. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  355. this.pageInit()
  356. this.resetSearchForm()
  357. }
  358. },
  359. activated () {
  360. // 如果是新页签打开,则重置当前页面
  361. if (this.$store.state.app.isNewTab) {
  362. this.pageInit()
  363. this.resetSearchForm()
  364. }
  365. },
  366. beforeRouteEnter (to, from, next) {
  367. next(vm => {})
  368. }
  369. }
  370. </script>