G2CustomSetting.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <template>
  2. <div class="bs-setting-wrap">
  3. <el-form
  4. ref="form"
  5. :model="config"
  6. :rules="customRules"
  7. label-width="120px"
  8. label-position="left"
  9. class="setting-body bs-el-form"
  10. >
  11. <SettingTitle>基础</SettingTitle>
  12. <div class="lc-field-body">
  13. <el-form-item
  14. label="标题"
  15. label-width="120px"
  16. >
  17. <el-input
  18. v-model="config.title"
  19. placeholder="请输入标题"
  20. clearable
  21. />
  22. </el-form-item>
  23. </div>
  24. <SettingTitle>边框</SettingTitle>
  25. <div class="lc-field-body">
  26. <BorderSetting
  27. v-if="config.border"
  28. label-width="120px"
  29. :config="config.border"
  30. :big-title="config.title"
  31. />
  32. </div>
  33. <SettingTitle>位置</SettingTitle>
  34. <div class="lc-field-body">
  35. <PosWhSetting
  36. label-width="120px"
  37. :config="config"
  38. />
  39. </div>
  40. <SettingTitle>旋转</SettingTitle>
  41. <div class="lc-field-body">
  42. <RotateSetting
  43. :config="config"
  44. />
  45. </div>
  46. <template v-for="group in groupList">
  47. <div :key="group.groupName">
  48. <SettingTitle> {{ group.groupName | filterGroupName }}</SettingTitle>
  49. <div class="lc-field-body">
  50. <div
  51. v-for="(setting, settingIndex) in group.list"
  52. :key="settingIndex+1"
  53. >
  54. <el-form-item
  55. :label="['padding','appendPadding'].includes(setting.type)? '' : setting.label"
  56. :label-width="['padding','appendPadding'].includes(setting.type)? '0px' :'120px'"
  57. >
  58. <el-input
  59. v-if="setting.type === 'input'"
  60. v-model="setting.value"
  61. :placeholder="`请输入${setting.label}`"
  62. clearable
  63. />
  64. <el-select
  65. v-else-if="setting.type === 'select'"
  66. v-model="setting.value"
  67. popper-class="bs-el-select"
  68. class="bs-el-select"
  69. :placeholder="`请选择${setting.label}`"
  70. :filterable="setting.filterable"
  71. :multiple="setting.multiple"
  72. clearable
  73. >
  74. <el-option
  75. v-for="(opt, optIndex) in setting.options"
  76. :key="optIndex"
  77. :label="opt.label"
  78. :value="opt.value"
  79. />
  80. </el-select>
  81. <template v-else-if="setting.type === 'colorSelect'">
  82. <color-select
  83. v-model="setting.value"
  84. @update="updateColorScheme"
  85. />
  86. <div
  87. style="
  88. display: flex;
  89. align-items: center;
  90. flex-wrap: wrap;
  91. "
  92. class="color-picker-box"
  93. >
  94. <el-color-picker
  95. v-for="(colorItem, colorItemIndex) in colors"
  96. :key="colorItemIndex"
  97. v-model="setting.value[colorItemIndex]"
  98. popper-class="bs-el-color-picker"
  99. show-alpha
  100. class="start-color"
  101. />
  102. <span
  103. class="el-icon-circle-plus-outline"
  104. style="color: #007aff; font-size: 20px"
  105. @click="addColor"
  106. />
  107. <span
  108. v-if="colors.length"
  109. class="el-icon-remove-outline"
  110. style="color: #ea0b30; font-size: 20px"
  111. @click="delColor()"
  112. />
  113. </div>
  114. </template>
  115. <el-color-picker
  116. v-else-if="setting.type === 'colorPicker'"
  117. v-model="setting.value"
  118. popper-class="bs-el-color-picker"
  119. class="bs-el-color-picker"
  120. show-alpha
  121. />
  122. <!-- 渐变色设置 -->
  123. <GradualSetting
  124. v-else-if="setting.type === 'gradual'"
  125. v-model="setting.value"
  126. />
  127. <el-input-number
  128. v-else-if="setting.type === 'inputNumber'"
  129. v-model="setting.value"
  130. class="bs-el-input-number"
  131. :step="setting.step || 1"
  132. :min="setting.min || 0"
  133. :max="setting.max || 100000"
  134. />
  135. <el-radio-group
  136. v-else-if="setting.type === 'radio'"
  137. v-model="setting.value"
  138. class="bs-el-radio-group"
  139. >
  140. <template v-for="(opt, optIndex) in setting.options">
  141. <el-radio-button
  142. :key="optIndex"
  143. :label="opt.value"
  144. >
  145. {{ opt.label }}
  146. </el-radio-button>
  147. </template>
  148. </el-radio-group>
  149. <el-switch
  150. v-else-if="setting.type === 'switch'"
  151. v-model="setting.value"
  152. class="bs-el-switch"
  153. :active-value="setting.active"
  154. :inactive-value="setting.inactive"
  155. />
  156. <el-slider
  157. v-else-if="setting.type === 'slider'"
  158. v-model="setting.value"
  159. :min="0"
  160. :max="1"
  161. :step="0.01"
  162. />
  163. <PaddingSetting
  164. v-else-if="setting.type === 'appendPadding'"
  165. v-model="setting.value"
  166. />
  167. </el-form-item>
  168. </div>
  169. </div>
  170. </div>
  171. </template>
  172. <!-- </div> -->
  173. </el-form>
  174. </div>
  175. </template>
  176. <script>
  177. import BorderSetting from 'data-room-ui/BigScreenDesign/RightSetting/BorderSetting.vue'
  178. import SettingTitle from 'data-room-ui/SettingTitle/index.vue'
  179. import { chartSettingMixins } from 'data-room-ui/js/mixins/chartSettingMixins'
  180. import ColorSelect from 'data-room-ui/ColorMultipleSelect/index.vue'
  181. // import ColorPicker from 'data-room-ui/ColorPicker/index.vue'
  182. import PaddingSetting from 'data-room-ui/BigScreenDesign/RightSetting/PaddingSetting/index.vue'
  183. import GradualSetting from 'data-room-ui/BigScreenDesign/RightSetting/GradualSetting/index.vue'
  184. import PosWhSetting from 'data-room-ui/BigScreenDesign/RightSetting/PosWhSetting.vue'
  185. import RotateSetting from 'data-room-ui/BigScreenDesign/RightSetting/RotateSetting.vue'
  186. export default {
  187. name: 'CustomComponentSetting',
  188. components: {
  189. ColorSelect,
  190. // ColorPicker,
  191. PaddingSetting,
  192. GradualSetting,
  193. PosWhSetting,
  194. BorderSetting,
  195. SettingTitle,
  196. RotateSetting
  197. },
  198. mixins: [chartSettingMixins],
  199. data () {
  200. return {
  201. groupList: []
  202. }
  203. },
  204. filters: {
  205. filterGroupName (val) {
  206. const settingGroup = {
  207. basic: '基础',
  208. position: '位置',
  209. graph: '图表',
  210. grid: '网格线',
  211. legend: '图例',
  212. xAxis: 'X轴',
  213. yAxis: 'Y轴',
  214. padding: '边距',
  215. appendPadding: '内边距',
  216. other: '其他'
  217. }
  218. return settingGroup[val]
  219. }
  220. },
  221. computed: {
  222. config: {
  223. get () {
  224. return this.$store.state.bigScreen.activeItemConfig
  225. },
  226. set (val) {
  227. this.$store.commit('bigScreen/changeActiveItemConfig', val)
  228. }
  229. },
  230. appCode: {
  231. get () {
  232. return this.$store.state.bigScreen.pageInfo.appCode
  233. }
  234. },
  235. pageCode () {
  236. return this.$route.query.code
  237. }
  238. },
  239. watch: {
  240. groupList: {
  241. // 1、原数组,2、修改后的数组只包含custom,3、合并的时候xy的配置必须放在最前面
  242. handler (val) {
  243. const setList = [].concat(...val.map(item => item.list))
  244. const newSetList = [...this.config.setting, ...setList]
  245. let newArr = [] // 存新数组
  246. const hash = {}
  247. newArr = newSetList.reduce(function (acc, cru, index) {
  248. if (!hash[cru.field]) {
  249. hash[cru.field] = { index: index }
  250. acc.push(cru)
  251. } else {
  252. acc.splice(hash[cru.field].index, 1, cru)
  253. }
  254. return acc
  255. }, [])
  256. this.$store.commit('bigScreen/changeActiveItemConfig', { ...this.config, setting: newArr })
  257. },
  258. deep: true
  259. }
  260. },
  261. mounted () {
  262. this.init()
  263. const groupNameList = []
  264. this.config.setting.filter(
  265. (item) => item.tabName === 'custom'
  266. ).forEach(item => {
  267. if (item.tabName === 'custom' && item.groupName) {
  268. if (!groupNameList.includes(item.groupName)) {
  269. groupNameList.push(item.groupName)
  270. this.groupList.push({
  271. groupName: item.groupName,
  272. list: [item]
  273. })
  274. } else {
  275. this.groupList.find(group => group.groupName === item.groupName).list.push(item)
  276. }
  277. } else {
  278. if (this.groupList.find(group => group.groupName === 'other')) {
  279. this.groupList.find(group => group.groupName === 'other').list.push(item)
  280. } else {
  281. this.groupList.push({
  282. groupName: 'other',
  283. list: [item]
  284. })
  285. }
  286. }
  287. })
  288. for (let i = 0; i < this.groupList.length; i++) {
  289. if (this.groupList[i].groupName === 'other') {
  290. const otherObject = this.groupList.splice(i, 1)[0]
  291. this.groupList.push(otherObject)
  292. break
  293. }
  294. }
  295. },
  296. methods: {
  297. init () {
  298. this.config = this.$store.state.bigScreen.activeItemConfig
  299. }
  300. }
  301. }
  302. </script>
  303. <style lang="scss" scoped>
  304. @import '../../assets/style/settingWrap.scss';
  305. @import '../../assets/style/bsTheme.scss';
  306. // 筛选条件的按钮样式
  307. .add-filter-box {
  308. position: relative;
  309. .add-filter {
  310. margin-left: 90px;
  311. margin-bottom: 10px;
  312. }
  313. .add-filter-btn {
  314. position: absolute;
  315. top: 0;
  316. }
  317. }
  318. .lc-field-body {
  319. padding:12px 16px;
  320. }
  321. .el-form-item{
  322. margin-bottom: 6px !important;
  323. }
  324. .lc-field-title {
  325. position: relative;
  326. padding-left: 12px;
  327. line-height: 30px;
  328. height: 30px;
  329. margin-bottom: 12px;
  330. &:after {
  331. position: absolute;
  332. left: 0;
  333. top: 50%;
  334. transform: translateY(-50%);
  335. content: '';
  336. width: 4px;
  337. height: 14px;
  338. background-color: var(--bs-el-color-primary);
  339. }
  340. }
  341. ::v-deep .el-color-picker__trigger {
  342. border-color: var(--bs-el-border);
  343. }
  344. .color-picker-box{
  345. ::v-deep .el-color-picker__trigger {
  346. width: 27px!important;
  347. }
  348. }
  349. </style>