index.vue 21 KB

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