batchDistribution.vue 8.5 KB

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