list.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  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: 2480 }"
  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 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 + ' 00:00:00',
  194. getDate.getCurrMonthDays().endtime + ' 23:59:59'
  195. ],
  196. beginDate: getDate.getCurrMonthDays().starttime + ' 00:00:00',
  197. endDate: getDate.getCurrMonthDays().endtime + ' 23:59:59',
  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: 'subareaNames', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  221. { title: '销售单号', dataIndex: 'salesBillNo', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  222. { title: '省份', dataIndex: 'dealerProvinceName', width: 90, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  223. { title: '客户名称', dataIndex: 'dealerName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  224. { title: '客户级别', dataIndex: 'dealerLevelDictValue', width: 120, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  225. { title: '直接绑定客户名称', dataIndex: 'directDealerName', width: 120, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  226. { title: '间接绑定客户名称', dataIndex: 'indirectDealerName', width: 120, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  227. { title: '开单日期', dataIndex: 'createDate', width: 130, align: 'center', customRender: function (text) { return text || '--' } },
  228. { title: '销售日期', dataIndex: 'salesTime', width: 130, align: 'center', customRender: function (text) { return text || '--' } },
  229. { title: '品牌', dataIndex: 'productBrandName', width: 130, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  230. { title: '二级分类', dataIndex: 'productTypeName2', width: 130, align: 'center', customRender: function (text) { return text || '--' } },
  231. { title: '产品名称', dataIndex: 'productName', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  232. { title: '产品编码', dataIndex: 'productCode', width: 150, align: 'center', customRender: function (text) { return text || '--' } },
  233. { title: '单位', dataIndex: 'productUnit', width: 50, align: 'center', customRender: function (text) { return text || '--' } },
  234. { title: '销售数量', dataIndex: 'qty', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  235. { title: '成本价', dataIndex: 'totalRealCost', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  236. { title: '实售价', dataIndex: 'totalRealSaleAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  237. { title: '开单价', dataIndex: 'totalAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  238. { title: '市级价', dataIndex: 'totalCityAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  239. { title: '直接差价', dataIndex: 'directRebateAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  240. { title: '间接差价', dataIndex: 'indirectRebateAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  241. { title: '折后单价', dataIndex: 'discountedPrice', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  242. { title: '折扣金额', dataIndex: 'discountAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  243. { title: '操作员', dataIndex: 'operatorName', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true }
  244. ],
  245. // 加载数据方法 必须为 Promise 对象
  246. loadData: parameter => {
  247. this.disabled = true
  248. this.spinning = true
  249. const params = Object.assign(parameter, this.queryParam)
  250. delete params.time
  251. return reportSalesBillDetailList(params).then(res => {
  252. this.getCount(params)
  253. const data = res.data
  254. const no = (data.pageNo - 1) * data.pageSize
  255. for (var i = 0; i < data.list.length; i++) {
  256. data.list[i].no = no + i + 1
  257. }
  258. this.disabled = false
  259. this.spinning = false
  260. return data
  261. })
  262. },
  263. totalData: null,
  264. addrProvinceList: [], // 省下拉
  265. addrCityList: [], // 市下拉
  266. addrDistrictList: [], // 区下拉
  267. productBrandList: [], // 品牌下拉数据
  268. productTypeList: [] // 分类下拉数据
  269. }
  270. },
  271. methods: {
  272. // 盘点库存日期
  273. handleStock () {
  274. this.$message.info('无盘点区间的起始/终止时间,请自行选择日期区间查询!')
  275. },
  276. // 总计
  277. getCount (params) {
  278. reportSalesBillDetailCount(params).then(res => {
  279. if (res.status == 200 && res.data) {
  280. this.totalData = res.data
  281. } else {
  282. this.totalData = null
  283. }
  284. })
  285. },
  286. handleSearch () {
  287. const _this = this
  288. this.$refs.ruleForm.validate(valid => {
  289. if (valid) {
  290. _this.$refs.table.refresh(true)
  291. } else {
  292. return false
  293. }
  294. })
  295. },
  296. // 创建时间 change
  297. dateChange (date) {
  298. this.queryParam.time = date
  299. this.queryParam.beginDate = date[0] || ''
  300. this.queryParam.endDate = date[1] || ''
  301. },
  302. custChange (val) {
  303. this.queryParam.dealerSn = val.key
  304. },
  305. // 重置
  306. resetSearchForm () {
  307. this.queryParam.time = [
  308. getDate.getCurrMonthDays().starttime + ' 00:00:00',
  309. getDate.getCurrMonthDays().endtime + ' 23:59:59'
  310. ]
  311. this.$refs.rangeDate.resetDate(this.queryParam.time)
  312. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime + ' 00:00:00'
  313. this.queryParam.endDate = getDate.getCurrMonthDays().endtime + ' 23:59:59'
  314. this.queryParam.salesBillNo = ''
  315. this.queryParam.productCode = ''
  316. this.queryParam.productName = ''
  317. this.queryParam.dealerName = ''
  318. this.queryParam.dealerLevel = undefined
  319. this.queryParam.productBrandTypeSn = undefined
  320. this.queryParam.productBrandSn = undefined
  321. this.queryParam.productTypeSn1 = ''
  322. this.queryParam.productTypeSn2 = ''
  323. this.queryParam.productTypeSn3 = ''
  324. this.queryParam.subareaSn = undefined
  325. this.queryParam.dealerProvinceSn = undefined
  326. this.queryParam.dealerCitySn = undefined
  327. this.queryParam.dealerCountySn = undefined
  328. this.productType = []
  329. this.totalData = null
  330. this.$refs.ruleForm.resetFields()
  331. this.$refs.table.clearTable()
  332. },
  333. // 导出
  334. handleExport () {
  335. const _this = this
  336. const params = this.queryParam
  337. this.exportLoading = true
  338. this.spinning = true
  339. hdExportExcel(reportSalesBillDetailExport, params, '销售明细(开单统计)报表', function () {
  340. _this.exportLoading = false
  341. _this.spinning = false
  342. })
  343. },
  344. filterOption (input, option) {
  345. return (
  346. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  347. )
  348. },
  349. // 产品分类 change
  350. changeProductType (val, opt) {
  351. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  352. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  353. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  354. },
  355. // 产品品牌 列表
  356. getProductBrand () {
  357. productBrandQuery({}).then(res => {
  358. if (res.status == 200) {
  359. this.productBrandList = res.data
  360. } else {
  361. this.productBrandList = []
  362. }
  363. })
  364. },
  365. // 产品分类 列表
  366. getProductType () {
  367. productTypeQuery({}).then(res => {
  368. if (res.status == 200) {
  369. this.productTypeList = res.data
  370. } else {
  371. this.productTypeList = []
  372. }
  373. })
  374. },
  375. // 获取城市列表
  376. getCityList (val) {
  377. this.addrCityList = []
  378. this.addrDistrictList = []
  379. this.queryParam.dealerCitySn = undefined
  380. this.queryParam.dealerCountySn = undefined
  381. if (val) {
  382. this.getArea('city', val)
  383. }
  384. },
  385. // 获取区县列表
  386. getAreaList (val) {
  387. this.addrDistrictList = []
  388. this.queryParam.dealerCountySn = undefined
  389. if (val) {
  390. this.getArea('district', val)
  391. }
  392. },
  393. // 省/市/区
  394. getArea (leve, sn) {
  395. let params
  396. if (leve == 'province') {
  397. params = { type: '2' }
  398. } else {
  399. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  400. }
  401. getArea(params).then(res => {
  402. if (res.status == 200) {
  403. if (leve == 'province') {
  404. this.addrProvinceList = res.data || []
  405. } else if (leve == 'city') {
  406. this.addrCityList = res.data || []
  407. } else if (leve == 'district') {
  408. this.addrDistrictList = res.data || []
  409. }
  410. } else {
  411. if (leve == 'province') {
  412. this.addrProvinceList = []
  413. } else if (leve == 'city') {
  414. this.addrCityList = []
  415. } else if (leve == 'district') {
  416. this.addrDistrictList = []
  417. }
  418. }
  419. })
  420. },
  421. pageInit () {
  422. this.getProductBrand()
  423. this.getProductType()
  424. this.getArea('province')
  425. }
  426. },
  427. mounted () {
  428. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  429. this.pageInit()
  430. this.resetSearchForm()
  431. }
  432. },
  433. activated () {
  434. // 如果是新页签打开,则重置当前页面
  435. if (this.$store.state.app.isNewTab) {
  436. this.pageInit()
  437. this.resetSearchForm()
  438. }
  439. },
  440. beforeRouteEnter (to, from, next) {
  441. next(vm => {})
  442. }
  443. }
  444. </script>