更新选择关联信息

This commit is contained in:
yaooo 2023-12-06 09:35:30 +08:00
parent e7209ce566
commit 671db7e8f0
5 changed files with 42 additions and 32 deletions

View File

@ -7,7 +7,7 @@ export function getUserList(params: any) {
// 土地表列表 // 土地表列表
export function apiLandLists(params: any) { export function apiLandLists(params: any) {
return request.get({ url: '/land.land/lists', params }) return request.get({ url: '/land.land/datas', params })
} }
// 产品列表列表 // 产品列表列表

View File

@ -38,18 +38,17 @@
<el-form-item label="所属土地" prop="land_id"> <el-form-item label="所属土地" prop="land_id">
<el-select <el-select
v-model="formData.land_id" v-model="formData.land_id"
filterable
remote remote
reserve-keyword filterable
placeholder="请输入土地信息" placeholder="请输入土地信息"
:remote-method="queryLand" :remote-method="queryLand"
:loading="loading" :loading="loading"
> >
<el-option <el-option
v-for="item in landOptions" v-for="(item, index) in optionsData.land"
:key="item.value" :key="index"
:label="item.label" :label="item.landinfo"
:value="item.value" :value="item.id"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
@ -132,18 +131,16 @@ const getDetail = async (row: Record<string, any>) => {
const { optionsData } = useDictOptions<{ const { optionsData } = useDictOptions<{
user: any[] user: any[]
land: any[]
}>({ }>({
user: { user: {
api: getUserList api: getUserList
},
land: {
api: apiLandLists
} }
}) })
interface ListItem {
value: string
label: string
}
const landOptions = ref<ListItem[]>([])
const loading = ref(false) const loading = ref(false)
const queryUser = async (query: string) => { const queryUser = async (query: string) => {
@ -157,21 +154,16 @@ const queryUser = async (query: string) => {
const selectedUser = (value: any) => { const selectedUser = (value: any) => {
console.log(value) console.log(value)
queryLand(value)
} }
const queryLand = async (query: string) => { const queryLand = async (user_id: string) => {
loading.value = true loading.value = true
const landList = await apiLandLists({ const landList = await apiLandLists({
title: query ?? '' user_id: user_id ?? ''
}) })
loading.value = false loading.value = false
if (landList.count > 0) { optionsData.land = landList
landOptions.value = landList.lists.map((land: any) => {
return { value: `${land.id}`, label: `ID: ${land.id} / 名称: ${land.title}` }
})
} else {
landOptions.value = []
}
loading.value = false loading.value = false
} }
@ -212,8 +204,6 @@ const handleClose = () => {
emit('close') emit('close')
} }
defineExpose({ defineExpose({
open, open,
setFormData, setFormData,

View File

@ -42,6 +42,11 @@ class LandController extends BaseAdminController
return $this->dataLists(new LandLists()); return $this->dataLists(new LandLists());
} }
public function datas()
{
$datas = (new LandLogic())->datas(input(''));
return $this->success('', $datas);
}
/** /**
* @notes 添加 * @notes 添加

View File

@ -38,12 +38,6 @@ class UserController extends BaseAdminController
return $this->dataLists(new UserLists()); return $this->dataLists(new UserLists());
} }
/**
* @notes 用户列表
* @return \think\response\Json
* @author 段誉
* @date 2022/9/22 16:16
*/
public function datas() public function datas()
{ {
$datas = (new UserLogic())->datas(input('')); $datas = (new UserLogic())->datas(input(''));

View File

@ -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 删除 * @notes 删除