G2CustomSetting.vue 10 KB

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