index.vue 23 KB

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