G2CustomSetting.vue 10 KB

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