list.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. <template>
  2. <a-card size="small" :bordered="false" class="salesDetailsList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper">
  6. <a-form-model
  7. id="salesSlipReportList-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="salesDetailsList-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="salesDetailsList-productCode" v-model.trim="queryParam.productCode" 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. <a-input id="salesDetailsList-productName" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
  34. </a-form-model-item>
  35. </a-col>
  36. <a-col :md="6" :sm="24">
  37. <a-form-model-item label="客户名称">
  38. <a-input id="salesDetailsList-dealerName" v-model.trim="queryParam.dealerName" allowClear placeholder="请输入客户名称"/>
  39. </a-form-model-item>
  40. </a-col>
  41. <a-col :md="6" :sm="24">
  42. <a-form-model-item label="客户级别">
  43. <v-select
  44. v-model="queryParam.dealerLevel"
  45. ref="dealerLevel"
  46. id="salesDetailsList-dealerLevel"
  47. code="DEALER_LEVEL"
  48. placeholder="请选择客户级别"
  49. allowClear></v-select>
  50. </a-form-model-item>
  51. </a-col>
  52. <a-col :md="6" :sm="24">
  53. <a-form-model-item label="品牌分类">
  54. <v-select code="BRAND_TYPE" id="salesDetailsList-productBrandTypeSn" v-model="queryParam.productBrandTypeSn" allowClear placeholder="请选择品牌分类"></v-select>
  55. </a-form-model-item>
  56. </a-col>
  57. <a-col :md="6" :sm="24">
  58. <a-form-model-item label="产品品牌">
  59. <ProductBrand id="salesDetailsList-productBrandSn" v-model="queryParam.productBrandSn"></ProductBrand>
  60. </a-form-model-item>
  61. </a-col>
  62. <a-col :md="6" :sm="24">
  63. <a-form-model-item label="产品分类">
  64. <a-cascader
  65. @change="changeProductType"
  66. expand-trigger="hover"
  67. change-on-select
  68. :options="productTypeList"
  69. :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
  70. id="salesDetailsList-productType"
  71. placeholder="请选择产品分类"
  72. allowClear
  73. v-model="productType" />
  74. </a-form-model-item>
  75. </a-col>
  76. <a-col :md="6" :sm="24">
  77. <a-form-model-item label="所在区域">
  78. <subarea id="salesDetailsList-subareaSn" v-model="queryParam.subareaSn"></subarea>
  79. </a-form-model-item>
  80. </a-col>
  81. <a-col :md="12" :sm="24">
  82. <a-row>
  83. <a-form-model-item label="地区">
  84. <a-col span="7">
  85. <a-form-model-item prop="dealerProvinceSn" style="margin: 0;">
  86. <a-select v-model="queryParam.dealerProvinceSn" allowClear @change="getCityList" placeholder="请选择省">
  87. <a-select-option v-for="item in addrProvinceList" :value="item.id" :key="item.id + 'a'">{{ item.name }}</a-select-option>
  88. </a-select>
  89. </a-form-model-item>
  90. </a-col>
  91. <a-col span="7" offset="1">
  92. <a-form-model-item prop="dealerCitySn" style="margin: 0;">
  93. <a-select v-model="queryParam.dealerCitySn" allowClear @change="getAreaList" placeholder="请选择市">
  94. <a-select-option v-for="item in addrCityList" :value="item.id" :key="item.id + 'b'">{{ item.name }}</a-select-option>
  95. </a-select>
  96. </a-form-model-item>
  97. </a-col>
  98. <a-col span="7" offset="1">
  99. <a-form-model-item prop="dealerCountySn" style="margin: 0;">
  100. <a-select v-model="queryParam.dealerCountySn" allowClear placeholder="请选择区/县">
  101. <a-select-option v-for="item in addrDistrictList" :value="item.id" :key="item.id + 'c'">{{ item.name }}</a-select-option>
  102. </a-select>
  103. </a-form-model-item>
  104. </a-col>
  105. </a-form-model-item>
  106. </a-row>
  107. </a-col>
  108. </template>
  109. <a-col :md="8" :sm="24" style="margin-bottom: 10px;">
  110. <a-button
  111. type="primary"
  112. class="button-info"
  113. size="small"
  114. @click="handleStock"
  115. id="salesDetailsList-stockDate">盘点区间日期</a-button>
  116. <a-button style="margin-left: 5px" type="primary" @click="handleSearch" :disabled="disabled" id="salesDetailsList-refresh">查询</a-button>
  117. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="salesDetailsList-reset">重置</a-button>
  118. <a-button
  119. style="margin-left: 10px"
  120. type="primary"
  121. class="button-warning"
  122. @click="handleExport"
  123. :disabled="disabled"
  124. :loading="exportLoading"
  125. v-if="$hasPermissions('B_salesDetailsExport')"
  126. id="salesDetailsList-export">导出</a-button>
  127. <a @click="advanced=!advanced" style="margin-left: 5px">
  128. {{ advanced ? '收起' : '展开' }}
  129. <a-icon :type="advanced ? 'up' : 'down'"/>
  130. </a>
  131. </a-col>
  132. </a-row>
  133. </a-form-model>
  134. </div>
  135. <!-- 列表 -->
  136. <s-table
  137. class="sTable"
  138. ref="table"
  139. size="small"
  140. :rowKey="(record) => record.id"
  141. :columns="columns"
  142. :data="loadData"
  143. :scroll="{ x: 2720 }"
  144. :defaultLoadData="false"
  145. bordered>
  146. <template slot="footer">
  147. <a-row :gutter="15">
  148. <a-col :md="4" :sm="24">
  149. 数量:{{ (totalData && (totalData.qty || totalData.qty==0)) ? totalData.qty : '--' }}
  150. </a-col>
  151. <a-col :md="4" :sm="24">
  152. 实售价:{{ (totalData && (totalData.totalRealSaleAmount || totalData.totalRealSaleAmount==0)) ? totalData.totalRealSaleAmount : '--' }}
  153. </a-col>
  154. <a-col :md="4" :sm="24">
  155. 开单价:{{ (totalData && (totalData.totalAmount || totalData.totalAmount==0)) ? totalData.totalAmount : '--' }}
  156. </a-col>
  157. <a-col :md="4" :sm="24">
  158. 成本:{{ (totalData && (totalData.totalRealCost || totalData.totalRealCost==0)) ? totalData.totalRealCost : '--' }}
  159. </a-col>
  160. <a-col :md="4" :sm="24">
  161. 折后金额:{{ (totalData && (totalData.discountedAmount || totalData.discountedAmount==0)) ? totalData.discountedAmount : '--' }}
  162. </a-col>
  163. <a-col :md="4" :sm="24">
  164. 折扣金额:{{ (totalData && (totalData.discountAmount || totalData.discountAmount==0)) ? totalData.discountAmount : '--' }}
  165. </a-col>
  166. </a-row>
  167. </template>
  168. </s-table>
  169. </a-spin>
  170. </a-card>
  171. </template>
  172. <script>
  173. import moment from 'moment'
  174. import getDate from '@/libs/getDate.js'
  175. import { STable, VSelect } from '@/components'
  176. import rangeDateTime from '@/views/common/rangeDateTime.vue'
  177. import subarea from '@/views/common/subarea.js'
  178. import custList from '@/views/common/custList.vue'
  179. import { getArea } from '@/api/data'
  180. import { productBrandQuery } from '@/api/productBrand'
  181. import { productTypeQuery } from '@/api/productType'
  182. import ProductBrand from '@/views/common/productBrand.js'
  183. import { hdExportExcel } from '@/libs/exportExcel'
  184. import { reportSalesBillDetailList, reportSalesBillDetailCount, reportSalesBillDetailExport } from '@/api/reportData'
  185. export default {
  186. components: { STable, VSelect, rangeDateTime, custList, subarea, ProductBrand },
  187. data () {
  188. return {
  189. spinning: false,
  190. advanced: false, // 高级搜索 展开/关闭
  191. tableHeight: 0,
  192. queryParam: { // 查询条件
  193. time: [
  194. getDate.getCurrMonthDays().starttime,
  195. getDate.getCurrMonthDays().endtime
  196. ],
  197. beginDate: getDate.getCurrMonthDays().starttime,
  198. endDate: getDate.getCurrMonthDays().endtime,
  199. salesBillNo: '',
  200. productCode: '',
  201. productName: '',
  202. dealerName: '',
  203. dealerLevel: undefined,
  204. productBrandTypeSn: undefined,
  205. productBrandSn: undefined, // 产品品牌
  206. productTypeSn1: '', // 产品一级分类
  207. productTypeSn2: '', // 产品二级分类
  208. productTypeSn3: '', // 产品三级分类
  209. subareaSn: undefined,
  210. dealerProvinceSn: undefined,
  211. dealerCitySn: undefined,
  212. dealerCountySn: undefined
  213. },
  214. productType: [],
  215. rules: {
  216. 'time': [{ required: true, message: '请选择销售日期', trigger: 'change' }]
  217. },
  218. disabled: false, // 查询、重置按钮是否可操作
  219. exportLoading: false,
  220. columns: [
  221. { title: '序号', dataIndex: 'no', width: 60, align: 'center', fixed: 'left' },
  222. { title: '区域', dataIndex: 'subareaNames', width: 150, align: 'center', customRender: function (text) { return text || '--' } },
  223. { title: '销售单号', dataIndex: 'salesBillNo', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  224. { title: '省份', dataIndex: 'dealerProvinceName', width: 100, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  225. { title: '客户名称', dataIndex: 'dealerName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  226. { title: '客户级别', dataIndex: 'dealerLevelDictValue', width: 150, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  227. { title: '直接绑定客户名称', dataIndex: 'directDealerName', width: 150, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  228. { title: '间接绑定客户名称', dataIndex: 'indirectDealerName', width: 150, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  229. { title: '开单日期', dataIndex: 'createDate', width: 130, align: 'center', customRender: function (text) { return text || '--' } },
  230. { title: '销售日期', dataIndex: 'salesTime', width: 130, align: 'center', customRender: function (text) { return text || '--' } },
  231. { title: '品牌', dataIndex: 'productBrandName', width: 130, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  232. { title: '二级分类', dataIndex: 'productTypeName2', width: 130, align: 'center', customRender: function (text) { return text || '--' } },
  233. { title: '产品名称', dataIndex: 'productName', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  234. { title: '产品编码', dataIndex: 'productCode', width: 150, align: 'center', customRender: function (text) { return text || '--' } },
  235. { title: '单位', dataIndex: 'productUnit', width: 50, align: 'center', customRender: function (text) { return text || '--' } },
  236. { title: '销售数量', dataIndex: 'qty', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  237. { title: '成本价', dataIndex: 'totalRealCost', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  238. { title: '实售价', dataIndex: 'totalRealSaleAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  239. { title: '开单价', dataIndex: 'totalAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  240. { title: '市级价', dataIndex: 'totalCityAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  241. { title: '直接差价', dataIndex: 'directRebateAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  242. { title: '间接差价', dataIndex: 'indirectRebateAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  243. { title: '折后单价', dataIndex: 'discountedPrice', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  244. { title: '折扣金额', dataIndex: 'discountAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  245. { title: '操作员', dataIndex: 'operatorName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true }
  246. ],
  247. // 加载数据方法 必须为 Promise 对象
  248. loadData: parameter => {
  249. this.disabled = true
  250. this.spinning = true
  251. const params = Object.assign(parameter, this.queryParam)
  252. delete params.time
  253. return reportSalesBillDetailList(params).then(res => {
  254. this.getCount(params)
  255. const data = res.data
  256. const no = (data.pageNo - 1) * data.pageSize
  257. for (var i = 0; i < data.list.length; i++) {
  258. data.list[i].no = no + i + 1
  259. }
  260. this.disabled = false
  261. this.spinning = false
  262. return data
  263. })
  264. },
  265. totalData: null,
  266. addrProvinceList: [], // 省下拉
  267. addrCityList: [], // 市下拉
  268. addrDistrictList: [], // 区下拉
  269. productBrandList: [], // 品牌下拉数据
  270. productTypeList: [] // 分类下拉数据
  271. }
  272. },
  273. methods: {
  274. // 盘点库存日期
  275. handleStock () {
  276. this.$message.info('无盘点区间的起始/终止时间,请自行选择日期区间查询!')
  277. },
  278. // 总计
  279. getCount (params) {
  280. reportSalesBillDetailCount(params).then(res => {
  281. if (res.status == 200 && res.data) {
  282. this.totalData = res.data
  283. } else {
  284. this.totalData = null
  285. }
  286. })
  287. },
  288. handleSearch () {
  289. const _this = this
  290. this.$refs.ruleForm.validate(valid => {
  291. if (valid) {
  292. _this.$refs.table.refresh(true)
  293. } else {
  294. return false
  295. }
  296. })
  297. },
  298. // 创建时间 change
  299. dateChange (date) {
  300. this.queryParam.time = date
  301. this.queryParam.beginDate = date[0] || ''
  302. this.queryParam.endDate = date[1] || ''
  303. },
  304. custChange (val) {
  305. this.queryParam.dealerSn = val.key
  306. },
  307. // 重置
  308. resetSearchForm () {
  309. this.queryParam.time = [
  310. getDate.getCurrMonthDays().starttime,
  311. getDate.getCurrMonthDays().endtime
  312. ]
  313. this.$refs.rangeDate.resetDate(this.queryParam.time)
  314. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  315. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  316. this.queryParam.salesBillNo = ''
  317. this.queryParam.productCode = ''
  318. this.queryParam.productName = ''
  319. this.queryParam.dealerName = ''
  320. this.queryParam.dealerLevel = undefined
  321. this.queryParam.productBrandTypeSn = undefined
  322. this.queryParam.productBrandSn = undefined
  323. this.queryParam.productTypeSn1 = ''
  324. this.queryParam.productTypeSn2 = ''
  325. this.queryParam.productTypeSn3 = ''
  326. this.queryParam.subareaSn = undefined
  327. this.queryParam.dealerProvinceSn = undefined
  328. this.queryParam.dealerCitySn = undefined
  329. this.queryParam.dealerCountySn = undefined
  330. this.productType = []
  331. this.totalData = null
  332. this.$refs.ruleForm.resetFields()
  333. this.$refs.table.clearTable()
  334. },
  335. // 导出
  336. handleExport () {
  337. const _this = this
  338. const params = this.queryParam
  339. this.exportLoading = true
  340. this.spinning = true
  341. hdExportExcel(reportSalesBillDetailExport, params, '销售明细(开单统计)报表', function () {
  342. _this.exportLoading = false
  343. _this.spinning = false
  344. })
  345. },
  346. filterOption (input, option) {
  347. return (
  348. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  349. )
  350. },
  351. // 产品分类 change
  352. changeProductType (val, opt) {
  353. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  354. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  355. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  356. },
  357. // 产品品牌 列表
  358. getProductBrand () {
  359. productBrandQuery({}).then(res => {
  360. if (res.status == 200) {
  361. this.productBrandList = res.data
  362. } else {
  363. this.productBrandList = []
  364. }
  365. })
  366. },
  367. // 产品分类 列表
  368. getProductType () {
  369. productTypeQuery({}).then(res => {
  370. if (res.status == 200) {
  371. this.productTypeList = res.data
  372. } else {
  373. this.productTypeList = []
  374. }
  375. })
  376. },
  377. // 获取城市列表
  378. getCityList (val) {
  379. this.addrCityList = []
  380. this.addrDistrictList = []
  381. this.queryParam.dealerCitySn = undefined
  382. this.queryParam.dealerCountySn = undefined
  383. if (val) {
  384. this.getArea('city', val)
  385. }
  386. },
  387. // 获取区县列表
  388. getAreaList (val) {
  389. this.addrDistrictList = []
  390. this.queryParam.dealerCountySn = undefined
  391. if (val) {
  392. this.getArea('district', val)
  393. }
  394. },
  395. // 省/市/区
  396. getArea (leve, sn) {
  397. let params
  398. if (leve == 'province') {
  399. params = { type: '2' }
  400. } else {
  401. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  402. }
  403. getArea(params).then(res => {
  404. if (res.status == 200) {
  405. if (leve == 'province') {
  406. this.addrProvinceList = res.data || []
  407. } else if (leve == 'city') {
  408. this.addrCityList = res.data || []
  409. } else if (leve == 'district') {
  410. this.addrDistrictList = res.data || []
  411. }
  412. } else {
  413. if (leve == 'province') {
  414. this.addrProvinceList = []
  415. } else if (leve == 'city') {
  416. this.addrCityList = []
  417. } else if (leve == 'district') {
  418. this.addrDistrictList = []
  419. }
  420. }
  421. })
  422. },
  423. pageInit () {
  424. this.getProductBrand()
  425. this.getProductType()
  426. this.getArea('province')
  427. }
  428. },
  429. mounted () {
  430. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  431. this.pageInit()
  432. this.resetSearchForm()
  433. }
  434. },
  435. activated () {
  436. // 如果是新页签打开,则重置当前页面
  437. if (this.$store.state.app.isNewTab) {
  438. this.pageInit()
  439. this.resetSearchForm()
  440. }
  441. },
  442. beforeRouteEnter (to, from, next) {
  443. next(vm => {})
  444. }
  445. }
  446. </script>