allocationPerson.vue 8.3 KB

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