@qxs-bns/components 0.0.48 → 0.0.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/es/index.css +5 -5
  2. package/es/package.json.mjs +1 -1
  3. package/es/src/data-chart/src/components/area.vue2.mjs.map +1 -1
  4. package/es/src/data-chart/src/components/bar.vue.mjs +1 -1
  5. package/es/src/data-chart/src/components/bar.vue.mjs.map +1 -1
  6. package/es/src/data-chart/src/components/card.vue2.mjs.map +1 -1
  7. package/es/src/data-chart/src/components/empty.svg.mjs +1 -1
  8. package/es/src/data-chart/src/components/empty.svg.mjs.map +1 -1
  9. package/es/src/data-chart/src/components/empty.vue.mjs +1 -1
  10. package/es/src/data-chart/src/components/empty.vue.mjs.map +1 -1
  11. package/es/src/data-chart/src/components/funnel.vue.mjs +1 -1
  12. package/es/src/data-chart/src/components/funnel.vue.mjs.map +1 -1
  13. package/es/src/data-chart/src/components/line.vue2.mjs +1 -1
  14. package/es/src/data-chart/src/components/line.vue2.mjs.map +1 -1
  15. package/es/src/data-chart/src/components/pie.vue.mjs +1 -1
  16. package/es/src/data-chart/src/components/pie.vue.mjs.map +1 -1
  17. package/es/src/data-chart/src/components/radar.vue.mjs +1 -1
  18. package/es/src/data-chart/src/components/radar.vue.mjs.map +1 -1
  19. package/es/src/data-chart/src/components/scatter-simple.vue.mjs +1 -1
  20. package/es/src/data-chart/src/components/scatter-simple.vue.mjs.map +1 -1
  21. package/es/src/data-chart/src/components/scatter.vue.mjs +1 -1
  22. package/es/src/data-chart/src/components/scatter.vue.mjs.map +1 -1
  23. package/es/src/data-chart/src/components/table.vue.mjs +1 -1
  24. package/es/src/data-chart/src/components/table.vue.mjs.map +1 -1
  25. package/es/src/data-chart/src/data-chart.vue.mjs +1 -1
  26. package/es/src/data-chart/src/data-chart.vue.mjs.map +1 -1
  27. package/es/src/data-chart/src/utils/config.mjs +1 -1
  28. package/es/src/data-chart/src/utils/config.mjs.map +1 -1
  29. package/es/src/data-chart/src/utils/safe-eval.mjs +2 -0
  30. package/es/src/data-chart/src/utils/safe-eval.mjs.map +1 -0
  31. package/es/src/data-chart/src/utils/useCharts.mjs +1 -1
  32. package/es/src/data-chart/src/utils/useCharts.mjs.map +1 -1
  33. package/es/src/file-upload/src/file-upload.vue.mjs +1 -1
  34. package/es/src/file-upload/src/file-upload.vue.mjs.map +1 -1
  35. package/es/src/fixed-action-bar/src/fixed-action-bar.vue.mjs +1 -1
  36. package/es/src/fixed-action-bar/src/fixed-action-bar.vue.mjs.map +1 -1
  37. package/es/src/image-upload/src/image-upload.vue.mjs +1 -1
  38. package/es/src/image-upload/src/image-upload.vue.mjs.map +1 -1
  39. package/es/src/photo-crop-tool/src/photo-crop-tool.vue.mjs.map +1 -1
  40. package/es/src/subject-action/index.mjs.map +1 -1
  41. package/es/src/subject-action/src/subject-action.vue.mjs +1 -1
  42. package/es/src/subject-action/src/subject-action.vue.mjs.map +1 -1
  43. package/es/src/subject-layout/index.mjs.map +1 -1
  44. package/es/src/subject-layout/src/subject-layout.vue.mjs.map +1 -1
  45. package/es/src/subject-list/src/components/SubjectPageEnd.vue.mjs +1 -1
  46. package/es/src/subject-list/src/components/SubjectPageEnd.vue.mjs.map +1 -1
  47. package/es/src/subject-list/src/components/SubjectRichText.vue.mjs +1 -1
  48. package/es/src/subject-list/src/components/SubjectRichText.vue.mjs.map +1 -1
  49. package/es/src/subject-list/src/components/subject-blank-fill.vue.mjs +1 -1
  50. package/es/src/subject-list/src/components/subject-blank-fill.vue.mjs.map +1 -1
  51. package/es/src/subject-list/src/components/subject-scale.vue.mjs +1 -1
  52. package/es/src/subject-list/src/components/subject-scale.vue.mjs.map +1 -1
  53. package/es/src/subject-list/src/components/subject-single.vue.mjs +1 -1
  54. package/es/src/subject-list/src/components/subject-single.vue.mjs.map +1 -1
  55. package/es/src/subject-list/src/components/subject-text-fill.vue.mjs +1 -1
  56. package/es/src/subject-list/src/components/subject-text-fill.vue.mjs.map +1 -1
  57. package/es/src/subject-list/src/subject-list.vue.mjs +1 -1
  58. package/es/src/subject-list/src/subject-list.vue.mjs.map +1 -1
  59. package/es/src/subject-type/index.mjs.map +1 -1
  60. package/es/src/subject-type/src/subject-type.vue.mjs.map +1 -1
  61. package/lib/index.css +5 -5
  62. package/lib/package.json.cjs +1 -1
  63. package/lib/src/data-chart/src/components/area.vue2.cjs.map +1 -1
  64. package/lib/src/data-chart/src/components/bar.vue.cjs +1 -1
  65. package/lib/src/data-chart/src/components/bar.vue.cjs.map +1 -1
  66. package/lib/src/data-chart/src/components/card.vue2.cjs.map +1 -1
  67. package/lib/src/data-chart/src/components/empty.svg.cjs +1 -1
  68. package/lib/src/data-chart/src/components/empty.svg.cjs.map +1 -1
  69. package/lib/src/data-chart/src/components/empty.vue.cjs +1 -1
  70. package/lib/src/data-chart/src/components/empty.vue.cjs.map +1 -1
  71. package/lib/src/data-chart/src/components/funnel.vue.cjs +1 -1
  72. package/lib/src/data-chart/src/components/funnel.vue.cjs.map +1 -1
  73. package/lib/src/data-chart/src/components/line.vue2.cjs +1 -1
  74. package/lib/src/data-chart/src/components/line.vue2.cjs.map +1 -1
  75. package/lib/src/data-chart/src/components/pie.vue.cjs +1 -1
  76. package/lib/src/data-chart/src/components/pie.vue.cjs.map +1 -1
  77. package/lib/src/data-chart/src/components/radar.vue.cjs +1 -1
  78. package/lib/src/data-chart/src/components/radar.vue.cjs.map +1 -1
  79. package/lib/src/data-chart/src/components/scatter-simple.vue.cjs +1 -1
  80. package/lib/src/data-chart/src/components/scatter-simple.vue.cjs.map +1 -1
  81. package/lib/src/data-chart/src/components/scatter.vue.cjs +1 -1
  82. package/lib/src/data-chart/src/components/scatter.vue.cjs.map +1 -1
  83. package/lib/src/data-chart/src/components/table.vue.cjs +1 -1
  84. package/lib/src/data-chart/src/components/table.vue.cjs.map +1 -1
  85. package/lib/src/data-chart/src/data-chart.vue.cjs +1 -1
  86. package/lib/src/data-chart/src/data-chart.vue.cjs.map +1 -1
  87. package/lib/src/data-chart/src/utils/config.cjs +1 -1
  88. package/lib/src/data-chart/src/utils/config.cjs.map +1 -1
  89. package/lib/src/data-chart/src/utils/safe-eval.cjs +2 -0
  90. package/lib/src/data-chart/src/utils/safe-eval.cjs.map +1 -0
  91. package/lib/src/data-chart/src/utils/useCharts.cjs +1 -1
  92. package/lib/src/data-chart/src/utils/useCharts.cjs.map +1 -1
  93. package/lib/src/file-upload/src/file-upload.vue.cjs +1 -1
  94. package/lib/src/file-upload/src/file-upload.vue.cjs.map +1 -1
  95. package/lib/src/fixed-action-bar/src/fixed-action-bar.vue.cjs +1 -1
  96. package/lib/src/fixed-action-bar/src/fixed-action-bar.vue.cjs.map +1 -1
  97. package/lib/src/image-upload/src/image-upload.vue.cjs +1 -1
  98. package/lib/src/image-upload/src/image-upload.vue.cjs.map +1 -1
  99. package/lib/src/photo-crop-tool/src/photo-crop-tool.vue.cjs.map +1 -1
  100. package/lib/src/subject-action/index.cjs.map +1 -1
  101. package/lib/src/subject-action/src/subject-action.vue.cjs +1 -1
  102. package/lib/src/subject-action/src/subject-action.vue.cjs.map +1 -1
  103. package/lib/src/subject-layout/index.cjs.map +1 -1
  104. package/lib/src/subject-layout/src/subject-layout.vue.cjs.map +1 -1
  105. package/lib/src/subject-list/src/components/SubjectPageEnd.vue.cjs +1 -1
  106. package/lib/src/subject-list/src/components/SubjectPageEnd.vue.cjs.map +1 -1
  107. package/lib/src/subject-list/src/components/SubjectRichText.vue.cjs +1 -1
  108. package/lib/src/subject-list/src/components/SubjectRichText.vue.cjs.map +1 -1
  109. package/lib/src/subject-list/src/components/subject-blank-fill.vue.cjs +1 -1
  110. package/lib/src/subject-list/src/components/subject-blank-fill.vue.cjs.map +1 -1
  111. package/lib/src/subject-list/src/components/subject-scale.vue.cjs +1 -1
  112. package/lib/src/subject-list/src/components/subject-scale.vue.cjs.map +1 -1
  113. package/lib/src/subject-list/src/components/subject-single.vue.cjs +1 -1
  114. package/lib/src/subject-list/src/components/subject-single.vue.cjs.map +1 -1
  115. package/lib/src/subject-list/src/components/subject-text-fill.vue.cjs +1 -1
  116. package/lib/src/subject-list/src/components/subject-text-fill.vue.cjs.map +1 -1
  117. package/lib/src/subject-list/src/subject-list.vue.cjs +1 -1
  118. package/lib/src/subject-list/src/subject-list.vue.cjs.map +1 -1
  119. package/lib/src/subject-type/index.cjs.map +1 -1
  120. package/lib/src/subject-type/src/subject-type.vue.cjs.map +1 -1
  121. package/package.json +4 -11
  122. package/theme-chalk/index.css +1 -1
  123. package/theme-chalk/src/base.scss +2 -2
  124. package/theme-chalk/src/fixed-action-bar.css +1 -1
  125. package/theme-chalk/src/fixed-action-bar.scss +1 -1
  126. package/theme-chalk/src/image-upload.css +1 -1
  127. package/theme-chalk/src/image-upload.scss +3 -1
  128. package/theme-chalk/src/subject-action.css +1 -1
  129. package/theme-chalk/src/subject-action.scss +3 -2
  130. package/theme-chalk/src/subject-layout.scss +19 -19
  131. package/theme-chalk/src/subject-list.css +1 -1
  132. package/theme-chalk/src/subject-list.scss +15 -14
  133. package/theme-chalk/src/tiny-mce-editor.scss +4 -2
  134. package/types/src/data-chart/src/components/area.vue.d.ts.map +1 -1
  135. package/types/src/data-chart/src/components/bar.vue.d.ts.map +1 -1
  136. package/types/src/data-chart/src/components/card.vue.d.ts.map +1 -1
  137. package/types/src/data-chart/src/components/empty.vue.d.ts.map +1 -1
  138. package/types/src/data-chart/src/components/funnel.vue.d.ts.map +1 -1
  139. package/types/src/data-chart/src/components/line.vue.d.ts.map +1 -1
  140. package/types/src/data-chart/src/components/pie.vue.d.ts +1 -1
  141. package/types/src/data-chart/src/components/pie.vue.d.ts.map +1 -1
  142. package/types/src/data-chart/src/components/radar.vue.d.ts.map +1 -1
  143. package/types/src/data-chart/src/components/scatter-simple.vue.d.ts.map +1 -1
  144. package/types/src/data-chart/src/components/scatter.vue.d.ts.map +1 -1
  145. package/types/src/data-chart/src/components/table.vue.d.ts.map +1 -1
  146. package/types/src/data-chart/src/data-chart.vue.d.ts.map +1 -1
  147. package/types/src/data-chart/src/utils/config.d.ts.map +1 -1
  148. package/types/src/data-chart/src/utils/safe-eval.d.ts +9 -0
  149. package/types/src/data-chart/src/utils/safe-eval.d.ts.map +1 -0
  150. package/types/src/data-chart/src/utils/useCharts.d.ts +4 -4
  151. package/types/src/data-chart/src/utils/useCharts.d.ts.map +1 -1
  152. package/types/src/file-upload/src/file-upload.vue.d.ts +5 -5
  153. package/types/src/file-upload/src/file-upload.vue.d.ts.map +1 -1
  154. package/types/src/fixed-action-bar/index.d.ts +3 -3
  155. package/types/src/fixed-action-bar/src/fixed-action-bar.vue.d.ts +1 -1
  156. package/types/src/fixed-action-bar/src/fixed-action-bar.vue.d.ts.map +1 -1
  157. package/types/src/image-upload/src/image-upload.vue.d.ts +6 -6
  158. package/types/src/image-upload/src/image-upload.vue.d.ts.map +1 -1
  159. package/types/src/photo-crop-tool/src/photo-crop-tool.vue.d.ts.map +1 -1
  160. package/types/src/subject-action/index.d.ts +11 -11
  161. package/types/src/subject-action/index.d.ts.map +1 -1
  162. package/types/src/subject-action/src/subject-action.vue.d.ts +10 -10
  163. package/types/src/subject-action/src/subject-action.vue.d.ts.map +1 -1
  164. package/types/src/subject-layout/index.d.ts +1 -1
  165. package/types/src/subject-layout/index.d.ts.map +1 -1
  166. package/types/src/subject-layout/src/subject-layout.vue.d.ts.map +1 -1
  167. package/types/src/subject-list/src/components/SubjectPageEnd.vue.d.ts.map +1 -1
  168. package/types/src/subject-list/src/components/SubjectRichText.vue.d.ts.map +1 -1
  169. package/types/src/subject-list/src/components/subject-blank-fill.vue.d.ts.map +1 -1
  170. package/types/src/subject-list/src/components/subject-scale.vue.d.ts.map +1 -1
  171. package/types/src/subject-list/src/components/subject-single.vue.d.ts.map +1 -1
  172. package/types/src/subject-list/src/components/subject-text-fill.vue.d.ts.map +1 -1
  173. package/types/src/subject-list/src/subject-list.vue.d.ts.map +1 -1
  174. package/types/src/subject-type/index.d.ts +1 -1
  175. package/types/src/subject-type/index.d.ts.map +1 -1
  176. package/types/src/subject-type/src/subject-type.vue.d.ts.map +1 -1
  177. package/types/tsconfig.tsbuildinfo +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"config.cjs","sources":["../../../../../../../packages/components/src/data-chart/src/utils/config.ts"],"sourcesContent":["import type { GeoJson, IconRow, IGroupByInfos, ISelectInfos } from '../types'\nimport { merge } from 'lodash-es'\n\n/**\n * 禁用功能函数\n * 判断当前图表类型是否被禁用\n * 调用时机:渲染页面\n * @param {object} selectInfos 选择信息\n * @param {object} groupByInfos 分组信息\n * @param {Message[]|Message} data 数据\n * @returns Boolean 布尔值\n */\nexport const iconList: {\n data: IconRow[]\n get: (type: keyof IconRow, value: any) => IconRow\n} = {\n get(type: keyof IconRow = 'showTypeName', value: any = 'table') {\n return iconList.data.find(item => item[type].toString() === value || item[type] === value)!\n },\n data: [\n {\n showTypeName: 'table',\n label: '表格',\n coverImg: 'table.png',\n disabled: () => false,\n subTypeList: [],\n showType: 0,\n baseConfig: {},\n },\n {\n showTypeName: 'line',\n label: '折线图',\n coverImg: 'line-stack.png',\n showType: 1,\n subTypeList: [\n {\n value: 'line-simple',\n icon: 'line-smooth',\n tooltipContent: '折线图',\n },\n {\n value: 'area-basic',\n icon: 'chart-line-area',\n tooltipContent: '折线面积图',\n },\n ],\n baseConfig: {\n tooltip: {\n confine: false,\n trigger: 'axis',\n axisPointer: {\n type: 'line',\n },\n },\n toolbox: {\n show: false,\n showTitle: false,\n feature: {\n // dataView: { readOnly: true },\n // restore: {},\n saveAsImage: {},\n },\n },\n legend: {\n type: 'scroll',\n top: '25px',\n },\n grid: {\n left: '0',\n bottom: '10px',\n containLabel: true,\n },\n xAxis: {\n type: 'category',\n boundaryGap: false,\n },\n yAxis: {\n type: 'value',\n },\n dataZoom: [\n {\n type: 'inside',\n },\n ],\n },\n disabled: (_: ISelectInfos[], groupByInfos: IGroupByInfos[]) => {\n const groupByInfosLenght = groupByInfos?.length\n if (groupByInfosLenght >= 1 && groupByInfosLenght < 2) {\n return false\n }\n return true\n },\n },\n {\n showTypeName: 'bar',\n label: '柱状图',\n coverImg: 'bar-tick-align.png',\n showType: 2,\n baseConfig: {\n legend: {\n type: 'scroll',\n top: '25px',\n },\n tooltip: {\n confine: false,\n trigger: 'axis',\n axisPointer: {\n type: 'shadow',\n },\n },\n toolbox: {\n show: false,\n showTitle: false,\n feature: {\n // dataView: { readOnly: true },\n // restore: {},\n saveAsImage: {},\n // myFull: { // 全屏\n // show: true,\n // title: '全屏',\n // icon: 'path://...',\n // }\n },\n },\n grid: {\n left: '0',\n bottom: '20px',\n containLabel: true,\n },\n xAxis: {\n axisLabel: {\n showMaxLabel: true,\n },\n axisTick: {\n alignWithLabel: true,\n },\n },\n yAxis: {},\n dataZoom: [\n {\n type: 'inside',\n },\n ],\n },\n subTypeList: [\n {\n value: 'bar-simple',\n icon: 'bar-simple',\n tooltipContent: '垂直条形图',\n },\n {\n value: 'bar-y-category',\n icon: 'bar-y-category',\n tooltipContent: '水平条形图',\n },\n ],\n disabled: (_: ISelectInfos[], groupByInfos: IGroupByInfos[]) => {\n const groupByInfosLenght = groupByInfos?.length\n if (groupByInfosLenght >= 1) {\n return false\n }\n return true\n },\n },\n {\n showTypeName: 'pie',\n label: '饼图',\n coverImg: 'pie-simple.png',\n showType: 4,\n subTypeList: [\n {\n value: 'pie-simple',\n icon: 'pie-simple',\n tooltipContent: '饼图',\n },\n {\n value: 'pie-borderRadius',\n icon: 'pie-borderRadius',\n tooltipContent: '环形图',\n },\n ],\n baseConfig: {\n tooltip: {\n confine: true,\n formatter: '{a}<br>{b}: {c}({d}%)',\n trigger: 'item',\n },\n toolbox: {\n show: false,\n showTitle: false,\n feature: {\n // dataView: { readOnly: true },\n // restore: {},\n saveAsImage: {},\n },\n },\n legend: {\n type: 'scroll',\n top: '25px',\n },\n },\n disabled: (selectInfos: ISelectInfos[], groupByInfos: IGroupByInfos[]) => {\n const groupByInfosLenght = groupByInfos?.length\n const selectInfosLength = selectInfos?.length\n if (selectInfosLength <= 4 && groupByInfosLenght > 0 && groupByInfosLenght <= 1) {\n return false\n }\n return true\n },\n },\n {\n showTypeName: 'area',\n label: '地图',\n coverImg: 'area.png',\n showType: 5,\n subTypeList: [],\n baseConfig: {\n tooltip: {\n confine: true,\n trigger: 'item',\n },\n toolbox: {\n show: false,\n showTitle: false,\n feature: {\n // dataView: { readOnly: true },\n // restore: {},\n saveAsImage: {},\n },\n },\n visualMap: {\n text: ['高', '低'],\n realtime: false,\n calculable: true,\n inRange: {\n color: ['lightskyblue', 'yellow', 'orangered'],\n },\n },\n },\n disabled: (_: ISelectInfos[], groupByInfos: IGroupByInfos[]) => {\n const groupByInfosLenght = groupByInfos?.length\n const flag = groupByInfos?.some(({ colDesc }) => (colDesc.includes('省') || colDesc.includes('市')))\n if (flag && groupByInfosLenght > 0) {\n return false\n }\n return true\n },\n },\n {\n showTypeName: 'funnel',\n label: '漏斗图',\n coverImg: 'funnel.png',\n showType: 6,\n subTypeList: [],\n baseConfig: {\n tooltip: {\n confine: true,\n trigger: 'item',\n formatter: '{a} <br/>{b} : {c}',\n },\n toolbox: {\n show: false,\n showTitle: false,\n feature: {\n // dataView: { readOnly: true },\n // restore: {},\n saveAsImage: {},\n },\n },\n legend: {\n type: 'scroll',\n top: 20,\n },\n },\n disabled: (selectInfos: ISelectInfos[], groupByInfos: IGroupByInfos[]) => {\n const groupByInfosLenght = groupByInfos?.length\n const selectInfosLength = selectInfos?.length\n if (selectInfosLength <= 5 && groupByInfosLenght > 0 && groupByInfosLenght <= 1) {\n return false\n }\n return true\n },\n },\n\n // { label: 'scatter', value: 7 },\n {\n showTypeName: 'card',\n label: '卡片',\n coverImg: 'card.png',\n showType: 9,\n subTypeList: [],\n baseConfig: {},\n disabled: (selectInfos: ISelectInfos[], groupByInfos: IGroupByInfos[]) => {\n const groupByInfosLenght = groupByInfos?.length\n const selectInfosLength = selectInfos?.length\n if (selectInfosLength > 0 && groupByInfosLenght <= 1) {\n return false\n }\n return true\n },\n },\n {\n showTypeName: 'radar',\n label: '雷达图',\n coverImg: 'radar.png',\n showType: 10,\n subTypeList: [],\n baseConfig: {\n legend: {\n type: 'scroll',\n orient: 'vertical',\n left: 'left',\n top: '25px',\n },\n tooltip: {\n confine: true,\n trigger: 'item',\n },\n toolbox: {\n show: false,\n showTitle: false,\n feature: {\n // dataView: { readOnly: true },\n // restore: {},\n saveAsImage: {},\n },\n },\n radar: {\n // shape: 'circle',\n center: ['50%', '55%'],\n },\n },\n disabled: (selectInfos: ISelectInfos[], groupByInfos: IGroupByInfos[]) => {\n const groupByInfosLenght = groupByInfos?.length\n if (groupByInfosLenght === 1 && selectInfos.length === 1) {\n return false\n }\n return true\n },\n },\n {\n showTypeName: 'scatter-simple',\n label: '散点图',\n coverImg: '',\n showType: 11,\n subTypeList: [],\n disabled: () => false,\n baseConfig: {\n grid: {\n left: '0',\n bottom: '10px',\n containLabel: true,\n },\n tooltip: {\n showDelay: 0,\n axisPointer: {\n show: true,\n type: 'cross',\n lineStyle: {\n type: 'dashed',\n width: 1,\n },\n },\n },\n toolbox: {\n show: false,\n showTitle: false,\n feature: {\n // dataView: { readOnly: true },\n // restore: {},\n saveAsImage: {},\n },\n },\n legend: {\n type: 'scroll',\n top: '25px',\n },\n xAxis: {\n splitLine: {\n lineStyle: {\n type: 'dashed',\n },\n },\n },\n yAxis: {\n splitLine: {\n lineStyle: {\n type: 'dashed',\n },\n },\n },\n },\n },\n ],\n}\n\nexport function showTypeText(showType = 0): IconRow {\n const row = iconList.get('showType', showType)\n return row\n}\n\n// 修改默认配置\nexport function setDefaultChartOption(option: IconRow[], changeConfig: any) {\n const obj: {\n [key in IconRow['showTypeName']]: any\n } = {} as { [key in IconRow['showTypeName']]: any }\n option.forEach((item) => {\n obj[item.showTypeName] = merge(item.baseConfig, changeConfig)\n })\n return obj\n}\nexport const defaultChartOption = setDefaultChartOption(iconList.data, {\n backgroundColor: 'transparent',\n title: {\n textStyle: {\n fontSize: 14,\n lineHeight: 16,\n },\n },\n})\n// 获取地图数据(GeoJson)\nexport function getGeoJsonData(options: any): Promise<GeoJson> {\n return new Promise((resolve) => {\n const opt = {\n showbiz: false,\n extensions: 'all',\n ...options,\n }\n\n import('@amap/amap-jsapi-loader')\n .then(({ default: AMapLoader }) => AMapLoader.load({\n key: '2e820fac2a528b016a4cb95bb463e69e',\n version: '1.4.15',\n plugins: ['AMap.DistrictSearch'],\n AMapUI: {\n version: '1.1',\n plugins: ['geo/DistrictExplorer'],\n },\n }))\n .then((AMap) => {\n const district = new AMap.DistrictSearch(opt)\n // 行政区查询\n district.search(options.adcode, (_: any, result: any) => {\n // eslint-disable-next-line\n // @ts-expect-error\n AMapUI.loadUI(['geo/DistrictExplorer'], (DistrictExplorer: any) => {\n // 创建一个实例\n const districtExplorer = new DistrictExplorer()\n districtExplorer.loadAreaNode(result.districtList[0].adcode, (error: any, areaNode: any) => {\n if (error) {\n console.error(error)\n return\n }\n const mapJson: GeoJson = {\n features: [],\n type: 'FeatureCollection',\n }\n // geoJson必须这种格式\n mapJson.features = areaNode.getSubFeatures()\n resolve(mapJson)\n })\n })\n })\n })\n .catch((error) => {\n console.error('Failed to load map:', error)\n resolve({\n features: [],\n type: 'FeatureCollection',\n })\n })\n })\n}\n"],"names":["iconList","data","showTypeName","label","coverImg","disabled","subTypeList","showType","baseConfig","value","icon","tooltipContent","tooltip","confine","trigger","axisPointer","type","toolbox","show","showTitle","feature","saveAsImage","legend","top","grid","left","bottom","containLabel","xAxis","boundaryGap","yAxis","dataZoom","_","groupByInfos","groupByInfosLenght","length","axisLabel","showMaxLabel","axisTick","alignWithLabel","formatter","selectInfos","selectInfosLength","visualMap","text","realtime","calculable","inRange","color","flag","some","_ref","colDesc","includes","orient","radar","center","showDelay","lineStyle","width","splitLine","setDefaultChartOption","option","changeConfig","obj","forEach","item","merge","defaultChartOption","backgroundColor","title","textStyle","fontSize","lineHeight","options","Promise","resolve","opt","showbiz","extensions","import","then","_ref2","default","AMapLoader","load","key","version","plugins","AMapUI","AMap","DistrictSearch","search","adcode","result","loadUI","DistrictExplorer","loadAreaNode","districtList","error","areaNode","console","mapJson","features","getSubFeatures","catch"],"mappings":"wCAYO,MAAMA,EAGT,CAIFC,KAAM,CACJ,CACEC,aAAc,QACdC,MAAO,KACPC,SAAU,YACVC,SAAUA,KAAM,EAChBC,YAAa,GACbC,SAAU,EACVC,WAAY,CAAA,GAEd,CACEN,aAAc,OACdC,MAAO,MACPC,SAAU,iBACVG,SAAU,EACVD,YAAa,CACX,CACEG,MAAO,cACPC,KAAM,cACNC,eAAgB,OAElB,CACEF,MAAO,aACPC,KAAM,kBACNC,eAAgB,UAGpBH,WAAY,CACVI,QAAS,CACPC,SAAS,EACTC,QAAS,OACTC,YAAa,CACXC,KAAM,SAGVC,QAAS,CACPC,MAAM,EACNC,WAAW,EACXC,QAAS,CAGPC,YAAa,CAAA,IAGjBC,OAAQ,CACNN,KAAM,SACNO,IAAK,QAEPC,KAAM,CACJC,KAAM,IACNC,OAAQ,OACRC,cAAc,GAEhBC,MAAO,CACLZ,KAAM,WACNa,aAAa,GAEfC,MAAO,CACLd,KAAM,SAERe,SAAU,CACR,CACEf,KAAM,YAIZX,SAAUA,CAAC2B,EAAmBC,KAC5B,MAAMC,EAAqBD,GAAcE,OACrC,QAAAD,GAAsB,GAAKA,EAAqB,EAG7C,GAGX,CACEhC,aAAc,MACdC,MAAO,MACPC,SAAU,qBACVG,SAAU,EACVC,WAAY,CACVc,OAAQ,CACNN,KAAM,SACNO,IAAK,QAEPX,QAAS,CACPC,SAAS,EACTC,QAAS,OACTC,YAAa,CACXC,KAAM,WAGVC,QAAS,CACPC,MAAM,EACNC,WAAW,EACXC,QAAS,CAGPC,YAAa,CAAA,IAQjBG,KAAM,CACJC,KAAM,IACNC,OAAQ,OACRC,cAAc,GAEhBC,MAAO,CACLQ,UAAW,CACTC,cAAc,GAEhBC,SAAU,CACRC,gBAAgB,IAGpBT,MAAO,CAAC,EACRC,SAAU,CACR,CACEf,K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S,CAGPC,YAAa,CAAA,IAGjBC,OAAQ,CACNN,KAAM,SACNO,IAAK,QAEPK,MAAO,CACLgC,UAAW,CACTF,UAAW,CACT1C,KAAM,YAIZc,MAAO,CACL8B,UAAW,CACTF,UAAW,CACT1C,KAAM,gBAeJ,SAAA6C,EAAsBC,EAAmBC,GACvD,MAAMC,EAEF,CAAC,EAIE,OAHAF,EAAAG,SAASC,IACdF,EAAIE,EAAKhE,cAAgBiE,EAAMA,MAAAD,EAAK1D,WAAYuD,EAAY,IAEvDC,CACT,CACa,MAAAI,EAAqBP,EAAsB7D,EAASC,KAAM,CACrEoE,gBAAiB,cACjBC,MAAO,CACLC,UAAW,CACTC,SAAU,GACVC,WAAY,2DAKX,SAAwBC,GACtB,OAAA,IAAIC,SAASC,IAClB,MAAMC,EAAM,CACVC,SAAS,EACTC,WAAY,SACTL,GAGEM,OAAA,2BACJC,MAAKC,IAAA,IAAGC,QAASC,GAAiBF,EAAA,OAAAE,EAAWC,KAAK,CACjDC,IAAK,mCACLC,QAAS,SACTC,QAAS,CAAC,uBACVC,OAAQ,CACNF,QAAS,MACTC,QAAS,CAAC,0BAEZ,IACDP,MAAMS,IACY,IAAIA,EAAKC,eAAed,GAEhCe,OAAOlB,EAAQmB,QAAQ,CAAC7D,EAAQ8D,KAGvCL,OAAOM,OAAO,CAAC,yBAA0BC,KAEd,IAAIA,GACZC,aAAaH,EAAOI,aAAa,GAAGL,QAAQ,CAACM,EAAYC,KACxE,GAAID,EAEF,YADAE,QAAQF,MAAMA,GAGhB,MAAMG,EAAmB,CACvBC,SAAU,GACVvF,KAAM,qBAGAsF,EAAAC,SAAWH,EAASI,iBAC5B5B,EAAQ0B,EAAO,GAChB,GACF,GACF,IAEFG,OAAON,IACEE,QAAAF,MAAM,sBAAuBA,GAC7BvB,EAAA,CACN2B,SAAU,GACVvF,KAAM,qBACP,GACF,GAEP"}
1
+ {"version":3,"file":"config.cjs","sources":["../../../../../../../packages/components/src/data-chart/src/utils/config.ts"],"sourcesContent":["import type { GeoJson, IconRow, IGroupByInfos, ISelectInfos } from '../types'\nimport { merge } from 'lodash-es'\n\n/**\n * 禁用功能函数\n * 判断当前图表类型是否被禁用\n * 调用时机:渲染页面\n * @param {object} selectInfos 选择信息\n * @param {object} groupByInfos 分组信息\n * @param {Message[]|Message} data 数据\n * @returns Boolean 布尔值\n */\nexport const iconList: {\n data: IconRow[]\n get: (type: keyof IconRow, value: any) => IconRow\n} = {\n get(type: keyof IconRow = 'showTypeName', value: any = 'table') {\n return iconList.data.find(item => item[type].toString() === value || item[type] === value)!\n },\n data: [\n {\n showTypeName: 'table',\n label: '表格',\n coverImg: 'table.png',\n disabled: () => false,\n subTypeList: [],\n showType: 0,\n baseConfig: {},\n },\n {\n showTypeName: 'line',\n label: '折线图',\n coverImg: 'line-stack.png',\n showType: 1,\n subTypeList: [\n {\n value: 'line-simple',\n icon: 'line-smooth',\n tooltipContent: '折线图',\n },\n {\n value: 'area-basic',\n icon: 'chart-line-area',\n tooltipContent: '折线面积图',\n },\n ],\n baseConfig: {\n tooltip: {\n confine: false,\n trigger: 'axis',\n axisPointer: {\n type: 'line',\n },\n },\n toolbox: {\n show: false,\n showTitle: false,\n feature: {\n // dataView: { readOnly: true },\n // restore: {},\n saveAsImage: {},\n },\n },\n legend: {\n type: 'scroll',\n top: '25px',\n },\n grid: {\n left: '0',\n bottom: '10px',\n containLabel: true,\n },\n xAxis: {\n type: 'category',\n boundaryGap: false,\n },\n yAxis: {\n type: 'value',\n },\n dataZoom: [\n {\n type: 'inside',\n },\n ],\n },\n disabled: (_: ISelectInfos[], groupByInfos: IGroupByInfos[]) => {\n const groupByInfosLenght = groupByInfos?.length\n if (groupByInfosLenght >= 1 && groupByInfosLenght < 2) {\n return false\n }\n return true\n },\n },\n {\n showTypeName: 'bar',\n label: '柱状图',\n coverImg: 'bar-tick-align.png',\n showType: 2,\n baseConfig: {\n legend: {\n type: 'scroll',\n top: '25px',\n },\n tooltip: {\n confine: false,\n trigger: 'axis',\n axisPointer: {\n type: 'shadow',\n },\n },\n toolbox: {\n show: false,\n showTitle: false,\n feature: {\n // dataView: { readOnly: true },\n // restore: {},\n saveAsImage: {},\n // myFull: { // 全屏\n // show: true,\n // title: '全屏',\n // icon: 'path://...',\n // }\n },\n },\n grid: {\n left: '0',\n bottom: '20px',\n containLabel: true,\n },\n xAxis: {\n axisLabel: {\n showMaxLabel: true,\n },\n axisTick: {\n alignWithLabel: true,\n },\n },\n yAxis: {},\n dataZoom: [\n {\n type: 'inside',\n },\n ],\n },\n subTypeList: [\n {\n value: 'bar-simple',\n icon: 'bar-simple',\n tooltipContent: '垂直条形图',\n },\n {\n value: 'bar-y-category',\n icon: 'bar-y-category',\n tooltipContent: '水平条形图',\n },\n ],\n disabled: (_: ISelectInfos[], groupByInfos: IGroupByInfos[]) => {\n const groupByInfosLenght = groupByInfos?.length\n if (groupByInfosLenght >= 1) {\n return false\n }\n return true\n },\n },\n {\n showTypeName: 'pie',\n label: '饼图',\n coverImg: 'pie-simple.png',\n showType: 4,\n subTypeList: [\n {\n value: 'pie-simple',\n icon: 'pie-simple',\n tooltipContent: '饼图',\n },\n {\n value: 'pie-borderRadius',\n icon: 'pie-borderRadius',\n tooltipContent: '环形图',\n },\n ],\n baseConfig: {\n tooltip: {\n confine: true,\n formatter: '{a}<br>{b}: {c}({d}%)',\n trigger: 'item',\n },\n toolbox: {\n show: false,\n showTitle: false,\n feature: {\n // dataView: { readOnly: true },\n // restore: {},\n saveAsImage: {},\n },\n },\n legend: {\n type: 'scroll',\n top: '25px',\n },\n },\n disabled: (selectInfos: ISelectInfos[], groupByInfos: IGroupByInfos[]) => {\n const groupByInfosLenght = groupByInfos?.length\n const selectInfosLength = selectInfos?.length\n if (selectInfosLength <= 4 && groupByInfosLenght > 0 && groupByInfosLenght <= 1) {\n return false\n }\n return true\n },\n },\n {\n showTypeName: 'area',\n label: '地图',\n coverImg: 'area.png',\n showType: 5,\n subTypeList: [],\n baseConfig: {\n tooltip: {\n confine: true,\n trigger: 'item',\n },\n toolbox: {\n show: false,\n showTitle: false,\n feature: {\n // dataView: { readOnly: true },\n // restore: {},\n saveAsImage: {},\n },\n },\n visualMap: {\n text: ['高', '低'],\n realtime: false,\n calculable: true,\n inRange: {\n color: ['lightskyblue', 'yellow', 'orangered'],\n },\n },\n },\n disabled: (_: ISelectInfos[], groupByInfos: IGroupByInfos[]) => {\n const groupByInfosLenght = groupByInfos?.length\n const flag = groupByInfos?.some(({ colDesc }) => (colDesc.includes('省') || colDesc.includes('市')))\n if (flag && groupByInfosLenght > 0) {\n return false\n }\n return true\n },\n },\n {\n showTypeName: 'funnel',\n label: '漏斗图',\n coverImg: 'funnel.png',\n showType: 6,\n subTypeList: [],\n baseConfig: {\n tooltip: {\n confine: true,\n trigger: 'item',\n formatter: '{a} <br/>{b} : {c}',\n },\n toolbox: {\n show: false,\n showTitle: false,\n feature: {\n // dataView: { readOnly: true },\n // restore: {},\n saveAsImage: {},\n },\n },\n legend: {\n type: 'scroll',\n top: 20,\n },\n },\n disabled: (selectInfos: ISelectInfos[], groupByInfos: IGroupByInfos[]) => {\n const groupByInfosLenght = groupByInfos?.length\n const selectInfosLength = selectInfos?.length\n if (selectInfosLength <= 5 && groupByInfosLenght > 0 && groupByInfosLenght <= 1) {\n return false\n }\n return true\n },\n },\n\n // { label: 'scatter', value: 7 },\n {\n showTypeName: 'card',\n label: '卡片',\n coverImg: 'card.png',\n showType: 9,\n subTypeList: [],\n baseConfig: {},\n disabled: (selectInfos: ISelectInfos[], groupByInfos: IGroupByInfos[]) => {\n const groupByInfosLenght = groupByInfos?.length\n const selectInfosLength = selectInfos?.length\n if (selectInfosLength > 0 && groupByInfosLenght <= 1) {\n return false\n }\n return true\n },\n },\n {\n showTypeName: 'radar',\n label: '雷达图',\n coverImg: 'radar.png',\n showType: 10,\n subTypeList: [],\n baseConfig: {\n legend: {\n type: 'scroll',\n orient: 'vertical',\n left: 'left',\n top: '25px',\n },\n tooltip: {\n confine: true,\n trigger: 'item',\n },\n toolbox: {\n show: false,\n showTitle: false,\n feature: {\n // dataView: { readOnly: true },\n // restore: {},\n saveAsImage: {},\n },\n },\n radar: {\n // shape: 'circle',\n center: ['50%', '55%'],\n },\n },\n disabled: (selectInfos: ISelectInfos[], groupByInfos: IGroupByInfos[]) => {\n const groupByInfosLenght = groupByInfos?.length\n if (groupByInfosLenght === 1 && selectInfos.length === 1) {\n return false\n }\n return true\n },\n },\n {\n showTypeName: 'scatter-simple',\n label: '散点图',\n coverImg: '',\n showType: 11,\n subTypeList: [],\n disabled: () => false,\n baseConfig: {\n grid: {\n left: '0',\n bottom: '10px',\n containLabel: true,\n },\n tooltip: {\n showDelay: 0,\n axisPointer: {\n show: true,\n type: 'cross',\n lineStyle: {\n type: 'dashed',\n width: 1,\n },\n },\n },\n toolbox: {\n show: false,\n showTitle: false,\n feature: {\n // dataView: { readOnly: true },\n // restore: {},\n saveAsImage: {},\n },\n },\n legend: {\n type: 'scroll',\n top: '25px',\n },\n xAxis: {\n splitLine: {\n lineStyle: {\n type: 'dashed',\n },\n },\n },\n yAxis: {\n splitLine: {\n lineStyle: {\n type: 'dashed',\n },\n },\n },\n },\n },\n ],\n}\n\nexport function showTypeText(showType = 0): IconRow {\n const row = iconList.get('showType', showType)\n return row\n}\n\n// 修改默认配置\nexport function setDefaultChartOption(option: IconRow[], changeConfig: any) {\n const obj: {\n [key in IconRow['showTypeName']]: any\n } = {} as { [key in IconRow['showTypeName']]: any }\n option.forEach((item) => {\n obj[item.showTypeName] = merge(item.baseConfig, changeConfig)\n })\n return obj\n}\nexport const defaultChartOption = setDefaultChartOption(iconList.data, {\n backgroundColor: 'transparent',\n title: {\n textStyle: {\n fontSize: 14,\n lineHeight: 16,\n },\n },\n})\n// 获取地图数据(GeoJson)\n// 添加缓存对象\nconst geoJsonCache = new Map<string, GeoJson>()\nexport function getGeoJsonData(options: any): Promise<GeoJson> {\n const { adcode } = options\n\n // 检查缓存中是否存在对应的 GeoJSON 数据\n if (geoJsonCache.has(adcode)) {\n const cachedGeoJson = geoJsonCache.get(adcode)\n if (cachedGeoJson) {\n return Promise.resolve(cachedGeoJson)\n }\n }\n\n return new Promise((resolve) => {\n const opt = {\n showbiz: false,\n extensions: 'all',\n ...options,\n }\n\n import('@amap/amap-jsapi-loader')\n .then(({ default: AMapLoader }) => AMapLoader.load({\n key: '2e820fac2a528b016a4cb95bb463e69e',\n version: '1.4.15',\n plugins: ['AMap.DistrictSearch'],\n AMapUI: {\n version: '1.1',\n plugins: ['geo/DistrictExplorer'],\n },\n }))\n .then((AMap) => {\n const district = new AMap.DistrictSearch(opt)\n // 行政区查询\n district.search(options.adcode, (_: any, result: any) => {\n // eslint-disable-next-line\n // @ts-expect-error\n AMapUI.loadUI(['geo/DistrictExplorer'], (DistrictExplorer: any) => {\n // 创建一个实例\n const districtExplorer = new DistrictExplorer()\n districtExplorer.loadAreaNode(result.districtList[0].adcode, (error: any, areaNode: any) => {\n if (error) {\n console.error(error)\n return\n }\n const mapJson: GeoJson = {\n features: [],\n type: 'FeatureCollection',\n }\n // geoJson必须这种格式\n mapJson.features = areaNode.getSubFeatures()\n\n // 将获取到的 GeoJSON 数据存入缓存\n geoJsonCache.set(adcode, mapJson)\n\n resolve(mapJson)\n })\n })\n })\n })\n .catch((error) => {\n console.error('Failed to load map:', error)\n resolve({\n features: [],\n type: 'FeatureCollection',\n })\n })\n })\n}\n"],"names":["iconList","data","showTypeName","label","coverImg","disabled","subTypeList","showType","baseConfig","value","icon","tooltipContent","tooltip","confine","trigger","axisPointer","type","toolbox","show","showTitle","feature","saveAsImage","legend","top","grid","left","bottom","containLabel","xAxis","boundaryGap","yAxis","dataZoom","_","groupByInfos","groupByInfosLenght","length","axisLabel","showMaxLabel","axisTick","alignWithLabel","formatter","selectInfos","selectInfosLength","visualMap","text","realtime","calculable","inRange","color","flag","some","_ref","colDesc","includes","orient","radar","center","showDelay","lineStyle","width","splitLine","setDefaultChartOption","option","changeConfig","obj","forEach","item","merge","defaultChartOption","backgroundColor","title","textStyle","fontSize","lineHeight","geoJsonCache","Map","options","adcode","has","cachedGeoJson","get","Promise","resolve","opt","showbiz","extensions","import","then","_ref2","default","AMapLoader","load","key","version","plugins","AMapUI","AMap","DistrictSearch","search","result","loadUI","DistrictExplorer","loadAreaNode","districtList","error","areaNode","console","mapJson","features","getSubFeatures","set","catch"],"mappings":"wCAYO,MAAMA,EAGT,CAIFC,KAAM,CACJ,CACEC,aAAc,QACdC,MAAO,KACPC,SAAU,YACVC,SAAUA,KAAM,EAChBC,YAAa,GACbC,SAAU,EACVC,WAAY,CAAA,GAEd,CACEN,aAAc,OACdC,MAAO,MACPC,SAAU,iBACVG,SAAU,EACVD,YAAa,CACX,CACEG,MAAO,cACPC,KAAM,cACNC,eAAgB,OAElB,CACEF,MAAO,aACPC,KAAM,kBACNC,eAAgB,UAGpBH,WAAY,CACVI,QAAS,CACPC,SAAS,EACTC,QAAS,OACTC,YAAa,CACXC,KAAM,SAGVC,QAAS,CACPC,MAAM,EACNC,WAAW,EACXC,QAAS,CAGPC,YAAa,CAAA,IAGjBC,OAAQ,CACNN,KAAM,SACNO,IAAK,QAEPC,KAAM,CACJC,KAAM,IACNC,OAAQ,OACRC,cAAc,GAEhBC,MAAO,CACLZ,KAAM,WACNa,aAAa,GAEfC,MAAO,CACLd,KAAM,SAERe,SAAU,CACR,CACEf,KAAM,YAIZX,SAAUA,CAAC2B,EAAmBC,KAC5B,MAAMC,EAAqBD,GAAcE,OACrC,QAAAD,GAAsB,GAAKA,EAAqB,EAG7C,GAGX,CACEhC,aAAc,MACdC,MAAO,MACPC,SAAU,qBACVG,SAAU,EACVC,WAAY,CACVc,OAAQ,CACNN,KAAM,SACNO,IAAK,QAEPX,QAAS,CACPC,SAAS,EACTC,QAAS,OACTC,YAAa,CACXC,KAAM,WAGVC,QAAS,CACPC,MAAM,EACNC,WAAW,EACXC,QAAS,CAGPC,YAAa,CAAA,IAQjBG,KAAM,CACJC,KAAM,IACNC,OAAQ,OACRC,cAAc,G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AmB,CACvBC,SAAU,GACV5F,KAAM,qBAGA2F,EAAAC,SAAWH,EAASI,iBAGfnC,EAAAoC,IAAIjC,EAAQ8B,GAEzBzB,EAAQyB,EAAO,GAChB,GACF,GACF,IAEFI,OAAOP,IACEE,QAAAF,MAAM,sBAAuBA,GAC7BtB,EAAA,CACN0B,SAAU,GACV5F,KAAM,qBACP,GACF,GAEP"}
@@ -0,0 +1,2 @@
1
+ "use strict";exports.safeEvalConfig=function(e,t){const n={...{Math:Math,Date:Date,Array:Array,Object:Object,String:String,Number:Number,Boolean:Boolean,console:console,JSON:JSON},config:{...t}},o=new Proxy(n,{has:(e,t)=>!0,get:(e,t)=>{if("symbol"==typeof t){if(t===Symbol.unscopables)return;return Reflect.get(e,t)}return e[t]}});try{const t=`with (sandbox) { ${e} }`;return new Function("sandbox",t)(o),o.config}catch(e){return console.error("配置处理失败:",e),t}};
2
+ //# sourceMappingURL=safe-eval.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe-eval.cjs","sources":["../../../../../../../packages/components/src/data-chart/src/utils/safe-eval.ts"],"sourcesContent":["import type { EChartsOption } from '../types'\n\n/**\n * 安全的配置处理函数\n * @param jsCode - JavaScript 代码片段\n * @param config - ECharts 配置对象\n * @returns 处理后的配置对象\n */\nexport function safeEvalConfig(jsCode: string, config: EChartsOption): EChartsOption {\n // 预定义允许的操作和函数\n const allowedGlobals = {\n Math,\n Date,\n Array,\n Object,\n String,\n Number,\n Boolean,\n console,\n JSON,\n }\n\n // 创建安全的执行环境\n const sandbox = {\n ...allowedGlobals,\n config: { ...config },\n }\n\n // 使用 with 和 Proxy 创建安全的执行环境\n const handler: ProxyHandler<typeof sandbox> = {\n has: (_target, _key) => {\n return true // 使所有变量查找都在 sandbox 中\n },\n get: (target, key) => {\n // 处理 Symbol 类型的 key\n if (typeof key === 'symbol') {\n if (key === Symbol.unscopables) {\n return undefined\n }\n return Reflect.get(target, key)\n }\n return target[key as keyof typeof target]\n },\n }\n\n const proxiedSandbox = new Proxy(sandbox, handler)\n\n try {\n // 使用 with 语句创建局部作用域\n const code = `with (sandbox) { ${jsCode} }`\n // eslint-disable-next-line no-new-func\n const fn = new Function('sandbox', code)\n fn(proxiedSandbox)\n\n return proxiedSandbox.config as EChartsOption\n }\n catch (error) {\n console.error('配置处理失败:', error)\n return config\n }\n}\n"],"names":["jsCode","config","sandbox","Math","Date","Array","Object","String","Number","Boolean","console","JSON","proxiedSandbox","Proxy","has","_target","_key","get","target","key","Symbol","unscopables","Reflect","code","Function","fn","error"],"mappings":"oCAQgB,SAAeA,EAAgBC,GAE7C,MAaMC,EAAU,IAbO,CACrBC,UACAC,UACAC,YACAC,cACAC,cACAC,cACAC,gBACAC,gBACAC,WAMAV,OAAQ,IAAKA,IAoBTW,EAAiB,IAAIC,MAAMX,EAhBa,CAC5CY,IAAKA,CAACC,EAASC,KACN,EAETC,IAAKA,CAACC,EAAQC,KAER,GAAe,iBAARA,EAAkB,CACvB,GAAAA,IAAQC,OAAOC,YACV,OAEF,OAAAC,QAAQL,IAAIC,EAAQC,EAC7B,CACA,OAAOD,EAAOC,EAA0B,IAMxC,IAEI,MAAAI,EAAO,oBAAoBvB,MAKjC,OAHW,IAAIwB,SAAS,UAAWD,EACnCE,CAAGb,GAEIA,EAAeX,aAEjByB,GAEE,OADChB,QAAAgB,MAAM,UAAWA,GAClBzB,CACT,CACF"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("echarts"),t=require("../components/empty.svg.cjs"),o=require("vue"),i=require("@vueuse/core");function n(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(o){if("default"!==o){var i=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,i.get?i:{enumerable:!0,get:function(){return e[o]}})}})),t.default=e,Object.freeze(t)}var r=n(e);function a(e,t){const{width:o,height:n}=i.useElementSize(t);i.watchDebounced([o,n],(()=>{e&&e.resize()}))}exports.useCharts=function(e){let{chartDOM:n,chartData:u,chartOptions:l,mountedBefore:s,initAfter:c,callback:d}=e,f=null;const v=o.ref(!1),p=window.devicePixelRatio||1;function g(){f&&!f.isDisposed()&&(f.dispose(),f=null)}function h(){if(f&&v.value&&n.value){f.showLoading();try{f.isDisposed()&&(f=r.init(n.value,null,{devicePixelRatio:p,renderer:"svg"})),f.setOption(...arguments)}catch(e){console.log("error: ",e),g(),n.value&&(f=r.init(n.value,null,{devicePixelRatio:p,renderer:"svg"}),x("配置项错误"))}finally{f?.hideLoading()}}}const{isOutside:m}=i.useMouseInElement(n);function x(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"暂无数据";h({title:[{text:u.value?.modelName,...l.value.title},{subtext:e,top:"center",left:"center",text:" {a|}",itemGap:-20,textStyle:{align:"center",rich:{a:{color:"#000",fontSize:"16",height:80,width:160,backgroundColor:{image:t.default}}}},subtextStyle:{fontSize:16}}]},{notMerge:!0,replaceMerge:["xAxis","yAxis","series"],lazyUpdate:!1})}return i.watchDebounced(m,(e=>{var t;"boolean"==typeof e&&(t=!e,f?.isDisposed()||f?.setOption({toolbox:{show:t}}))}),{debounce:200}),o.onMounted((async()=>{s&&await s(),n.value&&(g(),f=r.init(n.value,null,{devicePixelRatio:p,renderer:"svg"}),d&&d(f),c&&await c(),a(f,n),v.value=!0,u.value?.data?.length?h(l.value,{}):x())})),o.onUnmounted((()=>{f&&(f.getZr()?.off("mousemove"),f.getZr()?.off("mouseout"),g())})),{myChart:f}},exports.useDataToExcelJson=function(e){const{desc:{colDesc:t=[],groupByDesc:o=[]}={},data:i=[]}=e,n=[...o.map((e=>e.colDesc)),...t].filter((e=>e)),r=i.map((e=>n.map((t=>e[t]||""))));return[n,...r]},exports.useResize=a;
1
+ "use strict";var e=require("echarts"),t=require("../components/empty.svg.cjs"),o=require("@vueuse/core"),n=require("vue");function r(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(o){if("default"!==o){var n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:function(){return e[o]}})}})),t.default=e,Object.freeze(t)}var i=r(e);function a(e,t){const{width:n,height:r}=o.useElementSize(t);o.watchDebounced([n,r],(()=>{e&&e.resize()}))}exports.useCharts=function(e){let{chartDOM:r,chartData:s,chartOptions:u,mountedBefore:c,initAfter:l,callback:d}=e,f=null,p=!1;const v=window.devicePixelRatio||1;function h(){f&&!f.isDisposed()&&(f.dispose(),f=null)}function g(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];if(r.value)try{f&&!f.isDisposed()||(f=i.init(r.value,null,{devicePixelRatio:v,renderer:"svg"})),f.showLoading(),s.value?.data?.length?(!0===p&&(t[1]||(t[1]={}),t[1].notMerge=!0),p=!1,f.setOption(...t)):t=m()}catch(e){console.log("error: ",e),f&&!f.isDisposed()&&h(),r.value&&!f&&(f=i.init(r.value,null,{devicePixelRatio:v,renderer:"svg"}),t=m("配置项错误"))}finally{f?.setOption(...t),f?.hideLoading()}}function m(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"暂无数据";const o={title:[{text:s.value?.modelName,...u.value.title},{subtext:e,top:"center",left:"center",text:" {a|}",itemGap:-20,textStyle:{align:"center",rich:{a:{color:"#000",fontSize:"16",height:80,width:160,backgroundColor:{image:t.default}}}},subtextStyle:{fontSize:16}}]};return p=!0,[o,{notMerge:!0,replaceMerge:["xAxis","yAxis","series"],lazyUpdate:!1}]}const{isOutside:b}=o.useMouseInElement(r);return o.watchDebounced(b,(e=>{var t;"boolean"==typeof e&&(t=!e,f?.isDisposed()||f?.setOption({toolbox:{show:t}}))}),{debounce:200}),o.watchDebounced((()=>u.value),(()=>g(u.value)),{debounce:500,deep:!0}),n.onMounted((async()=>{c&&await c(),g(u.value),d&&d(f),l&&await l(),f&&a(f,r)})),n.onUnmounted((()=>{f&&(f.getZr()?.off("mousemove"),f.getZr()?.off("mouseout"),h())})),{myChart:f}},exports.useDataToExcelJson=function(e){const{desc:{colDesc:t=[],groupByDesc:o=[]}={},data:n=[]}=e,r=[...o.map((e=>e.colDesc)),...t].filter((e=>e)),i=n.map((e=>r.map((t=>e[t]||""))));return[r,...i]},exports.useResize=a;
2
2
  //# sourceMappingURL=useCharts.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCharts.cjs","sources":["../../../../../../../packages/components/src/data-chart/src/utils/useCharts.ts"],"sourcesContent":["import type { ECharts, SetOptionOpts } from 'echarts'\nimport type { ComputedRef, Ref } from 'vue'\nimport type { EChartData, EChartsOption, IFormatPublicData } from '../types'\nimport * as echarts from 'echarts'\n\n// 使用别名路径导入 SVG\nimport emptyImg from '../components/empty.svg'\n\nexport function useCharts({ chartDOM, chartData, chartOptions, mountedBefore, initAfter, callback }: {\n chartDOM: Ref<HTMLElement | null>\n chartData: ComputedRef<IFormatPublicData>\n chartOptions: ComputedRef<EChartsOption>\n mountedBefore?: () => void\n initAfter?: () => void\n callback?: (e: ECharts) => void\n}) {\n let myChart: ECharts | null = null\n const initChartSuccess = ref(false)\n\n // 获取设备像素比\n const dpr = window.devicePixelRatio || 1\n\n function disposeChart() {\n if (myChart && !myChart.isDisposed()) {\n myChart.dispose()\n myChart = null\n }\n }\n\n function initChart(...opt: [EChartsOption, SetOptionOpts]) {\n if (!myChart || !initChartSuccess.value || !chartDOM.value) {\n return\n }\n\n myChart.showLoading()\n try {\n if (myChart.isDisposed()) {\n // 如果实例已被销毁,重新创建\n myChart = echarts.init(chartDOM.value, null, {\n devicePixelRatio: dpr,\n renderer: 'svg',\n })\n }\n myChart.setOption(...opt)\n }\n catch (error) {\n console.log('error: ', error)\n disposeChart()\n if (chartDOM.value) {\n myChart = echarts.init(chartDOM.value, null, {\n devicePixelRatio: dpr,\n renderer: 'svg',\n })\n setEmpty('配置项错误')\n }\n }\n finally {\n myChart?.hideLoading()\n }\n }\n\n const { isOutside: mouseInChart } = useMouseInElement(chartDOM)\n watchDebounced(mouseInChart, (newVal) => {\n if (typeof newVal !== 'boolean') {\n return\n }\n toggleToolbox(!newVal)\n }, { debounce: 200 })\n\n function setEmpty(subtext = '暂无数据') {\n const obj: EChartsOption = {\n title: [{\n text: chartData.value?.modelName,\n ...chartOptions.value.title,\n }, {\n subtext,\n top: 'center',\n left: 'center',\n text: ' {a|}',\n itemGap: -20,\n textStyle: {\n align: 'center',\n rich: {\n a: {\n color: '#000',\n fontSize: '16',\n height: 80,\n width: 160,\n backgroundColor: {\n image: emptyImg,\n },\n },\n },\n },\n subtextStyle: {\n fontSize: 16,\n },\n }],\n }\n initChart(obj, {\n notMerge: true,\n replaceMerge: ['xAxis', 'yAxis', 'series'],\n lazyUpdate: false,\n })\n }\n\n function toggleToolbox(show: boolean) {\n if (!myChart?.isDisposed()) {\n myChart?.setOption({\n toolbox: {\n show,\n },\n })\n }\n }\n\n onMounted(async () => {\n if (mountedBefore) {\n await mountedBefore()\n }\n if (!chartDOM.value) {\n return\n }\n disposeChart() // 确保旧实例被清理\n myChart = echarts.init(chartDOM.value, null, {\n devicePixelRatio: dpr,\n renderer: 'svg',\n })\n if (callback) {\n callback(myChart)\n }\n if (initAfter) {\n await initAfter()\n }\n\n useResize(myChart, chartDOM)\n\n initChartSuccess.value = true\n\n if (chartData.value?.data?.length) {\n initChart(chartOptions.value, {})\n }\n else {\n setEmpty()\n }\n })\n\n onUnmounted(() => {\n if (myChart) {\n myChart.getZr()?.off('mousemove')\n myChart.getZr()?.off('mouseout')\n disposeChart()\n }\n })\n\n return {\n myChart,\n }\n}\n\nexport function useResize(myChart: ECharts, chartDOM: Ref<HTMLElement | null>) {\n const { width, height } = useElementSize(chartDOM)\n watchDebounced([width, height], () => {\n if (myChart) {\n myChart.resize()\n }\n })\n}\n\nexport function useDataToExcelJson(dataSource: EChartData) {\n const { desc: { colDesc = [], groupByDesc = [] } = {}, data = [] } = dataSource\n const header = [...groupByDesc.map(item => item.colDesc), ...colDesc].filter(v => v) as string[]\n const json = data.map((item) => {\n return header.map((headerItem) => {\n return item[headerItem as keyof typeof item] || ''\n })\n })\n return [header, ...json]\n}\n"],"names":["useResize","myChart","chartDOM","width","height","useElementSize","watchDebounced","resize","_ref","chartData","chartOptions","mountedBefore","initAfter","callback","initChartSuccess","ref","dpr","window","devicePixelRatio","disposeChart","isDisposed","dispose","initChart","value","showLoading","echarts","init","renderer","setOption","arguments","error","console","log","setEmpty","hideLoading","isOutside","mouseInChart","useMouseInElement","subtext","title","text","modelName","top","left","itemGap","textStyle","align","rich","a","color","fontSize","backgroundColor","image","emptyImg","subtextStyle","notMerge","replaceMerge","lazyUpdate","newVal","show","toolbox","debounce","onMounted","async","data","length","onUnmounted","getZr","off","dataSource","desc","colDesc","groupByDesc","header","map","item","filter","v","json","headerItem"],"mappings":"wYAgKgB,SAAAA,EAAUC,EAAkBC,GAC1C,MAAMC,MAAEA,EAAAC,OAAOA,GAAWC,EAAAA,eAAeH,GACzCI,EAAAA,eAAe,CAACH,EAAOC,IAAS,KAC1BH,GACFA,EAAQM,QACV,GAEJ,mBA/JgB,SAAAC,GAOb,IAPuBN,SAAEA,EAAUO,UAAAA,EAAAC,aAAWA,gBAAcC,EAAeC,UAAAA,EAAAC,SAAWA,GAOtFL,EACGP,EAA0B,KACxB,MAAAa,EAAmBC,OAAI,GAGvBC,EAAMC,OAAOC,kBAAoB,EAEvC,SAASC,IACHlB,IAAYA,EAAQmB,eACtBnB,EAAQoB,UACEpB,EAAA,KAEd,CAEA,SAASqB,IACP,GAAKrB,GAAYa,EAAiBS,OAAUrB,EAASqB,MAArD,CAIAtB,EAAQuB,cACJ,IACEvB,EAAQmB,eAEVnB,EAAUwB,EAAQC,KAAKxB,EAASqB,MAAO,KAAM,CAC3CL,iBAAkBF,EAClBW,SAAU,SAGN1B,EAAA2B,aAAUC,iBAEbC,GACGC,QAAAC,IAAI,UAAWF,GACVX,IACTjB,EAASqB,QACXtB,EAAUwB,EAAQC,KAAKxB,EAASqB,MAAO,KAAM,CAC3CL,iBAAkBF,EAClBW,SAAU,QAEZM,EAAS,SAEb,CACA,QACEhC,GAASiC,aACX,CA1BA,CA2BF,CAEA,MAAQC,UAA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AKU,KAAKC,GACdF,EAAOC,KAAKK,GACVJ,EAAKI,IAAoC,OAG7C,MAAA,CAACN,KAAWK,EACrB"}
1
+ {"version":3,"file":"useCharts.cjs","sources":["../../../../../../../packages/components/src/data-chart/src/utils/useCharts.ts"],"sourcesContent":["import type { ECharts, SetOptionOpts } from 'echarts'\nimport type { Ref } from 'vue'\nimport type { EChartData, EChartsOption, IFormatPublicData } from '../types'\nimport * as echarts from 'echarts'\n\n// 使用别名路径导入 SVG\nimport emptyImg from '../components/empty.svg'\n\nexport function useCharts({ chartDOM, chartData, chartOptions, mountedBefore, initAfter, callback }: {\n chartDOM: Ref<HTMLElement | null>\n chartData: Ref<IFormatPublicData>\n chartOptions: Ref<EChartsOption>\n mountedBefore?: () => void\n initAfter?: () => void\n callback?: (e: ECharts | null) => void\n}) {\n let myChart: ECharts | null = null\n let isEmpty = false\n\n // 获取设备像素比\n const dpr = window.devicePixelRatio || 1\n\n function disposeChart() {\n if (myChart && !myChart.isDisposed()) {\n myChart.dispose()\n myChart = null\n }\n }\n\n function renderChart(...opt: [EChartsOption, SetOptionOpts?]) {\n if (!chartDOM.value) {\n return\n }\n try {\n if (myChart && !myChart.isDisposed()) {\n myChart.showLoading()\n }\n else {\n // 如果实例已被销毁,重新创建\n myChart = echarts.init(chartDOM.value, null, {\n devicePixelRatio: dpr,\n renderer: 'svg',\n })\n myChart.showLoading()\n }\n if (chartData.value?.data?.length) {\n if (isEmpty === true) {\n if (!opt[1]) {\n opt[1] = {}\n }\n opt[1].notMerge = true\n }\n isEmpty = false\n myChart.setOption(...opt)\n }\n else {\n opt = setEmpty()\n }\n }\n catch (error) {\n console.log('error: ', error)\n if (myChart && !myChart.isDisposed()) {\n disposeChart()\n }\n if (chartDOM.value && !myChart) {\n // 如果实例已被销毁,重新创建\n myChart = echarts.init(chartDOM.value, null, {\n devicePixelRatio: dpr,\n renderer: 'svg',\n })\n opt = setEmpty('配置项错误')\n }\n }\n finally {\n myChart?.setOption(...opt)\n myChart?.hideLoading()\n }\n }\n\n function setEmpty(subtext = '暂无数据'): [EChartsOption, SetOptionOpts] {\n const obj: EChartsOption = {\n title: [{\n text: chartData.value?.modelName,\n ...chartOptions.value.title,\n }, {\n subtext,\n top: 'center',\n left: 'center',\n text: ' {a|}',\n itemGap: -20,\n textStyle: {\n align: 'center',\n rich: {\n a: {\n color: '#000',\n fontSize: '16',\n height: 80,\n width: 160,\n backgroundColor: {\n image: emptyImg,\n },\n },\n },\n },\n subtextStyle: {\n fontSize: 16,\n },\n }],\n }\n isEmpty = true\n return [obj, {\n notMerge: true,\n replaceMerge: ['xAxis', 'yAxis', 'series'],\n lazyUpdate: false,\n }]\n }\n\n function toggleToolbox(show: boolean) {\n if (!myChart?.isDisposed()) {\n myChart?.setOption({\n toolbox: {\n show,\n },\n })\n }\n }\n\n const { isOutside: mouseInChart } = useMouseInElement(chartDOM)\n watchDebounced(mouseInChart, (newVal) => {\n if (typeof newVal !== 'boolean') {\n return\n }\n toggleToolbox(!newVal)\n }, { debounce: 200 })\n\n watchDebounced(\n () => chartOptions.value,\n () => renderChart(chartOptions.value),\n { debounce: 500, deep: true },\n )\n\n onMounted(async () => {\n if (mountedBefore) {\n await mountedBefore()\n }\n renderChart(chartOptions.value)\n if (callback) {\n callback(myChart)\n }\n if (initAfter) {\n await initAfter()\n }\n if (myChart) {\n useResize(myChart, chartDOM)\n }\n })\n\n onUnmounted(() => {\n if (myChart) {\n myChart.getZr()?.off('mousemove')\n myChart.getZr()?.off('mouseout')\n disposeChart()\n }\n })\n\n return {\n myChart,\n }\n}\n\nexport function useResize(myChart: ECharts, chartDOM: Ref<HTMLElement | null>) {\n const { width, height } = useElementSize(chartDOM)\n watchDebounced([width, height], () => {\n if (myChart) {\n myChart.resize()\n }\n })\n}\n\nexport function useDataToExcelJson(dataSource: EChartData) {\n const { desc: { colDesc = [], groupByDesc = [] } = {}, data = [] } = dataSource\n const header = [...groupByDesc.map(item => item.colDesc), ...colDesc].filter(v => v) as string[]\n const json = data.map((item) => {\n return header.map((headerItem) => {\n return item[headerItem as keyof typeof item] || ''\n })\n })\n return [header, ...json]\n}\n"],"names":["useResize","myChart","chartDOM","width","height","useElementSize","watchDebounced","resize","_ref","chartData","chartOptions","mountedBefore","initAfter","callback","isEmpty","dpr","window","devicePixelRatio","disposeChart","isDisposed","dispose","renderChart","_len","arguments","length","opt","Array","_key","value","echarts","init","renderer","showLoading","data","notMerge","setOption","setEmpty","error","console","log","hideLoading","subtext","obj","title","text","modelName","top","left","itemGap","textStyle","align","rich","a","color","fontSize","backgroundColor","image","emptyImg","subtextStyle","replaceMerge","lazyUpdate","isOutside","mouseInChart","useMouseInElement","newVal","show","toolbox","debounce","deep","onMounted","async","onUnmounted","getZr","off","dataSource","desc","colDesc","groupByDesc","header","map","item","filter","v","json","headerItem"],"mappings":"wYA0KgB,SAAAA,EAAUC,EAAkBC,GAC1C,MAAMC,MAAEA,EAAAC,OAAOA,GAAWC,EAAAA,eAAeH,GACzCI,EAAAA,eAAe,CAACH,EAAOC,IAAS,KAC1BH,GACFA,EAAQM,QACV,GAEJ,mBAzKgB,SAAAC,GAOb,IAPuBN,SAAEA,EAAUO,UAAAA,EAAAC,aAAWA,gBAAcC,EAAeC,UAAAA,EAAAC,SAAWA,GAOtFL,EACGP,EAA0B,KAC1Ba,GAAU,EAGR,MAAAC,EAAMC,OAAOC,kBAAoB,EAEvC,SAASC,IACHjB,IAAYA,EAAQkB,eACtBlB,EAAQmB,UACEnB,EAAA,KAEd,CAEA,SAASoB,IAAqD,IAAA,IAAAC,EAAAC,UAAAC,OAAtCC,EAAsCC,IAAAA,MAAAJ,GAAAK,EAAA,EAAAA,EAAAL,EAAAK,IAAtCF,EAAsCE,GAAAJ,UAAAI,GACxD,GAACzB,EAAS0B,MAGV,IACE3B,IAAYA,EAAQkB,eAKtBlB,EAAU4B,EAAQC,KAAK5B,EAAS0B,MAAO,KAAM,CAC3CX,iBAAkBF,EAClBgB,SAAU,SANZ9B,EAAQ+B,cAUNvB,E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ACFA,EAASZ,GAEPW,SACIA,IAEJX,GACFD,EAAUC,EAASC,EACrB,IAGFqE,EAAAA,aAAY,KACNtE,IACMA,EAAAuE,SAASC,IAAI,aACbxE,EAAAuE,SAASC,IAAI,YACRvD,IACf,IAGK,CACLjB,UAEJ,6BAWO,SAA4ByE,GACjC,MAAQC,MAAMC,QAAEA,EAAU,GAAIC,YAAAA,EAAc,IAAO,CAAC,EAAA5C,KAAGA,EAAO,IAAOyC,EAC/DI,EAAS,IAAID,EAAYE,KAAYC,GAAAA,EAAKJ,aAAaA,GAASK,WAAYC,IAC5EC,EAAOlD,EAAK8C,KAAKC,GACdF,EAAOC,KAAKK,GACVJ,EAAKI,IAAoC,OAG7C,MAAA,CAACN,KAAWK,EACrB"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("element-plus/es");require("element-plus/es/components/base/style/index"),require("element-plus/es/components/upload/style/index"),require("element-plus/es/components/alert/style/index"),require("element-plus/es/components/icon/style/index");var l=require("vue"),t=require("@element-plus/icons-vue"),a=require("@qxs-bns/hooks"),s=require("element-plus");require("element-plus/es/components/message/style/index");const r={class:"slot"},n={style:{display:"inline-block"}};var i=l.defineComponent({name:"QxsFileUpload",__name:"file-upload",props:{action:{type:String,required:!0},headers:{type:null,required:!1},data:{type:null,required:!1},name:{type:String,required:!1,default:"file"},size:{type:Number,required:!1,default:20},max:{type:Number,required:!1,default:3},accept:{type:String,required:!1,default:"zip,rar"},files:{type:Array,required:!1,default:()=>[]},notip:{type:Boolean,required:!1,default:!1},ext:{type:Array,required:!1}},emits:["onSuccess"],setup(i,{emit:o}){const u=o,d=a.useNamespace("file-upload"),c=s.useNamespace("file-upload"),p=l.computed((()=>i.accept.split(","))),m=l=>{const t=l.name.split(".").at(-1)??"",a=p.value.includes(t),s=l.size/1024/1024<i.size;return a||e.ElMessage.error(`上传文件只支持 ${p.value.join(" / ")} 格式!`),s||e.ElMessage.error(`上传文件大小不能超过 ${i.size}MB!`),a&&s},f=()=>{e.ElMessage.warning("文件上传超过限制")},y=(e,l,t)=>{u("onSuccess",e,l,t)};return(a,s)=>{const i=e.ElIcon,o=e.ElAlert,u=e.ElUpload;return l.openBlock(),l.createBlock(u,{headers:a.headers,action:a.action,data:a.data,name:a.name,"before-upload":m,"on-exceed":f,"on-success":y,"file-list":a.files,limit:a.max,drag:"",class:l.normalizeClass(l.unref(d).e("control"))},{tip:l.withCtx((()=>[a.notip?l.createCommentVNode("v-if",!0):(l.openBlock(),l.createElementBlock("div",{key:0,class:l.normalizeClass(l.unref(c).namespace.value+"-upload__tip")},[l.createElementVNode("div",n,[l.createVNode(o,{title:`上传文件支持 ${l.unref(p).join(" / ")} 格式,单个文件大小不超过 ${a.size}MB,且文件数量不超过 ${a.max} 个`,type:"info","show-icon":"",closable:!1},null,8,["title"])])],2))])),default:l.withCtx((()=>[l.createElementVNode("div",r,[l.createVNode(i,{class:l.normalizeClass(l.unref(c).namespace.value+"-icon--upload")},{default:l.withCtx((()=>[l.createVNode(l.unref(t.UploadFilled))])),_:1},8,["class"]),l.createElementVNode("div",{class:l.normalizeClass(l.unref(c).namespace.value+"-upload__text")},s[0]||(s[0]=[l.createTextVNode(" 将文件拖到此处,或"),l.createElementVNode("em",null,"点击上传",-1)]),2)])])),_:1},8,["headers","action","data","name","file-list","limit","class"])}}});exports.default=i;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("element-plus/es");require("element-plus/es/components/base/style/index"),require("element-plus/es/components/upload/style/index"),require("element-plus/es/components/alert/style/index"),require("element-plus/es/components/icon/style/index");var l=require("vue"),t=require("@element-plus/icons-vue"),a=require("@qxs-bns/hooks"),s=require("element-plus");require("element-plus/es/components/message/style/index");const r={class:"slot"},n={style:{display:"inline-block"}};var i=l.defineComponent({name:"QxsFileUpload",__name:"file-upload",props:{action:{type:String,required:!0},headers:{type:null,required:!1},data:{type:null,required:!1},name:{type:String,required:!1,default:"file"},size:{type:Number,required:!1,default:20},max:{type:Number,required:!1,default:3},accept:{type:String,required:!1,default:"zip,rar"},files:{type:Array,required:!1,default:()=>[]},notip:{type:Boolean,required:!1,default:!1},ext:{type:Array,required:!1}},emits:["onSuccess"],setup(i,{emit:o}){const u=o,d=a.useNamespace("file-upload"),c=s.useNamespace("file-upload"),p=l.computed((()=>i.accept.split(","))),m=l=>{const t=l.name.split(".").at(-1)??"",a=p.value.includes(t),s=l.size/1024/1024<i.size;return a||e.ElMessage.error(`上传文件只支持 ${p.value.join(" / ")} 格式!`),s||e.ElMessage.error(`上传文件大小不能超过 ${i.size}MB!`),a&&s},f=()=>{e.ElMessage.warning("文件上传超过限制")},y=(e,l,t)=>{u("onSuccess",e,l,t)};return(a,s)=>{const i=e.ElIcon,o=e.ElAlert,u=e.ElUpload;return l.openBlock(),l.createBlock(u,{headers:a.headers,action:a.action,data:a.data,name:a.name,"before-upload":m,"on-exceed":f,"on-success":y,"file-list":a.files,limit:a.max,drag:"",class:l.normalizeClass(l.unref(d).e("control"))},{tip:l.withCtx((()=>[a.notip?l.createCommentVNode("v-if",!0):(l.openBlock(),l.createElementBlock("div",{key:0,class:l.normalizeClass(`${l.unref(c).namespace.value}-upload__tip`)},[l.createElementVNode("div",n,[l.createVNode(o,{title:`上传文件支持 ${l.unref(p).join(" / ")} 格式,单个文件大小不超过 ${a.size}MB,且文件数量不超过 ${a.max} 个`,type:"info","show-icon":"",closable:!1},null,8,["title"])])],2))])),default:l.withCtx((()=>[l.createElementVNode("div",r,[l.createVNode(i,{class:l.normalizeClass(`${l.unref(c).namespace.value}-icon--upload`)},{default:l.withCtx((()=>[l.createVNode(l.unref(t.UploadFilled))])),_:1},8,["class"]),l.createElementVNode("div",{class:l.normalizeClass(`${l.unref(c).namespace.value}-upload__text`)},s[0]||(s[0]=[l.createTextVNode(" 将文件拖到此处,或"),l.createElementVNode("em",null,"点击上传",-1)]),2)])])),_:1},8,["headers","action","data","name","file-list","limit","class"])}}});exports.default=i;
2
2
  //# sourceMappingURL=file-upload.vue.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-upload.vue.cjs","sources":["../../../../../../packages/components/src/file-upload/src/file-upload.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { UploadProps, UploadUserFile } from \"element-plus\";\nimport { UploadFilled } from \"@element-plus/icons-vue\";\nimport { useNamespace } from \"@qxs-bns/hooks\";\nimport { useNamespace as useElNamespace } from \"element-plus\";\n\ndefineOptions({\n name: \"QxsFileUpload\",\n});\n\nconst {\n name = \"file\",\n size = 20,\n max = 3,\n files = [],\n notip = false,\n accept = \"zip,rar\",\n} = defineProps<{\n action: UploadProps[\"action\"];\n headers?: UploadProps[\"headers\"];\n data?: UploadProps[\"data\"];\n name?: UploadProps[\"name\"];\n size?: number;\n max?: number;\n accept?: string;\n files?: UploadUserFile[];\n notip?: boolean;\n ext?: string[];\n}>();\n\nconst emit = defineEmits([\"onSuccess\"]);\n\nconst ns = useNamespace(\"file-upload\");\nconst nsEl = useElNamespace(\"file-upload\");\n\nconst exts = computed(() => {\n return accept.split(\",\");\n});\nconst beforeUpload: UploadProps[\"beforeUpload\"] = (file) => {\n const fileName = file.name.split(\".\");\n const fileExt = fileName.at(-1) ?? \"\";\n const isTypeOk = exts.value.includes(fileExt);\n const isSizeOk = file.size / 1024 / 1024 < size;\n if (!isTypeOk) {\n ElMessage.error(`上传文件只支持 ${exts.value.join(\" / \")} 格式!`);\n }\n if (!isSizeOk) {\n ElMessage.error(`上传文件大小不能超过 ${size}MB!`);\n }\n return isTypeOk && isSizeOk;\n};\n\nconst onExceed: UploadProps[\"onExceed\"] = () => {\n ElMessage.warning(\"文件上传超过限制\");\n};\n\nconst onSuccess: UploadProps[\"onSuccess\"] = (res, file, fileList) => {\n emit(\"onSuccess\", res, file, fileList);\n};\n</script>\n\n<template>\n <el-upload\n :headers=\"headers\"\n :action=\"action\"\n :data=\"data\"\n :name=\"name\"\n :before-upload=\"beforeUpload\"\n :on-exceed=\"onExceed\"\n :on-success=\"onSuccess\"\n :file-list=\"files\"\n :limit=\"max\"\n drag\n :class=\"ns.e('control')\"\n >\n <div class=\"slot\">\n <el-icon :class=\"nsEl.namespace.value + '-icon--upload'\">\n <UploadFilled />\n </el-icon>\n <div :class=\"nsEl.namespace.value + '-upload__text'\">\n 将文件拖到此处,或<em>点击上传</em>\n </div>\n </div>\n <template #tip>\n <div v-if=\"!notip\" :class=\"nsEl.namespace.value + '-upload__tip'\">\n <div style=\"display: inline-block\">\n <el-alert\n :title=\"`上传文件支持 ${exts.join(\n ' / '\n )} 格式,单个文件大小不超过 ${size}MB,且文件数量不超过 ${max} 个`\"\n type=\"info\"\n show-icon\n :closable=\"false\"\n />\n </div>\n </div>\n </template>\n </el-upload>\n</template>\n"],"names":["emit","__emit","ns","useNamespace","nsEl","useElNamespace","exts","computed","__props","accept","split","beforeUpload","file","fileExt","name","at","isTypeOk","value","includes","isSizeOk","size","ElMessage","error","join","onExceed","warning","onSuccess","res","fileList"],"mappings":"iiCA8BA,MAAMA,EAAOC,EAEPC,EAAKC,eAAa,eAClBC,EAAOC,eAAe,eAEtBC,EAAOC,EAAAA,UAAS,IACbC,EAAAC,OAAOC,MAAM,OAEhBC,EAA6CC,IACjD,MACMC,EADWD,EAAKE,KAAKJ,MAAM,KACRK,IAAG,IAAO,GAC7BC,EAAWV,EAAKW,MAAMC,SAASL,GAC/BM,EAAWP,EAAKQ,KAAO,KAAO,KAAOZ,EAAIY,KAO/C,OANKJ,GACHK,YAAUC,MAAM,WAAWhB,EAAKW,MAAMM,KAAK,cAExCJ,GACHE,EAAAA,UAAUC,MAAM,cAAcd,EAAIY,WAE7BJ,GAAYG,CAAA,EAGfK,EAAoC,KACxCH,EAAAA,UAAUI,QAAQ,WAAU,EAGxBC,EAAsC,CAACC,EAAKf,EAAMgB,KACjD5B,EAAA,YAAa2B,EAAKf,EAAMgB,EAAQ"}
1
+ {"version":3,"file":"file-upload.vue.cjs","sources":["../../../../../../packages/components/src/file-upload/src/file-upload.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { UploadProps, UploadUserFile } from 'element-plus'\nimport { UploadFilled } from '@element-plus/icons-vue'\nimport { useNamespace } from '@qxs-bns/hooks'\nimport { useNamespace as useElNamespace } from 'element-plus'\n\ndefineOptions({\n name: 'QxsFileUpload',\n})\n\nconst {\n name = 'file',\n size = 20,\n max = 3,\n files = [],\n notip = false,\n accept = 'zip,rar',\n} = defineProps<{\n action: UploadProps['action']\n headers?: UploadProps['headers']\n data?: UploadProps['data']\n name?: UploadProps['name']\n size?: number\n max?: number\n accept?: string\n files?: UploadUserFile[]\n notip?: boolean\n ext?: string[]\n}>()\n\nconst emit = defineEmits(['onSuccess'])\n\nconst ns = useNamespace('file-upload')\nconst nsEl = useElNamespace('file-upload')\n\nconst exts = computed(() => {\n return accept.split(',')\n})\nconst beforeUpload: UploadProps['beforeUpload'] = (file) => {\n const fileName = file.name.split('.')\n const fileExt = fileName.at(-1) ?? ''\n const isTypeOk = exts.value.includes(fileExt)\n const isSizeOk = file.size / 1024 / 1024 < size\n if (!isTypeOk) {\n ElMessage.error(`上传文件只支持 ${exts.value.join(' / ')} 格式!`)\n }\n if (!isSizeOk) {\n ElMessage.error(`上传文件大小不能超过 ${size}MB!`)\n }\n return isTypeOk && isSizeOk\n}\n\nconst onExceed: UploadProps['onExceed'] = () => {\n ElMessage.warning('文件上传超过限制')\n}\n\nconst onSuccess: UploadProps['onSuccess'] = (res, file, fileList) => {\n emit('onSuccess', res, file, fileList)\n}\n</script>\n\n<template>\n <el-upload\n :headers=\"headers\"\n :action=\"action\"\n :data=\"data\"\n :name=\"name\"\n :before-upload=\"beforeUpload\"\n :on-exceed=\"onExceed\"\n :on-success=\"onSuccess\"\n :file-list=\"files\"\n :limit=\"max\"\n drag\n :class=\"ns.e('control')\"\n >\n <div class=\"slot\">\n <el-icon :class=\"`${nsEl.namespace.value}-icon--upload`\">\n <UploadFilled />\n </el-icon>\n <div :class=\"`${nsEl.namespace.value}-upload__text`\">\n 将文件拖到此处,或<em>点击上传</em>\n </div>\n </div>\n <template #tip>\n <div\n v-if=\"!notip\"\n :class=\"`${nsEl.namespace.value}-upload__tip`\"\n >\n <div style=\"display: inline-block;\">\n <el-alert\n :title=\"`上传文件支持 ${exts.join(\n ' / ',\n )} 格式,单个文件大小不超过 ${size}MB,且文件数量不超过 ${max} 个`\"\n type=\"info\"\n show-icon\n :closable=\"false\"\n />\n </div>\n </div>\n </template>\n </el-upload>\n</template>\n"],"names":["emit","__emit","ns","useNamespace","nsEl","useElNamespace","exts","computed","__props","accept","split","beforeUpload","file","fileExt","name","at","isTypeOk","value","includes","isSizeOk","size","ElMessage","error","join","onExceed","warning","onSuccess","res","fileList"],"mappings":"iiCA8BA,MAAMA,EAAOC,EAEPC,EAAKC,eAAa,eAClBC,EAAOC,eAAe,eAEtBC,EAAOC,EAAAA,UAAS,IACbC,EAAAC,OAAOC,MAAM,OAEhBC,EAA6CC,IACjD,MACMC,EADWD,EAAKE,KAAKJ,MAAM,KACRK,IAAG,IAAO,GAC7BC,EAAWV,EAAKW,MAAMC,SAASL,GAC/BM,EAAWP,EAAKQ,KAAO,KAAO,KAAOZ,EAAAY,KAO3C,OANKJ,GACHK,YAAUC,MAAM,WAAWhB,EAAKW,MAAMM,KAAK,cAExCJ,GACHE,EAAAA,UAAUC,MAAM,cAAcd,EAAAY,WAEzBJ,GAAYG,CAAA,EAGfK,EAAoC,KACxCH,EAAAA,UAAUI,QAAQ,WAAU,EAGxBC,EAAsC,CAACC,EAAKf,EAAMgB,KACjD5B,EAAA,YAAa2B,EAAKf,EAAMgB,EAAQ"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue"),t=require("@qxs-bns/hooks"),n=require("@qxs-bns/utils"),r=require("lodash-es");var a=e.defineComponent({name:"QxsFixedActionBar",props:{padding:{type:Number,default:8},className:{type:String,default:""}},setup(a){const o=a,i=t.useNamespace("fixed-action-bar"),l=e.ref(!1),d=e.ref(null),s=e.ref(null),c=e.ref({width:0,height:0}),u=e.ref(0),p=e.ref(0),f={resize:null,parent:null},h=(e,t,n)=>{const r=new ResizeObserver((e=>{e.forEach((e=>requestAnimationFrame((()=>t(e)))))}));return r.observe(e,n),r},m=()=>{if(!d.value||!s.value)return;f.resize=h(d.value,(e=>{const t=(e=>{const t=getComputedStyle(e);return{x:parseFloat(t.paddingLeft)+parseFloat(t.paddingRight),y:parseFloat(t.paddingTop)+parseFloat(t.paddingBottom)}})(e.target);c.value={width:e.contentRect.width+t.x,height:e.contentRect.height+t.y}}),{box:"border-box"});const e=s.value.parentElement;e&&(f.parent=h(e,(()=>{const t=e.getBoundingClientRect();u.value=t.width,p.value=t.left})))},v=r.debounce((()=>{const{scrollY:e}=window,{clientHeight:t,scrollHeight:n}=document.documentElement;l.value=Math.ceil(e+t)>=n}),100),g=e.computed((()=>l.value?"":i.is("shadow"))),x=e.computed((()=>"Android"===n.getDeviceType()?Math.max(o.padding,20):o.padding)),b=e.computed((()=>({width:`${u.value}px`,left:`${p.value}px`,...i.cssVarBlock({"actionbar-padding":`${o.padding}px`,"actionbar-padding-bottom":`${x.value}px`})})));return e.onMounted((()=>{m(),window.addEventListener("scroll",v,{passive:!0})})),e.onUnmounted((()=>{f.resize?.disconnect(),f.parent?.disconnect(),window.removeEventListener("scroll",v)})),(t,n)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"placeholderRef",ref:s,style:e.normalizeStyle({width:"100%",height:`${e.unref(c).height}px`})},[e.createElementVNode("div",{ref_key:"actionbar",ref:d,style:e.normalizeStyle(e.unref(b)),class:e.normalizeClass([e.unref(i).e("actionbar"),e.unref(g),a.className]),"data-fixed-calc-width":""},[e.renderSlot(t.$slots,"default")],6)],4))}});exports.default=a;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue"),t=require("@qxs-bns/hooks"),n=require("@qxs-bns/utils"),r=require("lodash-es");var a=e.defineComponent({name:"QxsFixedActionBar",props:{padding:{type:Number,default:8},className:{type:String,default:""}},setup(a){const o=a,i=t.useNamespace("fixed-action-bar"),l=e.ref(!1),d=e.ref(null),s=e.ref(null),u=e.ref({width:0,height:0}),c=e.ref(0),p=e.ref(0),f={resize:null,parent:null};function m(e,t,n){const r=new ResizeObserver((e=>{e.forEach((e=>requestAnimationFrame((()=>t(e)))))}));return r.observe(e,n),r}function h(){if(!d.value||!s.value)return;f.resize=m(d.value,(e=>{const t=function(e){const t=getComputedStyle(e);return{x:Number.parseFloat(t.paddingLeft)+Number.parseFloat(t.paddingRight),y:Number.parseFloat(t.paddingTop)+Number.parseFloat(t.paddingBottom)}}(e.target);u.value={width:e.contentRect.width+t.x,height:e.contentRect.height+t.y}}),{box:"border-box"});const e=s.value.parentElement;e&&(f.parent=m(e,(()=>{const t=e.getBoundingClientRect();c.value=t.width,p.value=t.left})))}const v=r.debounce((()=>{const{scrollY:e}=window,{clientHeight:t,scrollHeight:n}=document.documentElement;l.value=Math.ceil(e+t)>=n}),100),g=e.computed((()=>l.value?"":i.is("shadow"))),b=e.computed((()=>"Android"===n.getDeviceType()?Math.max(o.padding,20):o.padding)),x=e.computed((()=>({width:`${c.value}px`,left:`${p.value}px`,...i.cssVarBlock({"actionbar-padding":`${o.padding}px`,"actionbar-padding-bottom":`${b.value}px`})})));return e.onMounted((()=>{h(),window.addEventListener("scroll",v,{passive:!0})})),e.onUnmounted((()=>{f.resize?.disconnect(),f.parent?.disconnect(),window.removeEventListener("scroll",v)})),(t,n)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"placeholderRef",ref:s,style:e.normalizeStyle({width:"100%",height:`${e.unref(u).height}px`})},[e.createElementVNode("div",{ref_key:"actionbar",ref:d,style:e.normalizeStyle(e.unref(x)),class:e.normalizeClass([e.unref(i).e("actionbar"),e.unref(g),a.className]),"data-fixed-calc-width":""},[e.renderSlot(t.$slots,"default")],6)],4))}});exports.default=a;
2
2
  //# sourceMappingURL=fixed-action-bar.vue.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"fixed-action-bar.vue.cjs","sources":["../../../../../../packages/components/src/fixed-action-bar/src/fixed-action-bar.vue"],"sourcesContent":["<script lang=\"ts\">\nexport default {\n name: \"QxsFixedActionBar\",\n};\n</script>\n<script setup lang=\"ts\">\nimport { useNamespace } from \"@qxs-bns/hooks\";\nimport { getDeviceType } from \"@qxs-bns/utils\";\nimport { debounce } from \"lodash-es\";\n\ntype ElementSize = { width: number; height: number };\n\nconst props = defineProps({\n padding: {\n type: Number,\n default: 8,\n },\n className: {\n type: String,\n default: \"\",\n },\n});\n\nconst ns = useNamespace(\"fixed-action-bar\");\nconst isBottom = ref(false);\nconst actionbar = ref<HTMLElement | null>(null);\nconst placeholderRef = ref<HTMLElement | null>(null);\n\nconst elementSize = ref<ElementSize>({ width: 0, height: 0 });\nconst parentWidth = ref(0);\nconst elementLeft = ref(0);\n\nconst observers = {\n resize: null as ResizeObserver | null,\n parent: null as ResizeObserver | null,\n};\n\nconst getTotalPadding = (el: HTMLElement) => {\n const style = getComputedStyle(el);\n return {\n x: parseFloat(style.paddingLeft) + parseFloat(style.paddingRight),\n y: parseFloat(style.paddingTop) + parseFloat(style.paddingBottom),\n };\n};\n\nconst createResizeObserver = (\n el: HTMLElement,\n callback: (entry: ResizeObserverEntry) => void,\n options?: ResizeObserverOptions\n) => {\n const observer = new ResizeObserver((entries) => {\n entries.forEach((entry) => requestAnimationFrame(() => callback(entry)));\n });\n observer.observe(el, options);\n return observer;\n};\n\nconst initObservers = () => {\n if (!actionbar.value || !placeholderRef.value) return;\n\n // 主元素尺寸观察\n observers.resize = createResizeObserver(\n actionbar.value,\n (entry) => {\n const padding = getTotalPadding(entry.target as HTMLElement);\n elementSize.value = {\n width: entry.contentRect.width + padding.x,\n height: entry.contentRect.height + padding.y,\n };\n },\n { box: \"border-box\" }\n );\n\n // 父元素观察\n const parent = placeholderRef.value.parentElement;\n if (parent) {\n observers.parent = createResizeObserver(parent, () => {\n const rect = parent.getBoundingClientRect();\n parentWidth.value = rect.width;\n elementLeft.value = rect.left;\n });\n }\n};\n\nconst calculateScrollDetails = debounce(() => {\n const { scrollY } = window;\n const { clientHeight, scrollHeight } = document.documentElement;\n isBottom.value = Math.ceil(scrollY + clientHeight) >= scrollHeight;\n}, 100);\n\nconst shadowClass = computed(() => (!isBottom.value ? ns.is(\"shadow\") : \"\"));\n\nconst paddingBottom = computed(() =>\n getDeviceType() === \"Android\" ? Math.max(props.padding, 20) : props.padding\n);\n\nconst actionbarStyle = computed(() => ({\n width: `${parentWidth.value}px`,\n left: `${elementLeft.value}px`,\n ...ns.cssVarBlock({\n \"actionbar-padding\": `${props.padding}px`,\n \"actionbar-padding-bottom\": `${paddingBottom.value}px`,\n }),\n}));\n\nonMounted(() => {\n initObservers();\n window.addEventListener(\"scroll\", calculateScrollDetails, { passive: true });\n});\n\nonUnmounted(() => {\n observers.resize?.disconnect();\n observers.parent?.disconnect();\n window.removeEventListener(\"scroll\", calculateScrollDetails);\n});\n</script>\n\n<template>\n <div\n ref=\"placeholderRef\"\n :style=\"{ width: '100%', height: `${elementSize.height}px` }\"\n >\n <div\n ref=\"actionbar\"\n :style=\"actionbarStyle\"\n :class=\"[ns.e('actionbar'), shadowClass, className]\"\n data-fixed-calc-width\n >\n <slot />\n </div>\n </div>\n</template>\n"],"names":["name","props","__props","ns","useNamespace","isBottom","ref","actionbar","placeholderRef","elementSize","width","height","parentWidth","elementLeft","observers","resize","parent","createResizeObserver","el","callback","options","observer","ResizeObserver","entries","forEach","entry","requestAnimationFrame","observe","initObservers","value","padding","style","getComputedStyle","x","parseFloat","paddingLeft","paddingRight","y","paddingTop","paddingBottom","getTotalPadding","target","contentRect","box","parentElement","rect","getBoundingClientRect","left","calculateScrollDetails","debounce","scrollY","window","clientHeight","scrollHeight","document","documentElement","Math","ceil","shadowClass","computed","is","getDeviceType","max","actionbarStyle","cssVarBlock","onMounted","addEventListener","passive","onUnmounted","disconnect","removeEventListener"],"mappings":"iMAEEA,KAAM,wGAUR,MAAMC,EAAQC,EAWRC,EAAKC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B,MAA0B,GAAlB1B,EAAGyD,GAAG,YAEtDrB,EAAgBoB,EAAAA,UAAS,IACT,YAApBE,EAAcA,gBAAkBL,KAAKM,IAAI7D,EAAM6B,QAAS,IAAM7B,EAAM6B,UAGhEiC,EAAiBJ,EAAAA,UAAS,KAAO,CACrCjD,MAAO,GAAGE,EAAYiB,UACtBkB,KAAM,GAAGlC,EAAYgB,aAClB1B,EAAG6D,YAAY,CAChB,oBAAqB,GAAG/D,EAAM6B,YAC9B,2BAA4B,GAAGS,EAAcV,uBAIjDoC,EAAAA,WAAU,KACMrC,IACduB,OAAOe,iBAAiB,SAAUlB,EAAwB,CAAEmB,SAAS,GAAM,IAG7EC,EAAAA,aAAY,KACVtD,EAAUC,QAAQsD,aAClBvD,EAAUE,QAAQqD,aACXlB,OAAAmB,oBAAoB,SAAUtB,EAAsB"}
1
+ {"version":3,"file":"fixed-action-bar.vue.cjs","sources":["../../../../../../packages/components/src/fixed-action-bar/src/fixed-action-bar.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { useNamespace } from '@qxs-bns/hooks'\nimport { getDeviceType } from '@qxs-bns/utils'\nimport { debounce } from 'lodash-es'\n\nconst props = defineProps({\n padding: {\n type: Number,\n default: 8,\n },\n className: {\n type: String,\n default: '',\n },\n})\n\ninterface ElementSize { width: number, height: number }\n\nconst ns = useNamespace('fixed-action-bar')\nconst isBottom = ref(false)\nconst actionbar = ref<HTMLElement | null>(null)\nconst placeholderRef = ref<HTMLElement | null>(null)\n\nconst elementSize = ref<ElementSize>({ width: 0, height: 0 })\nconst parentWidth = ref(0)\nconst elementLeft = ref(0)\n\nconst observers = {\n resize: null as ResizeObserver | null,\n parent: null as ResizeObserver | null,\n}\n\nfunction getTotalPadding(el: HTMLElement) {\n const style = getComputedStyle(el)\n return {\n x: Number.parseFloat(style.paddingLeft) + Number.parseFloat(style.paddingRight),\n y: Number.parseFloat(style.paddingTop) + Number.parseFloat(style.paddingBottom),\n }\n}\n\nfunction createResizeObserver(el: HTMLElement,\n callback: (entry: ResizeObserverEntry) => void,\n options?: ResizeObserverOptions) {\n const observer = new ResizeObserver((entries) => {\n entries.forEach(entry => requestAnimationFrame(() => callback(entry)))\n })\n observer.observe(el, options)\n return observer\n}\n\nfunction initObservers() {\n if (!actionbar.value || !placeholderRef.value) {\n return\n }\n\n // 主元素尺寸观察\n observers.resize = createResizeObserver(\n actionbar.value,\n (entry) => {\n const padding = getTotalPadding(entry.target as HTMLElement)\n elementSize.value = {\n width: entry.contentRect.width + padding.x,\n height: entry.contentRect.height + padding.y,\n }\n },\n { box: 'border-box' },\n )\n\n // 父元素观察\n const parent = placeholderRef.value.parentElement\n if (parent) {\n observers.parent = createResizeObserver(parent, () => {\n const rect = parent.getBoundingClientRect()\n parentWidth.value = rect.width\n elementLeft.value = rect.left\n })\n }\n}\n\nconst calculateScrollDetails = debounce(() => {\n const { scrollY } = window\n const { clientHeight, scrollHeight } = document.documentElement\n isBottom.value = Math.ceil(scrollY + clientHeight) >= scrollHeight\n}, 100)\n\nconst shadowClass = computed(() => (!isBottom.value ? ns.is('shadow') : ''))\n\nconst paddingBottom = computed(() =>\n getDeviceType() === 'Android' ? Math.max(props.padding, 20) : props.padding,\n)\n\nconst actionbarStyle = computed(() => ({\n width: `${parentWidth.value}px`,\n left: `${elementLeft.value}px`,\n ...ns.cssVarBlock({\n 'actionbar-padding': `${props.padding}px`,\n 'actionbar-padding-bottom': `${paddingBottom.value}px`,\n }),\n}))\n\nonMounted(() => {\n initObservers()\n window.addEventListener('scroll', calculateScrollDetails, { passive: true })\n})\n\nonUnmounted(() => {\n observers.resize?.disconnect()\n observers.parent?.disconnect()\n window.removeEventListener('scroll', calculateScrollDetails)\n})\n</script>\n\n<script lang=\"ts\">\nexport default {\n name: 'QxsFixedActionBar',\n}\n</script>\n\n<template>\n <div\n ref=\"placeholderRef\"\n :style=\"{ width: '100%', height: `${elementSize.height}px` }\"\n >\n <div\n ref=\"actionbar\"\n :style=\"actionbarStyle\"\n :class=\"[ns.e('actionbar'), shadowClass, className]\"\n data-fixed-calc-width\n >\n <slot />\n </div>\n </div>\n</template>\n"],"names":["name","props","__props","ns","useNamespace","isBottom","ref","actionbar","placeholderRef","elementSize","width","height","parentWidth","elementLeft","observers","resize","parent","createResizeObserver","el","callback","options","observer","ResizeObserver","entries","forEach","entry","requestAnimationFrame","observe","initObservers","value","padding","style","getComputedStyle","x","Number","parseFloat","paddingLeft","paddingRight","y","paddingTop","paddingBottom","getTotalPadding","target","contentRect","box","parentElement","rect","getBoundingClientRect","left","calculateScrollDetails","debounce","scrollY","window","clientHeight","scrollHeight","document","documentElement","Math","ceil","shadowClass","computed","is","getDeviceType","max","actionbarStyle","cssVarBlock","onMounted","addEventListener","passive","onUnmounted","disconnect","removeEventListener"],"mappings":"iMAkHEA,KAAM,wGA7GR,MAAMC,EAAQC,EAaRC,EAAKC,eAAa,oBAClBC,EAAWC,OAAI,GACfC,EAAYD,MAAwB,MACpCE,EAAiBF,MAAwB,MAEzCG,EAAcH,EAAAA,IAAiB,CAAEI,MAAO,EAAGC,OAAQ,IACnDC,EAAcN,MAAI,GAClBO,EAAcP,MAAI,GAElBQ,EAAY,CAChBC,OAAQ,KACRC,OAAQ,MAWD,SAAAC,EAAqBC,EAC5BC,EACAC,GACA,MAAMC,EAAW,IAAIC,gBAAgBC,IACnCA,EAAQC,SAAiBC,GAAAC,uBAAsB,IAAMP,EAASM,MAAO,IAGhE,OADEJ,EAAAM,QAAQT,EAAIE,GACdC,CAAA,CAGT,SAASO,IACP,IAAKrB,EAAUsB,QAAUrB,EAAeqB,MACtC,OAIFf,EAAUC,OAASE,EACjBV,EAAUsB,OACTJ,IACO,MAAAK,EA3BZ,SAAyBZ,GACjB,MAAAa,EAAQC,iBAAiBd,GACxB,MAAA,CACLe,EAAGC,OAAOC,WAAWJ,EAAMK,aAAeF,OAAOC,WAAWJ,EAAMM,cAClEC,EAAGJ,OAAOC,WAAWJ,EAAMQ,YAAcL,OAAOC,WAAWJ,EAAMS,eACnE,CAsBoBC,CAAgBhB,EAAMiB,QACtCjC,EAAYoB,MAAQ,CAClBnB,MAAOe,EAAMkB,YAAYjC,MAAQoB,EAAQG,EACzCtB,OAAQc,EAAMkB,YAAYhC,OAASmB,EAAQQ,EAC7C,GAEF,CAAEM,IAAK,eAIH,MAAA5B,EAASR,EAAeqB,MAAMgB,cAChC7B,IACQF,EAAAE,OAASC,EAAqBD,GAAQ,KACxC,MAAA8B,EAAO9B,EAAO+B,wBACpBnC,EAAYiB,MAAQiB,EAAKpC,MACzBG,EAAYgB,MAAQiB,EAAKE,IAAA,IAE7B,CAGI,MAAAC,EAAyBC,EAAAA,UAAS,KAChC,MAAAC,QAAEA,GAAYC,QACdC,aAAEA,EAAAC,aAAcA,GAAiBC,SAASC,gBAChDnD,EAASwB,MAAQ4B,KAAKC,KAAKP,EAAUE,IAAiBC,CAAA,GACrD,KAEGK,EAAcC,YAAS,IAAQvD,EAASwB,MAA0B,GAAlB1B,EAAG0D,GAAG,YAEtDrB,EAAgBoB,EAAAA,UAAS,IACT,YAApBE,EAAcA,gBAAkBL,KAAKM,IAAI9D,EAAM6B,QAAS,IAAM7B,EAAM6B,UAGhEkC,EAAiBJ,EAAAA,UAAS,KAAO,CACrClD,MAAO,GAAGE,EAAYiB,UACtBmB,KAAM,GAAGnC,EAAYgB,aAClB1B,EAAG8D,YAAY,CAChB,oBAAqB,GAAGhE,EAAM6B,YAC9B,2BAA4B,GAAGU,EAAcX,uBAIjDqC,EAAAA,WAAU,KACMtC,IACdwB,OAAOe,iBAAiB,SAAUlB,EAAwB,CAAEmB,SAAS,GAAM,IAG7EC,EAAAA,aAAY,KACVvD,EAAUC,QAAQuD,aAClBxD,EAAUE,QAAQsD,aACXlB,OAAAmB,oBAAoB,SAAUtB,EAAsB"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("element-plus/es");require("element-plus/es/components/base/style/index"),require("element-plus/es/components/image-viewer/style/index"),require("element-plus/es/components/upload/style/index"),require("element-plus/es/components/progress/style/index"),require("element-plus/es/components/image/style/index"),require("element-plus/es/components/icon/style/index");var t=require("vue"),r=require("@element-plus/icons-vue"),l=require("@qxs-bns/hooks"),n=require("element-plus");require("element-plus/es/components/message/style/index");const i={key:1,class:"image"},s={class:"mask"},a={class:"actions"},o={class:"tip-content"};var u=t.defineComponent({name:"QxsImageUpload",__name:"image-upload",props:{action:{type:String,required:!0},headers:{type:null,required:!1},data:{type:null,required:!1},name:{type:String,required:!1,default:"file"},url:{type:String,required:!1,default:""},size:{type:Number,required:!1,default:20},width:{type:Number,required:!1,default:160},accept:{type:String,required:!1,default:"image/jpeg,image/jpg,image/png,image/gif"},height:{type:Number,required:!1,default:90},placeholder:{type:String,required:!1,default:"点击上传图片"},notip:{type:Boolean,required:!1,default:!1},tipText:{type:String,required:!1,default:""},beforeUpload:{type:null,required:!1}},emits:["update:url","onSuccess"],setup(u,{emit:c}){const p=c,d=l.useNamespace("image-upload"),m=n.useNamespace("upload"),f=t.ref({imageViewerVisible:!1,progress:{preview:"",percent:0}}),g=t.computed((()=>u.accept.split(",").map((e=>e.split("/").pop())))),y=t.computed((()=>({width:`${u.width}px`,height:`${u.height}px`}))),h=t.computed((()=>.8*Math.min(u.width,u.height))),v=t.computed((()=>u.tipText||`上传图片支持 ${g.value.join(" / ")} 格式,且图片大小不超过 ${u.size}MB,建议图片尺寸为 ${u.width}*${u.height}`));function V(e){e.preventDefault(),f.value.imageViewerVisible=!0}function q(){f.value.imageViewerVisible=!1}function w(e){e.preventDefault(),p("update:url","")}const N=t=>{const r=t.name.split(".").pop()??"",l=g.value.includes(r),n=t.size/1024/1024<u.size;return l?n?(f.value.progress.preview=URL.createObjectURL(t),!u.beforeUpload||u.beforeUpload(t)):(e.ElMessage.error(`上传图片大小不能超过 ${u.size}MB!`),!1):(e.ElMessage.error(`上传图片只支持${g.value.join(" / ")}格式!`),!1)},k=e=>{f.value.progress.percent=Math.floor(e.percent)},x=(...e)=>{f.value.progress={preview:"",percent:0},p("onSuccess",...e)};return(l,n)=>{const u=e.ElIcon,c=e.ElImage,p=e.ElProgress,g=e.ElUpload,E=e.ElImageViewer;return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(t.unref(d).e("container"))},[t.createVNode(g,{drag:"","show-file-list":!1,headers:l.headers,action:l.action,data:l.data,name:l.name,accept:l.accept,class:t.normalizeClass(t.unref(d).e("control")),"before-upload":N,"on-progress":k,"on-success":x},{default:t.withCtx((()=>[""===l.url?(t.openBlock(),t.createBlock(c,{key:0,style:t.normalizeStyle(t.unref(y)),src:l.placeholder,fit:"fill"},{error:t.withCtx((()=>[t.createElementVNode("div",{class:"image-slot",style:t.normalizeStyle(t.unref(y))},[t.createVNode(u,null,{default:t.withCtx((()=>[t.createVNode(t.unref(r.Plus))])),_:1}),t.createElementVNode("p",null,t.toDisplayString(l.placeholder),1)],4)])),_:1},8,["style","src"])):(t.openBlock(),t.createElementBlock("div",i,[t.createVNode(c,{src:l.url,style:t.normalizeStyle(t.unref(y)),fit:"fill"},null,8,["src","style"]),t.createElementVNode("div",s,[t.createElementVNode("div",a,[t.createElementVNode("span",{title:"预览",onClick:V},[t.createVNode(u,null,{default:t.withCtx((()=>[t.createVNode(t.unref(r.ZoomIn))])),_:1})]),t.createElementVNode("span",{title:"移除",onClick:w},[t.createVNode(u,null,{default:t.withCtx((()=>[t.createVNode(t.unref(r.Delete))])),_:1})])])])])),t.withDirectives(t.createElementVNode("div",{class:"progress",style:t.normalizeStyle(t.unref(y))},[t.createVNode(c,{src:t.unref(f).progress.preview,style:t.normalizeStyle(t.unref(y)),fit:"fill"},null,8,["src","style"]),100!==t.unref(f).progress.percent?(t.openBlock(),t.createBlock(p,{key:0,type:"circle",width:t.unref(h),percentage:t.unref(f).progress.percent},null,8,["width","percentage"])):t.createCommentVNode("v-if",!0)],4),[[t.vShow,""===l.url&&t.unref(f).progress.percent]])])),_:1},8,["headers","action","data","name","accept","class"]),l.notip?t.createCommentVNode("v-if",!0):(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(`${t.unref(m).namespace.value}-upload__tip-text`)},[t.createElementVNode("div",o,t.toDisplayString(t.unref(v)),1)],2)),t.unref(f).imageViewerVisible?(t.openBlock(),t.createBlock(E,{key:1,"url-list":[l.url],teleported:"",onClose:q},null,8,["url-list"])):t.createCommentVNode("v-if",!0)],2)}}});exports.default=u;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("element-plus/es");require("element-plus/es/components/base/style/index"),require("element-plus/es/components/image-viewer/style/index"),require("element-plus/es/components/upload/style/index"),require("element-plus/es/components/progress/style/index"),require("element-plus/es/components/image/style/index"),require("element-plus/es/components/icon/style/index");var t=require("vue"),r=require("@element-plus/icons-vue"),l=require("@qxs-bns/hooks"),i=require("element-plus");require("element-plus/es/components/message/style/index");const s={key:1,class:"image"},n={class:"mask"},a={class:"actions"},o={class:"tip-content"};var u=t.defineComponent({name:"QxsImageUpload",__name:"image-upload",props:{action:{type:String,required:!0},headers:{type:null,required:!1},data:{type:null,required:!1},name:{type:String,required:!1,default:"file"},url:{type:String,required:!1,default:""},size:{type:Number,required:!1,default:20},width:{type:Number,required:!1,default:160},accept:{type:String,required:!1,default:"image/jpeg,image/jpg,image/png,image/gif"},height:{type:Number,required:!1,default:90},placeholder:{type:String,required:!1,default:"点击上传图片"},notip:{type:Boolean,required:!1,default:!1},tipText:{type:String,required:!1,default:""},beforeUpload:{type:null,required:!1}},emits:["update:url","onSuccess"],setup(u,{emit:c}){const p=c,d=l.useNamespace("image-upload"),m=i.useNamespace("upload"),f=t.ref({imageViewerVisible:!1,progress:{preview:"",percent:0}}),g=t.computed((()=>u.accept.split(",").map((e=>e.split("/").pop())))),y=t.computed((()=>({width:`${u.width}px`,height:`${u.height}px`}))),h=t.computed((()=>.8*Math.min(u.width,u.height))),v=t.computed((()=>u.tipText||`上传图片支持 ${g.value.join(" / ")} 格式,且图片大小不超过 ${u.size}MB,建议图片尺寸为 ${u.width}*${u.height}`));function V(e){e.preventDefault(),f.value.imageViewerVisible=!0}function w(){f.value.imageViewerVisible=!1}function q(e){e.preventDefault(),p("update:url","")}const N=t=>{const r=t.name.split(".").pop()??"",l=g.value.includes(r),i=t.size/1024/1024<u.size;return l?i?(f.value.progress.preview=URL.createObjectURL(t),!u.beforeUpload||u.beforeUpload(t)):(e.ElMessage.error(`上传图片大小不能超过 ${u.size}MB!`),!1):(e.ElMessage.error(`上传图片只支持${g.value.join(" / ")}格式!`),!1)},k=e=>{f.value.progress.percent=Math.floor(e.percent)},x=(...e)=>{f.value.progress={preview:"",percent:0},p("onSuccess",...e)};return(l,i)=>{const u=e.ElIcon,c=e.ElImage,p=e.ElProgress,g=e.ElUpload,E=e.ElImageViewer;return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(t.unref(d).e("container"))},[t.createVNode(g,{drag:"","show-file-list":!1,headers:l.headers,action:l.action,data:l.data,name:l.name,accept:l.accept,class:t.normalizeClass(t.unref(d).e("control")),"before-upload":N,"on-progress":k,"on-success":x},{default:t.withCtx((()=>[""===l.url?(t.openBlock(),t.createBlock(c,{key:0,style:t.normalizeStyle(t.unref(y)),src:l.placeholder,fit:"fill"},{error:t.withCtx((()=>[t.createElementVNode("div",{class:"image-slot",style:t.normalizeStyle(t.unref(y))},[t.createVNode(u,null,{default:t.withCtx((()=>[t.createVNode(t.unref(r.Plus))])),_:1}),t.createElementVNode("p",null,t.toDisplayString(l.placeholder),1)],4)])),_:1},8,["style","src"])):(t.openBlock(),t.createElementBlock("div",s,[t.createVNode(c,{src:l.url,style:t.normalizeStyle(t.unref(y)),fit:"fill"},null,8,["src","style"]),t.createElementVNode("div",n,[t.createElementVNode("div",a,[t.createElementVNode("span",{title:"预览",onClick:t.withModifiers(V,["stop"])},[t.createVNode(u,null,{default:t.withCtx((()=>[t.createVNode(t.unref(r.ZoomIn))])),_:1})]),t.createElementVNode("span",{title:"移除",onClick:t.withModifiers(q,["stop"])},[t.createVNode(u,null,{default:t.withCtx((()=>[t.createVNode(t.unref(r.Delete))])),_:1})])])])])),t.withDirectives(t.createElementVNode("div",{class:"progress",style:t.normalizeStyle(t.unref(y))},[t.createVNode(c,{src:t.unref(f).progress.preview,style:t.normalizeStyle(t.unref(y)),fit:"fill"},null,8,["src","style"]),100!==t.unref(f).progress.percent?(t.openBlock(),t.createBlock(p,{key:0,type:"circle",width:t.unref(h),percentage:t.unref(f).progress.percent},null,8,["width","percentage"])):t.createCommentVNode("v-if",!0)],4),[[t.vShow,""===l.url&&t.unref(f).progress.percent]])])),_:1},8,["headers","action","data","name","accept","class"]),l.notip?t.createCommentVNode("v-if",!0):(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(`${t.unref(m).namespace.value}-upload__tip-text`)},[t.createElementVNode("div",o,t.toDisplayString(t.unref(v)),1)],2)),t.unref(f).imageViewerVisible?(t.openBlock(),t.createBlock(E,{key:1,"url-list":[l.url],teleported:"",onClose:w},null,8,["url-list"])):t.createCommentVNode("v-if",!0)],2)}}});exports.default=u;
2
2
  //# sourceMappingURL=image-upload.vue.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"image-upload.vue.cjs","sources":["../../../../../../packages/components/src/image-upload/src/image-upload.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { UploadFile, UploadFiles, UploadProps } from \"element-plus\";\nimport { Delete, Plus, ZoomIn } from \"@element-plus/icons-vue\";\nimport { useNamespace } from \"@qxs-bns/hooks\";\nimport { useNamespace as useElNamespace } from \"element-plus\";\n\n// 类型定义\nexport interface ImageUploadProps {\n action: UploadProps[\"action\"];\n headers?: UploadProps[\"headers\"];\n data?: UploadProps[\"data\"];\n name?: UploadProps[\"name\"];\n url?: string;\n size?: number;\n width?: number;\n accept?: string;\n height?: number;\n placeholder?: string;\n notip?: boolean;\n tipText?: string;\n beforeUpload?: UploadProps[\"beforeUpload\"];\n}\n\ninterface UploadProgress {\n preview: string;\n percent: number;\n}\n\n// 组件名称\ndefineOptions({\n name: \"QxsImageUpload\",\n});\n\n// Props 定义\nconst {\n name = \"file\",\n url = \"\",\n size = 20,\n width = 160,\n height = 90,\n placeholder = \"点击上传图片\",\n notip = false,\n accept = \"image/jpeg,image/jpg,image/png,image/gif\",\n beforeUpload,\n tipText = ''\n} = defineProps<ImageUploadProps>();\n\n// Emits 定义\nconst emits = defineEmits<{\n \"update:url\": [url: string];\n onSuccess: [res: any, uploadFile: UploadFile, uploadFiles: UploadFiles];\n}>();\n\n// 命名空间\nconst ns = useNamespace(\"image-upload\");\nconst nsEl = useElNamespace(\"upload\");\n\n// 响应式数据\nconst uploadData = ref<{\n imageViewerVisible: boolean;\n progress: UploadProgress;\n}>({\n imageViewerVisible: false,\n progress: {\n preview: \"\",\n percent: 0,\n },\n});\n\n// 计算属性\nconst exts = computed(() =>\n accept.split(\",\").map((ext) => ext.split(\"/\").pop())\n);\n\nconst imageStyle = computed(() => ({\n width: `${width}px`,\n height: `${height}px`,\n}));\n\nconst progressSize = computed(() => Math.min(width, height) * 0.8);\n\nconst tipMessage = computed(\n () =>\n tipText ||\n `上传图片支持 ${exts.value.join(\n \" / \"\n )} 格式,且图片大小不超过 ${size}MB,建议图片尺寸为 ${width}*${height}`\n);\n\n// 方法\nfunction preview(e: Event) {\n e.preventDefault();\n uploadData.value.imageViewerVisible = true;\n}\n\nfunction previewClose() {\n uploadData.value.imageViewerVisible = false;\n}\n\nfunction remove(e: Event) {\n e.preventDefault();\n emits(\"update:url\", \"\");\n}\n\nconst handleBeforeUpload: UploadProps[\"beforeUpload\"] = (file) => {\n const fileExt = file.name.split(\".\").pop() ?? \"\";\n const isTypeOk = exts.value.includes(fileExt);\n const isSizeOk = file.size / 1024 / 1024 < size;\n\n if (!isTypeOk) {\n ElMessage.error(`上传图片只支持${exts.value.join(\" / \")}格式!`);\n return false;\n }\n\n if (!isSizeOk) {\n ElMessage.error(`上传图片大小不能超过 ${size}MB!`);\n return false;\n }\n\n uploadData.value.progress.preview = URL.createObjectURL(file);\n\n return beforeUpload ? beforeUpload(file) : true;\n};\n\nconst onProgress: UploadProps[\"onProgress\"] = (evt) => {\n uploadData.value.progress.percent = Math.floor(evt.percent);\n};\n\nconst onSuccess: UploadProps[\"onSuccess\"] = (...args) => {\n uploadData.value.progress = {\n preview: \"\",\n percent: 0,\n };\n emits(\"onSuccess\", ...args);\n};\n</script>\n\n<template>\n <div :class=\"ns.e('container')\">\n <el-upload\n drag\n :show-file-list=\"false\"\n :headers=\"headers\"\n :action=\"action\"\n :data=\"data\"\n :name=\"name\"\n :accept=\"accept\"\n :class=\"ns.e('control')\"\n :before-upload=\"handleBeforeUpload\"\n :on-progress=\"onProgress\"\n :on-success=\"onSuccess\"\n >\n <template v-if=\"url === ''\">\n <el-image :style=\"imageStyle\" :src=\"placeholder\" fit=\"fill\">\n <template #error>\n <div class=\"image-slot\" :style=\"imageStyle\">\n <el-icon><Plus /></el-icon>\n <p>{{ placeholder }}</p>\n </div>\n </template>\n </el-image>\n </template>\n\n <template v-else>\n <div class=\"image\">\n <el-image :src=\"url\" :style=\"imageStyle\" fit=\"fill\" />\n <div class=\"mask\">\n <div class=\"actions\">\n <span title=\"预览\" @click=\"preview\">\n <el-icon><ZoomIn /></el-icon>\n </span>\n <span title=\"移除\" @click=\"remove\">\n <el-icon><Delete /></el-icon>\n </span>\n </div>\n </div>\n </div>\n </template>\n\n <div\n v-show=\"url === '' && uploadData.progress.percent\"\n class=\"progress\"\n :style=\"imageStyle\"\n >\n <el-image\n :src=\"uploadData.progress.preview\"\n :style=\"imageStyle\"\n fit=\"fill\"\n />\n <el-progress\n v-if=\"uploadData.progress.percent !== 100\"\n type=\"circle\"\n :width=\"progressSize\"\n :percentage=\"uploadData.progress.percent\"\n />\n </div>\n </el-upload>\n\n <div v-if=\"!notip\" :class=\"`${nsEl.namespace.value}-upload__tip-text`\">\n <div class=\"tip-content\">\n {{ tipMessage }}\n </div>\n </div>\n\n <el-image-viewer\n v-if=\"uploadData.imageViewerVisible\"\n :url-list=\"[url]\"\n teleported\n @close=\"previewClose\"\n />\n </div>\n</template>\n"],"names":["emits","__emit","ns","useNamespace","nsEl","useElNamespace","uploadData","ref","imageViewerVisible","progress","preview","percent","exts","computed","__props","split","map","ext","pop","imageStyle","width","height","progressSize","Math","min","tipMessage","tipText","value","join","size","e","preventDefault","previewClose","remove","handleBeforeUpload","file","fileExt","name","isTypeOk","includes","isSizeOk","URL","createObjectURL","beforeUpload","ElMessage","error","onProgress","evt","floor","onSuccess","args"],"mappings":"m4CAgDA,MAAMA,EAAQC,EAMRC,EAAKC,eAAa,gBAClBC,EAAOC,eAAe,UAGtBC,EAAaC,EAAAA,IAGhB,CACDC,oBAAoB,EACpBC,SAAU,CACRC,QAAS,GACTC,QAAS,KAKPC,EAAOC,EAAAA,UAAS,IACpBC,SAAOC,MAAM,KAAKC,KAAKC,GAAQA,EAAIF,MAAM,KAAKG,UAG1CC,EAAaN,EAAAA,UAAS,KAAO,CACjCO,MAAO,GAAGN,EAAAM,UACVC,OAAQ,GAAGP,EAAAO,eAGPC,EAAeT,EAAAA,UAAS,IAAgC,GAA1BU,KAAKC,IAAIV,EAAAM,MAAON,EAAMO,UAEpDI,EAAaZ,EAAAA,UACjB,IACEC,EAAAY,SACA,UAAUd,EAAKe,MAAMC,KACnB,sBACed,EAAIe,kBAAcf,EAAKM,SAAIN,aAIhD,SAASJ,EAAQoB,GACfA,EAAEC,iBACFzB,EAAWqB,MAAMnB,oBAAqB,CAAA,CAGxC,SAASwB,IACP1B,EAAWqB,MAAMnB,oBAAqB,CAAA,CAGxC,SAASyB,EAAOH,GACdA,EAAEC,iBACF/B,EAAM,aAAc,GAAE,CAGlB,MAAAkC,EAAmDC,IACvD,MAAMC,EAAUD,EAAKE,KAAKtB,MAAM,KAAKG,OAAS,GACxCoB,EAAW1B,EAAKe,MAAMY,SAASH,GAC/BI,EAAWL,EAAKN,KAAO,KAAO,KAAOf,EAAIe,KAE/C,OAAKS,EAKAE,GAKLlC,EAAWqB,MAAMlB,SAASC,QAAU+B,IAAIC,gBAAgBP,IAEjDrB,EAAY6B,cAAG7B,eAAaqB,KANjCS,EAAAA,UAAUC,MAAM,cAAc/B,EAAIe,YAC3B,IANPe,YAAUC,MAAM,UAAUjC,EAAKe,MAAMC,KAAK,cACnC,EAUkC,EAGvCkB,EAAyCC,IAC7CzC,EAAWqB,MAAMlB,SAASE,QAAUY,KAAKyB,MAAMD,EAAIpC,QAAO,EAGtDsC,EAAsC,IAAIC,KAC9C5C,EAAWqB,MAAMlB,SAAW,CAC1BC,QAAS,GACTC,QAAS,GAELX,EAAA,eAAgBkD,EAAI"}
1
+ {"version":3,"file":"image-upload.vue.cjs","sources":["../../../../../../packages/components/src/image-upload/src/image-upload.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { UploadFile, UploadFiles, UploadProps } from 'element-plus'\nimport { Delete, Plus, ZoomIn } from '@element-plus/icons-vue'\nimport { useNamespace } from '@qxs-bns/hooks'\nimport { useNamespace as useElNamespace } from 'element-plus'\n\n// 类型定义\nexport interface ImageUploadProps {\n action: UploadProps['action']\n headers?: UploadProps['headers']\n data?: UploadProps['data']\n name?: UploadProps['name']\n url?: string\n size?: number\n width?: number\n accept?: string\n height?: number\n placeholder?: string\n notip?: boolean\n tipText?: string\n beforeUpload?: UploadProps['beforeUpload']\n}\n\ninterface UploadProgress {\n preview: string\n percent: number\n}\n\n// 组件名称\ndefineOptions({\n name: 'QxsImageUpload',\n})\n\n// Props 定义\nconst {\n name = 'file',\n url = '',\n size = 20,\n width = 160,\n height = 90,\n placeholder = '点击上传图片',\n notip = false,\n accept = 'image/jpeg,image/jpg,image/png,image/gif',\n beforeUpload,\n tipText = '',\n} = defineProps<ImageUploadProps>()\n\n// Emits 定义\nconst emits = defineEmits<{\n 'update:url': [url: string]\n 'onSuccess': [res: any, uploadFile: UploadFile, uploadFiles: UploadFiles]\n}>()\n\n// 命名空间\nconst ns = useNamespace('image-upload')\nconst nsEl = useElNamespace('upload')\n\n// 响应式数据\nconst uploadData = ref<{\n imageViewerVisible: boolean\n progress: UploadProgress\n}>({\n imageViewerVisible: false,\n progress: {\n preview: '',\n percent: 0,\n },\n})\n\n// 计算属性\nconst exts = computed(() =>\n accept.split(',').map(ext => ext.split('/').pop()),\n)\n\nconst imageStyle = computed(() => ({\n width: `${width}px`,\n height: `${height}px`,\n}))\n\nconst progressSize = computed(() => Math.min(width, height) * 0.8)\n\nconst tipMessage = computed(\n () =>\n tipText\n || `上传图片支持 ${exts.value.join(\n ' / ',\n )} 格式,且图片大小不超过 ${size}MB,建议图片尺寸为 ${width}*${height}`,\n)\n\n// 方法\nfunction preview(e: Event) {\n e.preventDefault()\n uploadData.value.imageViewerVisible = true\n}\n\nfunction previewClose() {\n uploadData.value.imageViewerVisible = false\n}\n\nfunction remove(e: Event) {\n e.preventDefault()\n emits('update:url', '')\n}\n\nconst handleBeforeUpload: UploadProps['beforeUpload'] = (file) => {\n const fileExt = file.name.split('.').pop() ?? ''\n const isTypeOk = exts.value.includes(fileExt)\n const isSizeOk = file.size / 1024 / 1024 < size\n\n if (!isTypeOk) {\n ElMessage.error(`上传图片只支持${exts.value.join(' / ')}格式!`)\n return false\n }\n\n if (!isSizeOk) {\n ElMessage.error(`上传图片大小不能超过 ${size}MB!`)\n return false\n }\n\n uploadData.value.progress.preview = URL.createObjectURL(file)\n\n return beforeUpload ? beforeUpload(file) : true\n}\n\nconst onProgress: UploadProps['onProgress'] = (evt) => {\n uploadData.value.progress.percent = Math.floor(evt.percent)\n}\n\nconst onSuccess: UploadProps['onSuccess'] = (...args) => {\n uploadData.value.progress = {\n preview: '',\n percent: 0,\n }\n emits('onSuccess', ...args)\n}\n</script>\n\n<template>\n <div :class=\"ns.e('container')\">\n <el-upload\n drag\n :show-file-list=\"false\"\n :headers=\"headers\"\n :action=\"action\"\n :data=\"data\"\n :name=\"name\"\n :accept=\"accept\"\n :class=\"ns.e('control')\"\n :before-upload=\"handleBeforeUpload\"\n :on-progress=\"onProgress\"\n :on-success=\"onSuccess\"\n >\n <template v-if=\"url === ''\">\n <el-image\n :style=\"imageStyle\"\n :src=\"placeholder\"\n fit=\"fill\"\n >\n <template #error>\n <div\n class=\"image-slot\"\n :style=\"imageStyle\"\n >\n <el-icon><Plus /></el-icon>\n <p>{{ placeholder }}</p>\n </div>\n </template>\n </el-image>\n </template>\n\n <template v-else>\n <div class=\"image\">\n <el-image\n :src=\"url\"\n :style=\"imageStyle\"\n fit=\"fill\"\n />\n <div class=\"mask\">\n <div class=\"actions\">\n <span\n title=\"预览\"\n @click.stop=\"preview\"\n >\n <el-icon><ZoomIn /></el-icon>\n </span>\n <span\n title=\"移除\"\n @click.stop=\"remove\"\n >\n <el-icon><Delete /></el-icon>\n </span>\n </div>\n </div>\n </div>\n </template>\n\n <div\n v-show=\"url === '' && uploadData.progress.percent\"\n class=\"progress\"\n :style=\"imageStyle\"\n >\n <el-image\n :src=\"uploadData.progress.preview\"\n :style=\"imageStyle\"\n fit=\"fill\"\n />\n <el-progress\n v-if=\"uploadData.progress.percent !== 100\"\n type=\"circle\"\n :width=\"progressSize\"\n :percentage=\"uploadData.progress.percent\"\n />\n </div>\n </el-upload>\n\n <div\n v-if=\"!notip\"\n :class=\"`${nsEl.namespace.value}-upload__tip-text`\"\n >\n <div class=\"tip-content\">\n {{ tipMessage }}\n </div>\n </div>\n\n <el-image-viewer\n v-if=\"uploadData.imageViewerVisible\"\n :url-list=\"[url]\"\n teleported\n @close=\"previewClose\"\n />\n </div>\n</template>\n"],"names":["emits","__emit","ns","useNamespace","nsEl","useElNamespace","uploadData","ref","imageViewerVisible","progress","preview","percent","exts","computed","__props","split","map","ext","pop","imageStyle","width","height","progressSize","Math","min","tipMessage","tipText","value","join","size","e","preventDefault","previewClose","remove","handleBeforeUpload","file","fileExt","name","isTypeOk","includes","isSizeOk","URL","createObjectURL","beforeUpload","ElMessage","error","onProgress","evt","floor","onSuccess","args"],"mappings":"m4CAgDA,MAAMA,EAAQC,EAMRC,EAAKC,eAAa,gBAClBC,EAAOC,eAAe,UAGtBC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 +1 @@
1
- {"version":3,"file":"photo-crop-tool.vue.cjs","sources":["../../../../../../packages/components/src/photo-crop-tool/src/photo-crop-tool.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { PropType } from 'vue'\nimport { useNamespace } from '@qxs-bns/hooks'\nimport { useCanvas } from './composables'\n\ndefineOptions({\n name: 'QxsPhotoCropTool',\n})\n\nconst props = defineProps({\n imgFile: {\n type: Object as PropType<File>,\n default: () => null,\n },\n aspectRatio: {\n type: String,\n default: () => '16 / 9',\n },\n defaultWidth: {\n type: Number,\n default: () => 320,\n },\n defaultHeight: {\n type: Number,\n default: () => 180,\n },\n /**\n * free 自由缩放\n * fixed 固定比例缩放\n */\n zoomType: {\n type: String,\n default: () => 'fixed',\n },\n})\nlet startX = 0\nlet startY = 0\nlet startWidth = 0\nlet startHeight = 0\n\nconst ns = useNamespace('photo-crop-tool')\n\nconst cropBoxRef = ref<HTMLElement | null>(null)\nconst containerBoxRef = ref<HTMLElement | null>(null)\nconst imgRef = ref<HTMLImageElement | null>(null)\nconst errorMessage = ref('')\nconst dargPoint = ref('')\nconst initialValue = ref({\n x: 0,\n y: 0,\n})\nconst cropInfo = ref({\n width: props.defaultWidth,\n height: props.defaultHeight,\n x: 0,\n y: 0,\n})\n\nconst { width, height } = useElementSize(cropBoxRef)\nconst { width: imgWidth } = useElementSize(imgRef)\n\nconst { x, y, style } = useDraggable(cropBoxRef, {\n containerElement: containerBoxRef,\n draggingElement: cropBoxRef,\n disabled: computed(() => !!dargPoint.value),\n exact: true,\n initialValue,\n})\n\nconst imageUrl = computed(() => {\n if (!props.imgFile) {\n return ''\n }\n return URL.createObjectURL(props.imgFile)\n})\n\nwatch(\n () => props.imgFile,\n (newFile: File | null) => {\n if (newFile && !newFile.type.startsWith('image/')) {\n errorMessage.value = '文件类型错误'\n }\n else {\n errorMessage.value = ''\n }\n },\n)\n\nconst ratio = computed(() => {\n return (imgRef.value?.naturalWidth || 0) / imgWidth.value\n})\n\nconst customStyle = computed(() => {\n const position = {\n left: 0,\n top: 0,\n }\n if (dargPoint.value === 'bottom-right') {\n position.left = cropInfo.value.x\n position.top = cropInfo.value.y\n }\n else if (dargPoint.value === 'top-left') {\n position.left = cropInfo.value.x - width.value\n position.top = cropInfo.value.y - height.value\n }\n else if (dargPoint.value === 'top-right') {\n position.top = cropInfo.value.y - height.value\n position.left = cropInfo.value.x\n }\n else if (dargPoint.value === 'bottom-left') {\n position.left = cropInfo.value.x - width.value\n position.top = cropInfo.value.y\n }\n return position\n})\n\nconst sizeStyle = computed(() => {\n const { aspectRatio } = props\n\n const style: {\n 'height'?: string\n 'width': string\n 'aspect-ratio'?: string\n 'top': string\n 'left': string\n } = {\n 'width': `${cropInfo.value.width || props.defaultWidth}`,\n 'height': `${cropInfo.value.height || props.defaultHeight}`,\n 'aspect-ratio': aspectRatio,\n 'top': `${customStyle.value.top}px`,\n 'left': `${customStyle.value.left}px`,\n }\n if (props.zoomType === 'free') {\n delete style['aspect-ratio']\n }\n else if (props.zoomType === 'fixed') {\n delete style.height\n }\n return ns.cssVarBlock(style)\n})\n\nfunction zoom(pixel: number) {\n return pixel * ratio.value\n}\nasync function crop(img: HTMLImageElement = imgRef.value!) {\n let backgroundColor = 'transparent'\n if (containerBoxRef.value) {\n backgroundColor = window.getComputedStyle(\n containerBoxRef.value,\n ).backgroundColor\n }\n const canvas = document.createElement('canvas')\n canvas.width = zoom(containerBoxRef.value?.clientWidth || 0)\n canvas.height = zoom(containerBoxRef.value?.clientHeight || 0)\n const { drawImage, cropCanvas, drawColor } = useCanvas(canvas)\n drawColor(0, 0, canvas.width, canvas.height, backgroundColor)\n drawImage(\n img,\n zoom(img.offsetLeft),\n zoom(img.offsetTop),\n img.naturalWidth,\n img.naturalHeight,\n )\n return await cropCanvas(\n zoom(x.value),\n zoom(y.value),\n zoom(width.value),\n zoom(height.value),\n )\n}\n\nfunction checkBoundaries(\n newWidth: number,\n newHeight: number,\n): { width: number, height: number } {\n const maxWidth = containerBoxRef.value?.clientWidth || Infinity\n const maxHeight = containerBoxRef.value?.clientHeight || Infinity\n\n return {\n width: Math.min(Math.max(newWidth, 0), maxWidth),\n height: Math.min(Math.max(newHeight, 0), maxHeight),\n }\n}\n\nfunction mousemove(e: MouseEvent) {\n const deltaX = e.clientX - startX\n const deltaY = e.clientY - startY\n\n if (dargPoint.value === 'bottom-right') {\n if (props.zoomType === 'free') {\n const { width, height } = checkBoundaries(\n startWidth + deltaX,\n startHeight + deltaY,\n )\n cropInfo.value.width = width\n cropInfo.value.height = height\n }\n else if (props.zoomType === 'fixed') {\n const aspectRatio\n = Number.parseFloat(props.aspectRatio.split(' / ')[0])\n / Number.parseFloat(props.aspectRatio.split(' / ')[1])\n let newWidth = startWidth + deltaX\n let newHeight = newWidth / aspectRatio\n const { width, height } = checkBoundaries(newWidth, newHeight)\n if (height > (containerBoxRef.value?.clientHeight || Infinity)) {\n newHeight = containerBoxRef.value?.clientHeight || Infinity\n newWidth = newHeight * aspectRatio\n }\n cropInfo.value.width = width\n cropInfo.value.height = height\n }\n }\n else if (dargPoint.value === 'top-left') {\n if (props.zoomType === 'free') {\n const { width, height } = checkBoundaries(\n startWidth - deltaX,\n startHeight - deltaY,\n )\n cropInfo.value.width = width\n cropInfo.value.height = height\n }\n else if (props.zoomType === 'fixed') {\n const aspectRatio\n = Number.parseFloat(props.aspectRatio.split(' / ')[0])\n / Number.parseFloat(props.aspectRatio.split(' / ')[1])\n let newWidth = startWidth - deltaX\n let newHeight = newWidth / aspectRatio\n const { width, height } = checkBoundaries(newWidth, newHeight)\n if (height > (containerBoxRef.value?.clientHeight || Infinity)) {\n newHeight = containerBoxRef.value?.clientHeight || Infinity\n newWidth = newHeight * aspectRatio\n }\n cropInfo.value.width = width\n cropInfo.value.height = height\n }\n x.value = customStyle.value.left\n y.value = customStyle.value.top\n }\n else if (dargPoint.value === 'top-right') {\n if (props.zoomType === 'free') {\n const { width, height } = checkBoundaries(\n startWidth + deltaX,\n startHeight - deltaY,\n )\n cropInfo.value.width = width\n cropInfo.value.height = height\n }\n else if (props.zoomType === 'fixed') {\n const aspectRatio\n = Number.parseFloat(props.aspectRatio.split(' / ')[0])\n / Number.parseFloat(props.aspectRatio.split(' / ')[1])\n let newWidth = startWidth + deltaX\n let newHeight = newWidth / aspectRatio\n const { width, height } = checkBoundaries(newWidth, newHeight)\n if (height > (containerBoxRef.value?.clientHeight || Infinity)) {\n newHeight = containerBoxRef.value?.clientHeight || Infinity\n newWidth = newHeight * aspectRatio\n }\n cropInfo.value.width = width\n cropInfo.value.height = height\n }\n x.value = customStyle.value.left\n y.value = customStyle.value.top\n }\n else if (dargPoint.value === 'bottom-left') {\n if (props.zoomType === 'free') {\n const { width, height } = checkBoundaries(\n startWidth - deltaX,\n startHeight + deltaY,\n )\n cropInfo.value.width = width\n cropInfo.value.height = height\n }\n else if (props.zoomType === 'fixed') {\n const aspectRatio\n = Number.parseFloat(props.aspectRatio.split(' / ')[0])\n / Number.parseFloat(props.aspectRatio.split(' / ')[1])\n let newWidth = startWidth - deltaX\n let newHeight = newWidth / aspectRatio\n const { width, height } = checkBoundaries(newWidth, newHeight)\n if (height > (containerBoxRef.value?.clientHeight || Infinity)) {\n newHeight = containerBoxRef.value?.clientHeight || Infinity\n newWidth = newHeight * aspectRatio\n }\n cropInfo.value.width = width\n cropInfo.value.height = height\n }\n x.value = customStyle.value.left\n y.value = customStyle.value.top\n }\n e.preventDefault()\n e.stopPropagation()\n}\n\nfunction mousedown(e: MouseEvent, point: string) {\n dargPoint.value = point\n startX = e.clientX\n startY = e.clientY\n startWidth = cropInfo.value.width\n startHeight = cropInfo.value.height\n\n if (point === 'bottom-right') {\n cropInfo.value.x = x.value\n cropInfo.value.y = y.value\n }\n else if (point === 'top-left') {\n cropInfo.value.x = x.value + width.value\n cropInfo.value.y = y.value + height.value\n }\n else if (point === 'top-right') {\n cropInfo.value.x = x.value\n cropInfo.value.y = y.value + height.value\n }\n else if (point === 'bottom-left') {\n cropInfo.value.x = x.value + width.value\n cropInfo.value.y = y.value\n }\n}\n\nfunction mouseup() {\n dargPoint.value = ''\n}\n\nfunction resize() {\n cropInfo.value.width = props.defaultWidth\n cropInfo.value.height = props.defaultHeight\n x.value = 0\n y.value = 0\n}\n\ndocument.addEventListener('mouseup', mouseup)\ndocument.addEventListener('mousemove', mousemove)\n\nonMounted(() => {\n nextTick(() => {\n // 初始化位置\n initialValue.value.x\n = (containerBoxRef.value?.offsetWidth || 0) / 2 - cropInfo.value.width / 2\n initialValue.value.y\n = (containerBoxRef.value?.offsetHeight || 0) / 2\n - cropInfo.value.height / 2\n })\n})\n\nonUnmounted(() => {\n if (imageUrl.value) {\n URL.revokeObjectURL(imageUrl.value)\n }\n document.removeEventListener('mouseup', mouseup)\n document.removeEventListener('mousemove', mousemove)\n})\n\ndefineExpose({\n crop,\n resize,\n})\n</script>\n\n<template>\n <div ref=\"containerBoxRef\" :class=\"[ns.e('img-box')]\">\n <div v-if=\"errorMessage\" :class=\"[ns.e('error-message')]\">\n {{ errorMessage }}\n </div>\n <template v-else>\n <img\n ref=\"imgRef\"\n :class=\"[ns.e('image')]\"\n :src=\"imageUrl\"\n >\n <div\n ref=\"cropBoxRef\"\n :class=\"[ns.e('crop-tool-box')]\"\n :style=\"[\n sizeStyle,\n dargPoint\n ? `left: ${customStyle.left}px;top: ${customStyle.top}px`\n : style,\n ]\"\n >\n <div\n :class=\"[ns.e('top-left')]\"\n @mousedown=\"mousedown($event, 'top-left')\"\n />\n <div\n :class=\"[ns.e('top-right')]\"\n @mousedown=\"mousedown($event, 'top-right')\"\n />\n <div\n :class=\"[ns.e('bottom-right')]\"\n @mousedown=\"mousedown($event, 'bottom-right')\"\n />\n <div\n :class=\"[ns.e('bottom-left')]\"\n @mousedown=\"mousedown($event, 'bottom-left')\"\n />\n </div>\n </template>\n </div>\n</template>\n"],"names":["props","__props","startX","startY","startWidth","startHeight","ns","useNamespace","cropBoxRef","ref","containerBoxRef","imgRef","errorMessage","dargPoint","initialValue","x","y","cropInfo","width","defaultWidth","height","defaultHeight","useElementSize","imgWidth","style","useDraggable","containerElement","draggingElement","disabled","computed","value","exact","imageUrl","imgFile","URL","createObjectURL","watch","newFile","type","startsWith","ratio","naturalWidth","customStyle","position","left","top","sizeStyle","aspectRatio","zoomType","cssVarBlock","zoom","pixel","checkBoundaries","newWidth","newHeight","maxWidth","clientWidth","Infinity","maxHeight","clientHeight","Math","min","max","mousemove","e","deltaX","clientX","deltaY","clientY","Number","parseFloat","split","preventDefault","stopPropagation","mousedown","point","mouseup","document","addEventListener","onMounted","nextTick","offsetWidth","offsetHeight","onUnmounted","revokeObjectURL","removeEventListener","__expose","crop","async","img","backgroundColor","window","getComputedStyle","canvas","createElement","drawImage","cropCanvas","drawColor","useCanvas","offsetLeft","offsetTop","naturalHeight","resize"],"mappings":"4fASA,MAAMA,EAAQC,EA0Bd,IAAIC,EAAS,EACTC,EAAS,EACTC,EAAa,EACbC,EAAc,EAEZ,MAAAC,EAAKC,eAAa,mBAElBC,EAAaC,MAAwB,MACrCC,EAAkBD,MAAwB,MAC1CE,EAASF,MAA6B,MACtCG,EAAeH,MAAI,IACnBI,EAAYJ,MAAI,IAChBK,EAAeL,EAAAA,IAAI,CACvBM,EAAG,EACHC,EAAG,IAECC,EAAWR,EAAAA,IAAI,CACnBS,MAAOlB,EAAMmB,aACbC,OAAQpB,EAAMqB,cACdN,EAAG,EACHC,EAAG,KAGCE,MAAEA,EAAAE,OAAOA,GAAWE,EAAAA,eAAed,IACjCU,MAAOK,GAAaD,EAAAA,eAAeX,IAErCI,EAAEA,EAAGC,EAAAA,EAAAQ,MAAGA,GAAUC,EAAAA,aAAajB,EAAY,CAC/CkB,iBAAkBhB,EAClBiB,gBAAiBnB,EACjBoB,SAAUC,EAAAA,UAAS,MAAQhB,EAAUiB,QACrCC,OAAO,EACPjB,iBAGIkB,EAAWH,EAAAA,UAAS,IACnB7B,EAAMiC,QAGJC,IAAIC,gBAAgBnC,EAAMiC,SAFxB,KAKXG,EAAAA,OACE,IAAMp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,EAAAa,MAAMV,OAASpB,EAAMqB,cAC9BN,EAAEe,MAAQ,EACVd,EAAEc,MAAQ,CAAA"}
1
+ {"version":3,"file":"photo-crop-tool.vue.cjs","sources":["../../../../../../packages/components/src/photo-crop-tool/src/photo-crop-tool.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { PropType } from 'vue'\nimport { useNamespace } from '@qxs-bns/hooks'\nimport { useCanvas } from './composables'\n\ndefineOptions({\n name: 'QxsPhotoCropTool',\n})\n\nconst props = defineProps({\n imgFile: {\n type: Object as PropType<File>,\n default: () => null,\n },\n aspectRatio: {\n type: String,\n default: () => '16 / 9',\n },\n defaultWidth: {\n type: Number,\n default: () => 320,\n },\n defaultHeight: {\n type: Number,\n default: () => 180,\n },\n /**\n * free 自由缩放\n * fixed 固定比例缩放\n */\n zoomType: {\n type: String,\n default: () => 'fixed',\n },\n})\nlet startX = 0\nlet startY = 0\nlet startWidth = 0\nlet startHeight = 0\n\nconst ns = useNamespace('photo-crop-tool')\n\nconst cropBoxRef = ref<HTMLElement | null>(null)\nconst containerBoxRef = ref<HTMLElement | null>(null)\nconst imgRef = ref<HTMLImageElement | null>(null)\nconst errorMessage = ref('')\nconst dargPoint = ref('')\nconst initialValue = ref({\n x: 0,\n y: 0,\n})\nconst cropInfo = ref({\n width: props.defaultWidth,\n height: props.defaultHeight,\n x: 0,\n y: 0,\n})\n\nconst { width, height } = useElementSize(cropBoxRef)\nconst { width: imgWidth } = useElementSize(imgRef)\n\nconst { x, y, style } = useDraggable(cropBoxRef, {\n containerElement: containerBoxRef,\n draggingElement: cropBoxRef,\n disabled: computed(() => !!dargPoint.value),\n exact: true,\n initialValue,\n})\n\nconst imageUrl = computed(() => {\n if (!props.imgFile) {\n return ''\n }\n return URL.createObjectURL(props.imgFile)\n})\n\nwatch(\n () => props.imgFile,\n (newFile: File | null) => {\n if (newFile && !newFile.type.startsWith('image/')) {\n errorMessage.value = '文件类型错误'\n }\n else {\n errorMessage.value = ''\n }\n },\n)\n\nconst ratio = computed(() => {\n return (imgRef.value?.naturalWidth || 0) / imgWidth.value\n})\n\nconst customStyle = computed(() => {\n const position = {\n left: 0,\n top: 0,\n }\n if (dargPoint.value === 'bottom-right') {\n position.left = cropInfo.value.x\n position.top = cropInfo.value.y\n }\n else if (dargPoint.value === 'top-left') {\n position.left = cropInfo.value.x - width.value\n position.top = cropInfo.value.y - height.value\n }\n else if (dargPoint.value === 'top-right') {\n position.top = cropInfo.value.y - height.value\n position.left = cropInfo.value.x\n }\n else if (dargPoint.value === 'bottom-left') {\n position.left = cropInfo.value.x - width.value\n position.top = cropInfo.value.y\n }\n return position\n})\n\nconst sizeStyle = computed(() => {\n const { aspectRatio } = props\n\n const style: {\n 'height'?: string\n 'width': string\n 'aspect-ratio'?: string\n 'top': string\n 'left': string\n } = {\n 'width': `${cropInfo.value.width || props.defaultWidth}`,\n 'height': `${cropInfo.value.height || props.defaultHeight}`,\n 'aspect-ratio': aspectRatio,\n 'top': `${customStyle.value.top}px`,\n 'left': `${customStyle.value.left}px`,\n }\n if (props.zoomType === 'free') {\n delete style['aspect-ratio']\n }\n else if (props.zoomType === 'fixed') {\n delete style.height\n }\n return ns.cssVarBlock(style)\n})\n\nfunction zoom(pixel: number) {\n return pixel * ratio.value\n}\nasync function crop(img: HTMLImageElement = imgRef.value!) {\n let backgroundColor = 'transparent'\n if (containerBoxRef.value) {\n backgroundColor = window.getComputedStyle(\n containerBoxRef.value,\n ).backgroundColor\n }\n const canvas = document.createElement('canvas')\n canvas.width = zoom(containerBoxRef.value?.clientWidth || 0)\n canvas.height = zoom(containerBoxRef.value?.clientHeight || 0)\n const { drawImage, cropCanvas, drawColor } = useCanvas(canvas)\n drawColor(0, 0, canvas.width, canvas.height, backgroundColor)\n drawImage(\n img,\n zoom(img.offsetLeft),\n zoom(img.offsetTop),\n img.naturalWidth,\n img.naturalHeight,\n )\n return await cropCanvas(\n zoom(x.value),\n zoom(y.value),\n zoom(width.value),\n zoom(height.value),\n )\n}\n\nfunction checkBoundaries(\n newWidth: number,\n newHeight: number,\n): { width: number, height: number } {\n const maxWidth = containerBoxRef.value?.clientWidth || Infinity\n const maxHeight = containerBoxRef.value?.clientHeight || Infinity\n\n return {\n width: Math.min(Math.max(newWidth, 0), maxWidth),\n height: Math.min(Math.max(newHeight, 0), maxHeight),\n }\n}\n\nfunction mousemove(e: MouseEvent) {\n const deltaX = e.clientX - startX\n const deltaY = e.clientY - startY\n\n if (dargPoint.value === 'bottom-right') {\n if (props.zoomType === 'free') {\n const { width, height } = checkBoundaries(\n startWidth + deltaX,\n startHeight + deltaY,\n )\n cropInfo.value.width = width\n cropInfo.value.height = height\n }\n else if (props.zoomType === 'fixed') {\n const aspectRatio\n = Number.parseFloat(props.aspectRatio.split(' / ')[0])\n / Number.parseFloat(props.aspectRatio.split(' / ')[1])\n let newWidth = startWidth + deltaX\n let newHeight = newWidth / aspectRatio\n const { width, height } = checkBoundaries(newWidth, newHeight)\n if (height > (containerBoxRef.value?.clientHeight || Infinity)) {\n newHeight = containerBoxRef.value?.clientHeight || Infinity\n newWidth = newHeight * aspectRatio\n }\n cropInfo.value.width = width\n cropInfo.value.height = height\n }\n }\n else if (dargPoint.value === 'top-left') {\n if (props.zoomType === 'free') {\n const { width, height } = checkBoundaries(\n startWidth - deltaX,\n startHeight - deltaY,\n )\n cropInfo.value.width = width\n cropInfo.value.height = height\n }\n else if (props.zoomType === 'fixed') {\n const aspectRatio\n = Number.parseFloat(props.aspectRatio.split(' / ')[0])\n / Number.parseFloat(props.aspectRatio.split(' / ')[1])\n let newWidth = startWidth - deltaX\n let newHeight = newWidth / aspectRatio\n const { width, height } = checkBoundaries(newWidth, newHeight)\n if (height > (containerBoxRef.value?.clientHeight || Infinity)) {\n newHeight = containerBoxRef.value?.clientHeight || Infinity\n newWidth = newHeight * aspectRatio\n }\n cropInfo.value.width = width\n cropInfo.value.height = height\n }\n x.value = customStyle.value.left\n y.value = customStyle.value.top\n }\n else if (dargPoint.value === 'top-right') {\n if (props.zoomType === 'free') {\n const { width, height } = checkBoundaries(\n startWidth + deltaX,\n startHeight - deltaY,\n )\n cropInfo.value.width = width\n cropInfo.value.height = height\n }\n else if (props.zoomType === 'fixed') {\n const aspectRatio\n = Number.parseFloat(props.aspectRatio.split(' / ')[0])\n / Number.parseFloat(props.aspectRatio.split(' / ')[1])\n let newWidth = startWidth + deltaX\n let newHeight = newWidth / aspectRatio\n const { width, height } = checkBoundaries(newWidth, newHeight)\n if (height > (containerBoxRef.value?.clientHeight || Infinity)) {\n newHeight = containerBoxRef.value?.clientHeight || Infinity\n newWidth = newHeight * aspectRatio\n }\n cropInfo.value.width = width\n cropInfo.value.height = height\n }\n x.value = customStyle.value.left\n y.value = customStyle.value.top\n }\n else if (dargPoint.value === 'bottom-left') {\n if (props.zoomType === 'free') {\n const { width, height } = checkBoundaries(\n startWidth - deltaX,\n startHeight + deltaY,\n )\n cropInfo.value.width = width\n cropInfo.value.height = height\n }\n else if (props.zoomType === 'fixed') {\n const aspectRatio\n = Number.parseFloat(props.aspectRatio.split(' / ')[0])\n / Number.parseFloat(props.aspectRatio.split(' / ')[1])\n let newWidth = startWidth - deltaX\n let newHeight = newWidth / aspectRatio\n const { width, height } = checkBoundaries(newWidth, newHeight)\n if (height > (containerBoxRef.value?.clientHeight || Infinity)) {\n newHeight = containerBoxRef.value?.clientHeight || Infinity\n newWidth = newHeight * aspectRatio\n }\n cropInfo.value.width = width\n cropInfo.value.height = height\n }\n x.value = customStyle.value.left\n y.value = customStyle.value.top\n }\n e.preventDefault()\n e.stopPropagation()\n}\n\nfunction mousedown(e: MouseEvent, point: string) {\n dargPoint.value = point\n startX = e.clientX\n startY = e.clientY\n startWidth = cropInfo.value.width\n startHeight = cropInfo.value.height\n\n if (point === 'bottom-right') {\n cropInfo.value.x = x.value\n cropInfo.value.y = y.value\n }\n else if (point === 'top-left') {\n cropInfo.value.x = x.value + width.value\n cropInfo.value.y = y.value + height.value\n }\n else if (point === 'top-right') {\n cropInfo.value.x = x.value\n cropInfo.value.y = y.value + height.value\n }\n else if (point === 'bottom-left') {\n cropInfo.value.x = x.value + width.value\n cropInfo.value.y = y.value\n }\n}\n\nfunction mouseup() {\n dargPoint.value = ''\n}\n\nfunction resize() {\n cropInfo.value.width = props.defaultWidth\n cropInfo.value.height = props.defaultHeight\n x.value = 0\n y.value = 0\n}\n\ndocument.addEventListener('mouseup', mouseup)\ndocument.addEventListener('mousemove', mousemove)\n\nonMounted(() => {\n nextTick(() => {\n // 初始化位置\n initialValue.value.x\n = (containerBoxRef.value?.offsetWidth || 0) / 2 - cropInfo.value.width / 2\n initialValue.value.y\n = (containerBoxRef.value?.offsetHeight || 0) / 2\n - cropInfo.value.height / 2\n })\n})\n\nonUnmounted(() => {\n if (imageUrl.value) {\n URL.revokeObjectURL(imageUrl.value)\n }\n document.removeEventListener('mouseup', mouseup)\n document.removeEventListener('mousemove', mousemove)\n})\n\ndefineExpose({\n crop,\n resize,\n})\n</script>\n\n<template>\n <div\n ref=\"containerBoxRef\"\n :class=\"[ns.e('img-box')]\"\n >\n <div\n v-if=\"errorMessage\"\n :class=\"[ns.e('error-message')]\"\n >\n {{ errorMessage }}\n </div>\n <template v-else>\n <img\n ref=\"imgRef\"\n :class=\"[ns.e('image')]\"\n :src=\"imageUrl\"\n >\n <div\n ref=\"cropBoxRef\"\n :class=\"[ns.e('crop-tool-box')]\"\n :style=\"[\n sizeStyle,\n dargPoint\n ? `left: ${customStyle.left}px;top: ${customStyle.top}px`\n : style,\n ]\"\n >\n <div\n :class=\"[ns.e('top-left')]\"\n @mousedown=\"mousedown($event, 'top-left')\"\n />\n <div\n :class=\"[ns.e('top-right')]\"\n @mousedown=\"mousedown($event, 'top-right')\"\n />\n <div\n :class=\"[ns.e('bottom-right')]\"\n @mousedown=\"mousedown($event, 'bottom-right')\"\n />\n <div\n :class=\"[ns.e('bottom-left')]\"\n @mousedown=\"mousedown($event, 'bottom-left')\"\n />\n </div>\n </template>\n </div>\n</template>\n"],"names":["props","__props","startX","startY","startWidth","startHeight","ns","useNamespace","cropBoxRef","ref","containerBoxRef","imgRef","errorMessage","dargPoint","initialValue","x","y","cropInfo","width","defaultWidth","height","defaultHeight","useElementSize","imgWidth","style","useDraggable","containerElement","draggingElement","disabled","computed","value","exact","imageUrl","imgFile","URL","createObjectURL","watch","newFile","type","startsWith","ratio","naturalWidth","customStyle","position","left","top","sizeStyle","aspectRatio","zoomType","cssVarBlock","zoom","pixel","checkBoundaries","newWidth","newHeight","maxWidth","clientWidth","Infinity","maxHeight","clientHeight","Math","min","max","mousemove","e","deltaX","clientX","deltaY","clientY","Number","parseFloat","split","preventDefault","stopPropagation","mousedown","point","mouseup","document","addEventListener","onMounted","nextTick","offsetWidth","offsetHeight","onUnmounted","revokeObjectURL","removeEventListener","__expose","crop","async","img","backgroundColor","window","getComputedStyle","canvas","createElement","drawImage","cropCanvas","drawColor","useCanvas","offsetLeft","offsetTop","naturalHeight","resize"],"mappings":"4fASA,MAAMA,EAAQC,EA0Bd,IAAIC,EAAS,EACTC,EAAS,EACTC,EAAa,EACbC,EAAc,EAEZ,MAAAC,EAAKC,eAAa,mBAElBC,EAAaC,MAAwB,MACrCC,EAAkBD,MAAwB,MAC1CE,EAASF,MAA6B,MACtCG,EAAeH,MAAI,IACnBI,EAAYJ,MAAI,IAChBK,EAAeL,EAAAA,IAAI,CACvBM,EAAG,EACHC,EAAG,IAECC,EAAWR,EAAAA,IAAI,CACnBS,MAAOlB,EAAMmB,aACbC,OAAQpB,EAAMqB,cACdN,EAAG,EACHC,EAAG,KAGCE,MAAEA,EAAAE,OAAOA,GAAWE,EAAAA,eAAed,IACjCU,MAAOK,GAAaD,EAAAA,eAAeX,IAErCI,EAAEA,EAAGC,EAAAA,EAAAQ,MAAGA,GAAUC,EAAAA,aAAajB,EAAY,CAC/CkB,iBAAkBhB,EAClBiB,gBAAiBnB,EACjBoB,SAAUC,EAAAA,UAAS,MAAQhB,EAAUiB,QACrCC,OAAO,EACPjB,iBAGIkB,EAAWH,EAA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EAAMY,OACXoB,EAAK9B,EAAOU,OACd,EA0LAwE,OA/BF,WACWrF,EAAAa,MAAMZ,MAAQlB,EAAMmB,aACpBF,EAAAa,MAAMV,OAASpB,EAAMqB,cAC9BN,EAAEe,MAAQ,EACVd,EAAEc,MAAQ,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../../../packages/components/src/subject-action/index.ts"],"sourcesContent":["import { withInstall } from '../withInstall'\nimport component from './src/subject-action.vue'\n\nconst QxsSubjectAction = withInstall(component)\n \nexport {\n QxsSubjectAction\n}\n \nexport default QxsSubjectAction"],"names":["QxsSubjectAction","withInstall","component","default"],"mappings":"kJAGA,MAAMA,EAAmBC,cAAYC,EAASC"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../../../packages/components/src/subject-action/index.ts"],"sourcesContent":["import { withInstall } from '../withInstall'\nimport component from './src/subject-action.vue'\n\nconst QxsSubjectAction = withInstall(component)\n\nexport {\n QxsSubjectAction,\n}\n\nexport default QxsSubjectAction\n"],"names":["QxsSubjectAction","withInstall","component","default"],"mappings":"kJAGA,MAAMA,EAAmBC,cAAYC,EAASC"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("element-plus/es");require("element-plus/es/components/base/style/index"),require("element-plus/es/components/dialog/style/index"),require("element-plus/es/components/radio-group/style/index"),require("element-plus/es/components/radio/style/index"),require("element-plus/es/components/button/style/index"),require("element-plus/es/components/icon/style/index"),require("element-plus/es/components/checkbox/style/index"),require("element-plus/es/components/popover/style/index"),require("element-plus/es/components/link/style/index");var t=require("vue"),l=require("@element-plus/icons-vue"),o=require("@qxs-bns/hooks"),a=require("../../subject-type/src/subject-type.vue.cjs");const n={key:0,class:"flex-justify-between"},r={class:"flex-justify-between"},c={key:0,class:"has-set"},i={key:1,class:"flex flex-justify-end action-buttons"};var u=t.defineComponent({name:"QxsSubjectAction",__name:"subject-action",props:{isEdit:Boolean,isSet:{type:Boolean,default:!1},isKey:{type:Boolean,default:!1},answerCheckType:{type:Number,default:1},showOtherOption:{type:Boolean,default:!0},examAnswerRelationType:{type:Number,default:null},showRichText:{type:Boolean,default:!0},pageEnd:{type:Boolean,default:!1}},emits:["move-up","move-down","delete","save","edit","add","on-show-rich-text","set-key","set-answer-setting"],setup(u,{emit:s}){const d=u,m=t.ref(d.isKey),p=t.ref(!1),f=s,x=t.ref(d.answerCheckType),k=o.useNamespace("subject-action"),V=t.ref(!0),y=[{value:2,label:"必须全部都是支持选项,方可下一步"},{value:1,label:"无需判断是否是支持选项"},{value:3,label:"包含全部支持选项,即可下一步"}],C=t.computed((()=>y.find((e=>e.value===x.value))?.label));function h(){p.value=!1,f("set-answer-setting",x.value)}function v(){f("set-key",m.value)}function N(e,t){f("add",e,t?d.examAnswerRelationType:null)}return(o,s)=>{const d=e.ElLink,w=e.ElPopover,B=e.ElCheckbox,b=e.ElIcon,E=e.ElButton,_=e.ElRadio,g=e.ElRadioGroup,T=e.ElDialog;return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(t.unref(k).e("action-exam"))},[t.createElementVNode("div",{class:t.normalizeClass(["action flex flex-justify-between",{active:u.isEdit}])},[t.createCommentVNode(" 编辑模式 "),u.isEdit?(t.openBlock(),t.createElementBlock("div",n,[t.createVNode(w,{trigger:"click"},{reference:t.withCtx((()=>[t.createVNode(d,{type:"primary",class:"btn-margin"},{default:t.withCtx((()=>s[15]||(s[15]=[t.createTextVNode(" +在此题后加入新题")]))),_:1})])),default:t.withCtx((()=>[t.createVNode(a.default,{onSelect:N})])),_:1}),u.showRichText?(t.openBlock(),t.createBlock(d,{key:0,type:"primary",class:"btn-margin",onClick:s[0]||(s[0]=e=>f("on-show-rich-text"))},{default:t.withCtx((()=>s[16]||(s[16]=[t.createTextVNode(" +添加题目描述(图文) ")]))),_:1})):t.createCommentVNode("v-if",!0),u.showOtherOption?(t.openBlock(),t.createBlock(d,{key:1,type:"primary",class:"btn-margin",onClick:s[1]||(s[1]=e=>p.value=!0)},{default:t.withCtx((()=>s[17]||(s[17]=[t.createTextVNode(" 答题设置 ")]))),_:1})):t.createCommentVNode("v-if",!0),u.showOtherOption?(t.openBlock(),t.createBlock(B,{key:2,modelValue:t.unref(m),"onUpdate:modelValue":s[2]||(s[2]=e=>t.isRef(m)?m.value=e:null),label:"核心题",onChange:v},null,8,["modelValue"])):t.createCommentVNode("v-if",!0)])):(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[t.createCommentVNode(" 非编辑模式 "),t.createElementVNode("div",r,[u.showOtherOption?(t.openBlock(),t.createBlock(B,{key:0,modelValue:t.unref(m),"onUpdate:modelValue":s[3]||(s[3]=e=>t.isRef(m)?m.value=e:null),label:"核心题",disabled:""},null,8,["modelValue"])):t.createCommentVNode("v-if",!0),u.showOtherOption?(t.openBlock(),t.createBlock(B,{key:1,modelValue:t.unref(V),"onUpdate:modelValue":s[4]||(s[4]=e=>t.isRef(V)?V.value=e:null),label:t.unref(C),disabled:"",class:"btn-margin"},null,8,["modelValue","label"])):t.createCommentVNode("v-if",!0)])],2112)),t.createCommentVNode(" 操作按钮 "),t.createElementVNode("div",null,[u.isSet?(t.openBlock(),t.createElementBlock("div",c,"*此题设置了跳题逻辑")):(t.openBlock(),t.createElementBlock("div",i,[u.isEdit?(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[t.createVNode(E,{class:"btn-margin",onClick:s[9]||(s[9]=e=>f("delete"))},{default:t.withCtx((()=>s[22]||(s[22]=[t.createTextVNode("删除")]))),_:1}),t.createVNode(E,{type:"primary",onClick:s[10]||(s[10]=e=>f("save"))},{default:t.withCtx((()=>s[23]||(s[23]=[t.createTextVNode("完成编辑")]))),_:1})],64)):(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[u.pageEnd?t.createCommentVNode("v-if",!0):(t.openBlock(),t.createBlock(E,{key:0,onClick:s[5]||(s[5]=e=>f("edit"))},{icon:t.withCtx((()=>[t.createVNode(b,null,{default:t.withCtx((()=>[t.createVNode(t.unref(l.Edit))])),_:1})])),default:t.withCtx((()=>[s[18]||(s[18]=t.createTextVNode(" 编辑 "))])),_:1})),t.createVNode(E,{onClick:s[6]||(s[6]=e=>f("delete"))},{icon:t.withCtx((()=>[t.createVNode(b,null,{default:t.withCtx((()=>[t.createVNode(t.unref(l.Delete))])),_:1})])),default:t.withCtx((()=>[s[19]||(s[19]=t.createTextVNode(" 删除 "))])),_:1}),t.createVNode(E,{onClick:s[7]||(s[7]=e=>f("move-up"))},{icon:t.withCtx((()=>[t.createVNode(b,null,{default:t.withCtx((()=>[t.createVNode(t.unref(l.Top))])),_:1})])),default:t.withCtx((()=>[s[20]||(s[20]=t.createTextVNode(" 上移 "))])),_:1}),t.createVNode(E,{onClick:s[8]||(s[8]=e=>f("move-down"))},{icon:t.withCtx((()=>[t.createVNode(b,null,{default:t.withCtx((()=>[t.createVNode(t.unref(l.Bottom))])),_:1})])),default:t.withCtx((()=>[s[21]||(s[21]=t.createTextVNode(" 下移 "))])),_:1})],64))]))]),t.createCommentVNode(" 答题设置弹窗 "),t.createVNode(T,{modelValue:t.unref(p),"onUpdate:modelValue":s[13]||(s[13]=e=>t.isRef(p)?p.value=e:null),title:"答题设置",class:"customize-dialog",onClose:s[14]||(s[14]=e=>p.value=!1)},{footer:t.withCtx((()=>[t.createVNode(E,{class:"customize-button",type:"primary",plain:"",onClick:s[12]||(s[12]=e=>p.value=!1)},{default:t.withCtx((()=>s[24]||(s[24]=[t.createTextVNode(" 取消 ")]))),_:1}),t.createVNode(E,{class:"customize-button",type:"primary",plain:"",onClick:h},{default:t.withCtx((()=>s[25]||(s[25]=[t.createTextVNode(" 保存 ")]))),_:1})])),default:t.withCtx((()=>[t.createVNode(g,{modelValue:t.unref(x),"onUpdate:modelValue":s[11]||(s[11]=e=>t.isRef(x)?x.value=e:null),class:"vertical-radio-group"},{default:t.withCtx((()=>[(t.openBlock(),t.createElementBlock(t.Fragment,null,t.renderList(y,(e=>t.createVNode(_,{key:e.value,value:e.value},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(e.label),1)])),_:2},1032,["value"]))),64))])),_:1},8,["modelValue"])])),_:1},8,["modelValue"])],2)],2)}}});exports.default=u;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("element-plus/es");require("element-plus/es/components/base/style/index"),require("element-plus/es/components/dialog/style/index"),require("element-plus/es/components/radio-group/style/index"),require("element-plus/es/components/radio/style/index"),require("element-plus/es/components/button/style/index"),require("element-plus/es/components/icon/style/index"),require("element-plus/es/components/checkbox/style/index"),require("element-plus/es/components/popover/style/index"),require("element-plus/es/components/link/style/index");var t=require("vue"),l=require("@element-plus/icons-vue"),o=require("@qxs-bns/hooks"),a=require("../../subject-type/src/subject-type.vue.cjs");const n={key:0,class:"flex-justify-between"},c={class:"flex-justify-between"},r={key:0,class:"has-set"},i={key:1,class:"flex flex-justify-end action-buttons"};var u=t.defineComponent({name:"QxsSubjectAction",__name:"subject-action",props:{isEdit:Boolean,isSet:{type:Boolean,default:!1},isKey:{type:Boolean,default:!1},answerCheckType:{type:Number,default:1},showOtherOption:{type:Boolean,default:!0},examAnswerRelationType:{type:Number,default:null},showRichText:{type:Boolean,default:!0},pageEnd:{type:Boolean,default:!1}},emits:["moveUp","moveDown","delete","save","edit","add","onShowRichText","setKey","setAnswerSetting"],setup(u,{emit:s}){const d=u,m=s,p=t.ref(d.isKey),f=t.ref(!1),x=t.ref(d.answerCheckType),V=o.useNamespace("subject-action"),k=t.ref(!0),y=[{value:2,label:"必须全部都是支持选项,方可下一步"},{value:1,label:"无需判断是否是支持选项"},{value:3,label:"包含全部支持选项,即可下一步"}],C=t.computed((()=>y.find((e=>e.value===x.value))?.label));function h(){f.value=!1,m("setAnswerSetting",x.value)}function v(){m("setKey",p.value)}function N(e,t){m("add",e,t?d.examAnswerRelationType:null)}return(o,s)=>{const d=e.ElLink,w=e.ElPopover,B=e.ElCheckbox,b=e.ElIcon,E=e.ElButton,_=e.ElRadio,g=e.ElRadioGroup,T=e.ElDialog;return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(t.unref(V).e("action-exam"))},[t.createElementVNode("div",{class:t.normalizeClass(["action flex flex-justify-between",{active:u.isEdit}])},[t.createCommentVNode(" 编辑模式 "),u.isEdit?(t.openBlock(),t.createElementBlock("div",n,[t.createVNode(w,{trigger:"click"},{reference:t.withCtx((()=>[t.createVNode(d,{type:"primary",class:"btn-margin"},{default:t.withCtx((()=>s[15]||(s[15]=[t.createTextVNode(" +在此题后加入新题 ")]))),_:1})])),default:t.withCtx((()=>[t.createVNode(a.default,{onSelect:N})])),_:1}),u.showRichText?(t.openBlock(),t.createBlock(d,{key:0,type:"primary",class:"btn-margin",onClick:s[0]||(s[0]=e=>m("onShowRichText"))},{default:t.withCtx((()=>s[16]||(s[16]=[t.createTextVNode(" +添加题目描述(图文) ")]))),_:1})):t.createCommentVNode("v-if",!0),u.showOtherOption?(t.openBlock(),t.createBlock(d,{key:1,type:"primary",class:"btn-margin",onClick:s[1]||(s[1]=e=>f.value=!0)},{default:t.withCtx((()=>s[17]||(s[17]=[t.createTextVNode(" 答题设置 ")]))),_:1})):t.createCommentVNode("v-if",!0),u.showOtherOption?(t.openBlock(),t.createBlock(B,{key:2,modelValue:t.unref(p),"onUpdate:modelValue":s[2]||(s[2]=e=>t.isRef(p)?p.value=e:null),label:"核心题",onChange:v},null,8,["modelValue"])):t.createCommentVNode("v-if",!0)])):(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[t.createCommentVNode(" 非编辑模式 "),t.createElementVNode("div",c,[u.showOtherOption?(t.openBlock(),t.createBlock(B,{key:0,modelValue:t.unref(p),"onUpdate:modelValue":s[3]||(s[3]=e=>t.isRef(p)?p.value=e:null),label:"核心题",disabled:""},null,8,["modelValue"])):t.createCommentVNode("v-if",!0),u.showOtherOption?(t.openBlock(),t.createBlock(B,{key:1,modelValue:t.unref(k),"onUpdate:modelValue":s[4]||(s[4]=e=>t.isRef(k)?k.value=e:null),label:t.unref(C),disabled:"",class:"btn-margin"},null,8,["modelValue","label"])):t.createCommentVNode("v-if",!0)])],2112)),t.createCommentVNode(" 操作按钮 "),t.createElementVNode("div",null,[u.isSet?(t.openBlock(),t.createElementBlock("div",r," *此题设置了跳题逻辑 ")):(t.openBlock(),t.createElementBlock("div",i,[u.isEdit?(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[t.createVNode(E,{class:"btn-margin",onClick:s[9]||(s[9]=e=>m("delete"))},{default:t.withCtx((()=>s[22]||(s[22]=[t.createTextVNode(" 删除 ")]))),_:1}),t.createVNode(E,{type:"primary",onClick:s[10]||(s[10]=e=>m("save"))},{default:t.withCtx((()=>s[23]||(s[23]=[t.createTextVNode(" 完成编辑 ")]))),_:1})],64)):(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[u.pageEnd?t.createCommentVNode("v-if",!0):(t.openBlock(),t.createBlock(E,{key:0,onClick:s[5]||(s[5]=e=>m("edit"))},{icon:t.withCtx((()=>[t.createVNode(b,null,{default:t.withCtx((()=>[t.createVNode(t.unref(l.Edit))])),_:1})])),default:t.withCtx((()=>[s[18]||(s[18]=t.createTextVNode(" 编辑 "))])),_:1})),t.createVNode(E,{onClick:s[6]||(s[6]=e=>m("delete"))},{icon:t.withCtx((()=>[t.createVNode(b,null,{default:t.withCtx((()=>[t.createVNode(t.unref(l.Delete))])),_:1})])),default:t.withCtx((()=>[s[19]||(s[19]=t.createTextVNode(" 删除 "))])),_:1}),t.createVNode(E,{onClick:s[7]||(s[7]=e=>m("moveUp"))},{icon:t.withCtx((()=>[t.createVNode(b,null,{default:t.withCtx((()=>[t.createVNode(t.unref(l.Top))])),_:1})])),default:t.withCtx((()=>[s[20]||(s[20]=t.createTextVNode(" 上移 "))])),_:1}),t.createVNode(E,{onClick:s[8]||(s[8]=e=>m("moveDown"))},{icon:t.withCtx((()=>[t.createVNode(b,null,{default:t.withCtx((()=>[t.createVNode(t.unref(l.Bottom))])),_:1})])),default:t.withCtx((()=>[s[21]||(s[21]=t.createTextVNode(" 下移 "))])),_:1})],64))]))]),t.createCommentVNode(" 答题设置弹窗 "),t.createVNode(T,{modelValue:t.unref(f),"onUpdate:modelValue":s[13]||(s[13]=e=>t.isRef(f)?f.value=e:null),title:"答题设置",class:"customize-dialog",onClose:s[14]||(s[14]=e=>f.value=!1)},{footer:t.withCtx((()=>[t.createVNode(E,{class:"customize-button",type:"primary",plain:"",onClick:s[12]||(s[12]=e=>f.value=!1)},{default:t.withCtx((()=>s[24]||(s[24]=[t.createTextVNode(" 取消 ")]))),_:1}),t.createVNode(E,{class:"customize-button",type:"primary",plain:"",onClick:h},{default:t.withCtx((()=>s[25]||(s[25]=[t.createTextVNode(" 保存 ")]))),_:1})])),default:t.withCtx((()=>[t.createVNode(g,{modelValue:t.unref(x),"onUpdate:modelValue":s[11]||(s[11]=e=>t.isRef(x)?x.value=e:null),class:"vertical-radio-group"},{default:t.withCtx((()=>[(t.openBlock(),t.createElementBlock(t.Fragment,null,t.renderList(y,(e=>t.createVNode(_,{key:e.value,value:e.value},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(e.label),1)])),_:2},1032,["value"]))),64))])),_:1},8,["modelValue"])])),_:1},8,["modelValue"])],2)],2)}}});exports.default=u;
2
2
  //# sourceMappingURL=subject-action.vue.cjs.map