list.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  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 ref="creatDate" v-model="creatTime" @change="creatDateChange" />
  20. </a-form-model-item>
  21. </a-col>
  22. <a-col :md="6" :sm="24">
  23. <a-form-model-item label="审核时间">
  24. <rangeDate ref="rangeDate" v-model="time" @change="dateChange" />
  25. </a-form-model-item>
  26. </a-col>
  27. <a-col :md="6" :sm="24">
  28. <a-form-item label="出库时间">
  29. <rangeDate ref="outWareRangeDate" v-model="outWareTime" @change="outWareDateChange" />
  30. </a-form-item>
  31. </a-col>
  32. <template v-if="advanced">
  33. <a-col :md="6" :sm="24">
  34. <a-form-model-item label="客户名称">
  35. <custList id="salesReportList-salesTargetName" ref="custSatelliteList" @change="custSatelliteChange"></custList>
  36. </a-form-model-item>
  37. </a-col>
  38. <a-col :md="6" :sm="24">
  39. <a-form-item label="客户类型">
  40. <custType v-model="queryParam.salesTargetType" allowClear placeholder="请选择客户类型"></custType>
  41. </a-form-item>
  42. </a-col>
  43. <a-col :md="6" :sm="24">
  44. <a-form-model-item label="收款方式">
  45. <v-select
  46. code="SETTLE_STYLE"
  47. id="salesReportList-settleStyleSn"
  48. v-model="queryParam.settleStyleSn"
  49. allowClear
  50. placeholder="请选择收款方式"
  51. ></v-select>
  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-model-item label="业务员">
  61. <a-input id="salesReportList-salesManName" v-model.trim="queryParam.salesManName" allowClear placeholder="请输入业务员"/>
  62. </a-form-model-item>
  63. </a-col>
  64. <a-col :md="6" :sm="24">
  65. <a-form-item label="客户所在区">
  66. <AreaList changeOnSelect ref="areaList" @change="areaChange"></AreaList>
  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">
  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 { getArea } from '@/api/data'
  125. import custType from '@/views/common/custType.js'
  126. import AreaList from '@/views/common/areaList.js'
  127. import custList from '@/views/common/custList.vue'
  128. import { reportSalesBillList, reportSalesBillCount, reportSalesBillExport } from '@/api/reportData'
  129. export default {
  130. components: { STable, VSelect, rangeDate, custList, AreaList, custType },
  131. mixins: [commonMixin],
  132. data () {
  133. return {
  134. spinning: false,
  135. labelCol: { span: 8 },
  136. wrapperCol: { span: 16 },
  137. advanced: false, // 高级搜索 展开/关闭
  138. tableHeight: 0,
  139. queryParam: { // 查询条件
  140. createBeginDate: '',
  141. createEndDate: '',
  142. beginDate: '',
  143. endDate: '',
  144. outWarehouseBeginDate: '',
  145. outWarehouseEndDate: '',
  146. buyerNameCurrent: undefined, // 客户名称
  147. buyerSnCurrent: undefined, // 客户sn
  148. salesTargetType: undefined, // 客户类型
  149. provinceSn: undefined, // 省
  150. citySn: undefined, // 市
  151. countySn: undefined, // 区
  152. settleStyleSn: undefined,
  153. salesBillNo: '',
  154. salesManName: ''
  155. },
  156. creatTime: [],
  157. time: [],
  158. outWareTime: [],
  159. rules: {
  160. 'time': [{ required: true, message: '请选择审核时间', trigger: 'change' }]
  161. },
  162. disabled: false, // 查询、重置按钮是否可操作
  163. exportLoading: false,
  164. // 加载数据方法 必须为 Promise 对象
  165. loadData: parameter => {
  166. this.disabled = true
  167. const params = Object.assign(parameter, this.queryParam)
  168. this.spinning = true
  169. delete params.time
  170. return reportSalesBillList(params).then(res => {
  171. let data
  172. if (res.status == 200) {
  173. data = res.data
  174. // 总计
  175. this.getCount(params)
  176. const no = (data.pageNo - 1) * data.pageSize
  177. for (var i = 0; i < data.list.length; i++) {
  178. data.list[i].no = no + i + 1
  179. }
  180. this.disabled = false
  181. }
  182. this.spinning = false
  183. return data
  184. })
  185. },
  186. totalData: null, // 合计
  187. linkageGroupData: [],
  188. addrProvinceList: [], // 省下拉
  189. addrCityList: [], // 市下拉
  190. addrDistrictList: [], // 区下拉
  191. allocateTypeList: [], // 调拨类型
  192. custTypeList: [] // 客户类型 下拉数据
  193. }
  194. },
  195. computed: {
  196. columns () {
  197. const _this = this
  198. const arr = [
  199. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  200. { title: '销售单号', dataIndex: 'salesBillNo', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  201. { title: '客户名称', dataIndex: 'salesTargetName', width: '20%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  202. { title: '收款方式', dataIndex: 'settleStyleSnDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  203. { title: '款数', dataIndex: 'totalCategory', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  204. { title: '数量', dataIndex: 'totalQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  205. // { title: '成本', dataIndex: 'totalCost', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  206. { title: '总售价', dataIndex: 'totalAmount', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  207. { title: '折扣金额', dataIndex: 'discountAmount', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  208. { title: '折后总售价', dataIndex: 'discountedAmount', width: '9%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  209. // { title: '毛利', dataIndex: 'totalProfit', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  210. { title: '业务员', dataIndex: 'salesManName', width: '11%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  211. { title: '审核时间', dataIndex: 'salesAuditDate', width: '13%', align: 'center', customRender: function (text) { return text || '--' } }
  212. ]
  213. if (this.$hasPermissions('M_ShowAllCost')) {
  214. arr.splice(6, 0, { title: '成本', dataIndex: 'totalCost', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  215. arr.splice(10, 0, { title: '毛利', dataIndex: 'totalProfit', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  216. }
  217. return arr
  218. }
  219. },
  220. methods: {
  221. areaChange (val) {
  222. this.queryParam.provinceSn = val[0] ? val[0] : undefined
  223. this.queryParam.citySn = val[1] ? val[1] : undefined
  224. this.queryParam.countySn = val[2] ? val[2] : undefined
  225. },
  226. // 合计
  227. getCount (params) {
  228. reportSalesBillCount(params).then(res => {
  229. if (res.status == 200) {
  230. this.totalData = res.data
  231. } else {
  232. this.totalData = null
  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. outWareDateChange (date) {
  248. this.outWareTime = date
  249. this.queryParam.outWarehouseBeginDate = date[0]
  250. this.queryParam.outWarehouseEndDate = date[1]
  251. },
  252. // 查询
  253. handleSearch () {
  254. let hasVal = false
  255. for (const key in this.queryParam) {
  256. if (this.queryParam[key]) {
  257. hasVal = true
  258. break
  259. }
  260. }
  261. if (hasVal) {
  262. this.$refs.table.refresh(true)
  263. } else {
  264. this.$message.info('请至少输入一个查询条件')
  265. }
  266. },
  267. custSatelliteChange (v, row) {
  268. if (row && row.customerSn) {
  269. this.queryParam.buyerSnCurrent = row.customerSn
  270. this.queryParam.buyerNameCurrent = undefined
  271. } else {
  272. this.queryParam.buyerNameCurrent = v
  273. this.queryParam.buyerSnCurrent = undefined
  274. }
  275. },
  276. // 重置
  277. resetSearchForm () {
  278. this.$refs.rangeDate.resetDate()
  279. this.time = []
  280. this.queryParam.beginDate = ''
  281. this.queryParam.endDate = ''
  282. this.$refs.outWareRangeDate.resetDate('')
  283. this.outWareTime = []
  284. this.queryParam.outWarehouseBeginDate = ''
  285. this.queryParam.outWarehouseEndDate = ''
  286. this.$refs.creatDate.resetDate()
  287. this.creatTime = []
  288. this.queryParam.createBeginDate = ''
  289. this.queryParam.createEndDate = ''
  290. this.queryParam.buyerNameCurrent = undefined
  291. this.queryParam.buyerSnCurrent = undefined
  292. this.queryParam.salesTargetType = undefined
  293. this.queryParam.provinceSn = undefined
  294. this.queryParam.citySn = undefined
  295. this.queryParam.countySn = undefined
  296. this.queryParam.settleStyleSn = undefined
  297. this.queryParam.showCost = undefined
  298. this.queryParam.salesBillNo = ''
  299. this.queryParam.salesManName = ''
  300. this.$refs.ruleForm.resetFields()
  301. this.totalData = null
  302. if (this.advanced) {
  303. this.$refs.custSatelliteList.resetForm()
  304. this.$refs.areaList.clearData()
  305. }
  306. this.$refs.table.clearTable()
  307. },
  308. // 导出
  309. handleExport () {
  310. const _this = this
  311. let hasVal = false
  312. for (const key in this.queryParam) {
  313. if (this.queryParam[key]) {
  314. hasVal = true
  315. break
  316. }
  317. }
  318. if (hasVal) {
  319. const params = _this.queryParam
  320. params.showCost = this.$hasPermissions('M_ShowAllCost') ? '1' : '0'
  321. _this.exportLoading = true
  322. _this.spinning = true
  323. reportSalesBillExport(params).then(res => {
  324. downloadExcel(res, '销售报表')
  325. _this.exportLoading = false
  326. _this.spinning = false
  327. _this.queryParam.showCost = undefined
  328. })
  329. } else {
  330. this.$message.info('请至少输入一个查询条件')
  331. }
  332. },
  333. filterOption (input, option) {
  334. return (
  335. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  336. )
  337. },
  338. pageInit () {
  339. }
  340. },
  341. mounted () {
  342. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  343. this.pageInit()
  344. this.resetSearchForm()
  345. }
  346. },
  347. activated () {
  348. // 如果是新页签打开,则重置当前页面
  349. if (this.$store.state.app.isNewTab) {
  350. this.pageInit()
  351. this.resetSearchForm()
  352. }
  353. },
  354. beforeRouteEnter (to, from, next) {
  355. next(vm => {})
  356. }
  357. }
  358. </script>