list.vue 21 KB

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