需求:

做搜索时候的需求,需要给后端传数组

 控件:

 <el-select
     v-model="search.projectUuidList"
     placeholder="请选择项目名称"
     filterable
     clearable
     @change="searchHandler"
  >
     <el-option
        v-for="item in projects"
        :key="item.projectUuid"
        :label="item.name"
        :value="item.projectUuid"
      >
     </el-option>
</el-select>

 数据:

 data() {
    return {
      search: {
        projectUuidList: [],
        page: 0,
        pageSize: 20
      },
   }
}

 连获取控件的接口,这里就要传数组了

 loadData() {
      this.loading = true;
      let post = { ...Object.assign({}, this.search) };
       //!!!!!!!
      post.projectUuidList = post.projectUuidList ? [post.projectUuidList] : [];
     
      this.$axios
        .post(`${CUSTOMER_URL}/api/confirmation/page`, post)
        .then(response => {
          if (response.data.code == 0 && response.data.data) {
            this.list = response.data.data.pageData;
            this.loading = false;
        })
        .catch(error => {
          if (error.response.data) {
            this.$message.error(error.response.data.error);
          }
        });
    },

👇 

  post.projectUuidList = post.projectUuidList ? [post.projectUuidList] : [];
Logo

前往低代码交流专区

更多推荐