risk.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <template>
  2. <view class="container">
  3. <u-popup :show="showpopup" @close="showpopup=false" :safeAreaInsetBottom='false' :round="10">
  4. <view class="popupmain">
  5. <view class="popup_title">
  6. <text>筛选</text>
  7. </view>
  8. <view class="line">
  9. </view>
  10. <u-datetime-picker :show="show" @confirm='confirm1' @cancel='show=false'
  11. mode="date"></u-datetime-picker>
  12. <u-datetime-picker :show="show2" @confirm='confirm2' @cancel='show2=false'
  13. mode="date"></u-datetime-picker>
  14. <view class="project">
  15. <view class="project_box">
  16. <view class="title">
  17. 创建开始时间
  18. </view>
  19. <view @click="show=true" class='main'>
  20. <input style='margin-left:10%' type="text" disabled placeholder="请选择"
  21. v-model="popupData.timeStart" />
  22. </view>
  23. </view>
  24. <view class="project_box">
  25. <view class="title">
  26. 创建结束时间
  27. </view>
  28. <view @click="show2=true" class='main'>
  29. <input style='margin-left:10%' type="text" disabled placeholder="请选择"
  30. v-model="popupData.timeEnd" />
  31. </view>
  32. </view>
  33. <view class="project_box" v-for="(item,index) in columns" :key="index">
  34. <view class="title">
  35. {{item.title}}
  36. </view>
  37. <view class="main">
  38. <view class='btns_main' :class="popupData[item.key]===k.id?'primary':''"
  39. @click="changetype(item,k)" style="border-radius: 0.7rem;" v-for="k in item.project"
  40. :key="k.id">{{k.label}}</view>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="popup_btns">
  45. <u-button text="重置" @click="repect"></u-button>
  46. <u-button type="primary" text="确定" @click="surepopup">
  47. </u-button>
  48. </view>
  49. </view>
  50. </u-popup>
  51. <view style="position: relative;">
  52. <view style="display: flex;align-items: center;">
  53. <input placeholder='管线名称'
  54. style="background-color: #F2F2F2;border: none;padding: 3px 10px;border-radius: 1rem;"
  55. :style="'width: 100%;'" v-model="dataForm.lineName" type="text" confirm-type="search"
  56. @confirm="searchs">
  57. <u-icon @click="showpopup = true" style="margin-left: 0.3rem;" size="26" name="list-dot"
  58. color="#C6C7CB"></u-icon>
  59. </view>
  60. <view style="position: absolute;right: 2.5rem;top: 0.4rem;z-index:10"
  61. @click="dataForm.lineName='',getList()">
  62. <u-icon v-if="dataForm.lineName" name="close-circle-fill" color="#C6C7CB"></u-icon>
  63. </view>
  64. </view>
  65. <scroll-list ref="list" style="margin-top: 10rpx;" :option="option" @refresh="refresh"
  66. @scrolltolower="loadMore">
  67. <view class="list-item" :class="item.isHandle=='1'?'red':'green'" v-for="(item, index) in list" :key="index"
  68. @click="handleTest(item)">
  69. <view class="main_box">
  70. <view class="text">
  71. 管线名称 :{{item.lineName}}
  72. </view>
  73. <view class="text">
  74. 管线单元名称 :{{item.lineUnitName}}
  75. </view>
  76. <view class="text">
  77. 风险类型 :{{item.riskCategory}}
  78. </view>
  79. <view class="text">
  80. 风险状态:
  81. <span :style="{ color: item.isHandle=='1'?'red':'green' }">
  82. {{ item.isHandle== 1 ? "未处理" : "已处理"}}
  83. </span>
  84. </view>
  85. </view>
  86. </view>
  87. </scroll-list>
  88. </view>
  89. </template>
  90. <script>
  91. import Config from "@/common/Config.js";
  92. export default {
  93. data() {
  94. return {
  95. showpopup: false,
  96. show: false,
  97. scrollTop: 0,
  98. show2: false,
  99. columns: [{
  100. title: '状态',
  101. key: 'isHandle',
  102. project: [{
  103. label: '未处理',
  104. id: '1'
  105. }, {
  106. label: '已处理',
  107. id: '0'
  108. }]
  109. }],
  110. popupData: {
  111. timeStart: "",
  112. timeEnd: "",
  113. isHandle: ''
  114. },
  115. old: {
  116. scrollTop: 0
  117. },
  118. option: {
  119. size: 5,
  120. auto: true
  121. },
  122. dataForm: {
  123. page: 1,
  124. limit: 10
  125. },
  126. showType: false,
  127. templateIdList: ['JzW-GOYebclYExiTgICih8n5LfO38P7AFP_TAK8E2Ms'],
  128. list: []
  129. }
  130. },
  131. onLoad() {
  132. // #ifdef MP
  133. let that = this
  134. // uni.showModal({
  135. // title: '提示',
  136. // content: '确认进行服务通知提醒系统通知',
  137. // success: function(res) {
  138. // if (res.confirm) {
  139. // that.sureType()
  140. // } else if (res.cancel) {
  141. // console.log('用户点击取消');
  142. // }
  143. // }
  144. // });
  145. // #endif
  146. },
  147. onShow() {
  148. this.list = []
  149. this.dataForm.limit = 10
  150. this.getList()
  151. },
  152. methods: {
  153. sureType() {
  154. let that = this
  155. wx.requestSubscribeMessage({
  156. tmplIds: that.templateIdList,
  157. success(res) {
  158. console.log(res);
  159. },
  160. fail(err) {
  161. console.error('Failed to request subscribe message:', err);
  162. },
  163. complete() {
  164. that.showType = false
  165. }
  166. });
  167. },
  168. gettemplateIdList() {
  169. let that = this
  170. // this.$api.to_http(`/message/WeChat/templateIdList`, "GET").then((res) => {
  171. // if (res.data.code != 0) {
  172. // return uni.$u.toast(res.data.msg)
  173. // }
  174. // that.templateIdList = res.data.data
  175. // })
  176. wx.getSetting({
  177. withSubscriptions: true,
  178. success(res) {
  179. that.showType = true
  180. }
  181. })
  182. },
  183. loadMore() {
  184. // 在触底时,调用加载更多的 API 方法
  185. this.dataForm.limit += 10; // 页数加1
  186. this.getList(); // 获取更多数据
  187. },
  188. changetype(x, k) {
  189. this.popupData[x.key] = k.id
  190. },
  191. searchs(e) {
  192. this.checked = []
  193. this.dataList = []
  194. this.list = []
  195. this.dataForm.limit = 10
  196. this.getList()
  197. },
  198. surepopup() {
  199. this.showpopup = false
  200. this.list = []
  201. this.dataForm.limit = 10
  202. this.dataForm = {
  203. ...this.dataForm,
  204. ...this.popupData
  205. }
  206. this.getList()
  207. },
  208. repect() {
  209. for (let key in this.popupData) {
  210. this.popupData[key] = ''
  211. }
  212. },
  213. confirm1(x) {
  214. this.popupData.timeStart = this.formatTimestamp(x.value)
  215. this.show = false
  216. },
  217. confirm2(x) {
  218. this.popupData.timeEnd = this.formatTimestamp(x.value)
  219. this.show2 = false
  220. },
  221. formatTimestamp(timestamp) {
  222. const date = new Date(timestamp);
  223. const year = date.getFullYear();
  224. const month = (date.getMonth() + 1).toString().padStart(2, '0'); // 月份是从0开始的,所以加1
  225. const day = date.getDate().toString().padStart(2, '0'); // 日期补充为两位数
  226. return `${year}-${month}-${day}`;
  227. },
  228. searchs(e) {
  229. this.checked = []
  230. this.dataList = []
  231. this.list = []
  232. this.dataForm.limit = 10
  233. this.getList()
  234. },
  235. handleTest(x) {
  236. uni.navigateTo({
  237. url: '/pages/risk/riskDetail?data=' + JSON.stringify(x)
  238. })
  239. },
  240. getList() {
  241. this.dataForm.handleUserIds = uni.getStorageSync('userInfo').id
  242. this.$api.to_http(`/pipe/zhkjwurenjipiperisk/getUserPipeRisk`, this.dataForm, 'get').then((res) => {
  243. this.list.push(...res.data.data.list)
  244. this.$refs.list.loadSuccess({
  245. list: this.list,
  246. total: res.data.data.total
  247. });
  248. })
  249. },
  250. // 加载数据
  251. load(paging) {
  252. this.$api.to_http(`/pipe/zhkjwurenjipiperisk/getUserPipeRisk`, this.dataForm, 'get').then((res) => {
  253. let list = [];
  254. for (var i = 0; i < res.data.data.list.length; i++) {
  255. list.push(res.data.data.list[i]);
  256. }
  257. this.list = [...this.list, ...list];
  258. // 加载成功 参数对象{list: 当前列表,total: 数据总长度(后端查询的total)}
  259. this.$refs.list.loadSuccess({
  260. list: this.list,
  261. total: res.data.data.total
  262. });
  263. // 加载失败
  264. // this.$refs.list.loadFail()
  265. })
  266. },
  267. // 刷新刷剧
  268. refresh(paging) {
  269. this.list = []
  270. this.dataForm.limit = 10
  271. this.$api.to_http(`/pipe/zhkjwurenjipiperisk/getUserPipeRisk`, this.dataForm, 'get').then((res) => {
  272. let list = [];
  273. for (var i = 0; i < res.data.data.list.length; i++) {
  274. list.push(res.data.data.list[i]);
  275. }
  276. this.list = list;
  277. // 加载成功 参数对象{list: 当前列表,total: 数据总长度(后端查询的total)}
  278. this.$refs.list.refreshSuccess({
  279. list: this.list,
  280. total: res.data.data.total
  281. });
  282. // 加载失败
  283. // this.$refs.list.loadFail()
  284. })
  285. }
  286. }
  287. }
  288. </script>
  289. <style lang="less" scoped>
  290. .list-item {
  291. font-size: 30rpx;
  292. padding: 10rpx 20rpx;
  293. position: relative;
  294. .main_box {
  295. border-radius: 15rpx;
  296. // border: 1px solid #000;
  297. padding: 30rpx;
  298. background-color: #fff;
  299. .text {
  300. margin: 18rpx 0;
  301. }
  302. }
  303. }
  304. .popupmain {
  305. .popup_title {
  306. padding: 0.5rem 1rem;
  307. text-align: center;
  308. }
  309. .line {
  310. height: 0.4rem;
  311. background-color: #F3F4F6;
  312. }
  313. .project {
  314. padding: 0.6rem;
  315. height: 15rem;
  316. overflow: auto;
  317. .project_box {
  318. margin-bottom: 0.5rem;
  319. .main {
  320. margin-top: 0.5rem;
  321. display: grid;
  322. grid-template-columns: 1fr 1fr 1fr;
  323. // grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  324. grid-gap: 0.8rem;
  325. .btns_main {
  326. height: 40px;
  327. position: relative;
  328. align-items: center;
  329. justify-content: center;
  330. display: flex;
  331. flex-direction: row;
  332. box-sizing: border-box;
  333. flex-direction: row;
  334. padding: 0 12px;
  335. font-size: 14px;
  336. border-color: #ebedf0;
  337. border-width: 1px;
  338. border-style: solid;
  339. }
  340. .primary {
  341. background-color: #3c9cff;
  342. border-color: #3c9cff;
  343. color: #fff;
  344. }
  345. }
  346. }
  347. }
  348. .popup_btns {
  349. padding: 0.6rem;
  350. display: flex;
  351. margin-top: 1rem;
  352. border-top: 1px solid #f1f1f1;
  353. .u-button {
  354. width: 47%;
  355. }
  356. }
  357. }
  358. .list-item.green::after {
  359. display: block;
  360. content: '';
  361. width: 6rpx;
  362. height: 120rpx;
  363. background-color: #67c23a;
  364. position: absolute;
  365. top: 30%;
  366. }
  367. .list-item.red::after {
  368. display: block;
  369. content: '';
  370. width: 6rpx;
  371. height: 120rpx;
  372. background-color: #f56c6c;
  373. position: absolute;
  374. top: 30%;
  375. }
  376. </style>