allocationPerson.vue 6.2 KB

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