list.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <template>
  2. <a-spin :spinning="spinning" tip="Loading...">
  3. <a-alert :show-icon="false" type="error" message="注:销售单报表包含急件销售数量、售价,销售明细报表不包含急件销售数量、成本、售价" banner style="margin-bottom: 10px;" />
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper">
  6. <a-form-model
  7. id="salesReportList-form"
  8. ref="ruleForm"
  9. class="form-model-con"
  10. layout="inline"
  11. :model="queryParam"
  12. :rules="rules"
  13. :labelCol="labelCol"
  14. :wrapperCol="wrapperCol"
  15. @keyup.enter.native="handleSearch" >
  16. <a-row :gutter="15">
  17. <a-col :md="6" :sm="24">
  18. <a-form-model-item label="创建时间">
  19. <rangeDate id="salesReportList-creatDate" ref="creatDate" v-model="creatTime" @change="creatDateChange" />
  20. </a-form-model-item>
  21. </a-col>
  22. <template v-if="advanced">
  23. <a-col :md="6" :sm="24">
  24. <a-form-model-item label="客户名称">
  25. <custList id="salesReportList-salesTargetName" ref="custSatelliteList" @change="custSatelliteChange"></custList>
  26. </a-form-model-item>
  27. </a-col>
  28. <a-col :md="6" :sm="24">
  29. <a-form-item label="客户类型">
  30. <custType id="salesReportList-salesTargetType" v-model="queryParam.salesTargetType" allowClear placeholder="请选择客户类型"></custType>
  31. </a-form-item>
  32. </a-col>
  33. <a-col :md="6" :sm="24">
  34. <a-form-model-item label="收款方式">
  35. <v-select
  36. code="SETTLE_STYLE"
  37. id="salesReportList-settleStyleSn"
  38. v-model="queryParam.settleStyleSn"
  39. allowClear
  40. placeholder="请选择收款方式"
  41. ></v-select>
  42. </a-form-model-item>
  43. </a-col>
  44. <a-col :md="6" :sm="24">
  45. <a-form-model-item label="审核时间">
  46. <rangeDate id="salesReportList-rangeDate" ref="rangeDate" v-model="time" @change="dateChange" />
  47. </a-form-model-item>
  48. </a-col>
  49. <a-col :md="6" :sm="24">
  50. <a-form-model-item label="业务员">
  51. <a-input id="salesReportList-salesManName" v-model.trim="queryParam.salesManName" allowClear placeholder="请输入业务员"/>
  52. </a-form-model-item>
  53. </a-col>
  54. <a-col :md="6" :sm="24">
  55. <a-form-model-item label="单号">
  56. <a-input id="salesReportList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入单号"/>
  57. </a-form-model-item>
  58. </a-col>
  59. <a-col :md="6" :sm="24">
  60. <a-form-item label="客户所在区">
  61. <AreaList id="salesReportList-areaList" changeOnSelect ref="areaList" @change="areaChange"></AreaList>
  62. </a-form-item>
  63. </a-col>
  64. <a-col :md="6" :sm="24">
  65. <a-form-item label="出库时间">
  66. <rangeDate id="salesReportList-outWareTime" ref="outWareRangeDate" v-model="outWareTime" @change="outWareDateChange" />
  67. </a-form-item>
  68. </a-col>
  69. </template>
  70. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  71. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="salesReportList-refresh">查询</a-button>
  72. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="salesReportList-reset">重置</a-button>
  73. <a-button
  74. type="primary"
  75. style="margin-left: 5px"
  76. @click="handleExport"
  77. :disabled="disabled"
  78. :loading="exportLoading"
  79. v-if="$hasPermissions('B_salesReportExport')"
  80. class="button-warning"
  81. id="salesReportList-export-btn">导出</a-button>
  82. <a @click="advanced=!advanced" style="margin-left: 5px" id="salesReportList-advanced">
  83. {{ advanced ? '收起' : '展开' }}
  84. <a-icon :type="advanced ? 'up' : 'down'"/>
  85. </a>
  86. </a-col>
  87. </a-row>
  88. </a-form-model>
  89. </div>
  90. <!-- 合计 -->
  91. <a-alert type="info" style="margin-bottom:10px">
  92. <div class="ftext" slot="message">
  93. 总单数:<strong>{{ (totalData && (totalData.totalRowSize || totalData.totalRowSize==0)) ? totalData.totalRowSize : '--' }}</strong>;
  94. 产品总数量:<strong>{{ (totalData && (totalData.totalQty || totalData.totalQty==0)) ? totalData.totalQty : '--' }}</strong>;
  95. <div style="display: inline-block;" v-if="$hasPermissions('M_ShowAllCost')">
  96. 总成本:<strong>{{ (totalData && (totalData.totalCost || totalData.totalCost==0)) ? toThousands(totalData.totalCost) : '--' }}</strong>;
  97. </div>
  98. 总售价:<strong>{{ (totalData && (totalData.totalAmount || totalData.totalAmount==0)) ? toThousands(totalData.totalAmount) : '--' }}</strong>;
  99. 折后总售价:<strong>{{ (totalData && (totalData.discountedAmount || totalData.discountedAmount==0)) ? toThousands(totalData.discountedAmount) : '--' }}</strong>;
  100. <div style="display: inline-block;" v-if="$hasPermissions('M_ShowAllCost')">
  101. 总毛利:<strong>{{ (totalData && (totalData.totalProfit || totalData.totalProfit==0)) ? toThousands(totalData.totalProfit) : '--' }}</strong>。
  102. </div>
  103. </div>
  104. </a-alert>
  105. <!-- 列表 -->
  106. <s-table
  107. class="sTable"
  108. ref="table"
  109. size="small"
  110. :rowKey="(record) => record.no"
  111. rowKeyName="no"
  112. :columns="columns"
  113. :data="loadData"
  114. :defaultLoadData="false"
  115. bordered>
  116. </s-table>
  117. </a-spin>
  118. </template>
  119. <script>
  120. import { commonMixin } from '@/utils/mixin'
  121. import { STable, VSelect } from '@/components'
  122. import rangeDate from '@/views/common/rangeDate.vue'
  123. import { downloadExcel } from '@/libs/JGPrint.js'
  124. import custType from '@/views/common/custType.js'
  125. import AreaList from '@/views/common/areaList.js'
  126. import custList from '@/views/common/custList.vue'
  127. import { reportSalesBillList, reportSalesBillCount, reportSalesBillExport } from '@/api/reportData'
  128. export default {
  129. components: { STable, VSelect, rangeDate, custList, AreaList, custType },
  130. mixins: [commonMixin],
  131. data () {
  132. return {
  133. spinning: false,
  134. labelCol: { span: 8 },
  135. wrapperCol: { span: 16 },
  136. advanced: false, // 高级搜索 展开/关闭
  137. tableHeight: 0,
  138. queryParam: { // 查询条件
  139. createBeginDate: '', // 创建开始时间
  140. createEndDate: '', // 创建结束时间
  141. beginDate: '', // 审核开始时间
  142. endDate: '', // 审核结束时间
  143. outWarehouseBeginDate: '', // 出库开始时间
  144. outWarehouseEndDate: '', // 出库结束时间
  145. buyerNameCurrent: undefined, // 客户名称
  146. buyerSnCurrent: undefined, // 客户sn
  147. salesTargetType: undefined, // 客户类型
  148. provinceSn: undefined, // 省
  149. citySn: undefined, // 市
  150. countySn: undefined, // 区
  151. settleStyleSn: undefined,
  152. salesBillNo: '', // 销售单号
  153. salesManName: '' // 销售人员
  154. },
  155. creatTime: [], // 创建时间
  156. time: [], // 审核时间
  157. outWareTime: [], // 出库时间
  158. rules: {
  159. 'time': [{ required: true, message: '请选择审核时间', trigger: 'change' }]
  160. },
  161. disabled: false, // 查询、重置按钮是否可操作
  162. exportLoading: false,
  163. // 加载数据方法 必须为 Promise 对象
  164. loadData: parameter => {
  165. this.disabled = true
  166. const params = Object.assign(parameter, this.queryParam)
  167. this.spinning = true
  168. delete params.time
  169. return reportSalesBillList(params).then(res => {
  170. let data
  171. if (res.status == 200) {
  172. data = res.data
  173. // 总计
  174. this.getCount(params)
  175. const no = (data.pageNo - 1) * data.pageSize
  176. for (var i = 0; i < data.list.length; i++) {
  177. data.list[i].no = no + i + 1
  178. }
  179. this.disabled = false
  180. }
  181. this.spinning = false
  182. return data
  183. })
  184. },
  185. totalData: null, // 合计
  186. addrProvinceList: [], // 省下拉
  187. addrCityList: [], // 市下拉
  188. addrDistrictList: [], // 区下拉
  189. allocateTypeList: [], // 调拨类型
  190. custTypeList: [] // 客户类型 下拉数据
  191. }
  192. },
  193. computed: {
  194. columns () {
  195. const _this = this
  196. const arr = [
  197. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  198. { title: '销售单号', dataIndex: 'salesBillNo', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  199. { title: '客户名称', dataIndex: 'salesTargetName', width: '20%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  200. { title: '收款方式', dataIndex: 'settleStyleSnDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  201. { title: '款数', dataIndex: 'totalCategory', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  202. { title: '数量', dataIndex: 'totalQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  203. // { title: '成本', dataIndex: 'totalCost', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  204. { title: '总售价', dataIndex: 'totalAmount', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  205. { title: '折扣金额', dataIndex: 'discountAmount', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  206. { title: '折后总售价', dataIndex: 'discountedAmount', width: '9%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  207. // { title: '毛利', dataIndex: 'totalProfit', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  208. { title: '业务员', dataIndex: 'salesManName', width: '11%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  209. { title: '审核时间', dataIndex: 'salesAuditDate', width: '13%', align: 'center', customRender: function (text) { return text || '--' } }
  210. ]
  211. if (this.$hasPermissions('M_ShowAllCost')) {
  212. arr.splice(6, 0, { title: '成本', dataIndex: 'totalCost', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  213. arr.splice(10, 0, { title: '毛利', dataIndex: 'totalProfit', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  214. }
  215. return arr
  216. }
  217. },
  218. methods: {
  219. // 所在区域
  220. areaChange (val) {
  221. this.queryParam.provinceSn = val[0] ? val[0] : undefined
  222. this.queryParam.citySn = val[1] ? val[1] : undefined
  223. this.queryParam.countySn = val[2] ? val[2] : undefined
  224. },
  225. // 合计
  226. getCount (params) {
  227. reportSalesBillCount(params).then(res => {
  228. if (res.status == 200) {
  229. this.totalData = res.data
  230. } else {
  231. this.totalData = null
  232. }
  233. })
  234. },
  235. // 创建时间
  236. creatDateChange (date) {
  237. this.creatTime = date
  238. this.queryParam.createBeginDate = date[0] || ''
  239. this.queryParam.createEndDate = date[1] || ''
  240. },
  241. // 创建时间 change
  242. dateChange (date) {
  243. this.time = date
  244. this.queryParam.beginDate = date[0] || ''
  245. this.queryParam.endDate = date[1] || ''
  246. },
  247. // 出库时间
  248. outWareDateChange (date) {
  249. this.outWareTime = date
  250. this.queryParam.outWarehouseBeginDate = date[0]
  251. this.queryParam.outWarehouseEndDate = date[1]
  252. },
  253. // 查询
  254. handleSearch () {
  255. let hasVal = false
  256. for (const key in this.queryParam) {
  257. if (this.queryParam[key]) {
  258. hasVal = true
  259. break
  260. }
  261. }
  262. if (hasVal) {
  263. this.$refs.table.refresh(true)
  264. } else {
  265. this.$message.info('请至少输入一个查询条件')
  266. }
  267. },
  268. // 客户名称
  269. custSatelliteChange (v, row) {
  270. if (row && row.customerSn) {
  271. this.queryParam.buyerSnCurrent = row.customerSn
  272. this.queryParam.buyerNameCurrent = undefined
  273. } else {
  274. this.queryParam.buyerNameCurrent = v
  275. this.queryParam.buyerSnCurrent = undefined
  276. }
  277. },
  278. // 重置
  279. resetSearchForm () {
  280. this.$refs.creatDate.resetDate()
  281. this.creatTime = []
  282. this.queryParam.createBeginDate = ''
  283. this.queryParam.createEndDate = ''
  284. this.queryParam.buyerNameCurrent = undefined
  285. this.queryParam.buyerSnCurrent = undefined
  286. this.queryParam.salesTargetType = undefined
  287. this.queryParam.provinceSn = undefined
  288. this.queryParam.citySn = undefined
  289. this.queryParam.countySn = undefined
  290. this.queryParam.settleStyleSn = undefined
  291. this.queryParam.showCost = undefined
  292. this.queryParam.salesBillNo = ''
  293. this.queryParam.salesManName = ''
  294. this.$refs.ruleForm.resetFields()
  295. this.totalData = null
  296. if (this.advanced) {
  297. this.$refs.rangeDate.resetDate()
  298. this.time = []
  299. this.queryParam.beginDate = ''
  300. this.queryParam.endDate = ''
  301. this.$refs.outWareRangeDate.resetDate('')
  302. this.outWareTime = []
  303. this.queryParam.outWarehouseBeginDate = ''
  304. this.queryParam.outWarehouseEndDate = ''
  305. this.$refs.custSatelliteList.resetForm()
  306. this.$refs.areaList.clearData()
  307. }
  308. this.$refs.table.clearTable()
  309. },
  310. // 导出
  311. handleExport () {
  312. const _this = this
  313. let hasVal = false
  314. for (const key in this.queryParam) {
  315. if (this.queryParam[key]) {
  316. hasVal = true
  317. break
  318. }
  319. }
  320. if (hasVal) {
  321. const params = _this.queryParam
  322. params.showCost = this.$hasPermissions('M_ShowAllCost') ? '1' : '0'
  323. _this.exportLoading = true
  324. _this.spinning = true
  325. reportSalesBillExport(params).then(res => {
  326. downloadExcel(res, '销售报表')
  327. _this.exportLoading = false
  328. _this.spinning = false
  329. _this.queryParam.showCost = undefined
  330. })
  331. } else {
  332. this.$message.info('请至少输入一个查询条件')
  333. }
  334. }
  335. },
  336. mounted () {
  337. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  338. this.resetSearchForm()
  339. }
  340. },
  341. activated () {
  342. // 如果是新页签打开,则重置当前页面
  343. if (this.$store.state.app.isNewTab) {
  344. this.resetSearchForm()
  345. }
  346. },
  347. beforeRouteEnter (to, from, next) {
  348. next(vm => {})
  349. }
  350. }
  351. </script>