123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529 |
- <template>
- <div>
- <basic-container class="page-crad">
- <avue-crud
- ref="crud"
- :option="option"
- :data="dataList"
- :before-open="beforeOpen"
- :page.sync="page"
- :search.sync="search"
- :cell-style="cellStyle"
- @search-change="searchChange"
- @current-change="currentChange"
- @size-change="sizeChange"
- @refresh-change="refreshChange"
- @on-load="onLoad"
- :table-loading="loading"
- :summary-method="summaryMethod"
- @saveColumn="saveColumn"
- @resetColumn="resetColumn"
- @expand-change="expandChange"
- @search-criteria-switch="searchCriteriaSwitch"
- >
- <template slot="menuLeft">
- <el-button type="info" size="small" @click="outExport"
- >导出</el-button
- >
- </template>
- <template slot-scope="{ row }" slot="expand">
- <avue-crud
- :data="row.itemData"
- :option="itemOption"
- :table-loading="row.itemLoading"
- :cell-style="cellStyle"
- class="itemTable"
- >
- <template slot-scope="{ row }" slot="amount">
- <span>{{ row.amount | decimalFormat }}</span>
- </template>
- </avue-crud>
- </template>
- <template slot="corpIdSearch">
- <crop-select v-model="search.corpId" corpType="KH"></crop-select>
- </template>
- <template slot="businesDateSearch">
- <el-date-picker
- v-model="search.businesDate"
- type="daterange"
- start-placeholder="开始日期"
- end-placeholder="结束日期"
- format="yyyy-MM-dd"
- value-format="yyyy-MM-dd HH:mm:ss"
- :default-time="['00:00:00', '23:59:59']"
- >
- </el-date-picker>
- </template>
- <template slot-scope="{ row }" slot="purchasePrice">
- <span>{{ row.purchasePrice | decimalFormat }}</span>
- </template>
- <template slot-scope="{ row }" slot="outFactoryPrice">
- <span>{{ row.outFactoryPrice | decimalFormat }}</span>
- </template>
- <template slot-scope="{ row }" slot="amount">
- <span>{{ row.amount | decimalFormat }}</span>
- </template>
- <template slot-scope="{ row }" slot="procurementCost">
- <span>{{ row.procurementCost | decimalFormat }}</span>
- </template>
- <template slot-scope="{ row }" slot="partsCost">
- <span>{{ row.partsCost | decimalFormat }}</span>
- </template>
- <template slot-scope="{ row }" slot="grossProfit">
- <span>{{ row.grossProfit | decimalFormat }}</span>
- </template>
- <template slot-scope="{ row }" slot="fd">
- <span>{{ row.fd | decimalFormat }}</span>
- </template>
- <template slot-scope="{ row }" slot="fc">
- <span>{{ row.fc | decimalFormat }}</span>
- </template>
- <template slot-scope="{ row }" slot="singleTicketMargin">
- <span>{{ row.singleTicketMargin | decimalFormat }}</span>
- </template>
- <template slot-scope="scope" slot="orderNo">
- <span
- style="color: #409EFF;cursor: pointer"
- @click.stop="editOpen(scope.row)"
- >{{ scope.row.orderNo }}
- </span>
- </template>
- </avue-crud>
- </basic-container>
- </div>
- </template>
- <script>
- import { getToken } from "@/util/auth";
- import { getList, getProfitItem } from "@/api/statisticAnalysis/salesProfit";
- import { micrometerFormat } from "@/util/validate";
- import _ from "lodash";
- export default {
- name: "index",
- data() {
- return {
- form: {},
- search: {},
- dataList: [],
- loading: false,
- detailData: {},
- page: {
- pageSize: 20,
- currentPage: 1,
- total: 0,
- pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
- },
- option: {
- searchShow: true,
- searchMenuSpan: 16,
- align: "center",
- searchSpan: 8,
- border: true,
- index: true,
- addBtn: false,
- viewBtn: false,
- editBtn: false,
- delBtn: false,
- showSummary: true,
- searchIcon: true,
- searchIndex: 2,
- expand: true,
- expandWidth: 55,
- menu: false,
- column: [
- {
- label: "类别",
- prop: "billType",
- type: "select",
- searchValue: "XS",
- dicData: [
- {
- label: "销售",
- value: "XS"
- },
- {
- label: "报价",
- value: "BJ"
- }
- ],
- search: true
- },
- {
- label: "合同号",
- prop: "orderNo",
- overHidden: true,
- width: 100,
- search: true
- },
- {
- label: "客户名称",
- prop: "corpId",
- overHidden: true,
- width: 100,
- search: true,
- formatter: row => {
- return row.corpsName;
- }
- },
- {
- label: "合同日期",
- prop: "businesDate",
- type: "date",
- format: "yyyy-MM-dd",
- overHidden: true,
- search: true,
- width: 100
- },
- {
- label: "起运港",
- prop: "portOfLoad",
- overHidden: true,
- width: 100
- },
- {
- label: "目的港",
- prop: "portOfDestination",
- overHidden: true,
- width: 100
- },
- {
- label: "运输条款",
- prop: "transport",
- overHidden: true,
- width: 100
- },
- {
- label: "产品成本",
- prop: "procurementCost",
- overHidden: true,
- width: 100
- },
- {
- label: "配件成本",
- prop: "partsCost",
- overHidden: true,
- width: 100
- },
- {
- label: "采购报价",
- prop: "purchasePrice",
- overHidden: true,
- width: 100
- },
- {
- label: "出厂金额",
- prop: "outFactoryPrice",
- overHidden: true,
- width: 100
- },
- {
- label: "销售金额",
- prop: "amount",
- overHidden: true,
- width: 100
- },
- {
- label: "产品毛利",
- prop: "grossProfit",
- overHidden: true,
- width: 100
- },
- {
- label: "产品利率",
- prop: "grossProfitRate",
- overHidden: true,
- width: 100
- },
- {
- label: "费用应收",
- prop: "fd",
- overHidden: true,
- width: 100
- },
- {
- label: "费用应付",
- prop: "fc",
- overHidden: true,
- width: 100
- },
- {
- label: "单票利润",
- prop: "singleTicketMargin",
- overHidden: true,
- width: 100
- }
- ]
- },
- itemOption: {
- align: "center",
- header: false,
- menu: false,
- column: [
- {
- label: "产品类别",
- prop: "priceCategory",
- width: 100,
- overHidden: true
- },
- {
- label: "产品名称",
- prop: "cname",
- width: 100,
- overHidden: true
- },
- {
- label: "产品成本",
- prop: "purchaseAmount",
- width: 100,
- overHidden: true
- },
- {
- label: "原始成本",
- prop: "purchaseCost",
- width: 100,
- overHidden: true
- },
- {
- label: "配件成本",
- prop: "partsPrice",
- width: 100,
- overHidden: true
- },
- {
- label: "原始成本",
- prop: "partsCost",
- width: 100,
- overHidden: true
- },
- {
- label: "销售价",
- prop: "price",
- width: 100,
- overHidden: true
- },
- {
- label: "数量",
- prop: "orderQuantity",
- width: 100,
- overHidden: true
- },
- {
- label: "汇率",
- prop: "exchangeRate",
- width: 100,
- overHidden: true
- },
- {
- label: "销售金额",
- prop: "amount",
- width: 100,
- overHidden: true
- },
- {
- label: "产品毛利",
- prop: "productGrossMargin",
- width: 100,
- overHidden: true
- },
- {
- label: "产品毛利率 ",
- prop: "itemMargin",
- width: 100,
- overHidden: true
- }
- ]
- }
- };
- },
- filters: {
- decimalFormat(num) {
- return num ? Number(num).toFixed(2) : "0.00";
- }
- },
- methods: {
- cellStyle() {
- return "padding:0;height:40px;";
- },
- expandChange(row) {
- if (!row.itemData) {
- getProfitItem({ id: row.id })
- .then(res => {
- this.dataList[row.$index].itemData = res.data.data;
- })
- .finally(() => {
- this.dataList[row.$index].itemLoading = false;
- });
- }
- },
- searchCriteriaSwitch(type) {
- if (type) {
- this.option.height = this.option.height - 46;
- } else {
- this.option.height = this.option.height + 46;
- }
- this.$refs.crud.getTableHeight();
- },
- //点击搜索按钮触发
- searchChange(params, done) {
- if (!params.billType) {
- done();
- return this.$message.error("请选择类别");
- }
- if (params.businesDate) {
- params.contractStartDate = params.businesDate[0];
- params.contractEndDate = params.businesDate[1];
- }
- delete params.businesDate;
- this.page.currentPage = 1;
- this.onLoad(this.page, params);
- done();
- },
- refreshChange() {
- this.onLoad(this.page, this.search);
- },
- currentChange(val) {
- this.page.currentPage = val;
- },
- sizeChange(val) {
- this.page.currentPage = 1;
- this.page.pageSize = val;
- },
- onLoad(page, params = {}) {
- this.loading = true;
- if (!this.search.billType) {
- this.search.billType = "XS";
- }
- this.dataList.forEach(item => {
- this.$refs.crud.toggleRowExpansion(item, false);
- });
- let data = this.search
- delete data.businesDate
- getList(
- page.currentPage,
- page.pageSize,
- Object.assign(params, data)
- )
- .then(res => {
- if (res.data.data.records) {
- res.data.data.records.forEach(e => {
- e.itemLoading = true;
- });
- }
- this.dataList = res.data.data.records ? res.data.data.records : [];
- this.page.total = res.data.data.total;
- if (this.page.total) {
- this.option.height = window.innerHeight - 210;
- }
- })
- .finally(() => {
- this.loading = false;
- });
- },
- editOpen(row) {
- if (row.billType == "BJ") {
- this.$router.push({
- path: "/exportTrade/customerInquiry/index",
- query: {
- id: row.id
- }
- });
- } else {
- this.$router.push({
- path: "/exportTrade/salesContract/index",
- query: {
- id: row.id
- }
- });
- }
- },
- outExport() {
- if (!this.search.billType) {
- return this.$message.error("请选择类别");
- }
- window.open(
- `/api/blade-purchase-sales/exportOrder/exportProfit?${
- this.website.tokenHeader
- }=${getToken()}&billType=${this.search.billType}`
- );
- },
- summaryMethod({ columns, data }) {
- const sums = [];
- if (columns.length > 0) {
- columns.forEach((item, index) => {
- sums[0] = "合计";
- if (
- item.property == "purchasePrice" ||
- item.property == "amount" ||
- item.property == "grossProfit" ||
- item.property == "fd" ||
- item.property == "fc" ||
- item.property == "singleTicketMargin"||
- item.property == "outFactoryPrice"
- ) {
- let amountSum = 0;
- let purchaseAmountSum = 0;
- let grossProfitSum = 0;
- let fdSum = 0;
- let fcSum = 0;
- let singleTicketMarginSum = 0;
- let outFactoryPriceSum=0
- data.forEach(e => {
- amountSum = _.add(amountSum, Number(e.amount));
- purchaseAmountSum = _.add(
- purchaseAmountSum,
- Number(e.purchasePrice)
- );
- grossProfitSum = _.add(grossProfitSum, Number(e.grossProfit));
- fdSum = _.add(fdSum, Number(e.fd));
- fcSum = _.add(fcSum, Number(e.fc));
- singleTicketMarginSum = _.add(
- singleTicketMarginSum,
- Number(e.singleTicketMargin)
- );
- outFactoryPriceSum= _.add(
- outFactoryPriceSum,
- Number(e.outFactoryPrice)
- );
- });
- //入库金额总计
- if (item.property == "purchasePrice") {
- sums[index] = micrometerFormat(purchaseAmountSum);
- }
- if (item.property == "amount") {
- sums[index] = micrometerFormat(amountSum);
- }
- if (item.property == "grossProfit") {
- sums[index] = micrometerFormat(grossProfitSum);
- }
- if (item.property == "fd") {
- sums[index] = micrometerFormat(fdSum);
- }
- if (item.property == "fc") {
- sums[index] = micrometerFormat(fcSum);
- }
- if (item.property == "singleTicketMargin") {
- sums[index] = micrometerFormat(singleTicketMarginSum);
- }
- if (item.property == "outFactoryPrice") {
- sums[index] = micrometerFormat(outFactoryPriceSum);
- }
- }
- });
- }
- return sums;
- }
- }
- };
- </script>
- <style scoped>
- .page-crad ::v-deep .basic-container__card {
- height: 94.2vh;
- }
- ::v-deep .el-table__expanded-cell[class*="cell"] {
- padding: 0px;
- }
- .itemTable ::v-deep .el-table {
- width: 100%;
- }
- </style>
|