From 685f965d5ae0acaa8547d159c52c55bb722172cd Mon Sep 17 00:00:00 2001
From: chenbo <709206448@qq.com>
Date: Thu, 18 Jan 2024 11:21:28 +0800
Subject: [PATCH] =?UTF-8?q?update=20=E6=A0=8F=E8=88=8D=E7=AE=A1=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
admin/src/views/fence_house/edit.vue | 94 ++++++++++-
admin/src/views/fence_house/index.vue | 8 +-
.../lists/fence_house/FenceHouseLists.php | 152 +++++++++---------
.../logic/fence_house/FenceHouseLogic.php | 10 +-
4 files changed, 177 insertions(+), 87 deletions(-)
diff --git a/admin/src/views/fence_house/edit.vue b/admin/src/views/fence_house/edit.vue
index d150794..f09f1aa 100644
--- a/admin/src/views/fence_house/edit.vue
+++ b/admin/src/views/fence_house/edit.vue
@@ -28,6 +28,9 @@
+
+
+
-
+
+
+
-
-
+
+
+
+
+
+
@@ -72,19 +103,37 @@ import Popup from '@/components/popup/index.vue'
import {apiFenceHouseAdd, apiFenceHouseEdit, apiFenceHouseDetail, apiFenceHouseLists, apiFarmLists} from '@/api/fence_house'
import { timeFormat } from '@/utils/util'
import type { PropType } from 'vue'
-import {useDictOptions} from "@/hooks/useDictOptions";
-import {ref} from "vue";
+import {useDictOptions} from "@/hooks/useDictOptions"
+import {ref} from "vue"
+import config from "@/config";
+import useUserStore from "@/stores/modules/user";
+import {ElMessage, type UploadProps} from "element-plus";
+
defineProps({
dictData: {
type: Object as PropType>,
default: () => ({})
}
})
+
const emit = defineEmits(['success', 'close'])
const formRef = shallowRef()
const popupRef = shallowRef>()
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(() => {
@@ -95,6 +144,7 @@ const popupTitle = computed(() => {
const formData = reactive({
id: '',
farm_id: '',
+ animal_name: '',
fence_house_name: '',
animal_type: '',
fence_house_type: '',
@@ -102,6 +152,7 @@ const formData = reactive({
master: '',
status: '',
qr_code: '',
+ image: '',
})
@@ -130,7 +181,6 @@ const queryFarm= async (query: string) => {
optionsData.farmList = farmList
loading.value = false
}
-console.log(optionsData)
// 获取详情
@@ -183,3 +233,35 @@ defineExpose({
getDetail
})
+
+
+
\ No newline at end of file
diff --git a/admin/src/views/fence_house/index.vue b/admin/src/views/fence_house/index.vue
index 5ed311c..e22fe9c 100644
--- a/admin/src/views/fence_house/index.vue
+++ b/admin/src/views/fence_house/index.vue
@@ -47,7 +47,11 @@
-
+
+
+
+
+
@@ -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({
diff --git a/app/adminapi/lists/fence_house/FenceHouseLists.php b/app/adminapi/lists/fence_house/FenceHouseLists.php
index 2b1aa5b..ba2fe09 100644
--- a/app/adminapi/lists/fence_house/FenceHouseLists.php
+++ b/app/adminapi/lists/fence_house/FenceHouseLists.php
@@ -1,77 +1,77 @@
- ['fence_house_name'],
- ];
- }
-
-
- /**
- * @notes 获取列表
- * @return array
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- * @author likeadmin
- * @date 2024/01/10 15:15
- */
- public function lists(): array
- {
- return FenceHouse::where($this->searchWhere)
- ->field(['id', 'farm_id', 'fence_house_name', 'animal_type', 'fence_house_type', 'capacity', 'master', 'status'])
- ->limit($this->limitOffset, $this->limitLength)
- ->order(['id' => 'desc'])
- ->select()
- ->toArray();
- }
-
-
- /**
- * @notes 获取数量
- * @return int
- * @author likeadmin
- * @date 2024/01/10 15:15
- */
- public function count(): int
- {
- return FenceHouse::where($this->searchWhere)->count();
- }
-
+ ['fence_house_name'],
+
+ ];
+ }
+
+
+ /**
+ * @notes 获取列表
+ * @return array
+ * @throws \think\db\exception\DataNotFoundException
+ * @throws \think\db\exception\DbException
+ * @throws \think\db\exception\ModelNotFoundException
+ * @author likeadmin
+ * @date 2024/01/10 15:15
+ */
+ public function lists(): array
+ {
+ return FenceHouse::where($this->searchWhere)
+ ->limit($this->limitOffset, $this->limitLength)
+ ->order(['id' => 'desc'])
+ ->select()
+ ->toArray();
+ }
+
+
+ /**
+ * @notes 获取数量
+ * @return int
+ * @author likeadmin
+ * @date 2024/01/10 15:15
+ */
+ public function count(): int
+ {
+ return FenceHouse::where($this->searchWhere)->count();
+ }
+
}
\ No newline at end of file
diff --git a/app/adminapi/logic/fence_house/FenceHouseLogic.php b/app/adminapi/logic/fence_house/FenceHouseLogic.php
index 95d4b9d..4940f5c 100644
--- a/app/adminapi/logic/fence_house/FenceHouseLogic.php
+++ b/app/adminapi/logic/fence_house/FenceHouseLogic.php
@@ -43,6 +43,7 @@ class FenceHouseLogic extends BaseLogic
try {
FenceHouse::create([
'farm_id' => $params['farm_id'],
+ 'animal_name' => $params['animal_name'],
'fence_house_name' => $params['fence_house_name'],
'animal_type' => $params['animal_type'],
'fence_house_type' => $params['fence_house_type'],
@@ -50,6 +51,7 @@ class FenceHouseLogic extends BaseLogic
'master' => $params['master'],
'status' => $params['status'],
'qr_code' => $params['qr_code'],
+ 'image' => $params['image'],
]);
Db::commit();
@@ -75,6 +77,7 @@ class FenceHouseLogic extends BaseLogic
try {
FenceHouse::where('id', $params['id'])->update([
'farm_id' => $params['farm_id'],
+ 'animal_name' => $params['animal_name'],
'fence_house_name' => $params['fence_house_name'],
'animal_type' => $params['animal_type'],
'fence_house_type' => $params['fence_house_type'],
@@ -82,6 +85,7 @@ class FenceHouseLogic extends BaseLogic
'master' => $params['master'],
'status' => $params['status'],
'qr_code' => $params['qr_code'],
+ 'image' => $params['image'],
]);
Db::commit();
@@ -123,14 +127,14 @@ class FenceHouseLogic extends BaseLogic
public static function datas($params)
{
$queryWhere = [];
- if (!empty($params['fence_house_name'])) {
- $queryWhere[] = ['fence_house_name', 'like', '%' . $params['fence_house_name'] . '%'];
+ if (!empty($params['keyword'])) {
+ $queryWhere[] = ['fence_house_name', 'like', '%' . $params['keyword'] . '%'];
}
if (!empty($params['user_id'])) {
$farmIds = Farm::where('user_id', $params['user_id'])->column('id');
$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) {
$item['fencehouseinfo'] = 'ID:' . $item['id'] . ' / 名称:' . $item['fence_house_name'];
}