更新用户信息

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" @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 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-form-item label="产品ID" prop="product_id">
<el-select <el-select
v-model="formData.product_id" v-model="formData.product_id"
@ -135,7 +117,6 @@ const popupTitle = computed(() => {
// //
const formData = reactive({ const formData = reactive({
id: '', id: '',
user_id: '',
product_id: '', product_id: '',
code: '', code: '',
name: '', name: '',
@ -150,11 +131,6 @@ const formData = reactive({
// //
const formRules = reactive<any>({ const formRules = reactive<any>({
user_id: [{
required: true,
message: '请输入用户ID',
trigger: ['blur']
}],
product_id: [{ product_id: [{
required: true, required: true,
message: '请输入产品id', message: '请输入产品id',
@ -208,29 +184,8 @@ interface ListItem {
label: string label: string
} }
const productOptions = ref<ListItem[]>([]) const productOptions = ref<ListItem[]>([])
const userOptions = ref<ListItem[]>([])
const loading = ref(false) 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) => { const queryProduct = async (query: string) => {
if (query) { if (query) {
loading.value = true loading.value = true

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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