setting.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <div>
  3. <el-form
  4. ref="form"
  5. :model="config"
  6. label-width="120px"
  7. label-position="left"
  8. class="setting-body bs-el-form"
  9. >
  10. <SettingTitle>基础</SettingTitle>
  11. <el-form-item
  12. class="lc-field-body"
  13. label="名称"
  14. >
  15. <el-input
  16. v-model="config.title"
  17. clearable
  18. />
  19. </el-form-item>
  20. <SettingTitle>位置</SettingTitle>
  21. <div class="lc-field-body">
  22. <PosWhSetting
  23. :config="config"
  24. label-width="120px"
  25. />
  26. </div>
  27. <SettingTitle>基础</SettingTitle>
  28. <el-form-item
  29. class="lc-field-body"
  30. label="标题位置"
  31. label-width="100px"
  32. >
  33. <el-select
  34. v-model="config.customize.position"
  35. placeholder="请选择标题位置"
  36. popper-class="bs-el-select"
  37. class="bs-el-select"
  38. clearable
  39. >
  40. <el-option
  41. v-for="item in positionList"
  42. :key="item.value"
  43. :label="item.label"
  44. :value="item.value"
  45. />
  46. </el-select>
  47. </el-form-item>
  48. <el-form-item
  49. class="lc-field-body"
  50. label="字体大小"
  51. label-width="100px"
  52. >
  53. <el-input-number
  54. v-model="config.customize.fontSize"
  55. class="bs-el-input-number"
  56. placeholder="请输入字体大小"
  57. :min="0"
  58. />
  59. </el-form-item>
  60. <el-form-item
  61. class="lc-field-body"
  62. label="字体权重"
  63. label-width="100px"
  64. >
  65. <el-input-number
  66. v-model="config.customize.fontWeight"
  67. class="bs-el-input-number"
  68. placeholder="请输入字体权重"
  69. />
  70. </el-form-item>
  71. <el-form-item
  72. class="lc-field-body"
  73. label="字体颜色"
  74. label-width="100px"
  75. >
  76. <el-color-picker
  77. v-model="config.customize.color"
  78. class="bs-el-color-picker"
  79. popper-class="bs-el-color-picker"
  80. />
  81. </el-form-item>
  82. <el-form-item
  83. class="lc-field-body"
  84. label="分割线颜色"
  85. label-width="100px"
  86. >
  87. <el-color-picker
  88. v-model="config.customize.lineColor"
  89. class="bs-el-color-picker"
  90. popper-class="bs-el-color-picker"
  91. />
  92. </el-form-item>
  93. <SettingTitle>内容</SettingTitle>
  94. <div class="lc-field-body">
  95. <div class="select-item select-item-title">
  96. <span class="option-drag" />
  97. <span class="input-wrap_left">标签页名称</span>
  98. <span class="input-wrap_left">图表类型</span>
  99. </div>
  100. <draggable
  101. :list="config.customize.tabList"
  102. :animation="340"
  103. group="selectItem"
  104. handle=".option-drag"
  105. style="padding: 10px"
  106. >
  107. <template>
  108. <div
  109. v-for="(tab, index) in config.customize.tabList"
  110. :key="index"
  111. class="select-item"
  112. >
  113. <div class="select-line-icon option-drag">
  114. <i class="el-icon-rank" />
  115. </div>
  116. <div class="input-wrap">
  117. <el-form-item
  118. :prop="'customize.tabList.' + index + '.name'"
  119. :rules="rules.name"
  120. label-width="0px"
  121. >
  122. <el-input
  123. v-model="tab.name"
  124. placeholder="请输入标签页标题"
  125. size="mini"
  126. />
  127. </el-form-item>
  128. </div>
  129. <div class="input-wrap">
  130. <el-form-item
  131. :prop="'customize.tabList.' + index + '.chart'"
  132. :rules="rules.chart"
  133. label-width="0px"
  134. >
  135. <el-select
  136. v-model="tab.chart.title"
  137. size="mini"
  138. popper-class="bs-el-select"
  139. class="bs-el-select"
  140. @change="handleChangeBindCompnents(...arguments, index)"
  141. >
  142. <el-option
  143. v-for="item in componentList"
  144. :key="item.title"
  145. :label="item.title"
  146. :value="item.title"
  147. />
  148. </el-select>
  149. </el-form-item>
  150. </div>
  151. <div
  152. class="select-line-icon option-add"
  153. @click="addTab(index)"
  154. >
  155. <i class="el-icon-circle-plus-outline" />
  156. </div>
  157. <div
  158. class="select-line-icon option-delete"
  159. @click="deleteTab(index)"
  160. >
  161. <i class="el-icon-remove-outline" />
  162. </div>
  163. </div>
  164. </template>
  165. </draggable>
  166. <el-button
  167. type="primary"
  168. @click="addTab"
  169. >
  170. 新增标签页
  171. </el-button>
  172. </div>
  173. </el-form>
  174. </div>
  175. </template>
  176. <script>
  177. import draggable from 'vuedraggable'
  178. import SettingTitle from 'data-room-ui/SettingTitle/index.vue'
  179. import { chartSettingMixins } from 'data-room-ui/js/mixins/chartSettingMixins'
  180. import PosWhSetting from 'data-room-ui/BigScreenDesign/RightSetting/PosWhSetting.vue'
  181. import CloneDeep from 'lodash-es/cloneDeep'
  182. import plotList from 'data-room-ui/G2Plots/plotList'
  183. import { randomString } from 'data-room-ui/js/utils'
  184. import { settingToTheme } from 'data-room-ui/js/utils/themeFormatting'
  185. export default {
  186. components: {
  187. PosWhSetting,
  188. SettingTitle,
  189. draggable
  190. },
  191. mixins: [chartSettingMixins],
  192. data () {
  193. const validateChart = (rule, value, callback) => {
  194. if (!value) {
  195. return callback(new Error('请选择图表'))
  196. }
  197. callback()
  198. }
  199. return {
  200. positionList: [{
  201. label: '靠左',
  202. value: 'left'
  203. },
  204. {
  205. label: '居中',
  206. value: 'center'
  207. },
  208. {
  209. label: '靠右',
  210. value: 'right'
  211. }],
  212. rules: {
  213. name: [
  214. {
  215. required: true,
  216. message: '请输入标签页标题',
  217. trigger: 'blur'
  218. }
  219. ],
  220. chart: [
  221. { required: true, trigger: 'change', validator: validateChart }
  222. ]
  223. }
  224. }
  225. },
  226. computed: {
  227. config: {
  228. get () {
  229. return this.$store.state.bigScreen.activeItemConfig
  230. },
  231. set (val) {
  232. this.$store.state.bigScreen.activeItemConfig = val
  233. }
  234. },
  235. pageCode () {
  236. return this.$route.query.code
  237. },
  238. componentList () {
  239. return [...plotList]
  240. }
  241. },
  242. watch: {},
  243. mounted () { },
  244. methods: {
  245. deleteTab (index) {
  246. this.config.customize.tabList.splice(index, 1)
  247. },
  248. addTab () {
  249. const newTab = {
  250. code: '',
  251. chartCode: new Date().getTime() + '',
  252. name: '',
  253. chart: { parentCode: this.config.code }
  254. }
  255. this.config.customize.tabList.push(newTab)
  256. },
  257. handleChangeBindCompnents (configName, index) {
  258. const config = this.componentList.find(
  259. item => item.title === configName
  260. )
  261. config.code = randomString(12)
  262. this.$set(this.config.customize.tabList[index], 'name', configName)
  263. this.$set(this.config.customize.tabList[index], 'chart', { ...config, parentCode: this.config.code })
  264. this.$set(this.config.customize.tabList[index], 'chartCode', config.code)
  265. this.$set(this.config.customize.tabList[index].chart, 'key', config.code)
  266. this.$set(this.config.customize.tabList[index].chart, 'theme', settingToTheme(config, 'dark'))
  267. this.$set(this.config.customize.tabList[index].chart, 'theme', settingToTheme(config, 'light'))
  268. }
  269. }
  270. }
  271. </script>
  272. <style lang="scss" scoped>
  273. @import "../../assets/style/settingWrap.scss";
  274. .lc-field-body {
  275. padding: 12px 16px;
  276. }
  277. .select-item {
  278. display: flex;
  279. margin-bottom: 8px;
  280. .option-drag {
  281. cursor: move !important;
  282. width: 30px;
  283. font-size: 24px;
  284. }
  285. .input-wrap {
  286. flex: 1;
  287. display: flex;
  288. align-items: center;
  289. justify-content: center;
  290. margin-right: 2px;
  291. .el-input-number--mini {
  292. width: 90px !important;
  293. }
  294. }
  295. .input-wrap_left {
  296. flex: 1;
  297. display: flex;
  298. align-items: center;
  299. justify-content: left;
  300. }
  301. .select-line-icon {
  302. width: 30px;
  303. font-size: 18px;
  304. cursor: pointer;
  305. text-align: center;
  306. }
  307. .option-delete {
  308. color: #f56c6c;
  309. }
  310. }
  311. </style>