diff --git a/admin/src/api/product.ts b/admin/src/api/product.ts index 750651a7..bcd692c0 100644 --- a/admin/src/api/product.ts +++ b/admin/src/api/product.ts @@ -7,7 +7,7 @@ export function getUserList(params: any) { // 土地表列表 export function apiLandLists(params: any) { - return request.get({ url: '/land.land/lists', params }) + return request.get({ url: '/land.land/datas', params }) } // 产品列表列表 diff --git a/admin/src/views/product/edit.vue b/admin/src/views/product/edit.vue index 31aba754..8c4e9d17 100644 --- a/admin/src/views/product/edit.vue +++ b/admin/src/views/product/edit.vue @@ -38,19 +38,18 @@ - + @@ -132,18 +131,16 @@ const getDetail = async (row: Record) => { const { optionsData } = useDictOptions<{ user: any[] + land: any[] }>({ user: { api: getUserList + }, + land: { + api: apiLandLists } }) -interface ListItem { - value: string - label: string -} - -const landOptions = ref([]) const loading = ref(false) const queryUser = async (query: string) => { @@ -157,21 +154,16 @@ const queryUser = async (query: string) => { const selectedUser = (value: any) => { console.log(value) + queryLand(value) } -const queryLand = async (query: string) => { +const queryLand = async (user_id: string) => { loading.value = true const landList = await apiLandLists({ - title: query ?? '' + user_id: user_id ?? '' }) loading.value = false - if (landList.count > 0) { - landOptions.value = landList.lists.map((land: any) => { - return { value: `${land.id}`, label: `ID: ${land.id} / 名称: ${land.title}` } - }) - } else { - landOptions.value = [] - } + optionsData.land = landList loading.value = false } @@ -212,8 +204,6 @@ const handleClose = () => { emit('close') } - - defineExpose({ open, setFormData, diff --git a/app/adminapi/controller/land/LandController.php b/app/adminapi/controller/land/LandController.php index f8b52c8f..50aca4aa 100644 --- a/app/adminapi/controller/land/LandController.php +++ b/app/adminapi/controller/land/LandController.php @@ -42,6 +42,11 @@ class LandController extends BaseAdminController return $this->dataLists(new LandLists()); } + public function datas() + { + $datas = (new LandLogic())->datas(input('')); + return $this->success('', $datas); + } /** * @notes 添加 diff --git a/app/adminapi/controller/user/UserController.php b/app/adminapi/controller/user/UserController.php index 3dccc127..5afbda95 100644 --- a/app/adminapi/controller/user/UserController.php +++ b/app/adminapi/controller/user/UserController.php @@ -38,12 +38,6 @@ class UserController extends BaseAdminController return $this->dataLists(new UserLists()); } - /** - * @notes 用户列表 - * @return \think\response\Json - * @author 段誉 - * @date 2022/9/22 16:16 - */ public function datas() { $datas = (new UserLogic())->datas(input('')); diff --git a/app/adminapi/logic/land/LandLogic.php b/app/adminapi/logic/land/LandLogic.php index 23c45fe2..d3f45534 100644 --- a/app/adminapi/logic/land/LandLogic.php +++ b/app/adminapi/logic/land/LandLogic.php @@ -135,6 +135,27 @@ class LandLogic extends BaseLogic } } + public function datas($params): array + { + $userWhere = []; + if (!empty($params['user_id'])) { + $userWhere['user_id'] = $params['user_id']; + } + if (!request()->adminInfo['root'] && request()->adminInfo['user_id']) { + $userWhere['user_id'] = request()->adminInfo['user_id']; + } + $field = ['id', 'user_id', 'title', 'address', 'total_area', 'residual_area', 'province_code', 'province_name', 'city_code', 'city_name', 'county_code', 'county_name', 'town_code', 'town_name', 'village_code', 'village_name', 'group_code', 'group_name', 'master_name', 'master_phone', 'pic']; + $lists = Land::where($userWhere) + ->limit(0, 100) + ->field($field) + ->order('id desc') + ->select()->toArray(); + foreach ($lists as &$item) { + $item['landinfo'] = $item['id'] . ' / ' . $item['title']; + } + return $lists; + } + /** * @notes 删除