index.vue 12 KB

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