equipmentName.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <template>
  2. <view class="">
  3. <view class="xiugai">
  4. {{$t('equipmentname.title')}}
  5. </view>
  6. <view v-for="(list,index) in equipmentList" :key="index" class="body">
  7. <view class="input-two">
  8. <input :id=list.id type="text" class="input" @focus="setStyle()" @blur="setStyle2()" :value="list.name==null? list.clientId:list.name" @input="getValue" />
  9. <p id="p2" class="p2" :style="{display:showOrNo}">如:粤A张先生1</p>
  10. </view>
  11. <view class="button2">
  12. <button type="primary" @click="updata1()" class="button">
  13. <p class="p">{{$t('equipmentname.updata')}}</p>
  14. </button>
  15. </view>
  16. </view>
  17. <view v-if="btnShow" class="button-container">
  18. <button v-if="upBtn" class="left-button" :disabled="isLoading" @click="previousPage">{{$t('equipmentStatusList.previousPage')}}</button>
  19. <button v-if="nextBtn" class="right-button" :disabled="isLoading" @click="nextPage">{{$t('equipmentStatusList.nextPage')}}</button>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import {
  25. mapState,
  26. mapActions,
  27. mapMutations
  28. } from 'vuex'
  29. export default {
  30. data() {
  31. return {
  32. name: '',
  33. show: false,
  34. listName: [],
  35. equipmentList: [],
  36. value: null,
  37. id: null,
  38. parm: {
  39. name: null,
  40. id: null
  41. },
  42. showOrNo: null,
  43. avatarUrl: null,
  44. weixinUp: false,
  45. weixinDown: true,
  46. btnShow:false, // 按钮显示
  47. upBtn:false, // 上一页按钮
  48. nextBtn:true, // 下一页按钮
  49. equipmentTotal:0, // 设备总数
  50. isLoading: false, //是否加载中
  51. };
  52. },
  53. onPullDownRefresh() {
  54. setTimeout(function() {
  55. uni.stopPullDownRefresh();
  56. }, 800);
  57. },
  58. onShow() {
  59. uni.setNavigationBarTitle({title: this.$t('equipmentname.title')});
  60. // uni.startPullDownRefresh();
  61. this.globalUser = uni.getStorageSync("globalUser");
  62. this.globalUser.offset = 0;
  63. this.globalUser.limit = 10;
  64. var token = uni.getStorageSync("token");
  65. if (token.length > 1) {
  66. this.getEquipmentListData();
  67. this.upBtn = false;
  68. this.nextBtn = true;
  69. } else {
  70. uni.reLaunch({
  71. url: '../Login/Login',
  72. });
  73. }
  74. // var me = this;
  75. // var name = uni.getStorageSync("name");
  76. // me.name = name;
  77. // var listName = uni.getStorageSync("listName");
  78. // me.listName = listName;
  79. // if (listName != '' && listName != null) {
  80. // var adminId = listName[0].adminId;
  81. // if (adminId != '1' && adminId != null) {
  82. // me.show = true;
  83. // }
  84. // }
  85. // var newparm = uni.getStorageSync("newparm");
  86. // if (newparm.toString().length > 1) {
  87. // if (newparm.avatarUrl.length > 1) {
  88. // this.avatarUrl = newparm.avatarUrl;
  89. // this.weixinUp = true;
  90. // this.weixinDown = false;
  91. // }
  92. // }
  93. },
  94. onLoad() {
  95. },
  96. methods: {
  97. setStyle() {
  98. this.showOrNo = "block";
  99. },
  100. setStyle2() {
  101. this.showOrNo = "none";
  102. },
  103. getValue: function(event) {
  104. // 绕过v-model 获取input输入框的值
  105. var value = event.target.value;
  106. var id = event.target.id;
  107. this.value = value;
  108. this.id = id;
  109. this.parm.name = value;
  110. this.parm.id = id;
  111. },
  112. getEquipmentListData() {
  113. this.isLoading = true;
  114. this.getEquipmentListByUser(this.globalUser)
  115. .then(data => {
  116. this.equipmentList = data[0].equipmentList;
  117. this.equipmentTotal = data[0].equipmentTotal;
  118. if(this.equipmentTotal > this.globalUser.limit) {
  119. this.btnShow = true;
  120. }
  121. console.log(this.equipmentList);
  122. this.isLoading = false;
  123. }, _ => void uni.stopPullDownRefresh());
  124. },
  125. // 更改按钮显示状态
  126. changeBtnshow() {
  127. if(this.globalUser.offset != 0) {
  128. this.upBtn = true;
  129. } else {
  130. this.upBtn = false;
  131. }
  132. if(this.globalUser.offset + this.globalUser.limit < this.equipmentTotal) {
  133. this.nextBtn = true;
  134. } else {
  135. this.nextBtn = false;
  136. }
  137. },
  138. // 点击上一页
  139. previousPage() {
  140. this.globalUser.offset = this.globalUser.offset - this.globalUser.limit;
  141. this.getEquipmentListData();
  142. this.changeBtnshow();
  143. },
  144. // 点击下一页
  145. nextPage() {
  146. this.globalUser.offset = this.globalUser.offset + this.globalUser.limit;
  147. this.getEquipmentListData();
  148. this.changeBtnshow();
  149. },
  150. ...mapActions('chart', ['updata', 'getEquipmentListByUser']),
  151. updata1() {
  152. if (this.parm.id != null) {
  153. this.updata(this.parm)
  154. .then(res => {
  155. uni.showModal({
  156. title: '提示',
  157. content: '名称:' + this.parm.name + res.message,
  158. });
  159. }, _ => void uni.stopPullDownRefresh());
  160. }
  161. }
  162. }
  163. }
  164. </script>
  165. <style>
  166. .settings {
  167. width: 100upx;
  168. height: 64upx;
  169. border-radius: 10upx;
  170. background: #D6101F;
  171. /* padding-right: 50upx; */
  172. /* padding-top: 5upx; */
  173. text-align: center;
  174. margin: 0 auto;
  175. }
  176. .p3 {
  177. /* #ifdef H5 */
  178. top: -13%;
  179. /* #endif */
  180. font-size: 32upx;
  181. color: #FFFFFF;
  182. font-weight: bold;
  183. width: 100upx;
  184. height: 64upx;
  185. /* #ifndef H5 */
  186. padding-top: 3upx;
  187. /* #endif */
  188. position: absolute;
  189. /* 水平居中 */
  190. left: 50%;
  191. -webkit-transform: translateX(-50%);
  192. transform: translateX(-50%);
  193. }
  194. .centerY {
  195. position: absolute;
  196. top: 50%;
  197. -webkit-transform: translateY(-50%);
  198. transform: translateY(-50%);
  199. }
  200. .button2 {
  201. padding-right: 60upx;
  202. padding-top: 2upx;
  203. }
  204. .button {
  205. /* padding: 5upx 10upx 10upx 0upx; */
  206. width: 120upx;
  207. height: 60upx;
  208. border-radius: 10upx;
  209. }
  210. .p {
  211. /* #ifdef H5 */
  212. top: -13%;
  213. /* #endif */
  214. width: 80upx;
  215. height: 60upx;
  216. font-size: 30upx;
  217. /* #ifndef H5 */
  218. padding-top: 3upx;
  219. /* #endif */
  220. position: absolute;
  221. /* 水平居中 */
  222. left: 50%;
  223. -webkit-transform: translateX(-50%);
  224. transform: translateX(-50%);
  225. }
  226. .input {
  227. /* padding: 10upx 20upx 10upx 0upx; */
  228. padding-left: 20upx;
  229. padding-top: 10upx;
  230. background-color: #FFFFFF;
  231. width: 500upx;
  232. height: 50upx;
  233. box-shadow: 0upx 0upx 20upx #D3D3D3;
  234. border-radius: 5upx;
  235. }
  236. .xiugai {
  237. width: 92%;
  238. border-left: 20upx;
  239. border-left: 10upx solid #206DC3;
  240. padding-left: 10upx;
  241. height: 38upx;
  242. padding-bottom: 20upx;
  243. font-family: "PingFang-SC-Bold";
  244. font-weight: bold;
  245. margin: auto;
  246. font-size: 32upx;
  247. color: #363D44;
  248. }
  249. .xiugai2 {
  250. width: 100%;
  251. height: 80upx;
  252. font-family: "PingFang-SC-Bold";
  253. font-weight: bold;
  254. margin: auto;
  255. font-size: 50upx;
  256. color: #363D44;
  257. position: fixed;
  258. bottom: 0;
  259. }
  260. .xiugai3 {
  261. height: 80upx;
  262. font-family: "PingFang-SC-Bold";
  263. font-weight: bold;
  264. margin: auto;
  265. font-size: 40upx;
  266. color: #363D44;
  267. }
  268. .body {
  269. background-color: #FFFFFF;
  270. padding: 10upx 10upx 10upx 10upx;
  271. display: flex;
  272. flex-direction: row;
  273. justify-content: flex-start;
  274. }
  275. .input-two {
  276. width: 600upx;
  277. height: 100upx;
  278. padding-left: 30upx;
  279. }
  280. .p2 {
  281. color: #DD524D;
  282. display: none;
  283. width: 600upx;
  284. height: 50upx;
  285. border: 1px;
  286. }
  287. .button-container {
  288. display: flex;
  289. }
  290. .left-button,
  291. .right-button {
  292. flex: 1;
  293. }
  294. </style>