charles
2024-07-15 c77637aa6781f3275839674cb4fa2d4b72b8827c
src/views/employeeSalary/salaryPlan/index.vue
@@ -12,27 +12,24 @@
        <TableCommonView
          :table-list="tableList"
          @selTableCol="selTableCol"
          @handleShow="handleShow"
          @tableRowClick="tableRowClick"
        >
          <template slot="tableButton">
            <el-table-column label="操作" width="180">
            <el-table-column label="操作" width="110">
              <template slot-scope="scope">
                <el-button @click.stop="handleClick(scope.row, '查看')" type="text" size="small">查看</el-button>
                <el-button @click.stop="handleClick(scope.row, '修改')" type="text" size="small">修改</el-button>
                <el-button @click.stop="handleClick(scope.row, '删除')" type="text" size="small">删除</el-button>
                <el-button @click.stop="handleClick(scope.row)" type="text" size="small">修改</el-button>
                <el-button @click.stop="delClick(scope.row)" type="text" size="small">删除</el-button>
                
              </template>
            </el-table-column>
          </template>
        </TableCommonView>
      </div>
      <AddDialog
        :editDiaConfig="editConfig"
      />
      <div class="btn-pager">
        <PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
      </div>
      <AddDialog
      ref="add" :editRow="editRow"  @refresh="refresh"
      />
    </div>
  </div>
</template>
@@ -40,6 +37,7 @@
<script>
import AddDialog from "@/views/employeeSalary/salaryPlan/components/addDialog.vue"
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
import { getSalaryPlanList, deleteSalaryPlanInfo } from  "@/api/employeeSalary/salaryPlan.js"
export default {
  name: "salaryPlan",
  props: {},
@@ -51,29 +49,21 @@
      tableList: {},
      showCol: ["方案名称", "工种", "薪资类型", "计费周期", "计费公式定义", "添加时间", "添加人"],
      tableColumn: [
        // { label: "车间", prop: "workshopNumber",iconRight:"el-icon-setting"},
        { label: "方案名称", prop: "workshopNumber",},
        { label: "工种", prop: "groupNumber", },
        { label: "薪资类型", prop: "startCarNumber" },
        { label: "计费周期", prop: "endCarNumber" },
        { label: "计费公式定义", prop: "carFlag", },
        { label: "添加时间", prop: "notes", },
        { label: "添加人", prop: "notes", },
        { label: "方案名称", prop: "name",min:110},
        { label: "工种", prop: "workTypeNames",min:100 },
        { label: "薪资类型", prop: "salaryTypeName",min:110 },
        { label: "计费周期", prop: "cycle",min:110 },
        { label: "计费公式定义", prop: "salaryFormulaValue",min:140  },
        { label: "添加时间", prop: "createTime",min:130 },
        { label: "添加人", prop: "addPeople",min:110 },
      ],
      editConfig:{
        visible:false,
        infomitton:{
          TabsIndex:0,
          workshopId:null,
        }
      },
      getDataParams: {
        keyWord: '',
      },
      keyword: '',
      editRow:{},
    }
  },
  created() {
    this.setTable()
    this.getData(this.keyword)
  },
  methods: {
    setTable() {
@@ -108,25 +98,103 @@
      this.showcol = val
      this.tableList.tableColumn = this.setColumnVisible(val, this.tableColumn)
    },
    // 请求数据
    async getData() {
      this.loading = true
      await getSalaryPlanList({
        keyword: this.keyword,
        page: this.pagerOptions.currPage,
        pageSize: this.pagerOptions.pageSize
      })
        .then((res) => {
          if (res.code === 200) {
            if (res.data) {
              const list = res.data.map(item=>{
                let workTypeNames=''
                if(item.workTypes){
                  for(let i in item.workTypes){
                    workTypeNames=item.workTypes[i].workName+','+workTypeNames
                  }
                }
                let salaryFormulaValue=''
                salaryFormulaValue=item.salaryFormula?item.salaryFormula.split(",").join(''):[]
                return {
                  ...item,
                  workTypeNames:workTypeNames,
                  salaryFormulaValue:salaryFormulaValue,
                  salaryTypeName:item.salaryType?item.salaryType.name:''
                }
              })
              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
        })
    },
    // 新增
    addBtnClick() {
      this.editConfig.infomitton={}
      this.editConfig.dialogTitle="新增"
      this.editConfig.visible=true
      this.editRow = { title:'新建',type: 'add' }
      this.$refs.add.islook = true;
    },
    // 搜索
    onFilterSearch(searchText) {
      this.getDataParams.keyWord = searchText,
        this.getData()
      this.keyword= searchText,
      this.pagerOptions.currPage = 1
      this.getData()
    },
    // 组别
    handleShow() {
    refresh(){
      this.getData()
    },
    // 编辑
    handleClick(row) {
      let config=JSON.parse(JSON.stringify(row));
      let arr=config.workTypes?config.workTypes:[]
      let workTypes=[]
      if(arr&&arr.length>0){
        for(let i in arr){
          workTypes.push({
            value:arr[i].ID,
            label: arr[i].workName
          })
        }
      }
      this.editRow = {
        ...config,
        title:'编辑',
        type:'edit',
        id:config.ID,
        workTypes:workTypes
      }
      this.$refs.add.islook = true;
    },
    // 删除
    delClick(row) {
      this.$confirm("是否确认删除?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          deleteSalaryPlanInfo({ id: row.ID }).then((response) => {
            if (response.code === 200) {
              this.$message.success("删除成功")
              this.getData()
            }
          })
        })
        .catch(() => {})
    },
    },
    // 表格行点击
    tableRowClick(row) {
      console.log(row, "row")
    },
  }
}
</script>