list.vue 22 KB

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