ZaiZai 1 year ago
parent
commit
9319dae2ac
2 changed files with 149 additions and 0 deletions
  1. 48 0
      src/api/modules/desk/wbs.js
  2. 101 0
      src/views/desk/wbs.vue

+ 48 - 0
src/api/modules/desk/wbs.js

@@ -0,0 +1,48 @@
+import { HcApi } from '../../request/index'
+
+export default {
+    async page(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsInfo/page',
+            method: 'get',
+            params: form,
+        })
+    },
+    async detail(id) {
+        return HcApi({
+            url: '/api/blade-manager/wbsInfo/detail',
+            method: 'get',
+            params: { id },
+        })
+    },
+    async submit(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsInfo/submit',
+            method: 'post',
+            data: form,
+        })
+    },
+    async del(ids) {
+        return HcApi({
+            url: '/api/blade-manager/wbsInfo/remove',
+            method: 'post',
+            params: { ids },
+        })
+    },
+    //元素库、独立库节点排序
+    async wbsInfotabSort(primaryKeyIds) {
+        return HcApi({
+            url: '/api/blade-manager/wbsInfo/tab-sort',
+            method: 'post',
+            params: { primaryKeyIds },
+        })
+    },
+    //获取1质检 2实验公有树列表
+    async getWbsList(type) {
+        return HcApi({
+            url: '/api/blade-manager/wbsInfo/get-wbs-type',
+            method: 'get',
+            params: { type },
+        })
+    },
+}

+ 101 - 0
src/views/desk/wbs.vue

@@ -1,8 +1,109 @@
 <template>
+    <hc-card>
+        <template #header>
+            <div class="w-400px">
+                <hc-search-input v-model="searchForm.queryValue" @search="searchClick" />
+            </div>
+        </template>
+        <template #extra>
+            <el-button hc-btn type="primary">新增</el-button>
+            <el-button hc-btn type="danger">删除</el-button>
+            <el-button hc-btn type="warning">元素库</el-button>
+        </template>
+        <hc-table
+            :column="tableColumn" :datas="tableData" :loading="tableLoading" :index-style="{ width: 60 }"
+            is-check :check-style="{ width: 29 }" @selection-change="tableCheckChange"
+        >
+            <template #wbsType="{ row }">
+                <span>{{ getWbsTypeName(row.wbsType) }}</span>
+            </template>
+            <template #status="{ row }">
+                <span>{{ row.status === 1 ? '是' : '否' }}</span>
+            </template>
+            <template #action="{ row }">
+                <el-link type="primary">编辑wbs库</el-link>
+                <el-link type="warning">修改</el-link>
+                <el-link type="danger">删除</el-link>
+            </template>
+        </hc-table>
+        <template #action>
+            <hc-pages :pages="searchForm" @change="pageChange" />
+        </template>
+    </hc-card>
 </template>
 
 <script setup>
+import { onActivated, ref } from 'vue'
+import { getArrValue, getObjValue, isNullES } from 'js-fast-way'
+import { getDictionaryData } from '~uti/tools'
+import mainApi from '~api/desk/wbs'
 
+//激活
+onActivated(() => {
+    getWbsTypeData()
+    getTableData()
+})
+
+//获取划分类型
+const wbsTypeData = ref([])
+const getWbsTypeData = async () => {
+    wbsTypeData.value = await getDictionaryData('wbs_type')
+}
+//获取划分类型名称
+const getWbsTypeName = (val) => {
+    if (isNullES(val)) return ''
+    const data = wbsTypeData.value.find(item => {
+        return Number(item.value) === Number(val)
+    })
+    const res = getObjValue(data)
+    return res.label || ''
+}
+
+//搜索表单
+const searchForm = ref({ current: 1, size: 30, total: 0 })
+
+//搜索
+const searchClick = () => {
+    searchForm.value.current = 1
+    getTableData()
+}
+
+//分页
+const pageChange = ({ current, size }) => {
+    searchForm.value.current = current
+    searchForm.value.size = size
+    getTableData()
+}
+
+//表格数据
+const tableData = ref([])
+const tableColumn = ref([
+    { key: 'wbsName', name: '名称' },
+    { key: 'wbsType', name: '划分类型', width: 120, align: 'center' },
+    { key: 'status', name: '是否启用', width: 100, align: 'center' },
+    { key: 'createTime', name: '创建时间', width: 180, align: 'center' },
+    { key: 'action', name: '操作', width: 180, align: 'center' },
+])
+
+//获取表格数据
+const tableLoading = ref(false)
+const getTableData = async () => {
+    tableData.value = []
+    tableLoading.value = true
+    const { data } = await mainApi.page({
+        ...searchForm.value,
+        total: null,
+    })
+    tableLoading.value = false
+    tableData.value = getArrValue(data?.records)
+    searchForm.value.total = data?.total || 0
+}
+
+//表格被选择
+const tableCheckKeys = ref([])
+const tableCheckChange = (rows) => {
+    tableCheckKeys.value = rows
+}
 </script>
 
 <style scoped lang="scss">