setting.vue 9.0 KB

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