songshankun
2023-09-23 7f0ec738a0af4d9d334ce85012f864f2519ebb3f
src/views/supplierManage/supplier/index.vue
@@ -23,6 +23,7 @@
                :table-list="tableList"
                @selCommonClick="selCommonClick"
                @tableRowClick="tableRowClick"
                @selTableCol="selTableCol"
            >
              <template slot="tableButton">
                <el-table-column label="操作" width="100">
@@ -77,6 +78,7 @@
                :table-list="productTableList"
                @selCommonClick="selCommonClick"
                @getSelectArray="getSelectArray"
                @selTableCol="selProductTableCol"
            >
              <template slot="tableButton">
                <el-table-column label="操作" width="170">
@@ -157,7 +159,28 @@
        pageSize: 10,
        totalCount: 0
      },
      supplierId: 0
      supplierId: 0,
      showCol:['供应商编号','供应商名称','供应商类型','所属行业','联系人','联系电话','状态','创建时间'],
      tableColumn: [
        { label: "供应商编号", prop: "number", min: 190, isCommonClick: true },
        { label: "供应商名称", prop: "name", min: 130 },
        { label: "供应商类型", prop: "supplierType", min: 130 },
        { label: "所属行业", prop: "industry", min: 130 },
        { label: "联系人", prop: "contact", min: 130 },
        { label: "联系电话", prop: "phone", min: 130 },
        { label: "状态", prop: "status_name", min: 130 },
        { label: "创建时间", prop: "created_at", min: 130 }
      ],
      showProductCol:['产品编码','产品名称','产品规格','单位','采购价格','供货时长(天)','物流时长(天)'],
      productColumn:[
        { label: "产品编码", prop: "number", min: 190 },
        { label: "产品名称", prop: "name", min: 130 },
        { label: "产品规格", prop: "specifications", min: 130 },
        { label: "单位", prop: "unit", min: 130 },
        { label: "采购价格", prop: "purchasePrice", min: 130 },
        { label: "供货时长(天)", prop: "deliveryTime", min: 130 },
        { label: "物流时长(天)", prop: "shippingDuration", min: 130 }
      ]
    }
  },
  created() {
@@ -166,23 +189,34 @@
    this.getData()
  },
  methods: {
    setColumnVisible(showCol){
      return  this.tableColumn.map(ele=>{
        return {
          ...ele,
          isShowColumn:showCol.includes(ele.label)
        }
      })
    },
    setProductColumnVisible(showCol){
      return  this.productColumn.map(ele=>{
        return {
          ...ele,
          isShowColumn:showCol.includes(ele.label)
        }
      })
    },
    setTable() {
      this.tableList = {
        tableInfomation: [],
        selectIndex: true,
        highlight: true,
        ref: "tableListRef",
        tableColumn: [
          { label: "供应商编号", prop: "number", min: 190, isCommonClick: true },
          { label: "供应商名称", prop: "name", min: 130 },
          { label: "供应商类型", prop: "supplierType", min: 130 },
          { label: "所属行业", prop: "industry", min: 130 },
          { label: "联系人", prop: "contact", min: 130 },
          { label: "联系电话", prop: "phone", min: 130 },
          { label: "状态", prop: "status_name", min: 130 },
          { label: "创建时间", prop: "created_at", min: 130 }
        ]
        showcol: this.showCol,
        allcol: [],
        tableColumn: this.setColumnVisible(this.showCol),
      }
      this.tableList.allcol = this.tableList.tableColumn.filter(ele=>!ele.default).map(ele=>ele.label);
      this.searchOptions = []
      for (let i = 0; i < this.tableList.tableColumn.length; i++) {
        const label = this.tableList.tableColumn[i].label
@@ -190,20 +224,18 @@
        this.searchOptions.push({ value: value, label: label })
      }
    },
    selTableCol(val) {
      this.showcol = val;
      this.tableList.tableColumn = this.setColumnVisible(val);
    },
    setProductTable() {
      this.productTableList = {
        tableInfomation: [],
        selectBox: true,
        selectIndex: true,
        tableColumn: [
          { label: "产品编码", prop: "number", min: 190 },
          { label: "产品名称", prop: "name", min: 130 },
          { label: "产品规格", prop: "specifications", min: 130 },
          { label: "单位", prop: "unit", min: 130 },
          { label: "采购价格", prop: "purchasePrice", min: 130 },
          { label: "供货时长(天)", prop: "deliveryTime", min: 130 },
          { label: "物流时长(天)", prop: "shippingDuration", min: 130 }
        ]
        showcol: this.showProductCol,
        allcol: [],
        tableColumn: this.setProductColumnVisible(this.showProductCol),
      }
      this.searchProductOptions = []
      for (let i = 0; i < this.productTableList.tableColumn.length; i++) {
@@ -211,6 +243,13 @@
        const value = this.productTableList.tableColumn[i].prop
        this.searchProductOptions.push({ value: value, label: label })
      }
      this.productTableList.allcol = this.productTableList.tableColumn.filter(ele=>!ele.default).map(ele=>ele.label);
      console.log('this.productTableList',this.productTableList)
    },
    selProductTableCol(val) {
      this.showProductCol = val;
      this.productTableList.tableColumn = this.setProductColumnVisible(val);
    },
    // 请求数据
    getData() {