更新细节
This commit is contained in:
parent
9cca6e0b99
commit
731f595db4
|
@ -17,7 +17,7 @@ export function apiProductLists(params: any) {
|
||||||
|
|
||||||
// 监测设备列表
|
// 监测设备列表
|
||||||
export function apiDeviceLists(params: any) {
|
export function apiDeviceLists(params: any) {
|
||||||
return request.get({ url: '/device.device/lists', params })
|
return request.get({ url: '/device.device/datas', params })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -101,10 +101,10 @@ const { optionsData } = useDictOptions<{
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
|
||||||
const queryProduct = async (land_id: string) => {
|
const queryProduct = async (query: string) => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
const productList = await apiProductLists({
|
const productList = await apiProductLists({
|
||||||
land_id: land_id ?? ''
|
name: query ?? ''
|
||||||
})
|
})
|
||||||
optionsData.product = productList
|
optionsData.product = productList
|
||||||
loading.value = false
|
loading.value = false
|
||||||
|
|
|
@ -32,10 +32,10 @@
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in deviceOptions"
|
v-for="(item, index) in optionsData.device"
|
||||||
:key="item.value"
|
:key="index"
|
||||||
:label="item.label"
|
:label="item.deviceinfo"
|
||||||
:value="item.value"
|
:value="item.id"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -45,6 +45,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup name="landEdit">
|
<script lang="ts" setup name="landEdit">
|
||||||
|
import { useDictOptions } from '@/hooks/useDictOptions'
|
||||||
import type { FormInstance } from 'element-plus'
|
import type { FormInstance } from 'element-plus'
|
||||||
import Popup from '@/components/popup/index.vue'
|
import Popup from '@/components/popup/index.vue'
|
||||||
import { apiProductBind, apiDeviceLists } from '@/api/product'
|
import { apiProductBind, apiDeviceLists } from '@/api/product'
|
||||||
|
@ -93,31 +94,23 @@ const setFormData = async (data: Record<any, any>) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ListItem {
|
const { optionsData } = useDictOptions<{
|
||||||
value: string
|
device: any[]
|
||||||
label: string
|
}>({
|
||||||
}
|
device: {
|
||||||
const deviceOptions = ref<ListItem[]>([])
|
api: apiDeviceLists
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
|
||||||
const queryDevice = async (query: string) => {
|
const queryDevice = async (query: string) => {
|
||||||
if (query) {
|
loading.value = true
|
||||||
loading.value = true
|
const deviceList = await apiDeviceLists({
|
||||||
const deviceList = await apiDeviceLists({
|
name: query ?? ''
|
||||||
name: query
|
})
|
||||||
})
|
optionsData.device = deviceList
|
||||||
loading.value = false
|
loading.value = false
|
||||||
if (deviceList.count > 0) {
|
|
||||||
deviceOptions.value = deviceList.lists.map((device: any) => {
|
|
||||||
return { value: `${device.id}`, label: `ID: ${device.id} / 名称: ${device.name}` }
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
deviceOptions.value = []
|
|
||||||
}
|
|
||||||
loading.value = false
|
|
||||||
} else {
|
|
||||||
deviceOptions.value = []
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 提交按钮
|
// 提交按钮
|
||||||
|
|
|
@ -84,7 +84,7 @@
|
||||||
<span>{{ row.create_time ? timeFormat(row.create_time, 'yyyy-mm-dd hh:MM:ss') : '' }}</span>
|
<span>{{ row.create_time ? timeFormat(row.create_time, 'yyyy-mm-dd hh:MM:ss') : '' }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" width="260" align="center" fixed="right">
|
<el-table-column label="操作" width="300" align="center" fixed="right">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-button
|
<el-button
|
||||||
v-perms="['land.product/edit']"
|
v-perms="['land.product/edit']"
|
||||||
|
@ -94,14 +94,14 @@
|
||||||
>
|
>
|
||||||
编辑
|
编辑
|
||||||
</el-button>
|
</el-button>
|
||||||
<!-- <el-button
|
<el-button
|
||||||
v-perms="['land.product/bind']"
|
v-perms="['land.product/bind']"
|
||||||
type="primary"
|
type="primary"
|
||||||
link
|
link
|
||||||
@click="handleBind(row)"
|
@click="handleBind(row)"
|
||||||
>
|
>
|
||||||
绑定设备
|
绑定设备
|
||||||
</el-button> -->
|
</el-button>
|
||||||
<el-button v-perms="['device.device/lists']" type="primary" link >
|
<el-button v-perms="['device.device/lists']" type="primary" link >
|
||||||
<router-link
|
<router-link
|
||||||
:to="{
|
:to="{
|
||||||
|
|
|
@ -42,6 +42,11 @@ class DeviceController extends BaseAdminController
|
||||||
return $this->dataLists(new DeviceLists());
|
return $this->dataLists(new DeviceLists());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function datas()
|
||||||
|
{
|
||||||
|
$datas = (new DeviceLogic())->datas(input(''));
|
||||||
|
return $this->success('', $datas);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notes 添加
|
* @notes 添加
|
||||||
|
|
|
@ -127,6 +127,38 @@ class DeviceLogic extends BaseLogic
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function datas($params): array
|
||||||
|
{
|
||||||
|
$userWhere['d.user_id'] = -1;
|
||||||
|
if (!empty($params['user_id'])) {
|
||||||
|
$userWhere['d.user_id'] = $params['user_id'];
|
||||||
|
}
|
||||||
|
if (!request()->adminInfo['root'] && request()->adminInfo['user_id']) {
|
||||||
|
$userWhere['d.user_id'] = request()->adminInfo['user_id'];
|
||||||
|
}
|
||||||
|
if (request()->adminInfo['root']) {
|
||||||
|
unset($userWhere['d.user_id']);
|
||||||
|
}
|
||||||
|
$queryWhere = [];
|
||||||
|
if (!empty($params['name'])) {
|
||||||
|
$queryWhere[] = ['d.name', 'like', '%' . $params['name'] . '%'];
|
||||||
|
}
|
||||||
|
$deviceIdArray = Db::name('product_device')->column('device_id');
|
||||||
|
$lists = Db::name('device')->alias('d')
|
||||||
|
->where($userWhere)->where($queryWhere)->whereNotIn('d.id', $deviceIdArray)
|
||||||
|
->leftJoin('product_device pd','pd.device_id = d.id')
|
||||||
|
->leftJoin('product p','p.id = pd.product_id')
|
||||||
|
->leftJoin('user u','u.id = p.user_id')
|
||||||
|
->field('d.*')
|
||||||
|
->limit(0, 100)
|
||||||
|
->order(['d.id' => 'desc'])
|
||||||
|
->select()->toArray();
|
||||||
|
foreach ($lists as &$item) {
|
||||||
|
$item['deviceinfo'] = 'ID:' . $item['id'] . ' / 名称:' . $item['name'];
|
||||||
|
}
|
||||||
|
return $lists;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notes 删除
|
* @notes 删除
|
||||||
|
|
|
@ -141,12 +141,12 @@ class ProductLogic extends BaseLogic
|
||||||
unset($userWhere['p.user_id']);
|
unset($userWhere['p.user_id']);
|
||||||
}
|
}
|
||||||
$queryWhere = [];
|
$queryWhere = [];
|
||||||
if (!empty($params['land_id'])) {
|
if (!empty($params['name'])) {
|
||||||
$queryWhere['l.id'] = $params['land_id'];
|
$queryWhere[] = ['p.name', 'like', '%' . $params['name'] . '%'];
|
||||||
}
|
}
|
||||||
$productIdArray = Db::name('land_product')->column('product_id');
|
$productIdArray = Db::name('land_product')->column('product_id');
|
||||||
$lists = Db::name('product')->alias('p')
|
$lists = Db::name('product')->alias('p')
|
||||||
->where($userWhere)->whereNotIn('p.id', $productIdArray)
|
->where($userWhere)->where($queryWhere)->whereNotIn('p.id', $productIdArray)
|
||||||
->leftJoin('user u','u.id = p.user_id')
|
->leftJoin('user u','u.id = p.user_id')
|
||||||
->field('p.*')
|
->field('p.*')
|
||||||
->limit(0, 100)
|
->limit(0, 100)
|
||||||
|
@ -188,9 +188,10 @@ class ProductLogic extends BaseLogic
|
||||||
|
|
||||||
public static function bind($params): bool
|
public static function bind($params): bool
|
||||||
{
|
{
|
||||||
|
$root = (request()->adminInfo)['root'];
|
||||||
$userId = (request()->adminInfo)['user_id'];
|
$userId = (request()->adminInfo)['user_id'];
|
||||||
if (!empty($params['id'])) {
|
if ($root && !empty($params['user_id'])) {
|
||||||
$userId = Db::name('product')->where('id', $params['id'])->value('user_id');
|
$userId = $params['user_id'];
|
||||||
}
|
}
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue