|  | @@ -0,0 +1,295 @@
 | 
	
		
			
				|  |  | +<template>
 | 
	
		
			
				|  |  | +  <div>
 | 
	
		
			
				|  |  | +    <basic-container v-if="show" class="page-crad">
 | 
	
		
			
				|  |  | +      <avue-crud
 | 
	
		
			
				|  |  | +        ref="crud"
 | 
	
		
			
				|  |  | +        :option="option"
 | 
	
		
			
				|  |  | +        :data="dataList"
 | 
	
		
			
				|  |  | +        v-model="form"
 | 
	
		
			
				|  |  | +        :page.sync="page"
 | 
	
		
			
				|  |  | +        :search.sync="search"
 | 
	
		
			
				|  |  | +        @search-change="searchChange"
 | 
	
		
			
				|  |  | +        @current-change="currentChange"
 | 
	
		
			
				|  |  | +        @size-change="sizeChange"
 | 
	
		
			
				|  |  | +        @refresh-change="refreshChange"
 | 
	
		
			
				|  |  | +        @on-load="onLoad"
 | 
	
		
			
				|  |  | +        :table-loading="loading"
 | 
	
		
			
				|  |  | +        @saveColumn="saveColumn"
 | 
	
		
			
				|  |  | +        :cell-style="cellStyle"
 | 
	
		
			
				|  |  | +        :summary-method="summaryMethod"
 | 
	
		
			
				|  |  | +      >
 | 
	
		
			
				|  |  | +        <template slot="menuLeft">
 | 
	
		
			
				|  |  | +          <el-button
 | 
	
		
			
				|  |  | +            type="primary"
 | 
	
		
			
				|  |  | +            icon="el-icon-plus"
 | 
	
		
			
				|  |  | +            size="small"
 | 
	
		
			
				|  |  | +            @click.stop="newAdd()"
 | 
	
		
			
				|  |  | +            >新单</el-button
 | 
	
		
			
				|  |  | +          >
 | 
	
		
			
				|  |  | +          <el-button type="info" size="small">报表</el-button>
 | 
	
		
			
				|  |  | +        </template>
 | 
	
		
			
				|  |  | +        <template slot="cnameSearch">
 | 
	
		
			
				|  |  | +          <goods-select 
 | 
	
		
			
				|  |  | +          v-model="search.cname"
 | 
	
		
			
				|  |  | +          :configuration="goodsConfiguration"
 | 
	
		
			
				|  |  | +          />
 | 
	
		
			
				|  |  | +        </template>
 | 
	
		
			
				|  |  | +        <template slot="corpIdSearch">
 | 
	
		
			
				|  |  | +          <select-component
 | 
	
		
			
				|  |  | +            v-model="search.corpId"
 | 
	
		
			
				|  |  | +            :configuration="configuration"
 | 
	
		
			
				|  |  | +          ></select-component>
 | 
	
		
			
				|  |  | +        </template>
 | 
	
		
			
				|  |  | +        <template slot-scope="scope" slot="corpId">
 | 
	
		
			
				|  |  | +          {{ scope.row.corpName }}
 | 
	
		
			
				|  |  | +        </template>
 | 
	
		
			
				|  |  | +        <template slot-scope="scope" slot="grossProfitRate">
 | 
	
		
			
				|  |  | +          {{ scope.row.grossProfitRate ? scope.row.grossProfitRate : 0 }}%
 | 
	
		
			
				|  |  | +        </template>
 | 
	
		
			
				|  |  | +        <template slot-scope="scope" slot="menu">
 | 
	
		
			
				|  |  | +          <el-button
 | 
	
		
			
				|  |  | +            type="text"
 | 
	
		
			
				|  |  | +            icon="el-icon-view"
 | 
	
		
			
				|  |  | +            size="small"
 | 
	
		
			
				|  |  | +            @click.stop="beforeOpenPage(scope.row, 1)"
 | 
	
		
			
				|  |  | +            >查看
 | 
	
		
			
				|  |  | +          </el-button>
 | 
	
		
			
				|  |  | +          <el-button
 | 
	
		
			
				|  |  | +            type="text"
 | 
	
		
			
				|  |  | +            icon="el-icon-edit"
 | 
	
		
			
				|  |  | +            size="small"
 | 
	
		
			
				|  |  | +            @click.stop="editOpen(scope.row, 2)"
 | 
	
		
			
				|  |  | +            >编辑
 | 
	
		
			
				|  |  | +          </el-button>
 | 
	
		
			
				|  |  | +          <el-button
 | 
	
		
			
				|  |  | +            type="text"
 | 
	
		
			
				|  |  | +            icon="el-icon-delete"
 | 
	
		
			
				|  |  | +            size="small"
 | 
	
		
			
				|  |  | +            @click.stop="rowDel(scope.row, scope.index)"
 | 
	
		
			
				|  |  | +            >删除
 | 
	
		
			
				|  |  | +          </el-button>
 | 
	
		
			
				|  |  | +        </template>
 | 
	
		
			
				|  |  | +      </avue-crud>
 | 
	
		
			
				|  |  | +    </basic-container>
 | 
	
		
			
				|  |  | +    <detail-page @goBack="goBack" :detailData="detailData" v-else></detail-page>
 | 
	
		
			
				|  |  | +  </div>
 | 
	
		
			
				|  |  | +</template>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +<script>
 | 
	
		
			
				|  |  | +import option from "./config/mainList.json";
 | 
	
		
			
				|  |  | +import { getList, remove} from "@/api/maintenance/priceLibrary";
 | 
	
		
			
				|  |  | +import detailPage from "./detailsPage.vue";
 | 
	
		
			
				|  |  | +import { defaultDate } from "@/util/date";
 | 
	
		
			
				|  |  | +import { micrometerFormat } from "@/util/validate";
 | 
	
		
			
				|  |  | +import _ from "lodash";
 | 
	
		
			
				|  |  | +export default {
 | 
	
		
			
				|  |  | +  name: "customerInformation",
 | 
	
		
			
				|  |  | +  data() {
 | 
	
		
			
				|  |  | +    return {
 | 
	
		
			
				|  |  | +      goodsConfiguration: {
 | 
	
		
			
				|  |  | +        multipleChoices: false,
 | 
	
		
			
				|  |  | +        multiple: false,
 | 
	
		
			
				|  |  | +        collapseTags: false,
 | 
	
		
			
				|  |  | +        placeholder: "请点击右边按钮选择",
 | 
	
		
			
				|  |  | +        dicData: [],
 | 
	
		
			
				|  |  | +        clearable: true
 | 
	
		
			
				|  |  | +      },
 | 
	
		
			
				|  |  | +      configuration: {
 | 
	
		
			
				|  |  | +        multipleChoices: false,
 | 
	
		
			
				|  |  | +        multiple: false,
 | 
	
		
			
				|  |  | +        collapseTags: false,
 | 
	
		
			
				|  |  | +        placeholder: "请点击右边按钮选择",
 | 
	
		
			
				|  |  | +        dicData: [],
 | 
	
		
			
				|  |  | +        clearable: true
 | 
	
		
			
				|  |  | +      },
 | 
	
		
			
				|  |  | +      search: {
 | 
	
		
			
				|  |  | +        businesDate: defaultDate()
 | 
	
		
			
				|  |  | +      },
 | 
	
		
			
				|  |  | +      form: {},
 | 
	
		
			
				|  |  | +      option: {},
 | 
	
		
			
				|  |  | +      parentId: 0,
 | 
	
		
			
				|  |  | +      dataList: [],
 | 
	
		
			
				|  |  | +      page: {
 | 
	
		
			
				|  |  | +        pageSize: 10,
 | 
	
		
			
				|  |  | +        currentPage: 1,
 | 
	
		
			
				|  |  | +        total: 0
 | 
	
		
			
				|  |  | +      },
 | 
	
		
			
				|  |  | +      show: true,
 | 
	
		
			
				|  |  | +      detailData: {},
 | 
	
		
			
				|  |  | +      loading: false
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  | +  },
 | 
	
		
			
				|  |  | +  components: { detailPage },
 | 
	
		
			
				|  |  | +  async created() {
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 已定义全局方法,直接使用,getColumnData获取列数据,参数传值(表格名称,引入的本地JSON的数据定义的名称)
 | 
	
		
			
				|  |  | +     * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
 | 
	
		
			
				|  |  | +     * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    this.option = await this.getColumnData(this.getColumnName(47), option);
 | 
	
		
			
				|  |  | +    let _this = this;
 | 
	
		
			
				|  |  | +    this.option.column.forEach(e => {
 | 
	
		
			
				|  |  | +      if (e.prop == "exchangeRate") {
 | 
	
		
			
				|  |  | +        e.formatter = function(row) {
 | 
	
		
			
				|  |  | +          return _this.textFormat(
 | 
	
		
			
				|  |  | +            Number(row.exchangeRate ? row.exchangeRate : 0) / 100,
 | 
	
		
			
				|  |  | +            "0.00%"
 | 
	
		
			
				|  |  | +          );
 | 
	
		
			
				|  |  | +        };
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      if (e.prop == "creditAmount") {
 | 
	
		
			
				|  |  | +        e.formatter = function(row) {
 | 
	
		
			
				|  |  | +          return _this.textFormat(
 | 
	
		
			
				|  |  | +            Number(row.creditAmount ? row.creditAmount : 0),
 | 
	
		
			
				|  |  | +            "#,##0.00"
 | 
	
		
			
				|  |  | +          );
 | 
	
		
			
				|  |  | +        };
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +  },
 | 
	
		
			
				|  |  | +  methods: {
 | 
	
		
			
				|  |  | +    cellStyle() {
 | 
	
		
			
				|  |  | +      return "padding:0;height:40px;";
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    //删除列表后面的删除按钮触发触发(row, index, done)
 | 
	
		
			
				|  |  | +    rowDel(row, index, done) {
 | 
	
		
			
				|  |  | +      this.$confirm("确定删除数据?", {
 | 
	
		
			
				|  |  | +        confirmButtonText: "确定",
 | 
	
		
			
				|  |  | +        cancelButtonText: "取消",
 | 
	
		
			
				|  |  | +        type: "warning"
 | 
	
		
			
				|  |  | +      }).then(() => {
 | 
	
		
			
				|  |  | +        remove(row.id).then(res => {
 | 
	
		
			
				|  |  | +          if (res.data.code == 200) {
 | 
	
		
			
				|  |  | +            this.$message({
 | 
	
		
			
				|  |  | +              type: "success",
 | 
	
		
			
				|  |  | +              message: "删除成功!"
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +            this.onLoad(this.page, this.search);
 | 
	
		
			
				|  |  | +          }
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +      });
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    //查看跳转页面
 | 
	
		
			
				|  |  | +    beforeOpenPage(row, status) {
 | 
	
		
			
				|  |  | +      this.detailData = {
 | 
	
		
			
				|  |  | +        id: row.id,
 | 
	
		
			
				|  |  | +        status: status
 | 
	
		
			
				|  |  | +      };
 | 
	
		
			
				|  |  | +      this.show = false;
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    editOpen(row, status) {
 | 
	
		
			
				|  |  | +      this.detailData = {
 | 
	
		
			
				|  |  | +        id: row.id,
 | 
	
		
			
				|  |  | +        status: status
 | 
	
		
			
				|  |  | +      };
 | 
	
		
			
				|  |  | +      this.show = false;
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    //点击搜索按钮触发
 | 
	
		
			
				|  |  | +    searchChange(params, done) {
 | 
	
		
			
				|  |  | +      this.page.currentPage = 1;
 | 
	
		
			
				|  |  | +      this.onLoad(this.page, params);
 | 
	
		
			
				|  |  | +      done();
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    currentChange(val) {
 | 
	
		
			
				|  |  | +      this.page.currentPage = val;
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    sizeChange(val) {
 | 
	
		
			
				|  |  | +      this.page.currentPage = 1;
 | 
	
		
			
				|  |  | +      this.page.pageSize = val;
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    onLoad(page, params) {
 | 
	
		
			
				|  |  | +      params={
 | 
	
		
			
				|  |  | +        ...params,
 | 
	
		
			
				|  |  | +        tradeType:"CK"
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      this.loading = true;
 | 
	
		
			
				|  |  | +      getList(page.currentPage, page.pageSize, params)
 | 
	
		
			
				|  |  | +        .then(res => {
 | 
	
		
			
				|  |  | +          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 - 450;
 | 
	
		
			
				|  |  | +          }
 | 
	
		
			
				|  |  | +        })
 | 
	
		
			
				|  |  | +        .finally(() => {
 | 
	
		
			
				|  |  | +          this.loading = false;
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    summaryMethod({ columns, data }) {
 | 
	
		
			
				|  |  | +      const sums = [];
 | 
	
		
			
				|  |  | +      if (columns.length > 0) {
 | 
	
		
			
				|  |  | +        columns.forEach((item, index) => {
 | 
	
		
			
				|  |  | +          sums[0] = "合计";
 | 
	
		
			
				|  |  | +          if (
 | 
	
		
			
				|  |  | +            item.property == "orderQuantity" ||
 | 
	
		
			
				|  |  | +            item.property == "amount" ||
 | 
	
		
			
				|  |  | +            item.property == "purchaseAmount"
 | 
	
		
			
				|  |  | +          ) {
 | 
	
		
			
				|  |  | +            let qtySum = 0;
 | 
	
		
			
				|  |  | +            let instoreSum = 0;
 | 
	
		
			
				|  |  | +            let totalSum = 0;
 | 
	
		
			
				|  |  | +            data.forEach(e => {
 | 
	
		
			
				|  |  | +              qtySum = _.add(qtySum, Number(e.orderQuantity));
 | 
	
		
			
				|  |  | +              instoreSum = _.add(instoreSum, Number(e.amount));
 | 
	
		
			
				|  |  | +              totalSum = _.add(totalSum, Number(e.purchaseAmount));
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +            //数量总计
 | 
	
		
			
				|  |  | +            if (item.property == "orderQuantity") {
 | 
	
		
			
				|  |  | +              sums[index] = qtySum ? qtySum.toFixed(2) : "0.00";
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            //入库金额总计
 | 
	
		
			
				|  |  | +            if (item.property == "amount") {
 | 
	
		
			
				|  |  | +              sums[index] = micrometerFormat(instoreSum);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            //金额总计
 | 
	
		
			
				|  |  | +            if (item.property == "purchaseAmount") {
 | 
	
		
			
				|  |  | +              sums[index] = micrometerFormat(totalSum);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +          }
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      return sums;
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    refreshChange() {
 | 
	
		
			
				|  |  | +      this.onLoad(this.page, this.search);
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    newAdd() {
 | 
	
		
			
				|  |  | +      this.show = false;
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    goBack() {
 | 
	
		
			
				|  |  | +      this.detailData = this.$options.data().detailData;
 | 
	
		
			
				|  |  | +      this.show = true;
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    async saveColumn() {
 | 
	
		
			
				|  |  | +      /**
 | 
	
		
			
				|  |  | +       * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
 | 
	
		
			
				|  |  | +       * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
 | 
	
		
			
				|  |  | +       * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
 | 
	
		
			
				|  |  | +       */
 | 
	
		
			
				|  |  | +      const inSave = await this.saveColumnData(
 | 
	
		
			
				|  |  | +        this.getColumnName(47),
 | 
	
		
			
				|  |  | +        this.option
 | 
	
		
			
				|  |  | +      );
 | 
	
		
			
				|  |  | +      if (inSave) {
 | 
	
		
			
				|  |  | +        this.$message.success("保存成功");
 | 
	
		
			
				|  |  | +        //关闭窗口
 | 
	
		
			
				|  |  | +        this.$refs.crud.$refs.dialogColumn.columnBox = false;
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  },
 | 
	
		
			
				|  |  | +  watch: {
 | 
	
		
			
				|  |  | +    option: function() {
 | 
	
		
			
				|  |  | +      this.search.businesDate = defaultDate();
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +};
 | 
	
		
			
				|  |  | +</script>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +<style scoped>
 | 
	
		
			
				|  |  | +::v-deep .select-component {
 | 
	
		
			
				|  |  | +  display: flex;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +.page-crad ::v-deep .basic-container__card {
 | 
	
		
			
				|  |  | +  height: 86.5vh;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +</style>
 |