G2CustomSetting.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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.label"
  41. label-width="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-drag-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-drag-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. height: 42px;
  75. flex-wrap: wrap;
  76. "
  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. />
  135. <el-switch
  136. v-else-if="setting.type === 'switchNumber'"
  137. v-model="setting.value"
  138. :active-value="1"
  139. :inactive-value="0"
  140. />
  141. <el-slider
  142. v-else-if="setting.type === 'slider'"
  143. v-model="setting.value"
  144. :min="0"
  145. :max="1"
  146. :step="0.01"
  147. />
  148. <PaddingSetting
  149. v-else-if="setting.type === 'padding'"
  150. v-model="setting.value"
  151. />
  152. </el-form-item>
  153. </div>
  154. </div>
  155. </div>
  156. </template>
  157. <!-- </div> -->
  158. </el-form>
  159. </div>
  160. </template>
  161. <script>
  162. import ElDragSelect from 'packages/BigScreenDesign/RightSetting/ElDragSelect.vue'
  163. import SettingTitle from 'packages/SettingTitle/index.vue'
  164. import { chartSettingMixins } from 'packages/js/mixins/chartSettingMixins'
  165. import ColorSelect from 'packages/ColorMultipleSelect/index.vue'
  166. // import ColorPicker from 'packages/ColorPicker/index.vue'
  167. import PaddingSetting from 'packages/BigScreenDesign/RightSetting/PaddingSetting/index.vue'
  168. import GradualSetting from 'packages/BigScreenDesign/RightSetting/GradualSetting/index.vue'
  169. import PosWhSetting from 'packages/BigScreenDesign/RightSetting/PosWhSetting.vue'
  170. import _ from 'lodash'
  171. export default {
  172. name: 'CustomComponentSetting',
  173. components: {
  174. ColorSelect,
  175. ElDragSelect,
  176. // ColorPicker,
  177. PaddingSetting,
  178. GradualSetting,
  179. PosWhSetting,
  180. SettingTitle
  181. },
  182. mixins: [chartSettingMixins],
  183. data () {
  184. return {
  185. groupList: []
  186. }
  187. },
  188. filters: {
  189. filterGroupName (val) {
  190. const settingGroup = {
  191. basic: '基础',
  192. position: '位置',
  193. graph: '图表',
  194. grid: '网格线',
  195. legend: '图例',
  196. xAxis: 'X轴',
  197. yAxis: 'Y轴',
  198. padding: '边距',
  199. other: '其他'
  200. }
  201. return settingGroup[val]
  202. }
  203. },
  204. computed: {
  205. config: {
  206. get () {
  207. return this.$store.state.bigScreen.activeItemConfig
  208. },
  209. set (val) {
  210. this.$store.commit('bigScreen/changeActiveItemConfig', val)
  211. }
  212. },
  213. appCode: {
  214. get () {
  215. return this.$store.state.bigScreen.pageInfo.appCode
  216. }
  217. },
  218. pageCode () {
  219. return this.$route.query.code
  220. }
  221. },
  222. watch: {
  223. groupList: {
  224. handler (val) {
  225. const setList = [].concat(...val.map(item => item.list))
  226. this.$store.commit('bigScreen/changeActiveItemConfig', { ...this.config, setting: [...this.config.setting, ...setList] })
  227. },
  228. deep: true
  229. }
  230. },
  231. mounted () {
  232. this.init()
  233. const groupNameList = []
  234. this.config.setting.filter(
  235. (item) => item.tabName === 'custom'
  236. ).forEach(item => {
  237. if (item.tabName === 'custom' && item.groupName) {
  238. if (!groupNameList.includes(item.groupName)) {
  239. groupNameList.push(item.groupName)
  240. this.groupList.push({
  241. groupName: item.groupName,
  242. list: [item]
  243. })
  244. } else {
  245. this.groupList.find(group => group.groupName === item.groupName).list.push(item)
  246. }
  247. } else {
  248. if (this.groupList.find(group => group.groupName === 'other')) {
  249. this.groupList.find(group => group.groupName === 'other').list.push(item)
  250. } else {
  251. this.groupList.push({
  252. groupName: 'other',
  253. list: [item]
  254. })
  255. }
  256. }
  257. })
  258. for (let i = 0; i < this.groupList.length; i++) {
  259. if (this.groupList[i].groupName === 'other') {
  260. const otherObject = this.groupList.splice(i, 1)[0]
  261. this.groupList.push(otherObject)
  262. break
  263. }
  264. }
  265. },
  266. methods: {
  267. init () {
  268. this.config = this.$store.state.bigScreen.activeItemConfig
  269. }
  270. }
  271. }
  272. </script>
  273. <style lang="scss" scoped>
  274. @import '../../assets/style/settingWrap.scss';
  275. // 筛选条件的按钮样式
  276. .add-filter-box {
  277. position: relative;
  278. .add-filter {
  279. margin-left: 90px;
  280. margin-bottom: 10px;
  281. }
  282. .add-filter-btn {
  283. position: absolute;
  284. top: 0;
  285. }
  286. }
  287. .lc-field-body {
  288. padding:12px 16px;
  289. }
  290. .el-form-item{
  291. margin-bottom: 6px !important;
  292. }
  293. .lc-field-title {
  294. position: relative;
  295. padding-left: 12px;
  296. line-height: 30px;
  297. height: 30px;
  298. margin-bottom: 12px;
  299. &:after {
  300. position: absolute;
  301. left: 0;
  302. top: 50%;
  303. transform: translateY(-50%);
  304. content: '';
  305. width: 4px;
  306. height: 14px;
  307. background-color: var(--bs-el-color-primary);
  308. }
  309. }
  310. ::v-deep .el-color-picker__trigger {
  311. border-color: var(--bs-el-border);
  312. }
  313. </style>