细节处理

This commit is contained in:
yaooo 2023-11-30 15:27:33 +08:00
parent c54325c428
commit de35413527
5 changed files with 33 additions and 22 deletions

View File

@ -146,7 +146,7 @@
}
}"
>
查看详情
详情
</router-link>
</el-button>
<el-button
@ -162,7 +162,7 @@
}
}"
>
查看报警
报警
</router-link>
</el-button>
<el-button

View File

@ -29,6 +29,9 @@
</el-form-item>
<el-form-item label="土地名称" prop="title">
<el-input v-model="formData.title" clearable placeholder="请输入土地名称" />
</el-form-item>
<el-form-item label="详细地址" prop="address">
<el-input v-model="formData.address" clearable placeholder="请输入详细地址" />
</el-form-item>
<el-form-item label="土地面积" prop="total_area">
<el-input v-model="formData.total_area" clearable placeholder="请输入土地面积" />
@ -71,12 +74,6 @@
</el-form-item>
<el-form-item label="组名称" prop="group_name">
<el-input v-model="formData.group_name" clearable placeholder="请输入组名称" />
</el-form-item>
<el-form-item label="经度" prop="longitude">
<el-input v-model="formData.longitude" clearable placeholder="请输入经度" />
</el-form-item>
<el-form-item label="纬度" prop="latitude">
<el-input v-model="formData.latitude" clearable placeholder="请输入纬度" />
</el-form-item>
<el-form-item label="土地负责人" prop="master_name">
<el-input v-model="formData.master_name" clearable placeholder="请输入土地负责人" />
@ -134,10 +131,9 @@ const formData = reactive({
village_name: '',
group_code: '',
group_name: '',
longitude: '',
latitude: '',
master_name: '',
master_phone: '',
address: '',
pic: ''
})
@ -148,6 +144,11 @@ const formRules = reactive<any>({
message: '请输入土地名称',
trigger: ['blur']
}],
address: [{
required: true,
message: '请输入详细地址',
trigger: ['blur']
}],
master_name: [{
required: true,
message: '请输入土地负责人',

View File

@ -70,7 +70,7 @@ class LandLists extends BaseAdminDataLists implements ListsSearchInterface
{
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', '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'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($item, $key){

View File

@ -47,6 +47,7 @@ class LandLogic extends BaseLogic
Land::create([
'user_id' => $userId,
'title' => $params['title'],
'address' => $params['address'],
'total_area' => $params['total_area'],
'residual_area' => $params['residual_area'],
'province_code' => $params['province_code'],
@ -61,8 +62,6 @@ class LandLogic extends BaseLogic
'village_name' => $params['village_name'],
'group_code' => $params['group_code'],
'group_name' => $params['group_name'],
'longitude' => $params['longitude'],
'latitude' => $params['latitude'],
'master_name' => $params['master_name'],
'master_phone' => $params['master_phone'],
'pic' => json_encode($params['pic']),
@ -96,6 +95,7 @@ class LandLogic extends BaseLogic
Land::where('id', $params['id'])->update([
'user_id' => $userId,
'title' => $params['title'],
'address' => $params['address'],
'total_area' => $params['total_area'],
'residual_area' => $params['residual_area'],
'province_code' => $params['province_code'],
@ -109,9 +109,7 @@ class LandLogic extends BaseLogic
'village_code' => $params['village_code'],
'village_name' => $params['village_name'],
'group_code' => $params['group_code'],
'group_name' => $params['group_name'],
'longitude' => $params['longitude'],
'latitude' => $params['latitude'],
'group_name' => $params['group_name'],
'master_name' => $params['master_name'],
'master_phone' => $params['master_phone'],
'pic' => json_encode($params['pic']),
@ -161,7 +159,8 @@ class LandLogic extends BaseLogic
Db::startTrans();
try {
Db::name('product')->where('id', $params['product_id'])->update([
'user_id' => $userId
'user_id' => $userId,
'status' => 2
]);
Db::name('land_product')->where('land_id', $params['id'])->delete();
Db::name('land_product')->where('product_id', $params['product_id'])->delete();

View File

@ -35,8 +35,8 @@ class LandValidate extends BaseValidate
'id' => 'require',
'product_id' => 'require',
'title' => 'require',
'total_area' => 'require',
'residual_area' => 'require',
'address' => 'require',
'residual_area' => 'checkArea',
'province_code' => 'require',
'province_name' => 'require',
'city_code' => 'require',
@ -63,6 +63,7 @@ class LandValidate extends BaseValidate
protected $field = [
'id' => 'id',
'title' => '土地名称',
'address' => '详细地址',
'total_area' => '土地面积',
'residual_area' => '剩余面积',
'province_code' => '省编码',
@ -81,7 +82,7 @@ class LandValidate extends BaseValidate
'latitude' => '纬度',
'master_name' => '土地负责人',
'master_phone' => '负责人电话',
'status' => '土地状态1-未种植 2-部分种植 3-全部种植',
'status' => '土地状态',
'pic' => '土地图片',
];
@ -94,7 +95,7 @@ class LandValidate extends BaseValidate
*/
public function sceneAdd()
{
return $this->only(['title','master_name','master_phone']);
return $this->only(['title','address','residual_area','master_name','master_phone']);
}
@ -106,7 +107,7 @@ class LandValidate extends BaseValidate
*/
public function sceneEdit()
{
return $this->only(['id','title','master_name','master_phone']);
return $this->only(['id','title','address','residual_area','master_name','master_phone']);
}
@ -153,4 +154,14 @@ class LandValidate extends BaseValidate
return $this->only(['id', 'product_id']);
}
public function checkArea($value, $rule, $data)
{
if (!empty($data['total_area']) && !empty($data['residual_area'])) {
if ($data['residual_area'] > $data['total_area']) {
return '剩余面积不能大于总面积';
}
}
return true;
}
}