G2CustomSetting.vue 9.8 KB

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