list.vue 22 KB

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