funcAdd.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  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. <uni-data-select v-model="report_type" :localdata="skillsRange" >
  7. </uni-data-select>
  8. <!--
  9. <select name="" id="" placeholder="请选择" clearable v-model="report_type">
  10. <option value="">请选择</option>
  11. <option value="1">单位</option>
  12. <option value="2">类型</option>
  13. <option value="3">设备</option>
  14. </select> -->
  15. </view>
  16. <view class="form-item selectBox" v-if="report_type==2||report_type==3">
  17. <view class="title"><text class="necessary">*</text>设备类型:</view>
  18. <uni-data-select v-model="device_type" :localdata="deviceRange" >
  19. </uni-data-select>
  20. <!-- <select name="" id="" placeholder=""clearable v-model="device_type">
  21. <option value="">请选择</option>
  22. <option value="1">火系统</option>
  23. <option value="2">水系统</option>
  24. <option value="3">烟感系统</option>
  25. <option value="4">消防栓</option>
  26. <option value="5">液位</option>
  27. <option value="6">RTU</option>
  28. <option value="7">电气火灾</option>
  29. <option value="16">视频监控</option>
  30. <option value="128">井盖</option>
  31. <option value="131">可燃气体</option>
  32. <option value="130">门禁监测</option>
  33. <option value="129">地磁监测</option>
  34. <option value="17">电梯监测</option>
  35. </select> -->
  36. </view>
  37. <view class="form-item" v-if="report_type">
  38. <view class="title">
  39. <text class="necessary">*</text>
  40. 开始时间:
  41. </view>
  42. <view class="example-body">
  43. <uni-datetime-picker v-model="start_time" :start="this.id?'':now"/>
  44. </view>
  45. </view>
  46. <view class="form-item" v-if="report_type">
  47. <view class="title">
  48. <text class="necessary">*</text>
  49. 结束时间:
  50. </view>
  51. <view class="example-body">
  52. <uni-datetime-picker v-model="end_time" :start="start_time" />
  53. </view>
  54. </view>
  55. <view class="form-item " v-if="report_type==3&&device_type==6">
  56. <view class="title"><text class="necessary">*</text>端口号:</view>
  57. <input name="input" v-model="device_port"></input>
  58. </view>
  59. <view class="form-item selectBox" v-if="report_type==3&&device_type==6">
  60. <view class="title"><text class="necessary">*</text>端口类型:</view>
  61. <!-- <select name="" id="" placeholder=""clearable v-model="port_type">
  62. <option value="">请选择</option>
  63. <option value="1">数字量</option>
  64. <option value="2">模拟量</option>
  65. </select> -->
  66. <uni-data-select v-model="port_type" :localdata="portRange" >
  67. </uni-data-select>
  68. <!-- <text class="icon iconfont margin-right-sm margin-left">&#xe63d;</text> -->
  69. </view>
  70. <view class="form-item selectBox" v-if="report_type==3&&device_type">
  71. <view class="title"><text class="necessary">*</text>报备设备:</view>
  72. <!-- <select name="" id="" placeholder=""clearable v-model="device_code">
  73. <option value="">请选择</option>
  74. <option :value="item.owner_code" v-for="(item,index) in deviceListData" :key="index">{{item.owner_name}}
  75. </option>
  76. </select> -->
  77. <uni-data-select v-model="device_code" :localdata="deviceListData" >
  78. </uni-data-select>
  79. <!-- <text class="icon iconfont margin-right-sm margin-left">&#xe63d;</text> -->
  80. </view>
  81. <view class="form-item " v-if="report_type">
  82. <view class="title"><text class="necessary"></text>备注:</view>
  83. <input name="input" v-model="remarks"></input>
  84. </view>
  85. <view class="btn-area submitBottomBtn padding-lr-sm">
  86. <button class="bg-blue round margin-top" @tap="submit()">提 交 </button>
  87. </view>
  88. </form>
  89. </view>
  90. </template>
  91. <style scoped>
  92. /deep/ .funcAdd .uni-date-x--border, .uni-date-x{
  93. border-radius:0!important
  94. }
  95. .funcAdd .example-body{
  96. margin:0;
  97. width:calc(100% - 200rpx)
  98. }
  99. </style>
  100. <script>
  101. export default {
  102. data() {
  103. return {
  104. skillsRange: [{
  105. value: 1,
  106. text: "单位"
  107. },
  108. {
  109. value: 2,
  110. text: "类型"
  111. },
  112. {
  113. value: 3,
  114. text: "设备"
  115. },
  116. ],
  117. deviceRange:[{
  118. value: 1,
  119. text: "火系统"
  120. },
  121. {
  122. value: 2,
  123. text: "水系统"
  124. },
  125. {
  126. value: 3,
  127. text: "烟感系统"
  128. },{
  129. value: 4,
  130. text: "消防栓"
  131. },
  132. {
  133. value: 5,
  134. text: "液位"
  135. },
  136. {
  137. value: 6,
  138. text: "RTU"
  139. },{
  140. value: 7,
  141. text: "电气火灾"
  142. },
  143. {
  144. value: 16,
  145. text: "视频监控"
  146. },
  147. {
  148. value: 128,
  149. text: "井盖"
  150. },{
  151. value: 131,
  152. text: "可燃气体"
  153. },
  154. {
  155. value: 130,
  156. text: "门禁监测"
  157. },
  158. {
  159. value: 129,
  160. text: "地磁监测"
  161. },{
  162. value:17,
  163. text: "电梯监测"
  164. },],
  165. portRange: [{
  166. value: 1,
  167. text: "数字量"
  168. },
  169. {
  170. value: 2,
  171. text: "模拟量"
  172. },
  173. ],
  174. id:'',
  175. report_type:'',
  176. device_type:'',
  177. start_time:'',
  178. end_time:'',
  179. remarks:'',
  180. device_port:'',
  181. port_type:'',
  182. device_code:'',
  183. now:'',
  184. deviceListData:[],
  185. detailsData:''
  186. }
  187. },
  188. onLoad: function(option) {
  189. this.id=option.id;
  190. uni.setNavigationBarTitle({
  191. title: option.id?"编辑":"新增",
  192. });
  193. var nowTemp = new Date();
  194. this.now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
  195. if(option.id){
  196. this.getDetailsData({'id':option.id})
  197. }
  198. },
  199. watch: {
  200. start_time:function(){
  201. // alert(this.start_time)
  202. },
  203. report_type:function(newVal){
  204. // alert(this.device_type)
  205. if(newVal){
  206. var array123=['','1','2','3','4','5','6','7','16','128','131','130','129','17']
  207. if(array123.indexOf(this.device_type)==-1){
  208. // this.device_type=''
  209. }
  210. }
  211. },
  212. device_type:function(newVal){
  213. if(newVal){
  214. this.deviceList({'company_code':uni.getStorageSync('selectedCode'),'device_type' :this.device_type });
  215. }
  216. }
  217. },
  218. methods: {
  219. // 回显信息请求
  220. async getDetailsData(params = {}) {
  221. const res = await this.$myRequest({
  222. url: 'AlarmReport/editData',
  223. data:params,
  224. showLoading: true
  225. })
  226. this.detailsData=res.data.data[0];
  227. this.report_type=parseInt(this.detailsData.report_type);
  228. this.device_type=parseInt(this.detailsData.device_type);
  229. this.start_time=this.detailsData.start_time;
  230. this.end_time=this.detailsData.end_time;
  231. this.remarks=this.detailsData.remarks;
  232. this.port_type=parseInt(this.detailsData.port_type);
  233. this.device_port=this.detailsData.device_port;
  234. this.device_code=this.detailsData.device_code;
  235. },
  236. async submit() {
  237. //提交验证
  238. if (!this.report_type) {
  239. uni.showToast({
  240. title: "请输入报备类型",
  241. icon: "none"
  242. });
  243. return
  244. }
  245. if(this.report_type==1){
  246. if (!this.start_time.replace(/^\s*/g,'')) {
  247. uni.showToast({
  248. title: "请选择开始时间",
  249. icon: "none"
  250. });
  251. return
  252. }
  253. if (!this.end_time.replace(/^\s*/g,'')) {
  254. uni.showToast({
  255. title: "请选择结束时间",
  256. icon: "none"
  257. });
  258. return
  259. }
  260. }
  261. if(this.report_type==2||this.report_type==3){
  262. if (!this.device_type) {
  263. uni.showToast({
  264. title: "请选择设备类型",
  265. icon: "none"
  266. });
  267. return
  268. }
  269. if (!this.start_time.replace(/^\s*/g,'')) {
  270. uni.showToast({
  271. title: "请输入开始时间",
  272. icon: "none"
  273. });
  274. return
  275. }
  276. if (!this.end_time.replace(/^\s*/g,'')) {
  277. uni.showToast({
  278. title: "请输入结束时间",
  279. icon: "none"
  280. });
  281. return
  282. }
  283. }
  284. if(this.report_type==3&&this.device_type){
  285. if (this.device_type==6) {
  286. if (!this.device_port.replace(/^\s*/g,'')) {
  287. uni.showToast({
  288. title: "请输入端口号",
  289. icon: "none"
  290. });
  291. return
  292. }
  293. if (!this.port_type) {
  294. uni.showToast({
  295. title: "请选择端口类型",
  296. icon: "none"
  297. });
  298. return
  299. }
  300. if (!this.device_code) {
  301. uni.showToast({
  302. title: "请选择报备设备",
  303. icon: "none"
  304. });
  305. return
  306. }
  307. }
  308. if (!this.device_code) {
  309. uni.showToast({
  310. title: "请选择报备设备",
  311. icon: "none"
  312. });
  313. return
  314. }
  315. }
  316. let queryParam = {};
  317. if(this.id){
  318. queryParam.id=this.id
  319. }
  320. queryParam.report_type = this.report_type;
  321. queryParam.company_code=uni.getStorageSync('selectedCode');
  322. queryParam.remarks = this.remarks;
  323. queryParam.start_time = this.start_time;
  324. queryParam.end_time = this.end_time;
  325. if(this.id){
  326. queryParam.id = this.id;
  327. }
  328. if (this.report_type==1) {
  329. this.addDevice(queryParam)
  330. return;
  331. }
  332. if (this.report_type==2) {
  333. queryParam.device_type = this.device_type;
  334. this.addDevice(queryParam)
  335. return;
  336. }
  337. if (this.report_type==3) {
  338. queryParam.device_type = this.device_type;
  339. if(this.device_type==6){
  340. queryParam.port_type = this.port_type;
  341. queryParam.device_port = this.device_port;
  342. }
  343. queryParam.device_code = this.device_code;
  344. this.addDevice(queryParam)
  345. return;
  346. }
  347. this.addDevice(queryParam)
  348. },
  349. async addDevice(params = {}) {
  350. const res = await this.$myRequest({
  351. url: this.id?'AlarmReport/edit':'AlarmReport/add',
  352. data: params
  353. })
  354. uni.showToast({
  355. title:res.data.msg,
  356. icon: "none"
  357. });
  358. if (res.data.flag) {
  359. setTimeout(() => {
  360. uni.redirectTo({
  361. url: '/pages/setting/funReport/funReport',
  362. });
  363. }, 1000);
  364. }
  365. },
  366. radioChange(e) {
  367. console.log('type:' + e.detail.value);
  368. this.radioOne = e.detail.value;
  369. },
  370. //报备设备下拉请求数据
  371. async deviceList(params = {}) {
  372. const res = await this.$myRequest({
  373. url: 'AlarmReport/deviceList',
  374. data:params,
  375. })
  376. this.deviceListData = res.data.data;
  377. this.deviceListData=JSON.parse(JSON.stringify(this.deviceListData).replace(/owner_code/g,"value").replace(/owner_name/g,"text"))
  378. var arr=[]
  379. this.deviceListData.forEach(function(item){
  380. arr.push(item.owner_code)
  381. })
  382. if(arr.indexOf(this.device_code)==-1){
  383. // this.device_code=''
  384. }
  385. },
  386. }
  387. }
  388. </script>
  389. <style lang="scss">
  390. input,
  391. select,
  392. option {
  393. line-height: 70rpx;
  394. padding: 0 20rpx;
  395. height: 70rpx;
  396. border: 1px solid #EDEDED;
  397. // width:500rpx!important;
  398. background-color: #fff;
  399. box-sizing: border-box;
  400. appearance: none;
  401. -moz-appearance: none;
  402. -webkit-appearance: none;
  403. color: #999;
  404. }
  405. /* 站点多选下拉样式end */
  406. </style>