list.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  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)) ? '¥'+totalData.totalCost : '--' }}</strong>;
  121. </div>
  122. 总售价:<strong>{{ (totalData && (totalData.totalPrice || totalData.totalPrice==0)) ? '¥'+totalData.totalPrice : '--' }}</strong>;
  123. <div style="display: inline-block;" v-if="$hasPermissions('M_ShowAllCost')">
  124. 总毛利:<strong>{{ (totalData && (totalData.totalProfit || totalData.totalProfit==0)) ? '¥'+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 arr = [
  217. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  218. { title: '销售单号', dataIndex: 'salesBillNo', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  219. { title: '客户名称', dataIndex: 'salesTargetName', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  220. { title: '收款方式', dataIndex: 'settleStyleSnDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  221. { title: '款数', dataIndex: 'totalCategory', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  222. { title: '数量', dataIndex: 'totalQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  223. // { title: '成本', dataIndex: 'totalCost', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  224. { title: '售价', dataIndex: 'totalPrice', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  225. // { title: '毛利', dataIndex: 'totalProfit', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  226. { title: '业务员', dataIndex: 'salesManName', width: '11%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  227. { title: '审核时间', dataIndex: 'salesAuditDate', width: '13%', align: 'center', customRender: function (text) { return text || '--' } }
  228. ]
  229. if (this.$hasPermissions('M_ShowAllCost')) {
  230. arr.splice(6, 0, { title: '成本', dataIndex: 'totalCost', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  231. arr.splice(8, 0, { title: '毛利', dataIndex: 'totalProfit', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  232. }
  233. return arr
  234. }
  235. },
  236. methods: {
  237. // 合计
  238. getCount (params) {
  239. reportSalesBillCount(params).then(res => {
  240. if (res.status == 200) {
  241. this.totalData = res.data
  242. } else {
  243. this.totalData = null
  244. }
  245. })
  246. },
  247. creatDateChange (date) {
  248. this.creatTime = date
  249. this.queryParam.createBeginDate = date[0] || ''
  250. this.queryParam.createEndDate = date[1] || ''
  251. },
  252. // 创建时间 change
  253. dateChange (date) {
  254. this.time = date
  255. this.queryParam.beginDate = date[0] || ''
  256. this.queryParam.endDate = date[1] || ''
  257. },
  258. outWareDateChange (date) {
  259. this.outWareTime = date
  260. this.queryParam.outWarehouseBeginDate = date[0]
  261. this.queryParam.outWarehouseEndDate = date[1]
  262. },
  263. // 查询
  264. handleSearch () {
  265. let hasVal = false
  266. for (const key in this.queryParam) {
  267. if (this.queryParam[key]) {
  268. hasVal = true
  269. break
  270. }
  271. }
  272. if (hasVal) {
  273. this.$refs.table.refresh(true)
  274. } else {
  275. this.$message.info('请至少输入一个查询条件')
  276. }
  277. },
  278. // 重置
  279. resetSearchForm () {
  280. this.$refs.rangeDate.resetDate()
  281. this.time = []
  282. this.queryParam.beginDate = ''
  283. this.queryParam.endDate = ''
  284. this.$refs.outWareRangeDate.resetDate('')
  285. this.outWareTime = []
  286. this.queryParam.outWarehouseBeginDate = ''
  287. this.queryParam.outWarehouseEndDate = ''
  288. this.$refs.creatDate.resetDate()
  289. this.creatTime = []
  290. this.queryParam.createBeginDate = ''
  291. this.queryParam.createEndDate = ''
  292. this.queryParam.salesTargetName = ''
  293. this.queryParam.salesTargetType = undefined
  294. this.queryParam.provinceSn = undefined
  295. this.queryParam.citySn = undefined
  296. this.queryParam.countySn = undefined
  297. this.queryParam.settleStyleSn = undefined
  298. this.queryParam.salesBillNo = ''
  299. this.queryParam.salesManName = ''
  300. this.$refs.ruleForm.resetFields()
  301. this.totalData = null
  302. this.$refs.table.clearTable()
  303. },
  304. // 导出
  305. handleExport () {
  306. const _this = this
  307. this.$refs.ruleForm.validate(valid => {
  308. if (valid) {
  309. const params = _this.queryParam
  310. params.showCost = this.$hasPermissions('M_ShowAllCost') ? '1' : '0'
  311. _this.exportLoading = true
  312. _this.spinning = true
  313. reportSalesBillExport(params).then(res => {
  314. downloadExcel(res, '销售报表')
  315. _this.exportLoading = false
  316. _this.spinning = false
  317. })
  318. } else {
  319. console.log('error submit!!')
  320. return false
  321. }
  322. })
  323. },
  324. filterOption (input, option) {
  325. return (
  326. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  327. )
  328. },
  329. // 获取客户类型列表
  330. getCustTypeList () {
  331. const _this = this
  332. custTypeFindAllList().then(res => {
  333. if (res.status == 200) {
  334. _this.custTypeList = res.data || []
  335. } else {
  336. _this.custTypeList = []
  337. }
  338. })
  339. },
  340. // 获取城市列表
  341. getCityList (val) {
  342. this.addrCityList = []
  343. this.addrDistrictList = []
  344. this.queryParam.citySn = undefined
  345. this.queryParam.countySn = undefined
  346. if (val) {
  347. this.getArea('city', val)
  348. }
  349. },
  350. // 获取区县列表
  351. getAreaList (val) {
  352. this.addrDistrictList = []
  353. this.queryParam.countySn = undefined
  354. if (val) {
  355. this.getArea('district', val)
  356. }
  357. },
  358. // 省/市/区
  359. getArea (leve, sn) {
  360. let params
  361. if (leve == 'province') {
  362. params = { type: '2' }
  363. } else {
  364. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  365. }
  366. getArea(params).then(res => {
  367. if (res.status == 200) {
  368. if (leve == 'province') {
  369. this.addrProvinceList = res.data || []
  370. } else if (leve == 'city') {
  371. this.addrCityList = res.data || []
  372. } else if (leve == 'district') {
  373. this.addrDistrictList = res.data || []
  374. }
  375. } else {
  376. if (leve == 'province') {
  377. this.addrProvinceList = []
  378. } else if (leve == 'city') {
  379. this.addrCityList = []
  380. } else if (leve == 'district') {
  381. this.addrDistrictList = []
  382. }
  383. }
  384. })
  385. },
  386. pageInit () {
  387. this.getArea('province')
  388. this.getCustTypeList()
  389. }
  390. },
  391. mounted () {
  392. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  393. this.pageInit()
  394. this.resetSearchForm()
  395. }
  396. },
  397. activated () {
  398. // 如果是新页签打开,则重置当前页面
  399. if (this.$store.state.app.isNewTab) {
  400. this.pageInit()
  401. this.resetSearchForm()
  402. }
  403. },
  404. beforeRouteEnter (to, from, next) {
  405. next(vm => {})
  406. }
  407. }
  408. </script>