index.vue 18 KB

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