AddColumn.vue 30.6 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042
<template>
  <div class="add-column-page">
    <el-header class="add-column-header" height="48px">
      <div class="column-header-content">
        <div class="column-header-left">
          <el-page-header @back="goBack" :content="currentShowTitle">
          </el-page-header>
        </div>
        <div class="column-header-right">
          <el-button
            v-if="!(columnTenantId != -1 && baseColumn.isInit == 1)"
            type="primary"
            v-preventReClick
            @click="handleSavaForm"
            >保存</el-button
          >
          <el-button @click="handleClose">关闭</el-button>
        </div>
      </div>
    </el-header>
    <div class="add-column-content">
      <div class="column-content-left">
        <ht-custom-title
          title="栏目基本信息"
          left-bar-top="2px"
          title-height="68px"
          :isShowBottomBorder="false"
          :is-show-button="false"
        />
        <add-column-form
          :column="baseColumn"
          :designColumn="designColumn"
          :operateType="operateType"
          @height-type-change="handleHeightTypeChange"
          @public-type-change="handlePublicTypeChange"
        ></add-column-form>
        <ht-custom-title
          left-bar-top="2px"
          title-height="68px"
          title="栏目设计"
          :isShowBottomBorder="false"
          :is-show-button="false"
        />
        <design-column
          v-if="isShowDesignColumn"
          :designColumn="designColumn"
          :myApplicationOptionsList="myApplicationOptionsList"
          :column="baseColumn"
          :isPublic="baseColumn.isPublic"
          @click-type="handleClickType"
          @process-change="getCurrentShowData"
          @submit-column="getCurrentShowData"
          @custom-change="getCustomShowData"
          ref="designColumn"
        ></design-column>
      </div>
      <div class="column-content-right">
        <ht-custom-title
          title="栏目实时预览"
          left-bar-top="2px"
          title-height="68px"
          :isShowBottomBorder="false"
          :is-show-button="false"
        />
        <template v-if="currentComponentsComPuted">
          <template v-if="baseColumn.isPublic == 1">
            <div class="mobile-design-wrapper" style="pointer-events: none">
              <div class="mobile-design">
                <div class="mobile-design--box">
                  <div class="mobile-design__header">
                    <img :src="mobileHeaderImg" class="mobile-design__img" />
                  </div>

                  <div class="content-wrapper">
                    <component
                      :is="currentComponents"
                      :showData="showData"
                      :column-title="baseColumn.name || defaultTitle"
                      :ref="designColumn.colType"
                      :isHidePagination="isHidePagination"
                      :showTitle="baseColumn.showTitle"
                      :custom-column-height="baseColumn.colHeight"
                      :pageSize="baseColumn.refeshTime"
                      :combination-model="designColumn.model"
                      :operateType="operateType"
                      :more-url="baseColumn.colUrl"
                      :filter-type="designColumn.filterType"
                      :filter-scope="designColumn.filterScope"
                      :alias="baseColumn.alias"
                      :current-user="currentUser"
                      :appid="baseColumn.appid"
                      :custom-style="customStyle"
                      :isManage="true"
                      :isDisabled="true"
                      :isPublic="baseColumn.isPublic"
                    ></component>
                  </div>
                </div>
              </div>
            </div>
          </template>
          <template v-else>
            <p style="color: #666; margin: 24px 0 10px; font-size: 14px">
              提示:实时预览仅做栏目效果展示,不能进行点击操作
            </p>
            <el-card
              class="box-card"
              :class="{
                'column-height':
                  designColumn.colType !== 'swipeSlide' && baseColumn.colHeight
              }"
              :style="{'--columnHeight': `${baseColumn.colHeight}px`}"
              style="pointer-events: none"
            >
              <component
                :is="currentComponents"
                :showData="showData"
                :column-title="baseColumn.name || defaultTitle"
                :ref="designColumn.colType"
                :isHidePagination="isHidePagination"
                :showTitle="baseColumn.showTitle"
                :custom-column-height="baseColumn.colHeight"
                :pageSize="baseColumn.refeshTime"
                :combination-model="designColumn.model"
                :operateType="operateType"
                :more-url="baseColumn.colUrl"
                :filter-type="designColumn.filterType"
                :filter-scope="designColumn.filterScope"
                :alias="baseColumn.alias"
                :current-user="currentUser"
                :appid="baseColumn.appid"
                :custom-style="customStyle"
                :isManage="true"
                :isDisabled="true"
                :isPublic="baseColumn.isPublic"
                :preRequest="false"
              ></component>
            </el-card>
          </template>
        </template>
        <el-empty
          v-else
          :image-size="380"
          :image="noDataImg"
          description="暂无实时预览哦~"
        >
        </el-empty>
      </div>
    </div>
  </div>
</template>
<script>
import portal from '@/api/portal.js'
import flow from '@/api/flow.js'
import {COLUMN_TYPE_LIST} from './const.js'
import html2canvas from 'html2canvas'
import req from '@/request.js'
import columnMixins from '@/views/portal/components/columnMixins.js'
let Base64 = require('js-base64').Base64
export default {
  name: 'AddColumn',
  components: {
    AddColumnForm: () => import('./components/AddColumnForm.vue'),
    DesignColumn: () => import('./components/DesignColumn.vue')
  },
  props: {
    type: {
      type: String,
      default: ''
    },
    id: {
      type: String,
      default: ''
    }
  },
  mixins: [columnMixins],
  data() {
    return {
      currentUser: JSON.parse(sessionStorage.getItem('currentUser')) || {},
      baseColumn: {
        appid: '',
        secret: '',
        name: '',
        alias: '',
        catalogName: '',
        showTitle: true,
        isPublic: 2, //使用平台0-管理端,1-手机端,2-应用端
        isInit: 0, //数据类型 0-私有数据 1-平台公用数据
        needPage: 0, //是否分页
        colHeight: '',
        refeshTime: 0, //每页数量
        colUrl: '', //更多路径
        memo: '', //栏目用途
        style: '' //数据列表栏目自定义样式
      },
      designColumn: {
        colType: '',
        processPublicity: [],
        myApplication: [],
        announcementOrPictures: null,
        filterType: 'all',
        filterScope: [],
        selectType: [],
        pullFrequency: 'everyDay',
        dataFrom: '',
        model: 'upDown',
        colHeightType: 'default',
        timeType: 'day',
        date: '',
        currentDataType: 'dataChart'
      },
      templateHtml: '',
      templateJavaScript: '',
      templateStyle: '',
      defaultTitle: '', //栏目默认显示标题
      showData: null,
      currentComponents: '',
      noDataImg: require('@/assets/nodata_images/no-data.png'),
      initialData: null,
      uploadUrl: window.context.portal + '/system/file/v1/thumbnailUpload',
      isShowDesignColumn: true,
      timer: null,
      myApplicationOptionsList: []
    }
  },
  computed: {
    isHidePagination() {
      return this.baseColumn.needPage == '1' ? false : true     
    },
    operateType() {
      return this.type || this.$route.query.type
    },
    currentShowTitle() {
      return this.operateType === 'add' ? '新增栏目' : '编辑栏目'
    },
    customStyle() {
      return this.baseColumn.style && this.designColumn.colType === 'dataSheets'
        ? Base64.encode(this.baseColumn.style)
        : this.baseColumn.templateStyle &&
          this.designColumn.colType === 'custom'
        ? Base64.encode(this.designColumn.templateStyle2)
        : ''
    },
    mobileHeaderImg() {
      return require('@/assets/img/mobile-design-banner.png')
    },
    currentComponentsComPuted() {
      if (
        this.baseColumn.isPublic == 1 &&
        ![
          'HtSchedule',
          'HtMyApplication',
          'HtPersonalMatters',
          'HtMeetingRoom'
        ].includes(this.currentComponents)
      ) {
        return true
      }
      if (
        this.baseColumn.isPublic == 2 ||
        (this.baseColumn.isPublic == 0 &&
          !['HtMyApplication'].includes(this.currentComponents))
      ) {
        return true
      }
      return false
    }
  },
  watch: {
    customStyle: {
      handler(val) {},
      immediate: true,
      deep: true
    },
    'designColumn.colType': {
      handler(val) {
       if (val === 'myApplication') {
        this.queryByFilter()
       }
      },
      immediate: true
    },
  },
  created() {
    if (this.operateType === 'edit') {
      this.getColumnData()
      this.isShowDesignColumn = false
    } else {
      this.isShowDesignColumn = true
    }
  },
  beforeDestroy() {
    if (this.timer) {
      clearTimeout(this.timer)
    }
  },
  mounted() {
    this.initialData = _.cloneDeep({...this.baseColumn, ...this.designColumn})
    if (this.columnTenantId != -1) {
      //如果是租户,数据类型是 0-私有数据
      this.baseColumn.isInit = 0
    }
    if (this.operateType === 'edit') {
      this.timer = setTimeout(() => {
        this.isShowDesignColumn = true
      }, 5000)
    }
    
  },
  methods: {
    goBack() {
      this.handleClose()
    },
    handleClose() {
      const initialDataJson = JSON.stringify(this.initialData)
      const newData = JSON.stringify({...this.baseColumn, ...this.designColumn})
      if (initialDataJson == newData) {
        // this.$router.push('/portal')
        this.$emit('close')
      } else {
        this.$confirm('系统将不会保存您所做的更改,是否要离开此页面?', '提示', {
          confirmButtonText: '取消',
          cancelButtonText: '确定',
          customClass: 'col-msg__box',
          type: 'warning',
          closeOnClickModal: false
        })
          .then(() => {})
          .catch(() => {
            // this.$router.push('/portal')
            this.$emit('close')
          })
      }
    },

    //获取常用应用
    async queryByFilter() {
      let query = {
        pageBean: {
          page: 1,
          pageSize: -1,
          total: 0
        },
        params: {
          isManage: true,
          menuId: null
        }
      }
      await portal.queryByFilter(query).then(res => {
        if (res && res.status == 200) {
          let data = res.data ? res.data.rows : res.rows

          this.myApplicationOptionsList = data
          this.showData = []
          if (
            this.designColumn.myApplication &&
            this.designColumn.myApplication.length > 0
          ) {
            data.forEach(item => {
              if (this.designColumn.myApplication.includes(item.alias)) {
                this.showData.push(item)
              }
            })
          }
        }
      })
    },
    getColumnData() {
      const id = this.id || this.$route.query.id
      portal.getColumnById(id).then(({data}) => {
        this.baseColumn = {
          ...data,
          showTitle: data.showTitle == 1 ? true : false
        }
        this.designColumn = JSON.parse(data.dataParam)
        this.currentComponents = data.colType
        const {colType, selectType} = this.designColumn
        if (
          ['processCenter', 'combination', 'processPublicity'].includes(colType)
        ) {
          this.showData = selectType
        }
        if (this.designColumn.colType === 'statisticalChart') {
          let data = []
          data.push({
            dataType: this.designColumn.dataType,
            currentDataType: this.designColumn.currentDataType
          })
          this.showData = data
        }
        if (
          this.designColumn.colType === 'news' ||
          this.designColumn.colType === 'swipeSlide'
        ) {
          this.showData = this.designColumn.announcementOrPictures
        }
        if (this.designColumn.colType === 'custom') {
          this.designColumn.templateHtml2 = Base64.decode(data.templateHtml)
          this.designColumn.templateJavaScript2 = Base64.decode(
            data.templateJavaScript
          )
          if (Base64.decode(data.templateStyle) != 'undefined') {
            this.designColumn.templateStyle2 = Base64.decode(data.templateStyle)
          }
          this.showData = data
        }
        if (this.designColumn.colType === 'dataSheets') {
          this.showData = {
            ...this.designColumn.currentSelectedInfo,
            dataType: this.designColumn.dataType
          }
          this.baseColumn.style = data.style ? Base64.decode(data.style) : ''
        }
        if (this.designColumn.colType === 'officialAccounts') {
          this.showData = [JSON.parse(data.dataParam)]
        }
        if (this.designColumn.colType === 'myApplication') {
          this.queryByFilter()
        }
        this.isShowDesignColumn = true
      })
    },
    handleClickType(item) {
      this.defaultTitle = item.name
      if (this.designColumn.colHeightType === 'default') {
        this.baseColumn.colHeight = item.defaultColHeight
      }
      if (this.currentComponents !== item.componentsName) {
        this.designColumn.selectType = []
        this.designColumn.processPublicity = []
        this.designColumn.announcementOrPictures = null
        this.showData = []
        // this.baseColumn.needPage = 1
        if (this.baseColumn.isPublic == 1) {
          this.baseColumn.refeshTime = 5
        } else {
          this.baseColumn.refeshTime = 10
        }
        this.designColumn.model = 'upDown'
        this.designColumn.templateHtml2 = ''
        this.designColumn.templateJavaScript2 = ''
        this.designColumn.templateStyle2 = ''
        this.designColumn.currentDataType = ''
        this.$set(this.designColumn, 'dataType', '')
        this.baseColumn.style = ''
      }
      if (item.key === 'swipeSlide') {
        this.baseColumn.colUrl = ''
      } else if (item.key === 'dataSheets') {
        this.designColumn.currentDataType = 'formTable'
      } else if (item.key === 'statisticalChart') {
        this.designColumn.currentDataType = 'dataChart'
      }
      this.currentComponents = item.componentsName
    },
    handleHeightTypeChange(val) {
      if (val === 'custom') {
        this.baseColumn.colHeight = 0
      } else if (val === 'default' && this.designColumn.colType) {
        const defaultHeightMap = COLUMN_TYPE_LIST.reduce((pre, cur) => {
          pre[cur.key] = cur.defaultColHeight
          return pre
        }, {})
        this.baseColumn.colHeight = defaultHeightMap[this.designColumn.colType]
      }
    },
    handlePublicTypeChange(val) {
      if (this.designColumn.colType === 'combination') {
        this.designColumn.selectType = []
        this.getCurrentShowData(
          this.designColumn.selectType,
          this.designColumn.colType
        )
      }
    },
    getCurrentShowData(data, columnType) {
      if (columnType === 'combination') {
        data.forEach(item => {
          if (
            Object.prototype.toString.call(item.dataParam) == '[object Object]'
          ) {
            item.dataParam = JSON.stringify(item.dataParam)
          }
          if (item.colType === 'HtProcessCenter') {
            item.dataParam = JSON.parse(item.dataParam).selectType
          } else if (item.colType === 'HtCustom') {
            item.dataParam = JSON.parse(item.dataParam)
            delete item.dataParam.templateHtml
            delete item.dataParam.templateJavaScript
            delete item.templateHtml
            delete item.dataParam.templateStyle
          } else {
            if (item && item.dataParam) {
              item.dataParam = JSON.parse(item.dataParam)
            }
          }
        })
        this.showData = data
      } else {
        this.showData = data
      }
    },
    getCustomShowData(data, columnType) {
      this.baseColumn.templateStyle = Base64.encode(
        this.designColumn.templateStyle2
      )
      this.designColumn.colType = data.colType
      this.showData = {
        ...data,
        ...this.baseColumn,
        addCustom: 'add',
        templateHtml: Base64.encode(this.designColumn.templateHtml2),
        templateStyle: Base64.encode(this.designColumn.templateStyle2),
        templateJavaScript: Base64.encode(
          this.designColumn.templateJavaScript2
            ? this.designColumn.templateJavaScript2
            : '{}'
        )
      }
    },
    //流程公式组件获取已选流程
    getSelectProcess() {
      let result = []
      const {processOptions, processPublicity, colType} = this.designColumn
      if (
        processOptions &&
        processOptions.length > 0 &&
        processPublicity &&
        processPublicity.length > 0
      ) {
        result = processOptions.filter(item =>
          processPublicity.includes(item.defKey)
        )
      }
      if (colType === 'processPublicity') {
        this.$set(this.designColumn, 'selectType', result)
        delete this.designColumn.processOptions
      }
    },
    handleSavaForm() {
      this.$root.$validator.validateAll('columnForm').then(async result => {
        if (!this.designColumn.colType) {
          return this.$message.warning('请选择栏目类型')
        }

        let limit = this.baseColumn.isPublic == 1 ? 10 : 20
        if (this.baseColumn.refeshTime > limit) {
          this.$set(this.baseColumn, 'refeshTime', null)
          return this.$message.warning(`数据显示量不能大于${limit}条`)
        }
        await this.handleSnapshot()
        if (this.designColumn.colType === 'officialAccounts') {
          if (!this.baseColumn.appid)
            return this.$message.warning('请输入corpId')
          if (!this.baseColumn.secret)
            return this.$message.warning('请输入corpSecret')
        }
        if (result && this.$refs.designColumn.validateDesignColumnForm()) {
          if (this.designColumn.colType === 'custom') {
            if (!this.designColumn.templateHtml2) {
              return this.$message.warning('请输入自定义模版内容')
            }
            this.templateHtml = Base64.encode(this.designColumn.templateHtml2)
            this.templateJavaScript = Base64.encode(
              this.designColumn.templateJavaScript2
                ? this.designColumn.templateJavaScript2
                : '{}'
            )
            this.templateStyle = Base64.encode(this.designColumn.templateStyle2)
            delete this.designColumn.templateHtml2
            delete this.designColumn.templateStyle2
            delete this.designColumn.templateJavaScript2
          }
          const {colType, filterType} = this.designColumn
          this.getSelectProcess()
          if (
            colType === 'processCenter' &&
            filterType === 'processDefinition'
          ) {
            delete this.designColumn.processOptions
          }
          //去除我的应用icon
          delete this.designColumn.myApplicationOptionsList
        
          let dataParam = this.designColumn
          if (this.designColumn.colType === 'dataSheets') {
            dataParam = {
              ...this.designColumn,
              currentSelectedInfo: this.showData
            }
          }
          //置空外部更多路径
          if (this.designColumn.model == 'tab') {
            this.baseColumn.colUrl = ''
          }
          const submitData = {
            ...this.baseColumn,
            style: this.baseColumn.style
              ? Base64.encode(this.baseColumn.style)
              : '',
            templateHtml: this.templateHtml,
            templateJavaScript: this.templateJavaScript,
            templateStyle: this.templateStyle,
            showTitle: this.baseColumn.showTitle ? 1 : 0,
            dataParam: JSON.stringify(dataParam),
            colType: `Ht${colType.replace(/^\S/, s => s.toUpperCase())}`,
            dataFrom: this.designColumn.dataFrom || '',
            dataMode: this.designColumn.dataMode || ''
          }

          portal.savaColumns(submitData).then(({data}) => {
            if (data.state) {
              this.$message.success(data.message)
              // this.$router.go(-1)
              this.$emit('close')
              this.$emit('after-save')
            } else {
              this.$message.error(data.message)
            }
          })
        }
      })
    },
    savePic() {
      var getPixelRatio = function(context) {
        // 获取设备的PixelRatio
        var backingStore =
          context.backingStorePixelRatio ||
          context.webkitBackingStorePixelRatio ||
          context.mozBackingStorePixelRatio ||
          context.msBackingStorePixelRatio ||
          context.oBackingStorePixelRatio ||
          context.backingStorePixelRatio ||
          1
        return (window.devicePixelRatio || 1) / backingStore
      }
      var captureContent = this.$refs[this.designColumn.colType].$el
      var width = captureContent.offsetWidth
      var height = captureContent.offsetHeight
      var canvas = document.createElement('canvas')
      var context = canvas.getContext('2d')
      var scale = getPixelRatio(context)
      canvas.width = width * scale
      canvas.height = height * scale
      canvas.style.width = width + 'px'
      canvas.style.height = height + 'px'
      context.scale(scale, scale)

      var opts = {
        // useCORSOnly: true,
        useCORS: true, // 允许使用 CORS 跨域
        allowTaint: true, // 允许默认跨域
        scale: scale,
        canvas: canvas,
        width: width,
        height: height,
        dpi: window.devicePixelRatio
      }
      return {content: captureContent, opts: opts}
    },
    handleSnapshot() {
      //处理快照
      return new Promise((resolve, reject) => {
        let captureData = this.savePic()
        const oldFileId = this.baseColumn.snapshotId
        let _this = this
        html2canvas(captureData.content, captureData.opts).then(function(
          canvas
        ) {
          context.mozImageSmoothingEnabled = false
          context.webkitImageSmoothingEnabled = false
          context.msImageSmoothingEnabled = false
          context.imageSmoothingEnabled = false
          canvas.toBlob(function(filedata) {
            var formdata = new FormData()
            if (filedata) {
              formdata.append('image', filedata, _this.baseColumn.name + '.jpg')
            } else {
              // 文件数据为空,处理错误情况
              _this.$message.warning('生成的文件数据为空!')
            }
            let uploadUrl = _this.uploadUrl
            if (oldFileId) {
              uploadUrl = uploadUrl + '?id=' + oldFileId
            }
            req
              .post(uploadUrl, formdata)
              .then(response => {
                const result = response.data
                if (result.success) {
                  _this.$set(_this.baseColumn, 'snapshotId', result.fileId)
                  resolve()
                }
              })
              .finally(() => {
                resolve()
              })
          })
        })
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.add-column-page {
  height: 100%;
  overflow: hidden;
  .add-column-header {
    padding: 0 32px;
    border-bottom: 1px solid #e6e6e6;
  }
  .column-header-content {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    .column-header-left {
      ::v-deep {
        .el-page-header__left {
          color: #409eff;
        }
        .el-page-header__content {
          color: #222;
          font-size: 18px;
          font-weight: bold;
        }
      }
    }
    .column-header-right {
      ::v-deep {
        .el-button {
          padding: 8px 15px;
          border-radius: 2px;
        }
      }
    }
  }
  .add-column-content {
    padding: 32px;
    display: flex;
    width: 100%;
    height: calc(100% - 110px);
    .column-content-left,
    .column-content-right {
      border: 1px solid #e6e6e6;
      flex: 1;
      max-width: calc(50% - 96px);
      padding: 0 24px;
      overflow-y: auto;
      &::-webkit-scrollbar {
        width: 13px;
        height: 13px;
      }

      &::-webkit-scrollbar-thumb {
        background-color: rgba(0, 0, 0, 0.4);
        background-clip: padding-box;
        border: 3px solid transparent;
        border-radius: 7px;
      }

      &::-webkit-scrollbar-thumb:hover {
        background-color: rgba(0, 0, 0, 0.5);
      }

      &::-webkit-scrollbar-track {
        background-color: transparent;
      }

      &::-webkit-scrollbar-track:hover {
        background-color: #f8fafc;
      }

      ::v-deep {
        .ht-data-sheets {
          .no-tabs {
            padding: 16px 12px !important;
          }
          .form-list--header {
            display: none;
          }
          .template-preview-container {
            .template-content {
              display: block;
            }
            .field-wrap {
              padding: 12px;
            }
            .footer-wrap,
            .form-list--footer {
              display: none !important;
            }
            .van-cell__value {
              background: #f9f9f9;
              border-radius: 8px 8px 8px 8px;
            }
            .field-item--title,
            .field-content {
              padding: 0 !important;
            }

            .field-item--title {
              width: 100% !important;
            }
            .form-list--content {
              height: 100% !important;
              min-height: 150px;
            }
            .van-cell {
              padding: 0 !important;
            }
            .van-list > div:nth-last-of-type(2) {
              margin-bottom: 0 !important;
            }

            .van-cell:nth-last-of-type(1) {
            }
          }
        }
      }
    }
    .column-content-left {
      margin-right: 40px;
      overflow: auto;
      //隐藏滚动条
      &::-webkit-scrollbar {
        width: 0;
        background-color: transparent;
      }
      /*火狐下隐藏滚动条*/
      scrollbar-width: none;
    }
    .column-content-right {
      ::v-deep {
        .el-empty {
          height: calc(100% - 68px);
          .el-empty__description {
            margin-top: -40px;
            p {
              color: #333;
              font-size: 16px;
            }
          }
        }
        .box-card {
          .el-card__body {
            padding: 0;
          }
        }
      }
    }
    ::v-deep {
      .el-form-item__label {
        color: #888;
        padding-left: 10px;
      }
      .el-form-item__content {
        .el-radio-group {
          vertical-align: unset;
        }
        .el-input__inner,
        .el-textarea__inner {
          border-radius: 2px;
        }
      }
      .el-radio__label,
      .el-checkbox__label {
        color: #333;
      }
    }
  }
  .column-height {
    height: var(--columnHeight);
    ::v-deep {
      > .column-content {
        height: calc(var(--columnHeight) - 104px);
        overflow: auto;
        //隐藏滚动条
        &::-webkit-scrollbar {
          width: 0;
          background-color: transparent;
        }
        /*火狐下隐藏滚动条*/
        scrollbar-width: none;
      }
    }
  }
  ::v-deep {
    .page-form-item {
      .el-form-item__content {
        display: flex;
        .ht-form-inputs__inline {
          width: 148px;
        }
        .set-page__wrap {
          .page-number__input {
            margin-left: 8px;
            width: 88px;
            .el-input-number {
              width: 100%;
            }
          }
        }
      }
    }
    .column-height__input {
      width: 224px;
      .el-input-number {
        width: 100%;
      }
    }
    .unit {
      padding-left: 8px;
      color: #333;
    }
  }

  .mobile-design {
    background: url('../../assets/img/mobile-android.png') no-repeat;
    background-size: 100% 100%;
    background-color: #f5f5f5;
    border-radius: 40px;
    padding: 15px 0;
    scrollbar-width: 0;
    -ms-overflow-style: none;
    box-sizing: border-box;
    margin: 0 auto;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    &::-webkit-scrollbar {
      width: 0;
    }
    &--box {
      position: relative;
      border-radius: 28px;
      overflow-x: hidden;
      overflow-y: auto;
      scrollbar-width: 0;
      -ms-overflow-style: none;
      &::-webkit-scrollbar {
        width: 0px;
        background-color: transparent;
      }
    }
    &__img {
      width: 100%;
      height: auto;
    }
    ::v-deep {
      .mobile-design__header {
        text-align: center;
        .el-image {
          width: 350px;
          border-radius: 26px 26px 0 0;
        }
      }
    }
    .content-wrapper {
      position: absolute;
      top: 180px;
      left: 50%;
      transform: translateX(-50%);
      background-color: #fff;
      border-radius: 10px;
      overflow: hidden;
    }
  }

  // 屏幕小于 1440px 时应用该样式
  @media screen and (max-width: 1441px) {
    .mobile-design {
      width: 320px;
      height: 640px;
      padding: 8px 0;
      &--box {
        width: calc(320px - 26px);
        height: calc(640px - 45px);
      }
      .content-wrapper {
        width: calc(320px - 40px);
        top: 160px;
        // transform: scale3d(.8,.8,1)
      }
    }
  }

  // 屏幕大于 1440px 或小于 1920px 时应用该样式
  @media screen and (min-width: 1440px) and (max-width: 1920px) {
    .mobile-design {
      width: 407px;
      height: 812px;
      &--box {
        width: calc(407px - 30px);
        height: calc(812px - 45px);
      }
      .content-wrapper {
        width: calc(407px - 60px);
        top: 180px;
      }
    }
  }
  // 屏幕大于 1920px 时应用该样式
  @media screen and (min-width: 1920px) {
    .mobile-design {
      width: 407px;
      height: 812px;
      &--box {
        width: calc(407px - 30px);
        height: calc(812px - 45px);
      }
      .content-wrapper {
        width: calc(407px - 60px);
        top: 180px;
      }
    }
  }
}
.custom-title-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  .title-wrap {
    width: 50%;
  }
}

::v-deep {
  .form-list--content {
    height: auto;
    scrollbar-width: 0;
    &::-webkit-scrollbar {
      width: 0;
    }
    -ms-overflow-style: none; /*这将影响IE10+*/
    scrollbar-width: none; /*这将影响Firefox*/
  }
}
</style>