zhouwx
4 天以前 592c1750b148874737cdfba4b22b6229f9805fe6
src/views/build/conpanyFunctionConsult/qualityManage/environmentManage/catalogEnvironment/index.vue
@@ -1,11 +1,138 @@
<script setup>
</script>
<template>
  组织环境目录
  <div class="app-container">
    <div style="display: flex;justify-content: space-between">
      <el-form :inline="true" style="display: flex;align-items: center;flex-wrap: wrap;" >
        <el-form-item>
          <el-button
              type="primary"
              plain
              icon="Plus"
              @click="openDialog('add','',1)"
          >新增</el-button>
        </el-form-item>
      </el-form>
    </div>
    <!-- 表格数据 -->
    <el-table v-loading="loading"
              :data="dataList"
              :border="true"
              row-key="id"
              :default-expand-all="true"
              :tree-props="{ children: 'children'}"
    >
      <el-table-column label="目录名称" prop="mess"  >
        <template #default="scope">
          {{scope.row.number}} {{scope.row.mess}}
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" >
        <template #default="scope">
          <el-button link type="primary" @click="openDialog('add',scope.row,2)">新增</el-button>
          <el-button link type="primary" @click="openDialog('edit',scope.row,null)">编辑</el-button>
          <el-button link type="danger" v-if="scope.row.children && scope.row.children.length == 0" @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"
    />
    <edit-dialog ref="dialogRef" @getList=getList></edit-dialog>
  </div>
</template>
<style scoped lang="scss">
<script setup>
import {getCurrentInstance, onMounted, onUnmounted, reactive, ref, toRefs} from "vue";
import {ElMessage, ElMessageBox} from "element-plus";
import editDialog from './components/editDialog.vue'
import useUserStore from "@/store/modules/user";
import {delCatalogue, getCatalogue} from "@/api/qualityManage/catalog";
const userStore = useUserStore()
const { proxy } = getCurrentInstance();
const loading = ref(false);
const loadingCompany = ref(false)
const dialogRef = ref();
const data = reactive({
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    companyId: null,
  },
  total: 0,
  dataList: [],
  companyList: [],
  industryList: [],
  isAdmin: false,
</style>
});
const { queryParams, total, dataList,companyList,industryList, isAdmin } = toRefs(data);
const userInfo = ref()
onMounted(async ()=>{
  if(userStore.roles.includes('admin')){
    data.isAdmin = true
    data.queryParams.companyId = null
  }else{
    data.isAdmin = false
    data.queryParams.companyId = userStore.companyId
  }
  await getList()
})
onUnmounted(()=>{
})
const getList = async () => {
  loading.value = true
  const param = {
    type: 4,
  }
  const res = await getCatalogue(param);
  if(res.code === 200){
    data.dataList = res.data.data
  }else{
    ElMessage.warning(res.message)
  }
  loading.value = false
}
const openDialog = (type, value,flag) => {
  dialogRef.value.openDialog(type, value, data.queryParams.companyId, data.isAdmin,flag);
}
/** 重置新增的表单以及其他数据  */
const reset= async()=> {
  data.queryParams = {
    pageNum: 1,
    pageSize: 10,
    companyId: null,
  }
  await getList()
}
const handleDelete = (val) => {
  ElMessageBox.confirm(
      '确定删除此条数据?',
      '提示',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
      .then( async() => {
        const res = await delCatalogue(val.id)
        if(res.code == 200){
          ElMessage.success('数据删除成功')
          await getList()
        }else{
          ElMessage.warning(res.message)
        }
      })
}
</script>