更新细节
This commit is contained in:
parent
8b157ece54
commit
7df61d7920
|
@ -1,5 +1,10 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
// 用户列表
|
||||
export function getUserList(params: any) {
|
||||
return request.get({ url: '/user.user/lists', params }, { ignoreCancelToken: true })
|
||||
}
|
||||
|
||||
// 土地种植表列表
|
||||
export function apiLandPlantLists(params: any) {
|
||||
return request.get({ url: '/land.land_plant/lists', params })
|
||||
|
|
|
@ -62,11 +62,11 @@
|
|||
<el-tag class="ml-2" type="success">名称: {{ row.title }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="种植种类" width="150" prop="kind" show-overflow-tooltip />
|
||||
<el-table-column label="种植品牌" width="150" prop="breed" show-overflow-tooltip />
|
||||
<el-table-column label="种植面积" width="150" prop="area" show-overflow-tooltip />
|
||||
<el-table-column label="种植人员" width="150" prop="user" show-overflow-tooltip />
|
||||
<el-table-column label="生长状态" width="150" prop="status">
|
||||
<el-table-column label="种植种类" prop="kind" show-overflow-tooltip />
|
||||
<el-table-column label="种植品牌" prop="breed" show-overflow-tooltip />
|
||||
<el-table-column label="种植面积" prop="area" show-overflow-tooltip />
|
||||
<el-table-column label="种植人员" prop="user" show-overflow-tooltip />
|
||||
<el-table-column label="生长状态" prop="status">
|
||||
<template #default="{ row }">
|
||||
<dict-value :options="dictData.plant_status" :value="row.status" />
|
||||
</template>
|
||||
|
@ -142,7 +142,7 @@ const editRef = shallowRef<InstanceType<typeof EditPopup>>()
|
|||
// 是否显示编辑框
|
||||
const showEdit = ref(false)
|
||||
|
||||
var land_id = query.land_id
|
||||
let land_id = query.land_id
|
||||
if (typeof(land_id) == 'undefined') {
|
||||
land_id = ''
|
||||
}
|
||||
|
@ -156,6 +156,8 @@ const queryParams = reactive({
|
|||
user: '',
|
||||
status: '',
|
||||
plant_date: '',
|
||||
start_time: '',
|
||||
end_time: '',
|
||||
})
|
||||
|
||||
// 选中数据
|
||||
|
|
|
@ -9,6 +9,25 @@
|
|||
@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="plant_id">
|
||||
<el-input v-model="formData.plant_id" clearable placeholder="请输入种植ID" />
|
||||
</el-form-item> -->
|
||||
|
@ -54,7 +73,7 @@
|
|||
<script lang="ts" setup name="landPlantActionEdit">
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import Popup from '@/components/popup/index.vue'
|
||||
import { apiLandPlantActionAdd, apiLandPlantActionEdit, apiLandPlantActionDetail, apiLandPlantLists } from '@/api/land_plant_action'
|
||||
import { apiLandPlantActionAdd, apiLandPlantActionEdit, apiLandPlantActionDetail, apiLandPlantLists, getUserList } from '@/api/land_plant_action'
|
||||
import { timeFormat } from '@/utils/util'
|
||||
import type { PropType } from 'vue'
|
||||
defineProps({
|
||||
|
@ -77,6 +96,7 @@ const popupTitle = computed(() => {
|
|||
// 表单数据
|
||||
const formData = reactive({
|
||||
id: '',
|
||||
user_id: '',
|
||||
plant_id: '',
|
||||
type: '',
|
||||
type_text: '',
|
||||
|
@ -86,6 +106,11 @@ const formData = reactive({
|
|||
|
||||
// 表单验证
|
||||
const formRules = reactive<any>({
|
||||
user_id: [{
|
||||
required: true,
|
||||
message: '请输入用户ID',
|
||||
trigger: ['blur']
|
||||
}],
|
||||
plant_id: [{
|
||||
required: true,
|
||||
message: '请输入种植ID',
|
||||
|
@ -123,8 +148,29 @@ 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
|
||||
|
@ -134,7 +180,7 @@ const queryLandPlant = async (query: string) => {
|
|||
loading.value = false
|
||||
if (landList.count > 0) {
|
||||
landPlantOptions.value = landList.lists.map((landPlant: any) => {
|
||||
return { value: `${landPlant.id}`, label: `ID: ${landPlant.id} / 土地: ${landPlant.land.title} / 种类: ${landPlant.kind} / 品牌: ${landPlant.breed}` }
|
||||
return { value: `${landPlant.id}`, label: `ID: ${landPlant.id} / 种类: ${landPlant.kind} / 品牌: ${landPlant.breed}` }
|
||||
})
|
||||
} else {
|
||||
landPlantOptions.value = []
|
||||
|
|
|
@ -22,6 +22,12 @@
|
|||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="种植操作时间" prop="create_time">
|
||||
<daterange-picker
|
||||
v-model:startTime="queryParams.start_time"
|
||||
v-model:endTime="queryParams.end_time"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="resetPage">查询</el-button>
|
||||
|
@ -31,21 +37,33 @@
|
|||
</el-card>
|
||||
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
|
||||
<div class="mt-4">
|
||||
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
|
||||
<el-table :data="pager.lists" @selection-change="handleSelectionChange" style="width: 100%">
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column label="ID" prop="id" show-overflow-tooltip />
|
||||
|
||||
<el-table-column label="用户ID" prop="user_id" show-overflow-tooltip />
|
||||
<el-table-column label="种植ID" prop="plant_id" show-overflow-tooltip />
|
||||
<el-table-column label="种植类型" prop="landPlant.kind" show-overflow-tooltip />
|
||||
<el-table-column label="种植品牌" prop="landPlant.breed" show-overflow-tooltip />
|
||||
<el-table-column label="用户信息" width="200">
|
||||
<template #default="{ row }">
|
||||
<el-tag class="ml-2" type="success">ID: {{ row.user_id }}</el-tag>
|
||||
<el-tag class="ml-2" type="success">账户: {{ row.account }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="土地种植信息" width="200">
|
||||
<template #default="{ row }">
|
||||
<el-tag class="ml-2" type="success">ID: {{ row.plant_id }}</el-tag>
|
||||
<el-tag class="ml-2" type="success">类型: {{ row.kind }} 品牌: {{ row.breed }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="种植操作类型" prop="type">
|
||||
<template #default="{ row }">
|
||||
<dict-value :options="dictData.land_plant_action" :value="row.type" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="种植操作" prop="type_text" show-overflow-tooltip />
|
||||
<el-table-column label="操作详情" prop="detail" show-overflow-tooltip />
|
||||
<el-table-column label="种植操作详情" prop="detail" show-overflow-tooltip />
|
||||
<el-table-column label="种植操作时间" width="180" prop="plant_date">
|
||||
<template #default="{ row }">
|
||||
<span>{{ row.create_time ? timeFormat(row.create_time, 'yyyy-mm-dd hh:MM:ss') : '' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="120" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
|
@ -89,7 +107,7 @@ const editRef = shallowRef<InstanceType<typeof EditPopup>>()
|
|||
// 是否显示编辑框
|
||||
const showEdit = ref(false)
|
||||
|
||||
var plant_id = query.plant_id
|
||||
let plant_id = query.plant_id
|
||||
if (typeof(plant_id) == 'undefined') {
|
||||
plant_id = ''
|
||||
}
|
||||
|
@ -99,6 +117,8 @@ const queryParams = reactive({
|
|||
user_id: '',
|
||||
plant_id: plant_id,
|
||||
type: '',
|
||||
start_time: '',
|
||||
end_time: '',
|
||||
})
|
||||
|
||||
// 选中数据
|
||||
|
|
|
@ -57,21 +57,29 @@
|
|||
删除
|
||||
</el-button>
|
||||
<div class="mt-4">
|
||||
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
|
||||
<el-table :data="pager.lists" @selection-change="handleSelectionChange" style="width: 100%">
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column label="ID" prop="id" show-overflow-tooltip />
|
||||
<el-table-column label="用户信息" width="200">
|
||||
<template #default="{ row }">
|
||||
<el-tag class="ml-2" type="success">ID: {{ row.user_id }}</el-tag>
|
||||
<el-tag class="ml-2" type="success">账户: {{ row.account }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="土地信息" width="200">
|
||||
<template #default="{ row }">
|
||||
<el-tag class="ml-2" type="success">ID: {{ row.land_id }}</el-tag>
|
||||
<el-tag class="ml-2" type="success">名称: {{ row.title }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="产品编号" prop="code" show-overflow-tooltip />
|
||||
<el-table-column label="产品名称" prop="name" show-overflow-tooltip />
|
||||
<el-table-column label="用户ID" prop="user_id" show-overflow-tooltip />
|
||||
<el-table-column label="所属用户" prop="account" show-overflow-tooltip />
|
||||
<el-table-column label="土地ID" prop="land_id" show-overflow-tooltip />
|
||||
<el-table-column label="土地名称" prop="title" show-overflow-tooltip />
|
||||
<el-table-column label="产品状态" prop="status">
|
||||
<template #default="{ row }">
|
||||
<dict-value :options="dictData.product_status" :value="row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建时间" prop="create_time">
|
||||
<el-table-column label="创建时间" width="180" prop="create_time">
|
||||
<template #default="{ row }">
|
||||
<span>{{ row.create_time ? timeFormat(row.create_time, 'yyyy-mm-dd hh:MM:ss') : '' }}</span>
|
||||
</template>
|
||||
|
@ -119,7 +127,7 @@ const editRef = shallowRef<InstanceType<typeof EditPopup>>()
|
|||
// 是否显示编辑框
|
||||
const showEdit = ref(false)
|
||||
|
||||
var land_id = query.land_id
|
||||
let land_id = query.land_id
|
||||
if (typeof(land_id) == 'undefined') {
|
||||
land_id = ''
|
||||
}
|
||||
|
@ -131,6 +139,8 @@ const queryParams = reactive({
|
|||
name: '',
|
||||
status: '',
|
||||
create_time: '',
|
||||
start_time: '',
|
||||
end_time: '',
|
||||
})
|
||||
|
||||
// 选中数据
|
||||
|
|
|
@ -42,16 +42,33 @@ class LandPlantActionLists extends BaseAdminDataLists implements ListsSearchInte
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 搜索条件
|
||||
* @author 段誉
|
||||
* @date 2023/2/24 16:08
|
||||
*/
|
||||
public function querySearch()
|
||||
{
|
||||
$where = [];
|
||||
if (!empty($this->params['start_time'])) {
|
||||
$where[] = ['lpa.create_time', '>=', strtotime($this->params['start_time'])];
|
||||
}
|
||||
if (!empty($this->params['end_time'])) {
|
||||
$where[] = ['lpa.create_time', '<', strtotime($this->params['end_time'])];
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
|
||||
public function userSearch(): array
|
||||
{
|
||||
$userWhere['u.user_id'] = 0;
|
||||
$userWhere['lpa.user_id'] = 0;
|
||||
// 超级管理员数据
|
||||
if ($this->adminInfo['root'] && !$this->adminInfo['user_id']) {
|
||||
unset($userWhere['u.user_id']);
|
||||
unset($userWhere['lpa.user_id']);
|
||||
}
|
||||
// 普通用户数据
|
||||
if (!$this->adminInfo['root'] && $this->adminInfo['user_id']) {
|
||||
$userWhere['u.user_id'] = $this->adminInfo['user_id'];
|
||||
$userWhere['lpa.user_id'] = $this->adminInfo['user_id'];
|
||||
}
|
||||
return $userWhere;
|
||||
}
|
||||
|
@ -68,7 +85,7 @@ class LandPlantActionLists extends BaseAdminDataLists implements ListsSearchInte
|
|||
public function lists(): array
|
||||
{
|
||||
return Db::name('land_plant_action')->alias('lpa')
|
||||
->where($this->searchWhere)->where($this->userSearch())
|
||||
->where($this->searchWhere)->where($this->userSearch())->where($this->querySearch())
|
||||
->leftJoin('user u','u.id = lpa.user_id')
|
||||
->leftJoin('land_plant lp','lp.id = lpa.plant_id')
|
||||
->field('lpa.*, lp.kind, lp.breed, u.account')
|
||||
|
@ -87,7 +104,7 @@ class LandPlantActionLists extends BaseAdminDataLists implements ListsSearchInte
|
|||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return Db::name('land_plant_action')->alias('lpa')->where($this->searchWhere)->where($this->userSearch())->count();
|
||||
return Db::name('land_plant_action')->alias('lpa')->where($this->searchWhere)->where($this->userSearch())->where($this->querySearch())->count();
|
||||
}
|
||||
|
||||
}
|
|
@ -48,12 +48,18 @@ class LandPlantLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||
* @author 段誉
|
||||
* @date 2023/2/24 16:08
|
||||
*/
|
||||
public function queryWhere()
|
||||
public function querySearch()
|
||||
{
|
||||
$where = [];
|
||||
if (!empty($this->params['keyword'])) {
|
||||
$where[] = ['lp.kind|lp.breed', 'like', '%' . $this->params['keyword'] . '%'];
|
||||
}
|
||||
if (!empty($this->params['start_time'])) {
|
||||
$where[] = ['lp.plant_date', '>=', strtotime($this->params['start_time'])];
|
||||
}
|
||||
if (!empty($this->params['end_time'])) {
|
||||
$where[] = ['lp.plant_date', '<', strtotime($this->params['end_time'])];
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
|
||||
|
@ -83,7 +89,7 @@ class LandPlantLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||
public function lists(): array
|
||||
{
|
||||
return Db::name('land_plant')->alias('lp')
|
||||
->where($this->searchWhere)->where($this->userSearch())->where($this->queryWhere())
|
||||
->where($this->searchWhere)->where($this->userSearch())->where($this->querySearch())
|
||||
->leftJoin('user u','u.id = lp.user_id')
|
||||
->leftJoin('land l','l.id = lp.land_id')
|
||||
->field('lp.*, l.title, u.account')
|
||||
|
@ -102,7 +108,7 @@ class LandPlantLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return Db::name('land_plant')->alias('lp')->where($this->searchWhere)->where($this->userSearch())->where($this->queryWhere())->count();
|
||||
return Db::name('land_plant')->alias('lp')->where($this->searchWhere)->where($this->userSearch())->where($this->querySearch())->count();
|
||||
}
|
||||
|
||||
}
|
|
@ -38,7 +38,7 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['p.user_id', 'p.code', 'p.name', 'p.status', 'p.create_time'],
|
||||
'=' => ['p.user_id', 'p.code', 'p.name', 'p.status'],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,12 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||
if (!empty($this->params['land_id'])) {
|
||||
$queryWhere['l.id'] = $this->params['land_id'];
|
||||
}
|
||||
if (!empty($this->params['start_time'])) {
|
||||
$queryWhere[] = ['p.create_time', '>=', strtotime($this->params['start_time'])];
|
||||
}
|
||||
if (!empty($this->params['end_time'])) {
|
||||
$queryWhere[] = ['p.create_time', '<', strtotime($this->params['end_time'])];
|
||||
}
|
||||
return $queryWhere;
|
||||
}
|
||||
|
||||
|
@ -97,7 +103,7 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return Db::name('product')->alias('p')->where($this->searchWhere)->where($this->userSearch())->count();
|
||||
return Db::name('product')->alias('p')->where($this->searchWhere)->where($this->userSearch())->where($this->querySearch())->count();
|
||||
}
|
||||
|
||||
}
|
|
@ -41,6 +41,7 @@ class LandPlantActionLogic extends BaseLogic
|
|||
Db::startTrans();
|
||||
try {
|
||||
LandPlantAction::create([
|
||||
'user_id' => $params['user_id'],
|
||||
'plant_id' => $params['plant_id'],
|
||||
'type' => $params['type'],
|
||||
'type_text' => $params['type_text'],
|
||||
|
@ -69,6 +70,7 @@ class LandPlantActionLogic extends BaseLogic
|
|||
Db::startTrans();
|
||||
try {
|
||||
LandPlantAction::where('id', $params['id'])->update([
|
||||
'user_id' => $params['user_id'],
|
||||
'plant_id' => $params['plant_id'],
|
||||
'type' => $params['type'],
|
||||
'type_text' => $params['type_text'],
|
||||
|
|
Loading…
Reference in New Issue