list.vue 21 KB

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