editCheckList.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. <template>
  2. <view class="check-map-list">
  3. <scroll-view :class="[ifAllPlanListHasDistribution==true?'scroll-y noBottom':'scroll-y']" scroll-y="true" v-if="checkList.length > 0">
  4. <view class="item" v-for="(item, index) in checkList" :key="index">
  5. <view
  6. v-if="item.finishedStatus != 1"
  7. :class="{'checkPoint':true,checked:(checkedList.findIndex(t=>t.deptId == item.deptId) != -1)}"
  8. @click="checkedHandle(item)">
  9. <image class="innerImg" v-if="(checkedList.findIndex(t=>t.deptId == item.deptId) != -1)"
  10. src="../../static/check-checkbox.png" mode=""></image>
  11. </view>
  12. <view class="title-wrap">
  13. <text>{{item.deptName}}</text>
  14. <view>
  15. <image src="../../static/icon-map.png"></image>
  16. <text>{{item.deptClassName}}</text>
  17. </view>
  18. <view :class="getStatus(item.completeDes)" >{{item.completeDes}}</view>
  19. </view>
  20. <view class="content">
  21. <text>{{item.decs}}</text>
  22. <text>
  23. 要点概览:{{item.checkPointNames}}
  24. </text>
  25. </view>
  26. <view class="footer">
  27. <view class="row" @click="checkEdit(item, index, '指派查核人员')">
  28. <text class="label">查核人</text>
  29. <view class="content">
  30. <text :class="['base-text', item.empName ? 'black-color' : '']">
  31. {{ item.empName?item.empName : '选择查核成员'}}
  32. </text>
  33. </view>
  34. <image class="arrow" src="/static/images/icon-more.png"></image>
  35. </view>
  36. <view class="row" @click="checkEdit(item, index, '设置查核时间')">
  37. <text class="label">计划时间</text>
  38. <view class="content">
  39. <text :class="['base-text', item.startDate ? 'black-color' : '']">
  40. {{ item.startDate ? item.startDate : '选择起始时间' }}
  41. </text>
  42. <text class="center-text">至</text>
  43. <text :class="['base-text', item.endDate ? 'black-color' : '']">
  44. {{ item.endDate ? item.endDate : '选择结束时间' }}
  45. </text>
  46. </view>
  47. <image class="arrow" src="/static/images/icon-more.png"></image>
  48. </view>
  49. </view>
  50. </view>
  51. </scroll-view>
  52. <view class="null" v-else>暂无数据</view>
  53. <view class="fixed-buttom-btn" @click="submit" v-if="multiple == 'true'">
  54. <text class="btn-text">完成</text>
  55. </view>
  56. <view class="bottomBtnGroup" v-if="multiple != 'true'">
  57. <view class="selectAll" @click="bottomBtnClickHandle('left')">{{ifSlectedAllCheckList?'取消':'全选'}}</view>
  58. <view class="leftBtn" @click="bottomBtnClickHandle('middle')">{{`(已选${checkedList.length}项)撤销分配`}}</view>
  59. <view class="rightBtn" @click="bottomBtnClickHandle('right')">{{`(已选${checkedList.length}项)批量分配`}}</view>
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. // 查核列表(查核人和计划时间可编辑)
  65. import {
  66. mapState
  67. } from "vuex";
  68. import moment from 'moment';
  69. export default {
  70. computed: {
  71. ...mapState({
  72. checkList: state => state.editCheckList.checkList
  73. }),
  74. //计算当所有查核计划都已分配完时掩藏底部批量按钮
  75. ifAllPlanListHasDistribution: function() {
  76. const tempData = this.checkList.filter(item => (!item.empId && !item.empName));
  77. return tempData.length == 0
  78. },
  79. ifSlectedAllCheckList:function(){
  80. if(this.checkedList.length == this.checkList.length){ //选中集合==总集合
  81. this.ifCheckAll = true;
  82. return true;
  83. }else {
  84. this.ifCheckAll = false;
  85. return false;
  86. }
  87. }
  88. },
  89. data() {
  90. return {
  91. // 查核组id
  92. checkGroupId: 0,
  93. // 情境id (批量修改有,不然为0)
  94. situationId: 0,
  95. // 查核id
  96. checkId: 0,
  97. // 计划开始时间
  98. startDate: '',
  99. // 计划结束时间
  100. endDate: '',
  101. multiple: false,
  102. planList: [],
  103. hasStartedCheck: [], //查核已经开始的集合
  104. ifInit: null,
  105. ifshowBottom: false,
  106. checkedList: [], //批量选中的集合
  107. ifCheckAll:false,//是否全选
  108. };
  109. },
  110. onLoad({
  111. situationId,
  112. checkId,
  113. checkGroupId,
  114. startDate,
  115. endDate,
  116. multiple,
  117. situationType,
  118. checkNo
  119. }) {
  120. this.init(situationId,
  121. checkId,
  122. checkGroupId,
  123. startDate,
  124. endDate,
  125. multiple,
  126. situationType,
  127. checkNo
  128. );
  129. },
  130. onShow() {
  131. let pages = getCurrentPages(); // 获取当前页面栈
  132. let curPage = pages[pages.length - 1]; // 当前页面
  133. if (curPage.ifInit) {
  134. curPage.ifInit = false;
  135. this.init(
  136. this.situationId,
  137. this.checkId,
  138. this.checkGroupId,
  139. this.startDate,
  140. this.endDate,
  141. this.multiple,
  142. this.situationType,
  143. this.checkNo
  144. ) // A页面 method中的方法,用来刷新页面A
  145. }
  146. },
  147. mounted() {},
  148. onUnload() {
  149. //页面卸载或返回
  150. this.$store.commit('planList/comChangeState',{key:'ifReloadData',data:true})
  151. },
  152. methods: {
  153. init(situationId,
  154. checkId,
  155. checkGroupId,
  156. startDate,
  157. endDate,
  158. multiple,
  159. situationType,
  160. checkNo) {
  161. this.getCheckList(checkId, situationType);
  162. this.checkGroupId = checkGroupId ? +checkGroupId : 0;
  163. this.situationId = situationId ? +situationId : 0;
  164. this.checkId = checkId ? +checkId : 0;
  165. this.startDate = startDate;
  166. this.endDate = endDate;
  167. this.multiple = multiple;
  168. this.checkedList = [];
  169. this.situationType = situationType;
  170. this.checkNo = checkNo;
  171. },
  172. ifStartCheck(timeStr) {
  173. if (timeStr) {
  174. const currentTime = new Date().getTime();
  175. const startTime = Date.parse(timeStr.replace(/-/g, '/'));
  176. if (currentTime < startTime) {
  177. this.ifshowBottom = true;
  178. }
  179. return currentTime < startTime;
  180. }
  181. this.ifshowBottom = true;
  182. return true;
  183. },
  184. /**
  185. * @str string [noStart,checking,completed]
  186. */
  187. getStatus:function(str){ //设置状态颜色
  188. switch(str){
  189. case '未分配':
  190. return 'status noStart'
  191. break;
  192. case '进行中':
  193. return 'status checking'
  194. break;
  195. case '已完成':
  196. return 'status completed'
  197. break;
  198. }
  199. },
  200. batchCancelDistri(){ //批量撤销
  201. const _that = this;
  202. this.$store.dispatch({
  203. type: 'editCheckList/commActions',
  204. key: "batchCancelCheckDistribution",
  205. data: {
  206. checkId:this.checkId,
  207. deptIds:this.checkedList.map(t=>t.deptId)
  208. }
  209. }).then(data=>{
  210. if(data){
  211. uni.showModal({
  212. title: '提示',
  213. content: '撤销分配成功!',
  214. showCancel: false,
  215. success(res) {
  216. if(res.confirm){
  217. _that.checkedList = [];
  218. _that.getCheckList(_that.checkId,_that.situationType);
  219. }
  220. }
  221. });
  222. }
  223. })
  224. },
  225. bottomBtnClickHandle(key) {
  226. let details = {
  227. index: '', // 修改的下标
  228. title: '', // 标题
  229. empId: '',
  230. empName: '',
  231. startDate: '',
  232. endDate: '',
  233. situationType: this.situationType,
  234. checkNo:this.checkNo,
  235. checkedList: this.checkedList.map(t=>t.deptId),
  236. situationId: this.situationId, // 情境id (批量修改有,不然为0)
  237. checkId: this.checkId, // 查核id
  238. checkGroupId: this.checkGroupId, //查核组id
  239. planStartDate: this.startDate, // 计划开始时间
  240. planEndDate: this.endDate // 计划结束时间
  241. }
  242. if (key == 'left') { //全选
  243. this.ifCheckAll = !this.ifCheckAll;
  244. if(this.ifCheckAll){
  245. this.checkedList = this.checkList;
  246. }else {
  247. this.checkedList = [];
  248. }
  249. }
  250. if(key == 'middle'){ //批量撤销
  251. if(this.checkedList.findIndex(item=>item.completeDes == '未分配') != -1){
  252. //选中项包含未分配
  253. uni.showModal({
  254. title: '提示',
  255. content: '选择的病区里包含未分配项!是否继续操作?',
  256. success:(res)=>{
  257. if (res.confirm) {
  258. this.batchCancelDistri();
  259. }
  260. }
  261. });
  262. }else {
  263. this.batchCancelDistri();
  264. }
  265. }
  266. if (key == 'right') { //批量分配
  267. if (this.checkedList.length > 0) {
  268. if(this.checkedList.findIndex(item=>item.completeDes == '进行中') != -1){
  269. //选中项包含已分配
  270. uni.showModal({
  271. title: '提示',
  272. content: '选择的病区里包含已进行中项!是否继续操作?',
  273. success:(res)=>{
  274. if (res.confirm) {
  275. uni.navigateTo({
  276. url: `/pages/batchDistribution/batchDistribution?details=${encodeURIComponent(JSON.stringify(details))}`
  277. });
  278. }
  279. }
  280. });
  281. }else {
  282. uni.navigateTo({
  283. url: `/pages/batchDistribution/batchDistribution?details=${encodeURIComponent(JSON.stringify(details))}`
  284. });
  285. }
  286. } else {
  287. uni.showModal({
  288. title: '提示',
  289. content: '请先选择分配项!',
  290. showCancel: false
  291. });
  292. }
  293. }
  294. },
  295. checkedHandle(item) {
  296. let temp = this.checkedList;
  297. let index = temp.findIndex(val=>val.deptId == item.deptId)
  298. if ( index != -1) {
  299. temp.splice(index, 1);
  300. this.checkedList = temp;
  301. } else {
  302. this.checkedList = this.checkedList.concat([item]);
  303. }
  304. },
  305. // 完成
  306. submit(){
  307. const hadDistributionList = this.checkList.filter((item,index)=>{
  308. return item.isDistribution||item.empId;
  309. });
  310. const commitData = hadDistributionList.map(item=>({
  311. "checkId": item.checkId,
  312. "deptId": item.deptId,
  313. "empId":item.empId,
  314. "empName":item.empName,
  315. "startDate":item.startDate,
  316. "endDate": item.endDate,
  317. "categoryIds":item.categoryIds
  318. }));
  319. // console.log({commitData});
  320. this.batchDistribute(commitData);
  321. },
  322. /**
  323. * 获取时间字符串
  324. * @param {Number} startTimestamp 计划开始时间戳
  325. * @param {Number} endTimestamp 计划结束时间戳
  326. * @param {Number} diffTimestamp 第一次计划中的时间差
  327. * @param {String} endDateStr 计划结束时间字符串
  328. */
  329. getDateStr(startTimestamp, endTimestamp, diffTimestamp, endDateStr) {
  330. if ((startTimestamp + diffTimestamp) > endTimestamp) { // 超出计划结束时间, 则取计划结束时间
  331. return endDateStr;
  332. } else {
  333. return moment(startTimestamp + diffTimestamp).format('YYYY-MM-DD HH:mm');
  334. }
  335. },
  336. // 分配单位查核人员
  337. batchDistribute(empList) {
  338. if (empList.length === 0) { // 未作修改直接跳转页面
  339. return this.redirectToPlanList();
  340. }
  341. this.$store.dispatch({
  342. type: 'editCheckList/commActions',
  343. key: "batchDistribute",
  344. data: {
  345. empList
  346. }
  347. }).then(data => {
  348. if (data) {
  349. this.redirectToPlanList();
  350. }
  351. });
  352. },
  353. // 跳转页面
  354. redirectToPlanList() {
  355. uni.redirectTo({
  356. url: `/pages/planList/planList?situationId=${this.situationId}&checkGroupId=${this.checkGroupId}`
  357. });
  358. },
  359. // 日期时间转换为时间戳
  360. dateToTimestamp(dataStr) {
  361. return dataStr ? moment(dataStr).valueOf() : -1
  362. },
  363. checkEdit(data, index, title) {
  364. // console.log({data});
  365. if (data.completeState) { // 计划已开始, 不能编辑查核人和计划时间
  366. uni.showModal({
  367. content: '因查核计划已结束,故不可修改',
  368. showCancel: false
  369. });
  370. } else { // 跳转编辑页面
  371. const {
  372. empId,
  373. empName,
  374. startDate,
  375. endDate,
  376. deptId,
  377. categoryId,
  378. isDistribution,
  379. } = data;
  380. let details = {
  381. index, // 修改的下标
  382. title, // 标题
  383. empId,
  384. empName,
  385. startDate,
  386. endDate,
  387. deptId,
  388. categoryId,
  389. isDistribution,
  390. situationType: this.situationType,
  391. checkNo:this.checkNo,
  392. situationId: this.situationId, // 情境id (批量修改有,不然为0)
  393. checkId: this.checkId, // 查核id
  394. checkGroupId: this.checkGroupId, //查核组id
  395. planStartDate: this.startDate, // 计划开始时间
  396. planEndDate: this.endDate // 计划结束时间
  397. }
  398. if (this.multiple == 'true') {
  399. uni.navigateTo({
  400. url: `/pages/allocationPerson/allocationPerson?details=${encodeURIComponent(JSON.stringify(details))}`
  401. });
  402. }
  403. if (this.multiple == 'false') {
  404. const _detailsTwo = {
  405. ...details,
  406. checkedList: [deptId]
  407. }
  408. uni.navigateTo({
  409. url: `/pages/batchDistribution/batchDistribution?details=${encodeURIComponent(JSON.stringify(_detailsTwo))}`
  410. });
  411. }
  412. }
  413. },
  414. // 获取查核列表
  415. getCheckList(checkId, situationType) {
  416. this.$store.dispatch({
  417. type: 'editCheckList/commActions',
  418. key: "getCheckList",
  419. data: {
  420. checkId,
  421. situationType
  422. }
  423. }).then(data => {
  424. this.$store.dispatch({
  425. type: "commActions",
  426. key: "getDateStr",
  427. }).then((dateStr) => {
  428. if (dateStr) {
  429. this.$store.commit({
  430. type: 'editCheckList/comChangeState',
  431. key: 'checkList',
  432. data: (data || []).map(item => {
  433. if (item.endDate && moment(item.endDate)
  434. .valueOf() < moment(dateStr).valueOf()) {
  435. return {
  436. ...item,
  437. completeState: true // true:说明计划已结束, 不能编辑查核人和计划时间
  438. }
  439. } else {
  440. return item
  441. }
  442. })
  443. });
  444. }
  445. });
  446. });
  447. },
  448. // 获取计划列表
  449. getPlanList() {
  450. this.$store.dispatch({
  451. type: 'planList/commActions',
  452. payload: {
  453. key: 'planList',
  454. data: {
  455. situationId: this.situationId,
  456. }
  457. }
  458. }).then((data) => {
  459. this.planList = data || [];
  460. })
  461. }
  462. }
  463. }
  464. </script>
  465. <style lang="less">
  466. .check-map-list {
  467. display: flex;
  468. flex-direction: column;
  469. height: 100%;
  470. .scroll-y {
  471. flex: 1;
  472. height: 100%;
  473. // height: calc(100% - 87.5rpx);
  474. padding-top: 25rpx;
  475. padding-bottom:95rpx;
  476. &.noBottom {
  477. padding-bottom:0;
  478. }
  479. .item {
  480. position: relative;
  481. .title-wrap {
  482. text {
  483. white-space: nowrap;
  484. text-overflow:ellipsis;
  485. overflow:hidden;
  486. }
  487. }
  488. .status {
  489. display: flex;
  490. justify-content: center;
  491. width: 100rpx;
  492. height: 35rpx;
  493. color: #FFFFFF;
  494. text-align: center;
  495. line-height: 35rpx;
  496. border-radius:20rpx;
  497. &.noStart {
  498. background-color:#eee;
  499. }
  500. &.checking {
  501. background-color:#FFCC66;
  502. }
  503. &.completed {
  504. background-color:#29CC96;
  505. }
  506. }
  507. }
  508. .checkPoint {
  509. position: absolute;
  510. top: 30rpx;
  511. right: 25rpx;
  512. width: 25rpx;
  513. height: 25rpx;
  514. z-index: 2;
  515. border-radius: 50%;
  516. border: 2.5rpx solid #C3CAD9;
  517. .innerImg {
  518. width: 100%;
  519. height: 100%;
  520. }
  521. &.checked {
  522. border: none;
  523. }
  524. }
  525. .footer {
  526. .row {
  527. display: flex;
  528. align-items: center;
  529. justify-content: space-between;
  530. border-top: 1px solid #DADEE6;
  531. height: 62.5rpx;
  532. padding: 0 25rpx;
  533. font-size: 22.5rpx;
  534. .label {
  535. color: #525866;
  536. width: 100rpx;
  537. }
  538. .content {
  539. display: flex;
  540. flex-direction: row;
  541. align-items: center;
  542. flex: 1;
  543. height: 100%;
  544. padding: 0 25rpx;
  545. .base-text {
  546. flex: 1;
  547. line-height: 62.5rpx;
  548. color: #B8BECC;
  549. font-weight: normal;
  550. margin-bottom: 0;
  551. }
  552. .center-text {
  553. padding: 0 25rpx;
  554. color: #292C33;
  555. }
  556. .black-color {
  557. color: #292C33;
  558. }
  559. }
  560. .arrow {
  561. width: 12.5rpx;
  562. height: 21.25rpx;
  563. }
  564. }
  565. }
  566. }
  567. .bottomBtnGroup {
  568. position: fixed;
  569. width: 100%;
  570. height: 87.5rpx;
  571. bottom: 0;
  572. left: 0;
  573. display: flex;
  574. flex-direction: row;
  575. background-color: #FFFFFF;
  576. .selectAll {
  577. position: relative;
  578. display: flex;
  579. width:20%;
  580. height: 100%;
  581. justify-content: center;
  582. align-items: center;
  583. font-size: 22.5rpx;
  584. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  585. font-weight: 400;
  586. color: #3377FF;
  587. &::after {
  588. position: absolute;
  589. display: inline-block;
  590. content: '';
  591. right: 0;
  592. width: 1rpx;
  593. height:40%;
  594. background-color: #82848A;
  595. }
  596. }
  597. .leftBtn,
  598. .rightBtn {
  599. display: flex;
  600. width:40%;
  601. height: 100%;
  602. justify-content: center;
  603. align-items: center;
  604. font-size: 22.5rpx;
  605. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  606. font-weight: 400;
  607. color: #3377FF;
  608. }
  609. .rightBtn {
  610. color: #FFFFFF;
  611. background-color: #3377FF;
  612. }
  613. }
  614. .null {
  615. margin-top: 375rpx;
  616. text-align: center;
  617. color: #999;
  618. }
  619. }
  620. </style>