list.vue 20 KB

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