G2CustomSetting.vue 10 KB

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