123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320 |
- <template>
- <view class="allocationPerson-page">
- <scroll-view class="scroll-y" scroll-y="true">
-
- <template v-if="title === '指派查核人员'">
- <view class="blockTitle">查核人</view>
- <tm-checked-group :list="empList" :defaultValue='checkPresonList' :setting="{
- value: 'employeeId',
- name: 'employeeName'
- }" :openkeys="[0]" @change="onCheckPerosonChanged" />
- <view class="blockTitle" v-if="details.situationType == 3">要点分类</view>
- <tm-checked-group v-if="details.situationType == 3" :list="checkPointList" :defaultValue='checkedPointList' :setting="{
- value: 'categoryId',
- name: 'categoryName'
- }" :openkeys="[0]" @change="onCheckCategoryChanged" />
- </template>
- <template v-else>
- <div class="date-view">
- <view class="row">
- <text class="label">开始时间</text>
- <view class="date-box">
- <date-time-picker :height="100" :start="details.planStartDate" :end="details.planEndDate"
- :defaultValue="details.startDate" placeholder="请选择起始时间" pickType="startDate"
- @change="changeDateTime" />
- </view>
- </view>
- <view class="row">
- <text class="label">结束时间</text>
- <view class="date-box">
- <date-time-picker :height="100" :start="details.planStartDate" :end="details.planEndDate"
- :defaultValue="details.endDate" placeholder="请选择结束时间" pickType="endDate"
- @change="changeDateTime" />
- </view>
- </view>
- </div>
- </template>
- </scroll-view>
- <view class="fixed-buttom-btn" @click="sure">
- <text class="btn-text">确定</text>
- </view>
- </view>
- </template>
- <script>
- // 查核列表编辑 查核人和计划时间
- import {
- mapState
- } from "vuex";
- import moment from 'moment';
- export default {
- computed: {
- ...mapState({
- checkList: state => state.editCheckList.checkList
- })
- },
- data() {
- return {
- title: '', // 导航标题
- // 查核组员列表
- empList: [],
- //查核要点列表
- checkPointList:[],
- //选中的查核要点
- checkedPointList:[],
- //选中的查核人
- checkPresonList:[],
- // 组件信息
- details: {},
- // 服务器时间
- dateStr: '',
- timer: null,
- // 点击确定按钮是否直接保存
- isSubmit: false
- }
- },
- onLoad({
- details
- }) {
- const _details = details ? JSON.parse(details) : {};
- // 强制刷新返回查核列表页面
- if (getCurrentPages().length === 1) {
- const {
- situationId,
- checkId,
- checkGroupId,
- planStartDate,
- planEndDate
- } = _details;
- uni.redirectTo({
- url: `/pages/editCheckList/editCheckList?situationId=${situationId}&checkId=${checkId}&checkGroupId=${checkGroupId}&startDate=${planStartDate}&endDate=${planEndDate}`
- });
- }
- this.getComponentInfo(_details);
- },
- watch: {
- title(newVal, oldVal) {
- if (newVal === '设置查核时间') {
- this.getDateStr();
- !this.timer && (this.timer = setInterval(() => {
- this.getDateStr();
- }, 10000));
- } else {
- this.clearTimer();
- }
- }
- },
- destroyed() {
- this.clearTimer();
- },
- methods: {
- //查核人选择回调
- onCheckPerosonChanged(data){
- const {checkedList} = data;
- this.checkPresonList = checkedList;
- const empId = checkedList.map(item=>item.employeeId);
- const empName = checkedList.map(item=>item.employeeName);
- this.details = {
- ...this.details,
- empId:empId.join(','),
- empName:empName.join(','),
- }
- },
- onCheckCategoryChanged(data){
- const {checkedList} = data;
- this.checkedPointList = checkedList;
- const categoryIds = checkedList.map(item=>item.categoryId);
- this.details = {
- ...this.details,
- categoryIds:categoryIds,
- }
- },
- getComponentInfo(details) {
- const {checkGroupId,situationType,title,checkId,deptId} = details;
- this.setNavigationBarTitle(title);
- this.details = details;
- this.getEmpDeptTree(checkGroupId,situationType,deptId);
- // if(situationType == 3){
- // this.getCheckPointList(checkId,situationType);
- // }
- },
- // 查询部门人员树
- getEmpDeptTree(checkGroupId, situationType,deptId) {
- this.$store.dispatch({
- type: 'allocationPerson/commActions',
- key: "getGroupEmpList",
- data: {
- checkGroupId,
- situationType,
- deptId
- }
- }).then(data => {
- if (data) {
- this.empList = data.sysCheckGroupEmployees || [];
- this.checkPointList = data.pointCategoryBOs ||[];
- }
- });
- },
-
- // 时间变化
- changeDateTime(dateObj, pickType) {
- if (pickType === 'startDate') { // 开始时间变化
- this.diffDateTime(dateObj.f3, this.details.endDate);
- } else {
- this.diffDateTime(this.details.startDate, dateObj.f3);
- }
- this.details = {
- ...this.details,
- [pickType]: dateObj.f3
- };
- },
- // 开始时间和结束时间对比
- diffDateTime(startTime, endTime) {
- if (moment(startTime).valueOf() > moment(endTime).valueOf()) {
- this.showModal('开始时间不能大于结束时间');
- }
- },
- // 点击确定
- sure() {
- const {
- empId,
- empName,
- categoryIds,
- startDate,
- endDate
- } = this.details;
-
- if (this.isSubmit === true) {
- return this.changeCheckList(this.checkList);
- }
- if (this.title === '指派查核人员') {
- if (empName.length==0) {
- return this.showModal('请选择查核人');
- }
- this.setNavigationBarTitle('设置查核时间');
- } else {
- if (!startDate) {
- return this.showModal('请选择开始时间');
- }
- if (!endDate) {
- return this.showModal('请选择结束时间');
- }
- if (empName.length==0) {
- this.setNavigationBarTitle('指派查核人员');
- this.isSubmit = true;
- } else {
- this.changeCheckList(this.checkList);
- }
- }
- },
- // 更改查核列表数据
- changeCheckList(data) {
- const {
- situationId,
- checkId,
- empId,
- empName,
- categoryIds,
- checkGroupId
- } = this.details;
-
- let checkList = this.checkList.map((item, i) => {
- if (this.details.index === i) {
- return {
- ...item,
- ...this.details
- }
- } else {
- return item;
- }
- });
- // console.log({checkList});
- // return;
- this.$store.commit({
- type: 'editCheckList/comChangeState',
- key: 'checkList',
- data: checkList
- });
- // 关闭当前页面,返回上一页面
- uni.navigateBack({
- delta: 1
- });
- },
- // 修改导航名称
- setNavigationBarTitle(title) {
- this.title = title;
- uni.setNavigationBarTitle({
- title
- });
- },
- // 获取当前时间
- getDateStr() {
- this.$store.dispatch({
- type: "commActions",
- key: "getDateStr",
- }).then((data) => {
- if (data) {
- this.dateStr = data;
- }
- });
- },
- showModal(content) {
- uni.showModal({
- content,
- showCancel: false
- });
- },
- // 清除定时器
- clearTimer() {
- if (this.timer) {
- clearInterval(this.timer);
- this.timer = null;
- }
- }
- },
- }
- </script>
- <style lang="less">
- .allocationPerson-page {
- height: 100%;
- .scroll-y {
- height: calc(100% - 87.5rpx);
- padding-top: 15rpx;
-
- .blockTitle {
- font-size: 22.5rpx;
- font-family: SourceHanSansCN-Normal, SourceHanSansCN;
- font-weight: 400;
- color: #666F80;
- padding: 15rpx 0;
- padding-left: 25rpx;
- border-bottom: 0.62rpx solid #DADEE6;
- }
- .date-view {
- padding: 0 25rpx;
- background: #fff;
- .row {
- display: flex;
- align-items: center;
- height: 62.5rpx;
- border-top: 0.62rpx solid #DADEE6;
- .label {
- width: 112.5rpx;
- font-size: 22.5rpx;
- color: #292C33;
- }
- .date-box {
- padding-left: 25rpx;
- flex: 1;
- }
- }
- }
- }
- }
- </style>
|