haoxuan
2023-11-15 a6649a3319e9f5e9260848872d8cddabfcfc7553
src/views/supplierManage/supplier/index.vue
@@ -7,7 +7,7 @@
              :show-add="true"
              add-title="新建"
              @addCommonClick="addBtnClick"
              :show-download="false"
            :show-download="true"
              :amount-view="false"
              :show-action-btn="false"
              :placeholder="'请输入供应商名称'"
@@ -22,8 +22,9 @@
                ref="tableSupplier"
                :table-list="tableList"
                @selCommonClick="selCommonClick"
                @tableRowClick="tableRowClick"
                @selTableCol="selTableCol"
              @tableRowClick="tableRowClick"
              :selectClassRow="selectRow"
            >
              <template slot="tableButton">
                <el-table-column label="操作" width="100">
@@ -47,7 +48,6 @@
          </div>
        </div>
      </div>
    </div>
    <div class="bottom">
      <div class="simple-filter">
@@ -56,13 +56,14 @@
              :show-add="false"
              :show-download="false"
              :amount-view="false"
            :show-screen="false"
              :show-action-btn="false"
              :placeholder="'请输入产品名称'"
              @searchClick="onProductFilterSearch"
          >
            <template slot="leftButton">
              <div class="sub-title"><span class="sub-title-decorator"></span>可提供的产品</div>
              <el-button type="primary" size="mini">创建采购单</el-button>
              <el-button type="primary" size="mini" @click="creatPurchase">创建采购单</el-button>
            </template>
            <template slot="rightButton">
              <el-button type="primary" size="mini" @click="addNewProductClick">添加新产品</el-button>
@@ -110,6 +111,8 @@
    <RaleteSupplierList v-if="raleteSupplierConfig.visible" :common-config="raleteSupplierConfig" />
    <!-- 添加新产品 -->
    <AddNewProduct v-if="newProductConfig.visible" :add-common-config="newProductConfig" />
    <!-- 新建/编辑 -->
    <AddPurchase v-if="editPurchaseConfig.visible" :edit-common-config="editPurchaseConfig" />
  </div>
</template>
@@ -121,16 +124,17 @@
import RaleteSupplierList from "@/views/supplierManage/supplier/RaleteSupplierList"
import AddNewProduct from "@/views/supplierManage/supplier/AddNewProduct"
import { getProductList, deleteProduct } from "@/api/productManage/product"
import AddPurchase from "@/views/purchaseManage/purchase/components/AddPurchase"
export default {
  name: "SupplierManage",
  props: {},
  components: { DetailSupplier, AddSupplier, RaleteSupplierList, AddNewProduct },
  components: { DetailSupplier, AddSupplier, RaleteSupplierList, AddNewProduct, AddPurchase },
  mixins: [pageMixin],
  computed: {},
  data() {
    return {
      searchSupplierName: '',
      searchSupplierName: "",
      tableList: {}, // 供应商列表
      productTableList: {}, // 产品列表
      selValueList: [],
@@ -160,7 +164,7 @@
        totalCount: 0
      },
      supplierId: 0,
      showCol:['供应商编号','供应商名称','供应商类型','所属行业','联系人','联系电话','状态'],
      showCol: ["供应商编号", "供应商名称", "供应商类型", "所属行业", "联系人", "联系电话", "状态"],
      tableColumn: [
        { label: "供应商编号", prop: "number", min: 190, isCommonClick: true },
        { label: "供应商名称", prop: "name", min: 130, default: true },
@@ -171,7 +175,7 @@
        { label: "状态", prop: "status_name", min: 130 },
        { label: "创建时间", prop: "created_at", min: 130 }
      ],
      showProductCol:['产品编码','产品名称','产品规格','单位','采购价格','供货时长(天)','物流时长(天)'],
      showProductCol: ["产品编码", "产品名称", "产品规格", "单位", "采购价格", "供货时长(天)", "物流时长(天)"],
      productColumn:[
        { label: "产品编码", prop: "number", min: 190 },
        { label: "产品名称", prop: "name", min: 130, default: true },
@@ -180,7 +184,16 @@
        { label: "采购价格", prop: "purchasePrice", min: 130 },
        { label: "供货时长(天)", prop: "deliveryTime", min: 130 },
        { label: "物流时长(天)", prop: "shippingDuration", min: 130 }
      ]
      ],
      editPurchaseConfig: {
        // 创建采购
        visible: false,
        title: "创建",
        infomation: {
          supplierName: ""
        }
      },
      selectRow: {}
    }
  },
  created() {
@@ -190,7 +203,7 @@
  },
  methods: {
    setColumnVisible(showCol){
      return  this.tableColumn.map(ele=>{
      return this.tableColumn.map((ele) => {
        return {
          ...ele,
          isShowColumn: showCol.includes(ele.label)
@@ -198,7 +211,7 @@
      })
    },
    setProductColumnVisible(showCol){
      return  this.productColumn.map(ele=>{
      return this.productColumn.map((ele) => {
        return {
          ...ele,
          isShowColumn:showCol.includes(ele.label)
@@ -213,9 +226,9 @@
        ref: "tableListRef",
        showcol: this.showCol,
        allcol: [],
        tableColumn: this.setColumnVisible(this.showCol),
        tableColumn: this.setColumnVisible(this.showCol)
      }
      this.tableList.allcol = this.tableList.tableColumn.filter(ele=>!ele.default).map(ele=>ele.label);
      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++) {
@@ -225,8 +238,8 @@
      }
    },
    selTableCol(val) {
      this.showcol = val;
      this.tableList.tableColumn = this.setColumnVisible(val);
      this.showcol = val
      this.tableList.tableColumn = this.setColumnVisible(val)
    },
    setProductTable() {
      this.productTableList = {
@@ -235,7 +248,7 @@
        selectIndex: true,
        showcol: this.showProductCol,
        allcol: [],
        tableColumn: this.setProductColumnVisible(this.showProductCol),
        tableColumn: this.setProductColumnVisible(this.showProductCol)
      }
      this.searchProductOptions = []
      for (let i = 0; i < this.productTableList.tableColumn.length; i++) {
@@ -244,12 +257,14 @@
        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)
      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);
      this.showProductCol = val
      this.productTableList.tableColumn = this.setProductColumnVisible(val)
    },
    // 请求数据
    getData() {
@@ -262,33 +277,36 @@
        page: this.pagerOptions.currPage,
        pageSize: this.pagerOptions.pageSize
      }).then((res) => {
        console.log(res.data)
        if (res.data.code === 200) {
          const list = res.data.data.list.map((item) => {
        console.log(res)
        if (res.code === 200) {
          const list = res.data.list.map((item) => {
            return {
              ...item,
              id: item.ID,
              status_name: item.status === 0 ? "未启用" : "启用"
            }
          })
          console.log(list)
          this.tableList.tableInfomation = list || []
          this.pagerOptions.totalCount = res.data.data.total
          this.pagerOptions.totalCount = res.data.total
          if (list && list.length > 0) {
            this.supplierId = this.tableList.tableInfomation[0].ID
            this.selectRow = this.tableList.tableInfomation.length > 0 ? this.tableList.tableInfomation[0] : {}
          } else {
            this.supplierId = 0
          }
          this.$nextTick(() => {
            this.$refs.tableSupplier.$refs.table.setCurrentRow(this.tableList.tableInfomation[0])
          })
          // this.$nextTick(() => {
          //   this.$refs.tableSupplier.$refs.table.setCurrentRow(this.tableList.tableInfomation[0])
          // })
          // 重新获取供应商列表后应该重置产品列表页码
          this.productPagerOptions.currPage = 1;
          this.productPagerOptions.currPage = 1
          // 如果供应商列表为空,则可提供产品列表也应为空
          if (list.length){
            this.getProductList()
          }else {
            this.productTableList.tableInfomation=[]
            this.productPagerOptions.currPage = 1;
            this.productPagerOptions.currPage = 1
            this.productPagerOptions.totalCount = 0
          }
        }
@@ -315,14 +333,14 @@
    },
    // 搜索供应商
    onFilterSearch(searchText){
      this.searchSupplierName = searchText ??''
      this.searchSupplierName = searchText ?? ""
      this.pagerOptions.currPage = 1
      this.getSupplierList()
    },
    // 搜索产品
    onProductFilterSearch(searchText){
      this.productPagerOptions.currPage = 1
      this.getProductList('name', searchText)
      this.getProductList("name", searchText)
    },
    // 新建供应商
    addBtnClick() {
@@ -398,6 +416,7 @@
    tableRowClick(row) {
      console.log(row)
      this.productPagerOptions.currPage = 1
      this.selectRow = row
      this.supplierId = row.ID
      this.getProductList()
    },
@@ -416,6 +435,15 @@
    currentProductHandler(val) {
      this.productPagerOptions.currPage = val
      this.getProductList()
    },
    // 创建采购单
    creatPurchase() {
      this.editPurchaseConfig.visible = true
      this.editPurchaseConfig.title = "创建"
      this.editPurchaseConfig.infomation = {
        supplierId: this.selectRow.ID,
        supplierName: this.selectRow.name
      }
    }
  }
}
@@ -522,5 +550,4 @@
    left: 0;
  }
}
</style>