list.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  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. 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="chainSalesDetailReportList-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="chainSalesDetailReportList-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="chainSalesDetailReportList-customerType" 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. <v-select code="SETTLE_STYLE" id="chainSalesDetailReportList-settleStyleSn" v-model="queryParam.settleStyleSn" allowClear placeholder="请选择收款方式" ></v-select>
  53. </a-form-model-item>
  54. </a-col>
  55. <a-col :md="6" :sm="24">
  56. <a-form-item label="产品品牌">
  57. <a-select
  58. placeholder="请选择产品品牌"
  59. id="chainSalesDetailReportList-productBrandSn"
  60. allowClear
  61. v-model="queryParam.productEntity.productBrandSn"
  62. :showSearch="true"
  63. option-filter-prop="children"
  64. :filter-option="filterOption">
  65. <a-select-option v-for="item in productBrandList" :key="item.brandSn" :value="item.brandSn">{{ item.brandName }}</a-select-option>
  66. </a-select>
  67. </a-form-item>
  68. </a-col>
  69. <a-col :md="6" :sm="24">
  70. <a-form-model-item label="产品分类">
  71. <a-cascader
  72. @change="changeProductType"
  73. change-on-select
  74. v-model="productType"
  75. expand-trigger="hover"
  76. :options="productTypeList"
  77. :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
  78. id="chainSalesDetailReportList-productType"
  79. placeholder="请选择产品分类"
  80. allowClear />
  81. </a-form-model-item>
  82. </a-col>
  83. <a-col :md="6" :sm="24">
  84. <a-form-model-item label="产品编码">
  85. <a-input id="chainSalesDetailReportList-code" v-model.trim="queryParam.productEntity.code" allowClear placeholder="请输入产品编码"/>
  86. </a-form-model-item>
  87. </a-col>
  88. <a-col :md="6" :sm="24">
  89. <a-form-model-item label="产品名称">
  90. <a-input id="chainSalesDetailReportList-name" v-model.trim="queryParam.productEntity.name" allowClear placeholder="请输入产品名称"/>
  91. </a-form-model-item>
  92. </a-col>
  93. <a-col :md="6" :sm="24">
  94. <a-form-model-item label="仓库仓位">
  95. <a-cascader
  96. v-model="queryParam.warehouseCascade"
  97. expand-trigger="hover"
  98. :options="warehouseCascadeData"
  99. :fieldNames="{ label: 'name', value: 'sn', children: 'warehouseLocationList' }"
  100. id="chainSalesDetailReportList-warehouseCascade"
  101. placeholder="请选择仓库仓位"
  102. @change="warehouseCascadeChange"
  103. allowClear
  104. style="width: 100%;" />
  105. </a-form-model-item>
  106. </a-col>
  107. <a-col :md="6" :sm="24">
  108. <a-form-model-item label="单号">
  109. <a-input id="chainSalesDetailReportList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入单号"/>
  110. </a-form-model-item>
  111. </a-col>
  112. <a-col :md="6" :sm="24">
  113. <a-form-model-item label="业务员">
  114. <a-input id="chainSalesDetailReportList-salesManName" v-model.trim="queryParam.salesManName" allowClear placeholder="请输入业务员"/>
  115. </a-form-model-item>
  116. </a-col>
  117. <a-col :md="12" :sm="24">
  118. <a-row>
  119. <a-form-model-item label="客户所在区" :labelCol="{span: 4}" :wrapperCol="{ span: 20 }" style="margin-bottom: 0!important;">
  120. <a-col span="7">
  121. <a-form-model-item prop="provinceSn" style="margin: 0;">
  122. <a-select v-model="queryParam.provinceSn" @change="getCityList" placeholder="请选择省" allowClear>
  123. <a-select-option v-for="item in addrProvinceList" :value="item.areaSn" :key="item.areaSn + 'a'">{{ item.name }}</a-select-option>
  124. </a-select>
  125. </a-form-model-item>
  126. </a-col>
  127. <a-col span="7" offset="1">
  128. <a-form-model-item prop="citySn" style="margin: 0;">
  129. <a-select v-model="queryParam.citySn" @change="getAreaList" placeholder="请选择市" allowClear>
  130. <a-select-option v-for="item in addrCityList" :value="item.areaSn" :key="item.areaSn + 'b'">{{ item.name }}</a-select-option>
  131. </a-select>
  132. </a-form-model-item>
  133. </a-col>
  134. <a-col span="7" offset="1">
  135. <a-form-model-item prop="countySn" style="margin: 0;">
  136. <a-select v-model="queryParam.countySn" placeholder="请选择区/县" allowClear>
  137. <a-select-option v-for="item in addrDistrictList" :value="item.areaSn" :key="item.areaSn + 'c'">{{ item.name }}</a-select-option>
  138. </a-select>
  139. </a-form-model-item>
  140. </a-col>
  141. </a-form-model-item>
  142. </a-row>
  143. </a-col>
  144. </template>
  145. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  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: 5px">
  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" 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. :defaultLoadData="false"
  174. bordered>
  175. </s-table>
  176. </a-spin>
  177. </a-card>
  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 { dealerProductBrandQuery } from '@/api/dealerProductBrand'
  186. import { dealerProductTypeList } from '@/api/dealerProductType'
  187. import { warehouseCascadeList } from '@/api/warehouse'
  188. import { reportChainSalesBillDetailList, reportChainSalesBillDetailCount, linkageGroupList } from '@/api/reportData'
  189. export default {
  190. components: { STable, VSelect, rangeDate },
  191. mixins: [commonMixin],
  192. data () {
  193. return {
  194. spinning: false,
  195. labelCol: { span: 8 },
  196. wrapperCol: { span: 16 },
  197. advanced: false, // 高级搜索 展开/关闭
  198. tableHeight: 0,
  199. queryParam: { // 查询条件
  200. tenantId: 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. 'tenantId': [{ 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: '4%', align: 'center' },
  232. { title: '销售单号', dataIndex: 'salesBillNo', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  233. { title: '客户名称', dataIndex: 'salesTargetName', width: '13%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  234. { title: '收款方式', dataIndex: 'settleStyleName', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  235. { title: '产品编码', dataIndex: 'productEntity.code', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  236. { title: '产品名称', dataIndex: 'productEntity.name', width: '14%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  237. { title: '单位', dataIndex: 'productEntity.unit', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  238. { title: '数量', dataIndex: 'productQty', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  239. { title: '成本', dataIndex: 'productCost', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  240. { title: '售价', dataIndex: 'productPrice', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  241. { title: '毛利', dataIndex: 'productProfit', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  242. { title: '审核时间', dataIndex: 'salesAuditDate', width: '11%', 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 reportChainSalesBillDetailList(params).then(res => {
  252. let data
  253. if (res.status == 200) {
  254. data = res.data
  255. // 总计
  256. this.getCount(params)
  257. const no = (data.pageNo - 1) * data.pageSize
  258. for (var i = 0; i < data.list.length; i++) {
  259. data.list[i].no = no + i + 1
  260. }
  261. this.disabled = false
  262. }
  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. productBrandList: [], // 品牌下拉数据
  275. productType: [],
  276. productTypeList: [], // 分类下拉数据
  277. warehouseCascadeData: [] // 仓库仓位
  278. }
  279. },
  280. methods: {
  281. // 合计
  282. getCount (params) {
  283. reportChainSalesBillDetailCount(params).then(res => {
  284. if (res.status == 200) {
  285. this.totalData = res.data
  286. } else {
  287. this.totalData = null
  288. }
  289. })
  290. },
  291. // 创建时间 change
  292. dateChange (date) {
  293. this.queryParam.time = date
  294. this.queryParam.beginDate = date[0] || ''
  295. this.queryParam.endDate = date[1] || ''
  296. },
  297. // 查询
  298. handleSearch () {
  299. this.$refs.ruleForm.validate(valid => {
  300. if (valid) {
  301. this.$refs.table.refresh(true)
  302. } else {
  303. console.log('error submit!!')
  304. return false
  305. }
  306. })
  307. },
  308. // 重置
  309. resetSearchForm () {
  310. this.queryParam.tenantId = undefined
  311. this.$refs.rangeDate.resetDate()
  312. this.queryParam.time = []
  313. this.queryParam.beginDate = ''
  314. this.queryParam.endDate = ''
  315. this.queryParam.salesTargetName = ''
  316. this.queryParam.salesTargetType = undefined
  317. this.queryParam.provinceSn = undefined
  318. this.queryParam.citySn = undefined
  319. this.queryParam.countySn = undefined
  320. this.queryParam.settleStyleSn = undefined
  321. this.queryParam.productEntity.productBrandSn = undefined
  322. this.queryParam.productEntity.productTypeSn1 = ''
  323. this.queryParam.productEntity.productTypeSn2 = ''
  324. this.queryParam.productEntity.productTypeSn3 = ''
  325. this.queryParam.productEntity.code = ''
  326. this.queryParam.productEntity.name = ''
  327. this.queryParam.warehouseSn = undefined
  328. this.queryParam.warehouseLocationSn = undefined
  329. this.queryParam.warehouseCascade = []
  330. this.queryParam.salesBillNo = ''
  331. this.queryParam.salesManName = ''
  332. this.productType = []
  333. this.$refs.ruleForm.resetFields()
  334. this.totalData = null
  335. this.$refs.table.clearTable()
  336. },
  337. filterOption (input, option) {
  338. return (
  339. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  340. )
  341. },
  342. // 获取客户类型列表
  343. getCustTypeList () {
  344. const _this = this
  345. custTypeFindAllList().then(res => {
  346. if (res.status == 200) {
  347. _this.custTypeList = res.data || []
  348. } else {
  349. _this.custTypeList = []
  350. }
  351. })
  352. },
  353. // 产品品牌 列表
  354. getProductBrand () {
  355. dealerProductBrandQuery({}).then(res => {
  356. if (res.status == 200) {
  357. this.productBrandList = res.data
  358. } else {
  359. this.productBrandList = []
  360. }
  361. })
  362. },
  363. // 产品分类 change
  364. changeProductType (val, opt) {
  365. this.queryParam.productEntity.productTypeSn1 = val[0] ? val[0] : ''
  366. this.queryParam.productEntity.productTypeSn2 = val[1] ? val[1] : ''
  367. this.queryParam.productEntity.productTypeSn3 = val[2] ? val[2] : ''
  368. },
  369. // 产品分类 列表
  370. getProductType () {
  371. dealerProductTypeList({}).then(res => {
  372. if (res.status == 200) {
  373. this.productTypeList = res.data
  374. } else {
  375. this.productTypeList = []
  376. }
  377. })
  378. },
  379. // 连锁店
  380. getLinkageGroup () {
  381. linkageGroupList({}).then(res => {
  382. if (res.status == 200) {
  383. const data = res.data || []
  384. if (data.length > 0) {
  385. this.linkageGroupData = data
  386. } else {
  387. this.linkageGroupData = []
  388. }
  389. } else {
  390. this.linkageGroupData = []
  391. }
  392. })
  393. },
  394. // 仓库仓位 级联 列表
  395. getWarehouseCascade () {
  396. warehouseCascadeList({}).then(res => {
  397. if (res.status == 200) {
  398. res.data.map(item => {
  399. item.sn = item.warehouseSn
  400. if (item.warehouseLocationList) {
  401. item.warehouseLocationList.map(subItem => {
  402. subItem.sn = subItem.warehouseLocationSn
  403. })
  404. }
  405. })
  406. this.warehouseCascadeData = res.data
  407. } else {
  408. this.warehouseCascadeData = []
  409. }
  410. })
  411. },
  412. // 仓库仓位change
  413. warehouseCascadeChange (val) {
  414. if (val && val.length > 0) {
  415. this.queryParam.warehouseSn = val[0] || ''
  416. this.queryParam.warehouseLocationSn = val[1] || ''
  417. } else {
  418. this.queryParam.warehouseSn = ''
  419. this.queryParam.warehouseLocationSn = ''
  420. }
  421. },
  422. // 获取城市列表
  423. getCityList (val) {
  424. this.addrCityList = []
  425. this.addrDistrictList = []
  426. this.queryParam.citySn = undefined
  427. this.queryParam.countySn = undefined
  428. if (val) {
  429. this.getArea('city', val)
  430. }
  431. },
  432. // 获取区县列表
  433. getAreaList (val) {
  434. this.addrDistrictList = []
  435. this.queryParam.countySn = undefined
  436. if (val) {
  437. this.getArea('district', val)
  438. }
  439. },
  440. // 省/市/区
  441. getArea (leve, sn) {
  442. let params
  443. if (leve == 'province') {
  444. params = { type: '2' }
  445. } else {
  446. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  447. }
  448. getArea(params).then(res => {
  449. if (res.status == 200) {
  450. if (leve == 'province') {
  451. this.addrProvinceList = res.data || []
  452. } else if (leve == 'city') {
  453. this.addrCityList = res.data || []
  454. } else if (leve == 'district') {
  455. this.addrDistrictList = res.data || []
  456. }
  457. } else {
  458. if (leve == 'province') {
  459. this.addrProvinceList = []
  460. } else if (leve == 'city') {
  461. this.addrCityList = []
  462. } else if (leve == 'district') {
  463. this.addrDistrictList = []
  464. }
  465. }
  466. })
  467. },
  468. pageInit () {
  469. this.getLinkageGroup()
  470. this.getArea('province')
  471. this.getCustTypeList()
  472. this.getProductBrand()
  473. this.getProductType()
  474. this.getWarehouseCascade()
  475. }
  476. },
  477. mounted () {
  478. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  479. this.pageInit()
  480. this.resetSearchForm()
  481. }
  482. },
  483. activated () {
  484. // 如果是新页签打开,则重置当前页面
  485. if (this.$store.state.app.isNewTab) {
  486. this.pageInit()
  487. this.resetSearchForm()
  488. }
  489. },
  490. beforeRouteEnter (to, from, next) {
  491. next(vm => {})
  492. }
  493. }
  494. </script>