editCheckList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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"
  5. v-for="(item, index) in checkList"
  6. :key="index">
  7. <view class="title-wrap">
  8. <text>{{item.deptName}}</text>
  9. <view>
  10. <image src="../../static/icon-map.png"></image>
  11. <text>{{item.deptClassName}}</text>
  12. </view>
  13. </view>
  14. <view class="content">
  15. <text>{{item.decs}}</text>
  16. <text>
  17. 要点概览:{{item.checkPointNames}}
  18. </text>
  19. </view>
  20. <view class="footer">
  21. <view class="row" @click="checkEdit(item, index, '指派查核人员')">
  22. <text class="label">查核人</text>
  23. <view class="content">
  24. <text :class="['base-text', item.empName ? 'black-color' : '']">
  25. {{ item.empName ? item.empName : '选择查核成员'}}
  26. </text>
  27. </view>
  28. <image class="arrow" src="/static/images/icon-more.png"></image>
  29. </view>
  30. <view class="row" @click="checkEdit(item, index, '设置查核时间')">
  31. <text class="label">计划时间</text>
  32. <view class="content">
  33. <text :class="['base-text', item.startDate ? 'black-color' : '']">
  34. {{ item.startDate ? item.startDate : '选择起始时间' }}
  35. </text>
  36. <text class="center-text">至</text>
  37. <text :class="['base-text', item.endDate ? 'black-color' : '']">
  38. {{ item.endDate ? item.endDate : '选择结束时间' }}
  39. </text>
  40. </view>
  41. <image class="arrow" src="/static/images/icon-more.png"></image>
  42. </view>
  43. </view>
  44. </view>
  45. </scroll-view>
  46. <view class="null" v-else>暂无数据</view>
  47. <view class="fixed-buttom-btn" @click="submit" v-if="checkList.length > 0">
  48. <text class="btn-text">完成</text>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. // 查核列表(查核人和计划时间可编辑)
  54. import { mapState } from "vuex";
  55. import moment from 'moment';
  56. export default {
  57. computed: {
  58. ...mapState({
  59. checkList: state => state.editCheckList.checkList
  60. })
  61. },
  62. data() {
  63. return {
  64. // 查核组id
  65. checkGroupId: 0,
  66. // 情境id (批量修改有,不然为0)
  67. situationId: 0,
  68. // 查核id
  69. checkId: 0,
  70. // 计划开始时间
  71. startDate: '',
  72. // 计划结束时间
  73. endDate: '',
  74. multiple: 'false',
  75. planList: []
  76. };
  77. },
  78. onLoad({ situationId, checkId, checkGroupId, startDate, endDate, multiple }){
  79. this.getCheckList(checkId);
  80. this.checkGroupId = checkGroupId ? +checkGroupId : 0;
  81. this.situationId = situationId ? +situationId : 0;
  82. this.checkId = checkId ? +checkId : 0;
  83. this.startDate = startDate;
  84. this.endDate = endDate;
  85. this.multiple = multiple;
  86. },
  87. methods: {
  88. // 完成
  89. submit() {
  90. // baseEmpList: 第一次计划修改的数据; changePlanList: 批量分配,记录第一次计划修改数据的信息; multipleEmpList: 批量修改的数据
  91. let baseEmpList = [], changePlanList = [], multipleEmpList = [];
  92. // planStartTimestamp: 开始计划时间戳;
  93. let planStartTimestamp = this.dateToTimestamp(this.startDate);
  94. this.checkList.map((item, i) => {
  95. const {checkId, deptId, empId, empName, startDate, endDate} = item;
  96. if(empId && startDate && endDate){
  97. baseEmpList.push({
  98. checkId,
  99. deptId,
  100. empId,
  101. empName,
  102. startDate: startDate || '',
  103. endDate: endDate || ''
  104. });
  105. if(this.multiple === 'true'){ // 批量分配
  106. changePlanList.push({
  107. index: i, // 第一次计划修改的下标
  108. baseEmpListIndex: baseEmpList.length -1,
  109. startDiffTimestamp: (startDate && planStartTimestamp != -1) ? this.dateToTimestamp(startDate) - planStartTimestamp : -1, // 开始时间差
  110. endDifTimestamp: (endDate && planStartTimestamp != -1) ? this.dateToTimestamp(endDate) - planStartTimestamp : -1 // 结束时间差
  111. });
  112. }
  113. }
  114. });
  115. if(this.multiple === 'true') { // 批量分配
  116. this.$store.dispatch({
  117. type: 'planList/commActions',
  118. payload: {
  119. key: 'planList',
  120. data:{situationId: this.situationId}
  121. }
  122. }).then((planList) => {
  123. (planList || []).map(((planItem, planI) => {
  124. if(planI != 0){ // 过滤掉第一条
  125. // 计划开始时间戳
  126. let planStartTimestamp = planItem.startDate ? this.dateToTimestamp(planItem.startDate + ' 00:00') : -1;
  127. // 计划结束时间戳
  128. let planEndTimestamp = planItem.endDate ? this.dateToTimestamp(planItem.endDate + ' 23:59') : -1;
  129. planItem.empList && planItem.empList.map((empItem, empI) => {
  130. // 当前分配明细
  131. let currentEmp = changePlanList.find(item => item.index === empI);
  132. if(currentEmp){
  133. const { baseEmpListIndex, startDiffTimestamp, endDifTimestamp } = currentEmp;
  134. const { empId, empName } = baseEmpList[baseEmpListIndex] || {};
  135. multipleEmpList.push({
  136. empId,
  137. empName,
  138. checkId: empItem.checkId,
  139. deptId: empItem.deptId,
  140. startDate: (planStartTimestamp > -1 && startDiffTimestamp > -1)
  141. ? this.getDateStr(planStartTimestamp, planEndTimestamp, startDiffTimestamp, planItem.endDate)
  142. : '',
  143. endDate: (planStartTimestamp > -1 && endDifTimestamp > -1)
  144. ? this.getDateStr(planStartTimestamp, planEndTimestamp, endDifTimestamp, planItem.endDate)
  145. : ''
  146. });
  147. }
  148. })
  149. }
  150. }))
  151. multipleEmpList = [...baseEmpList, ...multipleEmpList];
  152. // console.log('批量',multipleEmpList )
  153. this.batchDistribute(multipleEmpList);
  154. })
  155. }else { // 单个分配
  156. this.batchDistribute(baseEmpList);
  157. }
  158. },
  159. /**
  160. * 获取时间字符串
  161. * @param {Number} startTimestamp 计划开始时间戳
  162. * @param {Number} endTimestamp 计划结束时间戳
  163. * @param {Number} diffTimestamp 第一次计划中的时间差
  164. * @param {String} endDateStr 计划结束时间字符串
  165. */
  166. getDateStr(startTimestamp, endTimestamp, diffTimestamp, endDateStr) {
  167. if((startTimestamp + diffTimestamp) > endTimestamp){ // 超出计划结束时间, 则取计划结束时间
  168. return endDateStr;
  169. }else {
  170. return moment(startTimestamp + diffTimestamp).format('YYYY-MM-DD HH:mm');
  171. }
  172. },
  173. // 分配单位查核人员
  174. batchDistribute(empList) {
  175. if(empList.length === 0) { // 未作修改直接跳转页面
  176. return this.redirectToPlanList();
  177. }
  178. this.$store.dispatch({
  179. type: 'editCheckList/commActions',
  180. key: "batchDistribute",
  181. data: { empList }
  182. }).then(data => {
  183. if(data){
  184. this.redirectToPlanList();
  185. }
  186. });
  187. },
  188. // 跳转页面
  189. redirectToPlanList() {
  190. uni.redirectTo({
  191. url: `/pages/planList/planList?situationId=${this.situationId}&checkGroupId=${this.checkGroupId}`
  192. });
  193. },
  194. // 日期时间转换为时间戳
  195. dateToTimestamp(dataStr) {
  196. return dataStr ? moment(dataStr).valueOf() : -1
  197. },
  198. checkEdit(data, index, title) {
  199. if(data.completeState){ // 计划已开始, 不能编辑查核人和计划时间
  200. uni.showModal({
  201. content: '因查核计划已开始,故不可修改',
  202. showCancel: false
  203. });
  204. }else {// 跳转编辑页面
  205. const { empId, empName, startDate, endDate } = data;
  206. let details = {
  207. index, // 修改的下标
  208. title, // 标题
  209. empId,
  210. empName,
  211. startDate,
  212. endDate,
  213. situationId: this.situationId, // 情境id (批量修改有,不然为0)
  214. checkId: this.checkId, // 查核id
  215. checkGroupId: this.checkGroupId, //查核组id
  216. planStartDate: this.startDate, // 计划开始时间
  217. planEndDate: this.endDate // 计划结束时间
  218. }
  219. uni.navigateTo({
  220. url: `/pages/allocationPerson/allocationPerson?details=${encodeURIComponent(JSON.stringify(details))}`
  221. });
  222. }
  223. },
  224. // 获取查核列表
  225. getCheckList(checkId) {
  226. this.$store.dispatch({
  227. type: 'editCheckList/commActions',
  228. key: "getCheckList",
  229. data: { checkId }
  230. }).then(data => {
  231. this.$store.dispatch({
  232. type: "commActions",
  233. key: "getDateStr",
  234. }).then((dateStr) => {
  235. if (dateStr) {
  236. this.$store.commit({
  237. type: 'editCheckList/comChangeState',
  238. key: 'checkList',
  239. data: (data || []).map(item => {
  240. if (item.startDate && moment(item.startDate).valueOf() < moment(dateStr).valueOf()) {
  241. return {
  242. ...item,
  243. completeState: true // true:说明计划已开始, 不能编辑查核人和计划时间
  244. }
  245. }else {
  246. return item
  247. }
  248. })
  249. });
  250. }
  251. });
  252. });
  253. },
  254. // 获取计划列表
  255. getPlanList() {
  256. this.$store.dispatch({
  257. type: 'planList/commActions',
  258. payload: {
  259. key: 'planList',
  260. data:{
  261. situationId: this.situationId
  262. }
  263. }
  264. }).then((data) => {
  265. this.planList = data || [];
  266. })
  267. }
  268. }
  269. }
  270. </script>
  271. <style lang="less">
  272. .check-map-list {
  273. height: 100%;
  274. .scroll-y {
  275. height: calc(100% - 87.5rpx);
  276. padding-top: 25rpx;
  277. .footer {
  278. .row {
  279. display: flex;
  280. align-items: center;
  281. justify-content: space-between;
  282. border-top: 1px solid #DADEE6;
  283. height: 62.5rpx;
  284. padding: 0 25rpx;
  285. font-size: 22.5rpx;
  286. .label {
  287. color: #525866;
  288. width: 93.75rpx;
  289. }
  290. .content {
  291. display: flex;
  292. flex-direction: row;
  293. align-items: center;
  294. flex: 1;
  295. height: 100%;
  296. padding: 0 25rpx;
  297. .base-text {
  298. flex: 1;
  299. line-height: 62.5rpx;
  300. color: #B8BECC;
  301. font-weight: normal;
  302. margin-bottom: 0;
  303. }
  304. .center-text {
  305. padding: 0 25rpx;
  306. color: #292C33;
  307. }
  308. .black-color {
  309. color: #292C33;
  310. }
  311. }
  312. .arrow {
  313. width: 12.5rpx;
  314. height: 21.25rpx;
  315. }
  316. }
  317. }
  318. }
  319. .null {
  320. margin-top: 375rpx;
  321. text-align: center;
  322. color: #999;
  323. }
  324. }
  325. </style>