list.vue 15 KB

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