setting.vue 9.1 KB

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