更新选择关联信息
This commit is contained in:
parent
e7209ce566
commit
671db7e8f0
|
@ -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 })
|
||||
}
|
||||
|
||||
// 产品列表列表
|
||||
|
|
|
@ -38,18 +38,17 @@
|
|||
<el-form-item label="所属土地" prop="land_id">
|
||||
<el-select
|
||||
v-model="formData.land_id"
|
||||
filterable
|
||||
remote
|
||||
reserve-keyword
|
||||
filterable
|
||||
placeholder="请输入土地信息"
|
||||
:remote-method="queryLand"
|
||||
:loading="loading"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in landOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
v-for="(item, index) in optionsData.land"
|
||||
:key="index"
|
||||
:label="item.landinfo"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
@ -132,18 +131,16 @@ const getDetail = async (row: Record<string, any>) => {
|
|||
|
||||
const { optionsData } = useDictOptions<{
|
||||
user: any[]
|
||||
land: any[]
|
||||
}>({
|
||||
user: {
|
||||
api: getUserList
|
||||
},
|
||||
land: {
|
||||
api: apiLandLists
|
||||
}
|
||||
})
|
||||
|
||||
interface ListItem {
|
||||
value: string
|
||||
label: string
|
||||
}
|
||||
|
||||
const landOptions = ref<ListItem[]>([])
|
||||
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,
|
||||
|
|
|
@ -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 添加
|
||||
|
|
|
@ -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(''));
|
||||
|
|
|
@ -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 删除
|
||||
|
|
Loading…
Reference in New Issue