list.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  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="4" :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="4" :sm="24">
  39. <a-form-model-item label="客户类型">
  40. <a-select id="salesReportList-salesTargetType" v-model="queryParam.salesTargetType" allowClear placeholder="请选择客户类型">
  41. <a-select-option v-for="item in custTypeList" :value="item.customerTypeSn" :key="item.customerTypeSn">{{ item.name }}</a-select-option>
  42. </a-select>
  43. </a-form-model-item>
  44. </a-col>
  45. <a-col :md="4" :sm="24">
  46. <a-form-model-item label="收款方式">
  47. <v-select
  48. code="SETTLE_STYLE"
  49. id="salesReportList-settleStyleSn"
  50. v-model="queryParam.settleStyleSn"
  51. allowClear
  52. placeholder="请选择收款方式"
  53. ></v-select>
  54. </a-form-model-item>
  55. </a-col>
  56. <a-col :md="4" :sm="24">
  57. <a-form-model-item label="单号">
  58. <a-input id="salesReportList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入单号"/>
  59. </a-form-model-item>
  60. </a-col>
  61. <a-col :md="4" :sm="24">
  62. <a-form-model-item label="业务员">
  63. <a-input id="salesReportList-salesManName" v-model.trim="queryParam.salesManName" allowClear placeholder="请输入业务员"/>
  64. </a-form-model-item>
  65. </a-col>
  66. <a-col :md="10" :sm="24">
  67. <a-row>
  68. <a-form-model-item label="客户所在区" :labelCol="{span: 4}" :wrapperCol="{ span: 20 }" style="margin-bottom: 0!important;">
  69. <a-col span="8">
  70. <a-form-model-item prop="provinceSn" style="margin: 0;">
  71. <a-select v-model="queryParam.provinceSn" allowClear @change="getCityList" placeholder="请选择省">
  72. <a-select-option v-for="item in addrProvinceList" :value="item.areaSn" :key="item.areaSn + 'a'">{{ item.name }}</a-select-option>
  73. </a-select>
  74. </a-form-model-item>
  75. </a-col>
  76. <a-col span="7" offset="1">
  77. <a-form-model-item prop="citySn" style="margin: 0;">
  78. <a-select v-model="queryParam.citySn" allowClear @change="getAreaList" placeholder="请选择市">
  79. <a-select-option v-for="item in addrCityList" :value="item.areaSn" :key="item.areaSn + 'b'">{{ item.name }}</a-select-option>
  80. </a-select>
  81. </a-form-model-item>
  82. </a-col>
  83. <a-col span="7" offset="1">
  84. <a-form-model-item prop="countySn" style="margin: 0;">
  85. <a-select v-model="queryParam.countySn" allowClear placeholder="请选择区/县">
  86. <a-select-option v-for="item in addrDistrictList" :value="item.areaSn" :key="item.areaSn + 'c'">{{ item.name }}</a-select-option>
  87. </a-select>
  88. </a-form-model-item>
  89. </a-col>
  90. </a-form-model-item>
  91. </a-row>
  92. </a-col>
  93. </template>
  94. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  95. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="salesReportList-refresh">查询</a-button>
  96. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="salesReportList-reset">重置</a-button>
  97. <a-button
  98. type="primary"
  99. style="margin-left: 5px"
  100. @click="handleExport"
  101. :disabled="disabled"
  102. :loading="exportLoading"
  103. v-if="$hasPermissions('B_salesReportExport')"
  104. class="button-warning"
  105. id="salesReportList-export-btn">导出</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. <a-alert type="info" style="margin-bottom:10px">
  116. <div class="ftext" slot="message">
  117. 总单数:<strong>{{ (totalData && (totalData.totalRowSize || totalData.totalRowSize==0)) ? totalData.totalRowSize : '--' }}</strong>;
  118. 产品总数量:<strong>{{ (totalData && (totalData.totalQty || totalData.totalQty==0)) ? totalData.totalQty : '--' }}</strong>;
  119. <div style="display: inline-block;" v-if="$hasPermissions('M_ShowAllCost')">
  120. 总成本:<strong>{{ (totalData && (totalData.totalCost || totalData.totalCost==0)) ? toThousands(totalData.totalCost) : '--' }}</strong>;
  121. </div>
  122. 总售价:<strong>{{ (totalData && (totalData.discountedAmount || totalData.discountedAmount==0)) ? toThousands(totalData.discountedAmount) : '--' }}</strong>;
  123. <div style="display: inline-block;" v-if="$hasPermissions('M_ShowAllCost')">
  124. 总毛利:<strong>{{ (totalData && (totalData.totalProfit || totalData.totalProfit==0)) ? toThousands(totalData.totalProfit) : '--' }}</strong>。
  125. </div>
  126. </div>
  127. </a-alert>
  128. <!-- 列表 -->
  129. <s-table
  130. class="sTable"
  131. ref="table"
  132. size="small"
  133. :rowKey="(record) => record.id"
  134. :columns="columns"
  135. :data="loadData"
  136. :defaultLoadData="false"
  137. bordered>
  138. </s-table>
  139. </a-spin>
  140. </template>
  141. <script>
  142. import { commonMixin } from '@/utils/mixin'
  143. import { STable, VSelect } from '@/components'
  144. import rangeDate from '@/views/common/rangeDate.vue'
  145. import { downloadExcel } from '@/libs/JGPrint.js'
  146. import { getArea } from '@/api/data'
  147. import { custTypeFindAllList } from '@/api/custType'
  148. import custList from '@/views/common/custList.vue'
  149. import { reportSalesBillList, reportSalesBillCount, reportSalesBillExport } from '@/api/reportData'
  150. export default {
  151. components: { STable, VSelect, rangeDate, custList },
  152. mixins: [commonMixin],
  153. data () {
  154. return {
  155. spinning: false,
  156. labelCol: { span: 8 },
  157. wrapperCol: { span: 16 },
  158. advanced: false, // 高级搜索 展开/关闭
  159. tableHeight: 0,
  160. queryParam: { // 查询条件
  161. createBeginDate: '',
  162. createEndDate: '',
  163. beginDate: '',
  164. endDate: '',
  165. outWarehouseBeginDate: '',
  166. outWarehouseEndDate: '',
  167. buyerNameCurrent: undefined, // 客户名称
  168. buyerSnCurrent: undefined, // 客户sn
  169. salesTargetType: undefined, // 客户类型
  170. provinceSn: undefined, // 省
  171. citySn: undefined, // 市
  172. countySn: undefined, // 区
  173. settleStyleSn: undefined,
  174. salesBillNo: '',
  175. salesManName: ''
  176. },
  177. creatTime: [],
  178. time: [],
  179. outWareTime: [],
  180. rules: {
  181. 'time': [{ required: true, message: '请选择审核时间', trigger: 'change' }]
  182. },
  183. disabled: false, // 查询、重置按钮是否可操作
  184. exportLoading: false,
  185. // 加载数据方法 必须为 Promise 对象
  186. loadData: parameter => {
  187. this.disabled = true
  188. const params = Object.assign(parameter, this.queryParam)
  189. this.spinning = true
  190. delete params.time
  191. return reportSalesBillList(params).then(res => {
  192. let data
  193. if (res.status == 200) {
  194. data = res.data
  195. // 总计
  196. this.getCount(params)
  197. const no = (data.pageNo - 1) * data.pageSize
  198. for (var i = 0; i < data.list.length; i++) {
  199. data.list[i].no = no + i + 1
  200. }
  201. this.disabled = false
  202. }
  203. this.spinning = false
  204. return data
  205. })
  206. },
  207. totalData: null, // 合计
  208. linkageGroupData: [],
  209. addrProvinceList: [], // 省下拉
  210. addrCityList: [], // 市下拉
  211. addrDistrictList: [], // 区下拉
  212. allocateTypeList: [], // 调拨类型
  213. custTypeList: [] // 客户类型 下拉数据
  214. }
  215. },
  216. computed: {
  217. columns () {
  218. const _this = this
  219. const arr = [
  220. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  221. { title: '销售单号', dataIndex: 'salesBillNo', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  222. { title: '客户名称', dataIndex: 'salesTargetName', width: '20%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  223. { title: '收款方式', dataIndex: 'settleStyleSnDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  224. { title: '款数', dataIndex: 'totalCategory', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  225. { title: '数量', dataIndex: 'totalQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  226. // { title: '成本', dataIndex: 'totalCost', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  227. { title: '售价', dataIndex: 'discountedAmount', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  228. // { title: '毛利', dataIndex: 'totalProfit', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  229. { title: '业务员', dataIndex: 'salesManName', width: '11%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  230. { title: '审核时间', dataIndex: 'salesAuditDate', width: '13%', align: 'center', customRender: function (text) { return text || '--' } }
  231. ]
  232. if (this.$hasPermissions('M_ShowAllCost')) {
  233. arr.splice(6, 0, { title: '成本', dataIndex: 'totalCost', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  234. arr.splice(8, 0, { title: '毛利', dataIndex: 'totalProfit', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  235. }
  236. return arr
  237. }
  238. },
  239. methods: {
  240. // 合计
  241. getCount (params) {
  242. reportSalesBillCount(params).then(res => {
  243. if (res.status == 200) {
  244. this.totalData = res.data
  245. } else {
  246. this.totalData = null
  247. }
  248. })
  249. },
  250. creatDateChange (date) {
  251. this.creatTime = date
  252. this.queryParam.createBeginDate = date[0] || ''
  253. this.queryParam.createEndDate = date[1] || ''
  254. },
  255. // 创建时间 change
  256. dateChange (date) {
  257. this.time = date
  258. this.queryParam.beginDate = date[0] || ''
  259. this.queryParam.endDate = date[1] || ''
  260. },
  261. outWareDateChange (date) {
  262. this.outWareTime = date
  263. this.queryParam.outWarehouseBeginDate = date[0]
  264. this.queryParam.outWarehouseEndDate = date[1]
  265. },
  266. // 查询
  267. handleSearch () {
  268. let hasVal = false
  269. for (const key in this.queryParam) {
  270. if (this.queryParam[key]) {
  271. hasVal = true
  272. break
  273. }
  274. }
  275. if (hasVal) {
  276. this.$refs.table.refresh(true)
  277. } else {
  278. this.$message.info('请至少输入一个查询条件')
  279. }
  280. },
  281. custSatelliteChange (v, row) {
  282. if (row && row.customerSn) {
  283. this.queryParam.buyerSnCurrent = row.customerSn
  284. this.queryParam.buyerNameCurrent = undefined
  285. } else {
  286. this.queryParam.buyerNameCurrent = v
  287. this.queryParam.buyerSnCurrent = undefined
  288. }
  289. },
  290. // 重置
  291. resetSearchForm () {
  292. this.$refs.rangeDate.resetDate()
  293. this.time = []
  294. this.queryParam.beginDate = ''
  295. this.queryParam.endDate = ''
  296. this.$refs.outWareRangeDate.resetDate('')
  297. this.outWareTime = []
  298. this.queryParam.outWarehouseBeginDate = ''
  299. this.queryParam.outWarehouseEndDate = ''
  300. this.$refs.creatDate.resetDate()
  301. this.creatTime = []
  302. this.queryParam.createBeginDate = ''
  303. this.queryParam.createEndDate = ''
  304. this.queryParam.buyerNameCurrent = undefined
  305. this.queryParam.buyerSnCurrent = undefined
  306. this.queryParam.salesTargetType = undefined
  307. this.queryParam.provinceSn = undefined
  308. this.queryParam.citySn = undefined
  309. this.queryParam.countySn = undefined
  310. this.queryParam.settleStyleSn = undefined
  311. this.queryParam.showCost = undefined
  312. this.queryParam.salesBillNo = ''
  313. this.queryParam.salesManName = ''
  314. this.$refs.ruleForm.resetFields()
  315. this.totalData = null
  316. if (this.advanced) {
  317. this.$refs.custSatelliteList.resetForm()
  318. }
  319. this.$refs.table.clearTable()
  320. },
  321. // 导出
  322. handleExport () {
  323. const _this = this
  324. let hasVal = false
  325. for (const key in this.queryParam) {
  326. if (this.queryParam[key]) {
  327. hasVal = true
  328. break
  329. }
  330. }
  331. if (hasVal) {
  332. const params = _this.queryParam
  333. params.showCost = this.$hasPermissions('M_ShowAllCost') ? '1' : '0'
  334. _this.exportLoading = true
  335. _this.spinning = true
  336. reportSalesBillExport(params).then(res => {
  337. downloadExcel(res, '销售报表')
  338. _this.exportLoading = false
  339. _this.spinning = false
  340. _this.queryParam.showCost = undefined
  341. })
  342. } else {
  343. this.$message.info('请至少输入一个查询条件')
  344. }
  345. },
  346. filterOption (input, option) {
  347. return (
  348. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  349. )
  350. },
  351. // 获取客户类型列表
  352. getCustTypeList () {
  353. const _this = this
  354. custTypeFindAllList().then(res => {
  355. if (res.status == 200) {
  356. _this.custTypeList = res.data || []
  357. } else {
  358. _this.custTypeList = []
  359. }
  360. })
  361. },
  362. // 获取城市列表
  363. getCityList (val) {
  364. this.addrCityList = []
  365. this.addrDistrictList = []
  366. this.queryParam.citySn = undefined
  367. this.queryParam.countySn = undefined
  368. if (val) {
  369. this.getArea('city', val)
  370. }
  371. },
  372. // 获取区县列表
  373. getAreaList (val) {
  374. this.addrDistrictList = []
  375. this.queryParam.countySn = undefined
  376. if (val) {
  377. this.getArea('district', val)
  378. }
  379. },
  380. // 省/市/区
  381. getArea (leve, sn) {
  382. let params
  383. if (leve == 'province') {
  384. params = { type: '2' }
  385. } else {
  386. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  387. }
  388. getArea(params).then(res => {
  389. if (res.status == 200) {
  390. if (leve == 'province') {
  391. this.addrProvinceList = res.data || []
  392. } else if (leve == 'city') {
  393. this.addrCityList = res.data || []
  394. } else if (leve == 'district') {
  395. this.addrDistrictList = res.data || []
  396. }
  397. } else {
  398. if (leve == 'province') {
  399. this.addrProvinceList = []
  400. } else if (leve == 'city') {
  401. this.addrCityList = []
  402. } else if (leve == 'district') {
  403. this.addrDistrictList = []
  404. }
  405. }
  406. })
  407. },
  408. pageInit () {
  409. this.getArea('province')
  410. this.getCustTypeList()
  411. }
  412. },
  413. mounted () {
  414. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  415. this.pageInit()
  416. this.resetSearchForm()
  417. }
  418. },
  419. activated () {
  420. // 如果是新页签打开,则重置当前页面
  421. if (this.$store.state.app.isNewTab) {
  422. this.pageInit()
  423. this.resetSearchForm()
  424. }
  425. },
  426. beforeRouteEnter (to, from, next) {
  427. next(vm => {})
  428. }
  429. }
  430. </script>