yangfeng
2023-08-26 7da8d51d212f96b2d419d4f22617827ea4df9e3d
src/views/supplierManage/supplier/index.vue
@@ -22,8 +22,14 @@
          <template slot="tableButton">
            <el-table-column label="操作" width="120">
              <template slot-scope="scope">
                <el-button @click="handleClick(scope.row)" type="text" size="small">启用</el-button>
                <el-button @click="editClick(scope.row)" type="text" size="small">停用</el-button>
                <el-button
                  v-if="scope.row.status === 0"
                  @click="enableClick(scope.row, '启用')"
                  type="text"
                  size="small"
                  >启用</el-button
                >
                <el-button v-else @click="enableClick(scope.row, '停用')" type="text" size="small">停用</el-button>
                <el-button @click="modifyClick(scope.row)" type="text" size="small">修改</el-button>
                <!-- <el-button @click="delClick(scope.row.id)" type="text" size="small">删除</el-button> -->
              </template>
@@ -45,8 +51,8 @@
          class="search"
          ref="searchCommonView"
          :search-options="searchProductOptions"
          @searchClick="searchClick"
          @resetClick="resetClick"
          @searchClick="searchProductClick"
          @resetClick="resetProductClick"
        />
        <div class="add-view">
          <el-button type="primary" size="mini" @click="addNewProductClick">添加新产品</el-button>
@@ -71,7 +77,7 @@
          </template>
        </TableCommonView>
        <div class="btn-pager">
          <PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
          <PagerView class="page" :pager-options="productPagerOptions" v-on="pagerEvents" />
        </div>
      </template>
    </div>
@@ -88,7 +94,7 @@
<script>
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
import { getSalesLeadsList, getDeleteSalesLeads } from "@/api/client/salesLead"
import { getSupplierList, changeSupplierStatus } from "@/api/supplierManage/supplier"
import DetailSupplier from "@/views/supplierManage/supplier/DetailSupplier"
import AddSupplier from "@/views/supplierManage/supplier/AddSupplier"
import RaleteSupplierList from "@/views/supplierManage/supplier/RaleteSupplierList"
@@ -125,7 +131,11 @@
        title: "添加",
        infomation: {}
      },
      search_map: {}
      productPagerOptions: {
        currPage: 1,
        pageSize: 10,
        totalCount: 0
      }
    }
  },
  created() {
@@ -141,11 +151,11 @@
        tableColumn: [
          { label: "供应商编号", prop: "number", min: 190, isCommonClick: true },
          { label: "供应商名称", prop: "name", min: 130 },
          { label: "供应商类型", prop: "contact_name", min: 130 },
          { label: "所属行业", prop: "contact_phone", min: 130 },
          { label: "联系人", prop: "sales_resources", min: 130 },
          { label: "联系电话", prop: "province", min: 130 },
          { label: "状态", prop: "city", 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: "member_name", min: 130 }
        ]
      }
@@ -183,49 +193,80 @@
      }
    },
    // 请求数据
    async getData() {
      await getSalesLeadsList({
        search_map: this.search_map,
    async getData(val, content, searchName) {
      if (searchName === "供应商") {
        this.getSupplierList(val, content)
      } else if (searchName === "产品") {
        this.getProductList(val, content)
      } else {
        this.getSupplierList()
        this.getProductList()
      }
    },
    // 供应商列表
    async getSupplierList(val, content) {
      await getSupplierList({
        [val]: content,
        page: this.pagerOptions.currPage,
        pageSize: this.pagerOptions.pageSize
      })
        .then((res) => {
          const list = res.data.list.map((item) => {
      }).then((res) => {
        console.log(res.data)
        if (res.data.code === 200) {
          const list = res.data.data.list.map((item) => {
            return {
              ...item,
              province: item.Province.name,
              city: item.City.name,
              sales_resources: item.sales_sources.name,
              member_name: item.member.username
              status_name: item.status === 0 ? "未启用" : "启用"
            }
          })
          this.tableList.tableInfomation = list || []
          this.pagerOptions.totalCount = res.data.count
        })
        .catch((err) => {
          console.log(err)
        })
          this.pagerOptions.totalCount = res.data.data.total
        }
      })
    },
    // 搜索
    // 产品列表
    async getProductList(val, content) {
      console.log(val, content)
      // await getProductList({
      //   [val]: content,
      //   page: this.productPagerOptions.currPage,
      //   pageSize: this.productPagerOptions.pageSize
      // }).then((res) => {
      //   console.log(res.data)
      // })
    },
    // 搜索供应商
    searchClick(val, content) {
      console.log(val, content)
      this.search_map = {
        [val.value]: content
      }
      this.getData()
      this.getData(val.value, content, "供应商")
    },
    resetClick() {
      this.search_map = {}
      this.getData()
      this.getData("", "", "供应商")
    },
    // 搜索产品
    searchProductClick(val, content) {
      console.log(val, content)
      this.getData(val.value, content, "产品")
    },
    resetProductClick() {
      this.getData("", "", "产品")
    },
    // 新建供应商
    addBtnClick() {
      this.editConfig.visible = true
      this.editConfig.title = "新建"
    },
    // 编辑供应商
    handleClick(row) {
      console.log(row)
    // 启用供应商
    async enableClick(row, value) {
      let status = value === "启用" ? 1 : 0
      await changeSupplierStatus({
        id: row.ID,
        status: status
      }).then((res) => {
        if (res.code === 200) {
          this.$message.success("状态修改成功")
          this.getData()
        }
      })
    },
    // 修改供应商
    modifyClick(row) {
@@ -261,14 +302,14 @@
        })
          .then(() => {
            console.log("dddd")
            getDeleteSalesLeads({ ids: this.selValueList }).then((response) => {
              if (response.code === 200) {
                this.$message.success("删除成功")
                this.getData()
              } else {
                this.$message.warning("删除失败")
              }
            })
            // deleteSupplier({ id: this.selValueList }).then((response) => {
            //   if (response.code === 200) {
            //     this.$message.success("删除成功")
            //     this.getData()
            //   } else {
            //     this.$message.warning("删除失败")
            //   }
            // })
          })
          .catch(() => {})
      } else {
@@ -276,6 +317,7 @@
      }
    },
    getSelectArray(val) {
      console.log(val)
      this.selValueList = []
      const list = val.map((item) => {
        return item.id