index.vue 22 KB

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