123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486 |
- <template>
- <view class="appWrapper padding-top" style="height:calc(100vh - 250rpx);overflow:scroll">
- <form action="" class="funcAdd">
- <view class="form-item selectBox">
- <view class="title"><text class="necessary">*</text>报备类型:</view>
-
-
- <uni-data-select v-model="report_type" :localdata="skillsRange" >
- </uni-data-select>
-
-
- <!--
- <select name="" id="" placeholder="请选择" clearable v-model="report_type">
- <option value="">请选择</option>
- <option value="1">单位</option>
- <option value="2">类型</option>
- <option value="3">设备</option>
- </select> -->
- </view>
- <view class="form-item selectBox" v-if="report_type==2||report_type==3">
- <view class="title"><text class="necessary">*</text>设备类型:</view>
-
- <uni-data-select v-model="device_type" :localdata="deviceRange" >
- </uni-data-select>
-
-
- <!-- <select name="" id="" placeholder=""clearable v-model="device_type">
- <option value="">请选择</option>
- <option value="1">火系统</option>
- <option value="2">水系统</option>
- <option value="3">烟感系统</option>
- <option value="4">消防栓</option>
- <option value="5">液位</option>
- <option value="6">RTU</option>
- <option value="7">电气火灾</option>
- <option value="16">视频监控</option>
- <option value="128">井盖</option>
- <option value="131">可燃气体</option>
- <option value="130">门禁监测</option>
- <option value="129">地磁监测</option>
- <option value="17">电梯监测</option>
- </select> -->
- </view>
-
- <view class="form-item" v-if="report_type">
- <view class="title">
- <text class="necessary">*</text>
- 开始时间:
- </view>
- <view class="example-body">
- <uni-datetime-picker v-model="start_time" :start="this.id?'':now"/>
- </view>
- </view>
- <view class="form-item" v-if="report_type">
- <view class="title">
- <text class="necessary">*</text>
- 结束时间:
- </view>
- <view class="example-body">
- <uni-datetime-picker v-model="end_time" :start="start_time" />
- </view>
- </view>
-
-
-
- <view class="form-item " v-if="report_type==3&&device_type==6">
- <view class="title"><text class="necessary">*</text>端口号:</view>
- <input name="input" v-model="device_port"></input>
- </view>
-
- <view class="form-item selectBox" v-if="report_type==3&&device_type==6">
- <view class="title"><text class="necessary">*</text>端口类型:</view>
- <!-- <select name="" id="" placeholder=""clearable v-model="port_type">
- <option value="">请选择</option>
- <option value="1">数字量</option>
- <option value="2">模拟量</option>
- </select> -->
- <uni-data-select v-model="port_type" :localdata="portRange" >
- </uni-data-select>
-
- <!-- <text class="icon iconfont margin-right-sm margin-left"></text> -->
- </view>
-
- <view class="form-item selectBox" v-if="report_type==3&&device_type">
- <view class="title"><text class="necessary">*</text>报备设备:</view>
- <!-- <select name="" id="" placeholder=""clearable v-model="device_code">
- <option value="">请选择</option>
- <option :value="item.owner_code" v-for="(item,index) in deviceListData" :key="index">{{item.owner_name}}
- </option>
-
- </select> -->
-
- <uni-data-select v-model="device_code" :localdata="deviceListData" >
- </uni-data-select>
-
-
- <!-- <text class="icon iconfont margin-right-sm margin-left"></text> -->
- </view>
-
- <view class="form-item " v-if="report_type">
- <view class="title"><text class="necessary"></text>备注:</view>
- <input name="input" v-model="remarks"></input>
- </view>
-
- <view class="btn-area submitBottomBtn padding-lr-sm">
- <button class="bg-blue round margin-top" @tap="submit()">提 交 </button>
- </view>
- </form>
- </view>
- </template>
- <style scoped>
- /deep/ .funcAdd .uni-date-x--border, .uni-date-x{
- border-radius:0!important
- }
- .funcAdd .example-body{
- margin:0;
- width:calc(100% - 200rpx)
- }
- </style>
- <script>
- export default {
- data() {
- return {
-
- skillsRange: [{
- value: 1,
- text: "单位"
- },
- {
- value: 2,
- text: "类型"
- },
- {
- value: 3,
- text: "设备"
- },
- ],
- deviceRange:[{
- value: 1,
- text: "火系统"
- },
- {
- value: 2,
- text: "水系统"
- },
- {
- value: 3,
- text: "烟感系统"
- },{
- value: 4,
- text: "消防栓"
- },
- {
- value: 5,
- text: "液位"
- },
- {
- value: 6,
- text: "RTU"
- },{
- value: 7,
- text: "电气火灾"
- },
- {
- value: 16,
- text: "视频监控"
- },
- {
- value: 128,
- text: "井盖"
- },{
- value: 131,
- text: "可燃气体"
- },
- {
- value: 130,
- text: "门禁监测"
- },
- {
- value: 129,
- text: "地磁监测"
- },{
- value:17,
- text: "电梯监测"
- },],
-
-
- portRange: [{
- value: 1,
- text: "数字量"
- },
- {
- value: 2,
- text: "模拟量"
- },
-
- ],
-
- id:'',
- report_type:'',
- device_type:'',
- start_time:'',
- end_time:'',
- remarks:'',
- device_port:'',
- port_type:'',
- device_code:'',
- now:'',
-
- deviceListData:[],
- detailsData:''
-
- }
- },
- onLoad: function(option) {
-
- this.id=option.id;
- uni.setNavigationBarTitle({
- title: option.id?"编辑":"新增",
- });
-
-
-
- var nowTemp = new Date();
- this.now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
-
- if(option.id){
- this.getDetailsData({'id':option.id})
-
- }
-
-
- },
- watch: {
- start_time:function(){
- // alert(this.start_time)
- },
- report_type:function(newVal){
- if(newVal){
- var array123=['','1','2','3','4','5','6','7','16','128','131','130','129','17']
- if(array123.indexOf(this.device_type)==-1){
- this.device_type=''
- }
- }
- },
- device_type:function(newVal){
- if(newVal){
- this.deviceList({'company_code':uni.getStorageSync('selectedCode'),'device_type' :this.device_type });
- }
- }
-
- },
- methods: {
-
- // 回显信息请求
- async getDetailsData(params = {}) {
- const res = await this.$myRequest({
- url: 'AlarmReport/editData',
- data:params,
- showLoading: true
- })
-
- this.detailsData=res.data.data[0];
- this.report_type=parseInt(this.detailsData.report_type);
- this.device_type=parseInt(this.detailsData.device_type);
- this.start_time=this.detailsData.start_time;
- this.end_time=this.detailsData.end_time;
- this.remarks=this.detailsData.remarks;
- this.port_type=parseInt(this.detailsData.port_type);
- this.device_port=this.detailsData.device_port;
- this.device_code=parseInt(this.detailsData.device_code);
- },
- async submit() {
-
- //提交验证
-
- if (!this.report_type) {
- uni.showToast({
- title: "请输入报备类型",
- icon: "none"
- });
- return
- }
- if(this.report_type==1){
- if (!this.start_time.replace(/^\s*/g,'')) {
- uni.showToast({
- title: "请选择开始时间",
- icon: "none"
- });
- return
- }
- if (!this.end_time.replace(/^\s*/g,'')) {
- uni.showToast({
- title: "请选择结束时间",
- icon: "none"
- });
- return
- }
- }
- if(this.report_type==2||this.report_type==3){
- if (!this.device_type) {
- uni.showToast({
- title: "请选择设备类型",
- icon: "none"
- });
- return
- }
- if (!this.start_time.replace(/^\s*/g,'')) {
- uni.showToast({
- title: "请输入开始时间",
- icon: "none"
- });
- return
- }
- if (!this.end_time.replace(/^\s*/g,'')) {
- uni.showToast({
- title: "请输入结束时间",
- icon: "none"
- });
- return
- }
- }
-
- if(this.report_type==3&&this.device_type){
-
- if (this.device_type==6) {
- if (!this.device_port.replace(/^\s*/g,'')) {
- uni.showToast({
- title: "请输入端口号",
- icon: "none"
- });
- return
- }
- if (!this.port_type) {
- uni.showToast({
- title: "请选择端口类型",
- icon: "none"
- });
- return
- }
- if (!this.device_code) {
- uni.showToast({
- title: "请选择报备设备",
- icon: "none"
- });
- return
- }
- }
- if (!this.device_code) {
- uni.showToast({
- title: "请选择报备设备",
- icon: "none"
- });
- return
- }
- }
-
- let queryParam = {};
- if(this.id){
- queryParam.id=this.id
- }
- queryParam.report_type = this.report_type;
- queryParam.company_code=uni.getStorageSync('selectedCode');
- queryParam.remarks = this.remarks;
- queryParam.start_time = this.start_time;
- queryParam.end_time = this.end_time;
-
- if(this.id){
- queryParam.id = this.id;
- }
-
- if (this.report_type==1) {
- this.addDevice(queryParam)
- return;
- }
- if (this.report_type==2) {
- queryParam.device_type = this.device_type;
- this.addDevice(queryParam)
- return;
- }
- if (this.report_type==3) {
- queryParam.device_type = this.device_type;
- if(this.device_type==6){
- queryParam.port_type = this.port_type;
- queryParam.device_port = this.device_port;
- }
- queryParam.device_code = this.device_code;
- this.addDevice(queryParam)
- return;
- }
-
- this.addDevice(queryParam)
-
- },
-
- async addDevice(params = {}) {
- const res = await this.$myRequest({
- url: this.id?'AlarmReport/edit':'AlarmReport/add',
- data: params
- })
- uni.showToast({
- title:res.data.msg,
- icon: "none"
- });
-
- if (res.data.flag) {
- setTimeout(() => {
- uni.redirectTo({
- url: '/pages/setting/funReport/funReport',
- });
- }, 1000);
- }
- },
-
-
- radioChange(e) {
- console.log('type:' + e.detail.value);
- this.radioOne = e.detail.value;
- },
- //报备设备下拉请求数据
- async deviceList(params = {}) {
-
- const res = await this.$myRequest({
- url: 'AlarmReport/deviceList',
- data:params,
- })
- this.deviceListData = res.data.data;
- this.deviceListData=JSON.parse(JSON.stringify(this.deviceListData).replace(/owner_code/g,"value").replace(/owner_name/g,"text"))
- var arr=[]
- this.deviceListData.forEach(function(item){
- arr.push(item.owner_code)
- })
- if(arr.indexOf(this.device_code)==-1){
- this.device_code=''
- }
-
- },
- }
- }
- </script>
- <style lang="scss">
- input,
- select,
- option {
- line-height: 70rpx;
- padding: 0 20rpx;
- height: 70rpx;
- border: 1px solid #EDEDED;
- // width:500rpx!important;
- background-color: #fff;
- box-sizing: border-box;
- appearance: none;
- -moz-appearance: none;
- -webkit-appearance: none;
- color: #999;
- }
- /* 站点多选下拉样式end */
- </style>
|