funcAdd.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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. id:'',
  98. repType:'',
  99. deviceType:'',
  100. startTime:'',
  101. endTime:'',
  102. remark:'',
  103. portId:'',
  104. portType:'',
  105. deviceNo:'',
  106. now:''
  107. }
  108. },
  109. onLoad: function(option) {
  110. this.id=option.id;
  111. this.getSiteList();
  112. uni.setNavigationBarTitle({
  113. title: option.id?"编辑":"新增",
  114. });
  115. var nowTemp = new Date();
  116. this.now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
  117. },
  118. watch: {
  119. startTime:function(){
  120. alert(this.startTime)
  121. }
  122. },
  123. methods: {
  124. async submit() {
  125. //提交验证
  126. if (!this.repType) {
  127. uni.showToast({
  128. title: "请输入报备类型",
  129. icon: "none"
  130. });
  131. return
  132. }
  133. if(this.repType==1){
  134. if (!this.startTime.replace(/^\s*/g,'')) {
  135. uni.showToast({
  136. title: "请选择开始时间",
  137. icon: "none"
  138. });
  139. return
  140. }
  141. if (!this.endTime.replace(/^\s*/g,'')) {
  142. uni.showToast({
  143. title: "请选择结束时间",
  144. icon: "none"
  145. });
  146. return
  147. }
  148. }
  149. if(this.repType==2||this.repType==3){
  150. if (!this.deviceType) {
  151. uni.showToast({
  152. title: "请选择设备类型",
  153. icon: "none"
  154. });
  155. return
  156. }
  157. if (!this.startTime.replace(/^\s*/g,'')) {
  158. uni.showToast({
  159. title: "请输入开始时间",
  160. icon: "none"
  161. });
  162. return
  163. }
  164. if (!this.endTime.replace(/^\s*/g,'')) {
  165. uni.showToast({
  166. title: "请输入结束时间",
  167. icon: "none"
  168. });
  169. return
  170. }
  171. }
  172. if(this.repType==3&&this.deviceType){
  173. if (this.deviceType==6) {
  174. if (!this.portId.replace(/^\s*/g,'')) {
  175. uni.showToast({
  176. title: "请输入端口号",
  177. icon: "none"
  178. });
  179. return
  180. }
  181. if (!this.portType) {
  182. uni.showToast({
  183. title: "请选择端口类型",
  184. icon: "none"
  185. });
  186. return
  187. }
  188. if (!this.deviceNo) {
  189. uni.showToast({
  190. title: "请选择报备设备",
  191. icon: "none"
  192. });
  193. return
  194. }
  195. }
  196. if (!this.deviceNo) {
  197. uni.showToast({
  198. title: "请选择报备设备",
  199. icon: "none"
  200. });
  201. return
  202. }
  203. }
  204. let queryParam = {};
  205. if(this.id){
  206. queryParam.id=this.id
  207. }
  208. queryParam.repType = this.repType;
  209. queryParam.companyCode='10012';
  210. queryParam.remark = this.remark;
  211. queryParam.startTime = this.startTime;
  212. queryParam.endTime = this.endTime;
  213. if (this.repType==1) {
  214. this.addDevice(queryParam)
  215. return;
  216. }
  217. if (this.repType==2) {
  218. queryParam.deviceType = this.deviceType;
  219. this.addDevice(queryParam)
  220. return;
  221. }
  222. if (this.repType==3) {
  223. queryParam.deviceType = this.deviceType;
  224. if(this.deviceType==6){
  225. queryParam.portType = this.portType;
  226. queryParam.portId = this.portId;
  227. }
  228. queryParam.deviceNo = this.deviceNo;
  229. this.addDevice(queryParam)
  230. return;
  231. }
  232. this.addDevice(queryParam)
  233. },
  234. async addDevice(params = {}) {
  235. const res = await this.$myRequest({
  236. url: 'DeviceConfig/setDevice',
  237. data: params
  238. })
  239. if (res.data.flag) {
  240. // uni.showToast({
  241. // title: "提交成功",
  242. // });
  243. // setTimeout(() => {
  244. // uni.navigateTo({
  245. // url: '/pages/deviceManage/deviceManage',
  246. // });
  247. // }, 1000);
  248. setTimeout(() => {
  249. uni.navigateTo({
  250. url: '/pages/accountManage/success/success',
  251. });
  252. }, 1000);
  253. }
  254. },
  255. radioChange(e) {
  256. console.log('type:' + e.detail.value);
  257. this.radioOne = e.detail.value;
  258. },
  259. //单位下拉请求数据
  260. async getSiteList() {
  261. const res = await this.$myRequest({
  262. url: 'Index/getCompanyList',
  263. })
  264. this.companyListData = res.data.data;
  265. },
  266. }
  267. }
  268. </script>
  269. <style lang="scss">
  270. input,
  271. select,
  272. option {
  273. line-height: 70rpx;
  274. padding: 0 20rpx;
  275. height: 70rpx;
  276. border: 1px solid #EDEDED;
  277. // width:500rpx!important;
  278. background-color: #fff;
  279. box-sizing: border-box;
  280. appearance: none;
  281. -moz-appearance: none;
  282. -webkit-appearance: none;
  283. color: #999;
  284. }
  285. /* 站点多选下拉样式end */
  286. </style>