zhouwx
4 天以前 592c1750b148874737cdfba4b22b6229f9805fe6
src/views/build/conpanyFunctionConsult/qualityManage/rangeManage/catalogRange/index.vue
@@ -10,31 +10,6 @@
              @click="openDialog('add','',1)"
          >新增</el-button>
        </el-form-item>
        <el-form-item v-if="isAdmin" label="企业:" >
          <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 v-if="isAdmin" type="primary" @click="getList">查询</el-button>
          <el-button v-if="isAdmin" type="primary" plain @click="reset">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <!-- 表格数据 -->
@@ -42,16 +17,19 @@
              :data="dataList"
              :border="true"
              row-key="id"
              :default-expand-all="false"
              :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
              :default-expand-all="true"
              :tree-props="{ children: 'children'}"
    >
      <el-table-column label="目录名称" prop="label" align="center"></el-table-column>
      <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" @click="handleDelete(scope.row)">删除</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>
@@ -69,18 +47,9 @@
<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 {delUser, getUser} from "@/api/onlineEducation/user";
import Cookies from "js-cookie";
import editDialog from './components/editDialog.vue'
import {
  delIndustryTemp,
  getIndustryTemp,
} from "@/api/staffManage/staff";
import useUserStore from "@/store/modules/user";
import axios from "axios";
import {getToken} from "@/utils/auth";
import {delCatalogue, getCatalogue} from "@/api/qualityManage/catalog";
const userStore = useUserStore()
const { proxy } = getCurrentInstance();
const loading = ref(false);
@@ -97,6 +66,7 @@
  companyList: [],
  industryList: [],
  isAdmin: false,
});
const { queryParams, total, dataList,companyList,industryList, isAdmin } = toRefs(data);
@@ -105,12 +75,12 @@
  if(userStore.roles.includes('admin')){
    data.isAdmin = true
    data.queryParams.companyId = null
    await getCompanyList()
  }else{
    data.isAdmin = false
    data.queryParams.companyId = userStore.companyId
  }
  await getList()
})
onUnmounted(()=>{
@@ -119,51 +89,15 @@
const getList = async () => {
  loading.value = true
  // const res = await getIndustryTemp(data.queryParams)
  // if(res.code == 200){
  //   data.dataList = res.data.list || []
  //   data.total = res.data.total
  // }else{
  //   ElMessage.warning(res.message)
  // }
  data.dataList = [
      {
        parentId: 0,
        id:1,
        label: '1.1规范范围管理',
        children: [
          {
            parentId: 1,
            id:2,
            label: 'Level three 1-1-1',
            children: [
              {
                parentId: 2,
                id:3,
                label: 'Level three 1-1-1',
                children: [
                  {
                    parentId: 3,
                    id:4,
                    label: 'Level three 1-1-1',
                  },
                ],
              },
            ],
          },
        ],
      },
      {
        parentId: 0,
        id:5,
        label: '1.2收集需求',
      },
      {
        parentId: 0,
        id:6,
        label: '1.3定义范围',
      },
  ]
  const param = {
    type: 1,
  }
  const res = await getCatalogue(param);
  if(res.code === 200){
    data.dataList = res.data.data
  }else{
    ElMessage.warning(res.message)
  }
  loading.value = false
}
@@ -179,7 +113,6 @@
    pageSize: 10,
    companyId: null,
  }
  await getCompanyList()
  await getList()
}
const handleDelete = (val) => {
@@ -192,7 +125,7 @@
        type: 'warning',
      })
      .then( async() => {
        const res = await delIndustryTemp({companyRosterId: val.id})
        const res = await delCatalogue(val.id)
        if(res.code == 200){
          ElMessage.success('数据删除成功')
          await getList()
@@ -200,43 +133,6 @@
          ElMessage.warning(res.message)
        }
      })
}
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)
    }
  }else {
    loadingCompany.value = true;
    const queryParams = {
      pageSize: 10,
      pageNum: 1,
    }
    const res = await getCompany(queryParams)
    if (res.code == 200) {
      loadingCompany.value = false;
      data.companyList = res.data.list
    } else {
      ElMessage.warning(res.message)
    }
  }
}
</script>