list.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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 }">
  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">
  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. // 总计
  187. this.getCount(params)
  188. const data = res.data
  189. const no = (data.pageNo - 1) * data.pageSize
  190. for (var i = 0; i < data.list.length; i++) {
  191. data.list[i].no = no + i + 1
  192. }
  193. this.disabled = false
  194. this.spinning = false
  195. return data
  196. })
  197. },
  198. totalData: null, // 合计
  199. linkageGroupData: [],
  200. addrProvinceList: [], // 省下拉
  201. addrCityList: [], // 市下拉
  202. addrDistrictList: [], // 区下拉
  203. allocateTypeList: [], // 调拨类型
  204. custTypeList: [], // 客户类型 下拉数据
  205. settleStyleList: [] // 收款方式 下拉数据
  206. }
  207. },
  208. methods: {
  209. // 合计
  210. getCount (params) {
  211. reportChainSalesBillCount(params).then(res => {
  212. if (res.status == 200) {
  213. this.totalData = res.data
  214. } else {
  215. this.totalData = null
  216. }
  217. })
  218. },
  219. // 创建时间 change
  220. dateChange (date) {
  221. this.queryParam.time = date
  222. this.queryParam.beginDate = date[0] || ''
  223. this.queryParam.endDate = date[1] || ''
  224. },
  225. // 查询
  226. handleSearch () {
  227. this.$refs.ruleForm.validate(valid => {
  228. if (valid) {
  229. this.$refs.table.refresh(true)
  230. } else {
  231. console.log('error submit!!')
  232. return false
  233. }
  234. })
  235. },
  236. // 重置
  237. resetSearchForm () {
  238. this.queryParam.tenantId = undefined
  239. this.$refs.rangeDate.resetDate()
  240. this.queryParam.time = []
  241. this.queryParam.beginDate = ''
  242. this.queryParam.endDate = ''
  243. this.queryParam.salesTargetName = ''
  244. this.queryParam.salesTargetType = undefined
  245. this.queryParam.provinceSn = undefined
  246. this.queryParam.citySn = undefined
  247. this.queryParam.countySn = undefined
  248. this.queryParam.settleStyleSn = undefined
  249. this.queryParam.salesBillNo = ''
  250. this.queryParam.salesManName = ''
  251. this.$refs.ruleForm.resetFields()
  252. this.totalData = null
  253. this.$refs.table.clearTable()
  254. },
  255. filterOption (input, option) {
  256. return (
  257. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  258. )
  259. },
  260. // 获取客户类型列表
  261. getCustTypeList () {
  262. const _this = this
  263. custTypeFindAllList().then(res => {
  264. if (res.status == 200) {
  265. _this.custTypeList = res.data || []
  266. } else {
  267. _this.custTypeList = []
  268. }
  269. })
  270. },
  271. // 收款方式
  272. getSettleStyleList () {
  273. settleStyleFindAllList().then(res => {
  274. if (res.status == 200) {
  275. this.settleStyleList = res.data
  276. } else {
  277. this.settleStyleList = []
  278. }
  279. })
  280. },
  281. // 连锁店
  282. getLinkageGroup () {
  283. linkageGroupList({}).then(res => {
  284. if (res.status == 200) {
  285. const data = res.data || []
  286. if (data.length > 0) {
  287. this.linkageGroupData = 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. pageInit () {
  343. this.getLinkageGroup()
  344. this.getArea('province')
  345. this.getCustTypeList()
  346. this.getSettleStyleList()
  347. }
  348. },
  349. mounted () {
  350. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  351. this.pageInit()
  352. this.resetSearchForm()
  353. }
  354. },
  355. activated () {
  356. // 如果是新页签打开,则重置当前页面
  357. if (this.$store.state.app.isNewTab) {
  358. this.pageInit()
  359. this.resetSearchForm()
  360. }
  361. },
  362. beforeRouteEnter (to, from, next) {
  363. next(vm => {})
  364. }
  365. }
  366. </script>