更新细节

This commit is contained in:
yaooo 2023-12-06 11:07:24 +08:00
parent 6f3314f92c
commit bed415a1e5
5 changed files with 39 additions and 41 deletions

View File

@ -2,7 +2,7 @@ import request from '@/utils/request'
// 用户列表 // 用户列表
export function getUserList(params: any) { export function getUserList(params: any) {
return request.get({ url: '/user.user/lists', params }, { ignoreCancelToken: true }) return request.get({ url: '/user.user/datas', params }, { ignoreCancelToken: true })
} }
// 产品列表列表 // 产品列表列表

View File

@ -9,22 +9,21 @@
@close="handleClose" @close="handleClose"
> >
<el-form ref="formRef" :model="formData" label-width="120px" :rules="formRules"> <el-form ref="formRef" :model="formData" label-width="120px" :rules="formRules">
<el-form-item v-if="formData.root == 1" label="用户ID" prop="user_id"> <el-form-item v-if="formData.root == 1" label="所属用户" prop="user_id">
<el-select <el-select
v-model="formData.user_id" v-model="formData.user_id"
filterable
remote remote
reserve-keyword filterable
placeholder="请输入用户信息" placeholder="请输入用户信息"
:remote-method="queryUser" :remote-method="queryUser"
:loading="loading" :loading="loading"
> >
<el-option <el-option
v-for="item in userOptions" v-for="(item, index) in optionsData.user"
:key="item.value" :key="index"
:label="item.label" :label="item.userinfo"
:value="item.value" :value="item.id"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="土地名称" prop="title"> <el-form-item label="土地名称" prop="title">
@ -90,6 +89,7 @@
</template> </template>
<script lang="ts" setup name="landEdit"> <script lang="ts" setup name="landEdit">
import { useDictOptions } from '@/hooks/useDictOptions'
import type { FormInstance } from 'element-plus' import type { FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue' import Popup from '@/components/popup/index.vue'
import { apiLandAdd, apiLandEdit, apiLandDetail, getUserList, getUserInfo } from '@/api/land' import { apiLandAdd, apiLandEdit, apiLandDetail, getUserList, getUserInfo } from '@/api/land'
@ -182,31 +182,23 @@ const getDetail = async (row: Record<string, any>) => {
setFormData(data) setFormData(data)
} }
interface ListItem { const { optionsData } = useDictOptions<{
value: string user: any[]
label: string }>({
} user: {
const userOptions = ref<ListItem[]>([]) api: getUserList
}
})
const loading = ref(false) const loading = ref(false)
const queryUser = async (query: string) => { const queryUser = async (query: string) => {
if (query) { loading.value = true
loading.value = true const userList = await getUserList({
const userList = await getUserList({ keyword: query ?? ''
keyword: query })
}) optionsData.user = userList
loading.value = false loading.value = false
if (userList.count > 0) {
userOptions.value = userList.lists.map((user: any) => {
return { value: `${user.id}`, label: `ID: ${user.id} / 账户: ${user.account}` }
})
} else {
userOptions.value = []
}
loading.value = false
} else {
userOptions.value = []
}
} }
// //
@ -240,7 +232,6 @@ const handleClose = () => {
} }
defineExpose({ defineExpose({
open, open,
setFormData, setFormData,

View File

@ -23,7 +23,7 @@
filterable filterable
placeholder="请输入用户信息" placeholder="请输入用户信息"
:remote-method="queryUser" :remote-method="queryUser"
@change="selectedUser" @blur="selectedUser"
:loading="loading" :loading="loading"
> >
<el-option <el-option
@ -42,6 +42,7 @@
filterable filterable
placeholder="请输入土地信息" placeholder="请输入土地信息"
:remote-method="queryLand" :remote-method="queryLand"
@focus="selectedLand"
:loading="loading" :loading="loading"
> >
<el-option <el-option
@ -117,7 +118,6 @@ const setFormData = async (data: Record<any, any>) => {
formData[key] = data[key] formData[key] = data[key]
} }
} }
//@ts-ignore //@ts-ignore
formData.create_time = timeFormat(formData.create_time,'yyyy-mm-dd hh:MM:ss') formData.create_time = timeFormat(formData.create_time,'yyyy-mm-dd hh:MM:ss')
} }
@ -153,7 +153,8 @@ const queryUser = async (query: string) => {
} }
const selectedUser = (value: any) => { const selectedUser = (value: any) => {
queryLand(value) optionsData.land = []
formData.land_id = ''
} }
const queryLand = async (user_id: string) => { const queryLand = async (user_id: string) => {
@ -166,6 +167,10 @@ const queryLand = async (user_id: string) => {
loading.value = false loading.value = false
} }
const selectedLand = () => {
queryLand(formData.user_id)
}
// //
const handleSubmit = async () => { const handleSubmit = async () => {
await formRef.value?.validate() await formRef.value?.validate()

View File

@ -38,9 +38,10 @@ class LandLogic extends BaseLogic
*/ */
public static function add(array $params): bool public static function add(array $params): bool
{ {
$root = (request()->adminInfo)['root'];
$userId = (request()->adminInfo)['user_id']; $userId = (request()->adminInfo)['user_id'];
if (!empty($params['user_id'])) { if ($root && !empty($params['user_id'])) {
$userId = $params['user_id']; $userId = $params['user_id'];
} }
Db::startTrans(); Db::startTrans();
try { try {
@ -86,9 +87,10 @@ class LandLogic extends BaseLogic
*/ */
public static function edit(array $params): bool public static function edit(array $params): bool
{ {
$root = (request()->adminInfo)['root'];
$userId = (request()->adminInfo)['user_id']; $userId = (request()->adminInfo)['user_id'];
if (!empty($params['user_id'])) { if ($root && !empty($params['user_id'])) {
$userId = $params['user_id']; $userId = $params['user_id'];
} }
Db::startTrans(); Db::startTrans();
try { try {

View File

@ -73,7 +73,7 @@ class UserLogic extends BaseLogic
->order('id desc') ->order('id desc')
->select()->toArray(); ->select()->toArray();
foreach ($lists as &$item) { foreach ($lists as &$item) {
$item['userinfo'] = $item['id'] . ' / ' . $item['nickname'] . ' / ' . $item['account']; $item['userinfo'] = $item['id'] . ' / ' . $item['account'];
} }
return $lists; return $lists;
} }