ZaiZai 11 kuukautta sitten
vanhempi
commit
99a94ef4f8
2 muutettua tiedostoa jossa 173 lisäystä ja 2 poistoa
  1. 49 0
      src/api/modules/desk/system-unit.js
  2. 124 2
      src/views/desk/system-unit.vue

+ 49 - 0
src/api/modules/desk/system-unit.js

@@ -0,0 +1,49 @@
+import { HcApi } from '../../request/index'
+
+export default {
+    async page(form) {
+        return HcApi({
+            url: '/api/blade-meter/tree/template/page',
+            method: 'post',
+            data: form,
+        })
+    },
+    async submit(form) {
+        return HcApi({
+            url: '/api/blade-meter/tree/template/submit',
+            method: 'post',
+            data: form,
+        })
+    },
+    async del(ids) {
+        return HcApi({
+            url: '/api/blade-meter/tree/template/remove',
+            method: 'get',
+            params: { ids },
+        })
+    },
+    //元素库树
+    async tabTypeLazyTreeAll(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsPrivate/tab-Type-lazy-tree-all',
+            method: 'get',
+            params: form,
+        })
+    },
+    //元素库、独立库节点排序
+    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 },
+        })
+    },
+}

+ 124 - 2
src/views/desk/system-unit.vue

@@ -1,11 +1,133 @@
 <template>
-    <div>11</div>
+    <hc-card>
+        <template #header>
+            <div class="w-60">
+                <hc-search-input v-model="searchForm.name" placeholder="请输入名称关键词" @search="searchClick" />
+            </div>
+        </template>
+        <template #extra>
+            <el-button hc-btn type="primary" @click="addClick">新增</el-button>
+        </template>
+        <hc-table :column="tableColumn" :datas="tableData" :loading="tableLoading" :index-style="{ width: 60 }" :is-current-row="false">
+            <template #action="{ row }">
+                <el-link type="warning" @click="editRowClick(row)">修改</el-link>
+                <el-link type="primary">编辑计量系统单元</el-link>
+                <el-link type="danger">删除</el-link>
+            </template>
+        </hc-table>
+        <template #action>
+            <hc-pages :pages="searchForm" @change="pageChange" />
+        </template>
+
+        <!-- 新增/修改 -->
+        <hc-dialog v-model="isDialogShow" widths="24rem" is-footer-center :title="formModel.id ? '新增' : '修改'" @close="dialogClose">
+            <el-form ref="formRef" :model="formModel" :rules="formRules" size="large" label-width="auto">
+                <el-form-item label="名称:" prop="name">
+                    <el-input v-model="formModel.name" clearable placeholder="请输入模版名称" />
+                </el-form-item>
+                <el-form-item label="备注:">
+                    <el-input v-model="formModel.remarks" clearable placeholder="请输入备注" />
+                </el-form-item>
+            </el-form>
+            <template #footer>
+                <el-button hc-btn @click="dialogClose">取消</el-button>
+                <el-button hc-btn type="primary" :loading="submitLoading" @click="dialogSubmit">提交</el-button>
+            </template>
+        </hc-dialog>
+    </hc-card>
 </template>
 
 <script setup>
+import { nextTick, onActivated, ref } from 'vue'
+import { deepClone, formValidate, getArrValue } from 'js-fast-way'
+import mainApi from '~api/desk/system-unit'
+
+//激活
+onActivated(() => {
+    searchForm.value.current = 1
+    getTableData()
+})
+
+//搜索表单
+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 tableColumn = ref([
+    { key: 'name', name: '模版名称' },
+    { key: 'remarks', name: '备注' },
+    { key: 'action', name: '操作', width: 220, align: 'center' },
+])
+
+//获取表格数据
+const tableLoading = ref(true)
+const tableData = ref([{}])
+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 isDialogShow = ref(false)
+const formRef = ref(null)
+const formModel = ref({})
+const formRules = { name: { required: true, trigger: 'blur', message: '请输入模版名称' } }
+
+//新增
+const addClick = async () => {
+    formModel.value = {}
+    await nextTick()
+    isDialogShow.value = true
+}
+
+//修改
+const editRowClick = async (row) => {
+    formModel.value = deepClone(row)
+    await nextTick()
+    isDialogShow.value = true
+}
+
+//提交表单
+const submitLoading = ref(false)
+const dialogSubmit = async () => {
+    const isForm = await formValidate(formRef.value)
+    if (!isForm) return false
+    submitLoading.value = true
+    const { error, code } = await mainApi.submit(formModel.value)
+    submitLoading.value = false
+    if (!error && code === 200) {
+        window?.$message?.success('操作成功')
+        dialogClose()
+        getTableData().then()
+    }
+}
 
+//关闭弹窗
+const dialogClose = () => {
+    isDialogShow.value = false
+    formModel.value = {}
+}
 </script>
 
-<style scoped lang="scss">
+<style lang="scss">
 
 </style>