list.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  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. <custList id="salesDetailReportList-salesTargetName" ref="custSatelliteList" @change="custSatelliteChange"></custList>
  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 custList from '@/views/common/custList.vue'
  185. import { reportSalesBillDetailList, reportSalesBillDetailCount, reportSalesBillDetailExport } from '@/api/reportData'
  186. export default {
  187. components: { STable, VSelect, rangeDate, ProductType, ProductBrand, custList },
  188. mixins: [commonMixin],
  189. data () {
  190. return {
  191. spinning: false,
  192. labelCol: { span: 8 },
  193. wrapperCol: { span: 16 },
  194. advanced: false, // 高级搜索 展开/关闭
  195. tableHeight: 0,
  196. outWareTime: [],
  197. time: [],
  198. creatTime: [],
  199. queryParam: { // 查询条件
  200. createBeginDate: '',
  201. createEndDate: '',
  202. beginDate: '',
  203. endDate: '',
  204. buyerNameCurrent: undefined, // 客户名称
  205. buyerSnCurrent: undefined, // 客户sn
  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. 'time': [{ required: true, message: '请选择审核时间', trigger: 'change' }]
  227. },
  228. disabled: false, // 查询、重置按钮是否可操作
  229. exportLoading: false,
  230. // 加载数据方法 必须为 Promise 对象
  231. loadData: parameter => {
  232. this.disabled = true
  233. const params = Object.assign(parameter, this.queryParam)
  234. this.spinning = true
  235. delete params.time
  236. delete params.warehouseCascade
  237. return reportSalesBillDetailList(params).then(res => {
  238. let data
  239. if (res.status == 200) {
  240. data = res.data
  241. // 总计
  242. this.getCount(params)
  243. const no = (data.pageNo - 1) * data.pageSize
  244. for (var i = 0; i < data.list.length; i++) {
  245. data.list[i].no = no + i + 1
  246. }
  247. this.disabled = false
  248. }
  249. this.spinning = false
  250. return data
  251. })
  252. },
  253. totalData: null, // 合计
  254. addrProvinceList: [], // 省下拉
  255. addrCityList: [], // 市下拉
  256. addrDistrictList: [], // 区下拉
  257. linkageGroupData: [],
  258. allocateTypeList: [], // 调拨类型
  259. custTypeList: [], // 客户类型 下拉数据
  260. productType: [],
  261. warehouseCascadeData: [] // 仓库仓位
  262. }
  263. },
  264. computed: {
  265. columns () {
  266. const _this = this
  267. const arr = [
  268. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  269. { title: '销售单号', dataIndex: 'salesBillNo', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  270. { title: '客户名称', dataIndex: 'salesTargetName', width: '15%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  271. { title: '收款方式', dataIndex: 'settleStyleSnDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  272. { title: '产品编码', dataIndex: 'productEntity.code', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  273. { title: '产品名称', dataIndex: 'productEntity.name', width: '17%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  274. { title: '单位', dataIndex: 'productEntity.unit', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  275. { title: '数量', dataIndex: 'productQty', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  276. // { title: '成本', dataIndex: 'productCost', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  277. { title: '售价', dataIndex: 'productPrice', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  278. // { title: '毛利', dataIndex: 'productProfit', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  279. { title: '审核时间', dataIndex: 'salesAuditDate', width: '11%', align: 'center', customRender: function (text) { return text || '--' } }
  280. ]
  281. if (this.$hasPermissions('M_ShowAllCost')) {
  282. arr.splice(8, 0, { title: '成本', dataIndex: 'productCost', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  283. arr.splice(10, 0, { title: '毛利', dataIndex: 'productProfit', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  284. }
  285. return arr
  286. }
  287. },
  288. methods: {
  289. // 合计
  290. getCount (params) {
  291. reportSalesBillDetailCount(params).then(res => {
  292. if (res.status == 200) {
  293. this.totalData = res.data
  294. } else {
  295. this.totalData = null
  296. }
  297. })
  298. },
  299. creatDateChange (date) {
  300. this.creatTime = date
  301. this.queryParam.createBeginDate = date[0] || ''
  302. this.queryParam.createEndDate = date[1] || ''
  303. },
  304. // 创建时间 change
  305. dateChange (date) {
  306. this.time = date
  307. this.queryParam.beginDate = date[0] || ''
  308. this.queryParam.endDate = date[1] || ''
  309. },
  310. outWareDateChange (date) {
  311. this.outWareTime = date
  312. this.queryParam.outWarehouseBeginDate = date[0]
  313. this.queryParam.outWarehouseEndDate = date[1]
  314. },
  315. // 查询
  316. handleSearch () {
  317. const str = JSON.stringify(this.queryParam)
  318. const ret = str.replace(/\[|\]/g, '"').replace(/"},"/g, '","').replace(/"}/g, '","').match(/"\:".*?","/g)
  319. const ret1 = ret.filter(item => item != '":"","')
  320. console.log(ret1)
  321. if (ret1.length) {
  322. this.$refs.table.refresh(true)
  323. } else {
  324. this.$message.info('请至少输入一个查询条件')
  325. }
  326. },
  327. custSatelliteChange (v, row) {
  328. if (row && row.customerSn) {
  329. this.queryParam.buyerSnCurrent = row.customerSn
  330. this.queryParam.buyerNameCurrent = undefined
  331. } else {
  332. this.queryParam.buyerNameCurrent = v
  333. this.queryParam.buyerSnCurrent = undefined
  334. }
  335. },
  336. // 重置
  337. resetSearchForm () {
  338. this.$refs.rangeDate.resetDate()
  339. this.queryParam.time = []
  340. this.queryParam.beginDate = ''
  341. this.queryParam.endDate = ''
  342. this.$refs.outWareRangeDate.resetDate('')
  343. this.outWareTime = []
  344. this.queryParam.outWarehouseBeginDate = ''
  345. this.queryParam.outWarehouseEndDate = ''
  346. this.$refs.creatDate.resetDate()
  347. this.creatTime = []
  348. this.queryParam.createBeginDate = ''
  349. this.queryParam.createEndDate = ''
  350. this.queryParam.buyerNameCurrent = undefined
  351. this.queryParam.buyerSnCurrent = undefined
  352. this.queryParam.salesTargetType = undefined
  353. this.queryParam.provinceSn = undefined
  354. this.queryParam.citySn = undefined
  355. this.queryParam.countySn = undefined
  356. this.queryParam.settleStyleSn = undefined
  357. this.queryParam.productEntity.productBrandSn = undefined
  358. this.queryParam.productEntity.productTypeSn1 = ''
  359. this.queryParam.productEntity.productTypeSn2 = ''
  360. this.queryParam.productEntity.productTypeSn3 = ''
  361. this.queryParam.productEntity.code = ''
  362. this.queryParam.productEntity.name = ''
  363. this.queryParam.warehouseSn = undefined
  364. this.queryParam.warehouseLocationSn = undefined
  365. this.queryParam.showCost = undefined
  366. this.queryParam.warehouseCascade = []
  367. this.queryParam.salesBillNo = ''
  368. this.queryParam.salesManName = ''
  369. this.productType = []
  370. this.$refs.ruleForm.resetFields()
  371. this.totalData = null
  372. this.$refs.table.clearTable()
  373. if (this.advanced) {
  374. this.$refs.custSatelliteList.resetForm()
  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. filterOption (input, option) {
  400. return (
  401. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  402. )
  403. },
  404. // 获取客户类型列表
  405. getCustTypeList () {
  406. const _this = this
  407. custTypeFindAllList().then(res => {
  408. if (res.status == 200) {
  409. _this.custTypeList = res.data || []
  410. } else {
  411. _this.custTypeList = []
  412. }
  413. })
  414. },
  415. // 产品分类 change
  416. changeProductType (val, opt) {
  417. this.queryParam.productEntity.productTypeSn1 = val[0] ? val[0] : ''
  418. this.queryParam.productEntity.productTypeSn2 = val[1] ? val[1] : ''
  419. this.queryParam.productEntity.productTypeSn3 = val[2] ? val[2] : ''
  420. },
  421. // 仓库仓位 级联 列表
  422. getWarehouseCascade () {
  423. warehouseCascadeList({}).then(res => {
  424. if (res.status == 200) {
  425. res.data.map(item => {
  426. item.sn = item.warehouseSn
  427. if (item.warehouseLocationList) {
  428. item.warehouseLocationList.map(subItem => {
  429. subItem.sn = subItem.warehouseLocationSn
  430. })
  431. }
  432. })
  433. this.warehouseCascadeData = res.data
  434. } else {
  435. this.warehouseCascadeData = []
  436. }
  437. })
  438. },
  439. // 仓库仓位change
  440. warehouseCascadeChange (val) {
  441. if (val && val.length > 0) {
  442. this.queryParam.warehouseSn = val[0] || ''
  443. this.queryParam.warehouseLocationSn = val[1] || ''
  444. } else {
  445. this.queryParam.warehouseSn = ''
  446. this.queryParam.warehouseLocationSn = ''
  447. }
  448. },
  449. // 获取城市列表
  450. getCityList (val) {
  451. this.addrCityList = []
  452. this.addrDistrictList = []
  453. this.queryParam.citySn = undefined
  454. this.queryParam.countySn = undefined
  455. if (val) {
  456. this.getArea('city', val)
  457. }
  458. },
  459. // 获取区县列表
  460. getAreaList (val) {
  461. this.addrDistrictList = []
  462. this.queryParam.countySn = undefined
  463. if (val) {
  464. this.getArea('district', val)
  465. }
  466. },
  467. // 省/市/区
  468. getArea (leve, sn) {
  469. let params
  470. if (leve == 'province') {
  471. params = { type: '2' }
  472. } else {
  473. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  474. }
  475. getArea(params).then(res => {
  476. if (res.status == 200) {
  477. if (leve == 'province') {
  478. this.addrProvinceList = res.data || []
  479. } else if (leve == 'city') {
  480. this.addrCityList = res.data || []
  481. } else if (leve == 'district') {
  482. this.addrDistrictList = res.data || []
  483. }
  484. } else {
  485. if (leve == 'province') {
  486. this.addrProvinceList = []
  487. } else if (leve == 'city') {
  488. this.addrCityList = []
  489. } else if (leve == 'district') {
  490. this.addrDistrictList = []
  491. }
  492. }
  493. })
  494. },
  495. pageInit () {
  496. this.disabled = false
  497. this.spinning = false
  498. this.getArea('province')
  499. this.getCustTypeList()
  500. this.getWarehouseCascade()
  501. }
  502. },
  503. mounted () {
  504. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  505. this.pageInit()
  506. this.resetSearchForm()
  507. }
  508. },
  509. activated () {
  510. // 如果是新页签打开,则重置当前页面
  511. if (this.$store.state.app.isNewTab) {
  512. this.pageInit()
  513. this.resetSearchForm()
  514. }
  515. },
  516. beforeRouteEnter (to, from, next) {
  517. next(vm => {})
  518. }
  519. }
  520. </script>