You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1286 lines
40 KiB

​
​
​
​
​
​
​
1 year ago
​
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
3 months ago
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
3 months ago
​
3 months ago
​
​
3 months ago
​
​
​
3 months ago
​
​
​
3 months ago
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 month ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 year ago
​
​
​
​
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 year ago
​
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
1 year ago
​
3 months ago
​
​
​
​
​
1 year ago
​
1 year ago
​
​
​
​
1 year ago
​
​
​
​
​
​
​
​
​
1 year ago
1 year ago
​
1 year ago
1 year ago
​
​
​
​
​
​
​
​
1 year ago
​
1 year ago
​
​
​
1 year ago
​
​
1 year ago
1 year ago
1 year ago
​
​
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
1 year ago
​
1 year ago
​
​
1 year ago
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
3 months ago
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
1 year ago
​
3 months ago
1 year ago
​
​
3 months ago
​
​
1 year ago
​
3 months ago
1 year ago
​
​
3 months ago
1 year ago
​
​
​
​
​
​
​
3 months ago
1 year ago
​
​
1 year ago
​
​
​
​
​
​
​
​
​
1 year ago
​
​
3 months ago
​
1 year ago
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 month ago
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
3 months ago
​
​
3 months ago
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1 year ago
​
​
​
1 year ago
​
1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <template>
  2. <div class="label-designer">
  3. <!-- 主要内容区域 -->
  4. <div class="main-content">
  5. <!-- 顶部工具栏区域 -->
  6. <div class="top-toolbar">
  7. <HorizontalToolbar
  8. :label-no="labelNo"
  9. :element-count="elements.length"
  10. @update:labelNo="labelNo = $event"
  11. @drag-start="handleToolDragStart"
  12. @clear-canvas="handleClearCanvas"
  13. @clear-selection="handleClearSelection"
  14. @preview="handlePreview"
  15. @save="handleSave"
  16. />
  17. </div>
  18. <!-- 画布区域 -->
  19. <div class="canvas-area">
  20. <!-- 画布信息栏 -->
  21. <div class="canvas-info-bar">
  22. <div class="canvas-info">
  23. <span class="info-item">
  24. <strong>{{ currentCanvasSize.name }}</strong>
  25. ({{ currentCanvasSize.widthMm }}×{{ currentCanvasSize.heightMm }}mm)
  26. </span>
  27. <!-- <span class="info-item">
  28. 精确: {{ currentCanvasSize.exactWidth }}×{{ currentCanvasSize.exactHeight }}px
  29. </span>-->
  30. <span class="info-item">
  31. {{ $t('labelSetting.designer.displaySize', { width: currentCanvasSize.width, height: currentCanvasSize.height }) }}
  32. </span>
  33. <span class="info-item" v-if="currentCanvasSize.isScaled">
  34. {{ $t('labelSetting.designer.scale', { scale: Math.round(currentCanvasSize.scale * 100) }) }}
  35. </span>
  36. </div>
  37. <div class="canvas-middle-controls">
  38. <!-- 纸张选择 -->
  39. <div class="control-item">
  40. <label class="control-label">{{ $t('labelSetting.designer.paperSize') }}</label>
  41. <PaperSelector
  42. :selected-paper="selectedPaper"
  43. :orientation="orientation"
  44. :horizontal-mode="true"
  45. @paper-change="handlePaperChange"
  46. @orientation-change="handleOrientationChange"
  47. />
  48. </div>
  49. <div class="canvas-info">
  50. <span class="info-item">
  51. {{ $t('labelSetting.designer.displaySize', { width: currentCanvasSize.width, height: currentCanvasSize.height }) }}
  52. </span>
  53. <span class="info-item" v-if="currentCanvasSize.isScaled">
  54. {{ $t('labelSetting.designer.scale', { scale: Math.round(currentCanvasSize.scale * 100) }) }}
  55. </span>
  56. </div>
  57. <!-- 网格设置 -->
  58. <div class="control-item">
  59. <label class="control-label">{{ $t('labelSetting.designer.grid') }}</label>
  60. <div class="grid-controls">
  61. <el-checkbox
  62. v-model="showGrid"
  63. size="small"
  64. >{{ $t('labelSetting.designer.showGrid') }}</el-checkbox>
  65. <el-checkbox
  66. v-model="snapToGrid"
  67. size="small"
  68. >{{ $t('labelSetting.designer.snapToGrid') }}</el-checkbox>
  69. <div class="grid-size-control">
  70. <span class="size-label">{{ $t('labelSetting.designer.gridSize') }}</span>
  71. <el-input-number
  72. v-model="gridSize"
  73. :min="5"
  74. :max="100"
  75. :step="5"
  76. size="mini"
  77. :controls="false"
  78. style="width: 60px;"
  79. />
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. <div class="canvas-controls">
  85. <el-select v-model="selectedDPI" @change="handleDPIChange" size="small" style="width: 120px;">
  86. <el-option
  87. v-for="option in dpiOptions"
  88. :key="option.value"
  89. :label="option.label"
  90. :value="option.value"
  91. :title="option.description"
  92. />
  93. </el-select>
  94. </div>
  95. </div>
  96. <div class="canvas-container" ref="canvasContainer">
  97. <DesignCanvas
  98. ref="canvas"
  99. :key="`canvas-${selectedPaper}-${selectedDPI}-${orientation}-${canvasUpdateKey}`"
  100. :orientation="orientation"
  101. :show-grid="showGrid"
  102. :grid-size="gridSize"
  103. :elements="elements"
  104. :selected-index="selectedIndex"
  105. :canvas-size="currentCanvasSize"
  106. @drop="handleDrop"
  107. @element-select="handleElementSelect"
  108. @element-drag="handleElementDrag"
  109. />
  110. </div>
  111. </div>
  112. </div>
  113. <!-- 右侧属性面板区域 -->
  114. <div class="right-panel">
  115. <PropertyPanel
  116. :print-engine="printEngine"
  117. :label-settings="labelSettings"
  118. :save-design="handleSave"
  119. :orientation="orientation"
  120. :elements="elements"
  121. :selected-index="selectedIndex"
  122. :selected-element="selectedElement"
  123. :selected-paper="selectedPaper+''"
  124. :canvas-size="currentCanvasSize"
  125. @delete-element="handleDeleteElement"
  126. @save="handleSave"
  127. @preview="handlePreview"
  128. @data-source="handleDataSource"
  129. @element-combination="handleElementCombination"
  130. @font-changed="handleFontChanged"
  131. />
  132. </div>
  133. <!-- 数据源选择对话框 -->
  134. <DataSourceDialog
  135. :visible="dataSourceVisible"
  136. :data-keys="dataKeys"
  137. :current-text="currentElementText"
  138. :source-type="sourceType"
  139. @update:visible="dataSourceVisible = $event"
  140. @confirm="handleDataSourceConfirm"
  141. />
  142. <!-- 元素组合对话框 -->
  143. <ElementCombinationDialog
  144. :visible="elementCombinationVisible"
  145. :target-element="currentCombinationElement"
  146. :all-elements="elements"
  147. :data-keys="dataKeys"
  148. @update:visible="elementCombinationVisible = $event"
  149. @confirm="handleElementCombinationConfirm"
  150. />
  151. </div>
  152. </template>
  153. <script>
  154. import HorizontalToolbar from './components/HorizontalToolbar.vue'
  155. import DesignCanvas from './components/DesignCanvas.vue'
  156. import PropertyPanel from './components/PropertyPanel.vue'
  157. import DataSourceDialog from './components/DataSourceDialog.vue'
  158. import ElementCombinationDialog from './components/ElementCombinationDialog.vue'
  159. import PaperSelector from './components/PaperSelector.vue'
  160. import { CoordinateTransformer } from '@/utils/coordinateTransform.js'
  161. import { ZPLGenerator } from '@/utils/zplGenerator.js'
  162. import { applyElementCombination } from '@/utils/elementCombination'
  163. import { getCanvasSize, getRecommendedGridSize } from '@/utils/paperConfig.js'
  164. import { saveZplElements, getZplElements } from '@/api/labelSetting/label_setting.js'
  165. import {getViewFieldsByLabelType} from '@/api/labelSetting/com_add_update_label.js';
  166. import { calculateCanvasConfig, calculateCanvasConfigById, getRecommendedDPI, DPI_CONFIGS } from '@/utils/canvasCalculator.js'
  167. import dynamicPaperConfig from '@/utils/paperConfigDynamic.js'
  168. import { debounce } from 'lodash'
  169. export default {
  170. name: 'LabelDesigner',
  171. components: {
  172. HorizontalToolbar,
  173. DesignCanvas,
  174. PropertyPanel,
  175. DataSourceDialog,
  176. ElementCombinationDialog,
  177. PaperSelector
  178. },
  179. props: {
  180. orientation: {
  181. type: String,
  182. default: 'portrait',
  183. validator: val => ['portrait', 'landscape'].includes(val)
  184. }
  185. },
  186. data() {
  187. return {
  188. sourceType: 'text', // 数据源类型,默认为文本
  189. labelNo: '',
  190. showGrid: true,
  191. snapToGrid: true,
  192. gridSize: 10,
  193. selectedPaper: null, // 动态纸张ID,初始为null
  194. selectedDPI: 300, // 新绘制标签默认DPI为300
  195. paperLoaded: false, // 纸张数据是否已加载
  196. elements: [],
  197. selectedIndex: -1,
  198. dataSourceVisible: false,
  199. dataKeys: [],
  200. currentElementText: '', // 当前元素的文本内容
  201. elementCombinationVisible: false,
  202. currentCombinationElement: null, // 当前要组合的元素
  203. labelSettings: {},
  204. partialVisibilityWarned: false, // 部分可见性警告状态
  205. debouncedBoundaryMessage: null, // 防抖边界消息函数
  206. containerSize: { width: 800, height: 600 }, // 画布容器尺寸
  207. canvasUpdateKey: 0 // 强制更新画布的key
  208. }
  209. },
  210. computed: {
  211. // Printing mode is maintained with the label definition, not edited on the canvas.
  212. printEngine() {
  213. return String(this.labelSettings.printEngine || 'ZPL').trim().toUpperCase() || 'ZPL'
  214. },
  215. selectedElement() {
  216. return this.selectedIndex >= 0 ? this.elements[this.selectedIndex] : null
  217. },
  218. currentCanvasSize() {
  219. try {
  220. // 如果纸张数据未加载或未选择纸张,返回默认尺寸
  221. if (!this.paperLoaded || !this.selectedPaper) {
  222. return this.getDefaultCanvasSize()
  223. }
  224. // 使用新的动态画布计算功能
  225. const canvasConfig = calculateCanvasConfigById(
  226. this.selectedPaper,
  227. this.orientation,
  228. this.selectedDPI,
  229. this.containerSize
  230. )
  231. // 添加调试信息
  232. console.log('currentCanvasSize 计算:', {
  233. paperId: this.selectedPaper,
  234. orientation: this.orientation,
  235. dpi: this.selectedDPI,
  236. exactSize: `${canvasConfig.exact.width}×${canvasConfig.exact.height}px`,
  237. physicalSize: `${canvasConfig.exact.widthMm}×${canvasConfig.exact.heightMm}mm`
  238. })
  239. return {
  240. // 使用精确尺寸,不进行缩放
  241. width: canvasConfig.exact.width,
  242. height: canvasConfig.exact.height,
  243. // 精确尺寸(用于坐标转换和ZPL生成)
  244. exactWidth: canvasConfig.exact.width,
  245. exactHeight: canvasConfig.exact.height,
  246. // 物理信息
  247. name: canvasConfig.physical.name,
  248. description: canvasConfig.meta.description,
  249. // 缩放信息(现在总是1:1)
  250. scale: 1,
  251. isScaled: false,
  252. // DPI信息
  253. dpi: this.selectedDPI,
  254. // 物理尺寸(毫米)
  255. widthMm: canvasConfig.exact.widthMm,
  256. heightMm: canvasConfig.exact.heightMm,
  257. // 纸张ID
  258. paperId: this.selectedPaper,
  259. // 添加更新键确保对象变化
  260. updateKey: `${this.selectedPaper}-${this.selectedDPI}-${this.orientation}-${Date.now()}`
  261. }
  262. } catch (error) {
  263. console.error('画布尺寸计算错误:', error)
  264. // 降级到原有的计算方式
  265. return this.fallbackCanvasSize()
  266. }
  267. },
  268. // 降级的画布尺寸计算
  269. fallbackCanvasSize() {
  270. // 使用原有的getCanvasSize方法
  271. const canvasSize = getCanvasSize(this.selectedPaper, this.orientation)
  272. return {
  273. ...canvasSize,
  274. dpi: this.selectedDPI,
  275. widthMm: canvasSize.width * 25.4 / this.selectedDPI,
  276. heightMm: canvasSize.height * 25.4 / this.selectedDPI,
  277. scale: 1,
  278. isScaled: false
  279. }
  280. },
  281. // 可用的DPI选项
  282. dpiOptions() {
  283. return Object.keys(DPI_CONFIGS).map(dpi => ({
  284. value: parseInt(dpi),
  285. label: DPI_CONFIGS[dpi].name,
  286. description: DPI_CONFIGS[dpi].description
  287. }))
  288. },
  289. coordinateTransformer() {
  290. // 使用纸张ID创建坐标转换器
  291. return new CoordinateTransformer(this.orientation, null, null, this.selectedPaper)
  292. },
  293. zplGenerator() {
  294. // 使用纸张ID和DPI创建ZPL生成器
  295. return new ZPLGenerator(this.orientation, null, null, this.selectedPaper, this.selectedDPI)
  296. }
  297. },
  298. async created() {
  299. await this.initializePapers()
  300. this.initializeFromRoute()
  301. },
  302. async activated() {
  303. await this.initializePapers()
  304. this.initializeFromRoute()
  305. this.loadElements()
  306. this.updateGridSize()
  307. },
  308. watch: {
  309. selectedPaper: {
  310. handler() {
  311. this.updateGridSize()
  312. this.updateTransformers()
  313. }
  314. },
  315. selectedDPI: {
  316. handler(newDPI, oldDPI) {
  317. if (oldDPI && newDPI !== oldDPI) {
  318. console.log('DPI监听器触发:', { oldDPI, newDPI })
  319. // DPI变化时立即处理
  320. this.handleDPIChange()
  321. }
  322. }
  323. },
  324. },
  325. methods: {
  326. // 初始化纸张数据
  327. async initializePapers() {
  328. try {
  329. await dynamicPaperConfig.loadPapers()
  330. this.paperLoaded = true
  331. // 如果还没有选择纸张,设置默认纸张
  332. if (!this.selectedPaper) {
  333. const papers = dynamicPaperConfig.getActivePapers()
  334. if (papers.length > 0) {
  335. // 优先选择4×2英寸作为默认纸张
  336. const defaultPaper = papers.find(p => p.name.includes('4×2')) || papers[0]
  337. this.selectedPaper = defaultPaper.id
  338. }
  339. }
  340. console.log('纸张数据初始化完成:', dynamicPaperConfig.getAllPapers().length)
  341. } catch (error) {
  342. console.error('初始化纸张数据失败:', error)
  343. this.paperLoaded = false
  344. }
  345. },
  346. // 获取默认画布尺寸
  347. getDefaultCanvasSize() {
  348. return {
  349. width: 812,
  350. height: 406,
  351. exactWidth: 812,
  352. exactHeight: 406,
  353. name: this.$t('labelSetting.designer.defaultPaper'),
  354. description: this.$t('labelSetting.designer.defaultPaperDescription'),
  355. scale: 1,
  356. isScaled: false,
  357. dpi: this.selectedDPI,
  358. widthMm: 101.6,
  359. heightMm: 50.8,
  360. paperId: null,
  361. updateKey: `default-${this.selectedDPI}-${this.orientation}-${Date.now()}`
  362. }
  363. },
  364. initializeFromRoute() {
  365. const labelSetting = this.$route.params.labelSetting
  366. if (labelSetting) {
  367. this.labelNo = labelSetting.labelNo
  368. this.labelSettings = labelSetting
  369. // 根据 ReportFileList 中的纸张信息设置
  370. if (labelSetting.paperId) {
  371. // 新格式:使用纸张ID
  372. this.selectedPaper = labelSetting.paperId
  373. console.log('从路由参数设置纸张ID:', labelSetting.paperId)
  374. } else if (labelSetting.paperSize) {
  375. // 兼容旧格式:根据纸张类型查找对应的纸张ID
  376. const legacyPaper = dynamicPaperConfig.findPaperByLegacyType(labelSetting.paperSize)
  377. if (legacyPaper) {
  378. this.selectedPaper = legacyPaper.id
  379. console.log('从路由参数转换纸张类型:', labelSetting.paperSize, '-> ID:', legacyPaper.id)
  380. } else {
  381. console.warn('未找到对应的纸张类型:', labelSetting.paperSize)
  382. }
  383. }
  384. if (labelSetting.dpi) {
  385. this.selectedDPI = labelSetting.dpi
  386. console.log('从路由参数设置DPI:', labelSetting.dpi)
  387. } else {
  388. // 没有历史DPI时,确保使用默认值 300
  389. this.selectedDPI = 300
  390. console.log('使用默认DPI: 300')
  391. }
  392. // 处理打印方向,优先使用 prop 传入的值,然后是路由参数
  393. if (this.orientation && this.orientation !== 'portrait') {
  394. // 如果组件prop已经指定了方向(如从label_draw2.vue传入的landscape),使用它
  395. console.log('使用组件prop指定的打印方向:', this.orientation)
  396. } else if (labelSetting.paperOrientation) {
  397. this.orientation = labelSetting.paperOrientation
  398. console.log('从路由参数设置打印方向(paperOrientation):', labelSetting.paperOrientation)
  399. } else if (labelSetting.printDirection) {
  400. // 将中文打印方向转换为英文
  401. this.orientation = (labelSetting.printDirection === '横向打印' || labelSetting.printDirection === '横向设计') ? 'landscape' : 'portrait'
  402. console.log('从路由参数设置打印方向(printDirection):', labelSetting.printDirection, '-> orientation:', this.orientation)
  403. } else {
  404. // 没有历史打印方向时,确保使用默认值 portrait
  405. this.orientation = 'portrait'
  406. console.log('使用默认打印方向: portrait')
  407. }
  408. // 输出初始化信息
  409. console.log('标签设计器初始化完成:', {
  410. labelNo: this.labelNo,
  411. paperId: this.selectedPaper,
  412. dpi: this.selectedDPI,
  413. orientation: this.orientation,
  414. hasHistoryData: {
  415. paperId: !!labelSetting.paperId,
  416. paperSize: !!labelSetting.paperSize,
  417. dpi: !!labelSetting.dpi,
  418. orientation: !!labelSetting.paperOrientation
  419. }
  420. })
  421. } else {
  422. // 完全没有路由参数时,使用所有默认值
  423. console.log('没有路由参数,使用所有默认值:', {
  424. paperId: this.selectedPaper,
  425. dpi: this.selectedDPI,
  426. orientation: this.orientation
  427. })
  428. }
  429. },
  430. async loadElements() {
  431. if (!this.labelNo) return
  432. try {
  433. const { data } = await getZplElements({ reportId: this.labelNo })
  434. if (data.code === 200) {
  435. // 修复:对每个元素补全属性,保证响应式
  436. const defaultElement = {reportId: '',
  437. type: '', x: 0, y: 0, data: '', fontSize: 30, bold: false, newline: false, lineRows: 2,
  438. lineWidth: 200, digits: 2, step: 1, width: 100, height: 30, previewUrl: '', barcodeType: '', showContent: true, showElement: true, showSerialNumber: false,
  439. showMainSeq: false,parentSerialLabelNo:'', seqName: '', isChecked: false, decimalPlaces: '', showDecimalPlaces: false, thousandsSeparator: false, roundHalfUp: true, fixedDigits: '', dateOffsetDays: 0,
  440. // 字体相关属性
  441. fontFamily: 'default', textAlign: 'left', letterSpacing: 0, fontItalic: false, fontUnderline: false
  442. };
  443. this.elements = (data.data || []).map(item => {
  444. const element = Object.assign({}, defaultElement, item);
  445. if (typeof element.showSerialNumber === 'string') {
  446. element.showSerialNumber = element.showSerialNumber === 'true'
  447. }
  448. // 为一维码元素确保有新属性和合理的毫米默认值
  449. if (element.type === 'onecode') {
  450. if (!element.barcodeType) element.barcodeType = 'CODE128';
  451. if (element.showContent === undefined) element.showContent = true;
  452. }
  453. // 为流水号元素确保显示属性默认为true
  454. if (element.type === 'serialNumber') {
  455. if (element.showSerialNumber === undefined || element.showSerialNumber === null || element.showSerialNumber === '') {
  456. element.showSerialNumber = true;
  457. }
  458. } else if (element.type === 'text' && element.dataType === 'date') {
  459. if (element.showSerialNumber === undefined || element.showSerialNumber === null || element.showSerialNumber === '') {
  460. element.showSerialNumber = false
  461. }
  462. if (element.digits === undefined || element.digits === null || element.digits === '') {
  463. element.digits = 2
  464. }
  465. if (element.step === undefined || element.step === null || element.step === '') {
  466. element.step = 1
  467. }
  468. }
  469. return element;
  470. });
  471. }
  472. } catch (error) {
  473. this.$message.error(this.$t('labelSetting.designer.loadElementsFailed'))
  474. }
  475. },
  476. handleToolDragStart(type) {
  477. // 工具栏拖拽开始,由画布处理
  478. },
  479. handleDrop(dropData) {
  480. console.log('主设计器接收到拖拽数据:', dropData) // 调试信息
  481. if (!this.labelNo) {
  482. this.$alert(this.$t('labelSetting.designer.labelNoEmpty'), this.$t('labelSetting.common.error'), {
  483. confirmButtonText: this.$t('labelSetting.common.confirm')
  484. })
  485. return
  486. }
  487. const newElement = this.createNewElement(dropData)
  488. console.log('创建的新元素:', newElement) // 调试信息
  489. this.elements.push(newElement)
  490. // 自动选中新添加的元素
  491. this.selectedIndex = this.elements.length - 1
  492. },
  493. createNewElement({ type, x, y }) {
  494. console.log('创建新元素:', { type, x, y }) // 调试信息
  495. const baseElement = {
  496. type,
  497. x,
  498. y,
  499. data: '',
  500. fontSize: 30,
  501. bold: false,
  502. newline: false,
  503. lineRows: 2,
  504. lineWidth: 200,
  505. fixedDigits: '',
  506. digits: 2,
  507. step: 1,
  508. showSerialNumber: false
  509. }
  510. // 根据类型设置默认尺寸和特殊属性
  511. const sizeConfig = {
  512. text: {
  513. width: 100,
  514. height: 30,
  515. data: '',
  516. isChecked: false,
  517. // 字体相关属性
  518. fontFamily: 'default',
  519. textAlign: 'left',
  520. letterSpacing: 0,
  521. fontItalic: false,
  522. fontUnderline: false,
  523. },
  524. onecode: {
  525. width: 0.5, // 默认宽度0.5mm
  526. height: 10, // 默认高度10mm
  527. data: '',
  528. barcodeType: 'CODE128', // 默认条码类型
  529. showContent: true // 默认显示内容
  530. },
  531. qrcode: {
  532. width: 10,
  533. height: 15, // 默认尺寸15mm
  534. data: ''
  535. },
  536. pic: {
  537. width: 200, // 默认宽度200像素
  538. height: 100 // 默认高度100像素
  539. },
  540. hLine: {
  541. width: 400,
  542. height: 3
  543. },
  544. vLine: {
  545. width: 3,
  546. height: 400
  547. },
  548. serialNumber: {
  549. width: 120,
  550. height: 30,
  551. digits: 6,
  552. step: 1,
  553. data: this.$t('labelSetting.designer.serialNumber'), // 默认显示值
  554. fontSize: 30,
  555. showMainSeq: false,
  556. parentSerialLabelNo:'',
  557. reportId: this.labelNo,
  558. showSerialNumber: true // 默认显示流水号
  559. }
  560. }
  561. const config = sizeConfig[type] || { width: 100, height: 30 }
  562. const newElement = {
  563. ...baseElement,
  564. ...config
  565. }
  566. console.log('新元素配置:', newElement) // 调试信息
  567. return newElement
  568. },
  569. handleElementSelect(index) {
  570. this.selectedIndex = index
  571. },
  572. handleElementDrag({ index, x, y, boundaryStatus }) {
  573. // 网格吸附处理
  574. if (this.snapToGrid && this.gridSize > 0) {
  575. x = Math.round(x / this.gridSize) * this.gridSize
  576. y = Math.round(y / this.gridSize) * this.gridSize
  577. }
  578. // 更新元素位置
  579. this.$set(this.elements[index], 'x', x)
  580. this.$set(this.elements[index], 'y', y)
  581. // 处理边界状态反馈
  582. if (boundaryStatus) {
  583. this.handleBoundaryFeedback(boundaryStatus, this.elements[index])
  584. }
  585. },
  586. /**
  587. * 处理边界状态反馈
  588. */
  589. handleBoundaryFeedback(boundaryStatus, element) {
  590. // 只有在真正需要时才给出反馈
  591. // 1. 严格模式元素触及边界时提示
  592. if (boundaryStatus.clamped && this.isStrictElement(element.type)) {
  593. const directions = []
  594. if (boundaryStatus.atLeft) directions.push(this.$t('labelSetting.designer.directionLeft'))
  595. if (boundaryStatus.atRight) directions.push(this.$t('labelSetting.designer.directionRight'))
  596. if (boundaryStatus.atTop) directions.push(this.$t('labelSetting.designer.directionTop'))
  597. if (boundaryStatus.atBottom) directions.push(this.$t('labelSetting.designer.directionBottom'))
  598. if (directions.length > 0) {
  599. // 使用防抖避免频繁提示
  600. if (!this.debouncedBoundaryMessage) {
  601. this.debouncedBoundaryMessage = debounce(() => {
  602. this.$message({
  603. message: this.$t('labelSetting.designer.boundaryReached', {
  604. element: this.getElementTypeName(element.type),
  605. directions: directions.join(this.$t('labelSetting.designer.directionSeparator'))
  606. }),
  607. type: 'info',
  608. duration: 1500,
  609. showClose: false
  610. })
  611. }, 1500) // 增加防抖时间
  612. }
  613. this.debouncedBoundaryMessage()
  614. }
  615. }
  616. // 2. 元素真正超出安全范围时警告
  617. if (boundaryStatus.partiallyVisible && !this.partialVisibilityWarned) {
  618. this.$message({
  619. message: this.$t('labelSetting.designer.unsafePosition'),
  620. type: 'warning',
  621. duration: 3000
  622. })
  623. this.partialVisibilityWarned = true
  624. // 5秒后重置警告状态
  625. setTimeout(() => {
  626. this.partialVisibilityWarned = false
  627. }, 5000)
  628. }
  629. },
  630. /**
  631. * 判断是否为严格模式元素
  632. */
  633. isStrictElement(elementType) {
  634. return ['onecode', 'qrcode'].includes(elementType)
  635. },
  636. /**
  637. * 获取元素类型的中文名称
  638. */
  639. getElementTypeName(elementType) {
  640. const nameMap = {
  641. text: this.$t('labelSetting.designer.text'),
  642. onecode: this.$t('labelSetting.designer.barcode'),
  643. qrcode: this.$t('labelSetting.designer.qrcode'),
  644. pic: this.$t('labelSetting.designer.image'),
  645. hLine: this.$t('labelSetting.designer.horizontalLine'),
  646. vLine: this.$t('labelSetting.designer.verticalLine')
  647. }
  648. return nameMap[elementType] || this.$t('labelSetting.designer.element')
  649. },
  650. handleDeleteElement() {
  651. if (this.selectedIndex >= 0) {
  652. this.$confirm(this.$t('labelSetting.designer.deleteElementConfirm'), this.$t('labelSetting.common.tip'), {
  653. confirmButtonText: this.$t('labelSetting.common.confirm'),
  654. cancelButtonText: this.$t('labelSetting.common.cancel'),
  655. type: 'warning'
  656. }).then(() => {
  657. this.elements.splice(this.selectedIndex, 1)
  658. this.selectedIndex = -1
  659. })
  660. }
  661. },
  662. async handleSave() {
  663. if (!this.labelNo) {
  664. this.$alert(this.$t('labelSetting.designer.labelNoEmpty'), this.$t('labelSetting.common.error'), {
  665. confirmButtonText: this.$t('labelSetting.common.confirm')
  666. })
  667. return false
  668. }
  669. const zplCode = this.printEngine === 'ZPL' ? this.zplGenerator.generate(this.elements) : null
  670. const saveData = {
  671. zplCode,
  672. elements: this.elements,
  673. reportId: this.labelNo,
  674. // 新格式:使用纸张ID
  675. paperId: this.selectedPaper,
  676. // 兼容性:保留原有字段
  677. paperSize: this.selectedPaper, // 现在存储的是纸张ID
  678. paperOrientation: this.orientation,
  679. dpi: this.selectedDPI,
  680. // 添加画布尺寸信息(像素)
  681. canvasWidth: this.currentCanvasSize.width,
  682. canvasHeight: this.currentCanvasSize.height,
  683. // 添加物理尺寸信息(毫米)
  684. physicalWidthMm: this.currentCanvasSize.widthMm,
  685. physicalHeightMm: this.currentCanvasSize.heightMm
  686. }
  687. try {
  688. const { data } = await saveZplElements(saveData)
  689. if (data.code === 0) {
  690. this.$message.success(this.$t('labelSetting.designer.saveSuccess'))
  691. // 输出保存的详细信息用于调试
  692. console.log('标签保存成功:', {
  693. reportId: this.labelNo,
  694. paperId: this.selectedPaper,
  695. orientation: this.orientation,
  696. dpi: this.selectedDPI,
  697. canvasSize: `${this.currentCanvasSize.width}×${this.currentCanvasSize.height}px`,
  698. physicalSize: `${this.currentCanvasSize.widthMm}×${this.currentCanvasSize.heightMm}mm`
  699. })
  700. return true
  701. } else {
  702. this.$message.error(data.msg)
  703. return false
  704. }
  705. } catch (error) {
  706. console.error('保存失败:', error)
  707. this.$message.error(this.$t('labelSetting.designer.saveFailed'))
  708. return false
  709. }
  710. },
  711. handlePreview() {
  712. // 预览逻辑由PropertyPanel处理
  713. },
  714. handleClearCanvas() {
  715. if (this.elements.length === 0) {
  716. this.$message.info(this.$t('labelSetting.designer.canvasEmpty'))
  717. return
  718. }
  719. this.$confirm(this.$t('labelSetting.designer.clearConfirm'), this.$t('labelSetting.designer.clearCanvas'), {
  720. confirmButtonText: this.$t('labelSetting.designer.confirmClear'),
  721. cancelButtonText: this.$t('labelSetting.common.cancel'),
  722. type: 'warning',
  723. dangerouslyUseHTMLString: true,
  724. message: `<div style="color: #E6A23C;"><i class="el-icon-warning"></i> ${this.$t('labelSetting.designer.clearConfirm')}</div><div style="margin-top: 10px; color: #909399; font-size: 13px;">${this.$t('labelSetting.designer.clearWarning')}</div>`
  725. }).then(() => {
  726. this.elements = []
  727. this.selectedIndex = -1
  728. this.$message.success(this.$t('labelSetting.designer.canvasCleared'))
  729. }).catch(() => {
  730. // 用户取消操作
  731. })
  732. },
  733. handleClearSelection() {
  734. if (this.selectedIndex >= 0) {
  735. this.selectedIndex = -1
  736. this.$message.info(this.$t('labelSetting.designer.selectionCleared'))
  737. }
  738. },
  739. async handleDataSource(inData) {
  740. const response = await getViewFieldsByLabelType({
  741. labelType: this.labelSettings.labelType,
  742. site: this.$store.state.user.site
  743. });
  744. if (response.data && response.data.code === 200) {
  745. this.dataKeys = response.data.data.map(field => ({
  746. ...field,
  747. fieldDescription: field.fieldDescription || ''
  748. }));
  749. this.currentElementText = inData.data || ''
  750. this.sourceType = inData.type || 'text'
  751. this.dataSourceVisible = true
  752. } else {
  753. this.$message.error(response.data.msg || this.$t('labelSetting.dataSource.loadFieldsFailed'));
  754. }
  755. },
  756. handleDataSourceConfirm(selectedKeys, sourceType) {
  757. if (this.selectedElement) {
  758. this.selectedElement.data = sourceType==='serialNumber'?selectedKeys.map(key => `#{${key}}`).join('+'):
  759. selectedKeys.map(key => `#{${key}}`).join('')
  760. }
  761. },
  762. async handleElementCombination(element) {
  763. // 获取数据源字段信息(如果还没有的话)
  764. if (!this.dataKeys.length) {
  765. try {
  766. const response = await getViewFieldsByLabelType({
  767. labelType: this.labelSettings.labelType,
  768. site: this.$store.state.user.site
  769. });
  770. if (response.data && response.data.code === 200) {
  771. this.dataKeys = response.data.data.map(field => ({
  772. ...field,
  773. fieldDescription: field.fieldDescription || ''
  774. }));
  775. }
  776. } catch (error) {
  777. console.error('获取数据源字段失败:', error);
  778. }
  779. }
  780. this.currentCombinationElement = element;
  781. this.elementCombinationVisible = true;
  782. },
  783. handleElementCombinationConfirm(combinationConfig) {
  784. if (this.currentCombinationElement) {
  785. // 根据组合模式设置元素数据
  786. switch (combinationConfig.mode) {
  787. case 'template':
  788. this.currentCombinationElement.data = combinationConfig.data;
  789. break;
  790. case 'sequence':
  791. this.currentCombinationElement.data = applyElementCombination(this.currentCombinationElement.data, combinationConfig.data);
  792. break;
  793. case 'custom':
  794. // 对于自定义模式,我们需要在后端处理时执行表达式
  795. this.currentCombinationElement.data = `CUSTOM:${combinationConfig.data}`;
  796. break;
  797. }
  798. // 保存组合配置到元素的扩展属性中
  799. this.$set(this.currentCombinationElement, 'combinationConfig', combinationConfig);
  800. this.$message.success(this.$t('labelSetting.designer.combinationSaved'));
  801. }
  802. },
  803. handlePaperChange(paperId) {
  804. this.selectedPaper = paperId
  805. // 获取纸张信息
  806. const paper = dynamicPaperConfig.getPaperById(paperId)
  807. const paperName = paper ? paper.name : this.$t('labelSetting.designer.paperId', { id: paperId })
  808. // 获取新的画布尺寸信息
  809. const newCanvasSize = this.currentCanvasSize
  810. const orientationText = this.orientation === 'portrait' ? this.$t('labelSetting.designer.portrait') : this.$t('labelSetting.designer.landscape')
  811. this.$message({
  812. message: this.$t('labelSetting.designer.paperSwitched', { paper: paperName, orientation: orientationText, width: newCanvasSize.width, height: newCanvasSize.height }),
  813. type: 'success',
  814. duration: 6000
  815. })
  816. // 调试信息
  817. console.log('纸张切换:', {
  818. paperId,
  819. paperName,
  820. orientation: this.orientation,
  821. canvasSize: newCanvasSize
  822. })
  823. },
  824. handleOrientationChange(orientation) {
  825. // 更新打印方向
  826. this.orientation = orientation
  827. // 获取新的画布尺寸信息
  828. const newCanvasSize = this.currentCanvasSize
  829. this.$message({
  830. message: this.$t('labelSetting.designer.orientationSwitched', {
  831. orientation: orientation === 'portrait' ? this.$t('labelSetting.designer.portrait') : this.$t('labelSetting.designer.landscape'),
  832. width: newCanvasSize.width,
  833. height: newCanvasSize.height
  834. }),
  835. type: 'success',
  836. duration: 3000
  837. })
  838. // 调试信息
  839. console.log('打印方向切换:', {
  840. orientation,
  841. paper: this.selectedPaper,
  842. canvasSize: newCanvasSize
  843. })
  844. },
  845. updateGridSize() {
  846. // 根据纸张大小推荐网格尺寸
  847. const recommendedSize = getRecommendedGridSize(this.selectedPaper)
  848. if (this.gridSize === 20) { // 只在默认值时自动调整
  849. this.gridSize = recommendedSize
  850. }
  851. },
  852. handleDPIChange() {
  853. console.log('handleDPIChange 被调用, DPI:', this.selectedDPI)
  854. // 强制更新画布组件的 key,确保重新渲染
  855. this.canvasUpdateKey++
  856. // 立即更新相关计算
  857. this.updateTransformers()
  858. // 使用 $nextTick 确保 DOM 更新
  859. this.$nextTick(() => {
  860. const newCanvasSize = this.currentCanvasSize
  861. console.log('DPI变更后的画布尺寸:', {
  862. dpi: this.selectedDPI,
  863. paper: this.selectedPaper,
  864. orientation: this.orientation,
  865. canvasSize: {
  866. display: `${newCanvasSize.width}×${newCanvasSize.height}px`,
  867. exact: `${newCanvasSize.exactWidth}×${newCanvasSize.exactHeight}px`,
  868. physical: `${newCanvasSize.widthMm}×${newCanvasSize.heightMm}mm`
  869. }
  870. })
  871. this.$message({
  872. message: this.$t('labelSetting.designer.dpiSwitched', { dpi: this.selectedDPI, width: newCanvasSize.exactWidth, height: newCanvasSize.exactHeight }),
  873. type: 'success',
  874. duration: 3000
  875. })
  876. })
  877. },
  878. updateContainerSize() {
  879. // 动态检测画布容器尺寸
  880. if (this.$refs.canvasContainer) {
  881. const rect = this.$refs.canvasContainer.getBoundingClientRect()
  882. this.containerSize = {
  883. width: Math.max(rect.width - 40, 400), // 减去padding
  884. height: Math.max(rect.height - 40, 300)
  885. }
  886. }
  887. },
  888. updateTransformers() {
  889. // 更新坐标转换器和ZPL生成器的纸张ID
  890. if (this.coordinateTransformer && this.coordinateTransformer.updatePaperId) {
  891. this.coordinateTransformer.updatePaperId(this.selectedPaper)
  892. }
  893. if (this.zplGenerator && this.zplGenerator.updatePaperId) {
  894. this.zplGenerator.updatePaperId(this.selectedPaper)
  895. }
  896. },
  897. // 处理字体变化
  898. handleFontChanged(fontData) {
  899. console.log('LabelDesigner收到字体变化事件:', fontData)
  900. if (fontData && fontData.elementId && this.selectedElement && this.selectedElement.id === fontData.elementId) {
  901. // 确保字体值正确设置
  902. this.$set(this.selectedElement, 'fontFamily', fontData.fontFamily)
  903. console.log('字体已更新:', this.selectedElement.fontFamily)
  904. // 强制更新画布
  905. this.canvasUpdateKey++
  906. // 触发ZPL预览更新
  907. this.$nextTick(() => {
  908. this.$emit('font-updated', fontData)
  909. })
  910. }
  911. }
  912. },
  913. mounted() {
  914. // 初始化容器尺寸检测
  915. this.updateContainerSize()
  916. // 监听窗口大小变化
  917. window.addEventListener('resize', this.updateContainerSize)
  918. // 使用ResizeObserver监听容器尺寸变化(如果支持)
  919. if (window.ResizeObserver && this.$refs.canvasContainer) {
  920. this.resizeObserver = new ResizeObserver(() => {
  921. this.updateContainerSize()
  922. })
  923. this.resizeObserver.observe(this.$refs.canvasContainer)
  924. }
  925. },
  926. beforeDestroy() {
  927. // 清理事件监听器
  928. window.removeEventListener('resize', this.updateContainerSize)
  929. if (this.resizeObserver) {
  930. this.resizeObserver.disconnect()
  931. }
  932. }
  933. }
  934. </script>
  935. <style scoped>
  936. .label-designer {
  937. display: flex;
  938. height: 100vh;
  939. overflow: hidden;
  940. background: #f5f7fa;
  941. }
  942. /* 主要内容区域 - 占据大部分空间 */
  943. .main-content {
  944. flex: 1;
  945. display: flex;
  946. flex-direction: column;
  947. overflow: hidden;
  948. }
  949. /* 顶部工具栏区域 - 自适应高度 */
  950. .top-toolbar {
  951. flex-shrink: 0;
  952. background: #fff;
  953. border-bottom: 1px solid #e4e7ed;
  954. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  955. }
  956. /* 画布区域 - 占据剩余空间 */
  957. .canvas-area {
  958. flex: 1;
  959. display: flex;
  960. flex-direction: column;
  961. overflow: hidden;
  962. background: #fafafa;
  963. }
  964. /* 画布信息栏 */
  965. .canvas-info-bar {
  966. display: flex;
  967. justify-content: space-between;
  968. align-items: center;
  969. padding: 12px 20px;
  970. background: #fff;
  971. border-bottom: 1px solid #e4e7ed;
  972. box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  973. gap: 20px;
  974. }
  975. .canvas-info {
  976. display: flex;
  977. gap: 20px;
  978. align-items: center;
  979. flex-shrink: 0;
  980. }
  981. .info-item {
  982. font-size: 13px;
  983. color: #606266;
  984. white-space: nowrap;
  985. }
  986. .info-item strong {
  987. color: #303133;
  988. font-weight: 600;
  989. }
  990. .canvas-middle-controls {
  991. display: flex;
  992. gap: 30px;
  993. align-items: center;
  994. flex: 1;
  995. justify-content: left;
  996. }
  997. .control-item {
  998. display: flex;
  999. align-items: center;
  1000. gap: 8px;
  1001. white-space: nowrap;
  1002. }
  1003. .control-label {
  1004. font-size: 13px;
  1005. color: #606266;
  1006. font-weight: 500;
  1007. min-width: fit-content;
  1008. }
  1009. .grid-controls {
  1010. display: flex;
  1011. align-items: center;
  1012. gap: 15px;
  1013. }
  1014. .grid-size-control {
  1015. display: flex;
  1016. align-items: center;
  1017. gap: 5px;
  1018. }
  1019. .size-label {
  1020. font-size: 12px;
  1021. color: #909399;
  1022. }
  1023. .canvas-controls {
  1024. display: flex;
  1025. gap: 10px;
  1026. align-items: center;
  1027. flex-shrink: 0;
  1028. }
  1029. /* 画布容器 - 支持滚动的原始尺寸画布 */
  1030. .canvas-container {
  1031. flex: 1;
  1032. padding: 20px;
  1033. overflow: auto;
  1034. position: relative;
  1035. background: #fafafa;
  1036. /* 确保滚动条样式美观 */
  1037. scrollbar-width: thin;
  1038. scrollbar-color: #c1c1c1 #f1f1f1;
  1039. }
  1040. .canvas-container::-webkit-scrollbar {
  1041. width: 8px;
  1042. height: 8px;
  1043. }
  1044. .canvas-container::-webkit-scrollbar-track {
  1045. background: #f1f1f1;
  1046. border-radius: 4px;
  1047. }
  1048. .canvas-container::-webkit-scrollbar-thumb {
  1049. background: #c1c1c1;
  1050. border-radius: 4px;
  1051. }
  1052. .canvas-container::-webkit-scrollbar-thumb:hover {
  1053. background: #a8a8a8;
  1054. }
  1055. /* 右侧属性面板区域 - 固定宽度 */
  1056. .right-panel {
  1057. width: 400px;
  1058. flex-shrink: 0;
  1059. background: #fff;
  1060. border-left: 1px solid #e4e7ed;
  1061. overflow-y: auto;
  1062. overflow-x: hidden;
  1063. }
  1064. /* 响应式设计 - 小屏幕适配 */
  1065. @media (max-width: 1200px) {
  1066. .top-toolbar {
  1067. height: 100px;
  1068. }
  1069. .right-panel {
  1070. width: 300px;
  1071. }
  1072. .canvas-info {
  1073. gap: 15px;
  1074. }
  1075. .info-item {
  1076. font-size: 12px;
  1077. }
  1078. .canvas-middle-controls {
  1079. gap: 20px;
  1080. }
  1081. }
  1082. @media (max-width: 1024px) {
  1083. .top-toolbar {
  1084. height: 80px;
  1085. }
  1086. .right-panel {
  1087. width: 280px;
  1088. }
  1089. .canvas-info-bar {
  1090. flex-direction: column;
  1091. gap: 10px;
  1092. align-items: flex-start;
  1093. padding: 10px 15px;
  1094. }
  1095. .canvas-info {
  1096. flex-wrap: wrap;
  1097. gap: 10px;
  1098. }
  1099. .canvas-middle-controls {
  1100. flex-direction: row;
  1101. justify-content: flex-start;
  1102. gap: 15px;
  1103. width: 100%;
  1104. }
  1105. .grid-controls {
  1106. gap: 10px;
  1107. }
  1108. }
  1109. @media (max-width: 768px) {
  1110. .label-designer {
  1111. flex-direction: column;
  1112. }
  1113. .main-content {
  1114. flex: 1;
  1115. }
  1116. .right-panel {
  1117. width: 100%;
  1118. height: 300px;
  1119. border-left: none;
  1120. border-top: 1px solid #e4e7ed;
  1121. }
  1122. .top-toolbar {
  1123. height: 60px;
  1124. }
  1125. .canvas-middle-controls {
  1126. flex-direction: column;
  1127. align-items: flex-start;
  1128. gap: 10px;
  1129. }
  1130. .control-item {
  1131. width: 100%;
  1132. justify-content: space-between;
  1133. }
  1134. .grid-controls {
  1135. flex-wrap: wrap;
  1136. gap: 8px;
  1137. }
  1138. }
  1139. </style>