list.vue 20 KB

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