list.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. <template>
  2. <a-card size="small" :bordered="false" class="chainSalesDetailReportList-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="chainSalesDetailReportList-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="chainSalesDetailReportList-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="chainSalesDetailReportList-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="chainSalesDetailReportList-customerType" 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" @change="getCityList" placeholder="请选择省" allowClear>
  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" @change="getAreaList" placeholder="请选择市" allowClear>
  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" placeholder="请选择区/县" allowClear>
  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="chainSalesDetailReportList-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-item label="产品品牌">
  84. <a-select
  85. placeholder="请选择产品品牌"
  86. id="chainSalesDetailReportList-productBrandSn"
  87. allowClear
  88. v-model="queryParam.productEntity.productBrandSn"
  89. :showSearch="true"
  90. option-filter-prop="children"
  91. :filter-option="filterOption">
  92. <a-select-option v-for="item in productBrandList" :key="item.brandSn" :value="item.brandSn">{{ item.brandName }}</a-select-option>
  93. </a-select>
  94. </a-form-item>
  95. </a-col>
  96. <a-col :md="6" :sm="24">
  97. <a-form-model-item label="产品分类">
  98. <a-cascader
  99. @change="changeProductType"
  100. change-on-select
  101. v-model="productType"
  102. expand-trigger="hover"
  103. :options="productTypeList"
  104. :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
  105. id="chainSalesDetailReportList-productType"
  106. placeholder="请选择产品分类"
  107. allowClear />
  108. </a-form-model-item>
  109. </a-col>
  110. <a-col :md="6" :sm="24">
  111. <a-form-model-item label="产品编码">
  112. <a-input id="chainSalesDetailReportList-code" v-model.trim="queryParam.productEntity.code" allowClear placeholder="请输入产品编码"/>
  113. </a-form-model-item>
  114. </a-col>
  115. <a-col :md="6" :sm="24">
  116. <a-form-model-item label="产品名称">
  117. <a-input id="chainSalesDetailReportList-name" v-model.trim="queryParam.productEntity.name" allowClear placeholder="请输入产品名称"/>
  118. </a-form-model-item>
  119. </a-col>
  120. <a-col :md="6" :sm="24">
  121. <a-form-model-item label="仓库仓位">
  122. <a-cascader
  123. v-model="queryParam.warehouseCascade"
  124. expand-trigger="hover"
  125. :options="warehouseCascadeData"
  126. :fieldNames="{ label: 'name', value: 'sn', children: 'warehouseLocationList' }"
  127. id="chainSalesDetailReportList-warehouseCascade"
  128. placeholder="请选择仓库仓位"
  129. @change="warehouseCascadeChange"
  130. allowClear
  131. style="width: 100%;" />
  132. </a-form-model-item>
  133. </a-col>
  134. <a-col :md="6" :sm="24">
  135. <a-form-model-item label="单号">
  136. <a-input id="chainSalesDetailReportList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入单号"/>
  137. </a-form-model-item>
  138. </a-col>
  139. <a-col :md="6" :sm="24">
  140. <a-form-model-item label="业务员">
  141. <a-input id="chainSalesDetailReportList-salesManName" v-model.trim="queryParam.salesManName" allowClear placeholder="请输入业务员"/>
  142. </a-form-model-item>
  143. </a-col>
  144. </template>
  145. <a-col :md="6" :sm="24" style="margin-top: 3px;">
  146. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="chainSalesDetailReportList-refresh">查询</a-button>
  147. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="chainSalesDetailReportList-reset">重置</a-button>
  148. <a @click="advanced=!advanced" style="margin-left: 8px">
  149. {{ advanced ? '收起' : '展开' }}
  150. <a-icon :type="advanced ? 'up' : 'down'"/>
  151. </a>
  152. </a-col>
  153. </a-row>
  154. </a-form-model>
  155. </div>
  156. <!-- 合计 -->
  157. <a-alert type="info" showIcon style="margin-bottom:10px">
  158. <div class="ftext" slot="message">
  159. 产品总数量:<strong>{{ (totalData && (totalData.totalQty || totalData.totalQty==0)) ? totalData.totalQty : '--' }}</strong>;
  160. 总成本:<strong>{{ (totalData && (totalData.totalCost || totalData.totalCost==0)) ? '¥'+totalData.totalCost : '--' }}</strong>;
  161. 总售价:<strong>{{ (totalData && (totalData.totalPrice || totalData.totalPrice==0)) ? '¥'+totalData.totalPrice : '--' }}</strong>;
  162. 总毛利:<strong>{{ (totalData && (totalData.totalProfit || totalData.totalProfit==0)) ? '¥'+totalData.totalProfit : '--' }}</strong>。
  163. </div>
  164. </a-alert>
  165. <!-- 列表 -->
  166. <s-table
  167. class="sTable"
  168. ref="table"
  169. size="small"
  170. :rowKey="(record) => record.id"
  171. :columns="columns"
  172. :data="loadData"
  173. :scroll="{ x: 1770 }"
  174. :defaultLoadData="false"
  175. bordered>
  176. </s-table>
  177. </a-spin>
  178. </a-card>
  179. </template>
  180. <script>
  181. import { STable, VSelect } from '@/components'
  182. import rangeDate from '@/views/common/rangeDate.vue'
  183. import { getArea } from '@/api/data'
  184. import { custTypeFindAllList } from '@/api/custType'
  185. import { settleStyleFindAllList } from '@/api/customer'
  186. import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
  187. import { dealerProductTypeList } from '@/api/dealerProductType'
  188. import { warehouseCascadeList } from '@/api/warehouse'
  189. import { reportSalesBillDetailList, reportSalesBillDetailCount, linkageGroupList } from '@/api/reportData'
  190. export default {
  191. components: { STable, VSelect, rangeDate },
  192. data () {
  193. return {
  194. spinning: false,
  195. labelCol: { span: 8 },
  196. wrapperCol: { span: 16 },
  197. advanced: false, // 高级搜索 展开/关闭
  198. tableHeight: 0,
  199. queryParam: { // 查询条件
  200. dealerSn: undefined,
  201. time: [],
  202. beginDate: '',
  203. endDate: '',
  204. salesTargetName: '',
  205. salesTargetType: undefined,
  206. provinceSn: undefined, // 省
  207. citySn: undefined, // 市
  208. countySn: undefined, // 区
  209. settleStyleSn: undefined,
  210. productEntity: {
  211. productBrandSn: undefined, // 产品品牌
  212. productTypeSn1: '', // 产品一级分类
  213. productTypeSn2: '', // 产品二级分类
  214. productTypeSn3: '', // 产品三级分类
  215. code: '', // 产品编码
  216. name: '' // 产品名称
  217. },
  218. warehouseCascade: [],
  219. warehouseSn: undefined,
  220. warehouseLocationSn: undefined,
  221. salesBillNo: '',
  222. salesManName: ''
  223. },
  224. rules: {
  225. 'dealerSn': [{ required: true, message: '请选择连锁店', trigger: 'change' }],
  226. 'time': [{ required: true, message: '请选择审核时间', trigger: 'change' }]
  227. },
  228. disabled: false, // 查询、重置按钮是否可操作
  229. exportLoading: false,
  230. columns: [
  231. { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
  232. { title: '销售单号', dataIndex: 'salesBillNo', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  233. { title: '客户名称', dataIndex: 'salesTargetName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  234. { title: '收款方式', dataIndex: 'settleStyleName', width: 150, align: 'center', customRender: function (text) { return text || '--' } },
  235. { title: '产品编码', dataIndex: 'productEntity.code', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  236. { title: '产品名称', dataIndex: 'productEntity.name', width: 220, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  237. { title: '单位', dataIndex: 'productEntity.unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  238. { title: '数量', dataIndex: 'productQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  239. { title: '成本', dataIndex: 'productCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  240. { title: '售价', dataIndex: 'productPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  241. { title: '毛利', dataIndex: 'productProfit', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  242. { title: '审核时间', dataIndex: 'salesAuditDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } }
  243. ],
  244. // 加载数据方法 必须为 Promise 对象
  245. loadData: parameter => {
  246. this.disabled = true
  247. const params = Object.assign(parameter, this.queryParam)
  248. this.spinning = true
  249. delete params.time
  250. delete params.warehouseCascade
  251. return reportSalesBillDetailList(params).then(res => {
  252. // 总计
  253. this.getCount(params)
  254. const data = res.data
  255. const no = (data.pageNo - 1) * data.pageSize
  256. for (var i = 0; i < data.list.length; i++) {
  257. data.list[i].no = no + i + 1
  258. }
  259. this.disabled = false
  260. this.spinning = false
  261. return data
  262. })
  263. },
  264. totalData: null, // 合计
  265. addrProvinceList: [], // 省下拉
  266. addrCityList: [], // 市下拉
  267. addrDistrictList: [], // 区下拉
  268. linkageGroupData: [],
  269. allocateTypeList: [], // 调拨类型
  270. custTypeList: [], // 客户类型 下拉数据
  271. settleStyleList: [], // 收款方式 下拉数据
  272. productBrandList: [], // 品牌下拉数据
  273. productType: [],
  274. productTypeList: [], // 分类下拉数据
  275. warehouseCascadeData: [] // 仓库仓位
  276. }
  277. },
  278. methods: {
  279. // 合计
  280. getCount (params) {
  281. reportSalesBillDetailCount(params).then(res => {
  282. if (res.status == 200) {
  283. this.totalData = res.data
  284. } else {
  285. this.totalData = null
  286. }
  287. })
  288. },
  289. // 创建时间 change
  290. dateChange (date) {
  291. this.queryParam.time = date
  292. this.queryParam.beginDate = date[0] || ''
  293. this.queryParam.endDate = date[1] || ''
  294. },
  295. // 查询
  296. handleSearch () {
  297. this.$refs.ruleForm.validate(valid => {
  298. if (valid) {
  299. this.$refs.table.refresh(true)
  300. } else {
  301. console.log('error submit!!')
  302. return false
  303. }
  304. })
  305. },
  306. // 重置
  307. resetSearchForm () {
  308. this.queryParam.dealerSn = undefined
  309. this.$refs.rangeDate.resetDate()
  310. this.queryParam.time = []
  311. this.queryParam.beginDate = ''
  312. this.queryParam.endDate = ''
  313. this.queryParam.salesTargetName = ''
  314. this.queryParam.salesTargetType = undefined
  315. this.queryParam.provinceSn = undefined
  316. this.queryParam.citySn = undefined
  317. this.queryParam.countySn = undefined
  318. this.queryParam.settleStyleSn = undefined
  319. this.queryParam.productEntity.productBrandSn = undefined
  320. this.queryParam.productEntity.productTypeSn1 = ''
  321. this.queryParam.productEntity.productTypeSn2 = ''
  322. this.queryParam.productEntity.productTypeSn3 = ''
  323. this.queryParam.productEntity.code = ''
  324. this.queryParam.productEntity.name = ''
  325. this.queryParam.warehouseSn = undefined
  326. this.queryParam.warehouseLocationSn = undefined
  327. this.queryParam.warehouseCascade = []
  328. this.queryParam.salesBillNo = ''
  329. this.queryParam.salesManName = ''
  330. this.productType = []
  331. this.$refs.ruleForm.resetFields()
  332. this.totalData = null
  333. this.$refs.table.clearTable()
  334. },
  335. filterOption (input, option) {
  336. return (
  337. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  338. )
  339. },
  340. // 获取客户类型列表
  341. getCustTypeList () {
  342. const _this = this
  343. custTypeFindAllList().then(res => {
  344. if (res.status == 200) {
  345. _this.custTypeList = res.data || []
  346. } else {
  347. _this.custTypeList = []
  348. }
  349. })
  350. },
  351. // 收款方式
  352. getSettleStyleList () {
  353. settleStyleFindAllList().then(res => {
  354. if (res.status == 200) {
  355. this.settleStyleList = res.data
  356. } else {
  357. this.settleStyleList = []
  358. }
  359. })
  360. },
  361. // 产品品牌 列表
  362. getProductBrand () {
  363. dealerProductBrandQuery({}).then(res => {
  364. if (res.status == 200) {
  365. this.productBrandList = res.data
  366. } else {
  367. this.productBrandList = []
  368. }
  369. })
  370. },
  371. // 产品分类 change
  372. changeProductType (val, opt) {
  373. this.queryParam.productEntity.productTypeSn1 = val[0] ? val[0] : ''
  374. this.queryParam.productEntity.productTypeSn2 = val[1] ? val[1] : ''
  375. this.queryParam.productEntity.productTypeSn3 = val[2] ? val[2] : ''
  376. },
  377. // 产品分类 列表
  378. getProductType () {
  379. dealerProductTypeList({}).then(res => {
  380. if (res.status == 200) {
  381. this.productTypeList = res.data
  382. } else {
  383. this.productTypeList = []
  384. }
  385. })
  386. },
  387. // 连锁店
  388. getLinkageGroup () {
  389. linkageGroupList({}).then(res => {
  390. const all = [{ dealerName: '全部', dealerSn: 'all' }]
  391. if (res.status == 200) {
  392. const data = res.data || []
  393. if (data.length > 0) {
  394. this.linkageGroupData = [...all, ...data]
  395. } else {
  396. this.linkageGroupData = []
  397. }
  398. } else {
  399. this.linkageGroupData = []
  400. }
  401. })
  402. },
  403. // 仓库仓位 级联 列表
  404. getWarehouseCascade () {
  405. warehouseCascadeList({}).then(res => {
  406. if (res.status == 200) {
  407. res.data.map(item => {
  408. item.sn = item.warehouseSn
  409. if (item.warehouseLocationList) {
  410. item.warehouseLocationList.map(subItem => {
  411. subItem.sn = subItem.warehouseLocationSn
  412. })
  413. }
  414. })
  415. this.warehouseCascadeData = res.data
  416. } else {
  417. this.warehouseCascadeData = []
  418. }
  419. })
  420. },
  421. // 仓库仓位change
  422. warehouseCascadeChange (val) {
  423. if (val && val.length > 0) {
  424. this.queryParam.warehouseSn = val[0] || ''
  425. this.queryParam.warehouseLocationSn = val[1] || ''
  426. } else {
  427. this.queryParam.warehouseSn = ''
  428. this.queryParam.warehouseLocationSn = ''
  429. }
  430. },
  431. // 获取城市列表
  432. getCityList (val) {
  433. this.addrCityList = []
  434. this.addrDistrictList = []
  435. this.queryParam.citySn = undefined
  436. this.queryParam.countySn = undefined
  437. if (val) {
  438. this.getArea('city', val)
  439. }
  440. },
  441. // 获取区县列表
  442. getAreaList (val) {
  443. this.addrDistrictList = []
  444. this.queryParam.countySn = undefined
  445. if (val) {
  446. this.getArea('district', val)
  447. }
  448. },
  449. // 省/市/区
  450. getArea (leve, sn) {
  451. let params
  452. if (leve == 'province') {
  453. params = { type: '2' }
  454. } else {
  455. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  456. }
  457. getArea(params).then(res => {
  458. if (res.status == 200) {
  459. if (leve == 'province') {
  460. this.addrProvinceList = res.data || []
  461. } else if (leve == 'city') {
  462. this.addrCityList = res.data || []
  463. } else if (leve == 'district') {
  464. this.addrDistrictList = res.data || []
  465. }
  466. } else {
  467. if (leve == 'province') {
  468. this.addrProvinceList = []
  469. } else if (leve == 'city') {
  470. this.addrCityList = []
  471. } else if (leve == 'district') {
  472. this.addrDistrictList = []
  473. }
  474. }
  475. })
  476. }
  477. },
  478. beforeRouteEnter (to, from, next) {
  479. next(vm => {
  480. vm.getLinkageGroup()
  481. vm.getArea('province')
  482. vm.getCustTypeList()
  483. vm.getSettleStyleList()
  484. vm.getProductBrand()
  485. vm.getProductType()
  486. vm.getWarehouseCascade()
  487. })
  488. }
  489. }
  490. </script>