index.vue 8.4 KB

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