funcAdd.vue 8.2 KB

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