update 栏舍管理
This commit is contained in:
parent
16121d7260
commit
685f965d5a
|
@ -28,6 +28,9 @@
|
||||||
<el-form-item label="栏舍名称" prop="fence_house_name">
|
<el-form-item label="栏舍名称" prop="fence_house_name">
|
||||||
<el-input v-model="formData.fence_house_name" clearable placeholder="请输入栏舍名称" />
|
<el-input v-model="formData.fence_house_name" clearable placeholder="请输入栏舍名称" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="动物名称" prop="animal_name">
|
||||||
|
<el-input v-model="formData.animal_name" clearable placeholder="请输入栏舍名称" />
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="动物类型" prop="animal_type">
|
<el-form-item label="动物类型" prop="animal_type">
|
||||||
<el-select class="flex-1" v-model="formData.animal_type" clearable placeholder="请选择动物类型">
|
<el-select class="flex-1" v-model="formData.animal_type" clearable placeholder="请选择动物类型">
|
||||||
<el-option
|
<el-option
|
||||||
|
@ -55,10 +58,38 @@
|
||||||
<el-input v-model="formData.master" clearable placeholder="请输入负责人" />
|
<el-input v-model="formData.master" clearable placeholder="请输入负责人" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态" prop="status">
|
<el-form-item label="状态" prop="status">
|
||||||
<el-input v-model="formData.status" clearable placeholder="请输入状态" />
|
<el-select class="flex-1" v-model="formData.status" clearable placeholder="请选择状态">
|
||||||
|
<el-option
|
||||||
|
v-for="(item, index) in dictData.system_disable"
|
||||||
|
:key="index"
|
||||||
|
:label="item.name"
|
||||||
|
:value="parseInt(item.value)"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="二维码" prop="qr_code">
|
|
||||||
<el-input v-model="formData.qr_code" clearable placeholder="请输入二维码" />
|
<el-form-item label="图片" prop="image">
|
||||||
|
<el-upload
|
||||||
|
class="avatar-uploader"
|
||||||
|
:accept="acceptFileTypes"
|
||||||
|
v-model="formData.image"
|
||||||
|
:data="{ cid: 1 }"
|
||||||
|
:headers="{ Token: userStore.token }"
|
||||||
|
:action="action"
|
||||||
|
:show-file-list="false"
|
||||||
|
:on-success="handleAvatarSuccessAvatar"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
v-if="formData.image"
|
||||||
|
:src="formData.image"
|
||||||
|
class="avatar"
|
||||||
|
/>
|
||||||
|
<div v-else class="avatar-uploader-icon">
|
||||||
|
<el-icon>
|
||||||
|
<Plus />
|
||||||
|
</el-icon>
|
||||||
|
</div>
|
||||||
|
</el-upload>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
</el-form>
|
</el-form>
|
||||||
|
@ -72,19 +103,37 @@ import Popup from '@/components/popup/index.vue'
|
||||||
import {apiFenceHouseAdd, apiFenceHouseEdit, apiFenceHouseDetail, apiFenceHouseLists, apiFarmLists} from '@/api/fence_house'
|
import {apiFenceHouseAdd, apiFenceHouseEdit, apiFenceHouseDetail, apiFenceHouseLists, apiFarmLists} from '@/api/fence_house'
|
||||||
import { timeFormat } from '@/utils/util'
|
import { timeFormat } from '@/utils/util'
|
||||||
import type { PropType } from 'vue'
|
import type { PropType } from 'vue'
|
||||||
import {useDictOptions} from "@/hooks/useDictOptions";
|
import {useDictOptions} from "@/hooks/useDictOptions"
|
||||||
import {ref} from "vue";
|
import {ref} from "vue"
|
||||||
|
import config from "@/config";
|
||||||
|
import useUserStore from "@/stores/modules/user";
|
||||||
|
import {ElMessage, type UploadProps} from "element-plus";
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
dictData: {
|
dictData: {
|
||||||
type: Object as PropType<Record<string, any[]>>,
|
type: Object as PropType<Record<string, any[]>>,
|
||||||
default: () => ({})
|
default: () => ({})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits(['success', 'close'])
|
const emit = defineEmits(['success', 'close'])
|
||||||
const formRef = shallowRef<FormInstance>()
|
const formRef = shallowRef<FormInstance>()
|
||||||
const popupRef = shallowRef<InstanceType<typeof Popup>>()
|
const popupRef = shallowRef<InstanceType<typeof Popup>>()
|
||||||
const mode = ref('add')
|
const mode = ref('add')
|
||||||
|
|
||||||
|
const acceptFileTypes = ref(".png, .jpg, .jpeg, image/png, image/jpeg")
|
||||||
|
const action = ref(`${config.baseUrl}${config.urlPrefix}/upload/image`)
|
||||||
|
const userStore = useUserStore()
|
||||||
|
const handleAvatarSuccessAvatar: UploadProps["onSuccess"] = (
|
||||||
|
response,
|
||||||
|
uploadFile
|
||||||
|
) => {
|
||||||
|
if (response.code == 0) {
|
||||||
|
ElMessage.error(response.msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
formData.image = response.data.uri;
|
||||||
|
}
|
||||||
|
|
||||||
// 弹窗标题
|
// 弹窗标题
|
||||||
const popupTitle = computed(() => {
|
const popupTitle = computed(() => {
|
||||||
|
@ -95,6 +144,7 @@ const popupTitle = computed(() => {
|
||||||
const formData = reactive({
|
const formData = reactive({
|
||||||
id: '',
|
id: '',
|
||||||
farm_id: '',
|
farm_id: '',
|
||||||
|
animal_name: '',
|
||||||
fence_house_name: '',
|
fence_house_name: '',
|
||||||
animal_type: '',
|
animal_type: '',
|
||||||
fence_house_type: '',
|
fence_house_type: '',
|
||||||
|
@ -102,6 +152,7 @@ const formData = reactive({
|
||||||
master: '',
|
master: '',
|
||||||
status: '',
|
status: '',
|
||||||
qr_code: '',
|
qr_code: '',
|
||||||
|
image: '',
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -130,7 +181,6 @@ const queryFarm= async (query: string) => {
|
||||||
optionsData.farmList = farmList
|
optionsData.farmList = farmList
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
console.log(optionsData)
|
|
||||||
|
|
||||||
|
|
||||||
// 获取详情
|
// 获取详情
|
||||||
|
@ -183,3 +233,35 @@ defineExpose({
|
||||||
getDetail
|
getDetail
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
<style scoped>
|
||||||
|
.avatar-uploader .avatar {
|
||||||
|
width: 178px;
|
||||||
|
height: 178px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.avatar-uploader .el-upload {
|
||||||
|
width: 200px;
|
||||||
|
height: 130px;
|
||||||
|
border: 1px dashed var(--el-border-color);
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
transition: var(--el-transition-duration-fast);
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar-uploader .el-upload:hover {
|
||||||
|
border-color: var(--el-color-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-icon.avatar-uploader-icon {
|
||||||
|
font-size: 28px;
|
||||||
|
color: #8c939d;
|
||||||
|
width: 178px;
|
||||||
|
height: 178px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -47,7 +47,11 @@
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="容量" prop="capacity" show-overflow-tooltip />
|
<el-table-column label="容量" prop="capacity" show-overflow-tooltip />
|
||||||
<el-table-column label="负责人" prop="master" show-overflow-tooltip />
|
<el-table-column label="负责人" prop="master" show-overflow-tooltip />
|
||||||
<el-table-column label="状态" prop="status" show-overflow-tooltip />
|
<el-table-column label="状态" prop="status">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<dict-value :options="dictData.system_disable" :value="row.status" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column label="操作" width="120" fixed="right">
|
<el-table-column label="操作" width="120" fixed="right">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
|
@ -106,7 +110,7 @@ const handleSelectionChange = (val: any[]) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取字典数据
|
// 获取字典数据
|
||||||
const { dictData } = useDictData('animal_type,fence_house_type')
|
const { dictData } = useDictData('animal_type,fence_house_type,system_disable')
|
||||||
|
|
||||||
// 分页相关
|
// 分页相关
|
||||||
const { pager, getLists, resetParams, resetPage } = usePaging({
|
const { pager, getLists, resetParams, resetPage } = usePaging({
|
||||||
|
|
|
@ -1,77 +1,77 @@
|
||||||
<?php
|
<?php
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||||
// | 开源版本可自由商用,可去除界面版权logo
|
// | 开源版本可自由商用,可去除界面版权logo
|
||||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||||
// | 访问官网:https://www.likeadmin.cn
|
// | 访问官网:https://www.likeadmin.cn
|
||||||
// | likeadmin团队 版权所有 拥有最终解释权
|
// | likeadmin团队 版权所有 拥有最终解释权
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
// | author: likeadminTeam
|
// | author: likeadminTeam
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
namespace app\adminapi\lists\fence_house;
|
namespace app\adminapi\lists\fence_house;
|
||||||
|
|
||||||
|
|
||||||
use app\adminapi\lists\BaseAdminDataLists;
|
use app\adminapi\lists\BaseAdminDataLists;
|
||||||
use app\common\model\fence_house\FenceHouse;
|
use app\common\model\fence_house\FenceHouse;
|
||||||
use app\common\lists\ListsSearchInterface;
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FenceHouse列表
|
* FenceHouse列表
|
||||||
* Class FenceHouseLists
|
* Class FenceHouseLists
|
||||||
* @package app\adminapi\listsfence_house
|
* @package app\adminapi\listsfence_house
|
||||||
*/
|
*/
|
||||||
class FenceHouseLists extends BaseAdminDataLists implements ListsSearchInterface
|
class FenceHouseLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notes 设置搜索条件
|
* @notes 设置搜索条件
|
||||||
* @return \string[][]
|
* @return \string[][]
|
||||||
* @author likeadmin
|
* @author likeadmin
|
||||||
* @date 2024/01/10 15:15
|
* @date 2024/01/10 15:15
|
||||||
*/
|
*/
|
||||||
public function setSearch(): array
|
public function setSearch(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'=' => ['fence_house_name'],
|
'=' => ['fence_house_name'],
|
||||||
];
|
|
||||||
}
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @notes 获取列表
|
/**
|
||||||
* @return array
|
* @notes 获取列表
|
||||||
* @throws \think\db\exception\DataNotFoundException
|
* @return array
|
||||||
* @throws \think\db\exception\DbException
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
* @throws \think\db\exception\ModelNotFoundException
|
* @throws \think\db\exception\DbException
|
||||||
* @author likeadmin
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
* @date 2024/01/10 15:15
|
* @author likeadmin
|
||||||
*/
|
* @date 2024/01/10 15:15
|
||||||
public function lists(): array
|
*/
|
||||||
{
|
public function lists(): array
|
||||||
return FenceHouse::where($this->searchWhere)
|
{
|
||||||
->field(['id', 'farm_id', 'fence_house_name', 'animal_type', 'fence_house_type', 'capacity', 'master', 'status'])
|
return FenceHouse::where($this->searchWhere)
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()
|
->select()
|
||||||
->toArray();
|
->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notes 获取数量
|
* @notes 获取数量
|
||||||
* @return int
|
* @return int
|
||||||
* @author likeadmin
|
* @author likeadmin
|
||||||
* @date 2024/01/10 15:15
|
* @date 2024/01/10 15:15
|
||||||
*/
|
*/
|
||||||
public function count(): int
|
public function count(): int
|
||||||
{
|
{
|
||||||
return FenceHouse::where($this->searchWhere)->count();
|
return FenceHouse::where($this->searchWhere)->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -43,6 +43,7 @@ class FenceHouseLogic extends BaseLogic
|
||||||
try {
|
try {
|
||||||
FenceHouse::create([
|
FenceHouse::create([
|
||||||
'farm_id' => $params['farm_id'],
|
'farm_id' => $params['farm_id'],
|
||||||
|
'animal_name' => $params['animal_name'],
|
||||||
'fence_house_name' => $params['fence_house_name'],
|
'fence_house_name' => $params['fence_house_name'],
|
||||||
'animal_type' => $params['animal_type'],
|
'animal_type' => $params['animal_type'],
|
||||||
'fence_house_type' => $params['fence_house_type'],
|
'fence_house_type' => $params['fence_house_type'],
|
||||||
|
@ -50,6 +51,7 @@ class FenceHouseLogic extends BaseLogic
|
||||||
'master' => $params['master'],
|
'master' => $params['master'],
|
||||||
'status' => $params['status'],
|
'status' => $params['status'],
|
||||||
'qr_code' => $params['qr_code'],
|
'qr_code' => $params['qr_code'],
|
||||||
|
'image' => $params['image'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
|
@ -75,6 +77,7 @@ class FenceHouseLogic extends BaseLogic
|
||||||
try {
|
try {
|
||||||
FenceHouse::where('id', $params['id'])->update([
|
FenceHouse::where('id', $params['id'])->update([
|
||||||
'farm_id' => $params['farm_id'],
|
'farm_id' => $params['farm_id'],
|
||||||
|
'animal_name' => $params['animal_name'],
|
||||||
'fence_house_name' => $params['fence_house_name'],
|
'fence_house_name' => $params['fence_house_name'],
|
||||||
'animal_type' => $params['animal_type'],
|
'animal_type' => $params['animal_type'],
|
||||||
'fence_house_type' => $params['fence_house_type'],
|
'fence_house_type' => $params['fence_house_type'],
|
||||||
|
@ -82,6 +85,7 @@ class FenceHouseLogic extends BaseLogic
|
||||||
'master' => $params['master'],
|
'master' => $params['master'],
|
||||||
'status' => $params['status'],
|
'status' => $params['status'],
|
||||||
'qr_code' => $params['qr_code'],
|
'qr_code' => $params['qr_code'],
|
||||||
|
'image' => $params['image'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
|
@ -123,14 +127,14 @@ class FenceHouseLogic extends BaseLogic
|
||||||
public static function datas($params)
|
public static function datas($params)
|
||||||
{
|
{
|
||||||
$queryWhere = [];
|
$queryWhere = [];
|
||||||
if (!empty($params['fence_house_name'])) {
|
if (!empty($params['keyword'])) {
|
||||||
$queryWhere[] = ['fence_house_name', 'like', '%' . $params['fence_house_name'] . '%'];
|
$queryWhere[] = ['fence_house_name', 'like', '%' . $params['keyword'] . '%'];
|
||||||
}
|
}
|
||||||
if (!empty($params['user_id'])) {
|
if (!empty($params['user_id'])) {
|
||||||
$farmIds = Farm::where('user_id', $params['user_id'])->column('id');
|
$farmIds = Farm::where('user_id', $params['user_id'])->column('id');
|
||||||
$queryWhere[] = ['farm_id', 'in', $farmIds];
|
$queryWhere[] = ['farm_id', 'in', $farmIds];
|
||||||
}
|
}
|
||||||
$lists = Db::name('fence_house')->where($queryWhere)->order(['id' => 'desc'])->select()->toArray();
|
$lists = FenceHouse::where($queryWhere)->order(['id' => 'desc'])->select()->toArray();
|
||||||
foreach ($lists as &$item) {
|
foreach ($lists as &$item) {
|
||||||
$item['fencehouseinfo'] = 'ID:' . $item['id'] . ' / 名称:' . $item['fence_house_name'];
|
$item['fencehouseinfo'] = 'ID:' . $item['id'] . ' / 名称:' . $item['fence_house_name'];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue