| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491 | <template>  <div>    <basic-container v-show="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"        @resetColumn="resetColumn"        :cell-style="cellStyle"        :summary-method="summaryMethod"        @selection-change="selectionChange"        @expand-change="expandChange"        @search-criteria-switch="searchCriteriaSwitch"      >        <template slot-scope="{ row }" slot="expand">          <avue-crud            :data="row.itemData"            :option="itemOption"            :table-loading="row.itemLoading"            :cell-style="cellStyle"            class="itemTable"          ></avue-crud>        </template>        <template slot-scope="{ row }" slot="createUser">          <span>{{ row.createUserName }}</span>        </template>        <template slot-scope="{ row }" slot="orderQuantity">          <span>{{ row.orderQuantity | IntegerFormat }}</span>        </template>        <template slot="portOfLoadSearch">          <port-info v-model="search.portOfLoad" />        </template>        <template slot="portOfDestinationSearch">          <port-info v-model="search.portOfDestination" />        </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="dateValiditySearch">          <el-date-picker            v-model="search.dateValidity"            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="createTimeSearch">          <el-date-picker            v-model="search.createTime"            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="menuLeft">          <el-button            type="primary"            icon="el-icon-plus"            size="small"            @click.stop="newAdd()"            >创建单据          </el-button>          <el-button            type="success"            size="small"            @click.stop="copyDoc()"            :disabled="selectionList.length != 1"            >复制单据</el-button          >          <el-button type="info" size="small">报表</el-button>        </template>        <template slot="corpIdSearch">          <crop-select v-model="search.corpId" corpType="KH"></crop-select>        </template>        <template slot-scope="scope" slot="corpId">          <span            style="color: #409EFF;cursor: pointer"            @click.stop="editOpen(scope.row, 1)"            >{{ scope.row.corpsName }}          </span>        </template>        <template slot-scope="scope" slot="orderNo">          <span            style="color: #409EFF;cursor: pointer"            @click.stop="editOpen(scope.row, 1)"            >{{ scope.row.orderNo }}          </span>        </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-delete"            size="small"            @click.stop="rowDel(scope.row, scope.index)"            >删除          </el-button>        </template>      </avue-crud>    </basic-container>    <detail-page      @goBack="goBack"      @copyOrder="copyOrder"      :detailData="detailData"      v-if="!show"    ></detail-page>  </div></template><script>import option from "./config/mainList.json";import {  getList,  remove,  gainUser,  getGoodsInfo} from "@/api/basicData/customerInquiry";import detailPage from "./detailsPage";import { defaultDate } from "@/util/date";import { micrometerFormat, IntegerFormat } from "@/util/validate";import _ from "lodash";export default {  name: "customerInformation",  data() {    return {      search: {        businesDate: defaultDate()      },      form: {},      option: {},      parentId: 0,      dataList: [],      page: {        pageSize: 10,        currentPage: 1,        total: 0,        pageSizes: [10, 50, 100, 200, 300, 400, 500]      },      show: true,      detailData: {},      loading: false,      searchShow: true,      selectionList: [],      itemOption: {        align: "center",        header: false,        menu: false,        column: [          {            label: "产品类别",            prop: "priceCategory",            width: 138,            overHidden: true          },          {            label: "产品名称",            prop: "cname",            width: 100,            overHidden: true          },          {            label: "产品描述",            prop: "itemDescription",            width: 100,            overHidden: true          },          {            label: "配件描述",            prop: "partsDescribe",            width: 100,            overHidden: true          },          {            label: "配件价格描述",            prop: "partsPriceDescribe",            width: 100,            overHidden: true          },          {            label: "数量",            prop: "orderQuantity",            width: 100,            overHidden: true          },          {            label: "金额",            prop: "amount",            width: 100,            overHidden: true          }        ]      }    };  },  components: { detailPage },  async created() {    /**     * 已定义全局方法,直接使用,getColumnData获取列数据,参数传值(表格名称,引入的本地JSON的数据定义的名称)     * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名     * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码     */    this.option = await this.getColumnData(this.getColumnName(0), option);    this.getWorkDicts("order_status").then(res => {      this.findObject(this.option.column, "orderStatus").dicData =        res.data.data;    });    gainUser().then(res => {      this.findObject(this.option.column, "createUser").dicData = res.data.data;    });    this.option.height = window.innerHeight - 210;  },  filters: {    IntegerFormat(num) {      return IntegerFormat(num);    }  },  activated() {    if (!this.$store.getters.bjStatus && !this.show) {      this.show = true;    }    if (this.$route.query.id) {      setTimeout(() => {        this.editOpen({ id: this.$route.query.id }, 1);      }, 100);    }  },  methods: {    searchCriteriaSwitch(type) {      if (type) {        this.option.height = this.option.height - 191;      } else {        this.option.height = this.option.height + 191;      }      this.$refs.crud.getTableHeight();    },    cellStyle() {      return "padding:0;height:40px;";    },    expandChange(row) {      if (!row.itemData) {        getGoodsInfo({ id: row.id, tradeType: "CK" })          .then(res => {            this.dataList[row.$index].itemData = res.data.data;          })          .finally(() => {            this.dataList[row.$index].itemLoading = false;          });      }    },    //删除列表后面的删除按钮触发触发(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);          }        });      });    },    selectionChange(list) {      this.selectionList = list;    },    editOpen(row, status) {      this.detailData = {        id: row.id,        status: status      };      this.show = false;      this.$store.commit("IN_BJ_STATUS");    },    copyDoc() {      this.selectionList.forEach(e => {        this.detailData = {          id: e.id,          status: "copy"        };        this.show = false;        this.$store.commit("IN_BJ_STATUS");      });    },    copyOrder(id) {      this.show = true;      this.detailData = {        id: id,        status: "copy"      };      this.$nextTick(() => {        this.show = false;        this.$store.commit("IN_BJ_STATUS");      });    },    //点击搜索按钮触发    searchChange(params, done) {      if (params.businesDate) {        params.orderStartDate = params.businesDate[0];        params.orderEndDate = params.businesDate[1];      }      if (params.dateValidity) {        params.dateValidityStart = params.dateValidity[0];        params.dateValidityEnd = params.dateValidity[1];      }      if (params.createTime) {        params.createTimeStart = params.createTime[0];        params.createTimeEnd = params.createTime[1];      }      this.search = this.deepClone(params);      delete params.businesDate;      delete params.dateValidity;      delete params.createTime;      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) {      if (this.search.businesDate && this.search.businesDate.length > 0) {        params = {          ...params,          orderStartDate: this.search.businesDate[0],          orderEndDate: this.search.businesDate[1]        };      }      let data = this.deepClone(Object.assign(params, this.search));      delete data.businesDate;      delete data.dateValidity;      delete data.createTime;      this.loading = true;      this.dataList.forEach(item => {        this.$refs.crud.toggleRowExpansion(item, false);      });      getList(page.currentPage, page.pageSize, 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;        })        .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;      this.$store.commit("IN_BJ_STATUS");    },    goBack() {      if (this.$route.query.id) {        this.$router.$avueRouter.closeTag(this.$route.fullPath);        this.$router.push({          path: "/exportTrade/customerInquiry/index"        });      }      this.detailData = this.$options.data().detailData;      this.show = true;      this.onLoad(this.page, this.search);      this.$store.commit("OUT_BJ_STATUS");    },    async saveColumn() {      /**       * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)       * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名       * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码       */      const inSave = await this.saveColumnData(        this.getColumnName(0),        this.option      );      if (inSave) {        this.$nextTick(() => {          this.$refs.crud.doLayout()        })        this.$message.success("保存成功");        //关闭窗口        this.$refs.crud.$refs.dialogColumn.columnBox = false;      }    },    async resetColumn() {      this.option = option;      const inSave = await this.delColumnData(this.getColumnName(0), option);      if (inSave) {        this.$nextTick(() => {          this.$refs.crud.doLayout()        })        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: 94.2vh;}.itemTable ::v-deep .el-table {  width: 738px;}</style>
 |