setting.vue 8.9 KB

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