更新后台系统
This commit is contained in:
parent
6f6ad628a4
commit
482908377d
|
@ -60,6 +60,16 @@
|
|||
:value="parseInt(item.value)"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="监测项" prop="monitor_item">
|
||||
<el-select class="flex-1" v-model="formData.monitor_item" multiple clearable placeholder="请选择设备监测项">
|
||||
<el-option
|
||||
v-for="(item, index) in dictData.monitor_item"
|
||||
:key="index"
|
||||
:label="item.name"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备状态" prop="status">
|
||||
<el-select class="flex-1" v-model="formData.status" clearable placeholder="请选择设备状态">
|
||||
|
@ -127,6 +137,7 @@ const formData = reactive({
|
|||
code: '',
|
||||
name: '',
|
||||
type: '',
|
||||
monitor_item: '',
|
||||
status: '',
|
||||
is_online: '',
|
||||
is_bind: '',
|
||||
|
@ -160,6 +171,11 @@ const formRules = reactive<any>({
|
|||
message: '请选择设备类型',
|
||||
trigger: ['blur']
|
||||
}],
|
||||
monitor_item: [{
|
||||
required: true,
|
||||
message: '请选择设备监测项',
|
||||
trigger: ['blur']
|
||||
}],
|
||||
status: [{
|
||||
required: true,
|
||||
message: '请选择设备状态',
|
||||
|
@ -186,6 +202,7 @@ const setFormData = async (data: Record<any, any>) => {
|
|||
formData[key] = data[key]
|
||||
}
|
||||
}
|
||||
console.log(dictData.monitor_item)
|
||||
}
|
||||
|
||||
interface ListItem {
|
||||
|
|
|
@ -226,7 +226,7 @@ const handleSelectionChange = (val: any[]) => {
|
|||
}
|
||||
|
||||
// 获取字典数据
|
||||
const { dictData } = useDictData('device_type,device_status,device_online_status,device_bind_status')
|
||||
const { dictData } = useDictData('device_type,device_status,device_online_status,device_bind_status,monitor_item')
|
||||
|
||||
// 分页相关
|
||||
const { pager, getLists, resetParams, resetPage } = usePaging({
|
||||
|
|
|
@ -93,7 +93,14 @@ class DeviceLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||
->field('d.*, u.account, pd.product_id, p.name as product_name, lp.land_id, l.title as land_title')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['d.id' => 'desc'])
|
||||
->select()
|
||||
->select()->each(function($item, $key){
|
||||
$monitorItemArray = [];
|
||||
if (!empty($item['monitor_item'])) {
|
||||
$monitorItemArray = explode(',', $item['monitor_item']);
|
||||
}
|
||||
$item['monitor_item'] = $monitorItemArray;
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,11 @@ class DeviceLogic extends BaseLogic
|
|||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
if (is_array($params['monitor_item'])) {
|
||||
$params['monitor_item'] = implode(',', $params['monitor_item']);
|
||||
} else {
|
||||
$params['monitor_item'] = trim($params['monitor_item']);
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$device = Device::create([
|
||||
|
@ -45,6 +50,7 @@ class DeviceLogic extends BaseLogic
|
|||
'code' => $params['code'],
|
||||
'name' => $params['name'],
|
||||
'type' => $params['type'],
|
||||
'monitor_item' => $params['monitor_item'],
|
||||
'status' => $params['status'],
|
||||
'is_online' => $params['is_online'],
|
||||
'is_bind' => $params['is_bind'],
|
||||
|
@ -75,6 +81,11 @@ class DeviceLogic extends BaseLogic
|
|||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
if (is_array($params['monitor_item'])) {
|
||||
$params['monitor_item'] = implode(',', $params['monitor_item']);
|
||||
} else {
|
||||
$params['monitor_item'] = trim($params['monitor_item']);
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$device = Device::where('id', $params['id'])->update([
|
||||
|
@ -82,6 +93,7 @@ class DeviceLogic extends BaseLogic
|
|||
'code' => $params['code'],
|
||||
'name' => $params['name'],
|
||||
'type' => $params['type'],
|
||||
'monitor_item' => $params['monitor_item'],
|
||||
'status' => $params['status'],
|
||||
'is_online' => $params['is_online'],
|
||||
'is_bind' => $params['is_bind'],
|
||||
|
|
Loading…
Reference in New Issue