powerCut.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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"/>
  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. deleteStatus: false
  138. };
  139. },
  140. onReachBottom() { //上拉触底函数
  141. if (!this.isLoadMore) { //此处判断,上锁,防止重复请求
  142. this.isLoadMore = true
  143. this.currentPage += 1;
  144. this.loadData()
  145. }
  146. },
  147. onLoad: function(option) {
  148. // this.getDataList({"status_value":1})
  149. this.loadData()
  150. },
  151. methods: {
  152. //编辑
  153. editItem(item) {
  154. uni.redirectTo({
  155. url: '/pages/eleControl/powerCut/powerCutAdd/powerCutAdd?id=' + item.id + '&status_value=' +
  156. this.status_value + '',
  157. });
  158. },
  159. //筛选
  160. searchSiteList() {
  161. this.currentPage = 1,
  162. this.planListData = []
  163. this.loadData()
  164. },
  165. loadData() {
  166. this.getDataList({
  167. "site_name": this.site_name,
  168. "status_value": this.status_value,
  169. "currentPage": this.currentPage,
  170. "size": this.size,
  171. })
  172. },
  173. //删除
  174. deleteItem(item) {
  175. this.deleteStatus = true
  176. uni.showModal({
  177. title: '确认删除吗?',
  178. content: '',
  179. success: function(result) {
  180. if (result.confirm) {
  181. this.setDelSite({
  182. "id": item.id
  183. })
  184. } else if (result.cancel) {
  185. // console.log('用户点击取消');
  186. }
  187. }.bind(this)
  188. });
  189. },
  190. async setDelSite(ming = {}) {
  191. const res = await this.$myRequest({
  192. url: 'BlackoutPlan/delBlackoutPlan',
  193. data: ming
  194. })
  195. if (!res.data.flag) {
  196. uni.showToast({
  197. title: "删除失败",
  198. icon: "none"
  199. });
  200. } else {
  201. uni.showToast({
  202. title: "删除成功",
  203. });
  204. setTimeout(() => {
  205. this.loadData()
  206. }, 1000);
  207. }
  208. },
  209. //数据请求
  210. async getDataList(params = {}) {
  211. const res = await this.$myRequest({
  212. url: 'BlackoutPlan/getBlackoutPlanList',
  213. showLoading: true,
  214. data: params
  215. })
  216. // console.log('res.data.data')
  217. // console.log(res.data.data)
  218. // this.planListData = res.data.data
  219. if (this.deleteStatus) {
  220. this.planListData = [];
  221. this.deleteStatus = false;
  222. }
  223. if (res.data.data.length) {
  224. this.planListData = this.planListData.concat(res.data.data)
  225. if (res.data.data.length < this.size) { //判断接口返回数据量小于请求数据量,则表示此为最后一页
  226. this.isLoadMore = true
  227. this.loadStatus = 'nomore'
  228. } else {
  229. this.loadStatus = 'loading'
  230. this.isLoadMore = false
  231. }
  232. } else {
  233. this.isLoadMore = true
  234. this.loadStatus = 'nomore'
  235. }
  236. },
  237. tabSelect(e) {
  238. console.log(e.currentTarget);
  239. this.currentPage = 1,
  240. this.planListData = [],
  241. this.site_name = '',
  242. this.TabCur = e.currentTarget.dataset.id;
  243. // this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60;
  244. this.status_value = e.currentTarget.dataset.status;
  245. this.modalName = null;
  246. this.loadData()
  247. },
  248. goAddPage(id) {
  249. uni.redirectTo({
  250. url: '/pages/eleControl/powerCut/powerCutAdd/powerCutAdd',
  251. });
  252. },
  253. goDetail(id) {
  254. uni.navigateTo({
  255. url: '/pages/eleControl/powerCut/powerCutDetail/powerCutDetail?id=' + id + '&&status_value=' +
  256. this.status_value,
  257. });
  258. },
  259. // ListTouch触摸开始
  260. ListTouchStart(e) {
  261. this.listTouchStart = e.touches[0].pageX;
  262. },
  263. // ListTouch计算方向
  264. ListTouchMove(e) {
  265. this.listTouchDirection = e.touches[0].pageX - this.listTouchStart < -80 ? 'left' : 'right'
  266. },
  267. // ListTouch计算滚动
  268. ListTouchEnd(e) {
  269. if (this.listTouchDirection == 'left') {
  270. this.modalName = e.currentTarget.dataset.target
  271. } else {
  272. this.modalName = null
  273. }
  274. this.listTouchDirection = null
  275. }
  276. }
  277. }
  278. </script>
  279. <style lang="scss">
  280. //已处理未处理消息个数样式
  281. .cu-list.menu-avatar .cu-item {
  282. height: 89px;
  283. }
  284. .nav .cu-item.cur {
  285. position: relative;
  286. border-bottom: 8rpx solid;
  287. }
  288. .cu-tag.badge {
  289. top: 14rpx;
  290. right: 42rpx;
  291. }
  292. .nav .cu-item {
  293. width: 33.333%;
  294. margin: 0;
  295. .text-blue,
  296. .line-blue,
  297. .lines-blue {
  298. color: #4274E7
  299. }
  300. }
  301. .cu-list.eleDoing>.cu-item.move-cur {
  302. -webkit-transform: translateX(-66px);
  303. }
  304. </style>