list.vue 20 KB

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