123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423 |
- <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>
- <select name="" id="" placeholder=""clearable v-model="repType">
- <option value="">请选择</option>
- <option value="1">单位</option>
- <option value="2">类型</option>
- <option value="3">设备</option>
- </select>
- <text class="icon iconfont margin-right-sm margin-left"></text>
- </view>
- <view class="form-item selectBox" v-if="repType==2||repType==3">
- <view class="title"><text class="necessary">*</text>设备类型:</view>
- <select name="" id="" placeholder=""clearable v-model="deviceType">
- <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>
- <text class="icon iconfont margin-right-sm margin-left"></text>
- </view>
-
- <view class="form-item" v-if="repType">
- <view class="title">
- <text class="necessary">*</text>
- 开始时间:
- </view>
- <view class="example-body">
- <uni-datetime-picker v-model="startTime" :start="now"/>
- </view>
- </view>
- <view class="form-item" v-if="repType">
- <view class="title">
- <text class="necessary">*</text>
- 结束时间:
- </view>
- <view class="example-body">
- <uni-datetime-picker v-model="endTime" :start="startTime" />
- </view>
- </view>
-
-
-
- <view class="form-item " v-if="repType==3&&deviceType==6">
- <view class="title"><text class="necessary">*</text>端口号:</view>
- <input name="input" v-model="portId"></input>
- </view>
-
- <view class="form-item selectBox" v-if="repType==3&&deviceType==6">
- <view class="title"><text class="necessary">*</text>端口类型:</view>
- <select name="" id="" placeholder=""clearable v-model="portType">
- <option value="">请选择</option>
- <option value="1">数字量</option>
- <option value="2">模拟量</option>
- </select>
- <text class="icon iconfont margin-right-sm margin-left"></text>
- </view>
-
- <view class="form-item selectBox" v-if="repType==3&&deviceType">
- <view class="title"><text class="necessary">*</text>设备编号:</view>
- <select name="" id="" placeholder=""clearable v-model="deviceNo">
- <option value="">请选择</option>
- <option value="1">编号1</option>
- <option value="2">编号2</option>
- </select>
- <text class="icon iconfont margin-right-sm margin-left"></text>
- </view>
-
- <view class="form-item " v-if="repType">
- <view class="title"><text class="necessary"></text>备注:</view>
- <input name="input" v-model="remark"></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 {
- repType:'',
- deviceType:'',
- startTime:'',
- endTime:'',
- remark:'',
- portId:'',
- portType:'',
- deviceNo:'',
- now:''
-
- }
- },
- onLoad: function(option) {
- this.getSiteList();
-
- uni.setNavigationBarTitle({
- title: option.id?"编辑":"新增",
- });
-
- var nowTemp = new Date();
- this.now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
- },
- watch: {
- startTime:function(){
- alert(this.startTime)
- }
-
- },
- methods: {
- async submit() {
- //提交验证
-
- if (!this.device_code) {
- uni.showToast({
- title: "请输入设备编号",
- icon: "none"
- });
- return
- }else{
- var reg = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{2,10}$/;
- if(!reg.test(this.device_code)){
- uni.showToast({
- title: "请输入字母和数字结合的设备编号",
- icon: "none"
- });
- return
- }
- }
-
- if (!this.device_name.replace(/^\s*/g,'')) {
- uni.showToast({
- title: "请输入设备名称",
- icon: "none"
- });
- return
- }
- if (!this.unitinfo.replace(/^\s*/g,'')) {
- uni.showToast({
- title: "请输入单元地址",
- icon: "none"
- });
- return
- }
- if (!this.louyu) {
- uni.showToast({
- title: "请选择所属楼层",
- icon: "none"
- });
- return
- }
- if (!this.sim.replace(/^\s*/g,'')) {
- uni.showToast({
- title: "请输入物联网卡号",
- icon: "none"
- });
- return
- }
- if (!this.company_code) {
- uni.showToast({
- title: "请选择所在单位",
- icon: "none"
- });
- return
- }
- if (!this.type) {
- uni.showToast({
- title: "请选择设备类型",
- icon: "none"
- });
- return
- }
- if (!this.transfer_type) {
- uni.showToast({
- title: "请选择传输方式",
- icon: "none"
- });
- return
- }
-
- if(this.type==1&&this.transfer_type=="4G"){
- if (this.owner_xh_a=='z') {
- uni.showToast({
- title: "请选择第一个解析方法",
- icon: "none"
- });
- return
- }
- if (this.owner_xh_b=='z') {
- uni.showToast({
- title: "请选择第二个解析方法",
- icon: "none"
- });
- return
- }
- if (this.owner_xh_c=='z') {
- uni.showToast({
- title: "请选择第三个解析方法",
- icon: "none"
- });
- return
- }
- }
-
- if(this.transfer_type=='NB'&&(this.type==2||this.type==5)){
- if (!this.deviceType) {
- uni.showToast({
- title: "请选择水表NB设备类型",
- icon: "none"
- });
- return
- }
- if (!this.manufacturerName) {
- uni.showToast({
- title: "请选择水表NB厂商名称",
- icon: "none"
- });
- return
- }
- if (!this.model) {
- uni.showToast({
- title: "请选择水表NB设备型号",
- icon: "none"
- });
- return
- }
- if (!this.manufacturerId) {
- uni.showToast({
- title: "请选择水表NB厂商ID",
- icon: "none"
- });
- return
- }
- if (!this.location.replace(/^\s*/g,'')) {
- uni.showToast({
- title: "请输入水表NB地址",
- icon: "none"
- });
- return
- }
- if (!this.protocolType.replace(/^\s*/g,'')) {
- uni.showToast({
- title: "请输入水表NB协议",
- icon: "none"
- });
- return
- }
- }
-
-
- if(this.type==7&&this.transfer_type=='4G'){
- if (!this.max_level) {
- uni.showToast({
- title: "请选择最高层",
- icon: "none"
- });
- return
- }
- if (!this.min_level) {
- uni.showToast({
- title: "请选择最低层",
- icon: "none"
- });
- return
- }
-
-
- if (!this.owner_bl.replace(/^\s*/g,'')) {
- uni.showToast({
- title: "请输入倍率",
- icon: "none"
- });
- return
- }
- }
-
- let queryParam = {};
- queryParam.device_code = this.device_code;
- queryParam.device_name = this.device_name;
- queryParam.unitinfo = this.unitinfo;
- queryParam.louyu = this.louyu;
- queryParam.sim = this.sim;
-
- queryParam.company_code = this.company_code;
- queryParam.type = this.type;
- queryParam.transfer_type = this.transfer_type;
- queryParam.is_top = this.radioOne;
-
- if (this.type==1&&this.transfer_type=="4G") {
- queryParam.owner_xh_a = this.owner_xh_a;
- queryParam.owner_xh_b = this.owner_xh_b;
- queryParam.owner_xh_c = this.owner_xh_c;
- this.addDevice(queryParam)
- return;
- }
- if (this.transfer_type=='NB'&&(this.type==2||this.type==5)) {
- queryParam.deviceType = this.deviceType;
- queryParam.manufacturerName = this.manufacturerName;
- queryParam.model = this.model;
- queryParam.location = this.location;
- queryParam.protocolType = this.protocolType;
- queryParam.manufacturerId = this.manufacturerId;
- this.addDevice(queryParam)
- return;
- }
- if (this.type==7&&this.transfer_type=='4G') {
- queryParam.max_level = this.max_level;
- queryParam.min_level = this.min_level;
- queryParam.owner_bl = this.owner_bl;
- this.addDevice(queryParam)
- return;
- }
- this.addDevice(queryParam)
-
- },
-
- async addDevice(params = {}) {
- const res = await this.$myRequest({
- url: 'DeviceConfig/setDevice',
- data: params
- })
- if (res.data.flag) {
- // uni.showToast({
- // title: "提交成功",
- // });
- // setTimeout(() => {
- // uni.navigateTo({
- // url: '/pages/deviceManage/deviceManage',
- // });
- // }, 1000);
- setTimeout(() => {
- uni.navigateTo({
- url: '/pages/accountManage/success/success',
- });
- }, 1000);
- }
- },
-
-
- radioChange(e) {
- console.log('type:' + e.detail.value);
- this.radioOne = e.detail.value;
- },
- //单位下拉请求数据
- async getSiteList() {
- const res = await this.$myRequest({
- url: 'Index/getCompanyList',
- })
- this.companyListData = res.data.data;
- },
- }
- }
- </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>
|