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.

225 lines
4.0 KiB

7 months ago
7 months ago
7 months ago
  1. <template>
  2. <div class="horizontal-toolbar">
  3. <!-- 最左侧区域设计工具 -->
  4. <div class="toolbar-section tools-section">
  5. <div class="toolbar-item">
  6. <label class="item-label">设计工具:</label>
  7. <div class="tools-horizontal">
  8. <ToolItem
  9. v-for="tool in tools"
  10. :key="tool.type"
  11. :tool="tool"
  12. :horizontal="true"
  13. @dragstart="handleDragStart"
  14. />
  15. </div>
  16. </div>
  17. </div>
  18. <!-- 中间区域基本设置 -->
  19. <div class="toolbar-section middle-section">
  20. <!-- 标签编号 -->
  21. <div class="toolbar-item">
  22. <label class="item-label">标签编号:</label>
  23. <el-input
  24. v-model="labelNoValue"
  25. placeholder="输入标签编号"
  26. size="small"
  27. style="width: 120px;"
  28. @input="$emit('update:labelNo', $event)"
  29. />
  30. </div>
  31. </div>
  32. </div>
  33. </template>
  34. <script>
  35. import ToolItem from './ToolItem.vue'
  36. export default {
  37. name: 'HorizontalToolbar',
  38. components: {
  39. ToolItem
  40. },
  41. props: {
  42. labelNo: String
  43. },
  44. computed: {
  45. labelNoValue: {
  46. get() {
  47. return this.labelNo
  48. },
  49. set(value) {
  50. this.$emit('update:labelNo', value)
  51. }
  52. },
  53. tools() {
  54. return [
  55. {
  56. type: 'text',
  57. icon: 'el-icon-document',
  58. label: '文本',
  59. color: '#409EFF'
  60. },
  61. {
  62. type: 'barcode',
  63. icon: 'el-icon-tickets',
  64. label: '条码',
  65. rotate: true,
  66. color: '#67C23A'
  67. },
  68. {
  69. type: 'qrcode',
  70. icon: 'el-icon-menu',
  71. label: '二维码',
  72. color: '#E6A23C'
  73. },
  74. {
  75. type: 'onecode',
  76. icon: 'el-icon-more',
  77. label: '一维码',
  78. color: '#F56C6C'
  79. },
  80. {
  81. type: 'pic',
  82. icon: 'el-icon-picture',
  83. label: '图片',
  84. color: '#909399'
  85. },
  86. {
  87. type: 'hLine',
  88. icon: 'el-icon-minus',
  89. label: '横线',
  90. color: '#606266'
  91. },
  92. {
  93. type: 'vLine',
  94. icon: 'el-icon-minus',
  95. label: '竖线',
  96. rotate: true,
  97. color: '#909399'
  98. },
  99. {
  100. type: 'serialNumber',
  101. icon: 'el-icon-setting',
  102. label: '流水号',
  103. color: '#909399'
  104. }
  105. ]
  106. }
  107. },
  108. methods: {
  109. handleDragStart(tool) {
  110. this.$emit('drag-start', tool)
  111. }
  112. }
  113. }
  114. </script>
  115. <style scoped>
  116. .horizontal-toolbar {
  117. display: flex;
  118. align-items: center;
  119. padding: 12px 20px;
  120. background: #fff;
  121. border-bottom: 1px solid #e4e7ed;
  122. gap: 30px;
  123. min-height: 60px;
  124. flex-wrap: wrap;
  125. }
  126. .toolbar-section {
  127. display: flex;
  128. align-items: center;
  129. gap: 20px;
  130. }
  131. .tools-section {
  132. flex: 0 0 auto;
  133. border-right: 1px solid #e4e7ed;
  134. padding-right: 20px;
  135. margin-right: 1px;
  136. }
  137. .middle-section {
  138. flex: 1;
  139. justify-content: flex-start;
  140. }
  141. .right-section {
  142. flex: 0 0 auto;
  143. justify-content: flex-end;
  144. }
  145. .toolbar-item {
  146. display: flex;
  147. align-items: center;
  148. gap: 8px;
  149. white-space: nowrap;
  150. }
  151. .item-label {
  152. font-size: 13px;
  153. color: #606266;
  154. font-weight: 500;
  155. min-width: fit-content;
  156. }
  157. .tools-horizontal {
  158. display: flex;
  159. gap: 4px;
  160. align-items: center;
  161. }
  162. /* 响应式设计 */
  163. @media (max-width: 1200px) {
  164. .horizontal-toolbar {
  165. gap: 20px;
  166. padding: 10px 15px;
  167. }
  168. .toolbar-section {
  169. gap: 15px;
  170. }
  171. }
  172. @media (max-width: 1024px) {
  173. .horizontal-toolbar {
  174. flex-wrap: wrap;
  175. gap: 15px;
  176. padding: 8px 12px;
  177. }
  178. .toolbar-section {
  179. gap: 12px;
  180. }
  181. .right-section {
  182. flex: 1 1 100%;
  183. justify-content: flex-start;
  184. }
  185. }
  186. @media (max-width: 768px) {
  187. .horizontal-toolbar {
  188. flex-direction: column;
  189. align-items: stretch;
  190. gap: 10px;
  191. padding: 10px;
  192. }
  193. .toolbar-section {
  194. justify-content: space-between;
  195. flex-wrap: wrap;
  196. }
  197. .toolbar-item {
  198. flex: 1;
  199. min-width: 200px;
  200. }
  201. }
  202. </style>