list.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <template>
  2. <a-card size="small" :bordered="false" class="chainSalesReportList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-alert :show-icon="false" type="error" message="注:连锁销售单报表包含急件销售数量、售价,连锁销售明细报表不包含急件销售数量、成本、售价" banner style="margin-bottom: 10px;" />
  5. <!-- 搜索条件 -->
  6. <div class="table-page-search-wrapper">
  7. <a-form-model
  8. id="chainSalesReportList-form"
  9. ref="ruleForm"
  10. :model="queryParam"
  11. :rules="rules"
  12. :labelCol="labelCol"
  13. :wrapperCol="wrapperCol"
  14. @keyup.enter.native="handleSearch" >
  15. <a-row :gutter="15">
  16. <a-col :md="6" :sm="24">
  17. <a-form-model-item label="连锁店" prop="dealerSn">
  18. <a-select
  19. placeholder="请选择连锁店"
  20. id="chainSalesReportList-dealerSn"
  21. allowClear
  22. v-model="queryParam.dealerSn"
  23. :showSearch="true"
  24. option-filter-prop="children"
  25. :filter-option="filterOption">
  26. <a-select-option v-for="item in linkageGroupData" :key="item.dealerSn" :value="item.dealerSn">{{ item.dealerName }}</a-select-option>
  27. </a-select>
  28. </a-form-model-item>
  29. </a-col>
  30. <a-col :md="6" :sm="24">
  31. <a-form-model-item label="审核时间" prop="time">
  32. <rangeDate ref="rangeDate" @change="dateChange" />
  33. </a-form-model-item>
  34. </a-col>
  35. <a-col :md="6" :sm="24">
  36. <a-form-model-item label="客户名称">
  37. <a-input id="chainSalesReportList-salesTargetName" v-model.trim="queryParam.salesTargetName" allowClear placeholder="请输入客户名称"/>
  38. </a-form-model-item>
  39. </a-col>
  40. <template v-if="advanced">
  41. <a-col :md="6" :sm="24">
  42. <a-form-model-item label="客户类型">
  43. <a-select id="chainSalesReportList-salesTargetType" v-model="queryParam.salesTargetType" allowClear placeholder="请选择客户类型">
  44. <a-select-option v-for="item in custTypeList" :value="item.customerTypeSn" :key="item.customerTypeSn">{{ item.name }}</a-select-option>
  45. </a-select>
  46. </a-form-model-item>
  47. </a-col>
  48. <a-col :md="12" :sm="24">
  49. <a-row>
  50. <a-form-model-item label="客户所在区" :labelCol="{span: 4}" :wrapperCol="{ span: 20 }">
  51. <a-col span="7">
  52. <a-form-model-item prop="provinceSn" style="margin: 0;">
  53. <a-select v-model="queryParam.provinceSn" allowClear @change="getCityList" placeholder="请选择省">
  54. <a-select-option v-for="item in addrProvinceList" :value="item.areaSn" :key="item.areaSn + 'a'">{{ item.name }}</a-select-option>
  55. </a-select>
  56. </a-form-model-item>
  57. </a-col>
  58. <a-col span="7" offset="1">
  59. <a-form-model-item prop="citySn" style="margin: 0;">
  60. <a-select v-model="queryParam.citySn" allowClear @change="getAreaList" placeholder="请选择市">
  61. <a-select-option v-for="item in addrCityList" :value="item.areaSn" :key="item.areaSn + 'b'">{{ item.name }}</a-select-option>
  62. </a-select>
  63. </a-form-model-item>
  64. </a-col>
  65. <a-col span="7" offset="1">
  66. <a-form-model-item prop="countySn" style="margin: 0;">
  67. <a-select v-model="queryParam.countySn" allowClear placeholder="请选择区/县">
  68. <a-select-option v-for="item in addrDistrictList" :value="item.areaSn" :key="item.areaSn + 'c'">{{ item.name }}</a-select-option>
  69. </a-select>
  70. </a-form-model-item>
  71. </a-col>
  72. </a-form-model-item>
  73. </a-row>
  74. </a-col>
  75. <a-col :md="6" :sm="24">
  76. <a-form-model-item label="收款方式">
  77. <a-select id="chainSalesReportList-settleStyleSn" v-model="queryParam.settleStyleSn" allowClear placeholder="请选择收款方式">
  78. <a-select-option v-for="item in settleStyleList" :value="item.settleStyleSn" :key="item.settleStyleSn">{{ item.name }}</a-select-option>
  79. </a-select>
  80. </a-form-model-item>
  81. </a-col>
  82. <a-col :md="6" :sm="24">
  83. <a-form-model-item label="单号">
  84. <a-input id="chainSalesReportList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入单号"/>
  85. </a-form-model-item>
  86. </a-col>
  87. <a-col :md="6" :sm="24">
  88. <a-form-model-item label="业务员">
  89. <a-input id="chainSalesReportList-salesManName" v-model.trim="queryParam.salesManName" allowClear placeholder="请输入业务员"/>
  90. </a-form-model-item>
  91. </a-col>
  92. </template>
  93. <a-col :md="6" :sm="24" style="margin-top: 3px;">
  94. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="chainSalesReportList-refresh">查询</a-button>
  95. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="chainSalesReportList-reset">重置</a-button>
  96. <a @click="advanced=!advanced" style="margin-left: 8px">
  97. {{ advanced ? '收起' : '展开' }}
  98. <a-icon :type="advanced ? 'up' : 'down'"/>
  99. </a>
  100. </a-col>
  101. </a-row>
  102. </a-form-model>
  103. </div>
  104. <!-- 合计 -->
  105. <a-alert type="info" showIcon style="margin-bottom:10px">
  106. <div class="ftext" slot="message">
  107. 总单数:<strong>{{ (totalData && (totalData.totalRowSize || totalData.totalRowSize==0)) ? totalData.totalRowSize : '--' }}</strong>;
  108. 产品总数量:<strong>{{ (totalData && (totalData.totalQty || totalData.totalQty==0)) ? totalData.totalQty : '--' }}</strong>;
  109. 总成本:<strong>{{ (totalData && (totalData.totalCost || totalData.totalCost==0)) ? '¥'+totalData.totalCost : '--' }}</strong>;
  110. 总售价:<strong>{{ (totalData && (totalData.totalPrice || totalData.totalPrice==0)) ? '¥'+totalData.totalPrice : '--' }}</strong>;
  111. 总毛利:<strong>{{ (totalData && (totalData.totalProfit || totalData.totalProfit==0)) ? '¥'+totalData.totalProfit : '--' }}</strong>。
  112. </div>
  113. </a-alert>
  114. <!-- 列表 -->
  115. <s-table
  116. class="sTable"
  117. ref="table"
  118. size="small"
  119. :rowKey="(record) => record.id"
  120. :columns="columns"
  121. :data="loadData"
  122. :scroll="{ x: 1480 }"
  123. :defaultLoadData="false"
  124. bordered>
  125. </s-table>
  126. </a-spin>
  127. </a-card>
  128. </template>
  129. <script>
  130. import { STable, VSelect } from '@/components'
  131. import rangeDate from '@/views/common/rangeDate.vue'
  132. import { getArea } from '@/api/data'
  133. import { custTypeFindAllList } from '@/api/custType'
  134. import { settleStyleFindAllList } from '@/api/customer'
  135. import { reportSalesBillList, reportSalesBillCount, linkageGroupList } from '@/api/reportData'
  136. export default {
  137. components: { STable, VSelect, rangeDate },
  138. data () {
  139. return {
  140. spinning: false,
  141. labelCol: { span: 8 },
  142. wrapperCol: { span: 16 },
  143. advanced: false, // 高级搜索 展开/关闭
  144. tableHeight: 0,
  145. queryParam: { // 查询条件
  146. dealerSn: undefined,
  147. time: [],
  148. beginDate: '',
  149. endDate: '',
  150. salesTargetName: '',
  151. salesTargetType: undefined,
  152. provinceSn: undefined, // 省
  153. citySn: undefined, // 市
  154. countySn: undefined, // 区
  155. settleStyleSn: undefined,
  156. salesBillNo: '',
  157. salesManName: ''
  158. },
  159. rules: {
  160. 'dealerSn': [{ required: true, message: '请选择连锁店', trigger: 'change' }],
  161. 'time': [{ required: true, message: '请选择审核时间', trigger: 'change' }]
  162. },
  163. disabled: false, // 查询、重置按钮是否可操作
  164. exportLoading: false,
  165. columns: [
  166. { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
  167. { title: '销售单号', dataIndex: 'salesBillNo', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  168. { title: '客户名称', dataIndex: 'salesTargetName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  169. { title: '收款方式', dataIndex: 'settleStyleName', width: 150, align: 'center', customRender: function (text) { return text || '--' } },
  170. { title: '款数', dataIndex: 'totalCategory', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  171. { title: '数量', dataIndex: 'totalQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  172. { title: '成本', dataIndex: 'totalCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  173. { title: '售价', dataIndex: 'totalPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  174. { title: '毛利', dataIndex: 'totalProfit', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  175. { title: '业务员', dataIndex: 'salesManName', width: 150, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  176. { title: '审核时间', dataIndex: 'salesAuditDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } }
  177. ],
  178. // 加载数据方法 必须为 Promise 对象
  179. loadData: parameter => {
  180. this.disabled = true
  181. const params = Object.assign(parameter, this.queryParam)
  182. this.spinning = true
  183. delete params.time
  184. return reportSalesBillList(params).then(res => {
  185. // 总计
  186. this.getCount(params)
  187. const data = res.data
  188. const no = (data.pageNo - 1) * data.pageSize
  189. for (var i = 0; i < data.list.length; i++) {
  190. data.list[i].no = no + i + 1
  191. }
  192. this.disabled = false
  193. this.spinning = false
  194. return data
  195. })
  196. },
  197. totalData: null, // 合计
  198. linkageGroupData: [],
  199. addrProvinceList: [], // 省下拉
  200. addrCityList: [], // 市下拉
  201. addrDistrictList: [], // 区下拉
  202. allocateTypeList: [], // 调拨类型
  203. custTypeList: [], // 客户类型 下拉数据
  204. settleStyleList: [] // 收款方式 下拉数据
  205. }
  206. },
  207. methods: {
  208. // 合计
  209. getCount (params) {
  210. reportSalesBillCount(params).then(res => {
  211. if (res.status == 200) {
  212. this.totalData = res.data
  213. } else {
  214. this.totalData = null
  215. }
  216. })
  217. },
  218. // 创建时间 change
  219. dateChange (date) {
  220. this.queryParam.time = date
  221. this.queryParam.beginDate = date[0] || ''
  222. this.queryParam.endDate = date[1] || ''
  223. },
  224. // 查询
  225. handleSearch () {
  226. this.$refs.ruleForm.validate(valid => {
  227. if (valid) {
  228. this.$refs.table.refresh(true)
  229. } else {
  230. console.log('error submit!!')
  231. return false
  232. }
  233. })
  234. },
  235. // 重置
  236. resetSearchForm () {
  237. this.queryParam.dealerSn = undefined
  238. this.$refs.rangeDate.resetDate()
  239. this.queryParam.time = []
  240. this.queryParam.beginDate = ''
  241. this.queryParam.endDate = ''
  242. this.queryParam.salesTargetName = ''
  243. this.queryParam.salesTargetType = undefined
  244. this.queryParam.provinceSn = undefined
  245. this.queryParam.citySn = undefined
  246. this.queryParam.countySn = undefined
  247. this.queryParam.settleStyleSn = undefined
  248. this.queryParam.salesBillNo = ''
  249. this.queryParam.salesManName = ''
  250. this.$refs.ruleForm.resetFields()
  251. this.totalData = null
  252. this.$refs.table.clearTable()
  253. },
  254. filterOption (input, option) {
  255. return (
  256. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  257. )
  258. },
  259. // 获取客户类型列表
  260. getCustTypeList () {
  261. const _this = this
  262. custTypeFindAllList().then(res => {
  263. if (res.status == 200) {
  264. _this.custTypeList = res.data || []
  265. } else {
  266. _this.custTypeList = []
  267. }
  268. })
  269. },
  270. // 收款方式
  271. getSettleStyleList () {
  272. settleStyleFindAllList().then(res => {
  273. if (res.status == 200) {
  274. this.settleStyleList = res.data
  275. } else {
  276. this.settleStyleList = []
  277. }
  278. })
  279. },
  280. // 连锁店
  281. getLinkageGroup () {
  282. linkageGroupList({}).then(res => {
  283. const all = [{ dealerName: '全部', dealerSn: 'all' }]
  284. if (res.status == 200) {
  285. const data = res.data || []
  286. if (data.length > 0) {
  287. this.linkageGroupData = [...all, ...data]
  288. } else {
  289. this.linkageGroupData = []
  290. }
  291. } else {
  292. this.linkageGroupData = []
  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. },
  343. beforeRouteEnter (to, from, next) {
  344. next(vm => {
  345. vm.getLinkageGroup()
  346. vm.getArea('province')
  347. vm.getCustTypeList()
  348. vm.getSettleStyleList()
  349. })
  350. }
  351. }
  352. </script>