yangfeng
2023-08-21 46ed69e3b72658140a40127f4bae16bef9a02d56
src/views/other/commonDialog/SelectContactDialog.vue
@@ -10,7 +10,7 @@
    >
      <div class="bg-view">
        <div class="query-bg">
          <el-input placeholder="请输入内容" v-model="queryInput" size="mini" class="input-with-select">
          <!-- <el-input placeholder="请输入内容" v-model="queryInput" size="mini" class="input-with-select">
            <el-select v-model="select" slot="prepend" placeholder="请选择" disabled>
              <el-option label="全部字段" value="1"></el-option>
              <el-option label="联系人姓名" value="2"></el-option>
@@ -42,7 +42,26 @@
          <div slot="empty">
            <el-empty :image-size="100"></el-empty>
          </div>
        </el-table>
        </el-table> -->
          <SearchCommonView
            ref="searchCommonView"
            :search-options="searchOptions"
            @searchClick="searchClick"
            @resetClick="resetClick"
          />
          <div class="btn">
            <!-- <el-button type="primary" size="mini" disabled>设置字段</el-button>
            <el-button type="primary" size="mini" disabled>快速创建</el-button> -->
          </div>
        </div>
        <TableCommonView
          ref="tableListRef"
          v-loading="loading"
          :table-list="tableList"
          :select-box="false"
          @selContactsClick="selNameClick"
        >
        </TableCommonView>
        <div slot="footer" class="dialog-footer">
          <div class="remark">说明:支持多字段模糊查询,仅显示符合条件的前5条数据</div>
        </div>
@@ -62,11 +81,7 @@
        return {
          editVisible: false,
          title: "",
          infomation: {
            name: "",
            color: "",
            setDefault: ""
          }
          infomation: {}
        }
      }
    }
@@ -79,22 +94,45 @@
      editConfig: this.editCommonConfig,
      queryInput: "",
      select: "1",
      tableData: [],
      tableList: [],
      searchSelOptions: [],
      loading: false
      loading: false,
      search_map: {}
    }
  },
  created() {
    this.setTable()
    this.getData()
  },
  methods: {
    setTable() {
      this.tableList = {
        tableInfomation: [],
        tableColumn: [
          { label: "联系人姓名", prop: "name", isContactClick: true }, // 联系人姓名
          { label: "联系人编号", prop: "number" }, // 联系人编号
          { label: "客户名称", prop: "client_name" }, // 客户名称
          { label: "手机", prop: "phone" } // 手机号码
        ]
      }
      this.searchOptions = []
      for (let i = 0; i < this.tableList.tableColumn.length; i++) {
        const label = this.tableList.tableColumn[i].label
        const value = this.tableList.tableColumn[i].prop
        this.searchOptions.push({ value: value, label: label })
      }
    },
    handleClose() {
      this.editConfig.editVisible = false
    },
    // 请求数据
    async getData() {
      this.loading = true
      await getContactList()
      await getContactList({
        search_map: this.search_map,
        page: 0,
        pageSize: 0
      })
        .then((res) => {
          console.log(res)
          if (res.code === 200) {
@@ -105,18 +143,18 @@
                  client_name: item.Client.name
                }
              })
              this.tableData = list.slice(0, 5) || []
              this.tableList.tableInfomation = list.slice(0, 5) || []
            } else {
              this.tableData = []
              this.tableList.tableInfomation = []
            }
          } else {
            this.tableData = []
            this.tableList.tableInfomation = []
          }
          this.loading = false
        })
        .catch((err) => {
          console.log(err)
          this.tableData = []
          this.tableList.tableInfomation = []
          this.loading = false
        })
    },
@@ -124,26 +162,17 @@
      this.editConfig.editVisible = false
      this.$emit("selClient", row, "contact")
    },
    // 时间显示
    dateFormat(fmt, date) {
      let ret = ""
      date = new Date(date)
      const opt = {
        "Y+": date.getFullYear().toString(), // 年
        "m+": (date.getMonth() + 1).toString(), // 月
        "d+": date.getDate().toString(), // 日
        "H+": date.getHours().toString(), // 时
        "M+": date.getMinutes().toString(), // 分
        "S+": date.getSeconds().toString() // 秒
        // 有其他格式化字符需求可以继续添加,必须转化成字符串
    // 搜索
    searchClick(val, content) {
      console.log(val, content)
      this.search_map = {
        [val.value]: content
      }
      for (let k in opt) {
        ret = new RegExp("(" + k + ")").exec(fmt)
        if (ret) {
          fmt = fmt.replace(ret[1], ret[1].length == 1 ? opt[k] : opt[k].padStart(ret[1].length, "0"))
        }
      }
      return fmt
      this.getData()
    },
    resetClick() {
      this.search_map = {}
      this.getData()
    }
  }
}
@@ -154,6 +183,7 @@
.bg-view {
  margin: 10px;
  .query-bg {
    margin-left: -20px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;