884 lines
25 KiB
Vue
884 lines
25 KiB
Vue
<template>
|
|
<view class="bg-page">
|
|
<u-navbar :isBack="showAppbar" :title="showAppbar?'设备管理':''" :background="background" :custom-back="goback"
|
|
:title-color="titleColor" :back-icon-color="titleColor">
|
|
<view class="nav_slot_right_box" slot="right">
|
|
<view v-auth="['endpoint.device.create']" class="custom_btn add_btn" @click="addBtn()">新增</view>
|
|
</view>
|
|
</u-navbar>
|
|
<view class="secreen-section">
|
|
<view class="search-box">
|
|
<view class="search-input-vh u-border" @click="screenShowFn()">
|
|
<view class="placeholder_text">筛选条件</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="content-box">
|
|
<u-swipe-action class="tb_swipe_list"
|
|
v-for="(item, index) in list"
|
|
:show="item.show" :index="index" :key="index"
|
|
@click="click"
|
|
@open="open"
|
|
:options="options"
|
|
>
|
|
|
|
<view class="tb_body" @click="showInfo(index)">
|
|
<view class="row_box">
|
|
<view class="text">类型:{{ item.type }}</view>
|
|
</view>
|
|
|
|
<view class="row_box">
|
|
<view class="text">设备编号:{{item.sn}}</view>
|
|
</view>
|
|
<view class="row_box">
|
|
<view class="text">基地:{{ item.base_name }}</view>
|
|
</view>
|
|
<view class="row_box">
|
|
<view class="text">监控点:{{ item.monitoring_point }}</view>
|
|
</view>
|
|
<view class="row_box">
|
|
<view class="text">状态:<u-tag :text="statusName[item.status]" size="mini"
|
|
:type="statusType[item.status]"/></view>
|
|
|
|
</view>
|
|
</view>
|
|
</u-swipe-action>
|
|
<u-loadmore :status="loading" margin-top="60"/>
|
|
</view>
|
|
<!-- 编辑 -->
|
|
<u-popup v-model="editShow" border-radius="28" width="92%" height="70%"
|
|
mode="center" :closeable="true" :mask-close-able="false" z-index="910">
|
|
<view class="popup-form-ubox">
|
|
<view class="top_box">
|
|
<view class="title" v-if="setInfo.id">编辑设备</view>
|
|
<view class="title" v-else>新增设备</view>
|
|
</view>
|
|
<scroll-view class="scroll-y" scroll-y="true">
|
|
<view class="form_edit" style="padding-left: 50rpx;">
|
|
<u-form>
|
|
<u-form-item label="ID" label-width="140" v-if="setInfo.id">
|
|
<view class="input_box bg_colorf8 pdlr12">
|
|
<u-input v-model="setInfo.id" :disabled="true" />
|
|
</view>
|
|
</u-form-item>
|
|
<u-form-item label="设备类型" label-width="140" :required='true'>
|
|
<view class="input_box">
|
|
<view class="u-select-list" @click="selectFn1()">
|
|
<view class="value u-line-2"
|
|
v-if="setInfo.type">{{setInfo.type_name}}</view>
|
|
<view class="placeholder" v-else>请选择设备类型</view>
|
|
<view class="right">
|
|
<u-icon name="arrow-right" color="#999" size="28"></u-icon>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</u-form-item>
|
|
<u-form-item label="排序" label-width="140" :required='true'>
|
|
<view class="input_box">
|
|
<u-input v-model="setInfo.sort" type="number" placeholder="请输入排序"/>
|
|
</view>
|
|
</u-form-item>
|
|
<u-form-item label="基地" label-width="140" :required='true'>
|
|
<view class="input_box">
|
|
<view class="u-select-list" @click="selectFn2()">
|
|
<view class="value u-line-2"
|
|
v-if="setInfo.base_name">{{setInfo.base_name}}</view>
|
|
<view class="placeholder" v-else>请选择基地</view>
|
|
<view class="right">
|
|
<u-icon name="arrow-right" color="#999" size="28"></u-icon>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</u-form-item>
|
|
<u-form-item label="设备编号" label-width="140" :required='true'>
|
|
<view class="input_box">
|
|
<u-input v-model="setInfo.sn" placeholder="请输入设备编号"/>
|
|
</view>
|
|
</u-form-item>
|
|
<u-form-item label="设备厂商" label-width="140" :required='true'>
|
|
|
|
<view class="input_box">
|
|
<view class="u-select-list" @click="selectFn3()">
|
|
<view class="value u-line-2"
|
|
v-if="setInfo.supplier_key">{{setInfo.supplier_name}}</view>
|
|
<view class="placeholder" v-else>请输入设备厂商</view>
|
|
<view class="right">
|
|
<u-icon name="arrow-right" color="#999" size="28"></u-icon>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</u-form-item>
|
|
<u-form-item label="项目" label-width="140" :required='true'>
|
|
<view class="input_box">
|
|
<view class="u-select-list" @click="selectFn4()">
|
|
<view class="value u-line-2"
|
|
v-if="setInfo.project_key">{{setInfo.project_name}}</view>
|
|
<view class="placeholder" v-else>请选择项目</view>
|
|
<view class="right">
|
|
<u-icon name="arrow-right" color="#999" size="28"></u-icon>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</u-form-item>
|
|
<u-form-item label="监控点" label-width="140" :required='true'>
|
|
<view class="input_box">
|
|
<u-input v-model="setInfo.monitoring_point" type="text" placeholder="请输入监控点"/>
|
|
</view>
|
|
</u-form-item>
|
|
<!-- 监控设备字段 -->
|
|
<template v-if="setInfo.type==1">
|
|
<u-form-item label="设备IP" label-width="140" :required='false'>
|
|
<view class="input_box">
|
|
<u-input v-model="extendConf.ip" type="text" placeholder="请输入设备IP"/>
|
|
</view>
|
|
</u-form-item>
|
|
<u-form-item label="设备端口" label-width="140" :required='false'>
|
|
<view class="input_box">
|
|
<u-input v-model="extendConf.port" type="text" placeholder="请输入设备端口"/>
|
|
</view>
|
|
</u-form-item>
|
|
<u-form-item label="RTSP地址" label-width="140" :required='false'>
|
|
<view class="input_box">
|
|
<u-input v-model="extendConf.rtsp_url" type="text" placeholder="请输入RTSP地址"/>
|
|
</view>
|
|
</u-form-item>
|
|
<u-form-item label="设备登录名" label-width="160" :required='false'>
|
|
<view class="input_box">
|
|
<u-input v-model="extendConf.username" type="text" autocomplete="off" placeholder="请输入设备登录名"/>
|
|
</view>
|
|
</u-form-item>
|
|
<u-form-item label="设备登录密码" label-width="180" :required='false'>
|
|
<view class="input_box">
|
|
<u-input v-model="extendConf.password" type="password" autocomplete="off" placeholder="请输入设备登录密码"/>
|
|
</view>
|
|
</u-form-item>
|
|
<u-form-item label="设备播放通道" label-width="180" :required='false'>
|
|
<view class="input_box">
|
|
<u-input v-model="extendConf.passage" type="text" placeholder="请输入设备播放通道"/>
|
|
</view>
|
|
</u-form-item>
|
|
</template>
|
|
</u-form>
|
|
|
|
</view>
|
|
</scroll-view>
|
|
<view class="buttom_section">
|
|
<u-button class="btn" type="default" @click="editShow = false">取消</u-button>
|
|
<u-button class="btn" @click="editInfoBtn()" type="primary">确定</u-button>
|
|
</view>
|
|
</view>
|
|
</u-popup>
|
|
<u-popup v-model="popupShow" mode="bottom" border-radius="28" z-index="900">
|
|
<view class="popup-form-info">
|
|
<view class="top_box u-border-bottom">
|
|
<view class="handle-btns">
|
|
<view class="btn_del" v-auth="['endpoint.device.destroy']" @click="deleteInfoId(formInfo.id)">删除</view>
|
|
<view class="btn_edit" v-auth="['endpoint.device.edit']" @click="editInfoId(formInfo.id)">编辑</view>
|
|
</view>
|
|
</view>
|
|
<view class="section_c">
|
|
|
|
<view class="plist u-border-bottom">
|
|
<view class="label_t">类型</view>
|
|
<view class="flex-1">{{formInfo.type}}</view>
|
|
</view>
|
|
<view class="plist u-border-bottom">
|
|
<view class="label_t">排序</view>
|
|
<view class="flex-1">{{formInfo.sort}}</view>
|
|
</view>
|
|
<view class="plist u-border-bottom">
|
|
<view class="label_t">设备编号</view>
|
|
<view class="flex-1">{{formInfo.sn}}</view>
|
|
</view>
|
|
<view class="plist u-border-bottom">
|
|
<view class="label_t">基地</view>
|
|
<view class="flex-1">{{formInfo.base_name}}</view>
|
|
</view>
|
|
<view class="plist u-border-bottom">
|
|
<view class="label_t">监控点</view>
|
|
<view class="flex-1">{{formInfo.monitoring_point}}</view>
|
|
</view>
|
|
<view class="plist u-border-bottom">
|
|
<view class="label_t">设备厂商</view>
|
|
<view class="flex-1">{{formInfo.supplier?formInfo.supplier.name:'-'}}</view>
|
|
</view>
|
|
<view class="plist u-border-bottom">
|
|
<view class="label_t">设备项目</view>
|
|
<view class="flex-1">{{formInfo.project?formInfo.project.name:'-'}}</view>
|
|
</view>
|
|
<view class="plist u-border-bottom">
|
|
<view class="label_t">状态</view>
|
|
<view class="flex-1">
|
|
<u-tag :text="statusName[formInfo.status]" size="mini"
|
|
:type="statusType[formInfo.status]"/>
|
|
</view>
|
|
</view>
|
|
|
|
</view>
|
|
</view>
|
|
</u-popup>
|
|
<u-select v-model="selectShow1" :list="deviceTypes"
|
|
:default-value="selectValue1" mode="single-column"
|
|
@confirm="uselectConfirm1"></u-select>
|
|
|
|
<u-select v-model="selectShow2" :list="basicList"
|
|
:default-value="selectValue2" mode="single-column"
|
|
@confirm="uselectConfirm2"></u-select>
|
|
|
|
<u-select v-model="selectShow3" :list="supplierlist"
|
|
:default-value="selectValue3" mode="single-column"
|
|
@confirm="uselectConfirm3"></u-select>
|
|
|
|
<u-select v-model="selectShow4" :list="projectlist"
|
|
:default-value="selectValue4" mode="single-column"
|
|
@confirm="uselectConfirm4"></u-select>
|
|
|
|
<u-select v-model="selectShow5" :list="statuslist"
|
|
:default-value="selectValue5" mode="single-column"
|
|
@confirm="uselectConfirm5"></u-select>
|
|
<!-- 筛选查询条件 -->
|
|
<u-popup v-model="screenShow" mode="top" z-index="9">
|
|
<view class="popup-screen-groups">
|
|
<view class="status_bar_top"></view>
|
|
<scroll-view class="scroll-y" scroll-y="true">
|
|
<view class="row_ul u-padding-right-20">
|
|
<view class="row_list u-flex">
|
|
<view class="label_tit">基地</view>
|
|
<yn-select-input-list :value="queryCond.base_name"
|
|
@click="selectFn2('q')"></yn-select-input-list>
|
|
</view>
|
|
<view class="row_list u-flex">
|
|
<view class="label_tit">类型</view>
|
|
<yn-select-input-list :value="queryCond.type_name"
|
|
@click="selectFn1('q')"></yn-select-input-list>
|
|
</view>
|
|
<view class="row_list u-flex">
|
|
<view class="label_tit">状态</view>
|
|
<yn-select-input-list :value="queryCond.status_name"
|
|
@click="selectFn5('q')"></yn-select-input-list>
|
|
</view>
|
|
<view class="row_list u-flex">
|
|
<view class="label_tit">监控点</view>
|
|
<u-input type="text" :border="true" />
|
|
</view>
|
|
<view class="row_list u-flex">
|
|
<view class="label_tit">设备编号</view>
|
|
<u-input type="text" :border="true" />
|
|
</view>
|
|
<view class="row_list u-flex">
|
|
<view class="label_tit">设备厂商</view>
|
|
<yn-select-input-list :value="queryCond.supplier_name"
|
|
@click="selectFn3('q')"></yn-select-input-list>
|
|
</view>
|
|
<view class="row_list u-flex">
|
|
<view class="label_tit">项目</view>
|
|
<yn-select-input-list :value="queryCond.project_name"
|
|
@click="selectFn4('q')"></yn-select-input-list>
|
|
</view>
|
|
</view>
|
|
</scroll-view>
|
|
<view class="buttom_section u-padding-top-40">
|
|
<u-button class="btn small_btn" type="default" @click="resetQuery()">重置</u-button>
|
|
<u-button class="btn small_btn" @click="queryBtn()" type="primary">查询</u-button>
|
|
</view>
|
|
</view>
|
|
</u-popup>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import {navigateBack} from '@/com/utils.js'
|
|
import checkPermission from '@/utils/permission.js'
|
|
export default {
|
|
data() {
|
|
return {
|
|
background: {
|
|
backgroundColor:'#2a7dc9',
|
|
},
|
|
titleColor:"#ffffff",
|
|
per_page:10,
|
|
page:1,
|
|
list:[],
|
|
loading:'loadmore',
|
|
popupShow:false,
|
|
cindex:-1,//操作的索引
|
|
editShow:false,
|
|
formInfo:{},
|
|
setInfo:{
|
|
id:'',
|
|
type:'',
|
|
type_name:'',
|
|
sort:'',
|
|
base_name:'',
|
|
agricultural_base_id:'',//基地id
|
|
sn:'',
|
|
supplier:'',
|
|
supplier_key:'',//厂商k
|
|
supplier_name:'',
|
|
project:'',
|
|
project_key:'',//项目k
|
|
project_name:'',
|
|
monitoring_point:'',
|
|
},
|
|
dropDownShow:false,
|
|
supplierlist:[
|
|
{
|
|
label: '其它',
|
|
value: 'device-supplier-other',
|
|
},
|
|
{
|
|
label: '慧联无限',
|
|
value: 'device-supplier-linkos',
|
|
},
|
|
{
|
|
label: '比昂',
|
|
value: 'device-supplier-biang',
|
|
},
|
|
{
|
|
label: '云飞',
|
|
value: 'device-supplier-yunfei',
|
|
},
|
|
],
|
|
selectShow:false,
|
|
select1Value:[],
|
|
// 状态: 0 禁用, 1 在线, 2 离线, 3 故障
|
|
statusType:['error','success ','info','warning '],
|
|
statusName:['禁用','在线','离线','故障'],
|
|
statuslist:[
|
|
{
|
|
value: 0,
|
|
|
|
label: '禁用',
|
|
},
|
|
{
|
|
value: 1,
|
|
label: '在线',
|
|
},
|
|
{
|
|
value: 2,
|
|
label: '离线',
|
|
},
|
|
{
|
|
value: 3,
|
|
label: '故障',
|
|
},
|
|
],
|
|
deviceTypes:[],//设备类型
|
|
selectShow1:false,
|
|
basicList:[],
|
|
selectShow2:false,
|
|
selectShow3:false,//厂商
|
|
selectShow4:false,//项目
|
|
selectShow5:false,
|
|
projectlist:[
|
|
{
|
|
value: 'device-project-cyxdnyyq',
|
|
label: '成渝现代高效特色农业带合作园区',
|
|
},
|
|
{
|
|
value: 'device-project-nyncj',
|
|
label: '隆昌市农业农村局',
|
|
},
|
|
{
|
|
value: 'device-project-syqshc',
|
|
label: '隆昌市石燕桥镇三合村股份经济联合社',
|
|
},
|
|
{
|
|
value: 'device-project-other',
|
|
label: '其它',
|
|
},
|
|
],
|
|
selectValue1:[0],
|
|
selectValue2:[0],
|
|
selectValue3:[0],
|
|
selectValue4:[0],
|
|
selectValue5:[0],
|
|
screenShow:false,
|
|
queryCond:{
|
|
base:'',
|
|
base_name:'',
|
|
type:'',
|
|
type_name:'',
|
|
status:'',
|
|
status_name:'',
|
|
point:'',
|
|
sn:'',
|
|
supplier_key:'',
|
|
supplier_name:'',
|
|
project_key:'',
|
|
project_name:''
|
|
},
|
|
isqueryselect:false,
|
|
//监控设备设备配置
|
|
extendConf:{
|
|
ip:'',
|
|
passage:'',//设备播放通道
|
|
password:'',
|
|
port:'',
|
|
rtsp_url:'',
|
|
username:'',//登录名
|
|
}
|
|
};
|
|
},
|
|
computed: {
|
|
options() {
|
|
return [
|
|
{
|
|
text: '编辑',
|
|
opt: 'edit',
|
|
permission: ['endpoint.device.edit'],
|
|
style: {
|
|
backgroundColor: '#007aff',
|
|
},
|
|
},
|
|
{
|
|
text: '删除',
|
|
opt: 'delete',
|
|
permission: ['endpoint.device.destroy'],
|
|
style: {
|
|
backgroundColor: '#dd524d',
|
|
},
|
|
},
|
|
].filter((e) => checkPermission(e.permission))
|
|
},
|
|
},
|
|
onLoad() {
|
|
this.queryDataList();
|
|
this.getDeviceTypes();
|
|
this.getAgriculturalBasic();
|
|
},
|
|
methods: {
|
|
queryBtn(){
|
|
this.list = [];
|
|
this.queryDataList(true);
|
|
this.screenShow = false;
|
|
},
|
|
screenShowFn(){
|
|
this.screenShow = true;
|
|
},
|
|
selectFn1(type){
|
|
this.isqueryselect = false;
|
|
let type_name = this.setInfo.type_name;
|
|
if(type=='q'){
|
|
this.isqueryselect = true;
|
|
type_name = this.queryCond.type_name;
|
|
}
|
|
for(let [index,item] of this.deviceTypes.entries()){
|
|
if(type_name==item.label){
|
|
this.selectValue1 = [index];
|
|
this.setInfo.type = item.value;
|
|
break;
|
|
}
|
|
}
|
|
this.selectShow1 = true;
|
|
},
|
|
selectFn2(type){
|
|
this.isqueryselect = false;
|
|
let base_id = this.setInfo.agricultural_base_id;
|
|
if(type=='q'){
|
|
this.isqueryselect = true;
|
|
base_id = this.queryCond.base;
|
|
}
|
|
for(let [index,item] of this.basicList.entries()){
|
|
if(base_id==item.value){
|
|
this.selectValue = [index];
|
|
break;
|
|
}
|
|
}
|
|
this.selectShow2 = true;
|
|
},
|
|
selectFn3(type){
|
|
this.isqueryselect = false;
|
|
let supplier_key = this.setInfo.supplier_key;
|
|
if(type=='q'){
|
|
this.isqueryselect = true;
|
|
supplier_key = this.queryCond.supplier_key;
|
|
}
|
|
for(let [index,item] of this.supplierlist.entries()){
|
|
if(supplier_key==item.value){
|
|
this.selectValue3 = [index];
|
|
break;
|
|
}
|
|
}
|
|
this.selectShow3 = true;
|
|
},
|
|
selectFn4(type){
|
|
this.isqueryselect = false;
|
|
let project_key = this.setInfo.project_key;
|
|
if(type=='q'){
|
|
this.isqueryselect = true;
|
|
project_key = this.queryCond.supplier_key;
|
|
}
|
|
for(let [index,item] of this.projectlist.entries()){
|
|
if(project_key==item.value){
|
|
this.selectValue4 = [index];
|
|
break;
|
|
}
|
|
}
|
|
this.selectShow4 = true;
|
|
},
|
|
selectFn5(type){
|
|
this.isqueryselect = false;
|
|
let status = this.queryCond.status;
|
|
if(type=='q'){
|
|
this.isqueryselect = true;
|
|
}
|
|
for(let [index,item] of this.statuslist.entries()){
|
|
if(status==item.value){
|
|
this.selectValue5 = [index];
|
|
break;
|
|
}
|
|
}
|
|
this.selectShow5 = true;
|
|
},
|
|
uselectConfirm1(e){
|
|
console.log(e)
|
|
if(this.isqueryselect){
|
|
this.queryCond.type = e[0].value;
|
|
this.queryCond.type_name = e[0].label;
|
|
}else{
|
|
this.setInfo.type = e[0].value;
|
|
this.setInfo.type_name = e[0].label;
|
|
}
|
|
},
|
|
uselectConfirm2(e){
|
|
if(this.isqueryselect){
|
|
this.queryCond.base = e[0].value;
|
|
this.queryCond.base_name = e[0].label;
|
|
}else{
|
|
this.setInfo.agricultural_base_id = e[0].value;
|
|
this.setInfo.base_name = e[0].label;
|
|
}
|
|
|
|
},
|
|
uselectConfirm3(e){
|
|
if(this.isqueryselect){
|
|
this.queryCond.supplier_key = e[0].value;
|
|
this.queryCond.supplier_name = e[0].label;
|
|
}else{
|
|
this.setInfo.supplier_key = e[0].value;
|
|
this.setInfo.supplier_name = e[0].label;
|
|
}
|
|
},
|
|
uselectConfirm4(e){
|
|
if(this.isqueryselect){
|
|
this.queryCond.project_key = e[0].value;
|
|
this.queryCond.project_name = e[0].label;
|
|
}else{
|
|
this.setInfo.project_key = e[0].value;
|
|
this.setInfo.project_name = e[0].label;
|
|
}
|
|
},
|
|
uselectConfirm5(e){
|
|
if(this.isqueryselect){
|
|
this.queryCond.status = e[0].value;
|
|
this.queryCond.status_name = e[0].label;
|
|
}else{
|
|
|
|
}
|
|
},
|
|
dropdownClose(){
|
|
this.dropDownShow= false;
|
|
},
|
|
openDropDown(index){
|
|
this.dropDownShow= true;
|
|
|
|
},
|
|
typePopupShow(){
|
|
// this.select2 = true;
|
|
},
|
|
addBtn(){
|
|
this.setInfoKeys('add');
|
|
this.editShow = true;
|
|
},
|
|
showInfo(index){
|
|
this.cindex = index;
|
|
let _id = this.list[index].id;
|
|
this.queryInfo(_id);
|
|
this.formInfo = this.list[index];
|
|
this.popupShow = true;
|
|
|
|
},
|
|
open(index){
|
|
this.list[index].show = true;
|
|
},
|
|
click(index, index1) {
|
|
console.log(index,index1,this.list[index])
|
|
if(index1 == 1) {
|
|
this.cindex = index;
|
|
let _id = this.list[index].id;
|
|
this.deleteInfoId(_id);
|
|
} else {//编辑
|
|
let _id = this.list[index].id;
|
|
this.queryInfo(_id);
|
|
this.formInfo = this.list[index];
|
|
this.setInfoKeys();
|
|
this.editShow = true;
|
|
this.list[index].show = false;
|
|
|
|
}
|
|
|
|
},
|
|
queryDataList(refresh){
|
|
if(refresh){
|
|
this.loading = 'loadmore';
|
|
this.page = 1;
|
|
}
|
|
if(this.loading=='nomore'){//超出最大页
|
|
return false;
|
|
}
|
|
let params = {
|
|
per_page:this.per_page,
|
|
page: this.page ++,
|
|
_t: new Date().getTime()
|
|
}
|
|
for(let k in this.queryCond){
|
|
if(this.queryCond[k]||this.queryCond[k]=='0'){
|
|
params[k] = this.queryCond[k];
|
|
}
|
|
}
|
|
|
|
this.loading = 'loading';
|
|
this.$http.get('/api/devices',{params:params}).then(({data})=>{
|
|
console.log(data)
|
|
this.screenShow = false;
|
|
if(refresh){
|
|
this.list = [];
|
|
}
|
|
this.loading = 'loadmore';
|
|
if(data.code==200){
|
|
let _list = data.data|| [];
|
|
for(let item of _list){
|
|
item.show = false;
|
|
}
|
|
this.list = this.list.concat(_list);
|
|
console.log(this.list);
|
|
if(this.list.length>= data.meta.total){
|
|
this.loading ='nomore';
|
|
}
|
|
}
|
|
}).catch(()=>{
|
|
this.loading = 'loadmore';
|
|
this.screenShow = false;
|
|
})
|
|
},
|
|
//修改
|
|
editInfoBtn(){
|
|
let {id,agricultural_base_id,sort,monitoring_point,
|
|
project_key,sn,type,supplier_key} = this.setInfo;
|
|
let params = {
|
|
agricultural_base_id:agricultural_base_id,
|
|
sort:sort,
|
|
monitoring_point:monitoring_point,
|
|
project_key:project_key,
|
|
sn:sn,
|
|
type:type,
|
|
supplier_key:supplier_key,
|
|
}
|
|
if(id){params['id'] = id;}
|
|
if(type==1){//监控
|
|
params['extends'] = this.extendConf;
|
|
}
|
|
if(params['id']){
|
|
this.$http.put(`/api/devices/${id}`,params).then(({data})=>{
|
|
if(data.code==200){
|
|
|
|
this.editShow = false;
|
|
this.queryDataList(true);
|
|
|
|
}
|
|
uni.showToast({ title: data.message, icon: 'none' });
|
|
}).catch(()=>{
|
|
|
|
})
|
|
}else{
|
|
this.$http.post(`/api/devices`,params).then(({data})=>{
|
|
if(data.code==200){
|
|
this.queryDataList(true);
|
|
this.editShow = false;
|
|
uni.showToast({ title: data.message, icon: 'none' });
|
|
}else{
|
|
uni.showToast({ title: data.message, icon: 'none' });
|
|
}
|
|
}).catch(()=>{
|
|
|
|
})
|
|
}
|
|
|
|
},
|
|
editInfoId(id){
|
|
// this.queryInfo(id);
|
|
|
|
this.setInfoKeys();
|
|
this.editShow = true;
|
|
this.popupShow = false;
|
|
},
|
|
setInfoKeys(type){
|
|
let info = {
|
|
id:'',
|
|
type:'',
|
|
type_name:'',
|
|
sort:'',
|
|
base_name:'',
|
|
agricultural_base_id:'',//基地id
|
|
sn:'',
|
|
supplier:'',
|
|
supplier_key:'',//厂商k
|
|
supplier_name:'',
|
|
project:'',
|
|
project_key:'',//项目k
|
|
project_name:'',
|
|
monitoring_point:'',
|
|
}
|
|
if(type=='add'){
|
|
this.setInfo = info;
|
|
}else{
|
|
let {id,type,sort,base_id,base_name,sn,supplier,project,
|
|
monitoring_point} = this.formInfo;
|
|
try{
|
|
for(let item of this.deviceTypes){
|
|
if(type == item.label){
|
|
info.type = item.value;
|
|
break;
|
|
}
|
|
}
|
|
info['id'] = id;
|
|
info['type_name'] = type;
|
|
info['sort'] = sort;
|
|
info['base_name'] = base_name;
|
|
info['agricultural_base_id'] = base_id;
|
|
info['sn'] = sn;
|
|
info['supplier_key'] = supplier?supplier.id:'';
|
|
info['supplier_name'] = supplier?supplier.name:'';
|
|
info['project_key'] = project?project.id:'';
|
|
info['project_name'] = project?project.name:'';
|
|
info['monitoring_point'] = monitoring_point;
|
|
this.setInfo = info;
|
|
if(this.formInfo.extends){
|
|
this.extendConf = this.formInfo.extends;
|
|
}
|
|
}catch(e){
|
|
//TODO handle the exception
|
|
uni.showToast({ title: '数据错误', icon: 'none' })
|
|
}
|
|
}
|
|
},
|
|
//删除deleteInfoId
|
|
deleteInfoId(id){
|
|
uni.showModal({
|
|
title: '提示',
|
|
content: '是否确定删除?',
|
|
success: (res)=> {
|
|
if (res.confirm) {
|
|
console.log('用户点击确定');
|
|
this.$http.delete(`/api/devices/${id}`).then(({data})=>{
|
|
if(data.code==200){
|
|
this.formInfo = {};//重置删除
|
|
this.popupShow = false;
|
|
// this.list.splice(this.cindex,1);
|
|
this.queryDataList(true);
|
|
|
|
}
|
|
uni.showToast({ title: data.message, icon: 'none' });
|
|
}).catch(()=>{
|
|
|
|
})
|
|
} else if (res.cancel) {
|
|
console.log('用户点击取消');
|
|
}
|
|
}
|
|
});
|
|
|
|
},
|
|
queryInfo(id){
|
|
this.$http.get(`/api/devices/${id}`).then(({data})=>{
|
|
console.log(data,'queryInfo===')
|
|
if(data.code==200){
|
|
this.formInfo = data.data;
|
|
this.setInfoKeys();
|
|
}
|
|
}).catch((err)=>{
|
|
|
|
})
|
|
},
|
|
//设备类型
|
|
getDeviceTypes(){
|
|
this.$http.get(`/api/device-types`).then(({data})=>{
|
|
if(data.code==200){
|
|
let _data = data.data;
|
|
console.log(_data,'===============ss')
|
|
let list = [];
|
|
for(let k in _data){
|
|
let option = {
|
|
value: k,
|
|
label: _data[k],
|
|
}
|
|
list.push(option)
|
|
}
|
|
console.log(list,'===============ss')
|
|
this.deviceTypes = list;
|
|
|
|
}
|
|
}).catch((err)=>{
|
|
|
|
})
|
|
},
|
|
//基地数据
|
|
getAgriculturalBasic(){
|
|
const params = { type: 1, per_page: 9999, page: 1 }
|
|
this.$http.get(`/api/agricultural-basic`,{params:params}).then(({data})=>{
|
|
if(data.code==200){
|
|
let _data = data.data;
|
|
|
|
let list = [];
|
|
for(let item of _data){
|
|
let option = {
|
|
value: item.id,
|
|
label: item.name,
|
|
}
|
|
list.push(option)
|
|
}
|
|
console.log(list,'===============ss')
|
|
this.basicList = list;
|
|
|
|
}
|
|
}).catch((err)=>{
|
|
|
|
})
|
|
},
|
|
resetQuery(){
|
|
this.queryCond = {
|
|
base:'',
|
|
base_name:'',
|
|
type:'',
|
|
type_name:'',
|
|
status:'',
|
|
status_name:'',
|
|
point:'',
|
|
sn:'',
|
|
supplier_key:'',
|
|
supplier_name:'',
|
|
project_key:'',
|
|
project_name:''
|
|
}
|
|
},
|
|
goback(){
|
|
navigateBack()
|
|
}
|
|
},
|
|
//触底加载
|
|
onReachBottom() {
|
|
if(this.loading=='loadmore'){
|
|
this.queryDataList();
|
|
}
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.content-box{
|
|
padding: 30rpx;
|
|
}
|
|
|
|
</style>
|