fix: 无用代码删除及代码优化。
This commit is contained in:
@@ -69,8 +69,6 @@
|
||||
</u--form>
|
||||
<view class="form-btn">
|
||||
<u-button type="primary" text="保存" @click="submitForm"></u-button>
|
||||
<!-- 调试用的测试按钮 -->
|
||||
<u-button type="warning" text="测试保存" @click="testSave" style="margin-top: 20rpx;"></u-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -391,52 +389,6 @@ function doSubmit() {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 测试函数 - 用于验证基本功能
|
||||
function testSave() {
|
||||
console.log('=== 开始测试保存功能 ===')
|
||||
console.log('当前表单状态:', form)
|
||||
console.log('编辑器上下文:', editorCtx.value)
|
||||
console.log('内容长度:', form.noticeContent?.length || 0)
|
||||
|
||||
// 强制获取编辑器内容进行测试
|
||||
if (editorCtx.value) {
|
||||
editorCtx.value.getContents({
|
||||
success: (res) => {
|
||||
console.log('测试获取的内容:', res)
|
||||
console.log('HTML内容:', res.html)
|
||||
console.log('纯文本内容:', res.text)
|
||||
console.log('字符数:', res.text?.length || 0)
|
||||
|
||||
// 尝试直接保存测试数据
|
||||
const testData = {
|
||||
noticeTitle: form.noticeTitle || '测试标题',
|
||||
noticeType: form.noticeType || '1',
|
||||
noticeContent: res.html || '<p>测试内容</p>',
|
||||
status: form.status || '0'
|
||||
}
|
||||
|
||||
console.log('测试数据:', testData)
|
||||
|
||||
// 直接调用API测试
|
||||
addNotice(testData).then(response => {
|
||||
console.log('测试保存成功:', response)
|
||||
modal.msgSuccess('测试保存成功!')
|
||||
}).catch(error => {
|
||||
console.error('测试保存失败:', error)
|
||||
modal.msgError('测试保存失败: ' + error.message)
|
||||
})
|
||||
},
|
||||
fail: (error) => {
|
||||
console.error('测试获取内容失败:', error)
|
||||
modal.msgError('无法获取编辑器内容')
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.log('编辑器未初始化')
|
||||
modal.msgError('编辑器未初始化')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
Reference in New Issue
Block a user