list.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  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. <a-input id="salesReportList-salesTargetName" v-model.trim="queryParam.salesTargetName" allowClear placeholder="请输入客户名称"/>
  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.totalPrice || totalData.totalPrice==0)) ? toThousands(totalData.totalPrice) : '--' }}</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 { reportSalesBillList, reportSalesBillCount, reportSalesBillExport } from '@/api/reportData'
  149. export default {
  150. components: { STable, VSelect, rangeDate },
  151. mixins: [commonMixin],
  152. data () {
  153. return {
  154. spinning: false,
  155. labelCol: { span: 8 },
  156. wrapperCol: { span: 16 },
  157. advanced: false, // 高级搜索 展开/关闭
  158. tableHeight: 0,
  159. queryParam: { // 查询条件
  160. createBeginDate: '',
  161. createEndDate: '',
  162. beginDate: '',
  163. endDate: '',
  164. outWarehouseBeginDate: '',
  165. outWarehouseEndDate: '',
  166. salesTargetName: '',
  167. salesTargetType: undefined,
  168. provinceSn: undefined, // 省
  169. citySn: undefined, // 市
  170. countySn: undefined, // 区
  171. settleStyleSn: undefined,
  172. salesBillNo: '',
  173. salesManName: ''
  174. },
  175. creatTime: [],
  176. time: [],
  177. outWareTime: [],
  178. rules: {
  179. 'time': [{ required: true, message: '请选择审核时间', trigger: 'change' }]
  180. },
  181. disabled: false, // 查询、重置按钮是否可操作
  182. exportLoading: false,
  183. // 加载数据方法 必须为 Promise 对象
  184. loadData: parameter => {
  185. this.disabled = true
  186. const params = Object.assign(parameter, this.queryParam)
  187. this.spinning = true
  188. delete params.time
  189. return reportSalesBillList(params).then(res => {
  190. let data
  191. if (res.status == 200) {
  192. data = res.data
  193. // 总计
  194. this.getCount(params)
  195. const no = (data.pageNo - 1) * data.pageSize
  196. for (var i = 0; i < data.list.length; i++) {
  197. data.list[i].no = no + i + 1
  198. }
  199. this.disabled = false
  200. }
  201. this.spinning = false
  202. return data
  203. })
  204. },
  205. totalData: null, // 合计
  206. linkageGroupData: [],
  207. addrProvinceList: [], // 省下拉
  208. addrCityList: [], // 市下拉
  209. addrDistrictList: [], // 区下拉
  210. allocateTypeList: [], // 调拨类型
  211. custTypeList: [] // 客户类型 下拉数据
  212. }
  213. },
  214. computed: {
  215. columns () {
  216. const _this = this
  217. const arr = [
  218. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  219. { title: '销售单号', dataIndex: 'salesBillNo', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  220. { title: '客户名称', dataIndex: 'salesTargetName', width: '20%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  221. { title: '收款方式', dataIndex: 'settleStyleSnDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  222. { title: '款数', dataIndex: 'totalCategory', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  223. { title: '数量', dataIndex: 'totalQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  224. // { title: '成本', dataIndex: 'totalCost', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  225. { title: '售价', dataIndex: 'totalPrice', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  226. // { title: '毛利', dataIndex: 'totalProfit', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  227. { title: '业务员', dataIndex: 'salesManName', width: '11%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  228. { title: '审核时间', dataIndex: 'salesAuditDate', width: '13%', align: 'center', customRender: function (text) { return text || '--' } }
  229. ]
  230. if (this.$hasPermissions('M_ShowAllCost')) {
  231. arr.splice(6, 0, { title: '成本', dataIndex: 'totalCost', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  232. arr.splice(8, 0, { title: '毛利', dataIndex: 'totalProfit', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  233. }
  234. return arr
  235. }
  236. },
  237. methods: {
  238. // 合计
  239. getCount (params) {
  240. reportSalesBillCount(params).then(res => {
  241. if (res.status == 200) {
  242. this.totalData = res.data
  243. } else {
  244. this.totalData = null
  245. }
  246. })
  247. },
  248. creatDateChange (date) {
  249. this.creatTime = date
  250. this.queryParam.createBeginDate = date[0] || ''
  251. this.queryParam.createEndDate = date[1] || ''
  252. },
  253. // 创建时间 change
  254. dateChange (date) {
  255. this.time = date
  256. this.queryParam.beginDate = date[0] || ''
  257. this.queryParam.endDate = date[1] || ''
  258. },
  259. outWareDateChange (date) {
  260. this.outWareTime = date
  261. this.queryParam.outWarehouseBeginDate = date[0]
  262. this.queryParam.outWarehouseEndDate = date[1]
  263. },
  264. // 查询
  265. handleSearch () {
  266. let hasVal = false
  267. for (const key in this.queryParam) {
  268. if (this.queryParam[key]) {
  269. hasVal = true
  270. break
  271. }
  272. }
  273. if (hasVal) {
  274. this.$refs.table.refresh(true)
  275. } else {
  276. this.$message.info('请至少输入一个查询条件')
  277. }
  278. },
  279. // 重置
  280. resetSearchForm () {
  281. this.$refs.rangeDate.resetDate()
  282. this.time = []
  283. this.queryParam.beginDate = ''
  284. this.queryParam.endDate = ''
  285. this.$refs.outWareRangeDate.resetDate('')
  286. this.outWareTime = []
  287. this.queryParam.outWarehouseBeginDate = ''
  288. this.queryParam.outWarehouseEndDate = ''
  289. this.$refs.creatDate.resetDate()
  290. this.creatTime = []
  291. this.queryParam.createBeginDate = ''
  292. this.queryParam.createEndDate = ''
  293. this.queryParam.salesTargetName = ''
  294. this.queryParam.salesTargetType = undefined
  295. this.queryParam.provinceSn = undefined
  296. this.queryParam.citySn = undefined
  297. this.queryParam.countySn = undefined
  298. this.queryParam.settleStyleSn = undefined
  299. this.queryParam.salesBillNo = ''
  300. this.queryParam.salesManName = ''
  301. this.$refs.ruleForm.resetFields()
  302. this.totalData = null
  303. this.$refs.table.clearTable()
  304. },
  305. // 导出
  306. handleExport () {
  307. const _this = this
  308. this.$refs.ruleForm.validate(valid => {
  309. if (valid) {
  310. const params = _this.queryParam
  311. params.showCost = this.$hasPermissions('M_ShowAllCost') ? '1' : '0'
  312. _this.exportLoading = true
  313. _this.spinning = true
  314. reportSalesBillExport(params).then(res => {
  315. downloadExcel(res, '销售报表')
  316. _this.exportLoading = false
  317. _this.spinning = false
  318. })
  319. } else {
  320. console.log('error submit!!')
  321. return false
  322. }
  323. })
  324. },
  325. filterOption (input, option) {
  326. return (
  327. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  328. )
  329. },
  330. // 获取客户类型列表
  331. getCustTypeList () {
  332. const _this = this
  333. custTypeFindAllList().then(res => {
  334. if (res.status == 200) {
  335. _this.custTypeList = res.data || []
  336. } else {
  337. _this.custTypeList = []
  338. }
  339. })
  340. },
  341. // 获取城市列表
  342. getCityList (val) {
  343. this.addrCityList = []
  344. this.addrDistrictList = []
  345. this.queryParam.citySn = undefined
  346. this.queryParam.countySn = undefined
  347. if (val) {
  348. this.getArea('city', val)
  349. }
  350. },
  351. // 获取区县列表
  352. getAreaList (val) {
  353. this.addrDistrictList = []
  354. this.queryParam.countySn = undefined
  355. if (val) {
  356. this.getArea('district', val)
  357. }
  358. },
  359. // 省/市/区
  360. getArea (leve, sn) {
  361. let params
  362. if (leve == 'province') {
  363. params = { type: '2' }
  364. } else {
  365. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  366. }
  367. getArea(params).then(res => {
  368. if (res.status == 200) {
  369. if (leve == 'province') {
  370. this.addrProvinceList = res.data || []
  371. } else if (leve == 'city') {
  372. this.addrCityList = res.data || []
  373. } else if (leve == 'district') {
  374. this.addrDistrictList = res.data || []
  375. }
  376. } else {
  377. if (leve == 'province') {
  378. this.addrProvinceList = []
  379. } else if (leve == 'city') {
  380. this.addrCityList = []
  381. } else if (leve == 'district') {
  382. this.addrDistrictList = []
  383. }
  384. }
  385. })
  386. },
  387. pageInit () {
  388. this.getArea('province')
  389. this.getCustTypeList()
  390. }
  391. },
  392. mounted () {
  393. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  394. this.pageInit()
  395. this.resetSearchForm()
  396. }
  397. },
  398. activated () {
  399. // 如果是新页签打开,则重置当前页面
  400. if (this.$store.state.app.isNewTab) {
  401. this.pageInit()
  402. this.resetSearchForm()
  403. }
  404. },
  405. beforeRouteEnter (to, from, next) {
  406. next(vm => {})
  407. }
  408. }
  409. </script>