| | |
| | | :disabled="!checkEditPermission(header)" |
| | | > |
| | | <i class="el-icon-plus"></i> |
| | | <!-- <div slot="tip" class="el-upload__tip">暂未连接服务器,使用默认图片</div> --> |
| | | </el-upload> |
| | | </el-form-item> |
| | | <el-form-item |
| | |
| | | rules: {}, |
| | | photoList: [], |
| | | spectrumList: [], |
| | | defaultImageUrl: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg', // 默认图片地址 |
| | | userOptions: [ |
| | | { value: '1', label: '用户1' }, |
| | | { value: '2', label: '用户2' }, |
| | |
| | | visible: { |
| | | handler(newVal) { |
| | | if (newVal) { |
| | | console.log('弹窗打开,初始化数据'); |
| | | this.showHeaderList = JSON.parse(JSON.stringify(this.headerList)); |
| | | this.$forceUpdate(); |
| | | if (this.isEdit && this.editData) { |
| | |
| | | this.initFormData(); |
| | | } |
| | | this.initRules(); |
| | | console.log('初始化后的表单数据:', this.form); |
| | | console.log('初始化后的校验规则:', this.rules); |
| | | } |
| | | }, |
| | | }, |
| | |
| | | immediate: true, |
| | | handler(newVal) { |
| | | if (newVal && newVal.length) { |
| | | console.log('headerList变化,重新初始化'); |
| | | if (this.isEdit && this.editData) { |
| | | this.setFormData(this.editData); |
| | | } else { |
| | | this.initFormData(); |
| | | } |
| | | this.initRules(); |
| | | } |
| | | }, |
| | | }, |
| | | showHeaderList: { |
| | | immediate: true, |
| | | handler(newVal) { |
| | | if (newVal ) { |
| | | |
| | | console.log("222222222222222222", JSON.stringify(newVal)); |
| | | |
| | | } |
| | | }, |
| | | }, |
| | |
| | | } |
| | | }); |
| | | } |
| | | console.log('生成的校验规则:', rules); |
| | | this.rules = rules; |
| | | }, |
| | | initFormData() { |
| | |
| | | Object.keys(formData).forEach(key => { |
| | | this.$set(this.form, key, formData[key]); |
| | | }); |
| | | |
| | | console.log('初始化后的表单数据:', this.form); |
| | | }, |
| | | setFormData(data) { |
| | | // 设置基础表单数据 |
| | |
| | | this.initFormData(); |
| | | }, |
| | | handleSubmit() { |
| | | console.log('开始提交表单'); |
| | | console.log('表单数据:', this.form); |
| | | console.log('校验规则:', this.rules); |
| | | |
| | | this.$refs.form.validate((valid) => { |
| | | console.log('表单验证结果:', valid); |
| | | if (valid) { |
| | | const submitData = { |
| | | ...this.form, |
| | | photos: this.photoList, |
| | | spectrums: this.spectrumList, |
| | | }; |
| | | console.log('提交数据:', submitData); |
| | | this.$emit("success", submitData); |
| | | this.handleClose(); |
| | | } else { |
| | | console.log('表单验证失败'); |
| | | this.$message.error('请填写必填项'); |
| | | } |
| | | }); |
| | |
| | | this.$refs.form.validateField("photos"); |
| | | }, |
| | | handleSpectrumChange(file, fileList) { |
| | | this.spectrumList = fileList; |
| | | // 使用默认图片替代实际上传 |
| | | this.spectrumList = [{ |
| | | name: '默认图片.jpg', |
| | | url: this.defaultImageUrl, |
| | | status: 'success' |
| | | }]; |
| | | |
| | | // 同时更新form中对应的字段值以通过表单验证 |
| | | const imageHeader = this.headerList.find(h => h.type === 'image'); |
| | | if (imageHeader && imageHeader.name) { |
| | | this.$set(this.form, imageHeader.name, '默认图片'); |
| | | } |
| | | |
| | | this.$refs.form.validateField("spectrums"); |
| | | }, |
| | | handleSpectrumRemove(file) { |
| | | // 处理文件移除逻辑 |
| | | this.spectrumList = []; |
| | | }, |
| | | |
| | | handleIPadSpectrum() { |
| | | // TODO: 调用 iPad 选择图谱功能 |
| | | console.log("调用 iPad 选择图谱功能"); |
| | | }, |
| | | }, |
| | | mounted() { |
| | | console.log("初始headerList:", this.headerList); |
| | | }, |
| | | }; |
| | | </script> |
| | |
| | | .form-content { |
| | | flex: 1; |
| | | overflow-y: auto; |
| | | padding: 0 10px; |
| | | padding: 10px 10px; |
| | | max-height: calc(90vh - 250px); // 设置内容区域最大高度 |
| | | |
| | | &::-webkit-scrollbar { |
| | |
| | | background: #f5f7fa; |
| | | } |
| | | } |
| | | .el-form-item::after{ |
| | | height: 10px !important; |
| | | } |
| | | } |
| | | } |
| | | |