|
@@ -35,11 +35,10 @@
|
|
|
<el-input v-model="q.tableName" placeholder="表名称"/>
|
|
|
</div>
|
|
|
</el-col>
|
|
|
- <el-col :span="6">
|
|
|
+ <el-col :span="12">
|
|
|
<div class="grid-content bg-purple">
|
|
|
<el-button type="primary" icon="el-icon-search" @click="search">搜索</el-button>
|
|
|
- <el-button type="primary" icon="el-icon-setting" @click="setting" @close="dsBox=false">维护
|
|
|
- </el-button>
|
|
|
+ <el-button type="primary" icon="el-icon-download" @click="openBatch">批量生成</el-button>
|
|
|
</div>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
@@ -75,25 +74,18 @@
|
|
|
@submit="gen()"/>
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
-
|
|
|
<el-dialog
|
|
|
- :visible.sync="dsBox"
|
|
|
- :table-loading="tableLoading"
|
|
|
- title="数据源管理"
|
|
|
- width="90%"
|
|
|
- @close="dsBox=false">
|
|
|
- <avue-crud
|
|
|
- ref="data-source-settings-crud"
|
|
|
- v-model="dsForm"
|
|
|
- :page="dsPage"
|
|
|
- :data="tableDsData"
|
|
|
- :option="tableDsOption"
|
|
|
- :before-open="handleOpenBefore"
|
|
|
- @row-update="handleUpdate"
|
|
|
- @row-save="handleSave"
|
|
|
- @row-del="rowDel"
|
|
|
- @refresh-change="refreshDsChange"
|
|
|
- @on-load="getDsList"/>
|
|
|
+ :visible.sync="boxBatch"
|
|
|
+ title="批量生成"
|
|
|
+ width="50%"
|
|
|
+ lock-scroll>
|
|
|
+ <div class="pull-auto">
|
|
|
+ <avue-form
|
|
|
+ ref="formBatchData"
|
|
|
+ :option="formBatchOption"
|
|
|
+ v-model="formBatchData"
|
|
|
+ @submit="batchGen()"/>
|
|
|
+ </div>
|
|
|
</el-dialog>
|
|
|
|
|
|
</basic-container>
|
|
@@ -101,124 +93,87 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { addObj, delObj, fetchDsList, fetchList, fetchSelectDsList, handleDown, putObj } from '@/api/gen/gen'
|
|
|
-import { formOption, tableDsOption, tableOption } from '@/const/crud/gen/gen'
|
|
|
+ import {fetchList, fetchSelectDsList, handleDown} from '@/api/gen/gen'
|
|
|
+ import {formBatchOption, formOption, tableOption} from '@/const/crud/gen/gen'
|
|
|
|
|
|
-export default {
|
|
|
- name: 'CodeGenerator',
|
|
|
- data() {
|
|
|
- return {
|
|
|
- dsBox: false,
|
|
|
- q: {},
|
|
|
- dataSourceList: [],
|
|
|
- tableData: [],
|
|
|
- tableDsData: [],
|
|
|
- formData: {},
|
|
|
- box: false,
|
|
|
- page: {
|
|
|
- total: 0, // 总页数
|
|
|
- currentPage: 1, // 当前页数
|
|
|
- pageSize: 20 // 每页显示多少条
|
|
|
- },
|
|
|
- dsPage: {
|
|
|
- total: 0, // 总页数
|
|
|
- currentPage: 1, // 当前页数
|
|
|
- pageSize: 20 // 每页显示多少条
|
|
|
- },
|
|
|
- dsForm: {},
|
|
|
- tableLoading: false,
|
|
|
- tableOption: tableOption,
|
|
|
- tableDsOption: tableDsOption,
|
|
|
- formOption: formOption
|
|
|
- }
|
|
|
- },
|
|
|
- created() {
|
|
|
- this.getdataSourceList()
|
|
|
- },
|
|
|
- methods: {
|
|
|
- getList(page) {
|
|
|
- this.tableLoading = true
|
|
|
- fetchList(Object.assign({
|
|
|
- current: page.currentPage,
|
|
|
- size: page.pageSize
|
|
|
- }, this.q)).then(response => {
|
|
|
- this.tableData = response.data.data.records
|
|
|
- this.page.total = response.data.data.total
|
|
|
- this.tableLoading = false
|
|
|
- })
|
|
|
- },
|
|
|
- rowDel: function(row, index) {
|
|
|
- this.$confirm('是否确认删除ID为' + row.id, '提示', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning'
|
|
|
- }).then(function() {
|
|
|
- return delObj(row.id)
|
|
|
- }).then(() => {
|
|
|
- this.tableData.splice(index, 1)
|
|
|
- this.$message.success('删除成功')
|
|
|
- this.getDsList(this.page)
|
|
|
- }).catch(function() {
|
|
|
- })
|
|
|
- },
|
|
|
- handleOpenBefore: function(show) {
|
|
|
- this.dsForm.password = undefined
|
|
|
- show()
|
|
|
- },
|
|
|
- handleUpdate: function(row, index, done) {
|
|
|
- putObj(row).then(() => {
|
|
|
- this.tableData.splice(index, 1, Object.assign({}, row))
|
|
|
- this.$message.success('修改成功')
|
|
|
- done()
|
|
|
- this.getDsList(this.page)
|
|
|
- })
|
|
|
- },
|
|
|
- handleSave: function(row, done) {
|
|
|
- addObj(row).then(() => {
|
|
|
- this.tableData.push(Object.assign({}, row))
|
|
|
- this.$message.success('添加成功')
|
|
|
- done()
|
|
|
- this.getDsList(this.page)
|
|
|
- })
|
|
|
+ export default {
|
|
|
+ name: 'CodeGenerator',
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ q: {},
|
|
|
+ dataSourceList: [],
|
|
|
+ tableData: [],
|
|
|
+ formData: {},
|
|
|
+ formBatchData: {},
|
|
|
+ box: false,
|
|
|
+ boxBatch: false,
|
|
|
+ page: {
|
|
|
+ total: 0, // 总页数
|
|
|
+ currentPage: 1, // 当前页数
|
|
|
+ pageSize: 20 // 每页显示多少条
|
|
|
+ },
|
|
|
+ tableLoading: false,
|
|
|
+ tableOption: tableOption,
|
|
|
+ formOption: formOption,
|
|
|
+ formBatchOption: formBatchOption
|
|
|
+ }
|
|
|
},
|
|
|
- getDsList(page, params) {
|
|
|
- fetchDsList(Object.assign({
|
|
|
- current: page.currentPage,
|
|
|
- size: page.pageSize
|
|
|
- }, params)).then(response => {
|
|
|
- this.tableDsData = response.data.data.records
|
|
|
- this.dsPage.total = response.data.data.total
|
|
|
- })
|
|
|
+ created() {
|
|
|
+ this.getdataSourceList()
|
|
|
},
|
|
|
- handleDown: function(row) {
|
|
|
- this.formData.tableName = row.tableName
|
|
|
- this.box = true
|
|
|
- },
|
|
|
- refreshChange() {
|
|
|
- this.getList(this.page)
|
|
|
- },
|
|
|
- refreshDsChange() {
|
|
|
- this.getDsList(this.page)
|
|
|
- },
|
|
|
- gen() {
|
|
|
- this.formData.id = this.q.id
|
|
|
- handleDown(this.formData).then(() => {
|
|
|
+ methods: {
|
|
|
+ getList(page) {
|
|
|
+ this.tableLoading = true
|
|
|
+ fetchList(Object.assign({
|
|
|
+ current: page.currentPage,
|
|
|
+ size: page.pageSize
|
|
|
+ }, this.q)).then(response => {
|
|
|
+ this.tableData = response.data.data.records
|
|
|
+ this.page.total = response.data.data.total
|
|
|
+ this.tableLoading = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handleDown: function (row) {
|
|
|
+ this.formData.tableName = row.tableName
|
|
|
this.box = true
|
|
|
- })
|
|
|
- },
|
|
|
- setting() {
|
|
|
- this.dsBox = true
|
|
|
- },
|
|
|
- search() {
|
|
|
- this.getList(this.page)
|
|
|
- },
|
|
|
- getdataSourceList() {
|
|
|
- fetchSelectDsList().then(response => {
|
|
|
- this.dataSourceList = response.data.data
|
|
|
- })
|
|
|
+ },
|
|
|
+ refreshChange() {
|
|
|
+ this.getList(this.page)
|
|
|
+ },
|
|
|
+ gen() {
|
|
|
+ this.formData.id = this.q.id
|
|
|
+ handleDown(this.formData).then(() => {
|
|
|
+ this.box = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getdataSourceList() {
|
|
|
+ fetchSelectDsList().then(response => {
|
|
|
+ this.dataSourceList = response.data.data
|
|
|
+ })
|
|
|
+ },
|
|
|
+ search() {
|
|
|
+ this.getList(this.page)
|
|
|
+ },
|
|
|
+ openBatch() {
|
|
|
+ if (this.$refs.crud.tableSelect.length <= 1 || this.$refs.crud.tableSelect.length > 10) {
|
|
|
+ this.$message.error('选中表数量不合法,数量最多10个')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ let tableName = []
|
|
|
+ for (const table of this.$refs.crud.tableSelect) {
|
|
|
+ tableName.push(table.tableName)
|
|
|
+ }
|
|
|
+ this.formBatchData.tableName = tableName.join('-')
|
|
|
+ this.boxBatch = true
|
|
|
+ },
|
|
|
+ batchGen() {
|
|
|
+ this.formBatchData.id = this.q.id
|
|
|
+ handleDown(this.formBatchData).then(() => {
|
|
|
+ this.boxBatch = false
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|