|
|
@@ -0,0 +1,264 @@
|
|
|
+<template>
|
|
|
+ <div class="app-container">
|
|
|
+ <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
|
|
|
+ <el-form-item label="模型名称" prop="modelName">
|
|
|
+ <el-input
|
|
|
+ v-model="queryParams.modelName"
|
|
|
+ placeholder="请输入模型名称"
|
|
|
+ clearable
|
|
|
+ @keyup.enter="handleQuery"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+<!-- <el-form-item label="排序" prop="orderNum">-->
|
|
|
+<!-- <el-input-->
|
|
|
+<!-- v-model="queryParams.orderNum"-->
|
|
|
+<!-- placeholder="请输入排序"-->
|
|
|
+<!-- clearable-->
|
|
|
+<!-- @keyup.enter="handleQuery"-->
|
|
|
+<!-- />-->
|
|
|
+<!-- </el-form-item>-->
|
|
|
+<!-- <el-form-item label="上级ID" prop="parentId">-->
|
|
|
+<!-- <el-input-->
|
|
|
+<!-- v-model="queryParams.parentId"-->
|
|
|
+<!-- placeholder="请输入上级ID"-->
|
|
|
+<!-- clearable-->
|
|
|
+<!-- @keyup.enter="handleQuery"-->
|
|
|
+<!-- />-->
|
|
|
+<!-- </el-form-item>-->
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
|
|
+ <el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+
|
|
|
+ <el-row :gutter="10" class="mb8">
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ plain
|
|
|
+ icon="Plus"
|
|
|
+ @click="handleAdd"
|
|
|
+ >新增
|
|
|
+ </el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="info"
|
|
|
+ plain
|
|
|
+ icon="Sort"
|
|
|
+ @click="toggleExpandAll"
|
|
|
+ >展开/折叠
|
|
|
+ </el-button>
|
|
|
+ </el-col>
|
|
|
+ <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <el-table
|
|
|
+ v-if="refreshTable"
|
|
|
+ v-loading="loading"
|
|
|
+ :data="modelList"
|
|
|
+ row-key="modelId"
|
|
|
+ :default-expand-all="isExpandAll"
|
|
|
+ :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
|
|
+ >
|
|
|
+ <el-table-column label="模型名称" prop="modelName"/>
|
|
|
+ <el-table-column label="模型描述" align="center" prop="modelDesc"/>
|
|
|
+<!-- <el-table-column label="排序" align="center" prop="orderNum"/>-->
|
|
|
+<!-- <el-table-column label="上级ID" align="center" prop="parentId"/>-->
|
|
|
+ <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"> 修改</el-button>
|
|
|
+ <el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)">新增</el-button>
|
|
|
+ <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <!-- 添加或修改分析模型对话框 -->
|
|
|
+ <el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
|
|
+ <el-form ref="modelRef" :model="form" :rules="rules" label-width="80px">
|
|
|
+ <el-form-item label="上级模型" prop="parentId">
|
|
|
+ <el-tree-select
|
|
|
+ v-model="form.parentId"
|
|
|
+ :data="modelOptions"
|
|
|
+ :props="{ value: 'modelId', label: 'modelName', children: 'children' }"
|
|
|
+ value-key="modelId"
|
|
|
+ placeholder="请选择上级模型"
|
|
|
+ check-strictly
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <el-form-item label="模型名称" prop="modelName">
|
|
|
+ <el-input v-model="form.modelName" placeholder="请输入模型名称"/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="模型描述" prop="modelDesc">
|
|
|
+ <el-input v-model="form.modelDesc" type="textarea" placeholder="请输入内容"/>
|
|
|
+ </el-form-item>
|
|
|
+ <!-- <el-form-item label="排序" prop="orderNum">-->
|
|
|
+ <!-- <el-input v-model="form.orderNum" placeholder="请输入排序"/>-->
|
|
|
+ <!-- </el-form-item>-->
|
|
|
+ <template #footer>
|
|
|
+ <div class="dialog-footer">
|
|
|
+ <el-button type="primary" @click="submitForm">确 定</el-button>
|
|
|
+ <el-button @click="cancel">取 消</el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup name="Model">
|
|
|
+
|
|
|
+import {addModel, delModel, getModel, listModel, updateModel} from "@/api/biz/model";
|
|
|
+
|
|
|
+const {proxy} = getCurrentInstance();
|
|
|
+
|
|
|
+const modelList = ref([]);
|
|
|
+const modelOptions = ref([]);
|
|
|
+const open = ref(false);
|
|
|
+const loading = ref(true);
|
|
|
+const showSearch = ref(true);
|
|
|
+const title = ref("");
|
|
|
+const isExpandAll = ref(true);
|
|
|
+const refreshTable = ref(true);
|
|
|
+
|
|
|
+const data = reactive({
|
|
|
+ form: {},
|
|
|
+ queryParams: {
|
|
|
+ modelName: null,
|
|
|
+ modelDesc: null,
|
|
|
+ orderNum: null,
|
|
|
+ parentId: null,
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ modelName: [
|
|
|
+ {required: true, message: "模型名称不能为空", trigger: "blur"}
|
|
|
+ ],
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+const {queryParams, form, rules} = toRefs(data);
|
|
|
+
|
|
|
+/** 查询分析模型列表 */
|
|
|
+function getList() {
|
|
|
+ loading.value = true;
|
|
|
+ listModel(queryParams.value).then(response => {
|
|
|
+ modelList.value = proxy.handleTree(response.data, "modelId", "parentId");
|
|
|
+ loading.value = false;
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+/** 查询分析模型下拉树结构 */
|
|
|
+function getTreeselect() {
|
|
|
+ listModel().then(response => {
|
|
|
+ modelOptions.value = [];
|
|
|
+ const data = {modelId: 0, modelName: '顶级节点', children: []};
|
|
|
+ data.children = proxy.handleTree(response.data, "modelId", "parentId");
|
|
|
+ modelOptions.value.push(data);
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+// 取消按钮
|
|
|
+function cancel() {
|
|
|
+ open.value = false;
|
|
|
+ reset();
|
|
|
+}
|
|
|
+
|
|
|
+// 表单重置
|
|
|
+function reset() {
|
|
|
+ form.value = {
|
|
|
+ modelId: null,
|
|
|
+ modelName: null,
|
|
|
+ modelDesc: null,
|
|
|
+ orderNum: null,
|
|
|
+ parentId: null,
|
|
|
+ createBy: null,
|
|
|
+ createTime: null,
|
|
|
+ updateBy: null,
|
|
|
+ updateTime: null,
|
|
|
+ remark: null
|
|
|
+ };
|
|
|
+ proxy.resetForm("modelRef");
|
|
|
+}
|
|
|
+
|
|
|
+/** 搜索按钮操作 */
|
|
|
+function handleQuery() {
|
|
|
+ getList();
|
|
|
+}
|
|
|
+
|
|
|
+/** 重置按钮操作 */
|
|
|
+function resetQuery() {
|
|
|
+ proxy.resetForm("queryRef");
|
|
|
+ handleQuery();
|
|
|
+}
|
|
|
+
|
|
|
+/** 新增按钮操作 */
|
|
|
+function handleAdd(row) {
|
|
|
+ reset();
|
|
|
+ getTreeselect();
|
|
|
+ if (row != null && row.modelId) {
|
|
|
+ form.value.parentId = row.modelId;
|
|
|
+ } else {
|
|
|
+ form.value.parentId = 0;
|
|
|
+ }
|
|
|
+ open.value = true;
|
|
|
+ title.value = "添加分析模型";
|
|
|
+}
|
|
|
+
|
|
|
+/** 展开/折叠操作 */
|
|
|
+function toggleExpandAll() {
|
|
|
+ refreshTable.value = false;
|
|
|
+ isExpandAll.value = !isExpandAll.value;
|
|
|
+ nextTick(() => {
|
|
|
+ refreshTable.value = true;
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+/** 修改按钮操作 */
|
|
|
+async function handleUpdate(row) {
|
|
|
+ reset();
|
|
|
+ await getTreeselect();
|
|
|
+ if (row != null) {
|
|
|
+ form.value.parentId = row.modelId;
|
|
|
+ }
|
|
|
+ getModel(row.modelId).then(response => {
|
|
|
+ form.value = response.data;
|
|
|
+ open.value = true;
|
|
|
+ title.value = "修改分析模型";
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+/** 提交按钮 */
|
|
|
+function submitForm() {
|
|
|
+ proxy.$refs["modelRef"].validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ if (form.value.modelId != null) {
|
|
|
+ updateModel(form.value).then(response => {
|
|
|
+ proxy.$modal.msgSuccess("修改成功");
|
|
|
+ open.value = false;
|
|
|
+ getList();
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ addModel(form.value).then(response => {
|
|
|
+ proxy.$modal.msgSuccess("新增成功");
|
|
|
+ open.value = false;
|
|
|
+ getList();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+/** 删除按钮操作 */
|
|
|
+function handleDelete(row) {
|
|
|
+ proxy.$modal.confirm('是否确认删除分析模型编号为"' + row.modelId + '"的数据项?').then(function () {
|
|
|
+ return delModel(row.modelId);
|
|
|
+ }).then(() => {
|
|
|
+ getList();
|
|
|
+ proxy.$modal.msgSuccess("删除成功");
|
|
|
+ }).catch(() => {
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+getList();
|
|
|
+</script>
|