batchDistribution.vue 8.4 KB

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