editCheckList.vue 15 KB

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