stationAdd.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <template>
  2. <view>
  3. <u-navbar title="关联场站管理" title-color="#101010"></u-navbar>
  4. <view class="top">
  5. <view class="search">
  6. <view class="searchBox">
  7. <u-search shape="square" placeholder="搜索停车场、设备编号" maxlength="12" v-model="testName"
  8. :show-action="false" :animation="true"></u-search>
  9. <u-button type="primary" size="mini" @click="testBtn">搜素</u-button>
  10. </view>
  11. </view>
  12. </view>
  13. <view class="list">
  14. <view class="item" v-for="(item,index) in list"
  15. @click="userHaveBtn(item)"
  16. :key="index">
  17. <view class="b1">
  18. <view class="v1">
  19. {{item.stationNo}}<span class="y">|</span>{{item.name}}
  20. </view>
  21. <view class="v2" v-if="item.stationAddress">
  22. {{item.stationAddress}}
  23. </view>
  24. </view>
  25. <u-icon v-if="radiovalue"
  26. color="red"
  27. size="40"
  28. name="minus-circle-fill"
  29. ></u-icon>
  30. <u-icon v-else-if="!item.userHave"
  31. color="#1677FF"
  32. size="40"
  33. name="plus-circle-fill"
  34. ></u-icon>
  35. <u-icon v-else
  36. color="red"
  37. size="40"
  38. name="minus-circle-fill"
  39. ></u-icon>
  40. </view>
  41. <u-divider :isnone="list.length==0" nonetext="没有找到相关内容" border-color="#CFD2D5">已经到底了</u-divider>
  42. </view>
  43. <view class="floating-button">
  44. <u-checkbox-group>
  45. <u-checkbox v-model="radiovalue" @change="radioChange"
  46. shape="circle">全选</u-checkbox>
  47. </u-checkbox-group>
  48. <view class="button " @click="submit">
  49. 关联场站
  50. </view>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. import * as API from '@/apis/pagejs/pagesTeam.js'
  56. export default {
  57. data() {
  58. return {
  59. addInfo:{},
  60. list: [],
  61. listForm: {
  62. pageIndex: 1,
  63. pageSize: 15,
  64. recordsTotal: 1,
  65. status: 0,
  66. roleName: "XJ,XJADMIN",
  67. roleName: "XJ",
  68. },
  69. radiovalue:false,
  70. id: "",
  71. testName: "",
  72. queryName: "",
  73. };
  74. },
  75. onLoad(op) {
  76. this.id = op.id
  77. this.getInfo()
  78. this.getList()
  79. },
  80. onShow() {
  81. },
  82. onReachBottom() {
  83. if (this.list.length < this.listForm.recordsTotal) {
  84. this.myLoadmore();
  85. }
  86. },
  87. methods: {
  88. userHaveBtn(item){
  89. if(this.radiovalue){
  90. this.radiovalue=false
  91. this.list.forEach(item=>{
  92. item.userHave=false
  93. })
  94. }
  95. item.userHave=!item.userHave
  96. },
  97. getInfo() {
  98. API.teamUser({
  99. id:this.id
  100. }).then((res) => {
  101. this.addInfo=res.data.user
  102. if(this.addInfo.authorizedStationEnabled==false){
  103. this.radiovalue=true
  104. }
  105. }).catch(error => {
  106. uni.hideLoading();
  107. uni.showToast({
  108. title: error,
  109. icon: "none"
  110. })
  111. })
  112. },
  113. myLoadmore() {
  114. this.listForm.pageIndex += 1;
  115. this.getList()
  116. },
  117. submit(){
  118. var list=[]
  119. var str=""
  120. if(this.radiovalue){
  121. str="-1"
  122. }else{
  123. list=this.list.filter(item=>{
  124. return item.userHave
  125. })
  126. var str=list.map(item=>{
  127. return item.id
  128. }).join(',')
  129. }
  130. uni.showLoading({
  131. title: "加载中",
  132. mask: true,
  133. })
  134. API.updateUserStation({
  135. id:this.id,
  136. stationIds:str,
  137. }).then((res) => {
  138. const eventChannel = this.getOpenerEventChannel();
  139. eventChannel.emit('acceptDataFromOpenerPage', {})
  140. uni.hideLoading();
  141. uni.showModal({
  142. title: '提示',
  143. showCancel: false,
  144. content: "操作成功",
  145. success: res1 => {
  146. if (res1.confirm) {
  147. uni.navigateBack()
  148. } else if (res1.cancel) {
  149. //('用户点击取消');
  150. }
  151. }
  152. })
  153. }).catch(error => {
  154. uni.hideLoading();
  155. uni.showToast({
  156. title: error,
  157. icon: "none"
  158. })
  159. })
  160. },
  161. radioChange(e){
  162. console.log(e,this.radiovalue)
  163. },
  164. showqueryName(item) {
  165. if (this.queryName) {
  166. var name = item.stationName+item.stationNo
  167. return name.indexOf(this.queryName) != -1
  168. } else {
  169. return true
  170. }
  171. },
  172. testBtn() {
  173. this.queryName = this.testName
  174. this.getList(1)
  175. },
  176. getList(bl) {
  177. if (bl) {
  178. this.listForm.pageIndex = 1
  179. }
  180. uni.showLoading({
  181. title: "加载中",
  182. mask: true,
  183. })
  184. this.listForm.id = this.id
  185. this.listForm.queryContent=this.queryName
  186. API.teamUserStationUpdateList(this.listForm).then((res) => {
  187. var list = this.list
  188. if (this.listForm.pageIndex == 1) {
  189. list = res.data.data;
  190. } else {
  191. list = [
  192. ...list,
  193. ...res.data.data
  194. ];
  195. }
  196. this.list =list
  197. this.listForm.recordsTotal=res.data.recordsTotal
  198. uni.hideLoading();
  199. }).catch(error => {
  200. uni.hideLoading();
  201. uni.showToast({
  202. title: error,
  203. icon: "none"
  204. })
  205. })
  206. },
  207. }
  208. }
  209. </script>
  210. <style lang="scss" scoped>
  211. .list {
  212. padding-top: 20rpx;
  213. padding-bottom: 60px;
  214. .item:not(:last-child) {
  215. border-bottom: 2rpx solid rgba(232, 232, 232, 1);
  216. }
  217. .item {
  218. padding: 24rpx 32rpx;
  219. background: #fff;
  220. // display: flex;
  221. // flex-direction: column;
  222. display: flex;
  223. flex-direction: row;
  224. justify-content: space-between;
  225. .vquery {
  226. display: flex;
  227. align-items: center;
  228. }
  229. .buildMode {
  230. font-size: 24rpx;
  231. border: 2rpx solid #bbbbbb;
  232. border-radius: 8rpx;
  233. color: #1677ff;
  234. padding: 2rpx 8rpx;
  235. margin: 0 8rpx;
  236. }
  237. .buildMode1 {
  238. color: #1677ff;
  239. border: 2rpx solid #1677ff;
  240. }
  241. .buildMode2 {
  242. color: #4CAF50;
  243. border: 2rpx solid #4CAF50;
  244. }
  245. .qName {
  246. color: #FF5100
  247. }
  248. .v1 {
  249. color: rgba(16, 16, 16, 1);
  250. font-size: 32rpx;
  251. }
  252. .y {
  253. margin: 0 8rpx;
  254. color: rgba(119, 119, 119, 1);
  255. }
  256. .v2 {
  257. color: rgba(119, 119, 119, 1);
  258. font-size: 24rpx;
  259. }
  260. }
  261. }
  262. .top {
  263. border-bottom: 2rpx solid #e8e8e8;
  264. }
  265. .search {
  266. padding: 16rpx 32rpx;
  267. background: #fff;
  268. .searchBox {
  269. display: flex;
  270. align-items: center;
  271. background: #F2F2F2;
  272. padding: 2rpx 16rpx;
  273. border-radius: 16rpx;
  274. justify-content: space-between;
  275. }
  276. }
  277. .floating-button {
  278. z-index: 999;
  279. position: fixed;
  280. bottom: 0;
  281. width: 100%;
  282. display: flex;
  283. height: 120rpx;
  284. justify-content: space-around;
  285. background-color: rgba(255, 255, 255, 1);
  286. .button {
  287. margin-top: 24rpx;
  288. border-radius: 50px;
  289. height: 80rpx;
  290. width: 60%;
  291. display: flex;
  292. align-items: center;
  293. justify-content: center;
  294. padding: 12rpx;
  295. background-color: rgba(22, 119, 255, 1);
  296. color: rgba(255, 255, 255, 1);
  297. font-size: 32rpx;
  298. }
  299. }
  300. </style>