list.vue 20 KB

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