CcSimple / vue-plugin-hiprint

hiprint for Vue2/Vue3 ⚡打印、打印设计、可视化设计器、报表设计、元素编辑、可视化打印编辑
https://ccsimple.github.io/vue-plugin-hiprint
MIT License
964 stars 188 forks source link

1.我希望有一个自定义函数列表来进行选择功能函数,然后去重构了他,但是不生效 #103

Open zj007-yj opened 7 months ago

zj007-yj commented 7 months ago

使用的版本

latest

版本号

2.5.4

你的安装方式

NPM 依赖

你的操作系统

Windows

你的浏览器

Chrome

你的项目编程语言

Vue 2

问题描述

1.我希望有一个自定义函数列表来进行选择功能函数,然后去重构了他,但是不生效

如何复现

import { getfunction } from '@/api/design'

export default (function() { var function_list = [] getfunction().then(response => { if (response.code === 200) { function_list = response.data.list console.log(response.data.list) console.log(function_list) } else { this.msgError(response.msg) } }) function t() { // json模板 options 对应键值 key this.name = 'formatter' } // 在这里添加你的函数 // function customFontSize(value, options, target, templateData) { // const aa = 17.75 // const maxwidth = options.width // const maxheight = options.height // let fontSize = options.fontSize || aa // const arr = value.split('·') // let num = 0 // // if (value.indexOf('·') !== -1) { // for (let i = 0; i < arr.length; i++) { // num = num > arr[i].length ? num : arr[i].length // } // } else { // num = value.length // } // // const fontHeight = value.split('·').length // // while (fontHeight fontSize > maxheight) { // fontSize = fontSize - 0.5 // } // // while (num fontSize > maxwidth) { // fontSize = fontSize - 0.5 // } // return fontSize // } // function (value,options,target,templateData){ let aa=17.75; let maxwidth = options.width; let maxheight = options.height; let fontSize = aa?aa:options.fontSize; let arr=value.split('·'); let num=0; if (value.indexOf('·')!==-1){ for (let i=0;i<arr.length;i++){ num=num>arr[i].length?num:arr[i].length; } }else { num=value.length+1; } let fontHeight=value.split('·').length; while(fontHeightfontSize>maxheight){ fontSize=fontSize-0.5; } while (numfontSize>maxwidth){ fontSize=fontSize-0.5; } return {'font-size':fontSize+'pt'} } // 涉及修改元素样式, 添加一个 css 方法 // t: 元素对象, e 参数值 return t.prototype.css = function(t, e, i) { return null }, // 创建 DOM t.prototype.createTarget = function() { const list = function_list let fontSizeList = '\n ' list.forEach(function(e) { fontSizeList += '\n ' }) this.target = $('

\n
\n 自定义函数\n
\n
\n \n
\n
') this.target.find('.auto-submit').append($(fontSizeList)) return this.target }, // 获取值 t.prototype.getValue = function() { var t = this.target.find('select').val() console.log(t) if (t) return parseFloat(t.toString()) }, // 设置值 t.prototype.setValue = function(t) { // t: options 对应键的值 t = function(title, value, options, templateData, target) { return value.slice(-3) } this.target.find('select').val(t) this.target.find('textarea').val(t ? t.toString() : null) }, // 销毁 DOM t.prototype.destroy = function() { this.target.remove() }, t }())

预期结果

1.formatter 重构下拉框,设置函数生效

实际结果

1.formatter 重构下拉框,设置函数不生效

截图或视频

[在这里上传图片]

这个问题是否已经存在?