list.vue 15 KB

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