funcAdd.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. <template>
  2. <view class="appWrapper padding-top" style="height:calc(100vh - 250rpx);overflow:scroll">
  3. <form action="" class="funcAdd">
  4. <view class="form-item selectBox">
  5. <view class="title"><text class="necessary">*</text>报备类型:</view>
  6. <select name="" id="" placeholder=""clearable v-model="repType">
  7. <option value="">请选择</option>
  8. <option value="1">单位</option>
  9. <option value="2">类型</option>
  10. <option value="3">设备</option>
  11. </select>
  12. <text class="icon iconfont margin-right-sm margin-left">&#xe63d;</text>
  13. </view>
  14. <view class="form-item selectBox" v-if="repType==2||repType==3">
  15. <view class="title"><text class="necessary">*</text>设备类型:</view>
  16. <select name="" id="" placeholder=""clearable v-model="deviceType">
  17. <option value="">请选择</option>
  18. <option value="1">火系统</option>
  19. <option value="2">水系统</option>
  20. <option value="3">烟感系统</option>
  21. <option value="4">消防栓</option>
  22. <option value="5">液位</option>
  23. <option value="6">RTU</option>
  24. <option value="7">电气火灾</option>
  25. <option value="16">视频监控</option>
  26. <option value="128">井盖</option>
  27. <option value="131">可燃气体</option>
  28. <option value="130">门禁监测</option>
  29. <option value="129">地磁监测</option>
  30. <option value="17">电梯监测</option>
  31. </select>
  32. <text class="icon iconfont margin-right-sm margin-left">&#xe63d;</text>
  33. </view>
  34. <view class="form-item" v-if="repType">
  35. <view class="title">
  36. <text class="necessary">*</text>
  37. 开始时间:
  38. </view>
  39. <view class="example-body">
  40. <uni-datetime-picker v-model="startTime" :start="now"/>
  41. </view>
  42. </view>
  43. <view class="form-item" v-if="repType">
  44. <view class="title">
  45. <text class="necessary">*</text>
  46. 结束时间:
  47. </view>
  48. <view class="example-body">
  49. <uni-datetime-picker v-model="endTime" :start="startTime" />
  50. </view>
  51. </view>
  52. <view class="form-item " v-if="repType==3&&deviceType==6">
  53. <view class="title"><text class="necessary">*</text>端口号:</view>
  54. <input name="input" v-model="portId"></input>
  55. </view>
  56. <view class="form-item selectBox" v-if="repType==3&&deviceType==6">
  57. <view class="title"><text class="necessary">*</text>端口类型:</view>
  58. <select name="" id="" placeholder=""clearable v-model="portType">
  59. <option value="">请选择</option>
  60. <option value="1">数字量</option>
  61. <option value="2">模拟量</option>
  62. </select>
  63. <text class="icon iconfont margin-right-sm margin-left">&#xe63d;</text>
  64. </view>
  65. <view class="form-item selectBox" v-if="repType==3&&deviceType">
  66. <view class="title"><text class="necessary">*</text>设备编号:</view>
  67. <select name="" id="" placeholder=""clearable v-model="deviceNo">
  68. <option value="">请选择</option>
  69. <option value="1">编号1</option>
  70. <option value="2">编号2</option>
  71. </select>
  72. <text class="icon iconfont margin-right-sm margin-left">&#xe63d;</text>
  73. </view>
  74. <view class="form-item " v-if="repType">
  75. <view class="title"><text class="necessary"></text>备注:</view>
  76. <input name="input" v-model="remark"></input>
  77. </view>
  78. <view class="btn-area submitBottomBtn padding-lr-sm">
  79. <button class="bg-blue round margin-top" @tap="submit()">提 交 </button>
  80. </view>
  81. </form>
  82. </view>
  83. </template>
  84. <style scoped>
  85. /deep/ .funcAdd .uni-date-x--border, .uni-date-x{
  86. border-radius:0!important
  87. }
  88. .funcAdd .example-body{
  89. margin:0;
  90. width:calc(100% - 200rpx)
  91. }
  92. </style>
  93. <script>
  94. export default {
  95. data() {
  96. return {
  97. repType:'',
  98. deviceType:'',
  99. startTime:'',
  100. endTime:'',
  101. remark:'',
  102. portId:'',
  103. portType:'',
  104. deviceNo:'',
  105. now:''
  106. }
  107. },
  108. onLoad: function(option) {
  109. this.getSiteList();
  110. uni.setNavigationBarTitle({
  111. title: option.id?"编辑":"新增",
  112. });
  113. var nowTemp = new Date();
  114. this.now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
  115. },
  116. watch: {
  117. startTime:function(){
  118. alert(this.startTime)
  119. }
  120. },
  121. methods: {
  122. async submit() {
  123. //提交验证
  124. if (!this.device_code) {
  125. uni.showToast({
  126. title: "请输入设备编号",
  127. icon: "none"
  128. });
  129. return
  130. }else{
  131. var reg = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{2,10}$/;
  132. if(!reg.test(this.device_code)){
  133. uni.showToast({
  134. title: "请输入字母和数字结合的设备编号",
  135. icon: "none"
  136. });
  137. return
  138. }
  139. }
  140. if (!this.device_name.replace(/^\s*/g,'')) {
  141. uni.showToast({
  142. title: "请输入设备名称",
  143. icon: "none"
  144. });
  145. return
  146. }
  147. if (!this.unitinfo.replace(/^\s*/g,'')) {
  148. uni.showToast({
  149. title: "请输入单元地址",
  150. icon: "none"
  151. });
  152. return
  153. }
  154. if (!this.louyu) {
  155. uni.showToast({
  156. title: "请选择所属楼层",
  157. icon: "none"
  158. });
  159. return
  160. }
  161. if (!this.sim.replace(/^\s*/g,'')) {
  162. uni.showToast({
  163. title: "请输入物联网卡号",
  164. icon: "none"
  165. });
  166. return
  167. }
  168. if (!this.company_code) {
  169. uni.showToast({
  170. title: "请选择所在单位",
  171. icon: "none"
  172. });
  173. return
  174. }
  175. if (!this.type) {
  176. uni.showToast({
  177. title: "请选择设备类型",
  178. icon: "none"
  179. });
  180. return
  181. }
  182. if (!this.transfer_type) {
  183. uni.showToast({
  184. title: "请选择传输方式",
  185. icon: "none"
  186. });
  187. return
  188. }
  189. if(this.type==1&&this.transfer_type=="4G"){
  190. if (this.owner_xh_a=='z') {
  191. uni.showToast({
  192. title: "请选择第一个解析方法",
  193. icon: "none"
  194. });
  195. return
  196. }
  197. if (this.owner_xh_b=='z') {
  198. uni.showToast({
  199. title: "请选择第二个解析方法",
  200. icon: "none"
  201. });
  202. return
  203. }
  204. if (this.owner_xh_c=='z') {
  205. uni.showToast({
  206. title: "请选择第三个解析方法",
  207. icon: "none"
  208. });
  209. return
  210. }
  211. }
  212. if(this.transfer_type=='NB'&&(this.type==2||this.type==5)){
  213. if (!this.deviceType) {
  214. uni.showToast({
  215. title: "请选择水表NB设备类型",
  216. icon: "none"
  217. });
  218. return
  219. }
  220. if (!this.manufacturerName) {
  221. uni.showToast({
  222. title: "请选择水表NB厂商名称",
  223. icon: "none"
  224. });
  225. return
  226. }
  227. if (!this.model) {
  228. uni.showToast({
  229. title: "请选择水表NB设备型号",
  230. icon: "none"
  231. });
  232. return
  233. }
  234. if (!this.manufacturerId) {
  235. uni.showToast({
  236. title: "请选择水表NB厂商ID",
  237. icon: "none"
  238. });
  239. return
  240. }
  241. if (!this.location.replace(/^\s*/g,'')) {
  242. uni.showToast({
  243. title: "请输入水表NB地址",
  244. icon: "none"
  245. });
  246. return
  247. }
  248. if (!this.protocolType.replace(/^\s*/g,'')) {
  249. uni.showToast({
  250. title: "请输入水表NB协议",
  251. icon: "none"
  252. });
  253. return
  254. }
  255. }
  256. if(this.type==7&&this.transfer_type=='4G'){
  257. if (!this.max_level) {
  258. uni.showToast({
  259. title: "请选择最高层",
  260. icon: "none"
  261. });
  262. return
  263. }
  264. if (!this.min_level) {
  265. uni.showToast({
  266. title: "请选择最低层",
  267. icon: "none"
  268. });
  269. return
  270. }
  271. if (!this.owner_bl.replace(/^\s*/g,'')) {
  272. uni.showToast({
  273. title: "请输入倍率",
  274. icon: "none"
  275. });
  276. return
  277. }
  278. }
  279. let queryParam = {};
  280. queryParam.device_code = this.device_code;
  281. queryParam.device_name = this.device_name;
  282. queryParam.unitinfo = this.unitinfo;
  283. queryParam.louyu = this.louyu;
  284. queryParam.sim = this.sim;
  285. queryParam.company_code = this.company_code;
  286. queryParam.type = this.type;
  287. queryParam.transfer_type = this.transfer_type;
  288. queryParam.is_top = this.radioOne;
  289. if (this.type==1&&this.transfer_type=="4G") {
  290. queryParam.owner_xh_a = this.owner_xh_a;
  291. queryParam.owner_xh_b = this.owner_xh_b;
  292. queryParam.owner_xh_c = this.owner_xh_c;
  293. this.addDevice(queryParam)
  294. return;
  295. }
  296. if (this.transfer_type=='NB'&&(this.type==2||this.type==5)) {
  297. queryParam.deviceType = this.deviceType;
  298. queryParam.manufacturerName = this.manufacturerName;
  299. queryParam.model = this.model;
  300. queryParam.location = this.location;
  301. queryParam.protocolType = this.protocolType;
  302. queryParam.manufacturerId = this.manufacturerId;
  303. this.addDevice(queryParam)
  304. return;
  305. }
  306. if (this.type==7&&this.transfer_type=='4G') {
  307. queryParam.max_level = this.max_level;
  308. queryParam.min_level = this.min_level;
  309. queryParam.owner_bl = this.owner_bl;
  310. this.addDevice(queryParam)
  311. return;
  312. }
  313. this.addDevice(queryParam)
  314. },
  315. async addDevice(params = {}) {
  316. const res = await this.$myRequest({
  317. url: 'DeviceConfig/setDevice',
  318. data: params
  319. })
  320. if (res.data.flag) {
  321. // uni.showToast({
  322. // title: "提交成功",
  323. // });
  324. // setTimeout(() => {
  325. // uni.navigateTo({
  326. // url: '/pages/deviceManage/deviceManage',
  327. // });
  328. // }, 1000);
  329. setTimeout(() => {
  330. uni.navigateTo({
  331. url: '/pages/accountManage/success/success',
  332. });
  333. }, 1000);
  334. }
  335. },
  336. radioChange(e) {
  337. console.log('type:' + e.detail.value);
  338. this.radioOne = e.detail.value;
  339. },
  340. //单位下拉请求数据
  341. async getSiteList() {
  342. const res = await this.$myRequest({
  343. url: 'Index/getCompanyList',
  344. })
  345. this.companyListData = res.data.data;
  346. },
  347. }
  348. }
  349. </script>
  350. <style lang="scss">
  351. input,
  352. select,
  353. option {
  354. line-height: 70rpx;
  355. padding: 0 20rpx;
  356. height: 70rpx;
  357. border: 1px solid #EDEDED;
  358. // width:500rpx!important;
  359. background-color: #fff;
  360. box-sizing: border-box;
  361. appearance: none;
  362. -moz-appearance: none;
  363. -webkit-appearance: none;
  364. color: #999;
  365. }
  366. /* 站点多选下拉样式end */
  367. </style>