powerCut.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <view class="processWrapper ">
  3. <view style="height:196rpx"></view>
  4. <view class="ding">
  5. <scroll-view scroll-x class="bg-white nav text-center">
  6. <view class="cu-item" :class="index==TabCur?'text-blue cur':''" v-for="(item,index) in tabNav"
  7. :key="index" @tap="tabSelect" :data-id="index" :data-status="index+1">
  8. <!-- <view v-if="TabCur==index" class="cu-tag badge">
  9. <block class="cu-tag badge">{{TabCur? unporcessList.length:porcessedList.length}} </block>
  10. </view> -->
  11. {{item}}
  12. </view>
  13. </scroll-view>
  14. <!-- 筛选框start -->
  15. <view class="cu-bar search bg-gray filter-section">
  16. <view class="search-form round bg-white">
  17. <text class="cuIcon-search"></text>
  18. <input class="" type="text" placeholder="请输入站点名称" v-model="site_name"></input>
  19. </view>
  20. <view class="action">
  21. <button class="cu-btn bg-blue round" @click="searchSiteList">查询</button>
  22. </view>
  23. </view>
  24. <!-- 筛选框end -->
  25. </view>
  26. <!-- 未执行 -->
  27. <block v-if="TabCur==0">
  28. <view style=" height: calc(100vh - 400rpx);">
  29. <view class="cu-list menu-avatar">
  30. <view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''"
  31. @touchstart="ListTouchStart" @touchmove="ListTouchMove" @touchend="ListTouchEnd"
  32. :data-target="'move-box-' + index" v-for="(item,index) in planListData" :key="index"
  33. @tap="goDetail(item.id)">
  34. <view class="cu-avatar lg" style="background-image:url(../../../static/unprocessIcon.png);">
  35. </view>
  36. <view class="content" style="width:460rpx">
  37. <view class="pro-title">
  38. <view class="cut inOneLine">{{item.site_name}}</view>
  39. </view>
  40. <view class="pro-date ">{{item.start_time}}</view>
  41. </view>
  42. <view class="action" style="z-index:99">
  43. <view class="unProcess" @tap="goUnprocessDetail(item.id)">未执行</view>
  44. </view>
  45. <view class="move">
  46. <view class="bg-grey" @click.stop="editItem(item)">编辑</view>
  47. <view class="bg-red" @click.stop="deleteItem(item)">删除</view>
  48. </view>
  49. </view>
  50. <view class=" text-center margin-top" v-if="planListData.length === 0">暂无数据...</view>
  51. <view v-show="isLoadMore&&planListData.length!= 0&&currentPage>1">
  52. <uni-load-more :status="loadStatus"></uni-load-more>
  53. </view>
  54. </view>
  55. </view>
  56. </block>
  57. <!-- 执行中 -->
  58. <block v-if="TabCur==1">
  59. <view style=" height: calc(100vh - 400rpx);">
  60. <view class="cu-list menu-avatar eleDoing">
  61. <view class="cu-item " :class="modalName=='move-box-'+ index?'move-cur':''"
  62. @touchstart="ListTouchStart" @touchmove="ListTouchMove" @touchend="ListTouchEnd"
  63. :data-target="'move-box-' + index" v-for="(item,index) in planListData" :key="index"
  64. @tap="goDetail(item.id)">
  65. <view class="cu-avatar lg" style="background-image:url(../../../static/processingIcon.png);">
  66. </view>
  67. <view class="content" style="width:460rpx">
  68. <view class="pro-title">
  69. <view class="cut inOneLine">{{item.site_name}}</view>
  70. </view>
  71. <view class="pro-date ">{{item.start_time}}</view>
  72. </view>
  73. <view class="action" style="z-index:99">
  74. <view class="processing" @tap="goProcessedDetail(item.id)">执行中</view>
  75. </view>
  76. <view class="move" style="width: 66px;" >
  77. <view class="bg-grey"@click.stop="editItem(item)">编辑</view>
  78. <!-- <view class="bg-red" @click.stop="deleteItem(item)">删除</view> -->
  79. </view>
  80. </view>
  81. <view class="text-center margin-top" v-if="planListData.length === 0">暂无数据...</view>
  82. <view v-show="isLoadMore&&planListData.length!= 0&&currentPage>1">
  83. <uni-load-more :status="loadStatus"></uni-load-more>
  84. </view>
  85. </view>
  86. </view>
  87. </block>
  88. <!-- 已执行 -->
  89. <block v-if="TabCur==2">
  90. <view style=" height: calc(100vh - 400rpx);">
  91. <view class="cu-list menu-avatar ">
  92. <view class="cu-item" v-for="(item,index) in planListData" :key="index" @tap="goDetail(item.id)">
  93. <view class="cu-avatar lg" style="background-image:url(../../../static/processedIcon.png);">
  94. </view>
  95. <view class="content" style="width:460rpx">
  96. <view class="pro-title">
  97. <view class="cut inOneLine">{{item.site_name}}</view>
  98. </view>
  99. <view class="pro-date ">{{item.start_time}}</view>
  100. </view>
  101. <view class="action" style="z-index:99">
  102. <view class="processed" @tap="goProcessedDetail(item.id)">已执行</view>
  103. </view>
  104. </view>
  105. <view class="text-center margin-top" v-if="planListData.length === 0">暂无数据...</view>
  106. <view v-show="isLoadMore&&planListData.length != 0&&this.currentPage>1">
  107. <uni-load-more :status="loadStatus"></uni-load-more>
  108. </view>
  109. </view>
  110. </view>
  111. </block>
  112. <!-- 新增按钮start -->
  113. <view class="plus">
  114. <image src="../../../static/plus.png" style="width:100rpx;height:100rpx" @tap="goAddPage()"></image>
  115. </view>
  116. <!-- 新增按钮end -->
  117. </view>
  118. </template>
  119. <script>
  120. export default {
  121. data() {
  122. return {
  123. modalName: null,
  124. listTouchStart: 0,
  125. listTouchDirection: null,
  126. type: '0',
  127. CustomBar: this.CustomBar,
  128. TabCur: 0,
  129. tabNav: ['未执行', '执行中', '已执行', ],
  130. planListData:[],
  131. site_name:'',
  132. status_value:1,
  133. currentPage: 1,
  134. size: 10,
  135. loadStatus: 'loading', //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
  136. isLoadMore: false, //是否加载中
  137. };
  138. },
  139. onReachBottom() { //上拉触底函数
  140. if (!this.isLoadMore) { //此处判断,上锁,防止重复请求
  141. this.isLoadMore = true
  142. this.currentPage += 1;
  143. this.loadData()
  144. }
  145. },
  146. onLoad: function(option) {
  147. // this.getDataList({"status_value":1})
  148. this.loadData()
  149. },
  150. methods: {
  151. //编辑
  152. editItem(item) {
  153. uni.navigateTo({
  154. url: '/pages/eleControl/powerCut/powerCutAdd/powerCutAdd?id=' + item.id + '&status_value=' + this.status_value + '',
  155. });
  156. },
  157. //筛选
  158. searchSiteList() {
  159. this.currentPage=1,
  160. this.planListData=[]
  161. this.loadData()
  162. },
  163. loadData(){
  164. this.getDataList({
  165. "site_name": this.site_name,
  166. "status_value":this.status_value,
  167. "currentPage": this.currentPage,
  168. "size": this.size,
  169. })
  170. },
  171. //删除
  172. deleteItem(item) {
  173. uni.showModal({
  174. title: '确认删除吗?',
  175. content: '',
  176. success: function(result) {
  177. if (result.confirm) {
  178. this.setDelSite({
  179. "id": item.id
  180. })
  181. } else if (result.cancel) {
  182. // console.log('用户点击取消');
  183. }
  184. }.bind(this)
  185. });
  186. },
  187. async setDelSite(ming = {}) {
  188. const res = await this.$myRequest({
  189. url: 'BlackoutPlan/delBlackoutPlan',
  190. data: ming
  191. })
  192. if (!res.data.flag) {
  193. uni.showToast({
  194. title: "删除失败",
  195. icon: "none"
  196. });
  197. }else{
  198. uni.showToast({
  199. title: "删除成功",
  200. });
  201. setTimeout(() => {
  202. this.loadData()
  203. }, 1000);
  204. }
  205. },
  206. //数据请求
  207. async getDataList(params = {}) {
  208. const res = await this.$myRequest({
  209. url: 'BlackoutPlan/getBlackoutPlanList',
  210. showLoading: true,
  211. data: params
  212. })
  213. // console.log('res.data.data')
  214. // console.log(res.data.data)
  215. // this.planListData = res.data.data
  216. if (res.data.data.length) {
  217. this.planListData = this.planListData.concat(res.data.data)
  218. if (res.data.data.length < this.size) { //判断接口返回数据量小于请求数据量,则表示此为最后一页
  219. this.isLoadMore = true
  220. this.loadStatus = 'nomore'
  221. } else {
  222. this.loadStatus='loading'
  223. this.isLoadMore = false
  224. }
  225. } else {
  226. this.isLoadMore = true
  227. this.loadStatus = 'nomore'
  228. }
  229. },
  230. tabSelect(e) {
  231. console.log(e.currentTarget);
  232. this.currentPage=1,
  233. this.planListData=[],
  234. this.site_name='',
  235. this.TabCur = e.currentTarget.dataset.id;
  236. // this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60;
  237. this.status_value=e.currentTarget.dataset.status;
  238. this.modalName=null;
  239. this.loadData()
  240. },
  241. goAddPage(id) {
  242. uni.navigateTo({
  243. url: '/pages/eleControl/powerCut/powerCutAdd/powerCutAdd',
  244. });
  245. },
  246. goDetail(id) {
  247. uni.navigateTo({
  248. url: '/pages/eleControl/powerCut/powerCutDetail/powerCutDetail?id='+id+'&&status_value='+this.status_value,
  249. });
  250. },
  251. // ListTouch触摸开始
  252. ListTouchStart(e) {
  253. this.listTouchStart = e.touches[0].pageX;
  254. },
  255. // ListTouch计算方向
  256. ListTouchMove(e) {
  257. this.listTouchDirection = e.touches[0].pageX - this.listTouchStart < -80 ? 'left' : 'right'
  258. },
  259. // ListTouch计算滚动
  260. ListTouchEnd(e) {
  261. if (this.listTouchDirection == 'left') {
  262. this.modalName = e.currentTarget.dataset.target
  263. } else {
  264. this.modalName = null
  265. }
  266. this.listTouchDirection = null
  267. }
  268. }
  269. }
  270. </script>
  271. <style lang="scss">
  272. //已处理未处理消息个数样式
  273. .cu-list.menu-avatar .cu-item {
  274. height: 89px;
  275. }
  276. .nav .cu-item.cur {
  277. position: relative;
  278. border-bottom: 8rpx solid;
  279. }
  280. .cu-tag.badge {
  281. top: 14rpx;
  282. right: 42rpx;
  283. }
  284. .nav .cu-item {
  285. width: 33.333%;
  286. margin: 0;
  287. .text-blue,
  288. .line-blue,
  289. .lines-blue {
  290. color: #4274E7
  291. }
  292. }
  293. .cu-list.eleDoing>.cu-item.move-cur {
  294. -webkit-transform: translateX(-66px);
  295. }
  296. </style>