list.vue 21 KB

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