index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. <template>
  2. <basic-container>
  3. <avue-crud :key="key" ref="crud" :option="option" :data="data" :search.sync="query" @on-load="onLoad" :table-loading="loading"
  4. @search-reset="resetChange" :page.sync="page" :cell-style="cellStyle" @search-change="searchChange"
  5. @resetColumn="resetColumnTwo('crud', 'option', 'optionList', 337.2)"
  6. @saveColumn="saveColumnTwo('crud', 'option', 'optionList', 337.2)">
  7. <template slot="menuLeft">
  8. <el-button type="warning" icon="el-icon-download" size="small" @click="outExport">导出</el-button>
  9. </template>
  10. <template slot="header">
  11. <el-table :data="commodityData" border size="small" @header-click="cellClick" style="width: 100%" v-loading="loading">
  12. <el-table-column v-for="(item, index) in commodityLabel" :key="index" :prop="item.prop"
  13. show-overflow-tooltip :label="item.label"/>
  14. </el-table>
  15. </template>
  16. <!-- <template slot="customerNameSearch">
  17. <search-query :datalist="customerData" :selectValue="query.customerName" :filterable="true"
  18. :clearable="true" :remote="true" :buttonIf="false"
  19. :forParameter="{ key: 'id', label: 'cname', value: 'cname' }" placeholder="请选择客户名称"
  20. @remoteMethod="KHgetListfun" @corpFocus="KHgetListfun" @corpChange="corpChange($event, 'customerName')">
  21. </search-query>
  22. </template> -->
  23. <template slot="brandNameSearch">
  24. <search-query :datalist="brandData" :selectValue="query.brandName" :clearable="true" :buttonIf="false"
  25. :forParameter="{ key: 'id', label: 'cname', value: 'cname' }" placeholder="请选择品牌"
  26. @corpFocus="listAllfun" @corpChange="corpChange($event, 'brandName')">
  27. </search-query>
  28. </template>
  29. <template slot="storageIdSearch">
  30. <search-query :datalist="storageData" :selectValue="query.storageId" :clearable="true" :buttonIf="false"
  31. :forParameter="{ key: 'id', label: 'cname', value: 'id' }" placeholder="请选择品牌"
  32. @corpFocus="storageIdfun" @corpChange="corpChange($event, 'storageId')">
  33. </search-query>
  34. </template>
  35. <!--<template slot="goodsNameSearch">-->
  36. <!-- <search-query :datalist="goodsData"-->
  37. <!-- :selectValue="query.goodsName"-->
  38. <!-- :filterable="true"-->
  39. <!-- :clearable="true"-->
  40. <!-- :remote="true"-->
  41. <!-- :buttonIf="false"-->
  42. <!-- :forParameter="{key:'id',label:'cname',value:'cname'}"-->
  43. <!-- placeholder="请选择商品名称"-->
  44. <!-- @remoteMethod="SPgetListfun"-->
  45. <!-- @corpFocus="SPgetListfun"-->
  46. <!-- @corpChange="corpChange($event,'goodsName')">-->
  47. <!-- </search-query>-->
  48. <!--</template>-->
  49. <template slot="salerNameSearch">
  50. <search-query :datalist="salerData" :selectValue="query.salerName" :clearable="true" :buttonIf="false"
  51. :forParameter="{ key: 'id', label: 'name', value: 'name' }" placeholder="请选择业务员"
  52. @corpFocus="YWYgetListfun" @corpChange="corpChange($event, 'salerName')">
  53. </search-query>
  54. </template>
  55. <template slot="actualPaymentStatusSearch">
  56. <search-query :datalist="actualPaymentStatusData" :selectValue="query.actualPaymentStatus"
  57. :clearable="true" :buttonIf="false"
  58. :forParameter="{ key: 'dictKey', label: 'dictValue', value: 'dictKey' }" placeholder="请选择结算方式"
  59. @corpFocus="actualPaymentWorkDictsfun" @corpChange="corpChange($event, 'actualPaymentStatus')">
  60. </search-query>
  61. </template>
  62. <template slot="bsTypeSearch">
  63. <search-query :datalist="bsTypeData" :selectValue="query.bsType" :clearable="false" :buttonIf="false"
  64. :forParameter="{ key: 'dictKey', label: 'dictValue', value: 'dictKey' }" placeholder="请选择单据状态"
  65. @corpChange="corpChange($event, 'bsType')">
  66. </search-query>
  67. </template>
  68. <template slot="isContainSearch">
  69. <el-checkbox v-model="query.isContain" :true-label="1" :false-label="0"></el-checkbox>
  70. </template>
  71. <template slot="status" slot-scope="{ row }">
  72. <span>{{ row.status }}</span>
  73. </template>
  74. </avue-crud>
  75. </basic-container>
  76. </template>
  77. <script>
  78. import { statisticsSaleDetail, statisticsSaleDetailSum } from "@/api/saleDetail";
  79. import { defaultDate3 } from "@/util/date";
  80. import { getList as KHgetList } from '@/api/tirePartsMall/basicData/customerInformation/index'
  81. import { getList as SPgetList } from '@/api/tirePartsMall/basicData/commodityInformation/index'
  82. import SearchQuery from "@/components/iosbasic-data/searchquery.vue";
  83. import { getWorkDicts } from "@/api/system/dictbiz";
  84. import { getToken } from "@/util/auth";
  85. import { getSalesman } from "@/api/landTransportation";
  86. import { listAll, storageDesc } from "@/api/tirePartsMall/basicData/listingManagement";
  87. import { getParamservice } from "@/api/tirePartsMall/purchasingManagement/warehouseEntryOrder";
  88. export default {
  89. components: { SearchQuery },
  90. data() {
  91. return {
  92. loading:false,
  93. key: 0,
  94. data: [],
  95. total: [],
  96. storageData: [],
  97. query: {
  98. businesDateStart: defaultDate3()[0],
  99. businesDateEnd: defaultDate3()[1],
  100. isContain: 1,
  101. bsType: 'CG,TKCG,RZCG',
  102. },
  103. page: {
  104. pageSize: 10,
  105. currentPage: 1,
  106. total: 0,
  107. pageSizes: [10, 50, 100, 200, 300]
  108. },
  109. option: {},
  110. optionList: {
  111. align: 'center',
  112. stripe: true,
  113. index: true,
  114. menu: false,
  115. height: "auto",
  116. searchSpan: 6,
  117. // searchIcon: true,
  118. // searchIndex: 2,
  119. // highlightCurrentRow: true,
  120. border: true,
  121. searchMenuSpan: 18,
  122. addBtn: false,
  123. showSummary: true,
  124. summaryText: "合计",
  125. sumColumnList: [
  126. {
  127. name: 'goodsNum',
  128. type: 'sum',
  129. decimals: 0
  130. },
  131. {
  132. name: 'subTotalMoney',
  133. type: 'sum',
  134. decimals: 2
  135. },
  136. {
  137. name: 'costprie',
  138. type: 'sum',
  139. decimals: 2
  140. },
  141. {
  142. name: 'profit',
  143. type: 'sum',
  144. decimals: 2
  145. },
  146. {
  147. name: 'primaryGoodsTotalNum',
  148. type: 'sum',
  149. decimals: 0
  150. },
  151. {
  152. name: 'primaryGoodsTotalMoney',
  153. type: 'sum',
  154. decimals: 2
  155. },
  156. {
  157. name: 'price',
  158. type: 'sum',
  159. decimals: 2
  160. },
  161. {
  162. name: 'outGoodsTotalShipNum',
  163. type: 'sum',
  164. decimals: 0
  165. },
  166. {
  167. name: 'outGoodsTotalShipAmount',
  168. type: 'sum',
  169. decimals: 2
  170. },
  171. {
  172. name: 'surplusNum',
  173. type: 'sum',
  174. decimals: 0
  175. },
  176. {
  177. name: 'surplusAmount',
  178. type: 'sum',
  179. decimals: 2
  180. }
  181. ],
  182. column: [{
  183. label: '供应商名称',
  184. prop: 'customerName',
  185. overHidden: true,
  186. width: 100,
  187. search: true,
  188. searchslot: true,
  189. searchOrder: 3
  190. },
  191. // {
  192. // label: '业务员',
  193. // prop: 'salerName',
  194. // overHidden: true,
  195. // search: true,
  196. // searchslot: true,
  197. // searchOrder: 4
  198. // },
  199. {
  200. label: '仓库',
  201. prop: "storageName",
  202. searchProp: "storageId",
  203. search: true,
  204. overHidden: true,
  205. searchOrder: 9
  206. }, {
  207. label: '业务编号',
  208. prop: 'ordNo',
  209. overHidden: true,
  210. search: true,
  211. searchOrder: 5
  212. }, {
  213. label: '业务日期',
  214. prop: 'businesDate',
  215. overHidden: true,
  216. }, {
  217. label: '入库时间',
  218. prop: 'deliveryBusinesDate',
  219. overHidden: true,
  220. }, {
  221. label: '结算状态',
  222. prop: 'actualPaymentStatus',
  223. overHidden: true,
  224. search: true,
  225. searchslot: true,
  226. searchOrder: 7
  227. }, {
  228. label: '品牌',
  229. prop: 'brandName',
  230. overHidden: true,
  231. search: true,
  232. searchslot: true,
  233. searchOrder: 6.1,
  234. }, {
  235. label: '商品编码',
  236. prop: 'code',
  237. overHidden: true,
  238. search: true,
  239. searchslot: true,
  240. searchOrder: 6
  241. }, {
  242. label: '商品名称',
  243. prop: 'goodsName',
  244. overHidden: true,
  245. search: true,
  246. searchslot: true,
  247. searchOrder: 6
  248. }, {
  249. label: '规格型号',
  250. prop: 'propertyName',
  251. overHidden: true,
  252. }, {
  253. label: '花纹',
  254. prop: 'pattern',
  255. overHidden: true,
  256. },
  257. // {
  258. // label: '数量',
  259. // prop: 'goodsNum',
  260. // overHidden: true,
  261. // },
  262. {
  263. label: '价格',
  264. prop: 'price',
  265. overHidden: true,
  266. },
  267. // {
  268. // label: '金额',
  269. // prop: 'subTotalMoney',
  270. // overHidden: true,
  271. // },
  272. {
  273. label: '订单数量',
  274. prop: 'primaryGoodsTotalNum',
  275. overHidden: true,
  276. },
  277. {
  278. label: '订单金额',
  279. prop: 'primaryGoodsTotalMoney',
  280. overHidden: true,
  281. },
  282. {
  283. label: '入库数量',
  284. prop: 'goodsNum',
  285. overHidden: true,
  286. },
  287. {
  288. label: '入库金额',
  289. prop: 'subTotalMoney',
  290. overHidden: true,
  291. },
  292. {
  293. label: '卖出数量',
  294. prop: 'outGoodsTotalShipNum',
  295. overHidden: true,
  296. },
  297. {
  298. label: '卖出金额',
  299. prop: 'outGoodsTotalShipAmount',
  300. overHidden: true,
  301. },
  302. {
  303. label: '剩余数量',
  304. prop: 'surplusNum',
  305. overHidden: true,
  306. },
  307. {
  308. label: '剩余金额',
  309. prop: 'surplusAmount',
  310. overHidden: true,
  311. },
  312. // {
  313. // label: '成本',
  314. // prop: 'costprie',
  315. // overHidden: true,
  316. // },
  317. // {
  318. // label: '毛利',
  319. // prop: 'profit',
  320. // overHidden: true,
  321. // },
  322. {
  323. label: '业务开始',
  324. prop: 'businesDateStart',
  325. overHidden: true,
  326. search: true,
  327. hide: true,
  328. searchOrder: 1,
  329. type: "date",
  330. format: "yyyy-MM-dd",
  331. valueFormat: "yyyy-MM-dd",
  332. },
  333. {
  334. label: '业务结束',
  335. prop: 'businesDateEnd',
  336. overHidden: true,
  337. search: true,
  338. hide: true,
  339. searchOrder: 2,
  340. type: "date",
  341. format: "yyyy-MM-dd",
  342. valueFormat: "yyyy-MM-dd",
  343. },
  344. {
  345. label: '入库开始',
  346. prop: 'dateStart',
  347. overHidden: true,
  348. search: true,
  349. hide: true,
  350. searchOrder: 2.1,
  351. type: "date",
  352. format: "yyyy-MM-dd",
  353. valueFormat: "yyyy-MM-dd",
  354. },
  355. {
  356. label: '入库结束',
  357. prop: 'dateEnd',
  358. overHidden: true,
  359. search: true,
  360. hide: true,
  361. searchOrder: 2.2,
  362. type: "date",
  363. format: "yyyy-MM-dd",
  364. valueFormat: "yyyy-MM-dd",
  365. },
  366. {
  367. label: '单据状态',
  368. prop: 'status',
  369. overHidden: true,
  370. // search: true,
  371. // searchslot: true,
  372. // searchOrder: 8
  373. },
  374. {
  375. label: '业务类型',
  376. prop: 'bsType',
  377. overHidden: true,
  378. search: true,
  379. searchslot: true,
  380. searchOrder: 8
  381. },
  382. {
  383. label: '包含未收货',
  384. prop: 'isContain',
  385. overHidden: true,
  386. hide: true,
  387. search: true,
  388. searchslot: true,
  389. searchOrder: 10
  390. }]
  391. },
  392. bsTypeData: [],
  393. customerData: [], // 客户数据
  394. brandData: [], // 品牌数据
  395. goodsData: [], // 商品名称
  396. salerData: [], // 业务员
  397. actualPaymentStatusData: [], // 结算状态
  398. statusData: [], // 单据状态
  399. commodityData: [], // 合计数据
  400. // 合计的配置项
  401. commodityLabel: [{
  402. id: 1,
  403. label: '订单数量',
  404. prop: 'primaryGoodsTotalNum'
  405. },
  406. {
  407. id: 2,
  408. label: '订单金额',
  409. prop: 'primaryGoodsTotalMoney'
  410. },
  411. // {
  412. // id: 3,
  413. // label: '采购成本',
  414. // prop: 'costprie'
  415. // },
  416. // {
  417. // id: 4,
  418. // label: '采购毛利',
  419. // prop: 'profit'
  420. // },
  421. {
  422. id: 5,
  423. label: '已取消数量',
  424. prop: 'goodsSumCancellation'
  425. },
  426. {
  427. id: 6,
  428. label: '已取消金额',
  429. prop: 'amountCancellation'
  430. },
  431. {
  432. label: '入库数量',
  433. prop: 'goodsSum',
  434. },
  435. {
  436. label: '入库金额',
  437. prop: 'amount',
  438. },
  439. {
  440. label: '卖出数量',
  441. prop: 'outGoodsTotalShipNum',
  442. },
  443. {
  444. label: '卖出金额',
  445. prop: 'outGoodsTotalShipAmount',
  446. },
  447. {
  448. label: '剩余数量',
  449. prop: 'surplusNum',
  450. },
  451. {
  452. label: '剩余金额',
  453. prop: 'surplusAmount',
  454. },
  455. // {
  456. // id: 7,
  457. // label: '已取消成本',
  458. // prop: 'costprieCancellation'
  459. // },
  460. // {
  461. // id: 8,
  462. // label: '已取消毛利',
  463. // prop: 'profitCancellation'
  464. // }
  465. ],
  466. }
  467. },
  468. async created() {
  469. this.option = await this.getColumnData(this.getColumnName(337.2), this.optionList);
  470. getWorkDicts('cg_business_Type').then(res2 => {
  471. getParamservice(1, 10, { paramKey: 'whether.financing' }).then(res => {
  472. if (res.data.data.records.length) {
  473. res.data.data.records.forEach(e => {
  474. if (e.paramValue == 1) {
  475. this.bsTypeData = res2.data.data
  476. } else {
  477. this.bsTypeData = res2.data.data.filter(e => e.dictKey != "RZCG")
  478. }
  479. })
  480. } else {
  481. this.bsTypeData = res2.data.data.filter(e => e.dictKey != "RZCG")
  482. }
  483. })
  484. })
  485. this.query = this.deepClone(this.query)
  486. },
  487. methods: {
  488. resetChange() {
  489. this.query = {
  490. businesDateStart: defaultDate3()[0],
  491. businesDateEnd: defaultDate3()[1],
  492. isContain: 1,
  493. bsType: 'CG,TKCG,RZCG',
  494. }
  495. },
  496. cellStyle({ row, rowIndex }) {
  497. if (row.status == '已取消') {
  498. return 'color: red';
  499. }
  500. return
  501. },
  502. //导出
  503. outExport() {
  504. let config = { params: { ...this.query } }
  505. if (config.params) {
  506. for (const propName of Object.keys(config.params)) {
  507. const value = config.params[propName];
  508. if (value !== null && typeof (value) !== "undefined") {
  509. if (value instanceof Array) {
  510. for (const key of Object.keys(value)) {
  511. let params = propName + '[' + key + ']';
  512. config.params[params] = value[key]
  513. }
  514. delete config.params[propName]
  515. }
  516. }
  517. }
  518. }
  519. const routeData = this.$router.resolve({
  520. path: '/api/blade-sales-part/statistics/saleDetailExport', //跳转目标窗口的地址
  521. query: {
  522. ...config.params, //括号内是要传递给新窗口的参数
  523. }
  524. })
  525. window.open(routeData.href.slice(1, routeData.href.length) + '&' + `${this.website.tokenHeader}=${getToken()}`);
  526. },
  527. // 获取品牌数据
  528. listAllfun() {
  529. listAll().then(res => {
  530. this.brandData = res.data.data
  531. })
  532. },
  533. //获取仓库
  534. storageIdfun() {
  535. storageDesc().then(res => {
  536. this.storageData = res.data.data
  537. })
  538. },
  539. // 获取客户数据
  540. KHgetListfun(cname) {
  541. KHgetList({ current: 1, size: 20, corpType: 'GYS', cname: cname ? cname : null }).then(res => {
  542. this.customerData = res.data.data.records
  543. })
  544. },
  545. // 获取业务员数据
  546. YWYgetListfun(realName) {
  547. // YWYgetList(1,10,{realName:realName?realName:null}).then(res=>{
  548. // this.salerData = res.data.data.records
  549. // })
  550. getSalesman().then(res => {
  551. this.salerData = res.data.data
  552. })
  553. },
  554. // 获取商品数据
  555. SPgetListfun(cname) {
  556. SPgetList({ current: 1, size: 20, cname: cname ? cname : null }).then(res => {
  557. this.goodsData = res.data.data.records
  558. })
  559. },
  560. // 结算状态
  561. actualPaymentWorkDictsfun() {
  562. getWorkDicts('settlement_Status').then(res => {
  563. this.actualPaymentStatusData = res.data.data
  564. })
  565. },
  566. // 单据状态
  567. statusWorkDictsfun() {
  568. getWorkDicts('sales_Status').then(res => {
  569. this.statusData = res.data.data
  570. })
  571. },
  572. // 下拉回调
  573. corpChange(value, name) {
  574. this.$set(this.query, name, value)
  575. },
  576. //搜索
  577. searchChange(params, done) {
  578. this.query = params;
  579. this.onLoad(this.page, params)
  580. done();
  581. },
  582. // 获取列表数据
  583. onLoad(page, params = {}) {
  584. let queryParams = {
  585. size: page.pageSize,
  586. current: page.currentPage,
  587. bsType: 'CG,TKCG',
  588. ...Object.assign(params, this.query)
  589. }
  590. this.loading = true;
  591. statisticsSaleDetail(queryParams).then(res => {
  592. this.data = res.data.data.records
  593. this.page.total = res.data.data.total
  594. // this.option.height = window.innerHeight - 230;
  595. // generalLedgerTotal(queryParams).then(res=>{
  596. // this.total = res.data.data
  597. // })
  598. statisticsSaleDetailSum({ ...Object.assign(params, this.query) }).then(re => {
  599. this.commodityData = [re.data.data]
  600. })
  601. }).finally(() => {
  602. this.$refs.crud.doLayout();
  603. this.loading = false;
  604. })
  605. },
  606. //自定义列保存
  607. async saveColumnTwo(ref, option, optionBack, code) {
  608. /**
  609. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  610. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  611. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  612. */
  613. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  614. if (inSave) {
  615. this.$message.success("保存成功");
  616. //关闭窗口
  617. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  618. }
  619. },
  620. //自定义列重置
  621. async resetColumnTwo(ref, option, optionBack, code) {
  622. this[option] = this[optionBack];
  623. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  624. if (inSave) {
  625. this.$message.success("重置成功");
  626. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  627. }
  628. },
  629. }
  630. }
  631. </script>
  632. <style scoped></style>