editCheckList.vue 11 KB

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