|
@@ -1,334 +1,334 @@
|
|
-<!-- DOM模板部分 -->
|
|
|
|
-<template>
|
|
|
|
- <el-dialog
|
|
|
|
- :close-on-click-modal="false"
|
|
|
|
- :close-on-press-escape="false"
|
|
|
|
- :title="title"
|
|
|
|
- :append-to-body="true"
|
|
|
|
- :visible.sync="isUserVisible"
|
|
|
|
- width="80%"
|
|
|
|
- top="50px"
|
|
|
|
- >
|
|
|
|
- <!-- 基本信息 -->
|
|
|
|
- <el-row class="filter-container">
|
|
|
|
- <el-col>
|
|
|
|
- <span>姓名:{{user.userName}}</span>
|
|
|
|
- <span style="margin-left: 15px;">月份:{{dateObj.year}}年{{dateObj.month}}月</span>
|
|
|
|
- <span style="margin-left: 15px;">所属部门:{{user.orgName}}</span>
|
|
|
|
- </el-col>
|
|
|
|
- </el-row>
|
|
|
|
-
|
|
|
|
- <!-- 功能按钮 -->
|
|
|
|
- <el-row class="filter-container">
|
|
|
|
- <el-col>
|
|
|
|
- <el-button type="primary" icon="el-icon-plus" size="medium" @click="add">{{ $t("common.add") }}</el-button>
|
|
|
|
- <el-button type="danger" icon="el-icon-delete" size="medium" @click="batchDelete">
|
|
|
|
- {{ $t("common.delete") }}
|
|
|
|
- </el-button>
|
|
|
|
- </el-col>
|
|
|
|
- </el-row>
|
|
|
|
-
|
|
|
|
- <!-- 日历内容 -->
|
|
|
|
- <el-calendar
|
|
|
|
- class="calendarWks"
|
|
|
|
- v-model="currDate"
|
|
|
|
- @change="calChange"
|
|
|
|
- >
|
|
|
|
- <!-- 这里使用的是 2.5 slot 语法,对于新项目请使用 2.6 slot 语法-->
|
|
|
|
- <template slot="dateCell" slot-scope="{date, data}">
|
|
|
|
- <p :class="data.isSelected ? 'is-selected' : ''">
|
|
|
|
- {{ data.day.split('-').slice(2).join('-') }}
|
|
|
|
- <el-checkbox v-model="checks[data.day]" :disabled="data.type == 'current-month' ? false : true"></el-checkbox>
|
|
|
|
- <!--<template v-for="item in userDateList">
|
|
|
|
- <el-checkbox v-if="item.day == data.day" v-model="checks[data.day]" :disabled="data.type == 'current-month' ? false : true"></el-checkbox>
|
|
|
|
- </template>-->
|
|
|
|
- <!--{{dealMyDate(data.day)}}-->
|
|
|
|
- </p>
|
|
|
|
- <!--自定义内容-->
|
|
|
|
- <div>
|
|
|
|
- <div v-for="item in userDateList">
|
|
|
|
- <div v-if="item.day == data.day">
|
|
|
|
- <span v-for="obj in item.data" :key="obj.keys" :style="obj.color" class="clsName">{{obj.text}}</span>
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
- </template>
|
|
|
|
- </el-calendar>
|
|
|
|
-
|
|
|
|
- <!-- 【新增】组件-->
|
|
|
|
- <edit-calendar
|
|
|
|
- ref="calendar"
|
|
|
|
- :dialog-visible="dialog.isVisible"
|
|
|
|
- :title="dialog.title"
|
|
|
|
- @close="editClose"
|
|
|
|
- @success="editSuccess"
|
|
|
|
- />
|
|
|
|
- </el-dialog>
|
|
|
|
-</template>
|
|
|
|
-
|
|
|
|
-<!-- JS部分 -->
|
|
|
|
-<script>
|
|
|
|
- // 【新增】组件
|
|
|
|
- import EditCalendar from "./EditCalendar"
|
|
|
|
- // 加载共通的方法
|
|
|
|
- import { initQueryParams, initDicts } from '@/utils/commons'
|
|
|
|
- // 【设置班表】-API
|
|
|
|
- import settingClassSchedulApi from "@/api/classScheduleMgr/settingClassSchedul"
|
|
|
|
- export default{
|
|
|
|
- name: 'CalendarUser',
|
|
|
|
- components: { EditCalendar },
|
|
|
|
- props: {
|
|
|
|
- dialogVisible: {
|
|
|
|
- type: Boolean,
|
|
|
|
- default: false
|
|
|
|
- },
|
|
|
|
- title: {
|
|
|
|
- type: String,
|
|
|
|
- default: ''
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- data () {
|
|
|
|
- return {
|
|
|
|
- checks: {}, // 选中日期
|
|
|
|
- currDate: '', // 默认日期
|
|
|
|
- userDateList: {}, // 数据
|
|
|
|
- dateObj: {}, // 年月对象
|
|
|
|
- user: {}, // 人员对象
|
|
|
|
- dialog: {
|
|
|
|
- isVisible: false,
|
|
|
|
- title: ""
|
|
|
|
- },
|
|
|
|
- dicts: {
|
|
|
|
- NATION: {}
|
|
|
|
- },
|
|
|
|
- queryParams: initQueryParams({})
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- // 实例已经在内存中创建好,此时data和methods已将ok,如果要操作data中的数据或是调用methods中的方法,最早只能在created中操作
|
|
|
|
- created() {
|
|
|
|
- // 加载【字典】
|
|
|
|
- initDicts(['NATION'], this.dicts);
|
|
|
|
- },
|
|
|
|
- computed: {
|
|
|
|
- isUserVisible: {
|
|
|
|
- get () {
|
|
|
|
- return this.dialogVisible
|
|
|
|
- },
|
|
|
|
- set () {
|
|
|
|
- this.close()
|
|
|
|
- this.reset()
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- nationList() {
|
|
|
|
- return convertEnum(this.dicts.NATION)
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- mounted () {
|
|
|
|
- /*this.$nextTick(() => {
|
|
|
|
- // 点击前一个月
|
|
|
|
- let prevBtn = document.querySelector(
|
|
|
|
- '.el-calendar__button-group .el-button-group>button:first-child');
|
|
|
|
- prevBtn.addEventListener('click', (e) => {
|
|
|
|
- console.log(e);
|
|
|
|
- })
|
|
|
|
- })
|
|
|
|
-
|
|
|
|
- this.$nextTick(() => {
|
|
|
|
- // 点击后一个月
|
|
|
|
- let prevBtn = document.querySelector(
|
|
|
|
- '.el-calendar__button-group .el-button-group>button:last-child');
|
|
|
|
- prevBtn.addEventListener('click', (e) => {
|
|
|
|
- console.log(this.value);
|
|
|
|
- })
|
|
|
|
- })*/
|
|
|
|
- },
|
|
|
|
- methods: {
|
|
|
|
- dealMyDate(v) {
|
|
|
|
- console.log(v)
|
|
|
|
- /*let len = this.userDateList.length
|
|
|
|
- let res = "<div>"
|
|
|
|
- for(let i=0; i<len; i++){
|
|
|
|
- if(this.userDateList[i].day == v) {
|
|
|
|
- let obj = this.userDateList[i]
|
|
|
|
- let leng = obj.data.length
|
|
|
|
- if(leng > 0){
|
|
|
|
- for(let j=0; j<obj.data.length; j++){
|
|
|
|
- res += "<span style=\""+ obj.data[j].color +"\" class=\"clsName\">"+ obj.data[j].text +"</span>"
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- break
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- res += "</div>"*/
|
|
|
|
- return ''
|
|
|
|
- },
|
|
|
|
- // 日历值变化事件
|
|
|
|
- calChange(e){
|
|
|
|
- console.log("日历值变化事件:", e)
|
|
|
|
- },
|
|
|
|
- // 关闭组件-事件
|
|
|
|
- close () {
|
|
|
|
- this.$emit('close')
|
|
|
|
- },
|
|
|
|
- // 重置组件内容-事件
|
|
|
|
- reset () {
|
|
|
|
-
|
|
|
|
- },
|
|
|
|
- editClose () {
|
|
|
|
- this.dialog.isVisible = false
|
|
|
|
- },
|
|
|
|
- editSuccess () {
|
|
|
|
- // 查询日历的数据
|
|
|
|
- this.fetch()
|
|
|
|
- },
|
|
|
|
- // 来自父组件的设置-函数
|
|
|
|
- setTenant (val, obj) {
|
|
|
|
- this.user = val
|
|
|
|
- this.dateObj = obj
|
|
|
|
- this.currDate = this.dateObj.year +"-"+ this.dateObj.month
|
|
|
|
- console.log("")
|
|
|
|
- // 查询日历的数据
|
|
|
|
- this.fetch()
|
|
|
|
- },
|
|
|
|
- // 【新增】按钮-事件
|
|
|
|
- add(){
|
|
|
|
- this.$refs.calendar.type = "add"
|
|
|
|
- this.$refs.calendar.setTenant(this.user, this.dicts, this.dateObj)
|
|
|
|
- this.dialog.title = this.$t("common.setting") + this.dateObj.year + this.$t("common.date.year") + this.dateObj.month + this.$t("common.date.month") + this.$t("calssSchedule.common.classSchul")
|
|
|
|
- this.dialog.isVisible = true
|
|
|
|
- console.log("this.dialog == ", this.dateObj)
|
|
|
|
- },
|
|
|
|
- // 【删除】按钮-事件
|
|
|
|
- batchDelete(){
|
|
|
|
- console.log("【删除】按钮-事件: ", this.checks)
|
|
|
|
- this.$confirm(this.$t("calssSchedule.tips.settingTips"), this.$t("common.tips"), {
|
|
|
|
- distinguishCancelAndClose: true,
|
|
|
|
- confirmButtonText: this.$t("common.confirm"),
|
|
|
|
- cancelButtonText: this.$t("common.cancel"),
|
|
|
|
- type: "warning"
|
|
|
|
- }).then(() => {
|
|
|
|
- let obj = {
|
|
|
|
- dateList: new Array(),
|
|
|
|
- strUserList: [this.user.userId]
|
|
|
|
- }
|
|
|
|
- // 获取对象的Key值(既是:日期)
|
|
|
|
- let keys = Object.keys(this.checks)
|
|
|
|
- keys.map(item => {
|
|
|
|
- if(this.checks[item]){
|
|
|
|
- obj.dateList.push(item)
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- this.clearSchedule(obj)
|
|
|
|
- }).catch(() => {})
|
|
|
|
- },
|
|
|
|
- // 【清除、全部清除】-函数
|
|
|
|
- clearSchedule(obj){
|
|
|
|
- settingClassSchedulApi.clearSchedule(obj).then(response => {
|
|
|
|
- const res = response.data
|
|
|
|
- if (res.isSuccess) {
|
|
|
|
- this.$message({
|
|
|
|
- message: this.$t("tips.deleteSuccess"),
|
|
|
|
- type: "success"
|
|
|
|
- })
|
|
|
|
- // 查询日历数据
|
|
|
|
- this.fetch()
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
- // 获取个人数据
|
|
|
|
- fetch () {
|
|
|
|
- this.loading = true
|
|
|
|
- // 分页数据
|
|
|
|
- this.queryParams.current = 1
|
|
|
|
- this.queryParams.size = 100
|
|
|
|
- // 条件,日期和用的userId
|
|
|
|
- this.queryParams.model = {
|
|
|
|
- userId: this.user.userId,
|
|
|
|
- year: this.dateObj.year,
|
|
|
|
- month: this.dateObj.month
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- settingClassSchedulApi.pageList(this.queryParams).then(response => {
|
|
|
|
- const res = response.data
|
|
|
|
- if (res.isSuccess) {
|
|
|
|
- this.formatData(res.data)
|
|
|
|
- }
|
|
|
|
- // eslint-disable-next-line no-return-assign
|
|
|
|
- }).finally(() => this.loading = false)
|
|
|
|
- },
|
|
|
|
- // 格式化,自己需要的渲染数据
|
|
|
|
- formatData(data){
|
|
|
|
- //this.tableData = res.data
|
|
|
|
- if(data.data && data.data.length > 0){
|
|
|
|
- // 数据内容
|
|
|
|
- let list = []
|
|
|
|
- let dateList = []
|
|
|
|
- data.data.map((item, index) => {
|
|
|
|
- let keys = Object.keys(item) // 对象的所有Key的数组
|
|
|
|
- keys.map(val => {
|
|
|
|
- // 如果字段是日期,格式化后,yyyy-MM-dd
|
|
|
|
- if(val.indexOf("-") > -1){
|
|
|
|
- // 如果值,存在--- "早班;#E20867,午班;#E30628"
|
|
|
|
- if(!!item[val]){
|
|
|
|
- // 组成新的数据
|
|
|
|
- let dateObj = {
|
|
|
|
- keys: 'WKS'+ Math.random(),
|
|
|
|
- day: val,
|
|
|
|
- data: []
|
|
|
|
- }
|
|
|
|
- let children = new Array()
|
|
|
|
- let arr = item[val].split(",") // ["早班;#E20867","午班;#E30628"]
|
|
|
|
- arr.map((res, keys) => {
|
|
|
|
- let result = res.split(";") // ["早班","#E20867"]/["午班","#E30628"]/
|
|
|
|
- children.push({
|
|
|
|
- day: val,
|
|
|
|
- keys: 'W'+ keys,
|
|
|
|
- text: result[0],
|
|
|
|
- color: 'background:'+ result[1]
|
|
|
|
- })
|
|
|
|
- })
|
|
|
|
- //
|
|
|
|
- dateObj.data = children
|
|
|
|
- // 赋值
|
|
|
|
- item[val] = children
|
|
|
|
- //
|
|
|
|
- dateList.push(dateObj)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- // 给数据赋值
|
|
|
|
- list.push(item)
|
|
|
|
- })
|
|
|
|
- data.data = list
|
|
|
|
-
|
|
|
|
- this.userDateList = dateList
|
|
|
|
- console.log("数据后111111:", dateList)
|
|
|
|
- }
|
|
|
|
- /*let arry = data.data
|
|
|
|
- console.log("数据后的内容:", arry[0])
|
|
|
|
- if(arry && arry.length > 0){
|
|
|
|
- this.userDateList = arry[0]
|
|
|
|
- }*/
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-</script>
|
|
|
|
-
|
|
|
|
-<!-- 全局样式 -->
|
|
|
|
-<style type="text/css">
|
|
|
|
- .calendarWks .el-calendar__button-group{
|
|
|
|
- display: none;
|
|
|
|
- }
|
|
|
|
-</style>
|
|
|
|
-
|
|
|
|
-<!-- 局部样式css -->
|
|
|
|
-<style lang="scss" scoped>
|
|
|
|
- .clsName{
|
|
|
|
- color: white;
|
|
|
|
- padding: 2px 6px;
|
|
|
|
- margin: 5px;
|
|
|
|
- -moz-border-radius: 3px;
|
|
|
|
- -webkit-border-radius: 3px;
|
|
|
|
- border-radius: 3px;
|
|
|
|
- }
|
|
|
|
-</style>
|
|
|
|
|
|
+<!-- DOM模板部分 -->
|
|
|
|
+<template>
|
|
|
|
+ <el-dialog
|
|
|
|
+ :close-on-click-modal="false"
|
|
|
|
+ :close-on-press-escape="false"
|
|
|
|
+ :title="title"
|
|
|
|
+ :append-to-body="true"
|
|
|
|
+ :visible.sync="isUserVisible"
|
|
|
|
+ width="80%"
|
|
|
|
+ top="50px"
|
|
|
|
+ >
|
|
|
|
+ <!-- 基本信息 -->
|
|
|
|
+ <el-row class="filter-container">
|
|
|
|
+ <el-col>
|
|
|
|
+ <span>姓名:{{user.userName}}</span>
|
|
|
|
+ <span style="margin-left: 15px;">月份:{{dateObj.year}}年{{dateObj.month}}月</span>
|
|
|
|
+ <span style="margin-left: 15px;">所属部门:{{user.orgName}}</span>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+
|
|
|
|
+ <!-- 功能按钮 -->
|
|
|
|
+ <el-row class="filter-container">
|
|
|
|
+ <el-col>
|
|
|
|
+ <el-button type="primary" icon="el-icon-plus" size="medium" @click="add">{{ $t("common.add") }}</el-button>
|
|
|
|
+ <el-button type="danger" icon="el-icon-delete" size="medium" @click="batchDelete">
|
|
|
|
+ {{ $t("common.delete") }}
|
|
|
|
+ </el-button>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+
|
|
|
|
+ <!-- 日历内容 -->
|
|
|
|
+ <el-calendar
|
|
|
|
+ class="calendarWks"
|
|
|
|
+ v-model="currDate"
|
|
|
|
+ @change="calChange"
|
|
|
|
+ >
|
|
|
|
+ <!-- 这里使用的是 2.5 slot 语法,对于新项目请使用 2.6 slot 语法-->
|
|
|
|
+ <template slot="dateCell" slot-scope="{date, data}">
|
|
|
|
+ <p :class="data.isSelected ? 'is-selected' : ''">
|
|
|
|
+ {{ data.day.split('-').slice(2).join('-') }}
|
|
|
|
+ <el-checkbox v-model="checks[data.day]" :disabled="data.type == 'current-month' ? false : true"></el-checkbox>
|
|
|
|
+ <!--<template v-for="item in userDateList">
|
|
|
|
+ <el-checkbox v-if="item.day == data.day" v-model="checks[data.day]" :disabled="data.type == 'current-month' ? false : true"></el-checkbox>
|
|
|
|
+ </template>-->
|
|
|
|
+ <!--{{dealMyDate(data.day)}}-->
|
|
|
|
+ </p>
|
|
|
|
+ <!--自定义内容-->
|
|
|
|
+ <div>
|
|
|
|
+ <div v-for="item in userDateList">
|
|
|
|
+ <div v-if="item.day == data.day">
|
|
|
|
+ <span v-for="obj in item.data" :key="obj.keys" :style="obj.color" class="clsName">{{obj.text}}</span>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </template>
|
|
|
|
+ </el-calendar>
|
|
|
|
+
|
|
|
|
+ <!-- 【新增】组件-->
|
|
|
|
+ <edit-calendar
|
|
|
|
+ ref="calendar"
|
|
|
|
+ :dialog-visible="dialog.isVisible"
|
|
|
|
+ :title="dialog.title"
|
|
|
|
+ @close="editClose"
|
|
|
|
+ @success="editSuccess"
|
|
|
|
+ />
|
|
|
|
+ </el-dialog>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<!-- JS部分 -->
|
|
|
|
+<script>
|
|
|
|
+ // 【新增】组件
|
|
|
|
+ import EditCalendar from "./EditCalendar"
|
|
|
|
+ // 加载共通的方法
|
|
|
|
+ import { initQueryParams, initDicts } from '@/utils/commons'
|
|
|
|
+ // 【设置班表】-API
|
|
|
|
+ import settingClassSchedulApi from "@/api/classScheduleMgr/settingClassSchedul"
|
|
|
|
+ export default{
|
|
|
|
+ name: 'CalendarUser',
|
|
|
|
+ components: { EditCalendar },
|
|
|
|
+ props: {
|
|
|
|
+ dialogVisible: {
|
|
|
|
+ type: Boolean,
|
|
|
|
+ default: false
|
|
|
|
+ },
|
|
|
|
+ title: {
|
|
|
|
+ type: String,
|
|
|
|
+ default: ''
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ data () {
|
|
|
|
+ return {
|
|
|
|
+ checks: {}, // 选中日期
|
|
|
|
+ currDate: '', // 默认日期
|
|
|
|
+ userDateList: {}, // 数据
|
|
|
|
+ dateObj: {}, // 年月对象
|
|
|
|
+ user: {}, // 人员对象
|
|
|
|
+ dialog: {
|
|
|
|
+ isVisible: false,
|
|
|
|
+ title: ""
|
|
|
|
+ },
|
|
|
|
+ dicts: {
|
|
|
|
+ NATION: {}
|
|
|
|
+ },
|
|
|
|
+ queryParams: initQueryParams({})
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ // 实例已经在内存中创建好,此时data和methods已将ok,如果要操作data中的数据或是调用methods中的方法,最早只能在created中操作
|
|
|
|
+ created() {
|
|
|
|
+ // 加载【字典】
|
|
|
|
+ initDicts(['NATION'], this.dicts);
|
|
|
|
+ },
|
|
|
|
+ computed: {
|
|
|
|
+ isUserVisible: {
|
|
|
|
+ get () {
|
|
|
|
+ return this.dialogVisible
|
|
|
|
+ },
|
|
|
|
+ set () {
|
|
|
|
+ this.close()
|
|
|
|
+ this.reset()
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ nationList() {
|
|
|
|
+ return convertEnum(this.dicts.NATION)
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ mounted () {
|
|
|
|
+ /*this.$nextTick(() => {
|
|
|
|
+ // 点击前一个月
|
|
|
|
+ let prevBtn = document.querySelector(
|
|
|
|
+ '.el-calendar__button-group .el-button-group>button:first-child');
|
|
|
|
+ prevBtn.addEventListener('click', (e) => {
|
|
|
|
+ console.log(e);
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ // 点击后一个月
|
|
|
|
+ let prevBtn = document.querySelector(
|
|
|
|
+ '.el-calendar__button-group .el-button-group>button:last-child');
|
|
|
|
+ prevBtn.addEventListener('click', (e) => {
|
|
|
|
+ console.log(this.value);
|
|
|
|
+ })
|
|
|
|
+ })*/
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ dealMyDate(v) {
|
|
|
|
+ console.log(v)
|
|
|
|
+ /*let len = this.userDateList.length
|
|
|
|
+ let res = "<div>"
|
|
|
|
+ for(let i=0; i<len; i++){
|
|
|
|
+ if(this.userDateList[i].day == v) {
|
|
|
|
+ let obj = this.userDateList[i]
|
|
|
|
+ let leng = obj.data.length
|
|
|
|
+ if(leng > 0){
|
|
|
|
+ for(let j=0; j<obj.data.length; j++){
|
|
|
|
+ res += "<span style=\""+ obj.data[j].color +"\" class=\"clsName\">"+ obj.data[j].text +"</span>"
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ res += "</div>"*/
|
|
|
|
+ return ''
|
|
|
|
+ },
|
|
|
|
+ // 日历值变化事件
|
|
|
|
+ calChange(e){
|
|
|
|
+ console.log("日历值变化事件:", e)
|
|
|
|
+ },
|
|
|
|
+ // 关闭组件-事件
|
|
|
|
+ close () {
|
|
|
|
+ this.$emit('close')
|
|
|
|
+ },
|
|
|
|
+ // 重置组件内容-事件
|
|
|
|
+ reset () {
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ editClose () {
|
|
|
|
+ this.dialog.isVisible = false
|
|
|
|
+ },
|
|
|
|
+ editSuccess () {
|
|
|
|
+ // 查询日历的数据
|
|
|
|
+ this.fetch()
|
|
|
|
+ },
|
|
|
|
+ // 来自父组件的设置-函数
|
|
|
|
+ setTenant (val, obj) {
|
|
|
|
+ this.user = val
|
|
|
|
+ this.dateObj = obj
|
|
|
|
+ this.currDate = this.dateObj.year +"-"+ this.dateObj.month
|
|
|
|
+ console.log("")
|
|
|
|
+ // 查询日历的数据
|
|
|
|
+ this.fetch()
|
|
|
|
+ },
|
|
|
|
+ // 【新增】按钮-事件
|
|
|
|
+ add(){
|
|
|
|
+ this.$refs.calendar.type = "add"
|
|
|
|
+ this.$refs.calendar.setTenant(this.user, this.dicts, this.dateObj)
|
|
|
|
+ this.dialog.title = this.$t("common.setting") + this.dateObj.year + this.$t("common.date.year") + this.dateObj.month + this.$t("common.date.month") + this.$t("calssSchedule.common.classSchul")
|
|
|
|
+ this.dialog.isVisible = true
|
|
|
|
+ console.log("this.dialog == ", this.dateObj)
|
|
|
|
+ },
|
|
|
|
+ // 【删除】按钮-事件
|
|
|
|
+ batchDelete(){
|
|
|
|
+ console.log("【删除】按钮-事件: ", this.checks)
|
|
|
|
+ this.$confirm(this.$t("calssSchedule.tips.settingTips"), this.$t("common.tips"), {
|
|
|
|
+ distinguishCancelAndClose: true,
|
|
|
|
+ confirmButtonText: this.$t("common.confirm"),
|
|
|
|
+ cancelButtonText: this.$t("common.cancel"),
|
|
|
|
+ type: "warning"
|
|
|
|
+ }).then(() => {
|
|
|
|
+ let obj = {
|
|
|
|
+ dateList: new Array(),
|
|
|
|
+ strUserList: [this.user.userId]
|
|
|
|
+ }
|
|
|
|
+ // 获取对象的Key值(既是:日期)
|
|
|
|
+ let keys = Object.keys(this.checks)
|
|
|
|
+ keys.map(item => {
|
|
|
|
+ if(this.checks[item]){
|
|
|
|
+ obj.dateList.push(item)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ this.clearSchedule(obj)
|
|
|
|
+ }).catch(() => {})
|
|
|
|
+ },
|
|
|
|
+ // 【清除、全部清除】-函数
|
|
|
|
+ clearSchedule(obj){
|
|
|
|
+ settingClassSchedulApi.clearSchedule(obj).then(response => {
|
|
|
|
+ const res = response.data
|
|
|
|
+ if (res.isSuccess) {
|
|
|
|
+ this.$message({
|
|
|
|
+ message: this.$t("tips.deleteSuccess"),
|
|
|
|
+ type: "success"
|
|
|
|
+ })
|
|
|
|
+ // 查询日历数据
|
|
|
|
+ this.fetch()
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ // 获取个人数据
|
|
|
|
+ fetch () {
|
|
|
|
+ this.loading = true
|
|
|
|
+ // 分页数据
|
|
|
|
+ this.queryParams.current = 1
|
|
|
|
+ this.queryParams.size = 100
|
|
|
|
+ // 条件,日期和用的userId
|
|
|
|
+ this.queryParams.model = {
|
|
|
|
+ userId: this.user.userId,
|
|
|
|
+ year: this.dateObj.year,
|
|
|
|
+ month: this.dateObj.month
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ settingClassSchedulApi.pageList(this.queryParams).then(response => {
|
|
|
|
+ const res = response.data
|
|
|
|
+ if (res.isSuccess) {
|
|
|
|
+ this.formatData(res.data)
|
|
|
|
+ }
|
|
|
|
+ // eslint-disable-next-line no-return-assign
|
|
|
|
+ }).finally(() => this.loading = false)
|
|
|
|
+ },
|
|
|
|
+ // 格式化,自己需要的渲染数据
|
|
|
|
+ formatData(data){
|
|
|
|
+ //this.tableData = res.data
|
|
|
|
+ if(data.data && data.data.length > 0){
|
|
|
|
+ // 数据内容
|
|
|
|
+ let list = []
|
|
|
|
+ let dateList = []
|
|
|
|
+ data.data.map((item, index) => {
|
|
|
|
+ let keys = Object.keys(item) // 对象的所有Key的数组
|
|
|
|
+ keys.map(val => {
|
|
|
|
+ // 如果字段是日期,格式化后,yyyy-MM-dd
|
|
|
|
+ if(val.indexOf("-") > -1){
|
|
|
|
+ // 如果值,存在--- "早班;#E20867,午班;#E30628"
|
|
|
|
+ if(!!item[val]){
|
|
|
|
+ // 组成新的数据
|
|
|
|
+ let dateObj = {
|
|
|
|
+ keys: 'WKS'+ Math.random(),
|
|
|
|
+ day: val,
|
|
|
|
+ data: []
|
|
|
|
+ }
|
|
|
|
+ let children = new Array()
|
|
|
|
+ let arr = item[val].split(",") // ["早班;#E20867","午班;#E30628"]
|
|
|
|
+ arr.map((res, keys) => {
|
|
|
|
+ let result = res.split(";") // ["早班","#E20867"]/["午班","#E30628"]/
|
|
|
|
+ children.push({
|
|
|
|
+ day: val,
|
|
|
|
+ keys: 'W'+ keys,
|
|
|
|
+ text: result[0],
|
|
|
|
+ color: 'background:'+ result[1]
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ //
|
|
|
|
+ dateObj.data = children
|
|
|
|
+ // 赋值
|
|
|
|
+ item[val] = children
|
|
|
|
+ //
|
|
|
|
+ dateList.push(dateObj)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ // 给数据赋值
|
|
|
|
+ list.push(item)
|
|
|
|
+ })
|
|
|
|
+ data.data = list
|
|
|
|
+
|
|
|
|
+ this.userDateList = dateList
|
|
|
|
+ console.log("数据后111111:", dateList)
|
|
|
|
+ }
|
|
|
|
+ /*let arry = data.data
|
|
|
|
+ console.log("数据后的内容:", arry[0])
|
|
|
|
+ if(arry && arry.length > 0){
|
|
|
|
+ this.userDateList = arry[0]
|
|
|
|
+ }*/
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+</script>
|
|
|
|
+
|
|
|
|
+<!-- 全局样式 -->
|
|
|
|
+<style type="text/css">
|
|
|
|
+ .calendarWks .el-calendar__button-group{
|
|
|
|
+ display: none;
|
|
|
|
+ }
|
|
|
|
+</style>
|
|
|
|
+
|
|
|
|
+<!-- 局部样式css -->
|
|
|
|
+<style lang="scss" scoped>
|
|
|
|
+ .clsName{
|
|
|
|
+ color: white;
|
|
|
|
+ padding: 2px 6px;
|
|
|
|
+ margin: 5px;
|
|
|
|
+ -moz-border-radius: 3px;
|
|
|
|
+ -webkit-border-radius: 3px;
|
|
|
|
+ border-radius: 3px;
|
|
|
|
+ }
|
|
|
|
+</style>
|