zuozhengqing
2024-04-07 12b5feba10e8f30553999d77205eb25ec0598f90
src/views/employeeSalary/attendanceStatistics/index.vue
@@ -1,21 +1,269 @@
<template>
  <div class="container"></div>
  <div class="silkRegister-form">
    <div class="filter">
      <div class="filter-card">
        <CommonSearch
          :show-add="false"
          :show-download="false"
          :amount-view="false"
          :show-action-btn="false"
          placeholder="请输入关键词"
          @searchClick="onFilterSearch"
        >
          <template slot="leftButton">
            <div class="margin_right_20px" style="width:200px;">
              <el-date-picker v-model="object.date" style="width:100%" type="month" placeholder="选择日期"
                value-format="yyyy-MM">
              </el-date-picker>
            </div>
            <el-button size="small" type="primary" @click="ruleSettingClick">规则设置</el-button>
          </template>
        </CommonSearch>
      </div>
    </div>
    <div class="body">
      <div class="body-card">
        <div class="list-view">
          <TableCommonView
            ref="tableListRef"
            v-loading="loading"
            :table-list="tableList"
            @selTableCol="selTableCol"
          >
            <template slot="tableButton">
              <el-table-column label="操作" width="90" fixed="right">
                <template slot-scope="scope">
                  <el-button @click="delClick(scope.row.id)" type="text" size="small">删除</el-button>
                </template>
              </el-table-column>
            </template>
          </TableCommonView>
        </div>
        <div class="btn-pager">
          <PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
        </div>
      </div>
    </div>
    <AttendanceStatisticsDetails ref="attendanceStatisticsDetails" :editRow="editRow"  @shutdown="getData" />
     <!-- 规则设置 -->
     <RuleSettingDialog ref="RuleSettingDialog" :editRow="editRow"  @closeClick="getData" />
  </div>
</template>
<script>
import { getFollowRecordList, getDeleteFollowRecord } from "@/api/employeeSalary/attendanceStatistics.js"
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
import AttendanceStatisticsDetails from  "@/views/employeeSalary/attendanceStatistics/components/AttendanceStatisticsDetails"
import RuleSettingDialog from  "@/views/employeeSalary/attendanceStatistics/components/RuleSettingDialog"
import Date from "@/api/date";
const { getCurrentMonth } = Date;
export default {
  name: "attendanceStatistics",
  props: {},
  components: {},
  mixins: [],
  computed: {},
  data() {
    return {}
  props: {
  },
  created() {},
  methods: {}
  mixins: [pageMixin],
  components: {
    AttendanceStatisticsDetails,
    RuleSettingDialog
  },
  data() {
    return {
      tableList: {},
      loading: false,
      object:{
        date:getCurrentMonth()
      },
      editRow:{
      },
      searchOptions: [],
      editConfig: {
        visible: false,
        title: "新建",
        infomation: {}
      },
      search_map: {},
      tableColumn: [
        { label: "姓名", prop: "topic", min: 120, default: true },
        { label: "人员ID", prop: "client_name", min: 190,default: true},
        { label: "工种", prop: "contact_name", min: 100, },
        { label: "月份", prop: "client_status", min: 100 },
        { label: "1/周一", prop: "client_status", min: 100 },
        { label: "工作日加班时长(小时)", prop: "contact_information_name", min: 180 },
        { label: "休息日加班时长(小时)", prop: "follow_time", min: 180 },
        { label: "应出勤天数", prop: "next_follow_time", min: 110 },
        { label: "实际出勤天数", prop: "member_name", min: 110 },
      ],
      showCol: [
        "姓名",
        "人员ID",
        "工种",
        "月份",
        "工作日加班时长(小时)",
        "休息日加班时长(小时)",
        "应出勤天数",
        "实际出勤天数",
      ]
    }
  },
  created() {
    this.setTable()
    this.getData(this.search_map)
  },
  computed: {
  },
  methods: {
    setTable() {
      this.tableList = {
        selectIndex: true,
        tableInfomation: [],
        allcol: [],
        showcol: this.showCol,
        tableColumn: this.setColumnVisible(this.showCol)
      }
      this.tableList.allcol = this.tableList.tableColumn.filter((ele) => !ele.default).map((ele) => ele.label)
      this.searchOptions = []
      for (let i = 0; i < this.tableList.tableColumn.length; i++) {
        const label = this.tableList.tableColumn[i].label
        const value = this.tableList.tableColumn[i].prop
        this.searchOptions.push({ value: value, label: label })
      }
    },
    setColumnVisible(showCol) {
      return this.tableColumn.map((ele) => {
        return {
          ...ele,
          isShowColumn: showCol.includes(ele.label)
        }
      })
    },
    selTableCol(val) {
      this.showcol = val
      this.tableList.tableColumn = this.setColumnVisible(val)
    },
    // 请求数据
    async getData() {
      this.loading = true
      await getFollowRecordList({
        search_map: this.search_map,
        page: this.pagerOptions.currPage,
        pageSize: this.pagerOptions.pageSize
      })
        .then((res) => {
          console.log(res)
          if (res.code === 200) {
            if (res.data.list && res.data.list.length > 0) {
              const list = res.data.list.map((item) => {
                return {
                  ...item,
                  client_name: item.client.name,
                  contact_name: item.contact.name,
                  client_status: item.client_status.name,
                  phone: item.contact.phone,
                  member_name: item.member.username,
                  contact_information_name: item.contact_information.name
                }
              })
              this.tableList.tableInfomation = list || []
              this.pagerOptions.totalCount = res.data.count
            } else {
              this.tableList.tableInfomation = []
            }
          } else {
            this.tableList.tableInfomation = []
          }
          this.loading = false
        })
        .catch((err) => {
          console.log(err)
          this.tableList.tableInfomation = []
          this.loading = false
        })
    },
    // 搜索
    onFilterSearch(searchText) {
      this.search_map.client_name = searchText ?? ""
      this.pagerOptions.currPage = 1
      this.getData()
    },
    // 详情
    detailsClick(row) {
      let config=JSON.parse(JSON.stringify(row));
      this.editRow = { ...config, title:'编辑',type:'add' }
      this.$refs.addWorkKind.islook = true;
    },
     // 打印
     ruleSettingClick(){
      this.$refs.RuleSettingDialog.islook = true;
    },
    // 删除
    delClick(id) {
      this.$confirm("是否确认删除?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          getDeleteFollowRecord({ ids: [id] }).then((response) => {
            if (response.code === 200) {
              this.$message.success("删除成功")
              this.getData()
            } else {
              this.$message.warning("删除失败")
            }
          })
        })
        .catch(() => {})
    },
  }
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped></style>
<style lang="scss" scoped>
.silkRegister-form {
  height: 100%;
  overflow: hidden;
  .filter {
    height: 80px;
    display: flex;
    align-items: center;
    padding: 12px 20px 0 20px;
    &-card {
      height: 80px;
      display: flex;
      align-items: center;
      box-sizing: border-box;
      padding: 10px 20px;
      flex: 1;
      border-radius: 12px;
      background-color: #fff;
    }
  }
  .body {
    box-sizing: border-box;
    padding: 10px 20px;
    border-radius: 12px;
    height: calc(100% - 92px);
    .body-card {
      background-color: #fff;
      border-radius: 12px;
      height: 100%;
      overflow: hidden;
    }
    .list-view {
      height: calc(100% - 60px);
      overflow: hidden;
    }
    .btn-pager {
      display: flex;
      margin-top: 10px;
      .page {
        margin-left: auto;
      }
    }
  }
}
</style>