index.vue 19 KB

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