yangfeng
2023-07-17 960d295793f1d164e3e8e22f8d7744b7923ae24b
src/views/custom/contacts/index.vue
@@ -5,7 +5,7 @@
      <PublicFunctionBtnView :operates-list="operatesList" />
      <PagerView class="page" />
    </div>
    <TableCommonView ref="tableListRef" :table-list="tableList">
    <TableCommonView ref="tableListRef" v-loading="loading" :table-list="tableList">
      <template slot="tableButton">
        <el-table-column label="操作" width="120" fixed="right">
          <template slot-scope="scope">
@@ -22,6 +22,7 @@
<script>
import AddContactsDialog from "@/views/custom/contacts/AddContactsDialog"
import { getContactList } from "@/api/custom/contacts"
export default {
  name: "ContactsView",
  props: {},
@@ -32,6 +33,7 @@
  data() {
    return {
      tableList: {},
      loading: false,
      queryClassOptions: [
        { value: "1", label: "全部" },
        { value: "2", label: "本月生日" }
@@ -59,29 +61,20 @@
  },
  created() {
    this.setTable()
    this.getData()
  },
  methods: {
    setTable() {
      this.tableList = {
        tableInfomation: [
          {
            contactName: "上海通用机械有限公司",
            customName: "BOSS",
            contactNumber: "C类客户",
            duties: "20",
            phoneNumber: "董奇伟",
            salesHead: "15988887777",
            primaryContact: "2023-07-26"
          }
        ],
        tableInfomation: [],
        tableColumn: [
          { label: "联系人姓名", prop: "contactName", min: 100 }, // 联系人姓名
          { label: "客户名称", prop: "customName", min: 190 }, // 客户名称
          { label: "联系人编号", prop: "contactNumber", min: 100 }, // 联系人编号
          { label: "客户名称", prop: "client_name", min: 190 }, // 客户名称
          { label: "联系人编号", prop: "number", min: 100 }, // 联系人编号
          { label: "职务", prop: "duties", min: 120 }, // 职务
          { label: "手机", prop: "phoneNumber", min: 100 }, // 手机号码
          { label: "手机", prop: "phone", min: 100 }, // 手机号码
          { label: "销售负责人", prop: "salesHead", min: 120 }, // 销售负责人
          { label: "首要联系人", prop: "primaryContact", min: 90 } // 首要联系人
          { label: "首要联系人", prop: "name", min: 90 } // 首要联系人
        ]
      }
      this.searchOptions = []
@@ -90,6 +83,40 @@
        this.searchOptions.push({ value: (i + 1).toString(), label: label })
      }
    },
    // 请求数据
    async getData() {
      this.loading = true
      await getContactList()
        .then((res) => {
          console.log(res)
          if (res.code === 200) {
            if (res.data.list && res.data.list.length > 0) {
              const list = res.data.list.map((item) => {
                return {
                  contactName: "",
                  client_name: item.Client.name,
                  number: item.number,
                  duties: "",
                  phone: item.phone,
                  salesHead: "",
                  name: item.name
                }
              })
              this.tableList.tableInfomation = list || []
            } else {
              this.tableList.tableInfomation = []
            }
          } else {
            this.tableList.tableInfomation = []
          }
          this.loading = false
        })
        .catch((err) => {
          console.log(err)
          this.tableList.tableInfomation = []
          this.loading = false
        })
    },
    // 新建
    addBtnClick() {
      this.editConfig.visible = true