batchDistribution.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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. //初始化默认时间
  77. const currentDate = new Date();
  78. _details.startDate = `${currentDate.getFullYear()}-${currentDate.getMonth()+1}-${currentDate.getDate()} 00:00`;
  79. _details.endDate = _details.planEndDate;
  80. // 强制刷新返回查核列表页面
  81. if (getCurrentPages().length === 1) {
  82. const {
  83. situationId,
  84. checkId,
  85. checkGroupId,
  86. planStartDate,
  87. planEndDate
  88. } = _details;
  89. uni.redirectTo({
  90. url: `/pages/editCheckList/editCheckList?situationId=${situationId}&checkId=${checkId}&checkGroupId=${checkGroupId}&startDate=${planStartDate}&endDate=${planEndDate}`
  91. });
  92. }
  93. this.getComponentInfo(_details);
  94. },
  95. destroyed() {
  96. this.clearTimer();
  97. },
  98. methods: {
  99. getComponentInfo(details) {
  100. const {
  101. checkGroupId,
  102. situationType,
  103. checkId,
  104. // deptId,
  105. checkedList,
  106. empId,
  107. empName,
  108. categoryId
  109. } = details;
  110. this.details = details;
  111. const deptId = checkedList.join(',');
  112. this.getEmpDeptTree(checkGroupId, situationType,deptId);
  113. //查核人回显
  114. if(empId&&empName){
  115. const empIdArr = empId.split(',');
  116. const empNameArr = empName.split(',');
  117. this.checkPresonList = empIdArr.map((item,index)=>({
  118. employeeId:Number(item),
  119. employeeName:empNameArr[index]
  120. }));
  121. }
  122. //查核要点回显
  123. if(categoryId){
  124. this.checkedPointList = categoryId.map((item)=>({
  125. categoryId:Number(item),
  126. }));
  127. }
  128. },
  129. // 查询部门人员树
  130. getEmpDeptTree(checkGroupId, situationType,deptId) {
  131. this.$store.dispatch({
  132. type: 'allocationPerson/commActions',
  133. key: "getGroupEmpList",
  134. data: {
  135. checkGroupId,
  136. situationType,
  137. deptId
  138. }
  139. }).then(data => {
  140. if (data) {
  141. this.empList = data.sysCheckGroupEmployees || [];
  142. if (situationType == 3) this.checkPointList = data.pointCategoryBOs || [] ;
  143. }
  144. });
  145. },
  146. //查核要点选择回调
  147. checkChanged(data) {
  148. // console.log({data});
  149. const {
  150. checkedList
  151. } = data;
  152. this.checkedPointList = checkedList;
  153. },
  154. //查核人选择回调
  155. onCheckPerosonChanged(data) {
  156. const {
  157. checkedList
  158. } = data;
  159. this.checkPresonList = checkedList;
  160. },
  161. // 指派查核人员改变
  162. changeDetails(selectVal, selectData, index) {
  163. this.details = {
  164. ...this.details,
  165. empId: selectData.employeeId,
  166. empName: selectData.employeeName
  167. }
  168. },
  169. // 时间变化
  170. changeDateTime(dateObj, pickType) {
  171. if (pickType === 'startDate') { // 开始时间变化
  172. this.diffDateTime(dateObj.f3, this.details.endDate);
  173. } else {
  174. this.diffDateTime(this.details.startDate, dateObj.f3);
  175. }
  176. this.details = {
  177. ...this.details,
  178. [pickType]: dateObj.f3
  179. };
  180. },
  181. // 开始时间和结束时间对比
  182. diffDateTime(startTime, endTime) {
  183. if (moment(startTime).valueOf() > moment(endTime).valueOf()) {
  184. this.showModal('开始时间不能大于结束时间');
  185. }
  186. },
  187. // 点击确定
  188. sure() {
  189. const {startDate,endDate} = this.details;
  190. const empId = (this.checkPresonList.map(item => item.employeeId)).join(',');
  191. const empName = (this.checkPresonList.map(item => item.employeeName)).join(',');
  192. if (!empId) {
  193. return this.showModal('请选择查核人');
  194. }
  195. if (!startDate) {
  196. return this.showModal('请选择开始时间');
  197. }
  198. if (!endDate) {
  199. return this.showModal('请选择结束时间');
  200. }
  201. const {checkId,checkedList,checkNo,situationType} = this.details;
  202. const categoryIds = this.checkedPointList.map(item=>item.categoryId);
  203. const data = {
  204. "checkId": checkId, // 计划id
  205. "deptId": JSON.parse(JSON.stringify(checkedList)), // 多个单位id列表
  206. "empId": empId, // 查核者id
  207. "empName": empName, // 查核者名字
  208. "startDate": startDate, // 开始时间
  209. "endDate":endDate, // 结束时间
  210. "checkNo":checkNo,
  211. "situationType":Number(situationType),
  212. "categoryIds":categoryIds
  213. }
  214. this.$store.dispatch({
  215. type: 'batchDistribution/commActions',
  216. key: 'batchCheckEmp',
  217. data: {
  218. ...data
  219. }
  220. }).then(data => {
  221. if (data) {
  222. uni.showModal({
  223. title: '分配成功!',
  224. content: '',
  225. showCancel: false,
  226. success: function(res) {
  227. if (res.confirm) {
  228. // console.log('用户点击确定');
  229. let pages = getCurrentPages(); // 获取当前页面栈
  230. let prePage = pages[pages.length - 2]; // 上一个页面
  231. prePage.ifInit = true;
  232. uni.navigateBack({
  233. delta: 1
  234. });
  235. }
  236. }
  237. });
  238. }
  239. });
  240. },
  241. // 获取当前时间
  242. getDateStr() {
  243. this.$store.dispatch({
  244. type: "commActions",
  245. key: "getDateStr",
  246. }).then((data) => {
  247. if (data) {
  248. this.dateStr = data;
  249. }
  250. });
  251. },
  252. showModal(content) {
  253. uni.showModal({
  254. content,
  255. showCancel: false
  256. });
  257. },
  258. // 清除定时器
  259. clearTimer() {
  260. if (this.timer) {
  261. clearInterval(this.timer);
  262. this.timer = null;
  263. }
  264. }
  265. },
  266. }
  267. </script>
  268. <style lang="less">
  269. .allocationPerson-page {
  270. height: 100%;
  271. .scroll-y {
  272. height: calc(100% - 87.5rpx);
  273. padding-top: 15rpx;
  274. .blockTitle {
  275. font-size: 22.5rpx;
  276. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  277. font-weight: 400;
  278. color: #666F80;
  279. padding: 15rpx 0;
  280. padding-left: 25rpx;
  281. border-bottom: 0.62rpx solid #DADEE6;
  282. }
  283. .date-view {
  284. padding: 0 25rpx;
  285. background: #fff;
  286. margin-bottom: 12.5rpx;
  287. border-bottom: 0.62rpx solid #DADEE6;
  288. .row {
  289. display: flex;
  290. align-items: center;
  291. height: 62.5rpx;
  292. border-bottom: 0.62rpx solid #DADEE6;
  293. .label {
  294. width: 112.5rpx;
  295. font-size: 22.5rpx;
  296. color: #292C33;
  297. }
  298. .date-box {
  299. padding-left: 25rpx;
  300. flex: 1;
  301. }
  302. &:last-child {
  303. border-bottom: 0;
  304. }
  305. }
  306. }
  307. }
  308. }
  309. </style>