haoxuan
2024-04-26 4e77a057819df8bcd8eb4218e6d1fcd8ccc8abf6
应发工资报表的前端开发
2个文件已修改
327 ■■■■ 已修改文件
src/components/makepager/TableCommonView.vue 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/reportManage/payableSalaryReport/index.vue 264 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/makepager/TableCommonView.vue
@@ -155,6 +155,39 @@
              item.getCallMethod(scope.row[item.prop], scope.row)
            }}</span>
          </div>
          <div v-else-if="item.isEditTd">
              <template
                  v-if="scope.row[item.prop+'editType']=='inputFloat'"
                >
                <el-input-number
                  v-model="scope.row[item.prop]"
                  placeholder="请输入"
                  :min="0"
                  :precision="2"
                  :controls="false"
                  size="mini"
                  style="width: calc(100% - 80px); margin-right: 5px"
                  @change="
                    (val) => {
                      commonInputChange(val, item.prop, scope.row, scope)
                    }
                  "
                ></el-input-number>
                <el-button
                  type="text"
                  @click="saveEditShow(item.prop, scope.row, scope)"
                  >保存</el-button
                >
              </template>
              <span v-else>
                  {{ scope.row[item.prop] }}
                <i
                  class="el-icon-edit"
                  style="font-size: 16px; margin-left: 5px; cursor: pointer"
                  @click="handleEditShow(scope.row,scope,item)"
                ></i>
              </span>
          </div>
          <span v-else>{{ scope.row[item.prop] ? scope.row[item.prop] : "--" }}</span>
        </template>
      </el-table-column>
@@ -241,6 +274,36 @@
    },
  },
  methods: {
    // 表格编辑
    handleEditShow(row,scope,item){
      scope.row[item.prop+'editType']=='inputFloat'
      this.$set(this.tableList.tableInfomation[scope.$index],item.prop+'editType','inputFloat')
      this.$forceUpdate()
    },
    commonInputChange(val, prop, row, scope) {
      // if (row.editType=='inputFloat') {
      //   let value = scope.row[prop]
      //   let reg2 = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/
      //   if (!reg2.test(value) || value == 0) {
      //     this.$message.error("需要填写大于0的2位小数!")
      //     return true
      //   }
      //   this.$forceUpdate()
      // }
      this.$emit("inputContent", val, prop, row, scope)
    },
    saveEditShow( prop, row, scope){
      if (row.editType=='inputFloat') {
        let value = scope.row[prop]
        let reg2 = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/
        if (!reg2.test(value) || value == 0) {
          this.$message.error("需要填写大于0的2位小数!")
          return true
        }
        this.$forceUpdate()
      }
      this.$emit("inputContent", prop, row, scope)
    },
    onMaskClick() {
      this.iscolopen = false
    },
src/views/reportManage/payableSalaryReport/index.vue
@@ -1,100 +1,101 @@
<template>
  <div class="payableSalaryReport-container">
    <div class="filter-card">
      <CommonSearch :show-add="false" :amount-view="false" placeholder="请输入关键词" @searchClick="onFilterSearch">
        <template slot="leftButton">
          <el-button size="small" type="primary" @click="exportBtnClick">导出</el-button>
          <el-button size="small" type="primary" @click="refreshBtnClick">刷新</el-button>
        </template>
      </CommonSearch>
    </div>
    <div class="body-card">
      <div class="list-view">
        <TableCommonView
          ref="tableListRef"
          v-loading="loading"
          :colOpenShow="false"
          :table-list="tableList"
          @selTableCol="selTableCol"
  <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"
        >
        </TableCommonView>
          <template slot="leftButton">
            <div class="margin_right_20px" style="width:200px;">
              <el-date-picker v-model="object.date" style="width:100%"
              @change="onFilterSearch"
              :clearable="false" type="month" placeholder="选择日期"
              :picker-options="pickerOptions"
                value-format="yyyy-MM">
              </el-date-picker>
            </div>
          </template>
        </CommonSearch>
      </div>
      <!-- <div class="btn-pager">
        <PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
      </div> -->
    </div>
    <div class="body">
      <div class="body-card">
        <div class="list-view">
          <TableCommonView
            ref="tableListRef"
            v-loading="loading"
            :table-list="tableList"
            @selTableCol="selTableCol"
            @inputContent="inputContent"
          >
          </TableCommonView>
        </div>
        <!-- <div class="btn-pager">
          <PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
        </div> -->
      </div>
    </div>
  </div>
</template>
<script>
import { getAttendanceStatistic } from  "@/api/employeeSalary/attendanceManage.js"
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
import NewDate from "@/api/date";
const { getCurrentMonth } = NewDate;
export default {
  name: "payableSalaryReport",
  props: {},
  components: {},
  name: "attendanceStatistics",
  props: {
  },
  mixins: [pageMixin],
  computed: {},
  components: {
  },
  data() {
    return {
      loading: false,
      tableList: {},
      loading: false,
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() > new Date().getTime() - 86400000;
        },
      },
      object:{
        date:getCurrentMonth()
      },
      searchOptions: [],
      keyword: "",
      tableColumn: [
        { label: "姓名", prop: "name", default: true, fixed: true },
        { label: "人员id", prop: "member_name" },
        { label: "姓名", prop: "workerName", min: 120, default: true },
        { label: "人员id", prop: "workerId", min: 190,default: true},
        { label: "手机号", prop: "client_level" },
        { label: "工种", prop: "next_visit_time" },
        { label: "生产工资", prop: "detail_address" },
        { label: "满勤", prop: "client_status" },
        { label: "超时工资", prop: "contact_name" },
        { label: "加班工资", prop: "contact_phone" },
        { label: "交通补贴", prop: "client_level" },
        { label: "带徒补贴", prop: "next_visit_time" },
        { label: "岗位补贴", prop: "detail_address" },
        { label: "社保补贴", prop: "client_status" },
        { label: "工龄补贴", prop: "contact_name" },
        { label: "不达保底", prop: "contact_phone" },
        { label: "质量奖", prop: "contact_phone" },
        { label: "奖罚1", prop: "client_level" },
        { label: "奖罚2/清凉补", prop: "next_visit_time", width: "110" },
        { label: "日常检查/奖罚3", prop: "detail_address", width: "110" },
        { label: "停机补贴", prop: "client_status" },
        { label: "应发工资", prop: "contact_name" },
        { label: "备注", prop: "contact_phone", width: "140" }
        { label: "工种", prop: "workType", min: 100, },
        { label: "备注", prop: "actualAttendanceDays", min: 110 },
      ],
      showCol: [
        "姓名",
        "人员id",
        "手机号",
        "工种",
        "生产工资",
        "满勤",
        "超时工资",
        "加班工资",
        "交通补贴",
        "带徒补贴",
        "岗位补贴",
        "社保补贴",
        "工龄补贴",
        "不达保底",
        "质量奖",
        "奖罚1",
        "奖罚2/清凉补",
        "日常检查/奖罚3",
        "停机补贴",
        "应发工资",
        "备注"
        "备注",
      ]
    }
  },
  created() {
    this.setTable()
    this.getData(this.keyword)
  },
  computed: {
  },
  methods: {
    setTable() {
      this.tableList = {
        selectIndex: true,
        isFixed: true,
        tableInfomation: [{ name: "张三" }, { name: "lisi" }, { name: "王五" }],
        isFixed:true,
        tableInfomation: [],
        allcol: [],
        showcol: this.showCol,
        tableColumn: this.setColumnVisible(this.showCol)
@@ -111,44 +112,135 @@
      return this.tableColumn.map((ele) => {
        return {
          ...ele,
          isShowColumn: showCol.includes(ele.label)
          isShowColumn:ele.default?true:showCol.includes(ele.label)
        }
      })
    },
    selTableCol(val) {
      this.showcol = val
      this.tableList.tableColumn = this.setColumnVisible(val)
      this.showcol = val;
      this.tableList.tableColumn = this.setColumnVisible(val);
    },
    // 请求数据
    async getData() {
      this.loading = true
      await getAttendanceStatistic({
        keyword: this.keyword,
        month:this.object.date,
        // page: this.pagerOptions.currPage,
        // pageSize: this.pagerOptions.pageSize
      })
        .then((res) => {
          if (res.code == 200) {
            if (res.data.list && res.data.list.length > 0) {
              let tableColumn1= [
                { label: "姓名", prop: "workerName", min: 120,default: true,fixed:'left' },
                { label: "人员ID", prop: "workerId", min: 120,default: true,fixed:'left'},
                { label: "手机号", prop: "client_level" },
                { label: "工种", prop: "workType", min: 100,fixed:'left' },
              ];
              let tableColumn3=[
               { label: "备注", prop: "actualAttendanceDays", min: 110 },
              ]
              let tableColumn2=[]
              let headerList=res.data.list.length>0?res.data.list[0]:[]
                if(headerList.details&&headerList.details.length>0){
                  for(let i in headerList.details){
                    tableColumn2.push({
                      label:headerList.details[i].date+'',
                      prop:'headerDate'+headerList.details[i].date,
                      min:150,
                      default:true,
                      isEditTd:true,
                    })
                  }
                }
              let tableColumn=tableColumn1.concat(tableColumn2).concat(tableColumn3)
              this.tableColumn=tableColumn;
              this.setTable()
              const list = res.data.list.map((item) => {
                let headerItem={}
                let details=item.details?item.details:[]
                for(let i in details){
                  headerItem['headerDate'+details[i].date]=details[i].status
                }
                return {
                  ...item,
                  ...headerItem,
                }
              })
              this.tableList.tableInfomation = list || []
              this.pagerOptions.totalCount = res.total
            } else {
              this.tableList.tableInfomation = []
            }
          } else {
            this.tableList.tableInfomation = []
          }
          this.loading = false
        })
        .catch((err) => {
          console.log(err)
          this.tableList.tableInfomation = []
          this.loading = false
        })
    },
    // 搜索
    onFilterSearch(searchText) {
      console.log(searchText)
      this.keyword = searchText ?? ""
      this.pagerOptions.currPage = 1
      this.getData()
    },
    // 导出
    exportBtnClick() {},
    // 刷新
    refreshBtnClick() {}
    inputContent( prop, row, scope){
      console.log(prop,'---',row,'---',scope)
    },
  }
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
.payableSalaryReport-container {
.silkRegister-form {
  height: 100%;
  .filter-card {
    margin: 20px 30px;
  overflow: hidden;
  .filter {
    height: 80px;
    display: flex;
    align-items: center;
    padding: 0 20px 0 20px;
    border-radius: 12px;
    background-color: #fff;
    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-card {
    margin: 0 30px;
    background-color: #fff;
    padding: 10px 15px;
    height: calc(100% - 180px);
  .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% - 10px);
      overflow: hidden;
    }
    .btn-pager {
      display: flex;
      margin-top: 10px;
      .page {
        margin-left: auto;
      }
    }
  }
}
</style>