G2CustomSetting.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  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. show-alpha
  104. />
  105. <!-- 渐变色设置 -->
  106. <GradualSetting
  107. v-else-if="setting.type === 'gradual'"
  108. v-model="setting.value"
  109. />
  110. <el-input-number
  111. v-else-if="setting.type === 'inputNumber'"
  112. v-model="setting.value"
  113. class="bs-el-input-number"
  114. :step="setting.step || 1"
  115. :min="setting.min || 0"
  116. :max="setting.max || 100000"
  117. />
  118. <el-radio-group
  119. v-else-if="setting.type === 'radio'"
  120. v-model="setting.value"
  121. >
  122. <template v-for="(opt, optIndex) in setting.options">
  123. <el-radio-button
  124. :key="optIndex"
  125. :label="opt.value"
  126. >
  127. {{ opt.label }}
  128. </el-radio-button>
  129. </template>
  130. </el-radio-group>
  131. <el-switch
  132. v-else-if="setting.type === 'switch'"
  133. v-model="setting.value"
  134. :active-value="setting.active"
  135. :inactive-value="setting.inactive"
  136. />
  137. <!-- <el-switch-->
  138. <!-- v-else-if="setting.type === 'switchNumber'"-->
  139. <!-- v-model="setting.value"-->
  140. <!-- :active-value="1"-->
  141. <!-- :inactive-value="0"-->
  142. <!-- />-->
  143. <!-- <el-switch-->
  144. <!-- v-else-if="setting.type === 'switch,'"-->
  145. <!-- v-model="setting.value"-->
  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 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. 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. // 筛选条件的按钮样式
  294. .add-filter-box {
  295. position: relative;
  296. .add-filter {
  297. margin-left: 90px;
  298. margin-bottom: 10px;
  299. }
  300. .add-filter-btn {
  301. position: absolute;
  302. top: 0;
  303. }
  304. }
  305. .lc-field-body {
  306. padding:12px 16px;
  307. }
  308. .el-form-item{
  309. margin-bottom: 6px !important;
  310. }
  311. .lc-field-title {
  312. position: relative;
  313. padding-left: 12px;
  314. line-height: 30px;
  315. height: 30px;
  316. margin-bottom: 12px;
  317. &:after {
  318. position: absolute;
  319. left: 0;
  320. top: 50%;
  321. transform: translateY(-50%);
  322. content: '';
  323. width: 4px;
  324. height: 14px;
  325. background-color: var(--bs-el-color-primary);
  326. }
  327. }
  328. ::v-deep .el-color-picker__trigger {
  329. border-color: var(--bs-el-border);
  330. }
  331. .color-picker-box{
  332. ::v-deep .el-color-picker__trigger {
  333. width: 27px!important;
  334. }
  335. }
  336. </style>