list.vue 20 KB

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