Graphics.vue 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408
  1. <template>
  2. <div class="graphics">
  3. <div class="group-asset">
  4. <t-radio-group
  5. v-model="activeAssets"
  6. @change="assetsChange"
  7. variant="primary-filled"
  8. >
  9. <t-radio-button value="system">系统资源</t-radio-button>
  10. <t-radio-button value="user">我的资源</t-radio-button>
  11. </t-radio-group>
  12. </div>
  13. <div class="groups-panel">
  14. <div class="groups">
  15. <div
  16. v-for="group in groups"
  17. :class="group.name === activedGroup ? 'active' : ''"
  18. @click="groupChange(group.name)"
  19. >
  20. <template v-if="group.type === 'iconfont'">
  21. <i class="l-icon" :class="group.icon"> </i>
  22. {{ group.name }}
  23. </template>
  24. <template v-else>
  25. <t-icon :name="group.icon" />
  26. {{ group.name }}
  27. </template>
  28. </div>
  29. </div>
  30. <div class="list" :class="groupType ? 'two-columns' : ''">
  31. <div class="input-search">
  32. <div class="btn">
  33. <!-- <t-icon name="search" /> -->
  34. <img src="/img/icon_search_gray.svg" />
  35. </div>
  36. <t-input
  37. v-model="search"
  38. @change="onSearch"
  39. @enter="onSearch"
  40. placeholder="搜索"
  41. />
  42. <div class="ml-16">
  43. <t-tooltip content="展开/折叠">
  44. <menu-fold-icon class="hover"
  45. style="font-size: 16px"
  46. @click="onFold"/>
  47. <!-- <t-icon
  48. name="menu-fold"
  49. class="hover"
  50. style="font-size: 16px"
  51. @click="onFold"
  52. /> -->
  53. </t-tooltip>
  54. </div>
  55. </div>
  56. <div v-if="loading" class="center mt-16">
  57. <t-loading text="加载中..." size="small" :indicator="false" />
  58. </div>
  59. <template v-else>
  60. <div
  61. v-if="
  62. activedGroup === '图片' ||
  63. (activeAssets === 'user' &&
  64. (activedGroup === '方案' || activedGroup === '模板' || activedGroup === '组件'))
  65. "
  66. class="px-16 mt-12 mb-8 ml-4"
  67. >
  68. <a @click="onCreateFolder">+ 新建文件夹</a>
  69. </div>
  70. <t-collapse v-model="activedPanels[activedGroup]">
  71. <t-collapse-panel
  72. :value="item.name"
  73. v-for="item in subGroups"
  74. :key="item.name"
  75. >
  76. <template #header>
  77. <div class="flex middle">
  78. <div v-if="item.edited" @click.stop>
  79. <t-input
  80. v-model="item.label"
  81. style="width: 140px"
  82. @blur="createFoder"
  83. @enter="createFoder"
  84. @keyup="onKeyHeader"
  85. :autofocus="true"
  86. />
  87. </div>
  88. <div v-else>
  89. {{ item.name }}
  90. </div>
  91. </div>
  92. </template>
  93. <template #headerRightContent>
  94. <t-space size="small" @click.stop tabindex="0">
  95. <t-upload
  96. v-if="item.canEdited && activedGroup === '图片'"
  97. action="/api/image/upload"
  98. accept="image/*"
  99. :headers="headers"
  100. :data="{
  101. directory: `/大屏/${activedGroup}/${item.name}`,
  102. conflict:'new'
  103. }"
  104. :auto-upload="true"
  105. :upload-all-files-in-one-request="false"
  106. :before-upload="beforeUpload"
  107. @selectChange="onSelectFiles(item)"
  108. allowUploadDuplicateFile
  109. @success="fileSuccessed"
  110. theme="custom"
  111. >
  112. <image-icon class="hover" />
  113. <!-- <t-icon name="image" class="hover" /> -->
  114. </t-upload>
  115. <template v-if="item.canEdited">
  116. <add-icon v-if="['组件', '方案', '模板'].includes(activedGroup)" class="hover"
  117. @click="onAdd(item)"/>
  118. <!-- <t-icon
  119. v-if="['组件', '方案', '模板'].includes(activedGroup)"
  120. name="add"
  121. class="hover"
  122. @click="onAdd(item)"
  123. /> -->
  124. <edit-icon class="hover"
  125. @click="onEditHeader(item)"/>
  126. <!-- <t-icon
  127. name="edit"
  128. class="hover"
  129. @click="onEditHeader(item)"
  130. /> -->
  131. <t-popconfirm
  132. content="确认删除该文件夹吗"
  133. placement="left"
  134. @confirm="delFolder(item)"
  135. >
  136. <delete-icon class="hover"/>
  137. <!-- <t-icon name="delete" class="hover" /> -->
  138. </t-popconfirm>
  139. </template>
  140. </t-space>
  141. </template>
  142. <template v-for="elem in item.list">
  143. <div
  144. v-show="elem.visible !== false"
  145. class="graphic"
  146. :draggable="true"
  147. @dragstart="dragStart($event, elem)"
  148. @click.stop="dragStart($event, elem)"
  149. @dblclick.stop="open(elem)"
  150. @contextmenu="onContextMenu($event, item, elem)"
  151. @touchstart.passive="
  152. dragStart($event, elem)
  153. "
  154. >
  155. <!-- img 路径这样拼凑避免更新后路径一致图片使用缓存不更新 -->
  156. <t-image
  157. v-if="!elem.svg && elem.image"
  158. :src="elem.image + '?' + Math.random()"
  159. :lazy="true"
  160. fit="contain"
  161. @load="loadImage(elem)"
  162. />
  163. <div class="svg-box" v-else-if="elem.svg" v-html="elem.svg" />
  164. <svg v-else class="l-icon" aria-hidden="true">
  165. <use :xlink:href="'#' + elem.icon"></use>
  166. </svg>
  167. <p :title="elem.name">{{ elem.name }}</p>
  168. <div class="price" v-if="elem.price > 0">
  169. ¥{{ elem.price }}
  170. </div>
  171. </div>
  172. </template>
  173. <div
  174. v-if="!item.list || !item.list.length"
  175. class="gray"
  176. style="white-space: nowrap; margin-left: 34px"
  177. >
  178. 暂无数据
  179. </div>
  180. </t-collapse-panel>
  181. </t-collapse>
  182. </template>
  183. <div class="div-manage" v-if="['图元', '素材'].includes(activedGroup)">
  184. <t-button
  185. class="w-full"
  186. @click="onManageGraphic"
  187. style="height: 30px"
  188. >
  189. {{ activedGroup }}管理
  190. </t-button>
  191. </div>
  192. </div>
  193. </div>
  194. <div
  195. class="context-menu-box"
  196. ref="contextmenuDom"
  197. v-show="contextmenu.visible"
  198. tabindex="0"
  199. :style="contextmenu.style"
  200. @blur="hideContextmenu"
  201. >
  202. <t-menu
  203. class="context-menu"
  204. @change="onMenu"
  205. expandType="popup"
  206. v-model="contextmenu.activeValue"
  207. >
  208. <t-submenu
  209. value="move"
  210. title="移动到"
  211. v-if="contextmenu.subMenus.length"
  212. :disabled="contextmenu.component['3d']"
  213. >
  214. <t-menu-item
  215. v-for="subMenu in contextmenu.subMenus"
  216. :value="'move:' + subMenu.name"
  217. >
  218. {{ subMenu.name }}
  219. </t-menu-item>
  220. </t-submenu>
  221. <t-menu-item value="edit" :disabled="activedGroup === '图片'">
  222. 编辑
  223. </t-menu-item>
  224. <t-menu-item value="del" :disabled="contextmenu.component['3d']">
  225. 删除
  226. </t-menu-item>
  227. </t-menu>
  228. </div>
  229. <t-dialog
  230. v-if="delDialog.show"
  231. theme="danger"
  232. header="删除"
  233. :visible="true"
  234. @close="delDialog.show = false"
  235. @confirm="delComponent"
  236. >
  237. 确定删除该数据吗?删除后不可恢复!
  238. </t-dialog>
  239. <t-dialog
  240. v-if="chargeDialog.show"
  241. :header="chargeDialog.data.name"
  242. :visible="true"
  243. @close="chargeDialog.show = false"
  244. width="70%"
  245. :top="8"
  246. >
  247. <t-image :src="chargeDialog.data.image" />
  248. <template #footer>
  249. <div class="flex between" style="margin-top: -7px">
  250. <p>付费项目,购买后查看并使用</p>
  251. <div>
  252. <label>金额:</label>
  253. <label class="bland">¥{{ chargeDialog.data.price }}</label>
  254. <t-button class="primary ml-12" @click="onSubmitOrder"
  255. >购买</t-button
  256. >
  257. </div>
  258. </div>
  259. </template>
  260. </t-dialog>
  261. <t-dialog
  262. v-if="wechatPayDialog.show"
  263. v-model:visible="wechatPayDialog.show"
  264. class="pay-dialog"
  265. header="乐吾乐收银台"
  266. :close-on-overlay-click="false"
  267. :top="95"
  268. :width="700"
  269. confirm-btn="支付完成"
  270. :cancel-btn="null"
  271. @close="getPayResult"
  272. >
  273. <WechatPay
  274. :order="wechatPayDialog.order"
  275. :code-url="wechatPayDialog.order.codeUrl"
  276. @success="onChargeSuccess"
  277. />
  278. </t-dialog>
  279. <t-dialog
  280. class="dialog-manage"
  281. :header="activedGroup + '管理'"
  282. :visible="manageDialog.show"
  283. @close="manageDialog.show = false"
  284. @confirm="manageConfirm"
  285. width="90%"
  286. :top="8"
  287. >
  288. <div class="manage-body">
  289. <t-collapse v-model="activedPanels[activedGroup]">
  290. <t-collapse-panel
  291. :value="item.name"
  292. v-for="item in manageDialog.data"
  293. :key="item.name"
  294. >
  295. <template #header>
  296. <div class="flex middle">
  297. {{ item.name }}
  298. </div>
  299. </template>
  300. <template v-for="elem in item.list">
  301. <div
  302. :style="{
  303. background: elem.visible ? '#42516c' : '',
  304. }"
  305. class="graphic manage-list"
  306. >
  307. <t-checkbox v-model:checked="elem.visible"></t-checkbox>
  308. <t-image
  309. :src="elem.image"
  310. :lazy="true"
  311. fit="contain"
  312. @load="loadImage(elem)"
  313. />
  314. </div>
  315. </template>
  316. <div
  317. v-if="!item.list || !item.list.length"
  318. class="gray"
  319. style="white-space: nowrap; margin-left: 34px"
  320. >
  321. 暂无数据
  322. </div>
  323. </t-collapse-panel>
  324. </t-collapse>
  325. </div>
  326. </t-dialog>
  327. </div>
  328. </template>
  329. <script lang="ts" setup>
  330. import { onMounted, onUnmounted, reactive, ref } from 'vue';
  331. import { useRouter } from 'vue-router';
  332. import { MessagePlugin } from 'tdesign-vue-next';
  333. import axios from 'axios';
  334. import { deepClone } from '@meta2d/core';
  335. import { cases, shapes, formComponents, templates } from '@/services/defaults';
  336. import { charts } from '@/services/echarts';
  337. import { getFolders, makeSvg } from '@/services/png';
  338. import {
  339. addCollection,
  340. delImage,
  341. getComponentsList,
  342. getLe5leV,
  343. updateCollection,
  344. getCollectionList,
  345. imageDrive,
  346. } from '@/services/api';
  347. import { convertPen } from '@/services/upgrade';
  348. import { isGif } from '@/services/utils';
  349. import { autoSave, delAttrs, blank, useFolder } from '@/services/common';
  350. import { debounce, throttle } from '@/services/debouce';
  351. import { searchObjectPinyin } from '@/services/pinyin';
  352. import { getCookie } from '@/services/cookie';
  353. import { parseSvg } from '@meta2d/svg';
  354. import WechatPay from './WechatPay.vue';
  355. import { filename } from '@/services/file';
  356. import { useUser } from '@/services/user';
  357. import { iframeCustom } from '@/services/defaults';
  358. import { getLe5le3d } from '@/services/api';
  359. import { useSelection } from '@/services/selections';
  360. import localforage from 'localforage';
  361. import { MenuFoldIcon, ImageIcon, AddIcon, EditIcon, DeleteIcon} from 'tdesign-icons-vue-next';
  362. const { user } = useUser();
  363. const { setFolder, getFolder } = useFolder();
  364. const router = useRouter();
  365. const { select } = useSelection();
  366. const activedGroup = ref('');
  367. const activeAssets = ref('system');
  368. let groups = reactive([]);
  369. const systemGroups = [
  370. {
  371. icon: 'desktop',
  372. name: '方案',
  373. key: '',
  374. class: 'tow',
  375. },
  376. {
  377. icon: 'root-list',
  378. name: '模板',
  379. key: '',
  380. },
  381. {
  382. icon: 'l-zujian',
  383. name: '组件',
  384. key: 'chart',
  385. type: 'iconfont',
  386. },
  387. {
  388. icon: 'chart',
  389. name: '图表',
  390. key: 'chart',
  391. },
  392. {
  393. icon: 'image',
  394. name: '素材',
  395. key: '',
  396. },
  397. {
  398. icon: 'control-platform',
  399. name: '图元',
  400. key: '',
  401. },
  402. {
  403. icon: 'relativity',
  404. name: '控件',
  405. key: '',
  406. },
  407. {
  408. icon: 'chart-bubble',
  409. name: '图形',
  410. key: 'shape',
  411. },
  412. // {
  413. // icon: 'app',
  414. // name: '我的',
  415. // key: '',
  416. // },
  417. ];
  418. const userGroups = [
  419. {
  420. icon: 'desktop',
  421. name: '方案',
  422. key: '',
  423. class: 'tow',
  424. },
  425. {
  426. icon: 'root-list',
  427. name: '模板',
  428. key: '',
  429. },
  430. {
  431. icon: 'l-zujian',
  432. name: '组件',
  433. key: 'chart',
  434. type: 'iconfont',
  435. },
  436. {
  437. icon: 'image',
  438. name: '图片',
  439. key: '',
  440. },
  441. {
  442. icon: 'control-platform',
  443. name: '3D',
  444. key: '',
  445. },
  446. ];
  447. groups = systemGroups;
  448. const subGroups = ref<any[]>([]);
  449. const groupType = ref(0);
  450. const activedPanels = reactive<any>({});
  451. const caseCaches = [];
  452. const templateCaches = [];
  453. const componentCaches = [];
  454. const materials = [];
  455. const pngs = [];
  456. const components = [
  457. {
  458. name:"默认",
  459. list:[]
  460. }
  461. ];
  462. let dropped = false;
  463. const chargeDialog = reactive<any>({});
  464. const wechatPayDialog = reactive<any>({
  465. show: false,
  466. });
  467. const manageDialog = reactive<any>({
  468. name: '',
  469. data: [],
  470. show: false,
  471. });
  472. const search = ref('');
  473. const loading = ref(false);
  474. const headers = {
  475. Authorization: 'Bearer ' + (getCookie('token') || ''),
  476. };
  477. const updataData = { directory: '/大屏/默认' };
  478. let lastName = '方案';
  479. let userLastName = '方案';
  480. const assetsChange = (value) => {
  481. if (value === 'system') {
  482. groups = systemGroups;
  483. activedGroup.value = lastName;
  484. } else if (value === 'user') {
  485. groups = userGroups;
  486. activedGroup.value = userLastName;
  487. }
  488. groupChange(activedGroup.value);
  489. };
  490. const groupChange = async (name: string) => {
  491. activedGroup.value = name;
  492. groupType.value = 0;
  493. switch (name) {
  494. case '方案':
  495. if (activeAssets.value === 'system') {
  496. if (!caseCaches.length) {
  497. loading.value = true;
  498. caseCaches.push(...(await getCaseProjects('系统方案',1)));
  499. for (const group of cases) {
  500. group.list = [];
  501. for (const item of caseCaches) {
  502. if (item.case === group.name) {
  503. group.list.push(item);
  504. }
  505. }
  506. }
  507. loading.value = false;
  508. }
  509. groupType.value = 1;
  510. subGroups.value = cases;
  511. lastName = name;
  512. } else {
  513. // subGroups.value = await getUserProjects('le5leV');
  514. // groupType.value = 1;
  515. // await getPrivateProjects('le5leV');
  516. // userLastName = name;
  517. //用户方案
  518. subGroups.value = await getCollectionImageList('方案', 'v',1);
  519. groupType.value = 1;
  520. userLastName = name;
  521. }
  522. break;
  523. case '模板':
  524. if (activeAssets.value === 'system') {
  525. if (!templateCaches.length) {
  526. loading.value = true;
  527. templateCaches.push(...(await getCaseProjects('系统模板',2)));
  528. for (const group of templates) {
  529. group.list = [];
  530. for (const item of templateCaches) {
  531. if (item.case === group.name) {
  532. group.list.push(item);
  533. }
  534. }
  535. }
  536. loading.value = false;
  537. }
  538. groupType.value = 1;
  539. subGroups.value = templates;
  540. lastName = name;
  541. } else {
  542. // subGroups.value = await getUserProjects('le5leV-template');
  543. // groupType.value = 1;
  544. // await getPrivateProjects('le5leV-template');
  545. // userLastName = name;
  546. subGroups.value = await getCollectionImageList('模板', 'v',2);
  547. groupType.value = 1;
  548. userLastName = name;
  549. }
  550. break;
  551. case '图表':
  552. subGroups.value = charts;
  553. lastName = name;
  554. break;
  555. case '控件':
  556. subGroups.value = formComponents;
  557. lastName = name;
  558. break;
  559. case '素材':
  560. groupType.value = 1;
  561. if (!materials.length) {
  562. loading.value = true;
  563. materials.push(...(await getFolders('v/material')));
  564. loading.value = false;
  565. const _materials: string = await localforage.getItem(
  566. 'le5leV-materials'
  567. );
  568. if (_materials) {
  569. Object.assign(materials, JSON.parse(_materials));
  570. }
  571. }
  572. subGroups.value = materials;
  573. lastName = name;
  574. break;
  575. case '图元':
  576. if (!pngs.length) {
  577. loading.value = true;
  578. pngs.push(...(await getFolders('png')));
  579. pngs.push(...(await getFolders('svg', true)));
  580. loading.value = false;
  581. const _pngs: string = await localforage.getItem('le5leV-pngs');
  582. if (_pngs) {
  583. Object.assign(pngs, JSON.parse(_pngs));
  584. }
  585. }
  586. subGroups.value = pngs;
  587. lastName = name;
  588. break;
  589. case '图形':
  590. subGroups.value = shapes;
  591. lastName = name;
  592. break;
  593. case '组件':
  594. if (activeAssets.value === 'system') {
  595. if (!componentCaches.length) {
  596. loading.value = true;
  597. componentCaches.push(...(await getCaseProjects('系统组件',1)));
  598. loading.value = false;
  599. for (const component of componentCaches) {
  600. if(component.case){
  601. let group = components.filter((item)=>{item.name===component.case});
  602. if(group&&group.length){
  603. group[0].list.push(component);
  604. }else{
  605. components.push({
  606. name:component.case,
  607. list:[component]
  608. })
  609. }
  610. }else{
  611. components[0].list.push(component);
  612. }
  613. }
  614. }
  615. groupType.value = 1;
  616. subGroups.value = components;
  617. lastName = name;
  618. } else {
  619. // subGroups.value = await getUserComponents();
  620. // groupType.value = 1;
  621. // await getPrivateGraphics();
  622. // userLastName = name;
  623. subGroups.value = await getCollectionImageList(
  624. '组件',
  625. 'v.component',
  626. 1
  627. );
  628. groupType.value = 1;
  629. userLastName = name;
  630. }
  631. break;
  632. case '图片':
  633. loading.value = true;
  634. subGroups.value = await getImageList();
  635. loading.value = false;
  636. userLastName = name;
  637. break;
  638. case '3D':
  639. subGroups.value = [
  640. {
  641. name: '3D',
  642. list: [],
  643. },
  644. ];
  645. groupType.value = 1;
  646. await getPrivateGraphics();
  647. userLastName = name;
  648. break;
  649. }
  650. // if (!activedPanels[name]) {
  651. activedPanels[name] = [];
  652. for (const item of subGroups.value) {
  653. activedPanels[name].push(item.name);
  654. }
  655. // }
  656. // searchGraphics();
  657. };
  658. // TODO 获取方案文件
  659. //获取方案文件夹
  660. const getCollectionImageList = async (name?: string, collection?: string, userFlag?:number) => {
  661. //1. 获取网盘文件夹
  662. const fullpath = `/大屏/${name}`;
  663. let ret: { list: any[] } = await axios.post('/api/directory/list', {
  664. fullpath,
  665. });
  666. if (!ret) {
  667. return [];
  668. }
  669. let list = [];
  670. for (let i of ret.list) {
  671. if (
  672. i.fullpath !== `${fullpath}/默认` &&
  673. i.fullpath.split('/').length === 4
  674. ) {
  675. //不取当前文件夹
  676. list.push(i);
  677. }
  678. }
  679. const data = {
  680. // directory: `/大屏/${name}`,
  681. // query: {
  682. // // folder: '',
  683. // tags: name !== '组件' ? name : undefined,
  684. // },
  685. userFlag,
  686. projection: {
  687. image: 1,
  688. id: 1,
  689. name: 1,
  690. tags: 1,
  691. folder: 1,
  692. component: 1,
  693. filename: 1,
  694. },
  695. };
  696. const config = {
  697. params: {
  698. current: 1,
  699. pageSize: 1000,
  700. },
  701. };
  702. //2.请求所有图纸/组件数据
  703. const res: any = await getCollectionList(collection, data, config);
  704. //3.将数据对应到云盘文件夹
  705. const results = [];
  706. const resultsMap = {
  707. 默认: [],
  708. };
  709. for (const item of list) {
  710. let folder = item.fullpath.split('/')[3];
  711. if (!resultsMap[folder]) {
  712. resultsMap[folder] = [];
  713. }
  714. }
  715. for (const item of res.list) {
  716. if(collection === 'v.component') {
  717. item.component = true;
  718. }
  719. if (item.folder && resultsMap[item.folder]) {
  720. resultsMap[item.folder].push(item);
  721. } else {
  722. resultsMap['默认'].push(item);
  723. }
  724. }
  725. for (const item of list) {
  726. let folder = item.fullpath.split('/')[3];
  727. results.push({
  728. name: folder,
  729. canEdited: true,
  730. id: item.id,
  731. list: resultsMap[folder],
  732. });
  733. }
  734. results.push({
  735. name: '默认',
  736. list: resultsMap['默认'],
  737. });
  738. return results;
  739. };
  740. const getImageList = async () => {
  741. let ret: { list: any[] } = await axios.post('/api/directory/list', {
  742. fullpath: '/大屏/图片',
  743. });
  744. if (!ret) {
  745. return [];
  746. }
  747. let list = [];
  748. for (let i of ret.list) {
  749. if (i.fullpath.split('/').length === 4) {
  750. //不取当前文件夹
  751. list.push(i);
  752. }
  753. }
  754. return await Promise.all(
  755. list.map(async (item) => {
  756. let secondDir = item.fullpath.split('/');
  757. const _ret: { list: any[]; total: number } = await axios.post(
  758. '/api/file/list',
  759. {
  760. type: '图片',
  761. directory: item.fullpath,
  762. },
  763. {
  764. params: {
  765. current: 1,
  766. pageSize: 100,
  767. },
  768. }
  769. );
  770. let list = _ret.list.map((_item) => {
  771. return {
  772. ..._item,
  773. image: _item.url || `/file${_item.filename}`,
  774. visible: true,
  775. folder: item.fullpath,
  776. id: _item.id || _item._id,
  777. };
  778. });
  779. return {
  780. name: secondDir[3],
  781. id: item.id || item._id,
  782. canEdited: secondDir[3] !== '默认',
  783. list: list,
  784. };
  785. })
  786. );
  787. };
  788. const getCaseProjects = async (name: string,systemFlag = 1, current = 1, pageSize = 1000) => {
  789. const query: any = { tags: name };
  790. let collection = name == '系统组件' ? 'v.component' : 'v';
  791. const ret: any = await axios.post(
  792. `/api/data/${collection}/list`,
  793. {
  794. // query: {
  795. // tags: "系统方案"
  796. // },
  797. //shared: true,
  798. // projection: "id,_id,name,image,price,case",
  799. // sort: { createdAt: 1 },
  800. systemFlag
  801. },
  802. {
  803. params: {
  804. current,
  805. pageSize,
  806. },
  807. }
  808. );
  809. if (!ret) {
  810. return [];
  811. }
  812. for (const item of ret.list) {
  813. if (!item.id) {
  814. item.id = item._id;
  815. }
  816. if(name !== '系统组件'){
  817. item.draggable = false;
  818. }else{
  819. item.component = true;
  820. }
  821. }
  822. return ret.list;
  823. };
  824. // const getUserProjects = async (name: string, current = 1, pageSize = 1000) => {
  825. // const query: any = { tags: name };
  826. // const ret: any = await axios.post(
  827. // '/api/data/le5leV/list',
  828. // {
  829. // query,
  830. // projection: {
  831. // id: 1,
  832. // _id: 1,
  833. // name: 1,
  834. // image: 1,
  835. // price: 1,
  836. // case: 1,
  837. // folder: 1,
  838. // },
  839. // sort: { createdAt: 1 },
  840. // },
  841. // {
  842. // params: {
  843. // current,
  844. // pageSize,
  845. // },
  846. // }
  847. // );
  848. // if (!ret) {
  849. // return [];
  850. // }
  851. // for (const item of ret.list) {
  852. // if (!item.id) {
  853. // item.id = item._id;
  854. // }
  855. // item.draggable = false;
  856. // }
  857. // return ret.list;
  858. // };
  859. const getPrivateGroups = async () => {
  860. const list = [
  861. {
  862. name: '默认',
  863. list: [],
  864. },
  865. ];
  866. const config = {
  867. params: {
  868. current: 1,
  869. pageSize: 1000,
  870. },
  871. };
  872. let ret: any = await axios.post(
  873. '/api/data/folders/list',
  874. {
  875. projection: {
  876. image: 1,
  877. _id: 1,
  878. name: 1,
  879. list: 1,
  880. },
  881. // query: {
  882. // type: `v-components`,
  883. // },
  884. sort: { createdAt: 1 },
  885. },
  886. config
  887. );
  888. if (!ret) {
  889. ret = { list: [] };
  890. }
  891. for (const item of ret.list) {
  892. item.canEdited = true;
  893. }
  894. list.push(...ret.list);
  895. list.push({
  896. name: '3D',
  897. list: [],
  898. });
  899. return list;
  900. };
  901. const getUserComponents = async () => {
  902. const list = [
  903. {
  904. name: '默认',
  905. list: [],
  906. },
  907. ];
  908. const config = {
  909. params: {
  910. current: 1,
  911. pageSize: 1000,
  912. },
  913. };
  914. let ret: any = await axios.post(
  915. '/api/data/folders/list',
  916. {
  917. projection: {
  918. image: 1,
  919. _id: 1,
  920. name: 1,
  921. list: 1,
  922. },
  923. // query: {
  924. // type: `v.component`,
  925. // },
  926. sort: { createdAt: 1 },
  927. },
  928. config
  929. );
  930. if (!ret) {
  931. ret = { list: [] };
  932. }
  933. for (const item of ret.list) {
  934. item.canEdited = true;
  935. }
  936. list.push(...ret.list);
  937. return list;
  938. };
  939. const getUserProjects = async (type: string) => {
  940. const list = [
  941. {
  942. name: '默认',
  943. list: [],
  944. },
  945. ];
  946. const config = {
  947. params: {
  948. current: 1,
  949. pageSize: 1000,
  950. },
  951. };
  952. let ret: any = await axios.post(
  953. '/api/data/folders/list',
  954. {
  955. projection: {
  956. image: 1,
  957. _id: 1,
  958. name: 1,
  959. list: 1,
  960. },
  961. // query: {
  962. // type,
  963. // },
  964. sort: { createdAt: 1 },
  965. },
  966. config
  967. );
  968. if (!ret) {
  969. ret = { list: [] };
  970. }
  971. for (const item of ret.list) {
  972. item.canEdited = true;
  973. }
  974. list.push(...ret.list);
  975. return list;
  976. };
  977. const getPrivateProjects = async (type: string) => {
  978. for (const item of subGroups.value) {
  979. if (!item.list.length) {
  980. item.loading = true;
  981. //TODO 方案/模板分类
  982. if (item.name === '默认') {
  983. const data = {
  984. // query: {
  985. // folder: '',
  986. // tags: type === 'v-template' ? '模板' : '方案',
  987. // },
  988. projection: {
  989. image: 1,
  990. _id: 1,
  991. name: 1,
  992. tags: 1,
  993. },
  994. };
  995. const config = {
  996. params: {
  997. current: 1,
  998. pageSize: 1000,
  999. },
  1000. };
  1001. const res: any = await getCollectionList('v', data, config);
  1002. if (res?.list) {
  1003. // res.list.forEach((item) => {
  1004. // item.draggable = false;
  1005. // })
  1006. item.list = res.list;
  1007. // if (type === 'le5leV') {
  1008. // //过滤模板
  1009. // // item.list = res.list.filter((item) => !item.isTemplate);
  1010. // }
  1011. }
  1012. }
  1013. item.loading = false;
  1014. }
  1015. }
  1016. };
  1017. const dragStart = async (event: DragEvent | MouseEvent|TouchEvent, item: any) => {
  1018. // event.stopPropagation();
  1019. if (!item) {
  1020. return;
  1021. }
  1022. meta2d.canvas.addCaches = [];
  1023. dropped = false;
  1024. let data = null;
  1025. const id = item.id || item._id;
  1026. let isAsync: boolean;
  1027. if (
  1028. activeAssets.value === 'user' &&
  1029. ['方案', '模板'].includes(activedGroup.value)
  1030. ) {
  1031. if (!item._id) {
  1032. item._id = item.id;
  1033. }
  1034. item.draggable = false;
  1035. data = item.data || item;
  1036. } else if (item.draggable === false) {
  1037. //方案
  1038. data = item.data || item;
  1039. } else if (item['3d']) {
  1040. const res: any = await getLe5le3d(item.id || item._id, {
  1041. image: 1,
  1042. _id: 1,
  1043. name: 1,
  1044. });
  1045. data = {
  1046. name: 'iframe',
  1047. x: 0,
  1048. y: 0,
  1049. tags: ['meta3d'],
  1050. zIndex: 1,
  1051. operationalRect: {
  1052. x: 0.2,
  1053. y: 0.2,
  1054. height: 0.8,
  1055. width: 0.6,
  1056. },
  1057. props: {
  1058. custom: iframeCustom,
  1059. },
  1060. width: meta2d.store.data.width || meta2d.store.options.width,
  1061. height: meta2d.store.data.height || meta2d.store.options.height,
  1062. externElement: true,
  1063. thumbImg: res.image,
  1064. iframe: location.origin+'/view/3d/?id=' + (item.id || item._id),
  1065. };
  1066. } else if (item.component) {
  1067. // 默认
  1068. if (!item.componentDatas && !item.componentData) {
  1069. isAsync = true;
  1070. const ret: any = await axios.post(`/api/data/v.component/get`, {
  1071. id,
  1072. });
  1073. item.componentDatas = ret.data.componentDatas;
  1074. item.componentData = ret.data.componentData;
  1075. }
  1076. if (item.componentData) {
  1077. const pens = convertPen([item.componentData]);
  1078. data = deepClone(pens);
  1079. } else if (item.componentDatas) {
  1080. data = deepClone(item.componentDatas);
  1081. }
  1082. } else if (item.data) {
  1083. // 普通图元
  1084. data = item.data;
  1085. } else if (item.image) {
  1086. // 拖拽图片
  1087. let target: any = event.target;
  1088. target.children[0] && (target = target.children[0].children[0]);
  1089. // firefox naturalWidth svg 图片 可能是 0
  1090. const width = target.naturalWidth || target.width;
  1091. const height = target.naturalHeight || target.height;
  1092. const [name, lockedOnCombine] = await isGif(item.image)
  1093. ? ['gif', 0]
  1094. : ['image', undefined];
  1095. data = {
  1096. name,
  1097. width,
  1098. height,
  1099. isBottom:true,
  1100. image: item.image,
  1101. imageRatio: true,
  1102. ratio: true,
  1103. lockedOnCombine,
  1104. };
  1105. } else {
  1106. return;
  1107. }
  1108. if (!Array.isArray(data)) {
  1109. data = deepClone([data]);
  1110. }
  1111. !dropped && (meta2d.canvas.addCaches = data);
  1112. if (event instanceof DragEvent) {
  1113. event.dataTransfer.setData(
  1114. 'Meta2d',
  1115. isAsync ? undefined : JSON.stringify(data)
  1116. );
  1117. }
  1118. };
  1119. const dragstart = (event: any) => {
  1120. event.target.style.opacity = 0.5;
  1121. };
  1122. const dragend = (event: any) => {
  1123. event.target.style.opacity = 1;
  1124. };
  1125. const open = async (item: any) => {
  1126. if (!item || item.draggable !== false) {
  1127. return;
  1128. }
  1129. const ret: any = await getLe5leV(item._id || item.id);
  1130. if (!ret) {
  1131. if (item.price > 0) {
  1132. chargeDialog.data = item;
  1133. chargeDialog.show = true;
  1134. }
  1135. return;
  1136. }
  1137. if (activeAssets.value === 'user') {
  1138. router.push({
  1139. path: '/',
  1140. query: {
  1141. r: Date.now() + '',
  1142. id:item.id || item._id,
  1143. },
  1144. });
  1145. } else {
  1146. sessionStorage.setItem('opening', '1');
  1147. router.push({
  1148. path: '/',
  1149. query: {
  1150. r: Date.now() + '',
  1151. },
  1152. });
  1153. for (const k of delAttrs) {
  1154. delete ret[k];
  1155. }
  1156. autoSave();
  1157. meta2d.open(ret.data);
  1158. meta2d.fitView();
  1159. }
  1160. select();
  1161. };
  1162. const getPrivateGraphics = async () => {
  1163. for (const item of subGroups.value) {
  1164. if (!item.list.length) {
  1165. item.loading = true;
  1166. if (item.name === '默认') {
  1167. const data = {
  1168. // query: { folder: '' },
  1169. projection: {
  1170. image: 1,
  1171. _id: 1,
  1172. name: 1,
  1173. component: 1,
  1174. },
  1175. };
  1176. const config = {
  1177. params: {
  1178. current: 1,
  1179. pageSize: 1000,
  1180. },
  1181. };
  1182. const res: any = await getComponentsList(data, config);
  1183. if (res?.list) {
  1184. item.list = res.list;
  1185. }
  1186. } else if (item.name === '3D') {
  1187. const data = {
  1188. projection: {
  1189. image: 1,
  1190. _id: 1,
  1191. name: 1,
  1192. },
  1193. };
  1194. const config = {
  1195. params: {
  1196. current: 1,
  1197. pageSize: 1000,
  1198. },
  1199. };
  1200. const res: any = await axios.post(
  1201. '/api/data/3d/list',
  1202. data,
  1203. config
  1204. );
  1205. if (res?.list) {
  1206. for (const item of res.list) {
  1207. item['3d'] = true;
  1208. item['draggable'] = true;
  1209. }
  1210. item.list = res.list;
  1211. }
  1212. }
  1213. item.loading = false;
  1214. }
  1215. }
  1216. };
  1217. const editedFolder = ref<any>(undefined);
  1218. const onCreateFolder = () => {
  1219. activedPanels[activedGroup.value].splice(
  1220. 0,
  1221. activedPanels[activedGroup.value].length
  1222. );
  1223. editedFolder.value = {
  1224. _id: '',
  1225. name: '',
  1226. label: '新建文件夹',
  1227. list: [],
  1228. edited: true,
  1229. canEdited: true,
  1230. };
  1231. subGroups.value.splice(subGroups.value.length - 1, 0, editedFolder.value);
  1232. };
  1233. const createFoder = async () => {
  1234. if (!editedFolder.value.label) {
  1235. return;
  1236. }
  1237. if (editedFolder.value.label === editedFolder.value.name) {
  1238. editedFolder.value.edited = false;
  1239. return;
  1240. }
  1241. const found = subGroups.value.findIndex(
  1242. (group: any) => group.name === editedFolder.value.label
  1243. );
  1244. if (found >= 0) {
  1245. MessagePlugin.error('已经存在相同名称文件夹');
  1246. return;
  1247. }
  1248. if (activeAssets.value !== 'user') {
  1249. return;
  1250. }
  1251. if (editedFolder.value.id || editedFolder.value._id) {
  1252. const ret: any = await axios.post('/api/directory/update', {
  1253. oldFullpath: `/大屏/${activedGroup.value}/` + editedFolder.value.oldLabel,
  1254. newFullpath: `/大屏/${activedGroup.value}/` + editedFolder.value.label,
  1255. });
  1256. if (ret) {
  1257. editedFolder.value.name = editedFolder.value.label;
  1258. editedFolder.value.edited = false;
  1259. }
  1260. //更新图纸的folder
  1261. if (['组件', '方案', '模板'].includes(activedGroup.value)) {
  1262. const collection =
  1263. activedGroup.value === '组件' ? 'v.component' : 'v';
  1264. editedFolder.value.list?.forEach(async (item) => {
  1265. item.folder = editedFolder.value.label;
  1266. await updateCollection(collection, {
  1267. id: item.id || item._id,
  1268. folder: editedFolder.value.label,
  1269. });
  1270. });
  1271. }
  1272. } else {
  1273. const ret: any = await axios.post('/api/directory/add', {
  1274. fullpath: `/大屏/${activedGroup.value}/` + editedFolder.value.label,
  1275. });
  1276. if (ret) {
  1277. editedFolder.value.name = editedFolder.value.label;
  1278. editedFolder.value.id = ret.id;
  1279. editedFolder.value.edited = false;
  1280. }
  1281. }
  1282. };
  1283. const _createFoder = async () => {
  1284. if (!editedFolder.value.label) {
  1285. return;
  1286. }
  1287. if (editedFolder.value.label === editedFolder.value.name) {
  1288. editedFolder.value.edited = false;
  1289. return;
  1290. }
  1291. const found = subGroups.value.findIndex(
  1292. (group: any) => group.name === editedFolder.value.label
  1293. );
  1294. if (found >= 0) {
  1295. MessagePlugin.error('已经存在相同名称文件夹');
  1296. return;
  1297. }
  1298. if (activeAssets.value !== 'user') {
  1299. return;
  1300. }
  1301. if (['组件', '方案', '模板'].includes(activedGroup.value)) {
  1302. if (editedFolder.value._id) {
  1303. const ret: any = await axios.post('/api/data/folders/update', {
  1304. _id: editedFolder.value._id,
  1305. name: editedFolder.value.label,
  1306. });
  1307. if (ret) {
  1308. editedFolder.value.name = editedFolder.value.label;
  1309. editedFolder.value.edited = false;
  1310. }
  1311. } else {
  1312. let type =
  1313. activedGroup.value === '组件'
  1314. ? 'v.component'
  1315. : activedGroup.value === '模板'
  1316. ? 'v-template'
  1317. : 'v';
  1318. const ret: any = await axios.post('/api/data/folders/add', {
  1319. name: editedFolder.value.label,
  1320. type,
  1321. list: [],
  1322. });
  1323. if (ret) {
  1324. editedFolder.value.name = editedFolder.value.label;
  1325. editedFolder.value._id = ret._id;
  1326. editedFolder.value.edited = false;
  1327. }
  1328. }
  1329. } else if (activedGroup.value === '图片') {
  1330. if (editedFolder.value._id) {
  1331. const ret: any = await axios.post('/api/directory/update', {
  1332. oldFullpath: '/大屏/' + editedFolder.value.oldLabel,
  1333. newFullpath: '/大屏/' + editedFolder.value.label,
  1334. });
  1335. if (ret) {
  1336. editedFolder.value.name = editedFolder.value.label;
  1337. editedFolder.value.edited = false;
  1338. }
  1339. } else {
  1340. const ret: any = await axios.post('/api/directory/add', {
  1341. fullpath: '/大屏/' + editedFolder.value.label,
  1342. });
  1343. if (ret) {
  1344. editedFolder.value.name = editedFolder.value.label;
  1345. editedFolder.value._id = ret.id || ret._id;
  1346. editedFolder.value.edited = false;
  1347. }
  1348. }
  1349. }
  1350. };
  1351. const onEditHeader = (item: any) => {
  1352. item.label = item.name;
  1353. item.edited = true;
  1354. item.oldLabel = item.name;
  1355. editedFolder.value = item;
  1356. };
  1357. const onAdd = (item: any) => {
  1358. blank();
  1359. if (activedGroup.value === '方案') {
  1360. item.vType = 'v';
  1361. } else if (activedGroup.value === '模板') {
  1362. item.vType = 'v-template';
  1363. } else if (activedGroup.value === '组件') {
  1364. item.vType = 'v.component';
  1365. }
  1366. setFolder(item);
  1367. const query: any = {
  1368. r: Date.now() + '',
  1369. folder: item.name,
  1370. tags: activedGroup.value,
  1371. };
  1372. if (activedGroup.value === '组件') {
  1373. query.c = 1;
  1374. }
  1375. router.push({
  1376. path: '/',
  1377. query,
  1378. });
  1379. activeAssets.value = 'system';
  1380. assetsChange('system');
  1381. // meta2d.open({
  1382. // name: '新建项目',
  1383. // pens: [],
  1384. // enableMock: true,
  1385. // tags: activedGroup.value,
  1386. // folder: item.name,
  1387. // } as any);
  1388. };
  1389. const onKeyHeader = (text: string, event: any) => {
  1390. if (event.e.key === 'Escape') {
  1391. editedFolder.value.edited = false;
  1392. }
  1393. };
  1394. // 默认右键菜单
  1395. const contextmenu = reactive<any>({
  1396. visible: false,
  1397. style: {},
  1398. // 子分类
  1399. group: undefined,
  1400. // 组件图纸
  1401. component: {},
  1402. // 右键二级子菜单
  1403. subMenus: [],
  1404. });
  1405. const contextmenuDom = ref<any>(null);
  1406. const onContextMenu = async (e: MouseEvent, group: any, item: any) => {
  1407. e.preventDefault();
  1408. e.stopPropagation();
  1409. if (activeAssets.value === 'system') {
  1410. return;
  1411. }
  1412. contextmenu.group = group;
  1413. contextmenu.component = item;
  1414. if (document.body.clientHeight - e.clientY < 128) {
  1415. contextmenu.style = {
  1416. left: e.clientX + 'px',
  1417. bottom: '4px',
  1418. };
  1419. } else {
  1420. contextmenu.style = {
  1421. left: e.clientX + 'px',
  1422. top: e.clientY + 'px',
  1423. };
  1424. }
  1425. contextmenu.subMenus = [];
  1426. for (const elem of subGroups.value) {
  1427. if (elem === group || elem.name === '默认' || elem.name === '3D') {
  1428. continue;
  1429. }
  1430. contextmenu.subMenus.push(elem);
  1431. }
  1432. contextmenu.visible = true;
  1433. setTimeout(() => {
  1434. if (contextmenuDom.value) {
  1435. contextmenuDom.value.focus();
  1436. }
  1437. }, 500);
  1438. };
  1439. const delDialog = reactive<any>({
  1440. contextmenuObj: {},
  1441. });
  1442. // TODO 右键菜单移动图纸
  1443. const onMenu = async (val: string) => {
  1444. const id = contextmenu.component.id || contextmenu.component._id;
  1445. setTimeout(() => {
  1446. contextmenu.group = '';
  1447. contextmenu.component = {};
  1448. contextmenu.subMenus = [];
  1449. }, 500);
  1450. switch (val) {
  1451. case 'edit':
  1452. if (
  1453. contextmenu.component.tags &&
  1454. contextmenu.component.tags.includes('svg')
  1455. ) {
  1456. MessagePlugin.warning('解析的svg图元不允许编辑!');
  1457. hideContextmenu();
  1458. contextmenu.activeValue = 0;
  1459. return;
  1460. }
  1461. // if (contextmenu.component.component) {
  1462. if (activedGroup.value == '组件') {
  1463. autoSave();
  1464. router.push({
  1465. path: '/',
  1466. query: {
  1467. id,
  1468. c: 1,
  1469. r: Date.now() + '',
  1470. },
  1471. });
  1472. } else if (contextmenu.component['3d']) {
  1473. let url = 'https://3d.le5le.com/?id=';
  1474. if (window.url3D) {
  1475. url = window.url3D;
  1476. }
  1477. window.open(url + id, '_blank');
  1478. } else {
  1479. if ((contextmenu.group.id||contextmenu.group._id) && contextmenu.group.name !== '默认') {
  1480. setFolder(contextmenu.group);
  1481. }
  1482. autoSave();
  1483. //文件夹
  1484. router.push({
  1485. path: '/',
  1486. query: {
  1487. id,
  1488. r: Date.now() + '',
  1489. },
  1490. });
  1491. }
  1492. hideContextmenu();
  1493. break;
  1494. case 'del':
  1495. delDialog.show = true;
  1496. Object.assign(delDialog.contextmenuObj, contextmenu);
  1497. break;
  1498. default:
  1499. if (val.indexOf('move:')) {
  1500. return;
  1501. }
  1502. val = val.replace('move:', '');
  1503. const group = contextmenu.subMenus.find(
  1504. (element: any) => element.name === val
  1505. );
  1506. if (!group) {
  1507. return;
  1508. }
  1509. // 前端: 添加组件到目标文件夹
  1510. let data: any;
  1511. if (contextmenu.component.component) {
  1512. data = {
  1513. component: true,
  1514. image: contextmenu.component.image,
  1515. name: contextmenu.component.name,
  1516. visible: true,
  1517. _id: contextmenu.component._id || contextmenu.component.id,
  1518. filename: contextmenu.component.filename,
  1519. };
  1520. } else {
  1521. data = {
  1522. image: contextmenu.component.image,
  1523. name: contextmenu.component.name,
  1524. tags: contextmenu.component.tags,
  1525. visible: true,
  1526. _id: contextmenu.component._id || contextmenu.component.id,
  1527. filename: contextmenu.component.filename,
  1528. };
  1529. }
  1530. group.list.push(data);
  1531. // 前端:从源文件夹移出组件
  1532. contextmenu.group.list.forEach((item: any, index: number, arr: any[]) => {
  1533. if (id === item._id || id === item.id) {
  1534. arr.splice(index, 1);
  1535. }
  1536. });
  1537. if (activedGroup.value !== '图片') {
  1538. let collection = activedGroup.value === '组件'
  1539. ? 'v.component'
  1540. : 'v';
  1541. // 更新后端组件信息
  1542. let ret = await updateCollection(collection, {
  1543. id,
  1544. folder: val === '默认' ? '' : val,
  1545. });
  1546. if (!ret) {
  1547. return;
  1548. }
  1549. }
  1550. // // 更新后端源文件夹列表
  1551. // if (contextmenu.group.name !== '默认') {
  1552. // await axios.post('/api/data/folders/update', {
  1553. // _id: contextmenu.group._id || contextmenu.group.id,
  1554. // list: contextmenu.group.list,
  1555. // });
  1556. // }
  1557. // 更新后端目标文件夹列表
  1558. // if (group.name !== '默认') {
  1559. // await axios.post('/api/data/folders/update', {
  1560. // _id: group._id || group.id,
  1561. // list: group.list,
  1562. // });
  1563. // }
  1564. let filename: string =
  1565. contextmenu.component.filename || contextmenu.component.image;
  1566. if (imageDrive && filename.startsWith(imageDrive)) {
  1567. filename = filename.slice(imageDrive.length);
  1568. }
  1569. let fullname: string =
  1570. contextmenu.component.filename || contextmenu.component.image;
  1571. //更新缩略图位置
  1572. // await axios.post('/api/files/update', {
  1573. // filenames: [filename],
  1574. // 'metadata.directory': `/大屏/${activedGroup.value}/${val || '默认'}`,
  1575. // });
  1576. // 原接口路径是 /api/file/{fullname}
  1577. // 因为img的路径中包含file,所以做如下拼接
  1578. await axios.patch(`/api${fullname}`, {
  1579. // filenames: [filename],
  1580. directory: `/大屏/${activedGroup.value}/${val || '默认'}`,
  1581. });
  1582. break;
  1583. }
  1584. contextmenu.activeValue = 0;
  1585. };
  1586. const hideContextmenu = () => {
  1587. contextmenu.visible = false;
  1588. };
  1589. const _delComponent = async () => {
  1590. // const id = contextmenu.component._id || contextmenu.component.id;
  1591. if (['组件', '方案', '模板'].includes(activedGroup.value)) {
  1592. let collection = delDialog.contextmenuObj.component.component
  1593. ? 'v.component'
  1594. : 'v';
  1595. const id =
  1596. delDialog.contextmenuObj.component._id ||
  1597. delDialog.contextmenuObj.component.id;
  1598. try {
  1599. await axios.post(`/api/data/${collection}/delete`, {
  1600. id,
  1601. });
  1602. } catch (e) {
  1603. console.error(e);
  1604. return;
  1605. }
  1606. //删除缩略图
  1607. if (delDialog.contextmenuObj.component.image) {
  1608. await delImage(delDialog.contextmenuObj.component.image);
  1609. }
  1610. // 前端:从源文件夹移出组件
  1611. delDialog.contextmenuObj.group.list.forEach(
  1612. (item: any, index: number, arr: any[]) => {
  1613. if (id === item._id || id === item.id) {
  1614. arr.splice(index, 1);
  1615. }
  1616. }
  1617. );
  1618. // 更新后端源文件夹列表
  1619. if (delDialog.contextmenuObj.group.name !== '默认') {
  1620. await axios.post('/api/data/folders/update', {
  1621. _id:
  1622. delDialog.contextmenuObj.group._id ||
  1623. delDialog.contextmenuObj.group.id,
  1624. list: delDialog.contextmenuObj.group.list,
  1625. });
  1626. }
  1627. } else {
  1628. const id =
  1629. delDialog.contextmenuObj.component._id ||
  1630. delDialog.contextmenuObj.component.id;
  1631. delDialog.contextmenuObj.group.list.forEach(
  1632. (item: any, index: number, arr: any[]) => {
  1633. if (id && (id === item._id || id === item.id)) {
  1634. arr.splice(index, 1);
  1635. }
  1636. if (!id) {
  1637. if (item.url === delDialog.contextmenuObj.component.url) {
  1638. arr.splice(index, 1);
  1639. }
  1640. }
  1641. }
  1642. );
  1643. await axios.post(`/api/files/delete`, {
  1644. fullnames: [delDialog.contextmenuObj.component.filename],
  1645. physically: true,
  1646. });
  1647. }
  1648. delDialog.show = false;
  1649. delDialog.contextmenuObj = {};
  1650. MessagePlugin.success('删除成功');
  1651. };
  1652. const delComponent = async () => {
  1653. // const id = contextmenu.component._id || contextmenu.component.id;
  1654. if (['组件', '方案', '模板'].includes(activedGroup.value)) {
  1655. // let collection = delDialog.contextmenuObj.component.component
  1656. // ? 'v.component'
  1657. // : 'v';
  1658. let collection = '';
  1659. if(activedGroup.value == '组件') {
  1660. collection = 'v.component'
  1661. } else {
  1662. collection = 'v'
  1663. }
  1664. const id =
  1665. delDialog.contextmenuObj.component._id ||
  1666. delDialog.contextmenuObj.component.id;
  1667. try {
  1668. await axios.post(`/api/data/${collection}/delete`, {
  1669. id,
  1670. });
  1671. } catch (e) {
  1672. console.error(e);
  1673. return;
  1674. }
  1675. // 前端:从源文件夹移出组件
  1676. delDialog.contextmenuObj.group.list.forEach(
  1677. (item: any, index: number, arr: any[]) => {
  1678. if (id === item._id || id === item.id) {
  1679. arr.splice(index, 1);
  1680. }
  1681. }
  1682. );
  1683. } else {
  1684. const id =
  1685. delDialog.contextmenuObj.component._id ||
  1686. delDialog.contextmenuObj.component.id;
  1687. delDialog.contextmenuObj.group.list.forEach(
  1688. (item: any, index: number, arr: any[]) => {
  1689. if (id && (id === item.id || id === item._id)) {
  1690. arr.splice(index, 1);
  1691. }
  1692. if (!id) {
  1693. if (item.url === delDialog.contextmenuObj.component.url) {
  1694. arr.splice(index, 1);
  1695. }
  1696. }
  1697. }
  1698. );
  1699. }
  1700. let fullname: string =
  1701. delDialog.contextmenuObj.component.fullname ||
  1702. delDialog.contextmenuObj.component.image;
  1703. if (imageDrive && fullname.startsWith(imageDrive)) {
  1704. fullname = fullname.slice(imageDrive.length);
  1705. }
  1706. if(fullname.startsWith('/file')) {
  1707. fullname = fullname.slice('/file'.length);
  1708. }
  1709. await axios.post(`/api/files/delete`, {
  1710. fullnames: [fullname],
  1711. physically: false,
  1712. });
  1713. delDialog.show = false;
  1714. delDialog.contextmenuObj = {};
  1715. MessagePlugin.success('删除成功');
  1716. };
  1717. const drop = (obj: any) => {
  1718. dropped = true;
  1719. if (obj) {
  1720. Array.isArray(obj) && open(obj[0]);
  1721. } else {
  1722. MessagePlugin.warning('正在请求网络数据中,请稍后重试');
  1723. }
  1724. };
  1725. const onSubmitOrder = async () => {
  1726. const result: any = await axios.post('/api/order/datas/submit', {
  1727. collection: 'v',
  1728. id: chargeDialog.data.id||chargeDialog.data._id,
  1729. });
  1730. if (result) {
  1731. wechatPayDialog.order = result;
  1732. wechatPayDialog.show = true;
  1733. }
  1734. };
  1735. const getPayResult = async () => {
  1736. const result: { state: number } = await axios.post('/api/order/pay/state', {
  1737. id: wechatPayDialog.order.id || wechatPayDialog.order._id,
  1738. });
  1739. if (result && result.state) {
  1740. return true;
  1741. }
  1742. };
  1743. const onChargeSuccess = () => {
  1744. MessagePlugin.success('支付成功!');
  1745. wechatPayDialog.show = false;
  1746. chargeDialog.show = false;
  1747. };
  1748. const onSearch = () => {
  1749. debounce(searchGraphics, 300);
  1750. };
  1751. const searchGraphics = async () => {
  1752. if (search.value) {
  1753. activedPanels[activedGroup.value].splice(
  1754. 0,
  1755. activedPanels[activedGroup.value].length
  1756. );
  1757. }
  1758. for (const group of subGroups.value) {
  1759. for (const item of group.list) {
  1760. if (search.value) {
  1761. item.visible = searchObjectPinyin(item, 'name', search.value);
  1762. } else {
  1763. item.visible = true;
  1764. }
  1765. }
  1766. if (search.value) {
  1767. activedPanels[activedGroup.value].push(group.name);
  1768. }
  1769. }
  1770. };
  1771. const onFold = () => {
  1772. if (!activedPanels[activedGroup.value]) {
  1773. return;
  1774. }
  1775. if (activedPanels[activedGroup.value].length) {
  1776. activedPanels[activedGroup.value] = [];
  1777. } else {
  1778. activedPanels[activedGroup.value] = [];
  1779. for (const item of subGroups.value) {
  1780. activedPanels[activedGroup.value].push(item.name);
  1781. }
  1782. }
  1783. };
  1784. const loadImage = (elem: any) => {
  1785. if (elem.isSvg) {
  1786. makeSvg(elem);
  1787. if (activedGroup.value === '图元') {
  1788. throttle(renderPngGroup, 100);
  1789. }
  1790. }
  1791. };
  1792. const renderPngGroup = () => {
  1793. subGroups.value = pngs;
  1794. };
  1795. let uploadGroup: any;
  1796. const onSelectFiles = (item: any) => {
  1797. uploadGroup = item;
  1798. };
  1799. const beforeUpload = (file: any) => {
  1800. if (!(user && user.id)) {
  1801. MessagePlugin.warning('请先登录!');
  1802. return false;
  1803. }
  1804. return true;
  1805. };
  1806. /*
  1807. * @description 根据上传的文件处理为meta2d能够识别的内容
  1808. * */
  1809. function processFileObj(fileObj, c) {
  1810. return new Promise((resolve) => {
  1811. if (fileObj.name.endsWith('.svg')) {
  1812. let fileReader = new FileReader();
  1813. fileReader.readAsText(fileObj.raw);
  1814. fileReader.onload = async () => {
  1815. let svgText = fileReader.result;
  1816. c.componentDatas = parseSvg(svgText as string);
  1817. c.component = true;
  1818. c.tags = ['svg'];
  1819. resolve(c);
  1820. };
  1821. } else {
  1822. // 除了svg 其他一律按照图片处理,这样是否会有问题?
  1823. resolve(c);
  1824. }
  1825. });
  1826. }
  1827. const fileSuccessed = async (content: any) => {
  1828. // 组件中去掉了上传图片入口
  1829. // if (activedGroup.value === '组件') {
  1830. // const c: any = {
  1831. // name: filename(content.file.name),
  1832. // image:
  1833. // content.response.url ||
  1834. // content.response.metadata.url ||
  1835. // `/file${content.response.filename}`,
  1836. // folder: uploadGroup.name === '默认' ? '' : uploadGroup.name,
  1837. // };
  1838. // let rst = await processFileObj(
  1839. // { raw: content.file.raw, name: content.file.name },
  1840. // c
  1841. // );
  1842. // const ret: any = await addCollection('v.component', rst);
  1843. // c._id = ret._id || ret.id;
  1844. // if (ret && uploadGroup.name !== '默认') {
  1845. // if (!uploadGroup.list) {
  1846. // uploadGroup.list = [];
  1847. // }
  1848. // uploadGroup.list.push(c);
  1849. // await axios.post('/api/data/folders/update', {
  1850. // _id: uploadGroup._id || uploadGroup.id,
  1851. // list: uploadGroup.list,
  1852. // });
  1853. // } else {
  1854. // if (!uploadGroup.list) {
  1855. // uploadGroup.list = [];
  1856. // }
  1857. // uploadGroup.list.push(c);
  1858. // }
  1859. // uploadGroup.list.push(c);
  1860. // } else if (activedGroup.value === '图片') {
  1861. uploadGroup.list.push({
  1862. ...content.response,
  1863. image:
  1864. content.response.url ||
  1865. content.response.metadata.url ||
  1866. `/file${content.response.filename}`,
  1867. visible: true,
  1868. folder: content.response.directory || content.response.metadata.directory,
  1869. });
  1870. // }
  1871. MessagePlugin.success('上传成功');
  1872. };
  1873. const delFolder = async (item: any) => {
  1874. if (item.list?.length) {
  1875. MessagePlugin.error('文件夹不为空!');
  1876. return;
  1877. }
  1878. const id = item.id || item._id;
  1879. let ret: any;
  1880. if (activeAssets.value !== 'user') {
  1881. return;
  1882. }
  1883. // if (['组件', '方案', '模板'].includes(activedGroup.value)) {
  1884. // ret = await axios.post('/api/data/folders/delete', {
  1885. // id,
  1886. // });
  1887. // } else if (activedGroup.value === '图片') {
  1888. // ret = await axios.post('/api/directory/delete', {
  1889. // fullpaths: [`/大屏/${item.name}`],
  1890. // });
  1891. // }
  1892. ret = await axios.post('/api/directory/delete', {
  1893. fullpaths: [`/大屏/${activedGroup.value}/${item.name}`],
  1894. physically: true
  1895. });
  1896. if (ret) {
  1897. const i = subGroups.value.findIndex(
  1898. (elem: any) => id === elem._id || id === elem.id
  1899. );
  1900. i >= 0 && subGroups.value.splice(i, 1);
  1901. }
  1902. };
  1903. const reloadCurrent = () => {
  1904. groupChange(activedGroup.value);
  1905. };
  1906. const updateAfterSave = (e) => {
  1907. if (activeAssets.value === 'user') {
  1908. if (e === 'v.component' && activedGroup.value === '组件') {
  1909. groupChange('组件');
  1910. } else if (e === 'v-template' && activedGroup.value === '模板') {
  1911. groupChange('模板');
  1912. } else if (e === '' && activedGroup.value === '方案') {
  1913. groupChange('方案');
  1914. }
  1915. }
  1916. };
  1917. const onManageGraphic = () => {
  1918. if (activedGroup.value === '素材') {
  1919. manageDialog.data = deepClone(materials);
  1920. } else if (activedGroup.value === '图元') {
  1921. manageDialog.data = deepClone(pngs);
  1922. }
  1923. manageDialog.show = true;
  1924. };
  1925. const manageConfirm = () => {
  1926. //TODO 后续存放到后端 目前本地存储
  1927. if (activedGroup.value === '素材') {
  1928. localforage.setItem('le5leV-materials', JSON.stringify(manageDialog.data));
  1929. materials.length = 0;
  1930. materials.push(...manageDialog.data);
  1931. } else if (activedGroup.value === '图元') {
  1932. localforage.setItem('le5leV-pngs', JSON.stringify(manageDialog.data));
  1933. pngs.length = 0;
  1934. pngs.push(...manageDialog.data);
  1935. }
  1936. subGroups.value = manageDialog.data;
  1937. manageDialog.show = false;
  1938. };
  1939. onMounted(() => {
  1940. groupChange('方案');
  1941. document.addEventListener('dragstart', dragstart, false);
  1942. document.addEventListener('dragend', dragend, false);
  1943. setTimeout(() => {
  1944. meta2d.on('drop', drop);
  1945. meta2d.on('logout', reloadCurrent);
  1946. meta2d.on('business-save', updateAfterSave);
  1947. meta2d.on('business-assets', changeAssets);
  1948. }, 2000);
  1949. });
  1950. const changeAssets = (e)=>{
  1951. if(e){
  1952. activeAssets.value = 'system';
  1953. assetsChange( activeAssets.value);
  1954. }
  1955. }
  1956. onUnmounted(() => {
  1957. document.removeEventListener('dragstart', dragstart);
  1958. document.removeEventListener('dragend', dragend);
  1959. meta2d.off('drop', drop);
  1960. meta2d.off('logout', reloadCurrent);
  1961. meta2d.off('business-save', updateAfterSave);
  1962. meta2d.off('business-assets', changeAssets);
  1963. });
  1964. </script>
  1965. <style lang="postcss" scoped>
  1966. .graphics {
  1967. display: flex;
  1968. flex-direction: column;
  1969. background-color: var(--color-background);
  1970. z-index: 3;
  1971. .group-asset {
  1972. height: 40px;
  1973. justify-content: center;
  1974. align-items: center;
  1975. display: flex;
  1976. .t-radio-group.t-radio-group--filled {
  1977. padding: 0px;
  1978. height: 30px;
  1979. }
  1980. :deep(.t-radio-button__label) {
  1981. margin: auto;
  1982. }
  1983. .t-radio-button {
  1984. width: 120px;
  1985. height: 100%;
  1986. color: #fff;
  1987. &:hover {
  1988. color: var(--color-primary);
  1989. }
  1990. &.t-is-checked {
  1991. background-color: var(--color-primary) !important;
  1992. color: #fff !important;
  1993. }
  1994. }
  1995. }
  1996. .groups-panel {
  1997. display: grid;
  1998. grid-template-columns: 50px 1fr;
  1999. border-top: 1px solid var(--color-background-input);
  2000. flex-grow: 1;
  2001. overflow-y: auto;
  2002. font-size: 12px;
  2003. z-index: 7;
  2004. .groups {
  2005. & > div {
  2006. display: flex;
  2007. flex-direction: column;
  2008. align-items: center;
  2009. padding: 16px 4px;
  2010. line-height: 1;
  2011. cursor: pointer;
  2012. .t-icon {
  2013. font-size: 20px;
  2014. margin-bottom: 8px;
  2015. }
  2016. .l-icon {
  2017. font-size: 24px;
  2018. margin-bottom: 8px;
  2019. }
  2020. &:hover {
  2021. color: var(--color-primary);
  2022. }
  2023. }
  2024. .active {
  2025. background-color: var(--color-background-active);
  2026. color: var(--color-primary);
  2027. border-left: 2px solid var(--color-primary);
  2028. }
  2029. }
  2030. .list {
  2031. overflow-y: auto;
  2032. max-height: calc(100vh - 80px);
  2033. background-color: var(--color-background-active);
  2034. /* padding-top: 8px; */
  2035. .input-search {
  2036. flex-shrink: 0;
  2037. /* height: 40px; */
  2038. position: sticky;
  2039. top: 0px;
  2040. z-index: 10;
  2041. padding: 16px;
  2042. color: #878f9c;
  2043. margin-top: -10px;
  2044. .btn {
  2045. background: #fff0;
  2046. img {
  2047. background-color: #fff0;
  2048. margin-top: 9px;
  2049. }
  2050. /* .t-icon {
  2051. background: #fff0;
  2052. } */
  2053. }
  2054. }
  2055. .div-manage {
  2056. position: sticky;
  2057. bottom: 2px;
  2058. z-index: 10;
  2059. margin-top: 800px;
  2060. }
  2061. * {
  2062. background-color: var(--color-background-active);
  2063. }
  2064. :deep(.t-collapse) {
  2065. /* min-height: 100vh; */
  2066. border: none;
  2067. }
  2068. :deep(.t-collapse-panel__header) {
  2069. border: none;
  2070. font-size: 12px;
  2071. font-weight: 400;
  2072. padding: 8px 8px 8px 16px;
  2073. & > .t-space {
  2074. display: none;
  2075. }
  2076. & > .t-space:focus {
  2077. display: inline-flex;
  2078. }
  2079. &:hover .t-collapse-panel__icon,
  2080. &:hover > .flex {
  2081. color: var(--color-primary);
  2082. }
  2083. .t-collapse-panel__icon,
  2084. .t-collapse-panel__icon * {
  2085. transition: none;
  2086. }
  2087. .t-icon {
  2088. font-size: 13px;
  2089. }
  2090. }
  2091. :deep(.t-collapse-panel__wrapper:hover) {
  2092. .t-collapse-panel__header > .t-space {
  2093. display: inline-flex;
  2094. }
  2095. }
  2096. :deep(.t-collapse-panel__body) {
  2097. border: none;
  2098. }
  2099. :deep(.t-collapse-panel__content) {
  2100. background-color: var(--color-background-active);
  2101. padding: 4px 4px 20px 4px;
  2102. display: grid;
  2103. grid-template-columns: 1fr 1fr 1fr;
  2104. grid-row-gap: 12px;
  2105. }
  2106. :deep(.t-loading--center) {
  2107. width: 100px;
  2108. .t-loading__text {
  2109. margin-left: 8px;
  2110. height: 24px;
  2111. }
  2112. }
  2113. :deep(.t-image__error) {
  2114. .t-space-item:last-child {
  2115. display: none;
  2116. }
  2117. }
  2118. :deep(.t-image__loading) {
  2119. .t-space-item:last-child {
  2120. display: none;
  2121. }
  2122. }
  2123. .graphic {
  2124. position: relative;
  2125. padding: 10px 0;
  2126. border-radius: 2px;
  2127. border: 1px solid transparent;
  2128. &:hover {
  2129. cursor: pointer;
  2130. border-color: var(--color-primary);
  2131. }
  2132. p {
  2133. margin-top: 10px;
  2134. padding: 0 8px;
  2135. text-align: center;
  2136. font-size: 12px;
  2137. height: 12px;
  2138. line-height: 1;
  2139. overflow: hidden;
  2140. text-overflow: ellipsis;
  2141. display: -webkit-box;
  2142. -webkit-line-clamp: 1;
  2143. word-break: break-all;
  2144. -webkit-box-orient: vertical;
  2145. }
  2146. .t-image__wrapper {
  2147. height: 32px;
  2148. width: 32px;
  2149. margin: auto;
  2150. :deep(.t-image) {
  2151. border-radius: 2px;
  2152. }
  2153. }
  2154. svg {
  2155. color: var(--color);
  2156. height: 32px;
  2157. width: 100%;
  2158. margin: auto;
  2159. }
  2160. .svg-box {
  2161. height: 32px;
  2162. width: 32px;
  2163. margin-left: calc(50% - 16px);
  2164. margin-top: 10px;
  2165. margin-bottom: 10px;
  2166. &:deep(svg) {
  2167. height: 100%;
  2168. width: 100%;
  2169. .cls-1 {
  2170. stroke: var(--color) !important;
  2171. stroke-width: 4px;
  2172. fill: none;
  2173. stroke-dasharray: none;
  2174. opacity: 1;
  2175. }
  2176. }
  2177. }
  2178. .price {
  2179. position: absolute;
  2180. top: 8px;
  2181. right: 8px;
  2182. display: inline-block;
  2183. z-index: 1;
  2184. border-radius: 2px;
  2185. background-color: #ff400060;
  2186. color: var(--color-bland);
  2187. font-size: 10px;
  2188. line-height: 1;
  2189. padding: 3px;
  2190. }
  2191. }
  2192. }
  2193. .two-columns {
  2194. :deep(.t-collapse-panel__content) {
  2195. grid-template-columns: 1fr 1fr;
  2196. }
  2197. .graphic {
  2198. .t-image__wrapper {
  2199. width: 100px;
  2200. height: 56.25px;
  2201. background-color: '#162030';
  2202. }
  2203. }
  2204. }
  2205. }
  2206. .context-menu-box {
  2207. position: fixed;
  2208. z-index: 200;
  2209. & > div {
  2210. width: 140px !important;
  2211. position: static;
  2212. }
  2213. :deep(.t-menu) {
  2214. .t-menu__item {
  2215. &.t-is-opened {
  2216. background-color: var(--color-background-popup-hover);
  2217. transition: none !important;
  2218. }
  2219. }
  2220. .t-fake-arrow {
  2221. transform: rotate(-90deg) !important;
  2222. }
  2223. .t-fake-arrow--active {
  2224. transform: rotate(90deg) !important;
  2225. }
  2226. }
  2227. }
  2228. :deep(.dialog-manage) {
  2229. .t-dialog__body {
  2230. height: 500px;
  2231. overflow: scroll;
  2232. }
  2233. .t-collapse {
  2234. border: 0px;
  2235. }
  2236. .t-collapse-panel__header {
  2237. border: 0px;
  2238. }
  2239. .t-collapse-panel__body {
  2240. border: 0px;
  2241. }
  2242. .t-collapse-panel__content {
  2243. display: grid;
  2244. grid-template-columns: 1fr 1fr 1fr 1fr;
  2245. /* grid-template-rows: repeat(100, 100px); */
  2246. grid-auto-rows: minmax(100px, auto);
  2247. grid-row-gap: 20px;
  2248. grid-column-gap: 20px;
  2249. }
  2250. .t-collapse-panel__body {
  2251. background: #fff0;
  2252. }
  2253. .manage-list {
  2254. max-height: 310px;
  2255. border: 1px solid #fff;
  2256. position: relative;
  2257. border: 1px solid #535f79;
  2258. position: relative;
  2259. border-radius: 2px;
  2260. .t-checkbox {
  2261. position: absolute;
  2262. right: 0px;
  2263. top: 10px;
  2264. z-index: 10;
  2265. }
  2266. }
  2267. }
  2268. }
  2269. </style>