modification.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <view>
  3. <view class="status_bar"></view>
  4. <view class="" style="position: relative;top: 64px;">
  5. <view style="position: fixed;z-index: 100;">
  6. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" title="修改名称"></uni-nav-bar>
  7. </view>
  8. <view class="mod">
  9. <view class="mod_name">
  10. <p><span style="color: #ff0000;" v-if="quanxian.namealter">*</span>设备名称</p>
  11. <input type="text" v-model="moddata.device_name" :class="quanxian.namealter?'namebg':''" :disabled="!quanxian.namealter"/>
  12. </view>
  13. <view class="mod_id">
  14. <p>设备ID</p>
  15. <input type="text" :value="moddata.imei||moddata.device_id" disabled />
  16. </view>
  17. <view class="mod_user">
  18. <p>适配用户</p>
  19. <input type="text" :value="moddata.real_name==''?'无':moddata.real_name" disabled />
  20. </view>
  21. <view class="mod_city" @click="amendcity" v-if="$QueryPermission(109)">
  22. <p><span style="color: #ff0000;" v-if="quanxian.cityalter">*</span>设备位置</p>
  23. <view style="display: flex;">
  24. <input type="text" :value="city" disabled style="width: 400rpx;" />
  25. <u-icon name="arrow-right"></u-icon>
  26. </view>
  27. </view>
  28. <view class="mod_time">
  29. <p>设备添加时间</p>
  30. <input type="text" :value="moddata.addtime|timeFormat()" disabled />
  31. </view>
  32. <p style="width: 90%;margin: 0 auto;text-align: right;color: #06B535;"><span style="color: #ff0000;">*</span>为可修改</p>
  33. <view class="sub" v-if="quanxian.infoalter" @click="btn">
  34. 提 交
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. data() {
  43. return {
  44. moddata: [],
  45. city: "",
  46. selectcityTF: false,
  47. quanxian:{
  48. namealter:false,
  49. cityalter:false,
  50. infoalter:false
  51. }
  52. }
  53. },
  54. methods: {
  55. async eqlistcity(lat, lng) { //修改设备定位
  56. const res = await this.$myRequest({
  57. url: '/api/api_gateway?method=forecast.worm_lamp.revise_device_lnglat',
  58. data: {
  59. device_id: this.moddata.imei,
  60. lat: lat,
  61. lng: lng
  62. }
  63. })
  64. console.log(res)
  65. if (res==false) {
  66. uni.showModal({
  67. title: "修改地址失败",
  68. icon: "none"
  69. })
  70. }
  71. },
  72. async eqlistname() { //修改设备名称
  73. const res = await this.$myRequest({
  74. url: '/api/api_gateway?method=forecast.worm_lamp.revise_device',
  75. data: {
  76. device_id: this.moddata.imei,
  77. device_name: this.moddata.device_name,
  78. }
  79. })
  80. console.log(res)
  81. if (res==false) {
  82. uni.showModal({
  83. title: "修改名称失败",
  84. icon: "none"
  85. })
  86. }
  87. },
  88. async eqlistuser(id, imei) { //获取设备信息
  89. const res = await this.$myRequest({
  90. url: '/api/api_gateway?method=forecast.worm_lamp.lamp_list',
  91. data: {
  92. device_type_id: id,
  93. device_id: imei,
  94. }
  95. })
  96. this.moddata = res.data[0]
  97. console.log(res)
  98. this.selectaddress(this.moddata.lng, this.moddata.lat)
  99. },
  100. async xyeqlistuser(imei) { //获取设备信息
  101. const res = await this.$myRequest({
  102. url: '/api/api_gateway?method=sex_lure_nl.sex_lure.nl_device_list',
  103. data: {
  104. device_id: imei,
  105. }
  106. })
  107. console.log(res)
  108. this.moddata = res.data[0]
  109. this.selectaddress(this.moddata.lng, this.moddata.lat)
  110. },
  111. btn() {
  112. this.eqlistcity(this.moddata.lat, this.moddata.lng)
  113. this.eqlistname()
  114. uni.removeStorage({
  115. key: "location"
  116. })
  117. this.clickLeft()
  118. },
  119. clickLeft() {
  120. uni.navigateBack({
  121. delta:1
  122. })
  123. },
  124. amendcity() { //修改设备地址
  125. if(this.quanxian.cityalter){
  126. this.selectcityTF = true
  127. uni.navigateTo({
  128. url: "../fourBase/city"
  129. })
  130. }else{
  131. uni.showToast({
  132. title: "您暂无权限进行此操作,如有需要,请联系管理员",
  133. icon: "none"
  134. })
  135. }
  136. },
  137. selectaddress(lng, lat) { //获取分布位置
  138. uni.request({
  139. type: "GET",
  140. url: "https://restapi.amap.com/v3/geocode/regeo?output=JSON&location=" + lng + "," + lat +
  141. "&key=27273b81090f78759e4057f94474516f&radius=1000&extensions=all",
  142. dataType: "json",
  143. complete: ress => {
  144. // console.log(ress)
  145. if (ress.data.regeocode.formatted_address.length == 0) {
  146. this.city = "--"
  147. } else {
  148. this.city = ress.data.regeocode.formatted_address
  149. }
  150. }
  151. });
  152. },
  153. },
  154. onLoad(option) {
  155. console.log(option)
  156. if(option.id==10){
  157. this.xyeqlistuser(JSON.parse(option.data).device_id)
  158. }else{
  159. this.eqlistuser(option.id, JSON.parse(option.data).imei)
  160. }
  161. uni.getStorage({
  162. key:"jurisdiction",
  163. success:(res)=>{
  164. console.log(JSON.parse(res.data))
  165. let items = JSON.parse(res.data).filter((item)=>{
  166. return item.purview_name == "设备管理"
  167. })
  168. let items2 = items[0].children.filter((item)=>{
  169. return item.purview_name == "设备列表"
  170. })
  171. this.quanxian.namealter = items2[0].children.some((item)=>{
  172. return item.purview_name == "修改名称"
  173. })
  174. this.quanxian.cityalter = items2[0].children.some((item)=>{
  175. return item.purview_name == "添加位置"
  176. })
  177. this.quanxian.infoalter = items2[0].children.some((item)=>{
  178. return item.purview_name == "修改名称" || item.purview_name == "添加位置"
  179. })
  180. },
  181. })
  182. },
  183. onShow(){
  184. uni.getStorage({
  185. key: "location",
  186. success: (res) => {
  187. // console.log(res);
  188. this.moddata.lat = res.data[1]
  189. this.moddata.lng = res.data[0]
  190. this.selectaddress(this.moddata.lng, this.moddata.lat)
  191. }
  192. })
  193. }
  194. }
  195. </script>
  196. <style lang="scss">
  197. page{
  198. background-color: #FAFAFA;
  199. }
  200. .mod {
  201. width: 100%;
  202. position: absolute;
  203. top: 44px;
  204. .mod_name,
  205. .mod_id,
  206. .mod_user,
  207. .mod_time,
  208. .mod_city {
  209. width: 90%;
  210. margin: 30rpx auto;
  211. display: flex;
  212. justify-content: space-between;
  213. background-color: #FFFFFF;
  214. padding: 20rpx 10rpx;
  215. color: #57C77A;
  216. line-height: 50rpx;
  217. .namebg{
  218. background-color: #FAFAFA;
  219. }
  220. input {
  221. text-align: right;
  222. font-size: 28rpx;
  223. padding: 10rpx;
  224. }
  225. }
  226. }
  227. .sub {
  228. width: 90%;
  229. margin: 30rpx auto;
  230. text-align: center;
  231. height: 70rpx;
  232. line-height: 70rpx;
  233. background-color: #57C77A;
  234. border-radius: 35rpx;
  235. color: #FFFFFF;
  236. }
  237. </style>