powerCut.vue 9.1 KB

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