소스 검색

协助元凯调整特殊节假日设置的功能

Lijy 1 년 전
부모
커밋
a17f31ca9d
1개의 변경된 파일224개의 추가작업 그리고 20개의 파일을 삭제
  1. 224 20
      fhKeeper/formulahousekeeper/timesheet/src/views/settings/timetype.vue

+ 224 - 20
fhKeeper/formulahousekeeper/timesheet/src/views/settings/timetype.vue

@@ -434,7 +434,7 @@
 
         <!-- 特殊节假日设置 -->
         <div class="yanjiu">
-            <p style="margin-left:10px;color:#666;">{{'特殊节假日设置'}}</p>
+            <p style="margin: 0 68px 0 10px;color:#666;">{{'特殊节假日设置'}}</p>
             <el-button size="small" type="primary" @click="holidaySeeting()">设置</el-button>
             <span style="margin-left:10px;color:#999;">{{'设置部门或人员的特殊节假日'}}</span>
         </div>
@@ -450,21 +450,41 @@
             <el-button  type="primary" @click="submitInsert" :loading="addLoading">{{ $t('save') }}</el-button>
         </div>
         <!-- 特殊节假日设置列表 -->
-        <el-dialog :title="'特殊节假日列表'" show-header="false" v-if="holidaySeetingDialog" :visible.sync="holidaySeetingDialog" :close-on-click-modal="false" customClass="customWidth" width="600px">
+        <el-dialog :title="'特殊节假日列表'" show-header="false" :top="'10vh'" v-if="holidaySeetingDialog" :visible.sync="holidaySeetingDialog" :close-on-click-modal="false" customClass="customWidth" width="1000px">
             <el-table :data="holidaySeetingDatas" highlight-current-row  height="400" style="width: 100%;">
             <el-table-column prop="holidayDate" width="120" :label="'日期'">
             </el-table-column>
-            <el-table-column prop="name" :label="'有效范围'" >
+            <el-table-column prop="name" :label="'有效范围'" width="120">
                 <template slot-scope="scope">
                     {{scope.row.rangeType==0?"全公司":"部分成员"}}
                 </template>
             </el-table-column>
-            <el-table-column prop="name" :label="'有效部门'" ></el-table-column>
-            <el-table-column prop="name" :label="'有效人员'" ></el-table-column>
-            <el-table-column :label="$t('operation')" width="150">
+            <el-table-column prop="name" :label="'有效部门'" width="300">
+                <template slot-scope="scope">
+                    <div v-if="user.userNameNeedTranslate != '1'">{{ scope.row.targetDeptsNames }}</div>
+                    <div v-else>
+                        <span v-for="(v,i) in (scope.row.newDeptName || [])">
+                            <ww-open-data type='departmentName' :openid='v'></ww-open-data>
+                            <span v-if="i < (scope.row.newDeptName || []).length - 1">,</span>
+                        </span>
+                    </div>
+                </template>
+            </el-table-column>
+            <el-table-column prop="name" :label="'有效人员'" width="300">
+                <template slot-scope="scope">
+                    <div v-if="user.userNameNeedTranslate != '1'">{{ scope.row.targetUsersNames }}</div>
+                    <div v-else>
+                        <span v-for="(v,i) in (scope.row.newDeptName || [])">
+                            <ww-open-data type='userName' :openid='v'></ww-open-data>
+                            <span v-if="i < (scope.row.newUserName || []).length - 1">,</span>
+                        </span>
+                    </div>
+                </template>
+            </el-table-column>
+            <el-table-column :label="$t('operation')" width="150" fixed="right">
                 <template slot-scope="scope" >
                     <el-button size="small" type="primary" @click="addNewHolidaySeeting(scope.row)">{{ $t('bian-ji') }}</el-button>
-                    <el-button size="small" type="danger" @click="deleteSubPro(scope.row)">{{ $t('btn.delete') }}</el-button>
+                    <el-button size="small" type="danger" @click="deleteHolidaySeeting(scope.row)">{{ $t('btn.delete') }}</el-button>
                 </template>
             </el-table-column>
             </el-table>
@@ -474,7 +494,7 @@
             </div>
         </el-dialog>
         <!-- 新增节假日设置 -->
-        <el-dialog :title="'特殊节假日设置'" show-header="false" v-if="addHolidaySeeting" :visible.sync="addHolidaySeeting" :close-on-click-modal="false" customClass="customWidth" width="400px">
+        <el-dialog :title="'特殊节假日设置'" show-header="false" v-if="addHolidaySeeting" :visible.sync="addHolidaySeeting" :top="'10vh'" :close-on-click-modal="false" customClass="customWidth" width="600px">
             <el-form ref="form" :model="holidaySeetingForm" label-width="80px">
                 <el-form-item label="日期">
                     <el-date-picker v-model="holidaySeetingForm.holidayDate"
@@ -488,12 +508,27 @@
                     <el-radio v-model="holidaySeetingForm.rangeType" label="0">全公司</el-radio>
                     <el-radio v-model="holidaySeetingForm.rangeType" label="1">部分成员</el-radio>
                 </el-form-item>
-                <el-form-item v-if="holidaySeetingForm.rangeType==1"label="有效部门">
-
-                </el-form-item>
-                <el-form-item v-if="holidaySeetingForm.rangeType==1" label="有效人员">
-
-                </el-form-item>
+                <div style="height: 36vh" v-if="holidaySeetingForm.rangeType!=1"></div>
+                <div v-if="holidaySeetingForm.rangeType==1">
+                    <div class="specialHolidaysClass">
+                        <div class="titles">有效部门 <el-link type="primary" :underline="false" @click="showSpecialHolidays(1)">添加</el-link></div>
+                        <div class="contents">
+                            <el-tag style="margin:10px 0 0 10px" v-for="(item, index) in specialHolidaysDept.labels" :key="item.id" closable @close="specialHolidaysDelete('specialHolidaysDept', index)">
+                                <span v-if="user.userNameNeedTranslate != '1'">{{item}}</span>
+                                <span v-if="user.userNameNeedTranslate == '1'"><ww-open-data type='departmentName' :openid='item'></ww-open-data></span>
+                            </el-tag>
+                        </div>
+                    </div>
+                    <div class="specialHolidaysClass">
+                        <div class="titles">有效人员 <el-link type="primary" :underline="false" @click="showSpecialHolidays(2)">添加</el-link></div>
+                        <div class="contents">
+                            <el-tag style="margin:10px 0 0 10px" v-for="(item, index) in specialHolidaysUser.labels" :key="item.id" closable @close="specialHolidaysDelete('specialHolidaysUser', index)">
+                                <span v-if="user.userNameNeedTranslate != '1'">{{item}}</span>
+                                <span v-if="user.userNameNeedTranslate == '1'"><ww-open-data type='userName' :openid='item'></ww-open-data></span>
+                            </el-tag>
+                        </div>
+                    </div>
+                </div>
             </el-form>
             <div slot="footer" class="dialog-footer">
                 <el-button type="primary" @click="addHolidaySeeting = false" >{{ $t('Shutdown') }}</el-button>
@@ -652,6 +687,45 @@
                 <el-button type="primary" @click="setWhiteList()">{{ $t('btn.determine') }}</el-button>
             </div>
         </el-dialog>
+
+        <!-- 特殊节假日设置 -->
+        <el-dialog :title="specialHolidays == 1 ? '请选择部门' : '请选择人员'" :top="'10vh'"  v-if="specialHolidaysDialog" :visible.sync="specialHolidaysDialog" :close-on-click-modal="false" customClass="customWidth" width="600px">
+            <div v-if="user.userNameNeedTranslate == '1'">
+                <el-input placeholder="请输入名字搜索" v-model.trim="wxFilterText" clearable @clear="clearEchartDepartment()" class="input-with-select">
+                    <el-button slot="append" icon="el-icon-search" @click="echartDepartment()"></el-button>
+                </el-input>
+            </div>
+            <div class="tree" style="height:400px">
+                <el-scrollbar style="height:100%">
+                    <el-input v-if="user.userNameNeedTranslate != '1'"
+                    :placeholder="$t('keywordfiltering')"
+                    v-model="filterText">
+                    </el-input>
+                <el-tree :data="whiteListAll" :key="searchPersonnelFlgnum" :default-expand-all="searchPersonnelFlg" show-checkbox :props="defaultProps" node-key="id"
+                    ref="specialHolidaysTree"
+                    highlight-current  :filter-node-method="filterNode">
+                        <span class="custom-tree-node" slot-scope="{ node, data }">
+                            <span v-if="user.userNameNeedTranslate == '1'">
+                                <span v-if="node.data.children">
+                                    <ww-open-data type='departmentName' :openid='node.label'></ww-open-data>
+                                </span>
+                                <span v-else>
+                                    <ww-open-data type='userName' :openid='node.label'></ww-open-data>
+                                </span>
+                            </span>
+                            <span v-if="user.userNameNeedTranslate != '1'">
+                                {{ node.label }}
+                            </span>
+                        </span>
+                    </el-tree>
+                </el-scrollbar>
+            </div>
+            <!-- <div>已选中&nbsp;{{chosenMembCount}}&nbsp;人</div>         :default-checked-keys="alreadyPartArray"  @check-change="onTreeItemChange" -->
+            <div slot="footer" class="dialog-footer">
+                <el-button @click="specialHolidaysDialog = false">{{ $t('btn.cancel') }}</el-button>
+                <el-button type="primary" @click="specialHolidaysChange()">{{ $t('btn.determine') }}</el-button>
+            </div>
+        </el-dialog>
     </section>
 </template>
 <script>
@@ -789,9 +863,21 @@
                 holidaySeetingDialog:false,
                 addHolidaySeeting:false,
                 holidaySeetingForm:{
-                    rangeType:"0"
+                    rangeType:"0",
+                    holidayDate: ''
+                },
+                holidaySeetingDatas:[],
+
+                specialHolidays: 0, // 1 部门, 2 人员
+                specialHolidaysDialog: false,
+                specialHolidaysDept: {
+                    values: [],
+                    labels: []
                 },
-                holidaySeetingDatas:[]
+                specialHolidaysUser: {
+                    values: [],
+                    labels: []
+                }
             };
         },
         watch: {
@@ -822,13 +908,56 @@
             }, 1000)
         },
          methods: {
+            setspecialHolidaysNodes() {
+                let key = []
+                if(this.specialHolidays == 1) {
+                    key = this.specialHolidaysDept.values || []
+                }
+                if(this.specialHolidays == 2) {
+                    key = this.specialHolidaysUser.values || []
+                }
+                console.log(key, '<=== 设置数据')
+                this.$refs.specialHolidaysTree.setCheckedKeys(key)
+            },
+            specialHolidaysDelete(flied, index) {
+                this[flied].labels.splice(index, 1)
+                this[flied].values.splice(index, 1)
+            },
+            specialHolidaysChange() {
+                let selectList = this.$refs.specialHolidaysTree.getCheckedNodes();
+                if(this.specialHolidays == 1) {
+                    let values = selectList.map(item => item.id)
+                    let labels = selectList.map(item => item.label)
+                    this.specialHolidaysDept = { values, labels }
+                }
+                if(this.specialHolidays == 2) {
+                    let values = selectList.filter(item => !item.userList).map(item => item.id)
+                    let labels = selectList.filter(item => !item.userList).map(item => item.label)
+                    this.specialHolidaysUser = { values, labels }
+                }
+                this.specialHolidaysDialog = false
+            },
+            showSpecialHolidays(key) {
+                this.specialHolidays = key
+                this.filterText = ''
+                this.getWhiteListAll()
+                this.specialHolidaysDialog = true
+            },
             submitInsertHolidaySeeting(){
-                this.http.post('/holiday-setting/holidaySetting',this.holidaySeetingForm,res => {
+                let newForm = {
+                    ...this.holidaySeetingForm,
+                    targetUsers: this.specialHolidaysUser.values.join(','),
+                    targetDepts: this.specialHolidaysDept.values.join(','),
+                }
+                this.http.post('/holiday-setting/holidaySetting',{...newForm},res => {
                     if(res.code == 'ok'){
                         this.$message({
-                            message: "新增成功",
+                            message: "保存成功",
                             type: 'success'
                         })
+                        this.specialHolidaysDialog = false
+                        this.addHolidaySeeting = false
+                        this.getHolidaySeetingList()
                     }else {
                         this.$message({
                             message: res.msg,
@@ -840,6 +969,8 @@
                         message: err,
                         type: 'error'
                     })
+                    this.specialHolidaysDialog = false
+                    this.addHolidaySeeting = false
                 })
             },
             onHideTask() {
@@ -858,6 +989,16 @@
                     this.holidaySeetingForm.holidayDate = item.holidayDate
                     this.holidaySeetingForm.id = item.id
                     this.holidaySeetingForm.rangeType = item.rangeType+""
+                    let newDeptForm = {
+                        values: item.newDeptId,
+                        labels: item.newDeptName
+                    }
+                    let newUserForm = {
+                        values: item.newUserId,
+                        labels: item.newUserName
+                    }
+                    this.specialHolidaysDept = newDeptForm
+                    this.specialHolidaysUser = newUserForm
                 }
                 this.addHolidaySeeting = true;
             },
@@ -870,7 +1011,13 @@
                 this.http.post('/holiday-setting/list',{
                 },res => {
                     if(res.code == 'ok'){
-                        this.holidaySeetingDatas=res.data
+                        res.data.forEach((item) => {
+                            item.newDeptName = item.targetDeptsNames ? item.targetDeptsNames.split(',') : []
+                            item.newUserName = item.targetUsersNames ? item.targetUsersNames.split(',') : []
+                            item.newDeptId = item.targetDepts ? item.targetDepts.split(',') : []
+                            item.newUserId = item.targetUsers ? item.targetUsers.split(',') : []
+                        })
+                        this.holidaySeetingDatas = res.data
                     }else {
                         this.$message({
                             message: res.msg,
@@ -1159,6 +1306,36 @@
                 }
                 this.addSubProject = true;
             },
+            deleteHolidaySeeting(item) {
+                this.$confirm('确定删除这条数据吗?','删除', {
+                    confirmButtonText: this.$t('btn.determine'),
+                    cancelButtonText: this.$t('btn.cancel'),
+                    type: "warning"
+                })
+                .then(() => {
+                    this.listLoading = true;
+                    this.http.post('/holiday-setting/delete',{ 
+                        id: item.id 
+                    },
+                    res => {
+                        if (res.code == "ok") {
+                            this.$message({
+                                message: this.$t('message.successfullyDeleted'),
+                                type: "success"
+                            });
+                            this.getHolidaySeetingList();
+                        }
+                    },
+                    error => {
+                        this.$message({
+                            message: error,
+                            type: "error"
+                        });
+                        }
+                    );
+                })
+                .catch(() => {});
+            },
             deleteSubPro(subProject) {
                 this.$confirm(this.$t('takethisone') + subProject.name + this.$t('shu-ju-ma'),this.$t('btn.delete'), {
                     confirmButtonText: this.$t('btn.determine'),
@@ -1256,8 +1433,14 @@
                 },res => {
                     if(res.code == 'ok'){
                         let list = res.data
-                        this.haveUsersList(list)
+                        if(this.specialHolidays != 1) {
+                            this.haveUsersList(list)
+                        }
                         this.whiteListAll = JSON.parse(JSON.stringify(list))
+
+                        if(this.specialHolidays != 0) {
+                            this.setspecialHolidaysNodes()
+                        }
                     }else {
                         this.$message({
                             message: res.msg,
@@ -1297,6 +1480,7 @@
             //     // this.chosenMembCount = list.length;
             // },
             addWhite(){
+                this.specialHolidays = 0
                 this.whiteListDialog = true
                 this.filterText = ''
                 this.getWhiteListAll()
@@ -1720,4 +1904,24 @@
 .panelFixation {
     height: 300px;
 }
+
+.specialHolidaysClass {
+    display: flex;
+    width: 100%;
+    padding: 0 10px;
+    flex-wrap: wrap;
+    .titles {
+        width: 100%;
+        display: flex;
+        padding-right: 20px;
+        justify-content: space-between;
+        align-items: center;
+    }
+    .contents {
+        width: 100%;
+        height: 15.5vh;
+        overflow-y: auto;
+        overflow-x: hidden;
+    }
+}
 </style>