setting.vue 9.0 KB

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