更新用户信息

This commit is contained in:
yaooo 2023-11-30 10:05:04 +08:00
parent 9bc28ea788
commit a9f6facd04
12 changed files with 32 additions and 204 deletions

View File

@ -9,24 +9,6 @@
@close="handleClose"
>
<el-form ref="formRef" :model="formData" label-width="120px" :rules="formRules">
<el-form-item label="用户ID" prop="user_id">
<el-select
v-model="formData.user_id"
filterable
remote
reserve-keyword
placeholder="请输入用户信息"
:remote-method="queryUser"
:loading="loading"
>
<el-option
v-for="item in userOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="产品ID" prop="product_id">
<el-select
v-model="formData.product_id"
@ -135,7 +117,6 @@ const popupTitle = computed(() => {
//
const formData = reactive({
id: '',
user_id: '',
product_id: '',
code: '',
name: '',
@ -150,11 +131,6 @@ const formData = reactive({
//
const formRules = reactive<any>({
user_id: [{
required: true,
message: '请输入用户ID',
trigger: ['blur']
}],
product_id: [{
required: true,
message: '请输入产品id',
@ -208,29 +184,8 @@ interface ListItem {
label: string
}
const productOptions = ref<ListItem[]>([])
const userOptions = ref<ListItem[]>([])
const loading = ref(false)
const queryUser = async (query: string) => {
if (query) {
loading.value = true
const userList = await getUserList({
keyword: query
})
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 = []
}
}
const queryProduct = async (query: string) => {
if (query) {
loading.value = true

View File

@ -9,7 +9,7 @@
@close="handleClose"
>
<el-form ref="formRef" :model="formData" label-width="120px" :rules="formRules">
<el-form-item label="用户ID" prop="user_id">
<el-form-item v-if="formData.root == 1" label="用户ID" prop="user_id">
<el-select
v-model="formData.user_id"
filterable
@ -118,6 +118,7 @@ const popupTitle = computed(() => {
const formData = reactive({
id: '',
user_id: '',
root: 0,
title: '',
total_area: '',
residual_area: '',
@ -142,11 +143,6 @@ const formData = reactive({
//
const formRules = reactive<any>({
user_id: [{
required: true,
message: '请输入用户ID',
trigger: ['blur']
}],
title: [{
required: true,
message: '请输入土地名称',

View File

@ -9,25 +9,6 @@
@close="handleClose"
>
<el-form ref="formRef" :model="formData" label-width="90px" :rules="formRules">
<el-form-item label="用户ID" prop="user_id">
<el-select
v-model="formData.user_id"
filterable
remote
reserve-keyword
placeholder="请输入用户信息"
:remote-method="queryUser"
:loading="loading"
>
<el-option
v-for="item in userOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="土地ID" prop="land_id">
<el-select
v-model="formData.land_id"
@ -116,7 +97,6 @@ const popupTitle = computed(() => {
//
const formData = reactive({
id: '',
user_id: '',
land_id: '',
kind: '',
breed: '',
@ -132,11 +112,6 @@ const formData = reactive({
//
const formRules = reactive<any>({
user_id: [{
required: true,
message: '请输入用户ID',
trigger: ['blur']
}],
land_id: [{
required: true,
message: '请输入土地id',
@ -198,29 +173,8 @@ interface ListItem {
label: string
}
const landOptions = ref<ListItem[]>([])
const userOptions = ref<ListItem[]>([])
const loading = ref(false)
const queryUser = async (query: string) => {
if (query) {
loading.value = true
const userList = await getUserList({
keyword: query
})
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 = []
}
}
const queryLand = async (query: string) => {
if (query) {
loading.value = true

View File

@ -9,25 +9,6 @@
@close="handleClose"
>
<el-form ref="formRef" :model="formData" label-width="90px" :rules="formRules">
<el-form-item label="用户ID" prop="user_id">
<el-select
v-model="formData.user_id"
filterable
remote
reserve-keyword
placeholder="请输入用户信息"
:remote-method="queryUser"
:loading="loading"
>
<el-option
v-for="item in userOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="种植ID" prop="land_id">
<el-select
v-model="formData.plant_id"
@ -93,7 +74,6 @@ const popupTitle = computed(() => {
//
const formData = reactive({
id: '',
user_id: '',
plant_id: '',
type: '',
type_text: '',
@ -103,11 +83,6 @@ const formData = reactive({
//
const formRules = reactive<any>({
user_id: [{
required: true,
message: '请输入用户ID',
trigger: ['blur']
}],
plant_id: [{
required: true,
message: '请输入种植ID',
@ -145,29 +120,8 @@ interface ListItem {
label: string
}
const landPlantOptions = ref<ListItem[]>([])
const userOptions = ref<ListItem[]>([])
const loading = ref(false)
const queryUser = async (query: string) => {
if (query) {
loading.value = true
const userList = await getUserList({
keyword: query
})
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 = []
}
}
const queryLandPlant = async (query: string) => {
if (query) {
loading.value = true

View File

@ -9,25 +9,6 @@
@close="handleClose"
>
<el-form ref="formRef" :model="formData" label-width="90px" :rules="formRules">
<el-form-item label="用户ID" prop="user_id">
<el-select
v-model="formData.user_id"
filterable
remote
reserve-keyword
placeholder="请输入用户信息"
:remote-method="queryUser"
:loading="loading"
>
<el-option
v-for="item in userOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="土地ID" prop="land_id">
<el-select
v-model="formData.land_id"
@ -93,7 +74,6 @@ const popupTitle = computed(() => {
//
const formData = reactive({
id: '',
user_id: '',
land_id: '',
code: '',
name: '',
@ -103,11 +83,6 @@ const formData = reactive({
//
const formRules = reactive<any>({
user_id: [{
required: true,
message: '请输入用户id',
trigger: ['blur']
}],
land_id: [{
required: true,
message: '请输入土地id',
@ -155,30 +130,9 @@ interface ListItem {
value: string
label: string
}
const userOptions = ref<ListItem[]>([])
const loading = ref(false)
const queryUser = async (query: string) => {
if (query) {
loading.value = true
const userList = await getUserList({
keyword: query
})
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 = []
}
}
const landOptions = ref<ListItem[]>([])
const loading = ref(false)
const queryLand = async (query: string) => {
if (query) {

View File

@ -68,11 +68,15 @@ class LandLists extends BaseAdminDataLists implements ListsSearchInterface
*/
public function lists(): array
{
return Land::where($this->searchWhere)->where($this->userSearch())->with('user')
->field(['id', 'user_id', 'title', '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', 'longitude', 'latitude', 'master_name', 'master_phone', 'pic'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->select()->each(function($item, $key){
$item['root'] = $this->adminInfo['root'] ?? 0;
return $item;
})
->toArray();
}

View File

@ -43,10 +43,11 @@ class DeviceLogic extends BaseLogic
} else {
$params['monitor_item'] = trim($params['monitor_item']);
}
$userId = Db::name('product')->where('id', $params['product_id'])->value('user_id');
Db::startTrans();
try {
$device = Device::create([
'user_id' => $params['user_id'],
'user_id' => $userId,
'code' => $params['code'],
'name' => $params['name'],
'type' => $params['type'],
@ -87,10 +88,11 @@ class DeviceLogic extends BaseLogic
} else {
$params['monitor_item'] = trim($params['monitor_item']);
}
$userId = Db::name('product')->where('id', $params['product_id'])->value('user_id');
Db::startTrans();
try {
$device = Device::where('id', $params['id'])->update([
'user_id' => $params['user_id'],
'user_id' => $userId,
'code' => $params['code'],
'name' => $params['name'],
'type' => $params['type'],

View File

@ -38,6 +38,9 @@ class LandLogic extends BaseLogic
*/
public static function add(array $params): bool
{
if ((request()->adminInfo)['root'] != 1) {
$params['user_id'] = (request()->adminInfo)['user_id'];
}
Db::startTrans();
try {
Land::create([
@ -83,6 +86,9 @@ class LandLogic extends BaseLogic
*/
public static function edit(array $params): bool
{
if ((request()->adminInfo)['root'] != 1) {
$params['user_id'] = (request()->adminInfo)['user_id'];
}
Db::startTrans();
try {
Land::where('id', $params['id'])->update([

View File

@ -38,10 +38,11 @@ class LandPlantActionLogic extends BaseLogic
*/
public static function add(array $params): bool
{
$userId = Db::name('land_plant')->where('id', $params['plant_id'])->value('user_id');
Db::startTrans();
try {
LandPlantAction::create([
'user_id' => $params['user_id'],
'user_id' => $userId,
'plant_id' => $params['plant_id'],
'type' => $params['type'],
'type_text' => $params['type_text'],
@ -67,10 +68,11 @@ class LandPlantActionLogic extends BaseLogic
*/
public static function edit(array $params): bool
{
$userId = Db::name('land_plant')->where('id', $params['plant_id'])->value('user_id');
Db::startTrans();
try {
LandPlantAction::where('id', $params['id'])->update([
'user_id' => $params['user_id'],
'user_id' => $userId,
'plant_id' => $params['plant_id'],
'type' => $params['type'],
'type_text' => $params['type_text'],

View File

@ -28,7 +28,6 @@ use think\facade\Db;
class LandPlantLogic extends BaseLogic
{
/**
* @notes 添加
* @param array $params
@ -38,10 +37,11 @@ class LandPlantLogic extends BaseLogic
*/
public static function add(array $params): bool
{
$userId = Db::name('land')->where('id', $params['land_id'])->value('user_id');
Db::startTrans();
try {
LandPlant::create([
'user_id' => $params['user_id'],
'user_id' => $userId,
'land_id' => $params['land_id'],
'kind' => $params['kind'],
'breed' => $params['breed'],
@ -73,10 +73,11 @@ class LandPlantLogic extends BaseLogic
*/
public static function edit(array $params): bool
{
$userId = Db::name('land')->where('id', $params['land_id'])->value('user_id');
Db::startTrans();
try {
LandPlant::where('id', $params['id'])->update([
'user_id' => $params['user_id'],
'user_id' => $userId,
'land_id' => $params['land_id'],
'kind' => $params['kind'],
'breed' => $params['breed'],

View File

@ -38,10 +38,11 @@ class ProductLogic extends BaseLogic
*/
public static function add(array $params): bool
{
$userId = Db::name('land')->where('id', $params['land_id'])->value('user_id');
Db::startTrans();
try {
$product = Product::create([
'user_id' => $params['user_id'],
'user_id' => $userId,
'code' => $params['code'],
'name' => $params['name'],
'status' => $params['status'],
@ -71,10 +72,11 @@ class ProductLogic extends BaseLogic
*/
public static function edit(array $params): bool
{
$userId = Db::name('land')->where('id', $params['land_id'])->value('user_id');
Db::startTrans();
try {
Product::where('id', $params['id'])->update([
'user_id' => $params['user_id'],
'user_id' => $userId,
'code' => $params['code'],
'name' => $params['name'],
'status' => $params['status'],

View File

@ -32,7 +32,6 @@ class ProductValidate extends BaseValidate
*/
protected $rule = [
'id' => 'require',
'user_id' => 'require',
'code' => 'require',
'name' => 'require',
'status' => 'require',
@ -45,7 +44,6 @@ class ProductValidate extends BaseValidate
*/
protected $field = [
'id' => 'id',
'user_id' => '用户id',
'code' => '产品编号',
'name' => '产品名称',
'status' => '产品状态',
@ -60,7 +58,7 @@ class ProductValidate extends BaseValidate
*/
public function sceneAdd()
{
return $this->only(['user_id','code','name','status']);
return $this->only(['code','name','status']);
}
@ -72,7 +70,7 @@ class ProductValidate extends BaseValidate
*/
public function sceneEdit()
{
return $this->only(['id','user_id','code','name','status']);
return $this->only(['id','code','name','status']);
}