batchDistribution.vue 8.4 KB

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