| | |
| | | <div v-for="(item, idx) in components" :key="item.id" class="dynamic-component"> |
| | | <!-- 富文本 --> |
| | | <div v-if="item.type == 'richText'"> |
| | | <AiEditor :ref="`editor_${item.id}`" :value="item.data.content" height="200px" :readOnly="!editable" placeholder="请输入内容..." |
| | | :disabled="!editable" /> |
| | | <AiEditor :ref="`editor_${item.id}`" :value="item.data.content" height="200px" :readOnly="!editable" |
| | | placeholder="请输入内容..." :disabled="!editable" /> |
| | | </div> |
| | | <!-- 自定义表格 --> |
| | | <div v-else-if="item.type == 'customTable'" style="flex: 1"> |
| | |
| | | <el-button size="mini" @click="showTableHeaderDialog(idx)">添加表头</el-button> |
| | | <el-button size="mini" type="primary" @click="showAddRowDialog(idx, item.data.headers)">添加数据</el-button> |
| | | </div> |
| | | <Table :data="item.data.rows" :total="null" :height="null" class="groupTable" :key="item.id + '_' + JSON.stringify(item.data.rows).length"> |
| | | <Table :data="item.data.rows" :total="null" :height="null" class="groupTable" |
| | | :key="item.id + '_' + JSON.stringify(item.data.rows).length"> |
| | | <el-table-column v-for="(header, hidx) in item.data.headers" :key="hidx" :label="header.name" |
| | | :prop="header.name"> |
| | | <template slot-scope="scope"> |
| | |
| | | </template> |
| | | <!-- 图片类型显示 --> |
| | | <template v-else-if="header.type === 'image'"> |
| | | <img v-if="scope.row[header.name]" |
| | | :src="getFullUrl(scope.row[header.name])" |
| | | alt="头像" |
| | | <img v-if="scope.row[header.name]" :src="getFullUrl(scope.row[header.name])" alt="头像" |
| | | class="table-image" /> |
| | | </template> |
| | | <!-- 其他类型 --> |
| | |
| | | </div> |
| | | <!-- 文件上传 --> |
| | | <div v-else-if="item.type == 'fileUpload'"> |
| | | <el-upload v-if="editable" :http-request="customUploadRequest" :file-list="item.data.fileList" |
| | | <el-upload v-if="editable" :action="uploadUrl" :headers="uploadHeaders" :file-list="item.data.fileList" |
| | | :on-change="(file, fileList) => handleFileChange(idx, fileList)" |
| | | :on-success="(res, file, fileList) => handleFileSuccess(res, file, fileList, idx)" |
| | | list-type="text"> |
| | |
| | | <!-- 图片上传 --> |
| | | <div v-else-if="item.type == 'imageUpload'"> |
| | | <div class="image-upload-container"> |
| | | <el-upload v-if="editable" :http-request="customUploadRequest" :file-list="item.data.imageList" |
| | | <el-upload v-if="editable" |
| | | :action="uploadUrl" |
| | | :headers="uploadHeaders" |
| | | :file-list="item.data.imageList" |
| | | :on-change="(file, fileList) => handleImageChange(idx, fileList)" |
| | | :on-success="(res, file, fileList) => handleImageSuccess(res, file, fileList, idx)" |
| | | :auto-upload="true" |
| | | :on-success="(res, file, fileList) => handleImageSuccess(res, file, fileList, idx)" :auto-upload="true" |
| | | :before-upload="beforeImageUpload" |
| | | list-type="picture-card" |
| | | :on-preview="(file) => handlePreview(file, idx)" |
| | | class="image-uploader"> |
| | | :on-preview="(file) => handlePreview(file, idx)" class="image-uploader"> |
| | | <i class="el-icon-plus"></i> |
| | | <div class="upload-text">上传图片</div> |
| | | </el-upload> |
| | | <div v-else class="image-preview"> |
| | | <el-image v-for="image in item.data.imageList" |
| | | :key="image.uid" |
| | | :src="getFullUrl(image.url)" |
| | | :preview-src-list="item.data.imageList.map(img => getFullUrl(img.url))" |
| | | class="preview-image" /> |
| | | <el-image v-for="image in item.data.imageList" :key="image.uid" :src="getFullUrl(image.url)" |
| | | :preview-src-list="item.data.imageList.map(img => getFullUrl(img.url))" class="preview-image" /> |
| | | </div> |
| | | <div class="uploaf-notice">支持.jpg .png格式</div> |
| | | </div> |
| | |
| | | </div> |
| | | |
| | | |
| | | <addTableHeader :visible.sync="tableHeaderDialog.visible" :participants="participants" |
| | | @confirm="confirmAddHeader"></addTableHeader> |
| | | <addTableData :visible.sync="rowDialog.visible" :headerList="rowDialog.headers" |
| | | :editData="rowDialog.form" :isEdit="rowDialog.isEdit" @success="confirmAddRow"> |
| | | <addTableHeader :visible.sync="tableHeaderDialog.visible" :participants="participants" @confirm="confirmAddHeader"> |
| | | </addTableHeader> |
| | | <addTableData :visible.sync="rowDialog.visible" :headerList="rowDialog.headers" :editData="rowDialog.form" |
| | | :isEdit="rowDialog.isEdit" @success="confirmAddRow"> |
| | | </addTableData> |
| | | |
| | | <el-dialog :visible.sync="imagePreviewVisible" width="auto" top="10vh" :show-close="true" v-if="imagePreviewUrl"> |
| | |
| | | import addTableHeader from "./addTableHeader.vue"; |
| | | import addTableData from "./addTableData.vue"; |
| | | import apiConfig from '../../utils/baseurl' |
| | | import { customUploadRequest, getFullUrl } from '@/utils/utils' |
| | | import { getFullUrl } from '@/utils/utils' |
| | | |
| | | export default { |
| | | name: "DynamicComponent", |
| | |
| | | data() { |
| | | return { |
| | | apiConfig:apiConfig, |
| | | uploadUrl: apiConfig.imgUrl, |
| | | uploadHeaders: { |
| | | Authorization: sessionStorage.getItem('token') || '' |
| | | }, |
| | | showAddDialog: false, |
| | | components: [], |
| | | tableHeaderDialog: { |
| | |
| | | submit() { |
| | | const data = this.components.map(component => { |
| | | let componentData = null; |
| | | const prefix = apiConfig.showImgUrl; |
| | | |
| | | switch (component.type) { |
| | | case 'richText': |
| | |
| | | }; |
| | | break; |
| | | case 'fileUpload': |
| | | componentData = component.data.fileList; |
| | | componentData = component.data.fileList.map(file => { |
| | | if (file.url && file.url.startsWith(prefix)) { |
| | | return { ...file, url: file.url.substring(prefix.length) }; |
| | | } |
| | | return file; |
| | | }); |
| | | break; |
| | | case 'imageUpload': |
| | | componentData = component.data.imageList; |
| | | componentData = component.data.imageList.map(image => { |
| | | if (image.url && image.url.startsWith(prefix)) { |
| | | return { ...image, url: image.url.substring(prefix.length) }; |
| | | } |
| | | return image; |
| | | }); |
| | | break; |
| | | } |
| | | |
| | |
| | | }, |
| | | handleFileSuccess(res, file, fileList, idx) { |
| | | // 上传成功后设置真实 url |
| | | file.url = res.data.url; |
| | | file.url = this.getFullUrl(res.msg); |
| | | this.components[idx].data.fileList = fileList; |
| | | this.emitUpdate(); |
| | | }, |
| | |
| | | }, |
| | | handleImageSuccess(res, file, fileList, idx) { |
| | | // 上传成功后设置真实 url |
| | | file.url = res.data.url; |
| | | file.url = this.getFullUrl(res.msg); |
| | | this.components[idx].data.imageList = fileList; |
| | | this.emitUpdate(); |
| | | }, |
| | |
| | | this.$message.error('上传图片大小不能超过 2MB!'); |
| | | return false; |
| | | } |
| | | this.imagePreviewVisible = true; |
| | | return true; |
| | | }, |
| | | handlePreview(file, idx) { |
| | |
| | | const updatedComponents = JSON.parse(JSON.stringify(this.components)); |
| | | this.$emit('update:dataSource', updatedComponents); |
| | | }, |
| | | getFullUrl, |
| | | }, |
| | | computed: { |
| | | }, |