8
0
duy 9 сар өмнө
parent
commit
2428b32062

+ 41 - 0
src/api/modules/desk/temperture-density.js

@@ -0,0 +1,41 @@
+import { HcApi } from "../../request/index";
+
+export default {
+    async getList(form) {
+        return HcApi({
+            url: "/api/blade-manager/trial/param/temperature-density/page",
+            method: "get",
+            params: form,
+        });
+    },
+
+    async getDetail(form) {
+        return HcApi({
+            url: "/api/blade-manager/trial/param/temperature-density/detail",
+            method: "get",
+            params: form,
+        });
+    },
+
+    async remove(form) {
+        return HcApi({
+            url: "/api/blade-manager/trial/param/temperature-density/remove",
+            method: "post",
+            params: form,
+        });
+    },
+    async submit(form) {
+        return HcApi({
+            url: "/api/blade-manager/trial/param/temperature-density/submit",
+            method: "post",
+            data: form,
+        });
+    },
+    async importParam(form) {
+        return HcApi({
+            url: "'/api/blade-manager/trial/param/temperature-density/import-excel",
+            method: "post",
+            data: form,
+        });
+    },
+};

+ 1 - 8
src/api/modules/desk/test-params.js

@@ -24,14 +24,7 @@ export default {
             params: form,
         });
     },
-    async add(form) {
-        return HcApi({
-            url: "/api/blade-manager/trial/param/compaction/submit",
-            method: "post",
-            data: form,
-        });
-    },
-    async update(form) {
+    async submit(form) {
         return HcApi({
             url: "/api/blade-manager/trial/param/compaction/submit",
             method: "post",

+ 52 - 14
src/views/desk/test-param.vue

@@ -1,6 +1,6 @@
 <template>
     <hc-tab-card :tabs="tabsData" :tab-key="tabsKey" @change="tabsChange">
-        <hc-card>
+        <hc-card v-if="tabsKey === '1'">
             <template #extra>
                 <el-button hc-btn type="primary" @click="addRowClick"
                     >新增</el-button
@@ -25,13 +25,19 @@
                 @selection-change="tableSelectionChange"
             >
                 <template #action="{ row, index }">
-                    <el-button size="small" type="primary">编辑</el-button>
+                    <el-button
+                        size="small"
+                        type="primary"
+                        @click="editRowClick(row)"
+                        >编辑</el-button
+                    >
                 </template>
             </hc-table>
             <template #action>
                 <hc-pages :pages="searchForm" @change="pageChange" />
             </template>
         </hc-card>
+        <temperatureDensity v-else :tabsKey="tabsKey"></temperatureDensity>
     </hc-tab-card>
     <!-- 新增/修改 -->
     <hc-dialog
@@ -99,7 +105,8 @@
 <script setup>
 import { onMounted, ref } from "vue";
 import mainApi from "~api/desk/test-params";
-import { getArrValue, isNullES } from "js-fast-way";
+import { getArrValue, isNullES, deepClone } from "js-fast-way";
+import temperatureDensity from "./wbs/temperature-density.vue";
 onMounted(() => {
     getTableData();
 });
@@ -109,21 +116,56 @@ const tabsData = ref([
     { key: "2", name: "温度及密度参数" },
 ]);
 const tabsChange = (item) => {
-    console.log(item);
+    console.log(item, "item");
+
+    tabsKey.value = item.key;
 };
 //新增、编辑
 const addRowClick = () => {
     isDataInfoShow.value = true;
+    formModel.value = {};
+};
+//修改
+const editRowClick = (row) => {
+    formModel.value = deepClone(row);
+    isDataInfoShow.value = true;
 };
-
 const isDataInfoShow = ref(false);
 const formModel = ref({});
 const formRules = {};
-const dialogClose = () => {};
+const dialogClose = () => {
+    isDataInfoShow.value = false;
+    formModel.value = {};
+};
 const submitLoading = ref(false);
-const dialogSubmit = () => {};
+const dialogSubmit = async () => {
+    submitLoading.value = true;
+    const { isRes } = await mainApi.submit(formModel.value);
+    submitLoading.value = false;
+    if (!isRes) return;
+    window.$message.success("操作成功");
+    dialogClose();
+    getTableData().then();
+};
 const tableCheckKeys = ref([]);
-const batchDelClick = () => {};
+const batchDelClick = () => {
+    const rows = tableCheckKeys.value;
+    if (rows.length <= 0) {
+        window.$message.warning("请选择要删除的应用");
+        return false;
+    }
+    rowRemoveApi(arrToId(rows));
+};
+//删除接口
+const rowRemoveApi = (ids) => {
+    HcDelMsg(async (resolve) => {
+        const { isRes } = await mainApi.remove({ ids: ids });
+        resolve(); //关闭弹窗的回调
+        if (!isRes) return;
+        window.$message.success("删除成功");
+        getTableData();
+    });
+};
 const impotClick = () => {};
 const tableColumn = [
     { key: "valueN", name: "N值" },
@@ -133,11 +175,7 @@ const tableColumn = [
     { key: "action", name: "操作", width: 100 },
 ];
 const searchForm = ref({ current: 1, size: 30, total: 0 });
-const tableData = ref([
-    { name: "名称1", text: "文本1", color: "red" },
-    { name: "名称2", text: "文本2", color: "blue" },
-    { name: "名称3", text: "文本3", color: "无" },
-]);
+const tableData = ref([]);
 const tableLoading = ref(false);
 const getTableData = async () => {
     tableLoading.value = true;
@@ -153,7 +191,7 @@ const getTableData = async () => {
 };
 //多选事件
 const tableSelectionChange = (rows) => {
-    console.log(rows);
+    tableCheckKeys.value = rows;
 };
 //分页
 const pageChange = ({ current, size }) => {

+ 193 - 0
src/views/desk/wbs/temperature-density.vue

@@ -0,0 +1,193 @@
+<template>
+    <hc-card>
+        <template #extra>
+            <el-button hc-btn type="primary" @click="addRowClick"
+                >新增</el-button
+            >
+            <el-button
+                hc-btn
+                type="danger"
+                :disabled="tableCheckKeys.length <= 0"
+                @click="batchDelClick"
+                >删除</el-button
+            >
+            <el-button hc-btn type="warning" @click="impotClick"
+                >导入</el-button
+            >
+        </template>
+
+        <hc-table
+            :loading="tableLoading"
+            :column="tableColumn"
+            :datas="tableData"
+            isCheck
+            @selection-change="tableSelectionChange"
+        >
+            <template #action="{ row, index }">
+                <el-button
+                    size="small"
+                    type="primary"
+                    @click="editRowClick(row)"
+                    >编辑</el-button
+                >
+            </template>
+        </hc-table>
+        <template #action>
+            <hc-pages :pages="searchForm" @change="pageChange" />
+        </template>
+    </hc-card>
+    <!-- 新增/修改 -->
+    <hc-dialog
+        v-model="isDataInfoShow"
+        is-footer-center
+        :title="isNullES(formModel.id) ? '新增' : '修改'"
+        @close="dialogClose"
+    >
+        <el-form
+            ref="formRef"
+            :model="formModel"
+            :rules="formRules"
+            label-position="top"
+            label-width="auto"
+            size="large"
+        >
+            <el-form-item label="温度:" prop="temperature">
+                <el-input
+                    v-model="formModel.temperature"
+                    clearable
+                    placeholder="请输入"
+                />
+            </el-form-item>
+            <el-form-item label="密度:" prop="waterDensity">
+                <el-input
+                    v-model="formModel.waterDensity"
+                    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>
+</template>
+<script setup>
+import { ref, watch } from "vue";
+import { HcDelMsg } from "hc-vue3-ui";
+import { arrToId, deepClone, getArrValue, isNullES } from "js-fast-way";
+import mainApi from "~api/desk/temperture-density";
+
+const props = defineProps({
+    tabsKey: {
+        type: String,
+        default: "",
+    },
+});
+
+const tabsKey = ref(props.tabsKey);
+//监听数据
+watch(
+    () => [props.tabsKey],
+    ([key]) => {
+        tabsKey.value = key;
+    },
+    { deep: true }
+);
+
+//新增、编辑
+const addRowClick = () => {
+    isDataInfoShow.value = true;
+    formModel.value = {};
+};
+//修改
+const editRowClick = (row) => {
+    formModel.value = deepClone(row);
+    isDataInfoShow.value = true;
+};
+const isDataInfoShow = ref(false);
+const formModel = ref({});
+const formRules = {};
+const dialogClose = () => {
+    isDataInfoShow.value = false;
+    formModel.value = {};
+};
+const submitLoading = ref(false);
+const dialogSubmit = async () => {
+    submitLoading.value = true;
+    const { isRes } = await mainApi.submit(formModel.value);
+    submitLoading.value = false;
+    if (!isRes) return;
+    window.$message.success("操作成功");
+    dialogClose();
+    getTableData().then();
+};
+const tableCheckKeys = ref([]);
+const batchDelClick = () => {
+    const rows = tableCheckKeys.value;
+    if (rows.length <= 0) {
+        window.$message.warning("请选择要删除的应用");
+        return false;
+    }
+    rowRemoveApi(arrToId(rows));
+};
+//删除接口
+const rowRemoveApi = (ids) => {
+    HcDelMsg(async (resolve) => {
+        const { isRes } = await mainApi.remove({ ids: ids });
+        resolve(); //关闭弹窗的回调
+        if (!isRes) return;
+        window.$message.success("删除成功");
+        getTableData();
+    });
+};
+const impotClick = () => {};
+const tableColumn = [
+    { key: "temperature", name: "温度" },
+    { key: "waterDensity", name: "密度" },
+
+    { key: "action", name: "操作", width: 100 },
+];
+const searchForm = ref({ current: 1, size: 30, total: 0 });
+const tableData = ref([]);
+const tableLoading = ref(false);
+const getTableData = async () => {
+    tableLoading.value = true;
+    const { code, msg, data } = await mainApi.getList({
+        ...searchForm.value,
+        total: null,
+    });
+    tableLoading.value = false;
+    if (code === 200) {
+        tableData.value = getArrValue(data?.records);
+        searchForm.value.total = data?.total || 0;
+    }
+};
+//监听显示
+watch(
+    tabsKey,
+    (val) => {
+        if (val === "2") {
+            getTableData();
+        }
+    },
+    { immediate: true }
+);
+//多选事件
+const tableSelectionChange = (rows) => {
+    tableCheckKeys.value = rows;
+};
+//分页
+const pageChange = ({ current, size }) => {
+    searchForm.value.current = current;
+    searchForm.value.size = size;
+    getTableData();
+};
+</script>
+<style lang="css" scoped></style>