batchDistribution.vue 6.9 KB

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