| | |
| | | label="搜索查询" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | showSearch |
| | | debounceTime={300} // 防抖 |
| | | debounceTime={300} |
| | | request={async ({ keyWords }) => { |
| | | const resp = await Http.doPost('api/host/page', { ...keyWords }); |
| | | console.log(resp); |
| | | // return [ |
| | | // { |
| | | // value: keyWords, |
| | | // label: '目标_target', |
| | | // }, |
| | | // { value: '520000201604258831', label: 'Patricia Lopez' }, |
| | | // { value: '520000198509222123', label: 'Jose Martinez' }, |
| | | // { value: '210000200811194757', label: 'Elizabeth Thomas' }, |
| | | // { value: '530000198808222758', label: 'Scott Anderson' }, |
| | | // { value: '500000198703236285', label: 'George Jackson' }, |
| | | // { value: '610000199906148074', label: 'Linda Hernandez' }, |
| | | // { value: '150000197210168659', label: 'Sandra Hall' }, |
| | | // { label: '目标_target' }, |
| | | // ] |
| | | const resp = await Http.doPostForm('api/host/query', { condition: keyWords }); |
| | | return resp.data; |
| | | }} |
| | | placeholder="Please select a country" |
| | | /> |
| | |
| | | return res; |
| | | } |
| | | |
| | | const doPostForm = async (url, params, fn) => { |
| | | const res = await request(url, { |
| | | method: 'POST', |
| | | headers: { |
| | | 'Content-Type': 'multipart/form-data' |
| | | }, |
| | | data: params |
| | | }); |
| | | if (fn) { |
| | | fn(res); |
| | | } |
| | | return res; |
| | | } |
| | | |
| | | const doPostPromise = (url, params, fn) => { |
| | | return request(url, { |
| | | method: 'POST', |
| | |
| | | }); |
| | | } |
| | | |
| | | const Http = { doGet, doGetPromise, doPost, doPostPromise } |
| | | const Http = { doGet, doGetPromise, doPost, doPostForm, doPostPromise } |
| | | |
| | | export default Http; |
New file |
| | |
| | | package com.zy.asrs.wcs.common.domain; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * Created by vincent on 2/16/2024 |
| | | */ |
| | | @Data |
| | | public class KeyValVo { |
| | | |
| | | private Object value; |
| | | |
| | | private Object label; |
| | | |
| | | public KeyValVo(Object value, Object label) { |
| | | this.value = value; |
| | | this.label = label; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.wcs.sys.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.R; |
| | | import com.zy.asrs.wcs.common.domain.KeyValVo; |
| | | import com.zy.asrs.wcs.sys.entity.Host; |
| | | import com.zy.asrs.wcs.sys.service.HostService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Created by vincent on 2/16/2024 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/api") |
| | | public class HostController extends BaseController { |
| | | |
| | | @Autowired |
| | | private HostService hostService; |
| | | |
| | | @PreAuthorize("hasAuthority('sys:host:list')") |
| | | @PostMapping("/host/query") |
| | | public R query(@RequestParam(required = false) String condition) { |
| | | List<KeyValVo> vos = new ArrayList<>(); |
| | | LambdaQueryWrapper<Host> wrapper = new LambdaQueryWrapper<>(); |
| | | if (!Cools.isEmpty(condition)) { |
| | | wrapper.like(Host::getName, condition); |
| | | } |
| | | hostService.page(new Page<>(1, 30), wrapper).getRecords().forEach( |
| | | item -> vos.add(new KeyValVo(item.getId(), item.getName())) |
| | | ); |
| | | return R.ok().add(vos); |
| | | } |
| | | |
| | | } |