|
@ -14,7 +14,7 @@ |
|
|
</template> |
|
|
</template> |
|
|
<el-form ref="getTableForm" style="margin-top:24px" :inline="true" :model="dbform" label-width="120px"> |
|
|
<el-form ref="getTableForm" style="margin-top:24px" :inline="true" :model="dbform" label-width="120px"> |
|
|
<el-form-item label="数据库名" prop="structName"> |
|
|
<el-form-item label="数据库名" prop="structName"> |
|
|
<el-select v-model="dbform.dbName" filterable placeholder="请选择数据库" @change="getTable"> |
|
|
|
|
|
|
|
|
<el-select v-model="dbform.dbName" filterable placeholder="请选择数据库" @change="getTableFunc"> |
|
|
<el-option |
|
|
<el-option |
|
|
v-for="item in dbOptions" |
|
|
v-for="item in dbOptions" |
|
|
:key="item.database" |
|
|
:key="item.database" |
|
@ -39,7 +39,7 @@ |
|
|
</el-select> |
|
|
</el-select> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
<el-form-item> |
|
|
<el-form-item> |
|
|
<el-button size="mini" type="primary" @click="getColumn">使用此表创建</el-button> |
|
|
|
|
|
|
|
|
<el-button size="mini" type="primary" @click="getColumnFunc">使用此表创建</el-button> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
</el-form> |
|
|
</el-form> |
|
|
</el-collapse-item> |
|
|
</el-collapse-item> |
|
@ -61,7 +61,7 @@ |
|
|
<el-input v-model="form.description" placeholder="中文描述作为自动api描述" /> |
|
|
<el-input v-model="form.description" placeholder="中文描述作为自动api描述" /> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
<el-form-item label="文件名称" prop="packageName"> |
|
|
<el-form-item label="文件名称" prop="packageName"> |
|
|
<el-input v-model="form.packageName" placeholder="生成文件的默认名称(建议为驼峰格式,首字母小写,如sysXxxXxxx)" @blur="toLowerCase(form,'packageName')" /> |
|
|
|
|
|
|
|
|
<el-input v-model="form.packageName" placeholder="生成文件的默认名称(建议为驼峰格式,首字母小写,如sysXxxXxxx)" @blur="toLowerCaseFunc(form,'packageName')" /> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
<el-form-item> |
|
|
<el-form-item> |
|
|
<template #label> |
|
|
<template #label> |
|
@ -138,7 +138,7 @@ |
|
|
</div> |
|
|
</div> |
|
|
<!-- 组件弹窗 --> |
|
|
<!-- 组件弹窗 --> |
|
|
<el-dialog v-model="dialogFlag" title="组件内容"> |
|
|
<el-dialog v-model="dialogFlag" title="组件内容"> |
|
|
<FieldDialog v-if="dialogFlag" ref="fieldDialog" :dialog-middle="dialogMiddle" /> |
|
|
|
|
|
|
|
|
<FieldDialog v-if="dialogFlag" ref="fieldDialogNode" :dialog-middle="dialogMiddle" /> |
|
|
<template #footer> |
|
|
<template #footer> |
|
|
<div class="dialog-footer"> |
|
|
<div class="dialog-footer"> |
|
|
<el-button size="mini" @click="closeDialog">取 消</el-button> |
|
|
<el-button size="mini" @click="closeDialog">取 消</el-button> |
|
@ -155,7 +155,7 @@ |
|
|
<el-button size="mini" type="primary" @click="copy">复制</el-button> |
|
|
<el-button size="mini" type="primary" @click="copy">复制</el-button> |
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
<PreviewCodeDialog v-if="previewFlag" ref="preview" :preview-code="preViewCode" /> |
|
|
|
|
|
|
|
|
<PreviewCodeDialog v-if="previewFlag" ref="previewNode" :preview-code="preViewCode" /> |
|
|
<template #footer> |
|
|
<template #footer> |
|
|
<div class="dialog-footer" style="padding-top:14px;padding-right:14px"> |
|
|
<div class="dialog-footer" style="padding-top:14px;padding-right:14px"> |
|
|
<el-button size="small" type="primary" @click="previewFlag = false">确 定</el-button> |
|
|
<el-button size="small" type="primary" @click="previewFlag = false">确 定</el-button> |
|
@ -165,7 +165,8 @@ |
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
|
|
|
|
<script setup> |
|
|
|
|
|
|
|
|
const fieldTemplate = { |
|
|
const fieldTemplate = { |
|
|
fieldName: '', |
|
|
fieldName: '', |
|
|
fieldDesc: '', |
|
|
fieldDesc: '', |
|
@ -184,26 +185,22 @@ import PreviewCodeDialog from '@/view/systemTools/autoCode/component/previewCode |
|
|
import { toUpperCase, toHump, toSQLLine, toLowerCase } from '@/utils/stringFun' |
|
|
import { toUpperCase, toHump, toSQLLine, toLowerCase } from '@/utils/stringFun' |
|
|
import { createTemp, getDB, getTable, getColumn, preview, getMeta } from '@/api/autoCode' |
|
|
import { createTemp, getDB, getTable, getColumn, preview, getMeta } from '@/api/autoCode' |
|
|
import { getDict } from '@/utils/dictionary' |
|
|
import { getDict } from '@/utils/dictionary' |
|
|
|
|
|
import { ref, getCurrentInstance } from 'vue' |
|
|
|
|
|
import { useRoute } from 'vue-router' |
|
|
|
|
|
import { ElMessage } from 'element-plus' |
|
|
|
|
|
|
|
|
export default { |
|
|
|
|
|
name: 'AutoCode', |
|
|
|
|
|
components: { |
|
|
|
|
|
FieldDialog, |
|
|
|
|
|
PreviewCodeDialog |
|
|
|
|
|
}, |
|
|
|
|
|
data() { |
|
|
|
|
|
return { |
|
|
|
|
|
activeNames: [''], |
|
|
|
|
|
preViewCode: {}, |
|
|
|
|
|
dbform: { |
|
|
|
|
|
|
|
|
const route = useRoute() |
|
|
|
|
|
const activeNames = ref(['']) |
|
|
|
|
|
const preViewCode = ref({}) |
|
|
|
|
|
const dbform = ref({ |
|
|
dbName: '', |
|
|
dbName: '', |
|
|
tableName: '' |
|
|
tableName: '' |
|
|
}, |
|
|
|
|
|
dbOptions: [], |
|
|
|
|
|
tableOptions: [], |
|
|
|
|
|
addFlag: '', |
|
|
|
|
|
fdMap: {}, |
|
|
|
|
|
form: { |
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
const dbOptions = ref([]) |
|
|
|
|
|
const tableOptions = ref([]) |
|
|
|
|
|
const addFlag = ref('') |
|
|
|
|
|
const fdMap = ref({}) |
|
|
|
|
|
const form = ref({ |
|
|
structName: '', |
|
|
structName: '', |
|
|
tableName: '', |
|
|
tableName: '', |
|
|
packageName: '', |
|
|
packageName: '', |
|
@ -212,8 +209,8 @@ export default { |
|
|
autoCreateApiToSql: false, |
|
|
autoCreateApiToSql: false, |
|
|
autoMoveFile: false, |
|
|
autoMoveFile: false, |
|
|
fields: [] |
|
|
fields: [] |
|
|
}, |
|
|
|
|
|
rules: { |
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
const rules = ref({ |
|
|
structName: [ |
|
|
structName: [ |
|
|
{ required: true, message: '请输入结构体名称', trigger: 'blur' } |
|
|
{ required: true, message: '请输入结构体名称', trigger: 'blur' } |
|
|
], |
|
|
], |
|
@ -230,134 +227,128 @@ export default { |
|
|
trigger: 'blur' |
|
|
trigger: 'blur' |
|
|
} |
|
|
} |
|
|
] |
|
|
] |
|
|
}, |
|
|
|
|
|
dialogMiddle: {}, |
|
|
|
|
|
bk: {}, |
|
|
|
|
|
dialogFlag: false, |
|
|
|
|
|
previewFlag: false |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
created() { |
|
|
|
|
|
this.getDb() |
|
|
|
|
|
this.setFdMap() |
|
|
|
|
|
const id = this.$route.params.id |
|
|
|
|
|
if (id) { |
|
|
|
|
|
this.getAutoCodeJson(id) |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
methods: { |
|
|
|
|
|
toLowerCase(form, key) { |
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
const dialogMiddle = ref({}) |
|
|
|
|
|
const bk = ref({}) |
|
|
|
|
|
const dialogFlag = ref(false) |
|
|
|
|
|
const previewFlag = ref(false) |
|
|
|
|
|
|
|
|
|
|
|
const toLowerCaseFunc = (form, key) => { |
|
|
form[key] = toLowerCase(form[key]) |
|
|
form[key] = toLowerCase(form[key]) |
|
|
}, |
|
|
|
|
|
selectText() { |
|
|
|
|
|
this.$refs.preview.selectText() |
|
|
|
|
|
}, |
|
|
|
|
|
copy() { |
|
|
|
|
|
this.$refs.preview.copy() |
|
|
|
|
|
}, |
|
|
|
|
|
editAndAddField(item) { |
|
|
|
|
|
this.dialogFlag = true |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
const previewNode = ref(null) |
|
|
|
|
|
const selectText = () => { |
|
|
|
|
|
previewNode.value.selectText() |
|
|
|
|
|
} |
|
|
|
|
|
const copy = () => { |
|
|
|
|
|
previewNode.value.copy() |
|
|
|
|
|
} |
|
|
|
|
|
const editAndAddField = (item) => { |
|
|
|
|
|
dialogFlag.value = true |
|
|
if (item) { |
|
|
if (item) { |
|
|
this.addFlag = 'edit' |
|
|
|
|
|
this.bk = JSON.parse(JSON.stringify(item)) |
|
|
|
|
|
this.dialogMiddle = item |
|
|
|
|
|
|
|
|
addFlag.value = 'edit' |
|
|
|
|
|
bk.value = JSON.parse(JSON.stringify(item)) |
|
|
|
|
|
dialogMiddle.value = item |
|
|
} else { |
|
|
} else { |
|
|
this.addFlag = 'add' |
|
|
|
|
|
this.dialogMiddle = JSON.parse(JSON.stringify(fieldTemplate)) |
|
|
|
|
|
|
|
|
addFlag.value = 'add' |
|
|
|
|
|
dialogMiddle.value = JSON.parse(JSON.stringify(fieldTemplate)) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
|
|
|
moveUpField(index) { |
|
|
|
|
|
|
|
|
const moveUpField = (index) => { |
|
|
if (index === 0) { |
|
|
if (index === 0) { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
const oldUpField = this.form.fields[index - 1] |
|
|
|
|
|
this.form.fields.splice(index - 1, 1) |
|
|
|
|
|
this.form.fields.splice(index, 0, oldUpField) |
|
|
|
|
|
}, |
|
|
|
|
|
moveDownField(index) { |
|
|
|
|
|
const fCount = this.form.fields.length |
|
|
|
|
|
|
|
|
const oldUpField = form.value.fields[index - 1] |
|
|
|
|
|
form.value.fields.splice(index - 1, 1) |
|
|
|
|
|
form.value.fields.splice(index, 0, oldUpField) |
|
|
|
|
|
} |
|
|
|
|
|
const moveDownField = (index) => { |
|
|
|
|
|
const fCount = form.value.fields.length |
|
|
if (index === fCount - 1) { |
|
|
if (index === fCount - 1) { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
const oldDownField = this.form.fields[index + 1] |
|
|
|
|
|
this.form.fields.splice(index + 1, 1) |
|
|
|
|
|
this.form.fields.splice(index, 0, oldDownField) |
|
|
|
|
|
}, |
|
|
|
|
|
enterDialog() { |
|
|
|
|
|
this.$refs.fieldDialog.$refs.fieldDialogFrom.validate(valid => { |
|
|
|
|
|
|
|
|
const oldDownField = form.value.fields[index + 1] |
|
|
|
|
|
form.value.fields.splice(index + 1, 1) |
|
|
|
|
|
form.value.fields.splice(index, 0, oldDownField) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const currentInstance = getCurrentInstance() |
|
|
|
|
|
const enterDialog = () => { |
|
|
|
|
|
currentInstance.refs.fieldDialogNode.fieldDialogFrom.validate(valid => { |
|
|
if (valid) { |
|
|
if (valid) { |
|
|
this.dialogMiddle.fieldName = toUpperCase( |
|
|
|
|
|
this.dialogMiddle.fieldName |
|
|
|
|
|
|
|
|
dialogMiddle.value.fieldName = toUpperCase( |
|
|
|
|
|
dialogMiddle.value.fieldName |
|
|
) |
|
|
) |
|
|
if (this.addFlag === 'add') { |
|
|
|
|
|
this.form.fields.push(this.dialogMiddle) |
|
|
|
|
|
|
|
|
if (addFlag.value === 'add') { |
|
|
|
|
|
form.value.fields.push(dialogMiddle.value) |
|
|
} |
|
|
} |
|
|
this.dialogFlag = false |
|
|
|
|
|
|
|
|
dialogFlag.value = false |
|
|
} else { |
|
|
} else { |
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
|
|
|
closeDialog() { |
|
|
|
|
|
if (this.addFlag === 'edit') { |
|
|
|
|
|
this.dialogMiddle = this.bk |
|
|
|
|
|
} |
|
|
|
|
|
this.dialogFlag = false |
|
|
|
|
|
}, |
|
|
|
|
|
deleteField(index) { |
|
|
|
|
|
this.form.fields.splice(index, 1) |
|
|
|
|
|
}, |
|
|
|
|
|
async enterForm(isPreview) { |
|
|
|
|
|
if (this.form.fields.length <= 0) { |
|
|
|
|
|
this.$message({ |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
const closeDialog = () => { |
|
|
|
|
|
if (addFlag.value === 'edit') { |
|
|
|
|
|
dialogMiddle.value = bk.value |
|
|
|
|
|
} |
|
|
|
|
|
dialogFlag.value = false |
|
|
|
|
|
} |
|
|
|
|
|
const deleteField = (index) => { |
|
|
|
|
|
form.value.fields.splice(index, 1) |
|
|
|
|
|
} |
|
|
|
|
|
const autoCodeForm = ref(null) |
|
|
|
|
|
const enterForm = async(isPreview) => { |
|
|
|
|
|
if (form.value.fields.length <= 0) { |
|
|
|
|
|
ElMessage({ |
|
|
type: 'error', |
|
|
type: 'error', |
|
|
message: '请填写至少一个field' |
|
|
message: '请填写至少一个field' |
|
|
}) |
|
|
}) |
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
|
if ( |
|
|
if ( |
|
|
this.form.fields.some(item => item.fieldName === this.form.structName) |
|
|
|
|
|
|
|
|
form.value.fields.some(item => item.fieldName === form.value.structName) |
|
|
) { |
|
|
) { |
|
|
this.$message({ |
|
|
|
|
|
|
|
|
ElMessage({ |
|
|
type: 'error', |
|
|
type: 'error', |
|
|
message: '存在与结构体同名的字段' |
|
|
message: '存在与结构体同名的字段' |
|
|
}) |
|
|
}) |
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
|
this.$refs.autoCodeForm.validate(async valid => { |
|
|
|
|
|
|
|
|
autoCodeForm.value.validate(async valid => { |
|
|
if (valid) { |
|
|
if (valid) { |
|
|
for (const key in this.form) { |
|
|
|
|
|
if (typeof this.form[key] === 'string') { |
|
|
|
|
|
this.form[key] = this.form[key].trim() |
|
|
|
|
|
|
|
|
for (const key in form.value) { |
|
|
|
|
|
if (typeof form.value[key] === 'string') { |
|
|
|
|
|
form.value[key] = form.value[key].trim() |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
this.form.structName = toUpperCase(this.form.structName) |
|
|
|
|
|
if (this.form.tableName) { this.form.tableName = this.form.tableName.replace(' ', '') } |
|
|
|
|
|
if (this.form.structName === this.form.abbreviation) { |
|
|
|
|
|
this.$message({ |
|
|
|
|
|
|
|
|
form.value.structName = toUpperCase(form.value.structName) |
|
|
|
|
|
if (form.value.tableName) { form.value.tableName = form.value.tableName.replace(' ', '') } |
|
|
|
|
|
if (form.value.structName === form.value.abbreviation) { |
|
|
|
|
|
ElMessage({ |
|
|
type: 'error', |
|
|
type: 'error', |
|
|
message: 'structName和struct简称不能相同' |
|
|
message: 'structName和struct简称不能相同' |
|
|
}) |
|
|
}) |
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
|
this.form.humpPackageName = toSQLLine(this.form.packageName) |
|
|
|
|
|
|
|
|
form.value.humpPackageName = toSQLLine(form.value.packageName) |
|
|
if (isPreview) { |
|
|
if (isPreview) { |
|
|
const data = await preview(this.form) |
|
|
|
|
|
this.preViewCode = data.data.autoCode |
|
|
|
|
|
this.previewFlag = true |
|
|
|
|
|
|
|
|
const data = await preview(form.value) |
|
|
|
|
|
preViewCode.value = data.data.autoCode |
|
|
|
|
|
previewFlag.value = true |
|
|
} else { |
|
|
} else { |
|
|
const data = await createTemp(this.form) |
|
|
|
|
|
|
|
|
const data = await createTemp(form.value) |
|
|
if (data.headers?.success === 'false') { |
|
|
if (data.headers?.success === 'false') { |
|
|
return |
|
|
return |
|
|
} else { |
|
|
} else { |
|
|
if (this.form.autoMoveFile) { |
|
|
|
|
|
this.$message({ |
|
|
|
|
|
|
|
|
if (form.value.autoMoveFile) { |
|
|
|
|
|
ElMessage({ |
|
|
type: 'success', |
|
|
type: 'success', |
|
|
message: '自动化代码创建成功,自动移动成功' |
|
|
message: '自动化代码创建成功,自动移动成功' |
|
|
}) |
|
|
}) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
this.$message({ |
|
|
|
|
|
|
|
|
ElMessage({ |
|
|
type: 'success', |
|
|
type: 'success', |
|
|
message: '自动化代码创建成功,正在下载' |
|
|
message: '自动化代码创建成功,正在下载' |
|
|
}) |
|
|
}) |
|
@ -384,40 +375,40 @@ export default { |
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
|
|
|
async getDb() { |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
const getDbFunc = async() => { |
|
|
const res = await getDB() |
|
|
const res = await getDB() |
|
|
if (res.code === 0) { |
|
|
if (res.code === 0) { |
|
|
this.dbOptions = res.data.dbs |
|
|
|
|
|
|
|
|
dbOptions.value = res.data.dbs |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
|
|
|
async getTable() { |
|
|
|
|
|
const res = await getTable({ dbName: this.dbform.dbName }) |
|
|
|
|
|
|
|
|
const getTableFunc = async() => { |
|
|
|
|
|
const res = await getTable({ dbName: dbform.value.dbName }) |
|
|
if (res.code === 0) { |
|
|
if (res.code === 0) { |
|
|
this.tableOptions = res.data.tables |
|
|
|
|
|
|
|
|
tableOptions.value = res.data.tables |
|
|
} |
|
|
} |
|
|
this.dbform.tableName = '' |
|
|
|
|
|
}, |
|
|
|
|
|
async getColumn() { |
|
|
|
|
|
|
|
|
dbform.value.tableName = '' |
|
|
|
|
|
} |
|
|
|
|
|
const getColumnFunc = async() => { |
|
|
const gormModelList = ['id', 'created_at', 'updated_at', 'deleted_at'] |
|
|
const gormModelList = ['id', 'created_at', 'updated_at', 'deleted_at'] |
|
|
const res = await getColumn(this.dbform) |
|
|
|
|
|
|
|
|
const res = await getColumn(dbform.value) |
|
|
if (res.code === 0) { |
|
|
if (res.code === 0) { |
|
|
const tbHump = toHump(this.dbform.tableName) |
|
|
|
|
|
this.form.structName = toUpperCase(tbHump) |
|
|
|
|
|
this.form.tableName = this.dbform.tableName |
|
|
|
|
|
this.form.packageName = tbHump |
|
|
|
|
|
this.form.abbreviation = tbHump |
|
|
|
|
|
this.form.description = tbHump + '表' |
|
|
|
|
|
this.form.autoCreateApiToSql = true |
|
|
|
|
|
this.form.fields = [] |
|
|
|
|
|
|
|
|
const tbHump = toHump(dbform.value.tableName) |
|
|
|
|
|
form.value.structName = toUpperCase(tbHump) |
|
|
|
|
|
form.value.tableName = dbform.value.tableName |
|
|
|
|
|
form.value.packageName = tbHump |
|
|
|
|
|
form.value.abbreviation = tbHump |
|
|
|
|
|
form.value.description = tbHump + '表' |
|
|
|
|
|
form.value.autoCreateApiToSql = true |
|
|
|
|
|
form.value.fields = [] |
|
|
res.data.columns && |
|
|
res.data.columns && |
|
|
res.data.columns.forEach(item => { |
|
|
res.data.columns.forEach(item => { |
|
|
if (!gormModelList.some(gormfd => gormfd === item.columnName)) { |
|
|
if (!gormModelList.some(gormfd => gormfd === item.columnName)) { |
|
|
const fbHump = toHump(item.columnName) |
|
|
const fbHump = toHump(item.columnName) |
|
|
this.form.fields.push({ |
|
|
|
|
|
|
|
|
form.value.fields.push({ |
|
|
fieldName: toUpperCase(fbHump), |
|
|
fieldName: toUpperCase(fbHump), |
|
|
fieldDesc: item.columnComment || fbHump + '字段', |
|
|
fieldDesc: item.columnComment || fbHump + '字段', |
|
|
fieldType: this.fdMap[item.dataType], |
|
|
|
|
|
|
|
|
fieldType: fdMap.value[item.dataType], |
|
|
dataType: item.dataType, |
|
|
dataType: item.dataType, |
|
|
fieldJson: fbHump, |
|
|
fieldJson: fbHump, |
|
|
dataTypeLong: item.dataTypeLong && item.dataTypeLong.split(',')[0], |
|
|
dataTypeLong: item.dataTypeLong && item.dataTypeLong.split(',')[0], |
|
@ -429,23 +420,39 @@ export default { |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
}, |
|
|
|
|
|
async setFdMap() { |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
const setFdMap = async() => { |
|
|
const fdTypes = ['string', 'int', 'bool', 'float64', 'time.Time'] |
|
|
const fdTypes = ['string', 'int', 'bool', 'float64', 'time.Time'] |
|
|
fdTypes.forEach(async fdtype => { |
|
|
fdTypes.forEach(async fdtype => { |
|
|
const res = await getDict(fdtype) |
|
|
const res = await getDict(fdtype) |
|
|
res && res.forEach(item => { |
|
|
res && res.forEach(item => { |
|
|
this.fdMap[item.label] = fdtype |
|
|
|
|
|
|
|
|
fdMap.value[item.label] = fdtype |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
|
|
|
async getAutoCodeJson(id) { |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
const getAutoCodeJson = async(id) => { |
|
|
const res = await getMeta({ id: Number(id) }) |
|
|
const res = await getMeta({ id: Number(id) }) |
|
|
if (res.code === 0) { |
|
|
if (res.code === 0) { |
|
|
this.form = JSON.parse(res.data.meta) |
|
|
|
|
|
|
|
|
form.value = JSON.parse(res.data.meta) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const init = () => { |
|
|
|
|
|
getDbFunc() |
|
|
|
|
|
setFdMap() |
|
|
|
|
|
const id = route.params.id |
|
|
|
|
|
if (id) { |
|
|
|
|
|
getAutoCodeJson(id) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
init() |
|
|
|
|
|
|
|
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
|
|
name: 'AutoCode' |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|