<template>
  <div class="sys-box">
    <div class="sys-operate">
      <el-button type="primary" @click="goBack">返回</el-button>
      <span style="margin:0 50px;font-weight: bold">客户名称:{{clientName}}</span>
      <span style="margin:0 50px;font-weight: bold">合同编号:{{contractCode}}</span>
    </div>
    <div class="sys-tabs">
      <el-tabs v-model="activeName" @tab-click="getList">
        <el-tab-pane label="发货通知" name="1">
          <normalPage :disableBtn="false"
                      :formTableData="page1.formTableData"
                      :tableData="page1.tableData"
                      :listQuery="page1.search_data"
                      :total="page1.total"
                      :pictLoading="page1.pictLoading"
                      :summary="page1.summary"
                      @goToLink="goToLink(1,$event)"
                      :showSummaryColumn="page1.showSummaryColumn"
                      @handleCurrentChange="handleCurrentChange"
                      @handleSizeChange="handleSizeChange"
                      @handleSelectionChange="handleSelectionChange">
          </normalPage>
        </el-tab-pane>
        <el-tab-pane label="发货检验" name="2">
          <normalPage :disableBtn="false"
                      :formTableData="page2.formTableData"
                      :tableData="page2.tableData"
                      :listQuery="page2.search_data"
                      :total="page2.total"
                      :pictLoading="page2.pictLoading"
                      :summary="page2.summary"
                      @goToLink="goToLink(2,$event)"
                      :showSummaryColumn="page2.showSummaryColumn"
                      @handleCurrentChange="handleCurrentChange"
                      @handleSizeChange="handleSizeChange"
                      @handleSelectionChange="handleSelectionChange">
          </normalPage>
        </el-tab-pane>
        <el-tab-pane label="销售出库" name="3">
          <normalPage :disableBtn="false"
                      :formTableData="page3.formTableData"
                      :tableData="page3.tableData"
                      :listQuery="page3.search_data"
                      :total="page3.total"
                      :pictLoading="page3.pictLoading"
                      :summary="page3.summary"
                      @goToLink="goToLink(3,$event)"
                      :showSummaryColumn="page3.showSummaryColumn"
                      @handleCurrentChange="handleCurrentChange"
                      @handleSizeChange="handleSizeChange"
                      @handleSelectionChange="handleSelectionChange">
          </normalPage>
        </el-tab-pane>
        <el-tab-pane label="销售发票" name="4">
          <normalPage :disableBtn="false"
                      :formTableData="page4.formTableData"
                      :tableData="page4.tableData"
                      :listQuery="page4.search_data"
                      :total="page4.total"
                      :pictLoading="page4.pictLoading"
                      :summary="page4.summary"
                      @goToLink="goToLink(4,$event)"
                      :showSummaryColumn="page4.showSummaryColumn"
                      @handleCurrentChange="handleCurrentChange"
                      @handleSizeChange="handleSizeChange"
                      @handleSelectionChange="handleSelectionChange">
          </normalPage>
        </el-tab-pane>
        <el-tab-pane label="销售退货" name="5">
          <normalPage :disableBtn="false"
                      :formTableData="page5.formTableData"
                      :tableData="page5.tableData"
                      :listQuery="page5.search_data"
                      :total="page5.total"
                      :pictLoading="page5.pictLoading"
                      :summary="page5.summary"
                      @goToLink="goToLink(5,$event)"
                      :showSummaryColumn="page5.showSummaryColumn"
                      @handleCurrentChange="handleCurrentChange"
                      @handleSizeChange="handleSizeChange"
                      @handleSelectionChange="handleSelectionChange">
          </normalPage>
        </el-tab-pane>
        <el-tab-pane label="收款单" name="6">
          <normalPage :disableBtn="false"
                      :formTableData="page6.formTableData"
                      :tableData="page6.tableData"
                      :listQuery="page6.search_data"
                      :total="page6.total"
                      :pictLoading="page6.pictLoading"
                      :summary="page6.summary"
                      @goToLink="goToLink(6,$event)"
                      :showSummaryColumn="page6.showSummaryColumn"
                      @handleCurrentChange="handleCurrentChange"
                      @handleSizeChange="handleSizeChange"
                      @handleSelectionChange="handleSelectionChange">
          </normalPage>
        </el-tab-pane>
        <el-tab-pane label="生产计划" name="7">
          <normalPage :disableBtn="false"
                      :formTableData="page7.formTableData"
                      :tableData="page7.tableData"
                      :listQuery="page7.search_data"
                      :total="page7.total"
                      :pictLoading="page7.pictLoading"
                      :summary="page7.summary"
                      @goToLink="goToLink(7,$event)"
                      :showSummaryColumn="page7.showSummaryColumn"
                      @handleCurrentChange="handleCurrentChange"
                      @handleSizeChange="handleSizeChange"
                      @handleSelectionChange="handleSelectionChange">
          </normalPage>
        </el-tab-pane>
        <el-tab-pane label="工序计划" name="8">
          <normalPage :disableBtn="false"
                      :formTableData="page8.formTableData"
                      :tableData="page8.tableData"
                      :listQuery="page8.search_data"
                      :total="page8.total"
                      :pictLoading="page8.pictLoading"
                      :summary="page8.summary"
                      @goToLink="goToLink(8,$event)"
                      :showSummaryColumn="page8.showSummaryColumn"
                      @handleCurrentChange="handleCurrentChange"
                      @handleSizeChange="handleSizeChange"
                      @handleSelectionChange="handleSelectionChange">
          </normalPage>
        </el-tab-pane>
        <el-tab-pane label="生产入库" name="9">
          <normalPage :disableBtn="false"
                      :formTableData="page9.formTableData"
                      :tableData="page9.tableData"
                      :listQuery="page9.search_data"
                      :total="page9.total"
                      :pictLoading="page9.pictLoading"
                      :summary="page9.summary"
                      @goToLink="goToLink(9,$event)"
                      :showSummaryColumn="page9.showSummaryColumn"
                      @handleCurrentChange="handleCurrentChange"
                      @handleSizeChange="handleSizeChange"
                      @handleSelectionChange="handleSelectionChange">
          </normalPage>
        </el-tab-pane>
      </el-tabs>
    </div>
  </div>
</template>

<script>
import btnInput from "@/components/btnInput.vue";
import dialogChooseSingleParts from "@/components/System/dialogChooseSingleParts";
import {mapState, mapActions, mapGetters} from "vuex";
import FileSaver from 'file-saver'
import config from "@/utils/config.js";
import normalPage from "@/components/TabPages/normalPage";
export default {
  components: {
    btnInput,dialogChooseSingleParts,normalPage
  },
  data() {
    return {
      id:'',
      clientName:'',
      contractCode:'',
      page1:{
        summary:{},
        showSummaryColumn:[
          {name:'deliveryCount',value:'totalDeliveryCount'},
          {name:'deliveryCountSupport',value:'totalDeliveryCountSupport'},
          {name:'sellAmount',value:'totalSellAmount'}],
        formTableData:[
          {title: "通知日期", prop_: "noteTime", select: true},
          {title: "单据编号", prop_: "deliveryCode", select: true},
          {title: "客户名称", prop_: "clientName", select: true},
          {title: "物料代码", prop_: "materielSerialNo", select: true},
          {title: "物料名称", prop_: "materielName", select: true},
          {title: "规格型号", prop_: "specification", select: true},
          {title: "主计量单位", prop_: "unitUomName", select: true},
          {title: "主单位数量", prop_: "deliveryCount", select: true},
          {title: "辅助单位", prop_: "supportUomName", select: true},
          {title: "发货数量", prop_: "deliveryCountSupport", select: true},
          {title: "销售单价", prop_: "sellUnitPrice", select: true},
          {title: "销售金额", prop_: "sellAmount", select: true},
          {title: "部门", prop_: "deptName", select: true},
          {title: "销售员", prop_: "salesPersonName", select: true},
          {title: "审批状态", prop_: "approveStateName", select: true},
          {title: "源单类型", prop_: "sourceTypeName", select: true},
          {title: "源单单号", prop_: "sourceCode", select: true}
        ],
        tableData:[],
        search_data:{
          page: 1,
          pageSize: 10,
          type: 0,
        },
        pictLoading:false,
        total:0,
      },
      page2:{
        summary:{},
        showSummaryColumn:[
          {name:'inspectionCountSupport',value:'inspectionCountSupport'},
          {name:'inspectionCount',value:'inspectionCounts'},
          {name:'qualifiedCountSupport',value:'qualifiedCountSupport'},
          {name:'qualifiedCount',value:'qualifiedCounts'},
          {name:'sendCountSupport',value:'sendCountSupport'},
          {name:'sendCount',value:'sendCounts'},
          {name:'unqualifiedCountSupport',value:'unqualifiedCountSupport'},
          {name:'unqualifiedCount',value:'unqualifiedCounts'}
        ],
        formTableData:[
          {title: "单据编号", prop_: "inspectionNo", select: true},
          {title: "日期", prop_: "createTime", select: true},
          {title: "物料代码", prop_: "materialSerialNo", select: true},
          {title: "物料名称", prop_: "materialName", select: true},
          {title: "规格型号", prop_: "specification", select: true},
          {title: "计量单位", prop_: "unitUomName", select: true},
          {title: "批号", prop_: "batchNo", select: true},
          {title: "部门", prop_: "deptName", select: true},
          {title: "客户", prop_: "clientName", select: true},
          {title: "报检数量(主单位)", prop_: "sendCount", select: true},
          {title: "检验数量(主单位)", prop_: "inspectionCount", select: true},
          {title: "合格数量(主单位)", prop_: "qualifiedCount", select: true},
          {title: "不合格数量(主单位)", prop_: "unqualifiedCount", select: true},
          {title: "辅助单位", prop_: "supportUomName", select: true},
          {title: "报检数量(辅单位)", prop_: "sendCountSupport", select: true},
          {title: "检验数量(辅单位)", prop_: "inspectionCountSupport", select: true},
          {title: "合格数量(辅单位)", prop_: "qualifiedCountSupport", select: true},
          {title: "不合格数量(辅单位)", prop_: "unqualifiedCountSupport", select: true},
          {title: "备注", prop_: "remarks", select: true},
          {title: "制单人", prop_: "createrName", select: true},
          {title: "审核人", prop_: "auditorName", select: true},
          {title: "源单类型", prop_: "sourceTypeName", select: true},
          {title: "源单单号", prop_: "sourceNo", select: true},
          {title: "单据状态", prop_: "statusName", select: true},
        ],
        tableData:[],
        search_data:{
          page: 1,
          pageSize: 10,
          type: 1,
        },
        pictLoading:false,
        total:0,
      },
      page3:{
        summary:{},
        showSummaryColumn:[
          {name:'count',value:'totalCount'},
          {name:'outCount',value:'totalOutCount'},
          {name:'sellAmount',value:'totalSellAmount'},
        ],
        formTableData:[
          {title: "出库日期", prop_: "outTime", select: true},
          {title: "单据编号", prop_: "code", select: true},
          {title: "客户名称", prop_: "clientName", select: true},
          {title: "物料代码", prop_: "materielSerialNo", select: true},
          {title: "物料名称", prop_: "materielName", select: true},
          {title: "规格型号", prop_: "specification", select: true},
          {title: "主计量单位", prop_: "unitUomName", select: true},
          {title: "主单位数量", prop_: "count", select: true},
          {title: "辅助单位", prop_: "supportUomName", select: true},
          {title: "出库数量", prop_: "outCount", select: true},
          {title: "销售单价（元）", prop_: "sellUnitPrice", select: true},
          {title: "销售金额（元）", prop_: "sellAmount", select: true},
          {title: "批号", prop_: "batch", select: true},
          {title: "仓库", prop_: "facName", select: true},
          {title: "仓位", prop_: "locationName", select: true},
          {title: "部门", prop_: "deptName", select: true},
          {title: "出库员", prop_: "operatorName", select: true},
          {title: "审核状态", prop_: "auditSignName", select: true},
          {title: "源单类型", prop_: "sourceTypeName", select: true},
          {title: "源单单号", prop_: "sourceCode", select: true}
        ],
        tableData:[],
        search_data:{
          page: 1,
          pageSize: 10,
          type: 2,
        },
        pictLoading:false,
        total:0,
      },
      page4:{
        summary:{},
        showSummaryColumn:[
          {name:'amount',value:'totalAmount'},
          {name:'count',value:'totalCount'},
          {name:'subCount',value:'totalSubCount'},
          {name:'taxAmount',value:'totalTaxAmount'},
          {name:'taxes',value:'totalTaxes'},
        ],
        formTableData:[
          {title: "开票日期", prop_: "invoiceDate", select: true},
          {title: "客户名称", prop_: "clientName", select: true},
          {title: "票据类型", prop_: "invoiceyTypeName", select: true},
          {title: "发票号码", prop_: "billCode", select: true},
          {title: "物料代码", prop_: "materielSerialNo", select: true},
          {title: "物料名称", prop_: "materielName", select: true},
          {title: "规格型号", prop_: "specification", select: true},
          {title: "主计量单位", prop_: "unitUomName", select: true},
          {title: "主单位数量", prop_: "count", select: true},
          {title: "辅助单位", prop_: "supportUomName", select: true},
          {title: "数量", prop_: "subCount", select: true},
          {title: "不含税单价（元）", prop_: "unitPrice", select: true},
          {title: "含税单价（元）", prop_: "taxUnitPrice", select: true},
          {title: "税率（%）", prop_: "taxRate", select: true},
          {title: "不含税金额（元）", prop_: "amount", select: true},
          {title: "税额（元）", prop_: "taxes", select: true},
          {title: "对税合计（元）", prop_: "taxAmount", select: true},
          {title: "审核状态", prop_: "auditSignName", select: true},
          {title: "源单类型", prop_: "sourceTypeName", select: true},
          {title: "源单单号", prop_: "sourceCode", select: true}
        ],
        tableData:[],
        search_data:{
          page: 1,
          pageSize: 10,
          type: 3,
        },
        pictLoading:false,
        total:0,
      },
      page5:{
        summary:{},
        showSummaryColumn:[
          {name:'amount',value:'totalAmount'},
          {name:'count',value:'totalCount'},
          {name:'backCount',value:'totalBackCount'},
        ],
        formTableData:[
          {title: "退货日期", prop_: "inOutTime", select: true},
          {title: "客户名称", prop_: "clientName", select: true},
          {title: "退货单号", prop_: "inheadCode", select: true},
          {title: "物料代码", prop_: "serialno", select: true},
          {title: "物料名称", prop_: "materielName", select: true},
          {title: "规格型号", prop_: "specification", select: true},
          {title: "主计量单位", prop_: "unitName", select: true},
          {title: "主单位数量", prop_: "count", select: true},
          {title: "辅助单位", prop_: "supportUomName", select: true},
          {title: "退货数量", prop_: "backCount", select: true},
          {title: "退货单价（元）", prop_: "unitPrice", select: true},
          {title: "金额（元）", prop_: "amount", select: true},
          {title: "批号", prop_: "batch", select: true},
          {title: "仓库", prop_: "warehouseName", select: true},
          {title: "仓位", prop_: "warehLocationName", select: true},
          {title: "退货原因", prop_: "returnReason", select: true},
          {title: "审核状态", prop_: "auditSignName", select: true},
          {title: "源单类型", prop_: "sourceTypeName", select: true},
          {title: "源单单号", prop_: "sourceCode", select: true}
        ],
        tableData:[],
        search_data:{
          page: 1,
          pageSize: 10,
          type: 4,
        },
        pictLoading:false,
        total:0,
      },
      page6:{
        summary:{},
        showSummaryColumn:[
          {name:'thisAmount',value:'totalThisAmount'},
        ],
        formTableData:[
          {title: "单据日期", prop_: "createTime", select: true},
          {title: "单据编号", prop_: "prCode", select: true},
          {title: "客户名称", prop_: "cusSupName", select: true},
          {title: "收款类型", prop_: "prTypeName", select: true},
          {title: "收款账号", prop_: "accountNumberName", select: true},
          {title: "结算方式", prop_: "settlementTypeName", select: true},
          {title: "收款金额（元）", prop_: "thisAmount", select: true},
          {title: "收款人", prop_: "payee", select: true},
          {title: "备注", prop_: "remarks", select: true},
          {title: "审核状态", prop_: "auditSignName", select: true},
          {title: "源单类型", prop_: "sourceTypeName", select: true},
          {title: "源单单号", prop_: "sourceCode", select: true},
        ],
        tableData:[],
        search_data:{
          page: 1,
          pageSize: 10,
          type: 5,
        },
        pictLoading:false,
        total:0,
      },
      page7:{
        summary:{},
        showSummaryColumn:[
          {name:'planCountSupport',value:'planCountSupports'},
          {name:'planCount',value:'planCounts'},
        ],
        formTableData:[
          {title: "生产计划单号", prop_: "planNo", select: true},
          {title: "单据状态", prop_: "planStatusName", select: true},
          {title: "交货期", prop_: "deliveryDate", select: true},
          {title: "产品代码", prop_: "materialSerialNo", select: true},
          {title: "产品名称", prop_: "materialName", select: true},
          {title: "规格型号", prop_: "specification", select: true},
          {title: "主计量单位", prop_: "unitUomName", select: true},
          {title: "辅助单位", prop_: "supportUomName", select: true},
          {title: "主单位数量", prop_: "planCount", select: true},
          {title: "计划生产数量", prop_: "planCountSupport", select: true},
          {title: "批号", prop_: "batchNo", select: true},
          {title: "计划开工日期", prop_: "planStartTime", select: true},
          {title: "计划完工日期", prop_: "planEndTime", select: true},
          {title: "BOM单号", prop_: "bomSerialno", select: true},
          {title: "BOM版本", prop_: "bomVersion", select: true},
          {title: "工艺编号", prop_: "tecRouteCode", select: true},
          {title: "工艺版本", prop_: "tecRouteVersion", select: true},
          {title: "制单日期", prop_: "createTime", select: true},
          {title: "下达时间", prop_: "giveTime", select: true},
          {title: "结案时间", prop_: "actualFinishTime", select: true},
          {title: "源单类型", prop_: "sourceTypeName", select: true},
          {title: "源单号", prop_: "sourceNo", select: true},
          {title: "客户名称", prop_: "clientName", select: true},
        ],
        tableData:[],
        search_data:{
          page: 1,
          pageSize: 10,
          type: 5,
        },
        pictLoading:false,
        total:0,
      },
      page8:{
        summary:{},
        showSummaryColumn:[
          {name:'planCount',value:'planCountTotal'},
        ],
        formTableData:[
          {title: "工序计划单编号", prop_: "planNo", select: true},
          {title: "单据状态", prop_: "planStatusName", select: true},
          {title: "客户", prop_: "clientName", select: true},
          {title: "交货期", prop_: "deliveryDate", select: true},
          {title: "产品代码", prop_: "materialSerialNo", select: true},
          {title: "产品名称", prop_: "materialName", select: true},
          {title: "规格型号", prop_: "specification", select: true},
          {title: "主计量单位", prop_: "unitUomName", select: true},
          {title: "辅助单位", prop_: "supportUomName", select: true},
          {title: "主单位数量", prop_: "planCount", select: true},
          {title: "计划生产数量", prop_: "planCountSupport", select: true},
          {title: "生产计划单号", prop_: "productionPlanNo", select: true},
        ],
        tableData:[],
        search_data:{
          page: 1,
          pageSize: 10,
          type: 5,
        },
        pictLoading:false,
        total:0,
      },
      page9:{
        summary:{},
        showSummaryColumn:[
          {name:'amount',value:'toatalAmount'},
          {name:'count',value:'toatalCount'},
          {name:'inCount',value:'totalInCount'},
        ],
        formTableData:[
          {title: "入库日期", prop_: "inOutTime", select: true},
          {title: "单据编号", prop_: "inheadCode", select: true},
          {title: "生产部门", prop_: "deptName", select: true},
          {title: "物料代码", prop_: "serialno", select: true},
          {title: "物料名称", prop_: "materielName", select: true},
          {title: "规格型号", prop_: "specification", select: true},
          {title: "批号", prop_: "batch", select: true},
          {title: "主计量单位", prop_: "unitName", select: true},
          {title: "主单位数量", prop_: "count", select: true},
          {title: "辅助单位", prop_: "supportUomName", select: true},
          {title: "入库数量", prop_: "inCount", select: true},
          {title: "单价（元）", prop_: "unitPrice", select: true},
          {title: "金额（元）", prop_: "amount", select: true},
          {title: "仓库", prop_: "warehouseName", select: true},
          {title: "仓位", prop_: "warehLocationName", select: true},
          {title: "源单类型", prop_: "sourceTypeName", select: true},
          {title: "源单单号", prop_: "sourceCode", select: true},
          {title: "审核状态", prop_: "auditSignName", select: true},
        ],
        tableData:[],
        search_data:{
          page: 1,
          pageSize: 10,
          type: 5,
        },
        pictLoading:false,
        total:0,
      },
      activeName:"1",
    }
  },
  computed: {
    ...mapGetters({
      userInfo: "user/getUserInfo"
    }),
  },
  mounted() {
    this.id = this.$route.query.id
    this.clientName = this.$route.query.clientName
    this.contractCode = this.$route.query.contractCode
    this.getList();
  },
  methods: {
    getList(){
      if (this.activeName === "1") {
        this.page1.pictLoading = true;
        this.page1.search_data.id = this.id;
        this.$api.salesAPI
          .associatedBill(this.page1.search_data)
          .then(res => {
            this.page1.pictLoading = false;
            if (res.data) {
              this.page1.summary = res.totalSum
              this.page1.total = res.data.total;
              this.page1.tableData = res.data.records ? res.data.records : [];
              this.page1.tableData.forEach(item => {
                //格式化日期
                if (item.noteTime) {
                  item.noteTime = item.noteTime.substring(0,10)
                }
              })
            } else {
              this.page1.total = 0;
              this.page1.tableData = [];
            }
          })
          .catch(r => {
            console.log(r);
          });
      }
      else if (this.activeName === "2") {
        this.page2.pictLoading = true;
        this.page2.search_data.id = this.id;
        this.$api.salesAPI
          .associatedBill(this.page2.search_data)
          .then(res => {
            this.page2.pictLoading = false;
            if (res.data) {
              this.page2.summary = res.count;
              this.page2.total = res.data.total;
              this.page2.tableData = res.data.records ? res.data.records : [];
              this.page2.tableData.forEach(item => {
                item.createTime = item.createTime.substr(0, 10)
              })
            } else {
              this.page2.total = 0;
              this.page2.tableData = [];
            }
          })
          .catch(r => {
            console.log(r);
          });
      }
      else if (this.activeName === "3") {
        this.page3.pictLoading = true;
        this.page3.search_data.id = this.id;
        this.$api.salesAPI
          .associatedBill(this.page3.search_data)
          .then(res => {
            this.page3.pictLoading = false;
            if (res.data) {
              this.page3.summary = res.total;
              this.page3.total = res.data.total;
              this.page3.tableData = res.data.records ? res.data.records : [];
              this.page3.tableData.forEach(item => {
                item.outTime = /\d{4}-\d{1,2}-\d{1,2}/g.exec(item.outTime)[0]
              })
            } else {
              this.page3.total = 0;
              this.page3.tableData = [];
            }
          })
          .catch(r => {
            console.log(r);
          });
      }
      else if (this.activeName === "4") {
        this.page4.pictLoading = true;
        this.page4.search_data.id = this.id;
        this.$api.salesAPI
          .associatedBill(this.page4.search_data)
          .then(res => {
            this.page4.pictLoading = false;
            if (res.data) {
              this.page4.summary = res.total;
              this.page4.total = res.data.total;
              this.page4.tableData = res.data.records ? res.data.records : [];
              this.page4.tableData.forEach(item => {
                item.invoiceDate = /\d{4}-\d{1,2}-\d{1,2}/g.exec(item.invoiceDate)[0]
              })
            } else {
              this.page4.total = 0;
              this.page4.tableData = [];
            }
          })
          .catch(r => {
            this.page4.pictLoading = false;
          });
      }
      else if (this.activeName === "5") {
        this.page5.pictLoading = true;
        this.page5.search_data.id = this.id;
        this.$api.salesAPI
          .associatedBill(this.page5.search_data)
          .then(res => {
            this.page5.pictLoading = false;
            if (res.data) {
              this.page5.summary = res.total;
              this.page5.total = res.data.total;
              this.page5.tableData = res.data.records ? res.data.records : [];
              this.page5.tableData.forEach(item => {
                item.inOutTime = /\d{4}-\d{1,2}-\d{1,2}/g.exec(item.inOutTime)[0]
              })
            } else {
              this.page5.total = 0;
              this.page5.tableData = [];
            }
          })
          .catch(r => {
            console.log(r);
          });
      }
      else if (this.activeName === "6") {
        this.page6.pictLoading = true;
        this.page6.search_data.id = this.id;
        this.$api.salesAPI
          .associatedBill(this.page6.search_data)
          .then(res => {
            this.page6.pictLoading = false;
            if (res.data) {
              this.page6.summary = res.total;
              this.page6.total = res.data.total;
              this.page6.tableData = res.data.records ? res.data.records : [];
              this.page6.tableData.forEach(item => {
                item.prDate = /\d{4}-\d{1,2}-\d{1,2}/g.exec(item.prDate)[0]
              })
            } else {
              this.page6.total = 0;
              this.page6.tableData = [];
            }
          })
          .catch(r => {
            console.log(r);
          });
      }
      else if (this.activeName === "7") {
        this.page7.pictLoading = true;
        this.page7.search_data.id = this.id;
        this.$api.planManagementAPI
          .productionPlanList2(this.page7.search_data)
          .then(res => {
            this.page7.pictLoading = false;
            if (res.data) {
              this.page7.summary = res.count;
              this.page7.total = res.data.totalRows;
              this.page7.tableData = res.data.datas ? res.data.datas : [];
              this.page7.tableData.forEach(item => {
                item.createTime=item.createTime.substr(0,10)
                item.deliveryDate=item.deliveryDate.substr(0,10)
                item.planStartTime=item.planStartTime.substr(0,10)
                item.planEndTime=item.planEndTime.substr(0,10)
              })
            } else {
              this.page7.total = 0;
              this.page7.tableData = [];
            }
          })
          .catch(r => {
            console.log(r);
          });
      }
      else if (this.activeName === "8") {
        this.page8.pictLoading = true;
        this.page8.search_data.id = this.id;
        this.$api.planManagementAPI
          .workingProcedurePlanList2(this.page8.search_data)
          .then(res => {
            this.page8.pictLoading = false;
            if (res.data) {
              this.page8.summary = res.total;
              this.page8.total = res.data.totalRows;
              this.page8.tableData = res.data.datas ? res.data.datas : [];
              this.page8.tableData.forEach(item => {
                item.deliveryDate=item.deliveryDate.substr(0,10)
              })
            } else {
              this.page8.total = 0;
              this.page8.tableData = [];
            }
          })
          .catch(r => {
            console.log(r);
          });
      }
      else if (this.activeName === "9") {
        this.page9.pictLoading = true;
        this.page9.search_data.id = this.id;
        this.$api.produceStockAPI
          .getProdeceList2(this.page9.search_data)
          .then(res => {
            this.page9.pictLoading = false;
            if (res.data) {
              this.page9.summary.toatalAmount = res.data.toatalAmount;
              this.page9.summary.toatalCount = res.data.toatalCount;
              this.page9.summary.totalInCount = res.data.totalInCount;
              this.page9.total = res.data.totalRows;
              this.page9.tableData = res.data.datas ? res.data.datas : [];
              this.page9.tableData.forEach(item => {
                item.createTime=item.createTime.substr(0,10)
                item.deliveryDate=item.deliveryDate.substr(0,10)
                item.planStartTime=item.planStartTime.substr(0,10)
                item.planEndTime=item.planEndTime.substr(0,10)
              })
            } else {
              this.page9.total = 0;
              this.page9.tableData = [];
            }
          })
          .catch(r => {
            console.log(r);
          });
      }
    },
    search(){
      switch (this.activeName) {
        case "1":
          this.page1.search_data.page = 1;
          break;
        case "2":
          this.page2.search_data.page = 1;
          break;
        case "3":
          this.page3.search_data.page = 1;
          break;
        case "4":
          this.page4.search_data.page = 1;
          break;
        case "5":
          this.page5.search_data.page = 1;
          break;
        case "6":
          this.page6.search_data.page = 1;
          break;
        case "7":
          this.page7.search_data.page = 1;
          break;
        case "8":
          this.page8.search_data.page = 1;
          break;
        case "9":
          this.page9.search_data.page = 1;
          break;
        default:
          break;
      }
      this.getList();
    },
    // 上下分页
    handleCurrentChange(val) {
      switch (this.activeName) {
        case "1":
          this.page1.search_data.page = val;
          break;
        case "2":
          this.page2.search_data.page = val;
          break;
        case "3":
          this.page3.search_data.page = val;
          break;
        case "4":
          this.page4.search_data.page = val;
          break;
        case "5":
          this.page5.search_data.page = val;
          break;
        case "6":
          this.page6.search_data.page = val;
          break;
        case "7":
          this.page7.search_data.page = val;
          break;
        case "8":
          this.page8.search_data.page = val;
          break;
        case "9":
          this.page9.search_data.page = val;
          break;
        default:
          break;
      }
      this.getList();
    },
    // 每页显示多少条
    handleSizeChange(val) {
      switch (this.activeName) {
        case "1":
          this.page1.search_data.pageSize = val;
          break;
        case "2":
          this.page2.search_data.pageSize = val;
          break;
        case "3":
          this.page3.search_data.pageSize = val;
          break;
        case "4":
          this.page4.search_data.pageSize = val;
          break;
        case "5":
          this.page5.search_data.pageSize = val;
          break;
        case "6":
          this.page6.search_data.pageSize = val;
          break;
        case "7":
          this.page7.search_data.pageSize = val;
          break;
        case "8":
          this.page8.search_data.pageSize = val;
          break;
        case "9":
          this.page9.search_data.pageSize = val;
          break;
        default:
          break;
      }
      this.getList();
    },
    handleSelectionChange(val) {
      this.rowIds = val;
    },
    handleClick(){
      this.getList();
    },

    goBack(){
      this.$router.push({ path: "/sales/salesContract", query: { t: Date.now() }})
    },
    goToLink(num,row){
      let url=''
      let id=row.id
      if(num==1){//发货通知
        url='/sales/deliveryNote_add'
        id=row.mainId
      }else if(num==2){//发货检验
        url='/quality/addDeliveryInspection'
      }else if(num==3){//销售出库
        url='/sales/salesStock_add'
      }else if(num==4){//销售发票
        url='/sales/salesBill_add'
      }else if(num==5){//销售退货
        url='/sales/salesReturn_add'
      }else if(num==6){//收款单
        url='/finance/commutation/paymentReceived_add'
      }else if(num==7){//生产计划
        url='/planManagement/production_add'
      }else if(num==8){//工序计划
        url='/planManagement/working_procedure_add'
      }else if(num==9){//生产入库
        url='/warehouse/produceStock_add'
      }
      this.$router.push({ path: url, query: {id:id, t: Date.now() }})
    }
  },
}
</script>

<style scoped>
>>>.sys-search .el-input__inner{
  width: 100%;
}
.dialog-form{
  position: relative;
}
.dialog-line{
  position: relative;
  display: flex;
  justify-content: center;
  width: 100%;
}
.dialog-line .dialog-form-inline{
  position: relative;
  width: 50%;
  margin-right: 0;
}
.dialog-line .dialog-form-inline1{
  position: relative;
  width: 50%;
  margin-right: 50%;
}
.dialog-line  .dialog-form-inline-single{
  position: relative;
  width: 100%;
  margin-right: 0;
}
>>>.dialog-line .el-input__inner{
  width: 100% !important;;
}
>>>.dialog-line .el-form-item__content{
  width: calc(100% - 80px) !important;;
}
>>>.dialog-line .el-input,>>>.dialog-line .el-cascader{
  width: 100% !important;
}
</style>


