zhouwx
2024-07-17 246f7b6fd81cf2ba620b8f9bf7cf24b61d7cf521
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<template>
  <div class="app-container">
    <div style="margin-bottom: 10px">
      <el-button
          type="primary"
          plain
          icon="Plus"
          @click="openDialog('add',{})"
      >新增</el-button>
    </div>
    <!-- 表格数据 -->
    <el-table v-loading="loading" :data="dataList" :border="true">
      <el-table-column label="序号" type="index" align="center" width="80" />
      <el-table-column label="企业信用代码" prop="creditCode" align="center"  />
      <el-table-column label="企业名称" prop="name" align="center" />
      <el-table-column label="负责人" prop="major" align="center"  />
      <el-table-column label="联系电话" prop="phone" align="center"/>
      <el-table-column label="当前剩余课时(分)" prop="remainPeriodMin" align="center" width="150" />
      <el-table-column label="累计已用课时(分)" prop="spendPeriodMin" align="center" width="150">
        <template #default="scope">
          <span>{{((scope.row.totalPeriod -scope.row.remainPeriod)/60).toFixed(2).replace(/\.00$/, '') + '分钟' }}</span>
        </template>
      </el-table-column>
      <el-table-column label="总课时(分)" prop="totalPeriodMin" align="center"/>
      <el-table-column label="课时变动详情" align="center" class-name="small-padding fixed-width" >
        <template #default="scope">
          <el-button link type="primary" @click="openDetail(scope.row)">查看详情</el-button>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="200" >
        <template #default="scope">
          <el-button link type="primary" @click="openDialog('distribute',scope.row)">分配课时</el-button>
          <el-button link type="primary" @click="openDialog('edit',scope.row)">编辑</el-button>
          <el-button link type="danger" @click="handleDelete(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
 
    <pagination
        v-show="total > 0"
        :total="total"
        v-model:page="queryParams.pageNum"
        v-model:limit="queryParams.pageSize"
        @pagination="getList"
    />
 
    <company-dialog ref="dialogRef" @getList=getList></company-dialog>
    <class-hour-change ref="classHourRef" @getList=getList></class-hour-change>
  </div>
</template>
 
<script setup>
import {getCurrentInstance, onMounted, onUnmounted, reactive, ref, toRefs} from "vue";
import {ElMessage, ElMessageBox} from "element-plus";
import {delCompany, getCompany} from "@/api/onlineEducation/company";
import companyDialog from "./components/companyDialog.vue";
import classHourChange from '@/views/onlineEducation/classHourBatch/components/classHourChange.vue'
 
const { proxy } = getCurrentInstance();
const loading = ref(false);
const dialogRef = ref();
const data = reactive({
  queryParams: {
    pageNum: 1,
    pageSize: 10,
  },
  total: 0,
  dataList: []
});
 
const { queryParams, total, dataList } = toRefs(data);
const classHourRef = ref();
onMounted(()=>{
  getList()
})
 
onUnmounted(()=>{
 
})
 
const getList = async () => {
  loading.value = true
  const res = await getCompany(data.queryParams)
  if(res.code == 200){
    data.dataList = res.data.list.map(item => {
      return{
        ...item,
        remainPeriodMin: item.remainPeriod ?(item.remainPeriod /60).toFixed(2).replace(/\.00$/, '') + '分钟':'',
        totalPeriodMin:item.totalPeriod ?(item.totalPeriod /60).toFixed(2).replace(/\.00$/, '') + '分钟':'',
      }
    })
    data.total = res.data.total
  }else{
    ElMessage.warning(res.message)
  }
  loading.value = false
}
 
const openDialog = (type, value) => {
  dialogRef.value.openDialog(type, value);
}
 
/** 重置新增的表单以及其他数据  */
function reset() {
  proxy.resetForm("roleRef");
}
const handleDelete = (val) => {
  ElMessageBox.confirm(
      '确定删除此条数据?',
      '提示',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
      .then( async() => {
        const res = await delCompany(val.id)
        if(res.code == 200){
          ElMessage.success('数据删除成功')
          await getList()
        }else{
          ElMessage.warning(res.message)
        }
      })
}
 
const openDetail = (val) => {
  classHourRef.value.openDialog(val.id)
}
</script>