From a4d7993d0b44faffe2e548250a9d2bc27c77e521 Mon Sep 17 00:00:00 2001 From: xiejun <xj@2023> Date: 星期三, 19 七月 2023 12:27:46 +0800 Subject: [PATCH] 集成获取分类接口(包含编码规则码段码值信息) --- Source/UBCS-WEB/dist/src/views/tool/model.vue | 349 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 349 insertions(+), 0 deletions(-) diff --git a/Source/UBCS-WEB/dist/src/views/tool/model.vue b/Source/UBCS-WEB/dist/src/views/tool/model.vue new file mode 100644 index 0000000..0c0db08 --- /dev/null +++ b/Source/UBCS-WEB/dist/src/views/tool/model.vue @@ -0,0 +1,349 @@ +<template> + <basic-container> + <avue-crud :option="option" + :table-loading="loading" + :data="data" + :page="page" + :permission="permissionList" + :before-open="beforeOpen" + v-model="form" + v-loading.fullscreen.lock="fullscreenLoading" + ref="crud" + @row-update="rowUpdate" + @row-save="rowSave" + @row-del="rowDel" + @search-change="searchChange" + @search-reset="searchReset" + @selection-change="selectionChange" + @current-change="currentChange" + @size-change="sizeChange" + @on-load="onLoad"> + <template slot="menuLeft"> + <el-button type="danger" + size="small" + icon="el-icon-delete" + plain + @click="handleDelete">鍒� 闄� + </el-button> + </template> + <template slot-scope="{row}" slot="menu"> + <el-button type="text" + icon="el-icon-setting" + size="small" + plain + class="none-border" + @click.stop="handleModel(row)">妯″瀷閰嶇疆 + </el-button> + </template> + <template slot-scope="{row}" slot="modelTable"> + <el-tag>{{ row.modelTable }}</el-tag> + </template> + </avue-crud> + <el-dialog title="鏁版嵁搴撴ā鍨嬮厤缃�" + :visible.sync="modelBox" + :fullscreen="true" + append-to-body> + <avue-crud ref="crudModel" :option="optionModel" :table-loading="loading" :data="fields"></avue-crud> + <span slot="footer" class="dialog-footer"> + <el-button type="danger" @click="modelBox = false">鍏� 闂�</el-button> + <el-button type="primary" @click="handleSubmit">鎻� 浜�</el-button> + </span> + </el-dialog> + </basic-container> +</template> + +<script> +import { + getList, + getDetail, + add, + update, + remove, + getTableList, + getTableInfoByName, + getModelPrototype, + submitModelPrototype +} from "@/api/tool/model"; +import {entityDic, option, optionModel} from "@/const/tool/model"; +import {validatenull} from "@/util/validate"; +import {mapGetters} from "vuex"; + +export default { + data() { + return { + form: {}, + query: {}, + loading: true, + loadingOption: { + lock: true, + text: 'Loading', + spinner: 'el-icon-loading', + background: 'rgba(0, 0, 0, 0)' + }, + fullscreenLoading: false, + page: { + pageSize: 10, + currentPage: 1, + total: 0 + }, + selectionList: [], + modelBox: false, + modelId: 0, + datasourceId: 1, + tableInfo: {}, + active: 0, + stepStart: 0, + stepEnd: 4, + data: [], + option: option, + optionModel: optionModel, + formStep: {}, + fields: [], + selectionModelList: [], + }; + }, + watch: { + 'form.datasourceId'() { + if (!validatenull(this.form.datasourceId)) { + const fullLoading = this.$loading(this.loadingOption); + getTableList(this.form.datasourceId).then(res => { + const column = this.findObject(this.option.column, "modelTable"); + column.dicData = res.data.data; + fullLoading.close(); + }).catch(() => { + fullLoading.close(); + }) + } + }, + 'form.modelTable'() { + if (!validatenull(this.form.modelTable)) { + const fullLoading = this.$loading(this.loadingOption); + getTableInfoByName(this.form.modelTable, this.form.datasourceId).then(res => { + const result = res.data; + if (result.success) { + const {comment, entityName} = result.data; + if (validatenull(this.form.modelClass)) { + this.form.modelClass = entityName; + } + if (validatenull(this.form.modelName)) { + this.form.modelName = comment; + } + if (validatenull(this.form.modelCode)) { + this.form.modelCode = entityName.replace(/^\S/, s => s.toLowerCase()); + } + fullLoading.close(); + } + }); + } + } + }, + computed: { + ...mapGetters(["permission"]), + permissionList() { + return { + addBtn: true, + delBtn: true, + editBtn: true, + viewBtn: false + }; + }, + ids() { + let ids = []; + this.selectionList.forEach(ele => { + ids.push(ele.id); + }); + return ids.join(","); + }, + }, + methods: { + rowSave(row, done, loading) { + add(row).then(() => { + done(); + this.onLoad(this.page); + this.$message({ + type: "success", + message: "鎿嶄綔鎴愬姛!" + }); + }, error => { + loading(); + window.console.log(error); + }); + }, + rowUpdate(row, index, done, loading) { + update(row).then(() => { + done(); + this.onLoad(this.page); + this.$message({ + type: "success", + message: "鎿嶄綔鎴愬姛!" + }); + }, error => { + loading(); + window.console.log(error); + }); + }, + rowDel(row) { + this.$confirm("纭畾灏嗛�夋嫨鏁版嵁鍒犻櫎?", { + confirmButtonText: "纭畾", + cancelButtonText: "鍙栨秷", + type: "warning" + }) + .then(() => { + return remove(row.id); + }) + .then(() => { + this.onLoad(this.page); + this.$message({ + type: "success", + message: "鎿嶄綔鎴愬姛!" + }); + }); + }, + handleDelete() { + if (this.selectionList.length === 0) { + this.$message.warning("璇烽�夋嫨鑷冲皯涓�鏉℃暟鎹�"); + return; + } + this.$confirm("纭畾灏嗛�夋嫨鏁版嵁鍒犻櫎?", { + confirmButtonText: "纭畾", + cancelButtonText: "鍙栨秷", + type: "warning" + }) + .then(() => { + return remove(this.ids); + }) + .then(() => { + this.onLoad(this.page); + this.$message({ + type: "success", + message: "鎿嶄綔鎴愬姛!" + }); + this.$refs.crud.toggleSelection(); + }); + }, + beforeOpen(done, type) { + if (["edit", "view"].includes(type)) { + getDetail(this.form.id).then(res => { + this.form = res.data.data; + }); + } + done(); + }, + searchReset() { + this.query = {}; + this.onLoad(this.page); + }, + searchChange(params, done) { + this.query = params; + this.onLoad(this.page, params); + done(); + }, + selectionChange(list) { + this.selectionList = list; + }, + selectionModelChange(list) { + this.selectionModelList = list; + }, + selectionClear() { + this.selectionList = []; + this.$refs.crud.toggleSelection(); + }, + currentChange(currentPage) { + this.page.currentPage = currentPage; + }, + sizeChange(pageSize) { + this.page.pageSize = pageSize; + }, + onLoad(page, params = {}) { + this.loading = true; + getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => { + const data = res.data.data; + this.page.total = data.total; + this.data = data.records; + this.loading = false; + this.selectionClear(); + }); + }, + handleModel(row) { + this.fields = []; + this.modelBox = true; + this.loading = true; + this.modelId = row.id; + this.datasourceId = row.datasourceId; + getModelPrototype(this.modelId, this.datasourceId).then(res => { + const result = res.data; + if (result.success) { + this.fields = result.data; + this.fields.forEach(item => { + item.$cellEdit = true; + item.modelId = this.modelId; + // 棣栨鍔犺浇閰嶇疆榛樿鍊� + if (validatenull(item.id)) { + item.isList = 1; + item.isForm = 1; + item.isRow = 0; + item.isRequired = 0; + item.isQuery = 0; + item.componentType = "input"; + } + if (!validatenull(item.name)) { + item.jdbcName = item.name; + item.jdbcType = item.propertyType; + // 鏍规嵁瀛楁鐗╃悊绫诲瀷鑷姩閫傞厤瀹炰綋绫诲瀷 + if (item.propertyType === "LocalDateTime") { + item.propertyType = "Date"; + item.propertyEntity = "java.util.Date"; + } else { + entityDic.forEach(d => { + if (d.label === item.propertyType) { + item.propertyType = d.label; + item.propertyEntity = d.value; + } + }); + } + } + }); + this.loading = false; + } + }); + }, + handleSubmit() { + console.log(this.fields); + this.$confirm("纭畾鎻愪氦妯″瀷閰嶇疆?", { + confirmButtonText: "纭畾", + cancelButtonText: "鍙栨秷", + type: "warning" + }).then(() => { + this.fields.forEach(item => { + entityDic.forEach(d => { + if (d.value === item.propertyEntity) { + item.propertyType = d.label; + } + }); + }); + submitModelPrototype(this.fields).then(res => { + const result = res.data; + if (result.success) { + this.$message.success(result.msg); + this.modelBox = false; + } else { + this.$message.error(result.msg); + } + }) + }); + + } + } +}; +</script> + +<style> +.none-border { + border: 0; + background-color: transparent !important; +} + +.step-div { + margin-top: 30px; +} +</style> -- Gitblit v1.9.3