allocationPerson.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <template>
  2. <view class="allocationPerson-page">
  3. <scroll-view class="scroll-y" scroll-y="true">
  4. <template v-if="title === '指派查核人员'">
  5. <view class="blockTitle">查核人</view>
  6. <tm-checked-group :list="empList" :defaultValue='checkPresonList' :setting="{
  7. value: 'employeeId',
  8. name: 'employeeName'
  9. }" :openkeys="[0]" @change="onCheckPerosonChanged" />
  10. <view class="blockTitle" v-if="details.situationType == 3">要点分类</view>
  11. <tm-checked-group v-if="details.situationType == 3" :list="checkPointList" :defaultValue='checkedPointList' :setting="{
  12. value: 'categoryId',
  13. name: 'categoryName'
  14. }" :openkeys="[0]" @change="onCheckCategoryChanged" />
  15. </template>
  16. <template v-else>
  17. <div class="date-view">
  18. <view class="row">
  19. <text class="label">开始时间</text>
  20. <view class="date-box">
  21. <date-time-picker :height="100" :start="details.planStartDate" :end="details.planEndDate"
  22. :defaultValue="details.startDate" placeholder="请选择起始时间" pickType="startDate"
  23. @change="changeDateTime" />
  24. </view>
  25. </view>
  26. <view class="row">
  27. <text class="label">结束时间</text>
  28. <view class="date-box">
  29. <date-time-picker :height="100" :start="details.planStartDate" :end="details.planEndDate"
  30. :defaultValue="details.endDate" placeholder="请选择结束时间" pickType="endDate"
  31. @change="changeDateTime" />
  32. </view>
  33. </view>
  34. </div>
  35. </template>
  36. </scroll-view>
  37. <view class="fixed-buttom-btn" @click="sure">
  38. <text class="btn-text">确定</text>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. // 查核列表编辑 查核人和计划时间
  44. import {
  45. mapState
  46. } from "vuex";
  47. import moment from 'moment';
  48. export default {
  49. computed: {
  50. ...mapState({
  51. checkList: state => state.editCheckList.checkList
  52. })
  53. },
  54. data() {
  55. return {
  56. title: '', // 导航标题
  57. // 查核组员列表
  58. empList: [],
  59. //查核要点列表
  60. checkPointList:[],
  61. //选中的查核要点
  62. checkedPointList:[],
  63. //选中的查核人
  64. checkPresonList:[],
  65. // 组件信息
  66. details: {},
  67. // 服务器时间
  68. dateStr: '',
  69. timer: null,
  70. // 点击确定按钮是否直接保存
  71. isSubmit: false
  72. }
  73. },
  74. onLoad({
  75. details
  76. }) {
  77. const _details = details ? JSON.parse(details) : {};
  78. // 强制刷新返回查核列表页面
  79. if (getCurrentPages().length === 1) {
  80. const {
  81. situationId,
  82. checkId,
  83. checkGroupId,
  84. planStartDate,
  85. planEndDate
  86. } = _details;
  87. uni.redirectTo({
  88. url: `/pages/editCheckList/editCheckList?situationId=${situationId}&checkId=${checkId}&checkGroupId=${checkGroupId}&startDate=${planStartDate}&endDate=${planEndDate}`
  89. });
  90. }
  91. this.getComponentInfo(_details);
  92. },
  93. watch: {
  94. title(newVal, oldVal) {
  95. if (newVal === '设置查核时间') {
  96. this.getDateStr();
  97. !this.timer && (this.timer = setInterval(() => {
  98. this.getDateStr();
  99. }, 10000));
  100. } else {
  101. this.clearTimer();
  102. }
  103. }
  104. },
  105. destroyed() {
  106. this.clearTimer();
  107. },
  108. methods: {
  109. //查核人选择回调
  110. onCheckPerosonChanged(data){
  111. const {checkedList} = data;
  112. this.checkPresonList = checkedList;
  113. const empId = checkedList.map(item=>item.employeeId);
  114. const empName = checkedList.map(item=>item.employeeName);
  115. this.details = {
  116. ...this.details,
  117. empId:empId.join(','),
  118. empName:empName.join(','),
  119. }
  120. },
  121. onCheckCategoryChanged(data){
  122. const {checkedList} = data;
  123. this.checkedPointList = checkedList;
  124. const categoryIds = checkedList.map(item=>item.categoryId);
  125. this.details = {
  126. ...this.details,
  127. categoryIds:categoryIds,
  128. }
  129. },
  130. getComponentInfo(details) {
  131. const {checkGroupId,situationType,title,checkId,deptId} = details;
  132. this.setNavigationBarTitle(title);
  133. this.details = details;
  134. this.getEmpDeptTree(checkGroupId,situationType,deptId);
  135. // if(situationType == 3){
  136. // this.getCheckPointList(checkId,situationType);
  137. // }
  138. },
  139. // 查询部门人员树
  140. getEmpDeptTree(checkGroupId, situationType,deptId) {
  141. this.$store.dispatch({
  142. type: 'allocationPerson/commActions',
  143. key: "getGroupEmpList",
  144. data: {
  145. checkGroupId,
  146. situationType,
  147. deptId
  148. }
  149. }).then(data => {
  150. if (data) {
  151. this.empList = data.sysCheckGroupEmployees || [];
  152. this.checkPointList = data.pointCategoryBOs ||[];
  153. }
  154. });
  155. },
  156. // 时间变化
  157. changeDateTime(dateObj, pickType) {
  158. if (pickType === 'startDate') { // 开始时间变化
  159. this.diffDateTime(dateObj.f3, this.details.endDate);
  160. } else {
  161. this.diffDateTime(this.details.startDate, dateObj.f3);
  162. }
  163. this.details = {
  164. ...this.details,
  165. [pickType]: dateObj.f3
  166. };
  167. },
  168. // 开始时间和结束时间对比
  169. diffDateTime(startTime, endTime) {
  170. if (moment(startTime).valueOf() > moment(endTime).valueOf()) {
  171. this.showModal('开始时间不能大于结束时间');
  172. }
  173. },
  174. // 点击确定
  175. sure() {
  176. const {
  177. empId,
  178. empName,
  179. categoryIds,
  180. startDate,
  181. endDate
  182. } = this.details;
  183. if (this.isSubmit === true) {
  184. return this.changeCheckList(this.checkList);
  185. }
  186. if (this.title === '指派查核人员') {
  187. if (empName.length==0) {
  188. return this.showModal('请选择查核人');
  189. }
  190. this.setNavigationBarTitle('设置查核时间');
  191. } else {
  192. if (!startDate) {
  193. return this.showModal('请选择开始时间');
  194. }
  195. if (!endDate) {
  196. return this.showModal('请选择结束时间');
  197. }
  198. if (empName.length==0) {
  199. this.setNavigationBarTitle('指派查核人员');
  200. this.isSubmit = true;
  201. } else {
  202. this.changeCheckList(this.checkList);
  203. }
  204. }
  205. },
  206. // 更改查核列表数据
  207. changeCheckList(data) {
  208. const {
  209. situationId,
  210. checkId,
  211. empId,
  212. empName,
  213. categoryIds,
  214. checkGroupId
  215. } = this.details;
  216. let checkList = this.checkList.map((item, i) => {
  217. if (this.details.index === i) {
  218. return {
  219. ...item,
  220. ...this.details
  221. }
  222. } else {
  223. return item;
  224. }
  225. });
  226. // console.log({checkList});
  227. // return;
  228. this.$store.commit({
  229. type: 'editCheckList/comChangeState',
  230. key: 'checkList',
  231. data: checkList
  232. });
  233. // 关闭当前页面,返回上一页面
  234. uni.navigateBack({
  235. delta: 1
  236. });
  237. },
  238. // 修改导航名称
  239. setNavigationBarTitle(title) {
  240. this.title = title;
  241. uni.setNavigationBarTitle({
  242. title
  243. });
  244. },
  245. // 获取当前时间
  246. getDateStr() {
  247. this.$store.dispatch({
  248. type: "commActions",
  249. key: "getDateStr",
  250. }).then((data) => {
  251. if (data) {
  252. this.dateStr = data;
  253. }
  254. });
  255. },
  256. showModal(content) {
  257. uni.showModal({
  258. content,
  259. showCancel: false
  260. });
  261. },
  262. // 清除定时器
  263. clearTimer() {
  264. if (this.timer) {
  265. clearInterval(this.timer);
  266. this.timer = null;
  267. }
  268. }
  269. },
  270. }
  271. </script>
  272. <style lang="less">
  273. .allocationPerson-page {
  274. height: 100%;
  275. .scroll-y {
  276. height: calc(100% - 87.5rpx);
  277. padding-top: 15rpx;
  278. .blockTitle {
  279. font-size: 22.5rpx;
  280. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  281. font-weight: 400;
  282. color: #666F80;
  283. padding: 15rpx 0;
  284. padding-left: 25rpx;
  285. border-bottom: 0.62rpx solid #DADEE6;
  286. }
  287. .date-view {
  288. padding: 0 25rpx;
  289. background: #fff;
  290. .row {
  291. display: flex;
  292. align-items: center;
  293. height: 62.5rpx;
  294. border-top: 0.62rpx solid #DADEE6;
  295. .label {
  296. width: 112.5rpx;
  297. font-size: 22.5rpx;
  298. color: #292C33;
  299. }
  300. .date-box {
  301. padding-left: 25rpx;
  302. flex: 1;
  303. }
  304. }
  305. }
  306. }
  307. }
  308. </style>