Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

主表关联工作流,actfrom会有RangeError: Maximum call stack size exceeded错误,是什么原因呢 #9

Open
sck-star opened this issue Aug 29, 2023 · 7 comments

Comments

@sck-star
Copy link

image

@polarbear567
Copy link
Owner

Hi @sck-star , 能够提供更多细节吗?我没有见过这样的报错,你可以看下生成的文件是否和这个PR(单表)差不多?

@sck-star
Copy link
Author

sck-star commented Aug 30, 2023

</a-tabs>
<a-form-item v-if="!disabled"
               :wrapperCol="{ span: 24 }"
               style="text-align: center"
  >
    <a-button type="primary" :disabled="disabled||btndisabled" @click="handleSubmit">保存</a-button>
    <a-button style="margin-left: 8px" :disabled="disabled" @click="close">取消</a-button>
  </a-form-item>
  <a-form-item v-if="task"
               :wrapperCol="{ span: 24 }"
               style="text-align: center"
  >
    <a-button type="primary"  @click="passTask">通过</a-button>
    <a-button style="margin-left: 8px"  @click="backTask">驳回</a-button>
  </a-form-item>

</a-card>
<script> import pick from 'lodash.pick' import { httpAction, getAction } from '@/api/manage' import { VALIDATE_NO_PASSED, FormTypes,getRefPromise, validateFormAndTables } from '@/utils/JEditableTableUtil' import { JEditableTableMixin } from '@/mixins/JEditableTableMixin' import OneToManyFirstForm from './OneToManyFirstForm.vue' export default { name: 'OneToManyActForm', mixins: [JEditableTableMixin], components: { OneToManyFirstForm, }, data() { return { model: {}, form: this.$form.createForm(this), labelCol: { xs: { span: 24 }, sm: { span: 6 }, }, wrapperCol: { xs: { span: 24 }, sm: { span: 16 }, }, labelCol2: { xs: { span: 24 }, sm: { span: 3 }, }, wrapperCol2: { xs: { span: 24 }, sm: { span: 20 }, }, // 新增时子表默认添加几行空数据 addDefaultRowNum: 1, validatorRules: { }, refKeys: ['oneToManyFirst', ], tableKeys:[], activeKey: 'oneToManyFirst', // 从表 oneToManyFirstTable: { loading: false, dataSource: [], columns: [ ] }, url: { add: "/onemany/oneToMany/add", edit: "/onemany/oneToMany/edit", queryById: "/onemany/oneToMany/queryById", oneToManyFirst: { list: '/onemany/oneToMany/queryOneToManyFirstByMainId' }, getForm:'/actBusiness/getForm', addApply:'/actBusiness/add', editForm:'/actBusiness/editForm', }, /*表单回显数据*/ data:{}, btndisabled: false } }, props: { //表单禁用 disabled: { type: Boolean, default: false, required: false }, processData:{ type:Object, default:()=>{return {}}, required:false }, /*是否新增*/ isNew: {type: Boolean, default: false, required: false}, /*是否处理流程*/ task: {type: Boolean, default: false, required: false} }, created () { if (!this.isNew){ this.init(this.processData); } else { this.show(); } }, methods: { addBefore(){ this.form.resetFields() this.$refs.oneToManyFirstForm.clearFormData() }, handleSubmit (e) { this.handleOk(e); }, close() { //todo 关闭后的回调 this.$emit('close') }, /*通过审批*/ passTask() { this.$emit('passTask') }, /*驳回审批*/ backTask() { this.$emit('backTask') }, getAllTable() { return new Promise(resolve => { resolve([]); }) }, eachAllTable(callback) { // 开始遍历 this.getAllTable().then(tables => { tables.forEach((item, index) => { if (typeof callback === 'function') { callback(item, index) } }) }) }, show() { this.$nextTick(() => { return new Promise((resolve) => { this.tableReset(); resolve(); }).then(() => { // 默认新增空数据 let rowNum = this.addDefaultRowNum if (typeof rowNum !== 'number') { rowNum = 1 console.warn('由于你没有在 data 中定义 addDefaultRowNum 或 addDefaultRowNum 不是数字,所以默认添加一条空数据,如果不想默认添加空数据,请将定义 addDefaultRowNum 为 0') } this.eachAllTable((item) => { item.add(rowNum) }) if (typeof this.addAfter === 'function') this.addAfter(this.model) this.edit({}) }) }) }, edit(record) { if(record && '{}'!=JSON.stringify(record)){ this.tableReset(); } if (typeof this.editBefore === 'function') this.editBefore(record) this.visible = true this.activeKey = this.refKeys[0] this.form.resetFields() this.model = Object.assign({}, record) if (typeof this.editAfter === 'function') this.editAfter(this.model) }, //清空子表table的数据 tableReset(){ this.eachAllTable((item) => { item.clearRow() }) }, /** 查询某个tab的数据 */ requestSubTableData(url, params, tab, success) { tab.loading = true getAction(url, params).then(res => { let { result } = res let dataSource = [] if (result) { if (Array.isArray(result)) { dataSource = result } else if (Array.isArray(result.records)) { dataSource = result.records } } tab.dataSource = dataSource typeof success === 'function' ? success(res) : '' }).finally(() => { tab.loading = false }) }, /** 发起请求,自动判断是执行新增还是修改操作 */ request(formData) { let url = this.url.add, method = 'post' if (this.model.id) { url = this.url.edit method = 'put' } this.confirmLoading = true this.btndisabled = true; httpAction(url, formData, method).then((res) => { if (res.success) { this.$message.success(res.message) this.$emit('ok') this.close() this.$emit('afterSubmit',formData) } else { this.$message.warning(res.message) } }).finally(() => { this.btndisabled = false; this.confirmLoading = false }) }, /** ATab 选项卡切换事件 */ handleChangeTabs(key) { // 自动重置scrollTop状态,防止出现白屏 getRefPromise(this, key).then(editableTable => { editableTable.resetScrollTop() }) }, /** 确定按钮点击事件 */ handleOk(e) { e.preventDefault(); /** 触发表单验证 */ this.getAllTable().then(tables => { /** 一次性验证主表和所有的次表 */ return validateFormAndTables(this.form, tables) }).then(allValues => { if (typeof this.classifyIntoFormData !== 'function') { throw this.throwNotFunction('classifyIntoFormData') } let formData = this.classifyIntoFormData(allValues); // 发起请求 return this.request(formData); }).catch(e => { if (e.error === VALIDATE_NO_PASSED) { // 如果有未通过表单验证的子表,就自动跳转到它所在的tab this.activeKey = e.index == null ? this.activeKey : this.refKeys[e.index] } else { console.error(e) } }) }, /* --- throw --- */ /** not a function */ throwNotFunction(name) { return `${name} 未定义或不是一个函数` }, /** not a array */ throwNotArray(name) { return `${name} 未定义或不是一个数组` }, /** 调用完edit()方法之后会自动调用此方法 */ editAfter() { let fieldval = pick(this.model,'name','actStatus') this.$nextTick(() => { this.form.setFieldsValue(fieldval) this.$refs.oneToManyFirstForm.initFormData(this.url.oneToManyFirst.list,this.model.id) }) // 加载子表数据 if (this.model.id) { let params = { id: this.model.id } } }, /** 整理成formData */ classifyIntoFormData(allValues) { let main = Object.assign(this.model, allValues.formValue) return { ...main, // 展开 oneToManyFirstList: this.$refs.oneToManyFirstForm.getFormData(), } }, validateError(msg){ this.$message.error(msg) }, popupCallback(row){ this.form.setFieldsValue(pick(row,'name','actStatus')) }, init(p) { getAction(this.url.queryById, {id:p.tableId}).then((res)=>{ if(res.success){ this.edit(res.result); } }); }, } } </script> <style scoped> </style>

上面是我用于测试生成的主表表单,跟单表的差不多,就是多了子表tabs和一些import,查了一下,这种错误栈内存超过最大才会出现

Hi @sck-star , 能够提供更多细节吗?我没有见过这样的报错,你可以看下生成的文件是否和这个PR(单表)差不多?

@polarbear567
Copy link
Owner

Hi @sck-star ,这看起来不是一个java错误,所以并没有什么错误信息让我能够定位,你能打包你的项目,然后提供数据库的sql(非敏感信息),然后告诉我点击什么按钮可以触发这个错误吗?

@sck-star
Copy link
Author

sck-star commented Sep 1, 2023

Hi @sck-star ,这看起来不是一个java错误,所以并没有什么错误信息让我能够定位,你能打包你的项目,然后提供数据库的sql(非敏感信息),然后告诉我点击什么按钮可以触发这个错误吗?

打包项目怎么发送给你?

@polarbear567
Copy link
Owner

Hi @sck-star , 你可以在github上上传的你code,或者在这里上传附件,谢谢!

@sck-star
Copy link
Author

sck-star commented Sep 20, 2023

Hi @sck-star , 你可以在github上上传的你code,或者在这里上传附件,谢谢!
只发前端代码可以么?github中上传不超过25MB
ant-design-vue-jeecg.zip

@polarbear567
Copy link
Owner

polarbear567 commented Sep 25, 2023

Hi @sck-star ,没有数据库的数据我跑不起来的。前端如果你没有改,应该没啥问题的,后端有错误吗?你可以上传你的代码的,然后数据库sql文件用附件上传。
然后告知复现的步骤。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants