setting.vue 8.7 KB

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