src/views/employeeSalary/apprenticeshipManage/index.vue
@@ -4,8 +4,7 @@
      <CommonSearch ref="searchRef" :show-add="false" :amount-view="false" placeholder="请输入关键词" @searchClick="onFilterSearch">
        <template slot="leftButton">
          <el-button size="small" type="primary" @click="addBtnClick" >新增</el-button>
          <el-button size="small" type="primary" @click="refreshClick">刷新</el-button>
          <el-button size="small" type="primary" @click="printClick">打印</el-button>
          <el-button size="small" type="primary" @click="exportClick">导入</el-button>
        </template>
      </CommonSearch>
    </div>
@@ -14,15 +13,14 @@
        <TableCommonView
          :table-list="tableList"
          @selTableCol="selTableCol"
          @handleShow="handleShow"
          @tableRowClick="tableRowClick"
          v-loading="loading"
        >
          <template slot="tableButton">
            <el-table-column label="操作" width="180">
              <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="delClick(scope.row)" type="text" size="small">删除</el-button>
                
              </template>
            </el-table-column>
@@ -30,7 +28,8 @@
        </TableCommonView>
      </div>
      <AddDialog 
        :editDiaConfig="editConfig"
       ref="add"
        :editRow="editRow"  @refresh="refreshClick"
      />
      <div class="btn-pager">
        <PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
@@ -40,6 +39,7 @@
</template>
<script>
import { getMentorList, deleteMentorInfo } from "@/api/employeeSalary/apprenticeshipManage.js"
import AddDialog from "@/views/employeeSalary/apprenticeshipManage/components/addDialog.vue"
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
export default {
@@ -51,23 +51,17 @@
  data() {
    return {
      tableList: {},
      showCol: ["车间", "组别", "开始车号", "结束车号", "半车标志", "备注"],
      showCol: ["月份", "员工编码", "员工姓名", "带徒天数", "添加时间", "添加人"],
      tableColumn: [
        // { label: "车间", prop: "workshopNumber",iconRight:"el-icon-setting"},
        { label: "车间", prop: "workshopNumber",},
        { label: "组别", prop: "groupNumber", },
        { label: "开始车号", prop: "startCarNumber" },
        { label: "结束车号", prop: "endCarNumber" },
        { label: "半车标志", prop: "carFlag",isCallMethod: true, getCallMethod: this.getStatusCarFlag },
        { label: "备注", prop: "notes", },
        { label: "月份", prop: "month",min:90,},
        { label: "员工编码", prop: "workerId", min:120,},
        { label: "员工姓名", prop: "name" },
        { label: "带徒天数", prop: "days" , min:110,},
        { label: "添加时间", prop: "carFlag", min:120, },
        { label: "添加人", prop: "creator", },
      ],
      editConfig:{
        visible:false,
        infomitton:{
          TabsIndex:0,
          workshopId:null,
        }
      },
      editRow:{},
      loading: false,
      getDataParams: {
        keyWord: '',
      },
@@ -75,6 +69,7 @@
  },
  created() {
    this.setTable()
    this.getData(this.getDataParams.keyWord)
  },
  methods: {
    setTable() {
@@ -109,35 +104,88 @@
      this.showcol = val
      this.tableList.tableColumn = this.setColumnVisible(val, this.tableColumn)
    },
    // 请求数据
    async getData() {
      this.loading = true
      await getMentorList({
        keyWord:this.getDataParams.keyWord,
        page: this.pagerOptions.currPage,
        pageSize: this.pagerOptions.pageSize
      })
        .then((res) => {
          if (res.code === 200) {
            if (res.data) {
              const list = res.data.map(item=>{
                return {
                  ...item,
                  name:item.worker?item.worker.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.pagerOptions.currPage = 1
      this.getData()
    },
    // 刷新
    refreshClick() {
      this.getDataParams.keyWord = ""
      this.pagerOptions.currPage = 1
      this.pagerOptions.pageSize = 15
      // this.$refs.searchRef.searchInput = ""
      this.getData()
    },
    // 打印
    printClick() { },
    // 组别
    handleShow() {
    },
    exportClick() { },
    // 表格行点击
    tableRowClick(row) {
      console.log(row, "row")
    },
     // 编辑
     handleClick(row) {
      let config=JSON.parse(JSON.stringify(row));
      this.editRow = {
        ...config,
        title:'编辑',
        type:'edit',
        id:config.ID
      }
      this.$refs.add.islook = true;
    },
    // 删除
    delClick(row) {
      this.$confirm("是否确认删除?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          deleteMentorInfo({ id: row.ID }).then((response) => {
            if (response.code === 200) {
              this.$message.success("删除成功")
              this.getData()
            }
          })
        })
        .catch(() => {})
    },
  }
}
</script>