index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. <template>
  2. <div>
  3. <basic-container class="page-crad">
  4. <avue-crud
  5. ref="crud"
  6. :option="option"
  7. :data="dataList"
  8. :before-open="beforeOpen"
  9. :page.sync="page"
  10. :search.sync="search"
  11. :cell-style="cellStyle"
  12. @search-change="searchChange"
  13. @current-change="currentChange"
  14. @size-change="sizeChange"
  15. @refresh-change="refreshChange"
  16. @on-load="onLoad"
  17. :table-loading="loading"
  18. :summary-method="summaryMethod"
  19. @saveColumn="saveColumn"
  20. @resetColumn="resetColumn"
  21. @expand-change="expandChange"
  22. @search-criteria-switch="searchCriteriaSwitch"
  23. >
  24. <template slot="menuLeft">
  25. <el-button type="info" size="small" @click="outExport"
  26. >导出</el-button
  27. >
  28. </template>
  29. <template slot-scope="{ row }" slot="expand">
  30. <avue-crud
  31. :data="row.itemData"
  32. :option="itemOption"
  33. :table-loading="row.itemLoading"
  34. :cell-style="cellStyle"
  35. class="itemTable"
  36. >
  37. <template slot-scope="{ row }" slot="amount">
  38. <span>{{ row.amount | decimalFormat }}</span>
  39. </template>
  40. </avue-crud>
  41. </template>
  42. <template slot="corpIdSearch">
  43. <crop-select v-model="search.corpId" corpType="KH"></crop-select>
  44. </template>
  45. <template slot="businesDateSearch">
  46. <el-date-picker
  47. v-model="search.businesDate"
  48. type="daterange"
  49. start-placeholder="开始日期"
  50. end-placeholder="结束日期"
  51. format="yyyy-MM-dd"
  52. value-format="yyyy-MM-dd HH:mm:ss"
  53. :default-time="['00:00:00', '23:59:59']"
  54. >
  55. </el-date-picker>
  56. </template>
  57. <template slot-scope="{ row }" slot="purchasePrice">
  58. <span>{{ row.purchasePrice | decimalFormat }}</span>
  59. </template>
  60. <template slot-scope="{ row }" slot="outFactoryPrice">
  61. <span>{{ row.outFactoryPrice | decimalFormat }}</span>
  62. </template>
  63. <template slot-scope="{ row }" slot="amount">
  64. <span>{{ row.amount | decimalFormat }}</span>
  65. </template>
  66. <template slot-scope="{ row }" slot="procurementCost">
  67. <span>{{ row.procurementCost | decimalFormat }}</span>
  68. </template>
  69. <template slot-scope="{ row }" slot="partsCost">
  70. <span>{{ row.partsCost | decimalFormat }}</span>
  71. </template>
  72. <template slot-scope="{ row }" slot="grossProfit">
  73. <span>{{ row.grossProfit | decimalFormat }}</span>
  74. </template>
  75. <template slot-scope="{ row }" slot="fd">
  76. <span>{{ row.fd | decimalFormat }}</span>
  77. </template>
  78. <template slot-scope="{ row }" slot="fc">
  79. <span>{{ row.fc | decimalFormat }}</span>
  80. </template>
  81. <template slot-scope="{ row }" slot="singleTicketMargin">
  82. <span>{{ row.singleTicketMargin | decimalFormat }}</span>
  83. </template>
  84. <template slot-scope="scope" slot="orderNo">
  85. <span
  86. style="color: #409EFF;cursor: pointer"
  87. @click.stop="editOpen(scope.row)"
  88. >{{ scope.row.orderNo }}
  89. </span>
  90. </template>
  91. </avue-crud>
  92. </basic-container>
  93. </div>
  94. </template>
  95. <script>
  96. import { getToken } from "@/util/auth";
  97. import { getList, getProfitItem } from "@/api/statisticAnalysis/salesProfit";
  98. import { micrometerFormat } from "@/util/validate";
  99. import _ from "lodash";
  100. export default {
  101. name: "index",
  102. data() {
  103. return {
  104. form: {},
  105. search: {},
  106. dataList: [],
  107. loading: false,
  108. detailData: {},
  109. page: {
  110. pageSize: 20,
  111. currentPage: 1,
  112. total: 0,
  113. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  114. },
  115. option: {
  116. searchShow: true,
  117. searchMenuSpan: 16,
  118. align: "center",
  119. searchSpan: 8,
  120. border: true,
  121. index: true,
  122. addBtn: false,
  123. viewBtn: false,
  124. editBtn: false,
  125. delBtn: false,
  126. showSummary: true,
  127. searchIcon: true,
  128. searchIndex: 2,
  129. expand: true,
  130. expandWidth: 55,
  131. menu: false,
  132. column: [
  133. {
  134. label: "类别",
  135. prop: "billType",
  136. type: "select",
  137. searchValue: "XS",
  138. dicData: [
  139. {
  140. label: "销售",
  141. value: "XS"
  142. },
  143. {
  144. label: "报价",
  145. value: "BJ"
  146. }
  147. ],
  148. search: true
  149. },
  150. {
  151. label: "合同号",
  152. prop: "orderNo",
  153. overHidden: true,
  154. width: 100,
  155. search: true
  156. },
  157. {
  158. label: "客户名称",
  159. prop: "corpId",
  160. overHidden: true,
  161. width: 100,
  162. search: true,
  163. formatter: row => {
  164. return row.corpsName;
  165. }
  166. },
  167. {
  168. label: "合同日期",
  169. prop: "businesDate",
  170. type: "date",
  171. format: "yyyy-MM-dd",
  172. overHidden: true,
  173. search: true,
  174. width: 100
  175. },
  176. {
  177. label: "起运港",
  178. prop: "portOfLoad",
  179. overHidden: true,
  180. width: 100
  181. },
  182. {
  183. label: "目的港",
  184. prop: "portOfDestination",
  185. overHidden: true,
  186. width: 100
  187. },
  188. {
  189. label: "运输条款",
  190. prop: "transport",
  191. overHidden: true,
  192. width: 100
  193. },
  194. {
  195. label: "产品成本",
  196. prop: "procurementCost",
  197. overHidden: true,
  198. width: 100
  199. },
  200. {
  201. label: "配件成本",
  202. prop: "partsCost",
  203. overHidden: true,
  204. width: 100
  205. },
  206. {
  207. label: "采购报价",
  208. prop: "purchasePrice",
  209. overHidden: true,
  210. width: 100
  211. },
  212. {
  213. label: "出厂金额",
  214. prop: "outFactoryPrice",
  215. overHidden: true,
  216. width: 100
  217. },
  218. {
  219. label: "销售金额",
  220. prop: "amount",
  221. overHidden: true,
  222. width: 100
  223. },
  224. {
  225. label: "产品毛利",
  226. prop: "grossProfit",
  227. overHidden: true,
  228. width: 100
  229. },
  230. {
  231. label: "产品利率",
  232. prop: "grossProfitRate",
  233. overHidden: true,
  234. width: 100
  235. },
  236. {
  237. label: "费用应收",
  238. prop: "fd",
  239. overHidden: true,
  240. width: 100
  241. },
  242. {
  243. label: "费用应付",
  244. prop: "fc",
  245. overHidden: true,
  246. width: 100
  247. },
  248. {
  249. label: "单票利润",
  250. prop: "singleTicketMargin",
  251. overHidden: true,
  252. width: 100
  253. }
  254. ]
  255. },
  256. itemOption: {
  257. align: "center",
  258. header: false,
  259. menu: false,
  260. column: [
  261. {
  262. label: "产品类别",
  263. prop: "priceCategory",
  264. width: 100,
  265. overHidden: true
  266. },
  267. {
  268. label: "产品名称",
  269. prop: "cname",
  270. width: 100,
  271. overHidden: true
  272. },
  273. {
  274. label: "产品成本",
  275. prop: "purchaseAmount",
  276. width: 100,
  277. overHidden: true
  278. },
  279. {
  280. label: "原始成本",
  281. prop: "purchaseCost",
  282. width: 100,
  283. overHidden: true
  284. },
  285. {
  286. label: "配件成本",
  287. prop: "partsPrice",
  288. width: 100,
  289. overHidden: true
  290. },
  291. {
  292. label: "原始成本",
  293. prop: "partsCost",
  294. width: 100,
  295. overHidden: true
  296. },
  297. {
  298. label: "销售价",
  299. prop: "price",
  300. width: 100,
  301. overHidden: true
  302. },
  303. {
  304. label: "数量",
  305. prop: "orderQuantity",
  306. width: 100,
  307. overHidden: true
  308. },
  309. {
  310. label: "汇率",
  311. prop: "exchangeRate",
  312. width: 100,
  313. overHidden: true
  314. },
  315. {
  316. label: "销售金额",
  317. prop: "amount",
  318. width: 100,
  319. overHidden: true
  320. },
  321. {
  322. label: "产品毛利",
  323. prop: "productGrossMargin",
  324. width: 100,
  325. overHidden: true
  326. },
  327. {
  328. label: "产品毛利率 ",
  329. prop: "itemMargin",
  330. width: 100,
  331. overHidden: true
  332. }
  333. ]
  334. }
  335. };
  336. },
  337. filters: {
  338. decimalFormat(num) {
  339. return num ? Number(num).toFixed(2) : "0.00";
  340. }
  341. },
  342. methods: {
  343. cellStyle() {
  344. return "padding:0;height:40px;";
  345. },
  346. expandChange(row) {
  347. if (!row.itemData) {
  348. getProfitItem({ id: row.id })
  349. .then(res => {
  350. this.dataList[row.$index].itemData = res.data.data;
  351. })
  352. .finally(() => {
  353. this.dataList[row.$index].itemLoading = false;
  354. });
  355. }
  356. },
  357. searchCriteriaSwitch(type) {
  358. if (type) {
  359. this.option.height = this.option.height - 46;
  360. } else {
  361. this.option.height = this.option.height + 46;
  362. }
  363. this.$refs.crud.getTableHeight();
  364. },
  365. //点击搜索按钮触发
  366. searchChange(params, done) {
  367. if (!params.billType) {
  368. done();
  369. return this.$message.error("请选择类别");
  370. }
  371. if (params.businesDate) {
  372. params.contractStartDate = params.businesDate[0];
  373. params.contractEndDate = params.businesDate[1];
  374. }
  375. delete params.businesDate;
  376. this.page.currentPage = 1;
  377. this.onLoad(this.page, params);
  378. done();
  379. },
  380. refreshChange() {
  381. this.onLoad(this.page, this.search);
  382. },
  383. currentChange(val) {
  384. this.page.currentPage = val;
  385. },
  386. sizeChange(val) {
  387. this.page.currentPage = 1;
  388. this.page.pageSize = val;
  389. },
  390. onLoad(page, params = {}) {
  391. this.loading = true;
  392. if (!this.search.billType) {
  393. this.search.billType = "XS";
  394. }
  395. this.dataList.forEach(item => {
  396. this.$refs.crud.toggleRowExpansion(item, false);
  397. });
  398. let data = this.search
  399. delete data.businesDate
  400. getList(
  401. page.currentPage,
  402. page.pageSize,
  403. Object.assign(params, data)
  404. )
  405. .then(res => {
  406. if (res.data.data.records) {
  407. res.data.data.records.forEach(e => {
  408. e.itemLoading = true;
  409. });
  410. }
  411. this.dataList = res.data.data.records ? res.data.data.records : [];
  412. this.page.total = res.data.data.total;
  413. if (this.page.total) {
  414. this.option.height = window.innerHeight - 210;
  415. }
  416. })
  417. .finally(() => {
  418. this.loading = false;
  419. });
  420. },
  421. editOpen(row) {
  422. if (row.billType == "BJ") {
  423. this.$router.push({
  424. path: "/exportTrade/customerInquiry/index",
  425. query: {
  426. id: row.id
  427. }
  428. });
  429. } else {
  430. this.$router.push({
  431. path: "/exportTrade/salesContract/index",
  432. query: {
  433. id: row.id
  434. }
  435. });
  436. }
  437. },
  438. outExport() {
  439. if (!this.search.billType) {
  440. return this.$message.error("请选择类别");
  441. }
  442. window.open(
  443. `/api/blade-purchase-sales/exportOrder/exportProfit?${
  444. this.website.tokenHeader
  445. }=${getToken()}&billType=${this.search.billType}`
  446. );
  447. },
  448. summaryMethod({ columns, data }) {
  449. const sums = [];
  450. if (columns.length > 0) {
  451. columns.forEach((item, index) => {
  452. sums[0] = "合计";
  453. if (
  454. item.property == "purchasePrice" ||
  455. item.property == "amount" ||
  456. item.property == "grossProfit" ||
  457. item.property == "fd" ||
  458. item.property == "fc" ||
  459. item.property == "singleTicketMargin"||
  460. item.property == "outFactoryPrice"
  461. ) {
  462. let amountSum = 0;
  463. let purchaseAmountSum = 0;
  464. let grossProfitSum = 0;
  465. let fdSum = 0;
  466. let fcSum = 0;
  467. let singleTicketMarginSum = 0;
  468. let outFactoryPriceSum=0
  469. data.forEach(e => {
  470. amountSum = _.add(amountSum, Number(e.amount));
  471. purchaseAmountSum = _.add(
  472. purchaseAmountSum,
  473. Number(e.purchasePrice)
  474. );
  475. grossProfitSum = _.add(grossProfitSum, Number(e.grossProfit));
  476. fdSum = _.add(fdSum, Number(e.fd));
  477. fcSum = _.add(fcSum, Number(e.fc));
  478. singleTicketMarginSum = _.add(
  479. singleTicketMarginSum,
  480. Number(e.singleTicketMargin)
  481. );
  482. outFactoryPriceSum= _.add(
  483. outFactoryPriceSum,
  484. Number(e.outFactoryPrice)
  485. );
  486. });
  487. //入库金额总计
  488. if (item.property == "purchasePrice") {
  489. sums[index] = micrometerFormat(purchaseAmountSum);
  490. }
  491. if (item.property == "amount") {
  492. sums[index] = micrometerFormat(amountSum);
  493. }
  494. if (item.property == "grossProfit") {
  495. sums[index] = micrometerFormat(grossProfitSum);
  496. }
  497. if (item.property == "fd") {
  498. sums[index] = micrometerFormat(fdSum);
  499. }
  500. if (item.property == "fc") {
  501. sums[index] = micrometerFormat(fcSum);
  502. }
  503. if (item.property == "singleTicketMargin") {
  504. sums[index] = micrometerFormat(singleTicketMarginSum);
  505. }
  506. if (item.property == "outFactoryPrice") {
  507. sums[index] = micrometerFormat(outFactoryPriceSum);
  508. }
  509. }
  510. });
  511. }
  512. return sums;
  513. }
  514. }
  515. };
  516. </script>
  517. <style scoped>
  518. .page-crad ::v-deep .basic-container__card {
  519. height: 94.2vh;
  520. }
  521. ::v-deep .el-table__expanded-cell[class*="cell"] {
  522. padding: 0px;
  523. }
  524. .itemTable ::v-deep .el-table {
  525. width: 100%;
  526. }
  527. </style>