list.vue 21 KB

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