list.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  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. subareaSn: undefined,
  173. subareaAreaSn: undefined,
  174. dealerProvinceSn: undefined,
  175. dealerCitySn: undefined,
  176. dealerCountySn: undefined
  177. },
  178. productType: [],
  179. rules: {
  180. 'time': [{ required: true, message: '请选择销售日期', trigger: 'change' }]
  181. },
  182. disabled: false, // 查询、重置按钮是否可操作
  183. exportLoading: false,
  184. // 加载数据方法 必须为 Promise 对象
  185. loadData: parameter => {
  186. this.disabled = true
  187. this.spinning = true
  188. const params = Object.assign(parameter, this.queryParam)
  189. return reportSalesBillDetailList(params).then(res => {
  190. let data
  191. if (res.status == 200) {
  192. data = res.data
  193. this.getCount(params)
  194. const no = (data.pageNo - 1) * data.pageSize
  195. for (var i = 0; i < data.list.length; i++) {
  196. data.list[i].no = no + i + 1
  197. }
  198. this.disabled = false
  199. }
  200. this.spinning = false
  201. return data
  202. })
  203. },
  204. totalData: null
  205. }
  206. },
  207. computed: {
  208. columns () {
  209. const _this = this
  210. const arr = [
  211. { title: '区域', dataIndex: 'subareaNames', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  212. { title: '销售单号', dataIndex: 'salesBillNo', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  213. { title: '省份', dataIndex: 'dealerProvinceName', width: 90, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  214. { title: '客户名称', dataIndex: 'dealerName', width: 100, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  215. { title: '客户级别', dataIndex: 'dealerLevelDictValue', width: 120, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  216. { title: '直接绑定客户名称', dataIndex: 'directDealerName', width: 120, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  217. { title: '间接绑定客户名称', dataIndex: 'indirectDealerName', width: 120, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  218. { title: '开单日期', dataIndex: 'createDate', width: 130, align: 'center', customRender: function (text) { return text || '--' } },
  219. { title: '销售日期', dataIndex: 'salesTime', width: 130, align: 'center', customRender: function (text) { return text || '--' } },
  220. { title: '品牌', dataIndex: 'productBrandName', width: 130, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  221. { title: '二级分类', dataIndex: 'productTypeName2', width: 130, align: 'center', customRender: function (text) { return text || '--' } },
  222. { title: '产品名称', dataIndex: 'productName', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  223. { title: '产品编码', dataIndex: 'productCode', width: 150, align: 'center', customRender: function (text) { return text || '--' } },
  224. { title: '单位', dataIndex: 'productUnit', width: 50, align: 'center', customRender: function (text) { return text || '--' } },
  225. { title: '销售数量', dataIndex: 'qty', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  226. // { title: '成本价', dataIndex: 'totalRealCost', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  227. // { title: '实售价', dataIndex: 'totalRealSaleAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  228. // { title: '开单价', dataIndex: 'totalAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  229. // { title: '市级价', dataIndex: 'totalCityAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  230. // { title: '直接差价', dataIndex: 'directRebateAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  231. // { title: '间接差价', dataIndex: 'indirectRebateAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  232. // { title: '折后单价', dataIndex: 'discountedPrice', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  233. // { title: '折扣金额', dataIndex: 'discountAmount', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  234. ]
  235. if (this.$hasPermissions('M_salesDetailsList_costPrice')) { // 成本价权限
  236. arr.splice(15, 0, { title: '成本价', dataIndex: 'totalRealCost', width: 70, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  237. }
  238. if (this.$hasPermissions('M_salesDetailsList_salesPrice')) { // 售价权限
  239. arr.push({ title: '实售价', dataIndex: 'totalRealSaleAmount', width: 70, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  240. arr.push({ title: '开单价', dataIndex: 'totalAmount', width: 70, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  241. }
  242. if (this.$hasPermissions('M_salesDetailsList_cityPrice')) { // 市级价权限
  243. arr.push({ title: '市级价', dataIndex: 'totalCityAmount', width: 70, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  244. }
  245. if (this.$hasPermissions('M_salesDetailsList_salesPrice')) { // 售价权限
  246. arr.push({ title: '直接差价', dataIndex: 'directRebateAmount', width: 70, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  247. arr.push({ title: '间接差价', dataIndex: 'indirectRebateAmount', width: 70, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  248. arr.push({ title: '折后单价', dataIndex: 'discountedPrice', width: 70, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  249. arr.push({ title: '折扣金额', dataIndex: 'discountAmount', width: 70, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  250. }
  251. arr.push({ title: '操作员', dataIndex: 'operatorName', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true })
  252. return arr
  253. }
  254. },
  255. methods: {
  256. // 盘点库存日期
  257. handleStock () {
  258. this.$message.info('无盘点区间的起始/终止时间,请自行选择日期区间查询!')
  259. },
  260. // 总计
  261. getCount (params) {
  262. reportSalesBillDetailCount(params).then(res => {
  263. if (res.status == 200 && res.data) {
  264. this.totalData = res.data
  265. } else {
  266. this.totalData = null
  267. }
  268. })
  269. },
  270. handleSearch () {
  271. const _this = this
  272. this.$refs.ruleForm.validate(valid => {
  273. if (valid) {
  274. _this.$refs.table.refresh(true)
  275. } else {
  276. _this.$message.error("请选择销售日期")
  277. return false
  278. }
  279. })
  280. },
  281. // 创建时间 change
  282. dateChange (date) {
  283. if (date[0] && date[1]) {
  284. this.queryParam.time = date
  285. } else {
  286. this.queryParam.time = []
  287. }
  288. this.queryParam.beginDate = date[0] || ''
  289. this.queryParam.endDate = date[1] || ''
  290. },
  291. custChange (val) {
  292. this.queryParam.dealerSn = val.key
  293. },
  294. subareaChange(val){
  295. this.queryParam.subareaSn = val[0] ? val[0] : undefined
  296. this.queryParam.subareaAreaSn = val[1] ? val[1] : undefined
  297. },
  298. // 重置
  299. resetSearchForm () {
  300. this.queryParam.time = [
  301. getDate.getCurrMonthDays().starttime,
  302. getDate.getCurrMonthDays().endtime
  303. ]
  304. this.$refs.rangeDate.resetDate(this.queryParam.time)
  305. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  306. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  307. this.queryParam.salesBillNo = ''
  308. this.queryParam.productCode = ''
  309. this.queryParam.productName = ''
  310. this.queryParam.dealerName = ''
  311. this.queryParam.dealerLevel = undefined
  312. this.queryParam.productBrandTypeSn = undefined
  313. this.queryParam.productBrandSn = undefined
  314. this.queryParam.productTypeSn1 = ''
  315. this.queryParam.productTypeSn2 = ''
  316. this.queryParam.productTypeSn3 = ''
  317. this.queryParam.subareaSn = undefined
  318. this.queryParam.subareaAreaSn = undefined
  319. this.queryParam.dealerProvinceSn = undefined
  320. this.queryParam.dealerCitySn = undefined
  321. this.queryParam.dealerCountySn = undefined
  322. if(this.advanced){
  323. this.$refs.subarea.clearData()
  324. this.$refs.areaList.clearData()
  325. }
  326. this.productType = []
  327. this.totalData = null
  328. this.$refs.ruleForm.resetFields()
  329. this.$refs.table.clearTable()
  330. },
  331. // 导出
  332. handleExport () {
  333. const _this = this
  334. this.$refs.ruleForm.validate(valid => {
  335. if (valid) {
  336. const params = _this.queryParam
  337. _this.$store.state.app.curActionPermission = 'B_salesDetailsExport'
  338. _this.showExport = true
  339. _this.exportLoading = true
  340. _this.spinning = true
  341. hdExportExcel(reportSalesBillDetailExport, params, '销售明细(开单统计)报表', function () {
  342. _this.exportLoading = false
  343. _this.spinning = false
  344. _this.$store.state.app.curActionPermission = ''
  345. })
  346. } else {
  347. return false
  348. }
  349. })
  350. },
  351. // 产品分类 change
  352. changeProductType (val, opt) {
  353. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  354. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  355. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  356. },
  357. areaChange(val){
  358. this.queryParam.dealerProvinceSn = val[0] ? val[0] : ''
  359. this.queryParam.dealerCitySn = val[1] ? val[1] : ''
  360. this.queryParam.dealerCountySn = val[2] ? val[2] : ''
  361. },
  362. pageInit () {
  363. this.resetSearchForm()
  364. }
  365. },
  366. mounted () {
  367. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  368. this.pageInit()
  369. }
  370. },
  371. activated () {
  372. // 如果是新页签打开,则重置当前页面
  373. if (this.$store.state.app.isNewTab) {
  374. this.pageInit()
  375. }
  376. },
  377. beforeRouteEnter (to, from, next) {
  378. next(vm => {})
  379. }
  380. }
  381. </script>