index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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="date" @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. components: {
  79. NavBar,
  80. OrgTree,
  81. Card,
  82. DateCell,
  83. SelectCell,
  84. SearchSelectCell,
  85. Scroll
  86. },
  87. data() {
  88. return {
  89. active:['1'],
  90. query:{
  91. taskTime: `${formatDate(new Date(),'YYYY-MM-DD')}`,
  92. checkOrgId:null,
  93. beCheckedOrgId:null,
  94. roleIds:[],
  95. // state:'1',
  96. pageNum:1,
  97. pageSize:10,
  98. },
  99. total:0,
  100. rolesList:[],
  101. prop:{
  102. label:'name',
  103. value:'id',
  104. },
  105. loading:false,
  106. dataList:[],
  107. dicts:['safety_check_status'],
  108. finishList:[],
  109. unfinishedList:[],
  110. //控制上拉加载
  111. pullup:false,
  112. go:{
  113. type:'replace',
  114. path:'/menu',
  115. }
  116. }
  117. },
  118. mounted() {
  119. this.initData();
  120. this.query.checkOrgId = this.orgId;
  121. // this.getRoleList();
  122. },
  123. computed:{
  124. ...mapGetters(['orgId','dictionary','roleList']),
  125. },
  126. methods: {
  127. formatDate,
  128. clickItem(item){
  129. if(item.status == 3){
  130. this.$router.push(
  131. {
  132. path:'/securityDetail',
  133. query:{id:item.taskId,enable:1}
  134. }
  135. )
  136. }else {
  137. this.$router.push(
  138. {
  139. path:'/securityAdd',
  140. query:{id:item.taskId,enable:1}
  141. }
  142. )
  143. }
  144. console.log(item,'item')
  145. },
  146. getState(state){
  147. switch (state){
  148. case '待检查':
  149. return '#008cd6';
  150. case '进行中':
  151. return '#bc9f71';
  152. case '已完成':
  153. return '#009240';
  154. case '已逾期':
  155. return '#D7000F';
  156. }
  157. },
  158. changeOrgId(){
  159. this.query.roleIds = [];
  160. this.getRoleList();
  161. this.refreshData();
  162. },
  163. changeList(item,type){
  164. this.$set(item,'active',type);
  165. },
  166. refreshData(){
  167. this.pullup = true;
  168. this.total = 0;
  169. this.query.pageNum = 1;
  170. this.dataList = [];
  171. this.getDataList();
  172. },
  173. initData(){
  174. this.query.checkOrgId = this.orgId;
  175. this.query.taskTime = formatDate(new Date(),'YYYY-MM-DD');
  176. this.getDataList();
  177. },
  178. getRoleList(){
  179. registerRole(this.query.checkOrgId).then(res=>{
  180. this.rolesList = res.data;
  181. })
  182. },
  183. getDataList(){
  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. if(res.total === '0'){
  196. this.pullup = false;
  197. this.$toast('已加载完毕');
  198. return
  199. }
  200. this.total = res.total;
  201. res.rows.forEach(v=>{
  202. v.active = 2
  203. });
  204. if(this.dataList.length < res.total) {
  205. this.dataList = [...this.dataList,...res.rows];
  206. this.pullup = true;
  207. this.query.pageNum++;
  208. this.$refs.Scroll.refresh(); //异步请求数据量过大,需手动刷新容器
  209. }
  210. })
  211. },
  212. }
  213. }
  214. </script>
  215. <style lang="scss">
  216. .check-register{
  217. .item-title{
  218. >.van-cell{
  219. padding: 0;
  220. }
  221. }
  222. .van-empty{
  223. padding: 0;
  224. .van-empty__image{
  225. width: 160px;
  226. height: 160px;
  227. }
  228. }
  229. .check-item-list{
  230. >.van-cell{
  231. padding: 20px;
  232. .van-cell__title{
  233. flex:2;
  234. }
  235. .van-cell__value{
  236. flex:1;
  237. }
  238. }
  239. .van-cell::after{
  240. left: 20px;
  241. right: 20px;
  242. }
  243. }
  244. }
  245. </style>
  246. <style lang="scss" scoped>
  247. .check-register{
  248. .org-line{
  249. padding:0 10px;
  250. background-color: #fff;
  251. }
  252. .search-flex{
  253. display: flex;
  254. align-items: center;
  255. justify-content: space-between;
  256. border-bottom: 1px solid #f5f5f5;
  257. >div{
  258. width: 50%;
  259. }
  260. }
  261. .org-label{
  262. height: 90px;
  263. width: 100%;
  264. display: flex;
  265. align-items: center;
  266. font-size: 28px;
  267. }
  268. .card-list{
  269. padding:0 20px 20px 20px;
  270. height: calc(100vh - 370px);
  271. overflow: auto;
  272. }
  273. .list-item{
  274. padding: 20px;
  275. }
  276. .item-title{
  277. width: 100%;
  278. display: flex;
  279. justify-content: space-between;
  280. border-bottom: 1px solid #f5f5f5;
  281. padding-bottom: 10px;
  282. }
  283. .check-item-list{
  284. -max-height: 500px;
  285. overflow: auto;
  286. }
  287. .card-num{
  288. display: flex;
  289. align-items: center;
  290. font-size: 28px;
  291. color: #008cd6;
  292. }
  293. .collapse-title{
  294. width: 50%;
  295. margin-left: 10px;
  296. display: flex;
  297. align-items: center;
  298. justify-content: space-between;
  299. font-size: 28px;
  300. color: #ccc;
  301. >div{
  302. width: 100px;
  303. font-size: 24px;
  304. height: 70px;
  305. padding: 5px 10px;
  306. border: 2px solid #ccc;
  307. border-radius: 10px;
  308. box-shadow: 0 3px 6px #eaeaea;
  309. >p{
  310. height: 28px;
  311. line-height: 28px;
  312. text-align: center;
  313. }
  314. }
  315. >div.active{
  316. color: #fff;
  317. background-color: #008cd6;
  318. border: 3px solid #008cd6;
  319. }
  320. }
  321. .flex-box{
  322. display: flex;
  323. align-items: center;
  324. >div{
  325. margin-right: 40px;
  326. }
  327. }
  328. .search-box{
  329. display: flex;
  330. justify-content: space-between;
  331. align-items: center;
  332. >div{
  333. width: 50%;
  334. }
  335. }
  336. }
  337. </style>