xyc
2025-02-21 664db98c9e8595ce4dd636a27f480e3a08b81ff5
web/src/views/modules/sysPictureBase/SysPictureBase-AddOrUpdate.vue
@@ -5,7 +5,7 @@
        <el-input v-model="dataForm.name"></el-input>
      </zt-form-item>
      <zt-form-item label="产品类型" prop="productType" rules="required">
        <zt-dict v-model="dataForm.productType" dict="product"></zt-dict>
        <zt-dict v-model="dataForm.productType" dict="product" :additional=additional></zt-dict>
      </zt-form-item>
      <zt-form-item label="是否默认" prop="isDefault" rules="required">
        <zt-dict v-model="dataForm.isDefault" dict="is_or_not"></zt-dict>
@@ -13,15 +13,18 @@
      <zt-form-item label="检索关键字" prop="contentType">
        <el-input v-model="dataForm.contentType"></el-input>
      </zt-form-item>
      <zt-form-item label="备注" prop="remark">
        <el-input v-model="dataForm.remark"></el-input>
      </zt-form-item>
      <input type="hidden" id="svgContentId" :value="dataForm.svgContent"/>
              <zt-form-item>
<!--                <el-upload action="*" :on-change="uploadSvgContent">-->
<!--                  <el-button slot="trigger" size="small" type="primary">选取文件</el-button>-->
<!--                </el-upload>-->
                <label class="custom-file-upload">
                <input type="file" @change="uploadSvgContent" />
                </label>
              </zt-form-item>
      <zt-form-item>
        <!--                <el-upload action="*" :on-change="uploadSvgContent">-->
        <!--                  <el-button slot="trigger" size="small" type="primary">选取文件</el-button>-->
        <!--                </el-upload>-->
        <label class="custom-file-upload">
          <input type="file" @change="uploadSvgContent"/>
        </label>
      </zt-form-item>
    </el-form>
    <iframe :src='SVGEditorUrl' ref="myIframe" width="100%" id="iframe"
            style="height:calc(100vh - 300px)">
@@ -36,6 +39,7 @@
  export default {
    data() {
      return {
        additional: [{dictValue: '20', dictLabel: '运算图元', remark: ''}],
        SVGEditorUrl: `/SVGOrigin/Method-Draw-master/editor/index.html`,
        url: `${window.SITE_CONFIG['apiURL']}/sysPictureBase/getProductImg?token=${Cookies.get('token')}&id=`,
        fileList: [],
@@ -55,14 +59,14 @@
      }
    },
    methods: {
      async init() {
        if (this.dataForm.id) {
          let res = await this.$http.get(`/sysPictureBase/${this.dataForm.id}`)
      async init(id,row) {
        if (id) {
          //let res = await this.$http.get(`/sysPictureBase/${this.dataForm.id}`)
          this.dataForm = {
            ...this.dataForm,
            ...res.data
            ...row
          }
          console.log(this.dataForm,'this.dataForm this.dataForm')
          console.log(this.dataForm, 'this.dataForm this.dataForm')
        }
      },
      httpRequest(option) {
@@ -100,10 +104,10 @@
      async formSubmit() {
        const iframeWindow = this.$refs.myIframe.contentWindow;
        this.dataForm.svgContent = iframeWindow.getSVGContentTest()
        console.log(this.dataForm.svgContent+'this.dataForm.svgContent')
        console.log(this.dataForm.svgContent + 'this.dataForm.svgContent')
        this.$http.post('/sysPictureBase/save', this.dataForm).then(res => {
          if (res.success) {
            console.log(this.dataForm,'this.dataForm')
            console.log(this.dataForm, 'this.dataForm')
            this.$tip.success()
            this.$refs.dialog.close()
            this.$emit('refreshDataList')
@@ -114,9 +118,9 @@
      async uploadSvgContent(event) {
        const iframeWindow = this.$refs.myIframe.contentWindow
        const file = event.target.files[0];
        console.log(file,'file file')
        console.log(file, 'file file')
        // 可以在这里进行进一步的文件处理,比如读取文件内容等操作
        if (file && file.type==='image/svg+xml') {
        if (file && file.type === 'image/svg+xml') {
          const reader = new FileReader();
          reader.onload = (e) => {
            const fileContent = e.target.result;
@@ -124,7 +128,7 @@
            iframeWindow.setSvgContent(fileContent)
          }
          reader.readAsText(file); // 以文本形式读取文件内容
        }else {
        } else {
          this.$message({message: '请选择SVG图片', type: 'warning'})
          return false; // 取消操作
        }
@@ -148,6 +152,7 @@
    cursor: pointer;
    background-color: #f9f9f9;
  }
  .img-sc > .el-form-item > .el-form-item__content {
    width: 100%;
  }