12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844 |
- <template>
- <div class="props">
- <t-tabs v-model="data.tab">
- <t-tab-panel :value="1" label="外观">
- <t-space direction="vertical" class="py-16 w-full">
- <div class="form-item px-12">
- <label style="width: 50px">ID</label>
- <t-input
- class="w-full"
- placeholder="ID"
- :value="data.pen.id"
- @change="changeID($event)"
- />
- </div>
- <div class="form-item px-12" style="margin-top: -12px">
- <label style="width: 50px">名称</label>
- <!-- <t-input
- class="w-full"
- placeholder="名称"
- disabled
- v-model.number="data.pen.name"
- @change="changeValue('name')"
- /> -->
- <div style="padding-left: 8px; line-height: 30px">
- {{ data.pen.name }}
- </div>
- </div>
- <div class="form-item px-12" style="margin-top: -12px">
- <label style="width: 50px">分组</label>
- <t-select-input
- v-model:inputValue="data.inputTag"
- :value="data.pen.tags"
- allow-input
- placeholder="请输入或选择分组"
- multiple
- @tag-change="onChangeInputTag"
- @focus="data.tagPopupVisible = true"
- @blur="data.tagPopupVisible = false"
- :tag-input-props="{ excessTagsDisplayType: 'break-line' }"
- >
- <template #panel>
- <ul style="padding: 8px 12px">
- <li
- v-for="item in data.groups"
- :key="item"
- @click="onSelectTag(item)"
- >
- {{ item }}
- </li>
- </ul>
- </template>
- </t-select-input>
- </div>
- <div v-if="isDom" class="form-item px-12" style="margin-top: -12px">
- <label style="width: 50px">z-index</label>
- <t-input-number
- v-model="data.pen.zIndex"
- theme="column"
- :min="0"
- placeholder="默认5"
- @change="changeValue('zIndex')"
- />
- </div>
- <div v-else class="form-item px-12" style="margin-top: -12px">
- <label style="width: 50px">画布层</label>
- <!-- <t-switch
- class="mt-8 ml-8"
- v-model="data.pen.template"
- size="small"
- @change="changeValue('template')"
- /> -->
- <t-select
- v-model="data.pen.canvasLayer"
- @change="changeValue('canvasLayer')"
- >
- <t-option :key="4" :disabled="data.pen.name!=='image'" :value="4" label="上层图片层"> 上层图片层 </t-option>
- <t-option :key="3" :value="3" label="主画布层"> 主画布层 </t-option>
- <t-option :key="2" :disabled="data.pen.name!=='image'" :value="2" label="下层图片层"> 下层图片层 </t-option>
- <t-option :key="1" :value="1" label="模板层"> 模板层 </t-option>
- </t-select>
- </div>
- <t-divider style="margin: -8px 0" />
- <div style="margin: 0 16px 16px 16px">
- <t-space direction="vertical" size="small" class="w-full">
- <div style="color: var(--color); margin-bottom: 2px">
- 大屏对齐
- </div>
- <div class="icons">
- <t-tooltip
- v-for="item in aligns"
- :content="item.label"
- placement="top"
- >
- <svg
- class="l-icon btn"
- aria-hidden="true"
- @click="align(item.value)"
- >
- <use :xlink:href="item.icon"></use>
- </svg>
- </t-tooltip>
- </div>
- </t-space>
- </div>
- <t-divider style="margin: -8px 0" />
- <div class="form-item" style="margin-top: -12px">
- <t-input
- class="ml-4"
- label="X"
- placeholder="X"
- v-model.number="data.rect.x"
- style="width: 80px"
- :format="decimalPlaces"
- @change="changeRectValue('x')"
- />
- <link-icon class="hidden ml-4"/>
- <!-- <t-icon name="link" class="hidden ml-4" /> -->
- <t-input
- class="ml-4"
- label="Y"
- placeholder="Y"
- v-model.number="data.rect.y"
- style="width: 80px"
- :format="decimalPlaces"
- @change="changeRectValue('y')"
- />
- <t-input
- class="ml-16"
- v-model.number="data.pen.rotate"
- placeholder="旋转"
- style="width: 80px"
- :format="decimalRound"
- @change="changeValue('rotate')"
- >
- <template #prefix-icon>
- <svg class="l-icon" aria-hidden="true">
- <use xlink:href="#l-rotate"></use>
- </svg>
- </template>
- </t-input>
- </div>
- <div class="form-item hover-icons" style="margin-top: -12px">
- <t-input
- class="ml-4"
- label="W"
- v-model.number="data.rect.width"
- placeholder="宽"
- min="1"
- style="width: 80px"
- :format="decimalPlaces"
- @change="changeRectValue('width')"
- />
- <t-tooltip v-if="data.pen.ratio" content="固定比例" placement="top">
- <link-icon
- class="ml-4 hover"
- @click="data.pen.ratio = !data.pen.ratio"/>
- <!-- <t-icon
- name="link"
- class="ml-4 hover"
- @click="data.pen.ratio = !data.pen.ratio"
- /> -->
- </t-tooltip>
- <t-tooltip v-else content="不固定比例" placement="top">
- <link-unlink-icon class="ml-4 hover icon"
- @click="data.pen.ratio = !data.pen.ratio"/>
- <!-- <t-icon
- name="link-unlink"
- class="ml-4 hover icon"
- @click="data.pen.ratio = !data.pen.ratio"
- /> -->
- </t-tooltip>
- <t-input
- class="ml-4"
- label="H"
- placeholder="高"
- v-model.number="data.rect.height"
- min="1"
- style="width: 80px"
- :format="decimalPlaces"
- @change="changeRectValue('height')"
- />
- <t-input
- class="ml-16"
- v-model.number="data.pen.borderRadius"
- placeholder="圆角"
- style="width: 80px"
- @change="changeValue('borderRadius')"
- >
- <template #prefix-icon>
- <svg class="l-icon" aria-hidden="true">
- <use xlink:href="#l-border-radius"></use>
- </svg>
- </template>
- </t-input>
- </div>
- <t-divider style="margin: -8px 0" />
- <div class="form-item px-16" style="margin-top: -12px">
- <label>透明度</label>
- <t-slider
- v-model="data.pen.globalAlpha"
- :min="0"
- :max="1"
- :step="0.01"
- @change="changeValue('globalAlpha')"
- />
- <span class="ml-16" style="width: 50px; line-height: 30px">
- {{ data.pen.globalAlpha }}
- </span>
- </div>
- <template
- v-if="
- data.pen.name === 'combine' && data.pen.showChild !== undefined
- "
- >
- <t-divider style="margin: -8px 0" />
- <div class="form-item px-16" style="margin-top: -12px">
- <label>状态</label>
- <t-select
- v-model="data.pen.showChild"
- placeholder="状态"
- @change="changeValue('showChild')"
- style="width: 150px"
- >
- <t-option
- v-for="(a, index) in data.pen.children"
- :key="index"
- :value="index"
- >
- 状态{{ index + 1 }}</t-option
- >
- </t-select>
- </div>
- </template>
- <t-collapse
- :defaultValue="['1', '2', '3', '4', '5']"
- expandIconPlacement="right"
- :borderless="true"
- >
- <t-collapse-panel
- v-if="data.pen.props.look !== false"
- value="1"
- header="外观"
- >
- <t-space direction="vertical" size="small" class="w-full">
- <div class="form-item">
- <t-color-picker
- class="simple mt-8 mr-4"
- format="CSS"
- :enable-alpha="true"
- :recent-colors="null"
- :swatch-colors="defaultPureColor"
- :color-modes="['monochrome']"
- :show-primary-color-preview="false"
- :clearable="true"
- v-model="data.pen.color"
- @change="changeValue('color')"
- />
- <label style="width: 64px">前景颜色</label>
- <t-color-picker
- class="simple mt-8 mr-4"
- format="CSS"
- :enable-alpha="true"
- :recent-colors="null"
- :swatch-colors="defaultPureColor"
- :color-modes="['monochrome']"
- :show-primary-color-preview="false"
- v-model="data.pen.hoverColor"
- @change="changeValue('hoverColor')"
- />
- <label style="width: 64px">悬停颜色</label>
- <t-color-picker
- class="simple mt-8 mr-4"
- format="CSS"
- :enable-alpha="true"
- :recent-colors="null"
- :swatch-colors="defaultPureColor"
- :color-modes="['monochrome']"
- :show-primary-color-preview="false"
- v-model="data.pen.activeColor"
- @change="changeValue('activeColor')"
- />
- <label style="width: 64px">选中颜色</label>
- </div>
- <div class="form-item">
- <label style="width: 32px">线条 </label>
- <t-select
- v-model="data.pen.dash"
- placeholder="线条样式"
- @change="changeValue('dash')"
- style="width: 80px"
- >
- <template #valueDisplay="{ value }">
- <svg
- xmlns="http://www.w3.org/2000/svg"
- version="1.1"
- style="width: 100%; height: 20px"
- >
- <g fill="none" stroke="var(--color)" stroke-width="1">
- <path v-if="value === 0" d="M0 9 l85 0" />
- <path
- v-else-if="value === 1"
- stroke-dasharray="5 5"
- d="M0 9 l85 0"
- />
- <path
- v-else-if="value === 2"
- stroke-dasharray="10 10"
- d="M0 9 l85 0"
- />
- <path
- v-else-if="value === 3"
- stroke-dasharray="10 10 2 10"
- d="M0 9 l85 0"
- />
- </g>
- </svg>
- </template>
- <t-option :key="0" :value="0">
- <svg
- xmlns="http://www.w3.org/2000/svg"
- version="1.1"
- style="width: 80px; height: 14px"
- >
- <g fill="none" stroke="var(--color)" stroke-width="1">
- <path d="M0 9 l85 0" />
- </g>
- </svg>
- </t-option>
- <t-option :key="1" :value="1">
- <svg
- xmlns="http://www.w3.org/2000/svg"
- version="1.1"
- style="width: 80px; height: 14px"
- >
- <g fill="none" stroke="var(--color)" stroke-width="1">
- <path stroke-dasharray="5 5" d="M0 9 l85 0" />
- </g>
- </svg>
- </t-option>
- <t-option :key="2" :value="2">
- <svg
- xmlns="http://www.w3.org/2000/svg"
- version="1.1"
- style="width: 80px; height: 14px"
- >
- <g fill="none" stroke="var(--color)" stroke-width="1">
- <path stroke-dasharray="10 10" d="M0 9 l85 0" />
- </g>
- </svg>
- </t-option>
- <t-option :key="3" :value="3">
- <svg
- xmlns="http://www.w3.org/2000/svg"
- version="1.1"
- style="width: 80px; height: 14px"
- >
- <g fill="none" stroke="var(--color)" stroke-width="1">
- <path stroke-dasharray="10 10 2 10" d="M0 9 l85 0" />
- </g>
- </svg>
- </t-option>
- </t-select>
- <t-input-number
- theme="normal"
- placeholder="线条宽度"
- v-model="data.pen.lineWidth"
- :min="0"
- :decimalPlaces="0"
- @change="changeValue('lineWidth')"
- class="ml-4"
- style="width: 40px"
- />
- <t-tooltip
- v-if="['polyline','line'].includes(data.pen.lineName)"
- content="平滑度"
- placement="top"
- >
- <t-input-number
- theme="normal"
- placeholder="1-3"
- v-model="data.pen.lineSmooth"
- :min="0"
- :decimalPlaces="0"
- @change="changeValue('lineSmooth')"
- class="ml-4"
- style="width: 44px"
- />
- </t-tooltip>
- <t-tooltip content="线条渐变" placement="top">
- <div class="flex middle ml-8">
- <t-checkbox
- v-model="data.pen.strokeType"
- @change="changeValue('strokeType')"
- style="width: 22px"
- />
- <t-color-picker
- v-if="data.pen.strokeType"
- class="simple mr-4"
- format="CSS"
- :swatch-colors="defaultGradientColor"
- :color-modes="['linear-gradient']"
- :show-primary-color-preview="false"
- :recent-colors="null"
- :enableAlpha="true"
- v-model="data.pen.lineGradientColors"
- @change="changeValue('lineGradientColors')"
- placeholder="无"
- />
- </div>
- </t-tooltip>
- </div>
- <div class="form-item">
- <label style="width: 52px">起点箭头 </label>
- <t-select
- v-model="data.pen.fromArrow"
- placeholder="线条样式"
- @change="changeValue('fromArrow')"
- style="width: 80px"
- >
- <template #valueDisplay="{ value }">
- <svg v-if="value" class="l-icon" aria-hidden="true">
- <use :xlink:href="fromArrows.find(item=>item.value===value).icon"></use>
- </svg>
- </template>
- <t-option v-for="item in fromArrows" :key="item.value" :value="item.value">
- <svg class="l-icon" aria-hidden="true">
- <use :xlink:href="item.icon"></use>
- </svg>
- </t-option>
- </t-select>
- <label style="width: 52px" class="ml-4">终点箭头 </label>
- <t-select
- v-model="data.pen.toArrow"
- placeholder="线条样式"
- @change="changeValue('toArrow')"
- style="width: 80px"
- >
- <template #valueDisplay="{ value }">
- <svg v-if="value" class="l-icon" aria-hidden="true">
- <use :xlink:href="toArrows.find(item=>item.value===value).icon"></use>
- </svg>
- </template>
- <t-option v-for="item in toArrows" :key="item.value" :value="item.value">
- <svg class="l-icon" aria-hidden="true">
- <use :xlink:href="item.icon"></use>
- </svg>
- </t-option>
- </t-select>
- </div>
- <div class="flex" style="margin-left: 40px">
- <div class="flex column middle">
- <t-radio-group
- size="small"
- v-model="data.pen.lineCap"
- default-value="butt"
- @change="changeValue('lineCap')"
- >
- <t-radio-button value="butt">
- <t-tooltip content="默认" placement="top">
- <svg class="l-icon" aria-hidden="true">
- <use xlink:href="#l-duandian1"></use>
- </svg>
- </t-tooltip>
- </t-radio-button>
- <t-radio-button value="round">
- <t-tooltip content="圆形" placement="top">
- <svg class="l-icon" aria-hidden="true">
- <use xlink:href="#l-duandian2"></use>
- </svg>
- </t-tooltip>
- </t-radio-button>
- <t-radio-button value="square">
- <t-tooltip content="方形" placement="top">
- <svg class="l-icon" aria-hidden="true">
- <use xlink:href="#l-duandian3"></use>
- </svg>
- </t-tooltip>
- </t-radio-button>
- </t-radio-group>
- <div class="mt-4" style="font-size: 12px">末端样式</div>
- </div>
- <div class="flex column middle ml-16">
- <t-radio-group
- size="small"
- v-model="data.pen.lineJoin"
- default-value="miter"
- @change="changeValue('lineJoin')"
- >
- <t-radio-button value="miter">
- <t-tooltip content="默认" placement="top">
- <svg class="l-icon" aria-hidden="true">
- <use xlink:href="#l-jiedian1"></use>
- </svg>
- </t-tooltip>
- </t-radio-button>
- <t-radio-button value="round">
- <t-tooltip content="圆形" placement="top">
- <svg class="l-icon" aria-hidden="true">
- <use xlink:href="#l-jiedian2"></use>
- </svg>
- </t-tooltip>
- </t-radio-button>
- <t-radio-button value="bevel">
- <t-tooltip content="斜角" placement="top">
- <svg class="l-icon" aria-hidden="true">
- <use xlink:href="#l-jiedian3"></use>
- </svg>
- </t-tooltip>
- </t-radio-button>
- </t-radio-group>
- <div class="mt-4" style="font-size: 12px">连接样式</div>
- </div>
- </div>
- <div class="form-item" v-if="!data.pen.type">
- <label style="width: 32px">背景</label>
- <div class="ml-8">
- <t-radio-group
- size="small"
- v-model="data.pen.bkType"
- :default-value="0"
- @change="changeValue('bkType')"
- >
- <t-radio-button :value="0"> 纯色 </t-radio-button>
- <t-radio-button :value="1"> 线性渐变 </t-radio-button>
- <t-radio-button :value="2"> 径向渐变 </t-radio-button>
- </t-radio-group>
- <div v-if="data.pen.bkType === 0" class="mt-8 -ml-8">
- <t-color-picker
- class="w-full"
- format="CSS"
- :swatch-colors="defaultPureColor"
- :color-modes="['monochrome']"
- :recent-colors="null"
- :enable-alpha="true"
- :show-primary-color-preview="false"
- v-model="data.pen.background"
- @change="changeValue('background')"
- />
- </div>
- <div
- v-else-if="data.pen.bkType === 1"
- class="mt-8 -ml-8"
- style="width: 200px"
- >
- <t-color-picker
- class="w-full"
- format="CSS"
- :enable-alpha="true"
- :recent-colors="null"
- :swatch-colors="defaultGradientColor"
- :color-modes="['linear-gradient']"
- :show-primary-color-preview="false"
- v-model="data.pen.gradientColors"
- @change="changeValue('gradientColors')"
- />
- </div>
- <div
- v-else-if="data.pen.bkType === 2"
- class="mt-8 flex middle"
- >
- <t-color-picker
- class="simple"
- format="CSS"
- :enable-alpha="true"
- :recent-colors="null"
- :swatch-colors="defaultGradientColor"
- :color-modes="['linear-gradient']"
- :show-primary-color-preview="false"
- v-model="data.pen.gradientColors"
- @change="changeValue('gradientColors')"
- />
- <t-input-number
- theme="column"
- placeholder="渐变半径"
- v-model="data.pen.gradientRadius"
- :min="0"
- :max="1"
- :step="0.1"
- @change="changeValue('gradientRadius')"
- class="ml-8"
- style="width: 100px"
- />
- </div>
- </div>
- </div>
- <div class="form-item">
- <label style="width: 32px">阴影 </label>
- <div class="flex middle ml-8">
- <t-checkbox
- v-model="data.pen.shadow"
- @change="changeValue('shadow')"
- style="width: 22px"
- />
- <t-color-picker
- v-if="data.pen.shadow"
- class="simple"
- format="CSS"
- :enable-alpha="true"
- :recent-colors="null"
- :swatch-colors="defaultPureColor"
- :color-modes="['monochrome']"
- :show-primary-color-preview="false"
- v-model="data.pen.shadowColor"
- @change="changeValue('shadowColor')"
- />
- </div>
- <label
- v-if="data.pen.shadow"
- style="width: 50px; margin-left: 25px"
- >文字阴影
- </label>
- <div v-if="data.pen.shadow" class="flex middle ml-8">
- <t-checkbox
- v-model="data.pen.textHasShadow"
- @change="changeValue('textHasShadow')"
- style="width: 22px"
- />
- </div>
- </div>
- <div class="form-item" v-if="data.pen.shadow">
- <label style="width: 28px"></label>
- <div class="flex" style="margin-top: -8px">
- <t-input
- class="ml-4"
- label="X"
- placeholder="0"
- v-model.number="data.pen.shadowOffsetX"
- style="width: 60px"
- @change="changeValue('shadowOffsetX')"
- title="X偏移"
- />
- <t-input
- class="ml-4"
- label="Y"
- placeholder="0"
- v-model.number="data.pen.shadowOffsetY"
- style="width: 60px"
- @change="changeValue('shadowOffsetY')"
- title="Y偏移"
- />
- <t-input
- class="ml-4"
- label="模糊"
- placeholder="0"
- v-model.number="data.pen.shadowBlur"
- style="width: 64px"
- @change="changeValue('shadowBlur')"
- title="模糊大小"
- />
- </div>
- </div>
- </t-space>
- </t-collapse-panel>
- <t-collapse-panel
- v-if="data.pen.props.text"
- value="2"
- header="文字"
- >
- <t-space direction="vertical" size="small" class="w-full">
- <div class="form-item">
- <div class="flex middle" style="margin-left: -10px">
- <t-select-input
- :value="data.pen.fontFamily"
- :popup-visible="data.fontFamilyPopupVisible"
- placeholder="字体名"
- allow-input
- style="width: 170px"
- @change="changeValue('fontFamily')"
- @enter="changeValue('fontFamily')"
- @blur="changeValue('fontFamily')"
- @popup-visible-change="onFontPopupVisible"
- :popup-props="{
- overlayInnerStyle: { width: 'auto' },
- }"
- >
- <template #panel>
- <ul style="padding: 12px">
- <li
- v-for="item in fonts"
- :key="item"
- @click="onFontFamily(item)"
- >
- {{ item }}
- </li>
- </ul>
- </template>
- <template #suffixIcon>
- <chevron-down-icon />
- <!-- <t-icon name="chevron-down" /> -->
- </template>
- </t-select-input>
- <t-input
- class="ml-8"
- placeholder="字体大小"
- v-model.number="data.pen.fontSize"
- style="width: 80px"
- :format="decimalRound"
- @change="changeValue('fontSize')"
- />
- </div>
- </div>
- <div class="flex middle">
- <t-radio-group
- size="small"
- v-model="data.pen.textAlign"
- default-value="center"
- @change="changeValue('textAlign')"
- >
- <t-radio-button value="left">
- <t-tooltip content="居左" placement="top">
- <format-vertical-align-left-icon />
- <!-- <t-icon name="format-vertical-align-left" /> -->
- </t-tooltip>
- </t-radio-button>
- <t-radio-button value="center">
- <t-tooltip content="水平居中" placement="top">
- <format-vertical-align-center-icon />
- <!-- <t-icon name="format-vertical-align-center" /> -->
- </t-tooltip>
- </t-radio-button>
- <t-radio-button value="right">
- <t-tooltip content="居右" placement="top">
- <format-vertical-align-right-icon />
- <!-- <t-icon name="format-vertical-align-right" /> -->
- </t-tooltip>
- </t-radio-button>
- </t-radio-group>
- <t-radio-group
- class="ml-8"
- size="small"
- v-model="data.pen.textBaseline"
- default-value="top"
- @change="changeValue('textBaseline')"
- >
- <t-radio-button value="top">
- <t-tooltip content="顶部对齐" placement="top">
- <format-horizontal-align-top-icon />
- <!-- <t-icon name="format-horizontal-align-top" /> -->
- </t-tooltip>
- </t-radio-button>
- <t-radio-button value="middle">
- <t-tooltip content="垂直居中" placement="top">
- <format-horizontal-align-center-icon />
- <!-- <t-icon name="format-horizontal-align-center" /> -->
- </t-tooltip>
- </t-radio-button>
- <t-radio-button value="bottom">
- <t-tooltip content="底部对齐" placement="top">
- <format-horizontal-align-bottom-icon />
- <!-- <t-icon name="format-horizontal-align-bottom" /> -->
- </t-tooltip>
- </t-radio-button>
- </t-radio-group>
- <t-button
- :class="{ active: data.pen.fontWeight === 'bold' }"
- class="ml-8 icon"
- shape="rectangle"
- variant="text"
- @click="
- data.pen.fontWeight === 'bold'
- ? (data.pen.fontWeight = 'normal')
- : (data.pen.fontWeight = 'bold');
- changeValue('fontWeight');
- "
- >
- B
- </t-button>
- <t-button
- :class="{ active: data.pen.fontStyle === 'italic' }"
- class="ml-4 icon"
- shape="rectangle"
- variant="text"
- @click="
- data.pen.fontStyle === 'italic'
- ? (data.pen.fontStyle = 'normal')
- : (data.pen.fontStyle = 'italic');
- changeValue('fontStyle');
- "
- style="font-style: italic; font-family: serif"
- >I</t-button
- >
- </div>
- <div class="form-item">
- <!-- <t-color-picker
- class="simple mt-8 mr-4"
- format="CSS"
- :enable-alpha="true"
- :recent-colors="null"
- :swatch-colors="defaultPureColor"
- :color-modes="['monochrome']"
- :show-primary-color-preview="false"
- v-model="data.pen.textColor"
- @change="changeValue('textColor')"
- />
- <label style="width: 44px">前景</label> -->
- <t-color-picker
- class="simple mt-8 mr-4"
- format="CSS"
- :enable-alpha="true"
- :recent-colors="null"
- :swatch-colors="defaultPureColor"
- :color-modes="['monochrome']"
- :show-primary-color-preview="false"
- v-model="data.pen.textBackground"
- @change="changeValue('textBackground')"
- />
- <label style="width: 64px">背景</label>
- <t-color-picker
- class="simple mt-8 mr-4"
- format="CSS"
- :enable-alpha="true"
- :recent-colors="null"
- :swatch-colors="defaultPureColor"
- :color-modes="['monochrome']"
- :show-primary-color-preview="false"
- v-model="data.pen.hoverTextColor"
- @change="changeValue('hoverTextColor')"
- />
- <label style="width: 64px">悬停</label>
- <t-color-picker
- class="simple mt-8 mr-4"
- format="CSS"
- :enable-alpha="true"
- :recent-colors="null"
- :swatch-colors="defaultPureColor"
- :color-modes="['monochrome']"
- :show-primary-color-preview="false"
- v-model="data.pen.activeTextColor"
- @change="changeValue('activeTextColor')"
- />
- <label style="width: 64px">选中</label>
- </div>
- <div class="form-item">
- <label style="width: 32px">前景</label>
- <div class="ml-8">
- <t-radio-group
- size="small"
- v-model="data.pen.textType"
- :default-value="0"
- @change="changeValue('textType')"
- >
- <t-radio-button :value="0"> 纯色 </t-radio-button>
- <t-radio-button :value="1"> 线性渐变 </t-radio-button>
- <t-radio-button :value="2"> 径向渐变 </t-radio-button>
- </t-radio-group>
- <div v-if="data.pen.textType === 0" class="mt-8 -ml-8">
- <t-color-picker
- class="w-full"
- format="CSS"
- :swatch-colors="defaultPureColor"
- :color-modes="['monochrome']"
- :recent-colors="null"
- :enable-alpha="true"
- :show-primary-color-preview="false"
- v-model="data.pen.textColor"
- @change="changeValue('textColor')"
- />
- </div>
- <div
- v-else-if="data.pen.textType === 1"
- class="mt-8 -ml-8"
- style="width: 200px"
- >
- <t-color-picker
- class="w-full"
- format="CSS"
- :enable-alpha="true"
- :recent-colors="null"
- :swatch-colors="defaultGradientColor"
- :color-modes="['linear-gradient']"
- :show-primary-color-preview="false"
- v-model="data.pen.textGradientColors"
- @change="changeValue('textGradientColors')"
- />
- </div>
- <div
- v-else-if="data.pen.textType === 2"
- class="mt-8 -ml-8"
- style="width: 200px"
- >
- <t-color-picker
- class="w-full"
- format="CSS"
- :enable-alpha="true"
- :recent-colors="null"
- :swatch-colors="defaultGradientColor"
- :color-modes="['linear-gradient']"
- :show-primary-color-preview="false"
- v-model="data.pen.textGradientColors"
- @change="changeValue('textGradientColors')"
- />
- </div>
- </div>
- </div>
- <div class="form-item">
- <t-checkbox
- :checked="data.pen.whiteSpace != 'nowrap' ? true : false"
- @change="changeValue('whiteSpace')"
- style="width: 64px"
- >
- 换行
- </t-checkbox>
- <t-checkbox
- v-model="data.pen.ellipsis"
- @change="changeValue('ellipsis')"
- style="width: 68px"
- >
- 省略号
- </t-checkbox>
- <t-tooltip content="行高">
- <t-input
- placeholder="行高"
- v-model.number="data.pen.lineHeight"
- style="width: 40px"
- @change="changeValue('lineHeight')"
- />
- </t-tooltip>
- <t-tooltip content="显示时保留小数位数">
- <t-input
- class="ml-4"
- placeholder="小数"
- v-model.number="data.pen.keepDecimal"
- style="width: 60px"
- @change="changeValue('keepDecimal')"
- />
- </t-tooltip>
- </div>
- <div class="form-item" style="margin-top: -4px">
- <t-tooltip content="水平偏移">
- <t-input
- placeholder="X"
- v-model.number="data.pen.textLeft"
- style="width: 60px; margin-left: -8px"
- @change="changeValue('textLeft')"
- />
- </t-tooltip>
- <t-tooltip content="垂直偏移">
- <t-input
- class="ml-4"
- placeholder="Y"
- v-model.number="data.pen.textTop"
- style="width: 60px"
- @change="changeValue('textTop')"
- />
- </t-tooltip>
- <t-tooltip content="宽">
- <t-input
- class="ml-4"
- placeholder="宽"
- v-model.number="data.pen.textWidth"
- style="width: 60px"
- @change="changeValue('textWidth')"
- />
- </t-tooltip>
- <t-tooltip content="高">
- <t-input
- class="ml-4"
- placeholder="高"
- v-model.number="data.pen.textHeight"
- style="width: 60px"
- @change="changeValue('textHeight')"
- />
- </t-tooltip>
- </div>
- <div class="flex middle">
- <t-checkbox
- v-model="data.pen.disableInput"
- @change="changeValue('disableInput')"
- style="width: 64px"
- >
- 只读
- </t-checkbox>
- <t-checkbox
- v-model="data.pen.hiddenText"
- @change="changeValue('hiddenText')"
- style="width: 90px"
- >
- 隐藏文字
- </t-checkbox>
- <t-checkbox
- v-model="data.pen.textAutoAdjust"
- @change="changeValue('textAutoAdjust')"
- style="width: 90px"
- >
- 自动调整
- </t-checkbox>
- </div>
- </t-space>
- </t-collapse-panel>
- <t-collapse-panel
- v-if="data.pen.props.image"
- value="3"
- header="图片"
- >
- <t-space direction="vertical" size="small" class="w-full">
- <div>
- <t-upload
- ref="uploadRef"
- v-model="data.images"
- action="/api/image/upload"
- theme="image"
- accept="image/*"
- :headers="headers"
- :data="updataData"
- :before-upload="beforeUpload"
- draggable
- @success="fileSuccessed"
- @remove="fileRemoved"
- >
- <template #fileListDisplay>
- <div style="z-index: 20">
- <a class="mr-4" @click="upload"> 点击上传 </a>
- / 拖拽图片到此区域
- </div>
- </template>
- </t-upload>
- </div>
- <div class="form-item hover-icons" style="margin-left: -12px">
- <t-input
- class="ml-4"
- label="W"
- v-model.number="data.pen.iconWidth"
- placeholder="自适应"
- min="1"
- style="width: 80px"
- :format="decimalPlaces"
- @change="changeValue('iconWidth')"
- />
- <t-tooltip
- v-if="data.pen.imageRatio"
- content="固定比例"
- placement="top"
- >
- <link-icon class="ml-4 hover"
- @click="data.pen.imageRatio = !data.pen.imageRatio"/>
- <!-- <t-icon
- name="link"
- class="ml-4 hover"
- @click="data.pen.imageRatio = !data.pen.imageRatio"
- /> -->
- </t-tooltip>
- <t-tooltip v-else content="不固定比例" placement="top">
- <link-unlink-icon class="ml-4 hover icon"
- @click="data.pen.imageRatio = !data.pen.imageRatio"/>
- <!-- <t-icon
- name="link-unlink"
- class="ml-4 hover icon"
- @click="data.pen.imageRatio = !data.pen.imageRatio"
- /> -->
- </t-tooltip>
- <t-input
- class="ml-4"
- label="H"
- placeholder="自适应"
- v-model.number="data.pen.iconHeight"
- min="1"
- style="width: 80px"
- :format="decimalPlaces"
- @change="changeValue('iconHeight')"
- />
- <t-checkbox
- class="ml-8"
- v-model="data.pen.toGif"
- @change="changeValue('toGif')"
- >
- 转动图
- </t-checkbox>
- </div>
- <div class="form-item">
- <label style="width: 30px; color: var(--color)">Url:</label>
- <!-- {{ data.pen.image }} -->
- <t-input
- class="w-full"
- placeholder="图片地址"
- v-model.number="data.pen.image"
- @change="changeValue('image')"
- />
- </div>
- </t-space>
- </t-collapse-panel>
- <t-collapse-panel
- v-if="data.pen.props.icon"
- value="4"
- header="图标"
- >
- <t-space direction="vertical" size="small" class="w-full">
- <div class="form-item">
- <label style="width: 32px">图标 </label>
- <i
- class="ml-8"
- :class="data.pen.iconFamily"
- style="line-height: 30px; height: 30px; color: var(--color)"
- >
- {{ data.pen.icon }}
- </i>
- <a class="ml-12 mt-4" @click="iconsDrawer.show = true">
- 选择
- </a>
- <t-drawer
- v-model:visible="iconsDrawer.show"
- header="选择图标"
- :footer="null"
- >
- <Iconfonts :urls="data.iconUrls" @change="onChangeIcon" />
- </t-drawer>
- </div>
- </t-space>
- </t-collapse-panel>
- <!-- <t-collapse-panel
- v-if="data.pen.props.custom"
- value="5"
- header="属性"
- >
- <t-space direction="vertical" size="small" class="w-full">
- <div v-for="item in data.pen.props.custom" class="form-item">
- <label :title="item.label">{{ item.label }}</label>
- <t-checkbox
- class="ml-8"
- v-if="item.type === 'bool'"
- v-model="data.pen[item.key]"
- @change="changeValue(item.key)"
- />
- <t-input-number
- class="w-full"
- v-else-if="item.type === 'number'"
- v-model.number="data.pen[item.key]"
- theme="column"
- :max="item.max"
- :min="item.min"
- @change="changeValue(item.key)"
- :placeholder="item.placeholder"
- />
- <t-color-picker
- class="w-full"
- v-else-if="item.type === 'color'"
- :enable-alpha="true"
- :recent-colors="null"
- format="CSS"
- :swatch-colors="defaultPureColor"
- :color-modes="['monochrome']"
- :show-primary-color-preview="false"
- v-model="data.pen[item.key]"
- @change="changeValue(item.key)"
- :placeholder="item.placeholder"
- />
- <t-select
- class="w-full"
- v-else-if="item.type === 'select'"
- size="small"
- :options="item.options"
- v-model="data.pen[item.key]"
- @change="changeValue(item.key)"
- :placeholder="item.placeholder"
- />
- <t-button
- v-else-if="item.type === 'code'"
- shape="square"
- variant="outline"
- style="width: 24px"
- @click="showPropsEdit(item)"
- >
- <t-icon name="ellipsis" slot="icon"
- /></t-button>
- <t-slider
- v-else-if="item.type === 'slider'"
- v-model="data.pen[item.key]"
- :min="0"
- :max="1"
- :step="0.01"
- @change="changeValue(item.key)"
- />
- <t-switch
- v-else-if="item.type === 'switch'"
- v-model="data.pen[item.key]"
- @change="changeValue(item.key)"
- />
- <t-input
- class="w-full"
- v-else
- v-model="data.pen[item.key]"
- @change="changeValue(item.key)"
- :placeholder="item.placeholder"
- />
- </div>
- </t-space>
- </t-collapse-panel> -->
- </t-collapse>
- <template v-if="!data.pen.externElement && data.pen.name !== 'image'&& data.pen.name !== 'gif'">
- <t-divider style="margin: -8px 0" />
- <div class="form-item px-16">
- <label>进度 </label>
- <t-slider
- v-model="data.pen.progress"
- :min="0"
- :max="1"
- :step="0.01"
- @change="changeValue('progress')"
- />
- <span class="ml-16" style="width: 50px; line-height: 30px">
- {{ data.pen.progress }}
- </span>
- </div>
- <div class="form-item" style="padding-left: 17px">
- <t-color-picker
- class="simple mr-25"
- format="CSS"
- :enable-alpha="true"
- :recent-colors="null"
- :swatch-colors="defaultPureColor"
- :color-modes="['monochrome']"
- :show-primary-color-preview="false"
- v-model="data.pen.progressColor"
- @change="changeValue('progressColor')"
- />
- <t-tooltip content="垂直进度" placement="top">
- <t-checkbox
- class="mr-25"
- v-model="data.pen.verticalProgress"
- @change="changeValue('verticalProgress')"
- style="width: 22px"
- />
- </t-tooltip>
- <t-tooltip content="反向进度" placement="top">
- <t-checkbox
- class="mr-25"
- v-model="data.pen.reverseProgress"
- @change="changeValue('reverseProgress')"
- style="width: 22px"
- />
- </t-tooltip>
- <t-tooltip content="进度渐变" placement="top">
- <t-checkbox
- class="mr-25"
- v-model="data.pen.temProgressFlag"
- @change="changetemProgressFlag(data.pen)"
- style="width: 22px"
- />
- </t-tooltip>
- <t-color-picker
- v-if="data.pen.temProgressFlag"
- class="simple"
- format="CSS"
- :swatch-colors="defaultGradientColor"
- :color-modes="['linear-gradient']"
- :show-primary-color-preview="false"
- :recent-colors="null"
- :enableAlpha="true"
- v-model="data.pen.progressGradientColors"
- @change="changeValue('progressGradientColors')"
- placeholder="无"
- />
- </div>
- </template>
- <t-divider style="margin: -8px 0" />
- <div class="form-item px-16" style="margin-top: -12px">
- <t-checkbox
- v-model="data.pen.flipX"
- @change="changeValue('flipX')"
- style="width: 90px"
- >
- 水平翻转
- </t-checkbox>
- <t-checkbox
- v-model="data.pen.flipY"
- @change="changeValue('flipY')"
- style="width: 90px"
- >
- 垂直翻转
- </t-checkbox>
- <label style="width: 50px">锚点半径</label>
- <input
- class="ml-4"
- v-model.number="data.pen.anchorRadius"
- style="width: 20px"
- @change="changeValue('anchorRadius')"
- placeholder="4"
- />
- </div>
- <t-divider style="margin: -8px 0" />
- <div class="form-item px-16" style="margin-top: -12px">
- <t-checkbox
- v-model="data.pen.disableRotate"
- @change="changeValue('disableRotate')"
- style="width: 90px"
- >
- 禁止旋转
- </t-checkbox>
- <t-checkbox
- v-model="data.pen.disableSize"
- @change="changeValue('disableSize')"
- style="width: 90px"
- >
- 禁止缩放
- </t-checkbox>
- <t-checkbox
- v-model="data.pen.disableAnchor"
- @change="changeValue('disableAnchor')"
- style="width: 90px"
- >
- 禁用锚点
- </t-checkbox>
- </div>
- <t-divider style="margin: -8px 0" />
- <div class="form-item px-16" style="margin-top: -12px">
- <label style="width: 60px">鼠标提示</label>
- <t-button
- shape="square"
- variant="outline"
- style="width: 24px"
- @click="showTooltip"
- >
- <ellipsis-icon slot="icon"/>
- <!-- <t-icon name="ellipsis" slot="icon" /> -->
- </t-button>
- </div>
- <t-dialog
- v-if="tooltipDialog.show"
- :visible="true"
- header="鼠标提示"
- @confirm="onOkTooltip"
- @close="tooltipDialog.show = false"
- :width="700"
- >
- <t-radio-group v-model="tooltipDialog.type">
- <t-radio value="1">文字</t-radio>
- <t-radio value="2">函数</t-radio>
- </t-radio-group>
- <div class="py-8">
- <CodeEditor
- v-show="tooltipDialog.type == 1"
- v-model="tooltipDialog.title"
- style="height: 300px"
- />
- <div v-show="tooltipDialog.type == 2">
- <div>function tooltip(pen) {</div>
- <CodeEditor
- v-model="tooltipDialog.titleFnJs"
- class="mt-4"
- style="height: 248px"
- />
- <div class="mt-4">}</div>
- </div>
- </div>
- <div class="gray" style="font-size: 12px">支持Markdown格式</div>
- </t-dialog>
- <t-dialog
- v-if="propsDialog.show"
- :visible="true"
- :header="propsDialog.header"
- @confirm="onOkPropsEdit"
- @close="propsDialog.show = false"
- :width="700"
- >
- <div class="py-8">
- <CodeEditor
- :json="true"
- :language="'json'"
- v-model="propsDialog.value"
- style="height: 300px"
- />
- </div>
- <div class="gray" style="font-size: 12px">
- {{ propsDialog.placeholder }}
- </div>
- </t-dialog>
- <t-space />
- </t-space>
- </t-tab-panel>
- <t-tab-panel :value="2" label="动画">
- <PenAnimates :pen="data.pen" />
- </t-tab-panel>
- <t-tab-panel :value="3" label="数据">
- <PenDatas :pen="data.pen" />
- </t-tab-panel>
- <t-tab-panel :value="4" label="交互">
- <PenEvents :key="data.key" :pen="data.pen" />
- </t-tab-panel>
- <t-tab-panel :value="5" label="结构">
- <ElementTree />
- </t-tab-panel>
- </t-tabs>
- </div>
- </template>
- <script lang="ts" setup>
- import { onBeforeMount, onUnmounted, reactive, ref, watch, computed } from 'vue';
- import CodeEditor from './common/CodeEditor.vue';
- import Iconfonts from './common/Iconfonts.vue';
- import PenAnimates from './PenAnimates.vue';
- import PenDatas from './PenDatas.vue';
- import PenEvents from './PenEvents.vue';
- import ElementTree from './ElementTree.vue';
- import { getCookie } from '@/services/cookie';
- import { useSelection } from '@/services/selections';
- import { autoSave, fonts, inTreePanel } from '@/services/common';
- import { updatePen } from './pen';
- import { MessagePlugin } from 'tdesign-vue-next';
- import { useUser } from '@/services/user';
- import { getter, queryURLParams, isDomShapes } from '@meta2d/core';
- import { defaultGradientColor, defaultPureColor, fromArrows, toArrows } from '@/services/defaults';
- import { getLe5le3d, getLe5leV, getLe5le2d } from '@/services/api';
- import { s8 } from '@/services/random';
- import { EllipsisIcon, LinkIcon, LinkUnlinkIcon, ChevronDownIcon, FormatVerticalAlignLeftIcon, FormatHorizontalAlignCenterIcon, FormatVerticalAlignCenterIcon, FormatVerticalAlignRightIcon, FormatHorizontalAlignTopIcon, FormatHorizontalAlignBottomIcon } from 'tdesign-icons-vue-next';
- const { user } = useUser();
- const headers = {
- Authorization: 'Bearer ' + (getCookie('token') || ''),
- };
- const updataData = { directory: '/大屏/图片/默认' };
- const uploadRef = ref();
- const data = reactive<any>({
- tab: 1,
- pen: {},
- rect: {},
- key: s8(),
- });
- const { selections } = useSelection();
- const tooltipDialog = reactive<any>({
- show: false,
- });
- const propsDialog = reactive<any>({
- show: false,
- });
- const iconsDrawer = reactive<any>({
- show: false,
- });
- const aligns = [
- {
- value: 'left',
- label: '左对齐',
- icon: '#l-align-left',
- },
- {
- value: 'center',
- label: '垂直居中对齐',
- icon: '#l-align-center',
- },
- {
- value: 'right',
- label: '右对齐',
- icon: '#l-align-right',
- },
- {
- value: 'top',
- label: '顶部对齐',
- icon: '#l-align-top',
- },
- {
- value: 'middle',
- label: '水平居中对齐',
- icon: '#l-align-middle',
- },
- {
- value: 'bottom',
- label: '底部对齐',
- icon: '#l-align-bottom',
- },
- ];
- const align = (align: string) => {
- meta2d.alignNodesV(align, meta2d.store.active);
- getRect();
- meta2d.render();
- };
- onBeforeMount(() => {
- if (inTreePanel.value) {
- data.tab = 5;
- }
- const d = meta2d.store.data as any;
- if (!d.groups) {
- d.groups = [];
- }
- if (!d.iconUrls) {
- d.iconUrls = [];
- }
- data.iconUrls = d.iconUrls;
- data.groups = d.groups;
- initPenData();
- meta2d.on('translatePens', getRect);
- meta2d.on('resizePens',detailResizePens);
- meta2d.on('rotatePens', getRect);
- });
- function initPenData() {
- data.key = s8(); //触发更新
- data.pen = selections.pen;
- if (!data.pen.props) {
- data.pen.props = {};
- }
- if (!data.pen.globalAlpha && data.pen.globalAlpha !== 0) {
- data.pen.globalAlpha = 1;
- }
- if (!data.pen.dash) {
- data.pen.dash = 0;
- }
- if (!data.pen.props.text) {
- if (data.pen.text || data.pen.name === 'text') {
- data.pen.props.text = true;
- }
- }
- if (!data.pen.props.image) {
- if (data.pen.image) {
- data.pen.props.image = true;
- }
- }
- if (!data.pen.props.icon) {
- if (data.pen.icon) {
- data.pen.props.icon = true;
- }
- }
- if (data.pen.image) {
- data.images = [
- {
- url: data.pen.image,
- },
- ];
- }
- if (!data.pen.tags) {
- data.pen.tags = [];
- }
- if (data.pen.bkType == undefined) {
- data.pen.bkType = 0;
- }
- if (data.pen.textType == undefined) {
- data.pen.textType = 0;
- }
- if (!data.pen.animations) {
- data.pen.animations = [];
- }
- if (!data.pen.whiteSpace) {
- data.pen.whiteSpace = 'break-all';
- }
- if (data.pen.ellipsis == undefined) {
- data.pen.ellipsis = false;
- }
- data.pen.shadow = !!data.pen.shadowColor;
- getRect();
- }
- const watcher = watch(() => selections.pen.id, initPenData);
- const getRect = () => {
- data.rect = meta2d.getPenRect(data.pen);
- };
- const detailResizePens = () => {
- getRect();
- updateTabBtnData();
- }
- const updateTabBtnData = () => {//更新tab按钮的宽高
- if(data.pen.name === 'tab') {
- const len = data.pen.data.length;
- const gap = data.pen.gap;
- const {width: w, height: h} = data.rect;
- let btnWidth = 0, btnHeight = 0;
- if (data.pen.direction == 'horizontal') {
- btnWidth = (w - (len + 1) * gap) / len;
- btnHeight = h - gap * 2;
- } else {
- btnWidth = w - gap * 2;
- btnHeight = (h - (len + 1) * gap) / len;
- }
- data.pen.btnWidth = btnWidth;
- data.pen.btnHeight = btnHeight;
- }
- }
- const decimalPlaces = (val: number) => {
- if (!val) {
- return 0;
- }
- return Math.round(+val * 100) / 100;
- };
- const decimalRound = (val: number) => {
- return Math.round(+val || 0);
- };
- const changeValue = (prop: string) => {
- if(prop.indexOf('radient')!==-1){
- let collect = document.querySelectorAll('[class^="t-color-picker"]')
- collect.forEach((i:HTMLElement)=> {
- if(!i.dataset.meta2dIgnore){
- i.dataset.meta2dIgnore = 'true';
- }
- })
- }
- if(prop === 'toGif'){
- if(data.pen.toGif){
- meta2d.setValue({id:data.pen.id,name:'gif'});
- }else{
- meta2d.setValue({id:data.pen.id,name:'image'});
- }
- return;
- }
- updatePen(data.pen, prop);
- selections.pen[prop] = getter(data.pen, prop);
- if (prop === 'iframe') {
- getThumbImg();
- }
- if(prop === 'image'){
- data.images = [
- {
- url: data.pen.image,
- },
- ];
- }
- };
- const getThumbImg = async () => {
- //改iframe地址后
- let arr = data.pen.iframe.split('?');
- let id = queryURLParams(arr[1]).id;
- if (!id) {
- return;
- }
- let projection = 'image,id,name';
- let res: any;
- if (arr[0].indexOf('2d.le5le') !== -1) {
- res = await getLe5le2d(id, projection);
- } else if (arr[0].indexOf('v.le5le') !== -1) {
- res = await getLe5leV(id, projection);
- } else if (arr[0].indexOf('3d.le5le') !== -1) {
- res = await getLe5le3d(id, projection);
- }
- if (res) {
- data.pen.thumbImg = res.image;
- }
- data.pen.onRenderPenRaw?.(data.pen);
- };
- const changeID = (value: any) => {
- if (!value) {
- initPenData();
- MessagePlugin.error('id 不能为空');
- return;
- }
- const oldID: string = data.pen.id;
- try {
- meta2d.changePenId(oldID, value);
- initPenData();
- } catch (error) {
- console.warn(error.message);
- MessagePlugin.error('id 修改失败,请检查 id 是否重复');
- return;
- }
- };
- const changeRectValue = (prop: string) => {
- data.rect.id = data.pen.id;
- data.rect.ratio = data.pen.ratio;
- updatePen(data.rect, prop);
- };
- const onFontPopupVisible = (val: boolean) => {
- data.fontFamilyPopupVisible = val;
- };
- const onFontFamily = (fontFamily: string) => {
- data.pen.fontFamily = fontFamily;
- data.fontFamilyPopupVisible = false;
- changeValue('fontFamily');
- };
- const beforeUpload = (file: any) => {
- // if (file.size > 5 * 1024 * 1024) {
- // MessagePlugin.warning('上传的图片不能大于5M');
- // return false;
- // }
- if (!(user && user.id)) {
- MessagePlugin.warning('请先登录!');
- return false;
- }
- return true;
- };
- const fileSuccessed = async (content: any) => {
- // meta2d.store.patchFlagsBackground = true;
- // meta2d.setBackgroundImage(content.response.url);
- // meta2d.store.patchFlagsBackground = true;
- data.pen.image = content.response.url || `/file${content.response.filename}`;
- updatePen(data.pen, 'image');
- meta2d.render();
- };
- const fileRemoved = () => {
- // meta2d.setBackgroundImage('');
- // meta2d.store.patchFlagsBackground = true;
- data.pen.image = '';
- updatePen(data.pen, 'image');
- meta2d.render();
- // data.background = [];
- };
- const upload = () => {
- uploadRef.value.triggerUpload();
- };
- const onSelectTag = (tag: string) => {
- data.tagPopupVisible = false;
- if (data.pen.tags.includes(tag)) {
- return;
- }
- data.pen.tags.push(tag);
- changeValue('tags');
- };
- const onChangeInputTag = (currentTags: any, context: any) => {
- const { trigger, index, item } = context;
- if (['tag-remove', 'backspace'].includes(trigger)) {
- data.pen.tags.splice(index, 1);
- }
- if (trigger === 'enter') {
- onSelectTag(item);
- const d = meta2d.store.data as any;
- if (!d.groups.includes(item)) {
- d.groups.push(item);
- data.groups = d.groups;
- }
- data.inputTag = '';
- }
- data.tagPopupVisible = false;
- };
- const showTooltip = () => {
- tooltipDialog.title = data.pen.title || '';
- tooltipDialog.titleFnJs =
- data.pen.titleFnJs || '// 例如:return `${pen.name}<br/>${pen.text}`;';
- tooltipDialog.type = data.pen.titleFnJs ? '2' : '1';
- tooltipDialog.show = true;
- };
- const onOkTooltip = () => {
- data.pen.titleFn = null;
- if (tooltipDialog.type === '1') {
- data.pen.title = tooltipDialog.title;
- data.pen.titleFnJs = '';
- } else {
- data.pen.title = '';
- data.pen.titleFnJs = tooltipDialog.titleFnJs;
- }
- tooltipDialog.show = false;
- };
- const showPropsEdit = (item: any) => {
- propsDialog.key = item.key;
- propsDialog.header = `${item.label}(${item.key})`;
- propsDialog.value = data.pen[item.key];
- propsDialog.placeholder = item.placeholder;
- propsDialog.show = true;
- };
- const onOkPropsEdit = () => {
- if (!propsDialog.value) {
- MessagePlugin.error('数据不满足json格式');
- return;
- }
- data.pen[propsDialog.key] = propsDialog.value;
- updatePen(data.pen, propsDialog.key);
- propsDialog.show = false;
- };
- const onChangeIcon = (params: any) => {
- Object.assign(data.pen, params);
- meta2d.setValue({
- id: data.pen.id,
- icon: params.icon,
- iconFamily: params.iconFamily,
- });
- autoSave(true);
- };
- const changetemProgressFlag = (pen: any) => {
- if (pen.temProgressFlag) {
- } else {
- pen.progressGradientColors = undefined;
- changeValue('progressGradientColors');
- }
- };
- const isDom = computed(() => {
- return isDomShapes.includes(data.pen.name) ||
- data.pen.name.endsWith('Dom') ||
- meta2d.store.options.domShapes.includes(data.pen.name)
- });
- onUnmounted(() => {
- watcher();
- meta2d.off('translatePens', getRect);
- meta2d.off('resizePens', detailResizePens);
- meta2d.off('rotatePens', getRect);
- });
- </script>
- <style lang="postcss" scoped>
- .props {
- .icons {
- display: flex;
- svg:hover {
- cursor: pointer;
- color: var(--color-primary);
- }
- .btn {
- font-size: 16px;
- margin-right: 16px;
- color: var(--color);
- }
- }
- }
- </style>
|