zhouwx
2025-06-10 21b86f6d81e2153d100587cadc16aaaf470cab33
src/views/build/conpanyFunctionConsult/companyInfo/overview/index.vue
@@ -1,11 +1,196 @@
<script setup>
</script>
<template>
  <div>公司概况</div>
  <div class="app-container">
    <div style="margin-bottom: 10px">
      <el-form style="display: flex;flex-wrap: wrap">
        <el-form-item>
          <el-button
              type="primary"
              plain
              icon="Plus"
              @click="openDialog('add',{})"
          >新增</el-button>
        </el-form-item>
        <el-form-item label="企业名称:" v-if="data.isAdmin" style="margin-left: 20px">
          <el-select
              v-model="data.queryParams.companyName"
              filterable
              remote
              @change="selectValue"
              reserve-keyword
              placeholder="请输入企业名称"
              remote-show-suffix
              :remote-method="getCompanyList"
              :loading="loadingCompany"
              style="width: 240px"
          >
            <el-option
                v-for="item in data.companyList"
                :key="item.id"
                :label="item.name"
                :value="item.name"
            />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" style="margin-left: 30px" @click="searchClick">查询</el-button>
          <el-button plain @click="reset">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <!-- 表格数据 -->
    <el-table v-loading="loading" :data="dataList" :border="true">
      <el-table-column type="index" label="序号" width="80" align="center"></el-table-column>
      <el-table-column label="企业名称" prop="conpanyName" align="center"  />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" >
        <template #default="scope">
          <el-button link type="primary"  @click="openDialog('review',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>
    <div class="pag-container">
      <el-pagination
          v-model:current-page="data.queryParams.pageNum"
          v-model:page-size="data.queryParams.pageSize"
          :page-sizes="[10,15,20,25]"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
      />
    </div>
    <overviewDialog ref="noticeRef" @getList = "getList"></overviewDialog>
  </div>
</template>
<style scoped lang="scss">
<script setup>
import {getCurrentInstance, onMounted, reactive, ref, toRefs} from "vue";
import overviewDialog from "./components/overviewDialog.vue"
import {ElMessage, ElMessageBox} from "element-plus";
import {getCompany} from "@/api/onlineEducation/company";
import Cookies from "js-cookie";
const { proxy } = getCurrentInstance();
const loading = ref(false);
const noticeRef = ref();
const loadingCompany = ref(false)
const data = reactive({
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    companyId: null,
  },
  companyList: [],
  isAdmin: false
});
const dataList = ref([]);
const total = ref(0);
const { queryParams } = toRefs(data);
onMounted(() => {
  const userInfo = JSON.parse(Cookies.get('userInfo'))
  console.log("userInfo",userInfo)
  data.isAdmin = userInfo.userType === 0;
  getList();
});
const getList = async () => {
  loading.value = true;
  // const res = await getNoticeList(data.queryParams);
  // if(res.code === 200){
  //   dataList.value = res.data.list.map(item => {
  //     return {
  //       ...item,
  //       createTime: item.createTime.replace(/T/g," ")
  //     }
  //   })
  //   total.value = res.data.total
  // }else{
  //   ElMessage.warning(res.message)
  // }
  loading.value = false;
}
const searchClick = () => {
  getList();
}
const openDialog = (type, value) => {
  noticeRef.value.openDialog(type, value);
}
const selectValue = (val) => {
  data.companyList.forEach(item => {
    if(item.name === val){
      data.queryParams.companyId = item.id
    }
  })
}
const getCompanyList = async (val)=>{
  if(val != ""){
    loadingCompany.value = true;
    const queryParams = {
      name: val
    }
    const res = await getCompany(queryParams)
    if (res.code == 200) {
      loadingCompany.value = false;
      data.companyList = res.data.list
    } else {
      ElMessage.warning(res.message)
    }
  }
}
const handleSizeChange = (val) => {
  data.queryParams.pageSize = val
  getList()
}
const handleCurrentChange = (val) => {
  data.queryParams.pageNum = val
  getList()
}
/** 重置新增的表单以及其他数据  */
function reset() {
  data.queryParams = {
    companyId: '',
    pageNum: 1,
    pageSize: 10,
  }
  data.companyList = [];
  getList();
}
const handleDelete = (val) => {
  ElMessageBox.confirm(
      '确定删除此条数据?',
      '提示',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
      .then( async() => {
        // const res = await delNotice(val);
        // if(res.code === 200){
        //   ElMessage({
        //     type: 'success',
        //     message: '删除成功'
        //   });
        //   getList();
        // }else{
        //   ElMessage.warning(res.message)
        // }
      })
}
</script>
<style lang="scss">
.pag-container{
  float: right;
  margin-top: 10px;
}
</style>