index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. <template>
  2. <div>
  3. <basic-container class="page-crad" v-show="show">
  4. <avue-crud ref="crud" :option="option" :data="dataList" :page.sync="page" :search.sync="search"
  5. :cell-style="cellStyle" @search-change="searchChange" @current-change="currentChange" @size-change="sizeChange"
  6. @refresh-change="refreshChange" @on-load="onLoad" :table-loading="loading" @saveColumn="saveColumn"
  7. @resetColumn="resetColumn" @search-criteria-switch="searchCriteriaSwitch" @search-reset="searchReset">
  8. <template slot="header">
  9. <el-table :data="commodityData" border size="small" @header-click="cellClick" style="width: 100%"
  10. v-loading="itemloading">
  11. <el-table-column v-for="(item, index) in commodityLabel" :key="index" :prop="item.prop" show-overflow-tooltip
  12. :label="item.label" />
  13. </el-table>
  14. </template>
  15. <template slot="menuLeft">
  16. <el-button type="info" icon="el-icon-printer" size="small" :loading="exportLoading" @click.stop="statement"
  17. v-if="false">报表打印
  18. </el-button>
  19. <el-button type="info" size="small" @click="outExport" icon="el-icon-download">导出</el-button>
  20. </template>
  21. <template slot="corpNameSearch">
  22. <crop-select v-model="search.corpId" corpType="KG"></crop-select>
  23. </template>
  24. <template slot="sizeSearch">
  25. <el-select v-model="search.size" placeholder="请选择">
  26. <el-option label="是" :value="1"></el-option>
  27. <el-option label="否" :value="0"></el-option>
  28. </el-select>
  29. </template>
  30. <template slot="customerName" slot-scope="scope">
  31. <span style="color: #409EFF;cursor: pointer" @click.stop="beforeOpenPage(scope.row, scope.index)">{{
  32. scope.row.customerName
  33. }}</span>
  34. </template>
  35. <template slot="whetherSettlementSearch">
  36. <el-checkbox v-model="search.whetherSettlement" :true-label="0" :false-label="1"></el-checkbox>
  37. </template>
  38. </avue-crud>
  39. </basic-container>
  40. <report-dialog :switchDialog="switchDialog" :searchValue="statementData" :reportName="'经销商-可用库存表'"
  41. @onClose="onClose()" />
  42. <detail v-if="!show" :detail-data="detailData" :trade-type="tradeType" @goBack="goBack"></detail>
  43. </div>
  44. </template>
  45. <script>
  46. import { getToken } from "@/util/auth";
  47. import { getList } from "@/api/statisticAnalysis/profitLedger";
  48. import { getStatisticsList, statisticsSum } from "@/api/tireMall/tirePartsMall/statisticAnalysis/index";
  49. import { micrometerFormat } from "@/util/validate";
  50. import _ from "lodash";
  51. import reportDialog from "@/components/report-dialog/main";
  52. import { gainUser } from "@/api/basicData/customerInquiry";
  53. import detail from "./detail";
  54. import {dateFormat} from "@/util/date";
  55. export default {
  56. name: "index",
  57. components: {
  58. reportDialog,
  59. detail
  60. },
  61. data() {
  62. return {
  63. itemloading: false,
  64. commodityLabel: [
  65. {
  66. id: 1,
  67. label: "收入",
  68. prop: "totalMoney",
  69. }, {
  70. id: 2,
  71. label: "成本",
  72. prop: "cost",
  73. }, {
  74. id: 3,
  75. label: "运费",
  76. prop: "freight",
  77. }, {
  78. id: 4,
  79. label: "毛利",
  80. prop: "profit",
  81. }
  82. ],
  83. commodityData: [], // 合计数据
  84. exportLoading: false,
  85. switchDialog: false,
  86. statementData: {},
  87. form: {},
  88. search: {
  89. whetherSettlement: 0,
  90. businesDateList:[dateFormat(new Date,'yyyy-MM'),dateFormat(new Date,'yyyy-MM')]
  91. },
  92. dataList: [],
  93. loading: false,
  94. detailData: {},
  95. page: {
  96. pageSize: 20,
  97. currentPage: 1,
  98. total: 0,
  99. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  100. },
  101. option: {},
  102. defaultOption: {
  103. // searchShow: true,
  104. align: "center",
  105. // searchSpan: 6,
  106. // searchMenuSpan: 24,
  107. border: true,
  108. index: true,
  109. addBtn: false,
  110. viewBtn: false,
  111. editBtn: false,
  112. delBtn: false,
  113. showSummary: true,
  114. summaryText: '合计',
  115. sumColumnList: [
  116. {
  117. name: 'totalMoney',
  118. type: 'sum'
  119. },
  120. {
  121. name: 'cost',
  122. type: 'sum'
  123. },
  124. {
  125. name: 'freight',
  126. type: 'sum'
  127. },
  128. {
  129. name: 'profit',
  130. type: 'sum'
  131. },
  132. ],
  133. // searchIcon: true,
  134. // searchIndex: 3,
  135. menu: false,
  136. column: [
  137. {
  138. label: '客户',
  139. prop: "customerName",
  140. type: "select",
  141. search: true,
  142. overHidden: true,
  143. props: {
  144. label: 'cname',
  145. value: 'id'
  146. },
  147. dicUrl: '/api/blade-sales-part/corpsDesc/listAll?cname={{key}}&corpType=KH&enableOrNot=1',
  148. },
  149. {
  150. label: '业务员',
  151. prop: "salerId",
  152. search: true,
  153. type: "select",
  154. props: {
  155. label: "name",
  156. value: "id"
  157. },
  158. dicUrl: "/api/blade-user/client/salerList",
  159. filterable: true,
  160. hide: true,
  161. },
  162. {
  163. label: '业务员',
  164. prop: "salerName",
  165. overHidden: true,
  166. },
  167. {
  168. label: "业务日期",
  169. prop: "businesDate",
  170. type: 'date',
  171. format: "yyyy-MM",
  172. valueFormat: "yyyy-MM",
  173. unlinkPanels: true,
  174. searchRange: true,
  175. overHidden: true,
  176. },
  177. {
  178. label: "业务日期",
  179. prop: "businesDateList",
  180. search: true,
  181. type: 'monthrange',
  182. format: "yyyy-MM",
  183. valueFormat: "yyyy-MM",
  184. unlinkPanels: true,
  185. searchRange: true,
  186. overHidden: true,
  187. hide: true
  188. },
  189. {
  190. label: "结清不显示",
  191. prop: "whetherSettlement",
  192. search: true,
  193. hide: true
  194. },
  195. {
  196. label: "收入",
  197. prop: "totalMoney",
  198. search: false,
  199. overHidden: true,
  200. },
  201. {
  202. label: "成本",
  203. prop: "cost",
  204. search: false,
  205. overHidden: true,
  206. },
  207. {
  208. label: "运费",
  209. prop: "freight",
  210. search: false,
  211. overHidden: true,
  212. },
  213. {
  214. label: "毛利",
  215. prop: "profit",
  216. search: false,
  217. overHidden: true,
  218. },
  219. ],
  220. },
  221. // 仓库配置
  222. configurationWarehouse: {
  223. multipleChoices: false,
  224. multiple: false,
  225. collapseTags: false,
  226. placeholder: "请点击右边按钮选择",
  227. dicData: [],
  228. },
  229. brandOption: [],
  230. userList: [],
  231. tradeType: '',
  232. sysitemType: null,
  233. show: true,
  234. };
  235. },
  236. filters: {
  237. decimalFormat(num) {
  238. return num ? Number(num).toFixed(2) : "0.00";
  239. }
  240. },
  241. async created() {
  242. this.option = this.defaultOption;
  243. this.option = await this.getColumnData(this.getColumnName(286), this.defaultOption);
  244. this.getWorkDicts('brand').then(res => {
  245. this.brandOption = res.data.data;
  246. })
  247. gainUser().then(res => {
  248. this.userList = res.data.data;
  249. });
  250. this.search=this.deepClone(this.search)
  251. // let i = 0;
  252. // this.option.column.forEach(item => {
  253. // if (item.search) i++
  254. // })
  255. // if (i % 3 !== 0) {
  256. // const num = 3 - Number(i % 3)
  257. // this.option.searchMenuSpan = num * 8;
  258. // this.option.searchMenuPosition = "right";
  259. // }
  260. },
  261. methods: {
  262. cellStyle() {
  263. return "padding:0;height:40px;";
  264. },
  265. searchReset() {
  266. },
  267. searchCriteriaSwitch(type) {
  268. if (type) {
  269. this.option.height = this.option.height - 46;
  270. } else {
  271. this.option.height = this.option.height + 46;
  272. }
  273. this.$refs.crud.getTableHeight();
  274. },
  275. //点击搜索按钮触发
  276. searchChange(params, done) {
  277. this.page.currentPage = 1;
  278. this.onLoad(this.page, params);
  279. done();
  280. },
  281. refreshChange() {
  282. this.onLoad(this.page, this.search);
  283. },
  284. currentChange(val) {
  285. this.page.currentPage = val;
  286. },
  287. sizeChange(val) {
  288. this.page.currentPage = 1;
  289. this.page.pageSize = val;
  290. },
  291. onLoad(page, params) {
  292. this.search=this.deepClone(this.search)
  293. this.search.customerId = this.search.customerName
  294. this.sysitemType = localStorage.getItem('sysitemType');
  295. if (this.sysitemType == 999) {
  296. this.tradeType = ''
  297. } else if (this.sysitemType == 1) {
  298. this.tradeType = 'XX'
  299. } else if (this.sysitemType == 2) {
  300. this.tradeType = 'GN'
  301. } else if (this.sysitemType == 3) {
  302. this.tradeType = 'JK'
  303. } else if (this.sysitemType == 4) {
  304. this.tradeType = 'CK'
  305. } else if (this.sysitemType == 5) {
  306. this.tradeType = 'SW'
  307. } else if (this.sysitemType == 6) {
  308. this.tradeType = 'JXS'
  309. } else if (this.sysitemType == 7) {
  310. this.tradeType = 'LY'
  311. }
  312. this.loading = true;
  313. this.dataList.forEach(item => {
  314. this.$refs.crud.toggleRowExpansion(item, false);
  315. });
  316. let queryParams = this.deepClone(Object.assign({ type: 0 }, params, this.search));
  317. if (queryParams.accDate && queryParams.accDate.length > 0) {
  318. queryParams = {
  319. ...queryParams,
  320. accDateStart: queryParams.accDate[0],
  321. accDateEnd: queryParams.accDate[1],
  322. }
  323. delete queryParams.accDate;
  324. }
  325. getStatisticsList(
  326. page.currentPage,
  327. page.pageSize,
  328. queryParams
  329. )
  330. .then(res => {
  331. if (res.data.data.records) {
  332. res.data.data.records.forEach(e => {
  333. e.itemLoading = true;
  334. });
  335. }
  336. this.dataList = res.data.data.records ? res.data.data.records : [];
  337. this.page.total = res.data.data.total;
  338. this.itemloading = true,
  339. statisticsSum({ type: 0, ...queryParams }).then(res => {
  340. this.commodityData = [res.data.data]
  341. }).finally(() => {
  342. this.itemloading = false;
  343. });
  344. if (this.page.total) {
  345. this.option.height = window.innerHeight - 330;
  346. }
  347. })
  348. .finally(() => {
  349. this.loading = false;
  350. });
  351. },
  352. editOpen(row) {
  353. if (row.billType == "BJ") {
  354. this.$router.push({
  355. path: "/exportTrade/customerInquiry/index",
  356. query: {
  357. id: row.id
  358. }
  359. });
  360. } else {
  361. this.$router.push({
  362. path: "/exportTrade/salesContract/index",
  363. query: {
  364. id: row.id
  365. }
  366. });
  367. }
  368. },
  369. statement() {
  370. this.statementData = { ...this.search };
  371. if (this.statementData.accDate && this.statementData.accDate.length > 0) {
  372. this.statementData.accDateStart = this.statementData.accDate[0]
  373. this.statementData.accDateEnd = this.statementData.accDate[1]
  374. delete this.statementData.accDate
  375. }
  376. this.switchDialog = !this.switchDialog;
  377. },
  378. onClose(val) {
  379. this.switchDialog = val;
  380. },
  381. //列保存触发
  382. async saveColumn() {
  383. const inSave = await this.saveColumnData(
  384. this.getColumnName(286),
  385. this.option
  386. );
  387. if (inSave) {
  388. this.$nextTick(() => {
  389. this.$refs.crud.doLayout();
  390. });
  391. this.$message.success("保存成功");
  392. //关闭窗口
  393. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  394. }
  395. },
  396. async resetColumn() {
  397. this.option = this.defaultOption;
  398. const inSave = await this.delColumnData(this.getColumnName(286), this.defaultOption);
  399. if (inSave) {
  400. this.$nextTick(() => {
  401. this.$refs.crud.doLayout()
  402. })
  403. this.$message.success("重置成功");
  404. //关闭窗口
  405. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  406. }
  407. },
  408. // 跳转到详情
  409. beforeOpenPage(row, index) {
  410. this.detailData = {
  411. customerId: row.customerId,
  412. businesDate: row.businesDate,
  413. salerId: row.salerId,
  414. };
  415. this.show = false;
  416. },
  417. goBack() {
  418. this.detailData = this.$options.data().detailData
  419. if (JSON.stringify(this.$route.query) != "{}") {
  420. this.$router.$avueRouter.closeTag();
  421. this.$router.push({
  422. path: "/statisticAnalysis/collectLedger/index"
  423. });
  424. }
  425. this.dataList.forEach(item => {
  426. this.$refs.crud.toggleRowExpansion(item, false)
  427. })
  428. this.show = true;
  429. this.onLoad(this.page, this.search);
  430. },
  431. outExport() {
  432. if (!this.search.corpId) this.$set(this.search, 'corpId', '');
  433. if (this.search.accDate && this.search.accDate.length > 0) {
  434. this.search = {
  435. ...this.search,
  436. accDateStart: this.search.accDate[0],
  437. accDateEnd: this.search.accDate[1]
  438. }
  439. } else {
  440. this.search = {
  441. ...this.search,
  442. accDateStart: '',
  443. accDateEnd: '',
  444. }
  445. }
  446. this.$confirm('是否导出应付总账信息?', '提示', {
  447. confirmButtonText: '确定',
  448. cancelButtonText: '取消',
  449. type: 'warning'
  450. }).then(() => {
  451. window.open(
  452. `/api/blade-sales-part/order/statistics-export?${this.website.tokenHeader
  453. }=${getToken()}&type=0&businesDateList[0]=${this.search.businesDateList[0] == null || this.search.businesDateList[0] === undefined ? '' : this.search.businesDateList[0]
  454. }&businesDateList[1]=${this.search.businesDateList[1] == null || this.search.businesDateList[1] === undefined ? '' : this.search.businesDateList[1]
  455. }&customerId=${this.search.customerName == null || this.search.customerName === undefined ? '' : this.search.customerName}`
  456. );
  457. }).catch(() => {
  458. this.$message({
  459. type: 'info',
  460. message: '已取消' //
  461. });
  462. })
  463. },
  464. }
  465. };
  466. </script>
  467. <style scoped>
  468. .page-crad ::v-deep .basic-container__card {
  469. height: 94.2vh;
  470. }
  471. ::v-deep .el-table__expanded-cell[class*="cell"] {
  472. padding: 0px;
  473. }
  474. .itemTable ::v-deep .el-table {
  475. width: 100%;
  476. }
  477. /deep/ .el-col-md-8 {
  478. width: 24.33333%;
  479. }
  480. </style>