index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. <template>
  2. <div class="check-register">
  3. <NavBar :go="go"/>
  4. <div class="statistics-container">
  5. <!-- 搜索 -->
  6. <div style="background-color: #fff;">
  7. <!--需求改为只查看本检查机构、登录角色的任务-->
  8. <!-- <div class="org-line van-hairline--bottom">
  9. <van-row>
  10. <van-col span="24">
  11. <org-tree v-model="query.checkOrgId" placeholder="选择检查机构" @change="changeOrgId"></org-tree>
  12. </van-col>
  13. </van-row>
  14. </div> -->
  15. <!-- <div class="org-line van-hairline&#45;&#45;bottom">-->
  16. <!-- <van-row>-->
  17. <!-- <van-col span="12">-->
  18. <!-- <org-tree v-model="query.beCheckedOrgId" clearable placeholder="选择受检机构" @change="refreshData"></org-tree>-->
  19. <!-- </van-col>-->
  20. <!-- <van-col span="12">-->
  21. <!-- <date-cell title="日期" v-model="query.taskTime" date-type="date" @change="refreshData"/>-->
  22. <!-- </van-col>-->
  23. <!-- </van-row>-->
  24. <!-- </div>-->
  25. <div class='search-flex'>
  26. <org-tree v-model="query.beCheckedOrgId" clearable placeholder="选择受检机构" @change="refreshData"></org-tree>
  27. <date-cell title="日期" v-model="query.taskTime" date-type="date" @change="refreshData"/>
  28. <!-- <search-select-cell-->
  29. <!-- class="van-hairline&#45;&#45;right"-->
  30. <!-- title="检查角色"-->
  31. <!-- :border="false"-->
  32. <!-- v-model="query.roleIds"-->
  33. <!-- :dataList="rolesList"-->
  34. <!-- :prop="prop"-->
  35. <!-- @change="refreshData"/> </div> -->
  36. </div>
  37. </div>
  38. <div class="card-list">
  39. <Scroll
  40. ref="Scroll"
  41. @refresh="refreshData"
  42. @loadMore="getDataList"
  43. :pullup="pullup">
  44. <empty v-if="!dataList || dataList.length === 0" />
  45. <card class="list-item" v-for="(v,i) in dataList" :key="v.planId+i">
  46. <div class="item-title">
  47. <van-cell :title="v.taskName" :border="false" :label="rangDate(formatDate(v.planStartTime,'DATE'),formatDate(v.planEndTime,'DATE'))" ></van-cell>
  48. <div class="collapse-title">
  49. <div :class="{'active':v.active==2}" @click.stop="changeList(v,2)">
  50. <p> {{v.uncompleted.length}}</p>
  51. <p>未完成</p>
  52. </div>
  53. <div :class="{'active':v.active==1}" @click.stop="changeList(v,1)">
  54. <p>{{v.completed.length}}</p>
  55. <p>完成</p>
  56. </div>
  57. </div>
  58. </div>
  59. <div class="check-item-list">
  60. <empty v-if="v.active==1? v.completed.length == 0 : v.uncompleted.length == 0" />
  61. <van-cell
  62. v-else
  63. v-for="(a,index) in v.active==1? v.completed:v.uncompleted" :key="a.taskId"
  64. :title="a.beCheckedOrgName"
  65. :to="{path:path,query:{id:a.taskId,enable:1}}">
  66. <template #right-icon>
  67. <div>
  68. <span :style="{color:getState(getDictLabel(a.status,'safety_check_status'))}">
  69. {{getDictLabel(a.status,'safety_check_status')}}
  70. </span>
  71. </div>
  72. </template>
  73. </van-cell>
  74. </div>
  75. </card>
  76. </Scroll>
  77. </div>
  78. </div>
  79. </div>
  80. </template>
  81. <script>
  82. import NavBar from '@/components/NavBar'
  83. import OrgTree from '@/components/orgTree'
  84. import Card from '@/components/card'
  85. import DateCell from '@/components/dateCell'
  86. import SelectCell from '@/components/selectCell'
  87. import SearchSelectCell from '@/components/SearchSelectCell'
  88. import Scroll from '@/components/scroll/scroll'
  89. import {dataList,registerRole} from './api'
  90. import {mapGetters} from "vuex";
  91. import {formatDate} from "@/filters/filter";
  92. export default {
  93. components: {
  94. NavBar,
  95. OrgTree,
  96. Card,
  97. DateCell,
  98. SelectCell,
  99. SearchSelectCell,
  100. Scroll
  101. },
  102. data() {
  103. return {
  104. active:['1'],
  105. //配置子页面路径
  106. path:'/securityDetail',
  107. query:{
  108. taskTime: `${formatDate(new Date(),'YYYY-MM-DD')}`,
  109. checkOrgId:null,
  110. beCheckedOrgId:null,
  111. roleIds:[],
  112. // state:'1',
  113. pageNum:1,
  114. pageSize:10,
  115. },
  116. total:0,
  117. rolesList:[],
  118. prop:{
  119. label:'name',
  120. value:'id',
  121. },
  122. loading:false,
  123. dataList:[],
  124. dicts:['safety_check_status'],
  125. finishList:[],
  126. unfinishedList:[],
  127. //控制上拉加载
  128. pullup:false,
  129. go:{
  130. type:'replace',
  131. path:'/menu',
  132. }
  133. }
  134. },
  135. mounted() {
  136. this.initData();
  137. this.query.checkOrgId = this.orgId;
  138. // this.getRoleList();
  139. },
  140. computed:{
  141. ...mapGetters(['orgId','dictionary','roleList']),
  142. },
  143. methods: {
  144. formatDate,
  145. getState(state){
  146. switch (state){
  147. case '待检查':
  148. return '#008cd6';
  149. case '进行中':
  150. return '#bc9f71';
  151. case '完成':
  152. return '#009240';
  153. case '已过期':
  154. return '#D7000F';
  155. }
  156. },
  157. changeOrgId(){
  158. this.query.roleIds = [];
  159. this.getRoleList();
  160. this.refreshData();
  161. },
  162. changeList(item,type){
  163. this.$set(item,'active',type);
  164. },
  165. refreshData(){
  166. this.pullup = true;
  167. this.total = 0;
  168. this.query.pageNum = 1;
  169. this.dataList = [];
  170. this.getDataList();
  171. },
  172. initData(){
  173. this.query.checkOrgId = this.orgId;
  174. this.query.taskTime = formatDate(new Date(),'YYYY-MM-DD');
  175. this.getDataList();
  176. },
  177. getRoleList(){
  178. registerRole(this.query.checkOrgId).then(res=>{
  179. this.rolesList = res.data;
  180. })
  181. },
  182. getDataList(){
  183. console.log(123123123)
  184. if( this.dataList.length !== 0 && this.dataList.length >= this.total) {
  185. this.pullup = false;
  186. this.$toast('已加载完毕');
  187. return;
  188. }
  189. let data = {
  190. ...this.query
  191. }
  192. if(!this.query.checkOrgId) return this.$toast('请选择机构');
  193. data.roleIds= this.roleList.map(v=>{return v.roleId})
  194. dataList(data).then(res=>{
  195. console.log(res,'ressssssss')
  196. if(res.total === '0'){
  197. this.pullup = false;
  198. this.$toast('已加载完毕');
  199. return
  200. }
  201. this.total = res.total;
  202. res.rows.forEach(v=>{
  203. v.active = 2
  204. });
  205. console.log(res.rows,'arr')
  206. if(this.dataList.length < res.total) {
  207. this.dataList = [...this.dataList,...res.rows];
  208. console.log(111)
  209. this.pullup = true;
  210. this.query.pageNum++;
  211. this.$refs.Scroll.refresh(); //异步请求数据量过大,需手动刷新容器
  212. }
  213. })
  214. },
  215. }
  216. }
  217. </script>
  218. <style lang="scss">
  219. .check-register{
  220. .item-title{
  221. >.van-cell{
  222. padding: 0;
  223. }
  224. }
  225. .van-empty{
  226. padding: 0;
  227. .van-empty__image{
  228. width: 160px;
  229. height: 160px;
  230. }
  231. }
  232. .check-item-list{
  233. >.van-cell{
  234. padding: 20px;
  235. .van-cell__title{
  236. flex:2;
  237. }
  238. .van-cell__value{
  239. flex:1;
  240. }
  241. }
  242. .van-cell::after{
  243. left: 20px;
  244. right: 20px;
  245. }
  246. }
  247. }
  248. </style>
  249. <style lang="scss" scoped>
  250. .check-register{
  251. .org-line{
  252. padding:0 10px;
  253. background-color: #fff;
  254. }
  255. .search-flex{
  256. display: flex;
  257. align-items: center;
  258. justify-content: space-between;
  259. border-bottom: 1px solid #f5f5f5;
  260. >div{
  261. width: 50%;
  262. }
  263. }
  264. .org-label{
  265. height: 90px;
  266. width: 100%;
  267. display: flex;
  268. align-items: center;
  269. font-size: 28px;
  270. }
  271. .card-list{
  272. padding:0 20px 20px 20px;
  273. height: calc(100vh - 318px);
  274. overflow: auto;
  275. border:1px solid red;
  276. }
  277. .list-item{
  278. padding: 20px;
  279. }
  280. .item-title{
  281. width: 100%;
  282. display: flex;
  283. justify-content: space-between;
  284. border-bottom: 1px solid #f5f5f5;
  285. padding-bottom: 10px;
  286. }
  287. .check-item-list{
  288. -max-height: 500px;
  289. overflow: auto;
  290. }
  291. .card-num{
  292. display: flex;
  293. align-items: center;
  294. font-size: 28px;
  295. color: #008cd6;
  296. }
  297. .collapse-title{
  298. width: 50%;
  299. margin-left: 10px;
  300. display: flex;
  301. align-items: center;
  302. justify-content: space-between;
  303. font-size: 28px;
  304. color: #ccc;
  305. >div{
  306. width: 100px;
  307. font-size: 24px;
  308. height: 70px;
  309. padding: 5px 10px;
  310. border: 2px solid #ccc;
  311. border-radius: 10px;
  312. box-shadow: 0 3px 6px #eaeaea;
  313. >p{
  314. height: 28px;
  315. line-height: 28px;
  316. text-align: center;
  317. }
  318. }
  319. >div.active{
  320. color: #fff;
  321. background-color: #008cd6;
  322. border: 3px solid #008cd6;
  323. }
  324. }
  325. .flex-box{
  326. display: flex;
  327. align-items: center;
  328. >div{
  329. margin-right: 40px;
  330. }
  331. }
  332. .search-box{
  333. display: flex;
  334. justify-content: space-between;
  335. align-items: center;
  336. >div{
  337. width: 50%;
  338. }
  339. }
  340. }
  341. </style>