list.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  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 || '--' } },
  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. if (params.dealerSn == 'all') {
  252. params.dealerSn = ''
  253. }
  254. return reportSalesBillDetailList(params).then(res => {
  255. // 总计
  256. this.getCount(params)
  257. const data = res.data
  258. const no = (data.pageNo - 1) * data.pageSize
  259. for (var i = 0; i < data.list.length; i++) {
  260. data.list[i].no = no + i + 1
  261. }
  262. this.disabled = false
  263. this.spinning = false
  264. return data
  265. })
  266. },
  267. totalData: null, // 合计
  268. addrProvinceList: [], // 省下拉
  269. addrCityList: [], // 市下拉
  270. addrDistrictList: [], // 区下拉
  271. linkageGroupData: [],
  272. allocateTypeList: [], // 调拨类型
  273. custTypeList: [], // 客户类型 下拉数据
  274. settleStyleList: [], // 收款方式 下拉数据
  275. productBrandList: [], // 品牌下拉数据
  276. productType: [],
  277. productTypeList: [], // 分类下拉数据
  278. warehouseCascadeData: [] // 仓库仓位
  279. }
  280. },
  281. methods: {
  282. // 合计
  283. getCount (params) {
  284. reportSalesBillDetailCount(params).then(res => {
  285. if (res.status == 200) {
  286. this.totalData = res.data
  287. } else {
  288. this.totalData = null
  289. }
  290. })
  291. },
  292. // 创建时间 change
  293. dateChange (date) {
  294. this.queryParam.time = date
  295. this.queryParam.beginDate = date[0] || ''
  296. this.queryParam.endDate = date[1] || ''
  297. },
  298. // 查询
  299. handleSearch () {
  300. this.$refs.ruleForm.validate(valid => {
  301. if (valid) {
  302. this.$refs.table.refresh(true)
  303. } else {
  304. console.log('error submit!!')
  305. return false
  306. }
  307. })
  308. },
  309. // 重置
  310. resetSearchForm () {
  311. this.queryParam.dealerSn = undefined
  312. this.$refs.rangeDate.resetDate()
  313. this.queryParam.time = []
  314. this.queryParam.beginDate = ''
  315. this.queryParam.endDate = ''
  316. this.queryParam.salesTargetName = ''
  317. this.queryParam.salesTargetType = undefined
  318. this.queryParam.provinceSn = undefined
  319. this.queryParam.citySn = undefined
  320. this.queryParam.countySn = undefined
  321. this.queryParam.settleStyleSn = undefined
  322. this.queryParam.productEntity.productBrandSn = undefined
  323. this.queryParam.productEntity.productTypeSn1 = ''
  324. this.queryParam.productEntity.productTypeSn2 = ''
  325. this.queryParam.productEntity.productTypeSn3 = ''
  326. this.queryParam.productEntity.code = ''
  327. this.queryParam.productEntity.name = ''
  328. this.queryParam.warehouseSn = undefined
  329. this.queryParam.warehouseLocationSn = undefined
  330. this.queryParam.warehouseCascade = []
  331. this.queryParam.salesBillNo = ''
  332. this.queryParam.salesManName = ''
  333. this.productType = []
  334. this.$refs.ruleForm.resetFields()
  335. this.totalData = null
  336. this.$refs.table.clearTable()
  337. },
  338. filterOption (input, option) {
  339. return (
  340. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  341. )
  342. },
  343. // 获取客户类型列表
  344. getCustTypeList () {
  345. const _this = this
  346. custTypeFindAllList().then(res => {
  347. if (res.status == 200) {
  348. _this.custTypeList = res.data || []
  349. } else {
  350. _this.custTypeList = []
  351. }
  352. })
  353. },
  354. // 收款方式
  355. getSettleStyleList () {
  356. settleStyleFindAllList().then(res => {
  357. if (res.status == 200) {
  358. this.settleStyleList = res.data
  359. } else {
  360. this.settleStyleList = []
  361. }
  362. })
  363. },
  364. // 产品品牌 列表
  365. getProductBrand () {
  366. dealerProductBrandQuery({}).then(res => {
  367. if (res.status == 200) {
  368. this.productBrandList = res.data
  369. } else {
  370. this.productBrandList = []
  371. }
  372. })
  373. },
  374. // 产品分类 change
  375. changeProductType (val, opt) {
  376. this.queryParam.productEntity.productTypeSn1 = val[0] ? val[0] : ''
  377. this.queryParam.productEntity.productTypeSn2 = val[1] ? val[1] : ''
  378. this.queryParam.productEntity.productTypeSn3 = val[2] ? val[2] : ''
  379. },
  380. // 产品分类 列表
  381. getProductType () {
  382. dealerProductTypeList({}).then(res => {
  383. if (res.status == 200) {
  384. this.productTypeList = res.data
  385. } else {
  386. this.productTypeList = []
  387. }
  388. })
  389. },
  390. // 连锁店
  391. getLinkageGroup () {
  392. linkageGroupList({}).then(res => {
  393. const all = [{ dealerName: '全部', dealerSn: 'all' }]
  394. if (res.status == 200) {
  395. const data = res.data || []
  396. this.linkageGroupData = [...all, ...data]
  397. } else {
  398. this.linkageGroupData = all
  399. }
  400. })
  401. },
  402. // 仓库仓位 级联 列表
  403. getWarehouseCascade () {
  404. warehouseCascadeList({}).then(res => {
  405. if (res.status == 200) {
  406. res.data.map(item => {
  407. item.sn = item.warehouseSn
  408. if (item.warehouseLocationList) {
  409. item.warehouseLocationList.map(subItem => {
  410. subItem.sn = subItem.warehouseLocationSn
  411. })
  412. }
  413. })
  414. this.warehouseCascadeData = res.data
  415. } else {
  416. this.warehouseCascadeData = []
  417. }
  418. })
  419. },
  420. // 仓库仓位change
  421. warehouseCascadeChange (val) {
  422. if (val && val.length > 0) {
  423. this.queryParam.warehouseSn = val[0] || ''
  424. this.queryParam.warehouseLocationSn = val[1] || ''
  425. } else {
  426. this.queryParam.warehouseSn = ''
  427. this.queryParam.warehouseLocationSn = ''
  428. }
  429. },
  430. // 获取城市列表
  431. getCityList (val) {
  432. this.addrCityList = []
  433. this.addrDistrictList = []
  434. this.queryParam.citySn = undefined
  435. this.queryParam.countySn = undefined
  436. if (val) {
  437. this.getArea('city', val)
  438. }
  439. },
  440. // 获取区县列表
  441. getAreaList (val) {
  442. this.addrDistrictList = []
  443. this.queryParam.countySn = undefined
  444. if (val) {
  445. this.getArea('district', val)
  446. }
  447. },
  448. // 省/市/区
  449. getArea (leve, sn) {
  450. let params
  451. if (leve == 'province') {
  452. params = { type: '2' }
  453. } else {
  454. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  455. }
  456. getArea(params).then(res => {
  457. if (res.status == 200) {
  458. if (leve == 'province') {
  459. this.addrProvinceList = res.data || []
  460. } else if (leve == 'city') {
  461. this.addrCityList = res.data || []
  462. } else if (leve == 'district') {
  463. this.addrDistrictList = res.data || []
  464. }
  465. } else {
  466. if (leve == 'province') {
  467. this.addrProvinceList = []
  468. } else if (leve == 'city') {
  469. this.addrCityList = []
  470. } else if (leve == 'district') {
  471. this.addrDistrictList = []
  472. }
  473. }
  474. })
  475. }
  476. },
  477. beforeRouteEnter (to, from, next) {
  478. next(vm => {
  479. vm.getLinkageGroup()
  480. vm.getArea('province')
  481. vm.getCustTypeList()
  482. vm.getSettleStyleList()
  483. vm.getProductBrand()
  484. vm.getProductType()
  485. vm.getWarehouseCascade()
  486. })
  487. }
  488. }
  489. </script>