editCheckList.vue 18 KB

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