stationAdd.vue 7.1 KB

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