EditForm.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. <template>
  2. <div>
  3. <el-dialog
  4. :close-on-click-modal="false"
  5. :title="title ? '编辑' : '新增'"
  6. :visible.sync="formVisible"
  7. :append-to-body="true"
  8. class="bs-dialog-wrap bs-el-dialog"
  9. @close="closeAddDialog"
  10. >
  11. <el-form
  12. ref="dataForm"
  13. :model="dataForm"
  14. :rules="dataFormRules"
  15. label-position="right"
  16. label-width="100px"
  17. class="bs-el-form"
  18. >
  19. <el-form-item
  20. label="名称"
  21. prop="name"
  22. >
  23. <el-input
  24. v-model="dataForm.name"
  25. autocomplete="off"
  26. placeholder="请输入名称"
  27. clearable
  28. maxlength="30"
  29. class="bs-el-input"
  30. />
  31. </el-form-item>
  32. <el-form-item
  33. label="推荐分辨率"
  34. >
  35. <el-select
  36. v-model="resolutionRatioValue"
  37. class="bs-el-select"
  38. popper-class="bs-el-select"
  39. placeholder="请选择分辨率"
  40. clearable
  41. >
  42. <el-option
  43. v-for="resolutionRatioItem in resolutionRatioOptions"
  44. :key="resolutionRatioItem.value"
  45. :label="resolutionRatioItem.label"
  46. :value="resolutionRatioItem.value"
  47. />
  48. </el-select>
  49. </el-form-item>
  50. <el-form-item
  51. label="大屏宽度"
  52. >
  53. <el-input-number
  54. v-model="resolutionRatio.w"
  55. :min="100"
  56. :max="8000"
  57. class="bs-el-input-number"
  58. />
  59. </el-form-item>
  60. <el-form-item
  61. label="大屏高度"
  62. >
  63. <el-input-number
  64. v-model="resolutionRatio.h"
  65. :min="100"
  66. :max="8000"
  67. class="bs-el-input-number"
  68. />
  69. </el-form-item>
  70. <el-form-item label="排序">
  71. <el-input-number
  72. v-model="dataForm.orderNum"
  73. :min="0"
  74. :max="30000"
  75. controls-position="right"
  76. class="bs-el-input-number"
  77. />
  78. </el-form-item>
  79. </el-form>
  80. <div
  81. slot="footer"
  82. class="dialog-footer"
  83. >
  84. <el-button
  85. class="bs-el-button-default"
  86. @click="closeAddDialog"
  87. >
  88. 取消
  89. </el-button>
  90. <el-button
  91. v-if="title"
  92. type="primary"
  93. :loading="toDesignLoading"
  94. :disabled="toDesignDisabled"
  95. @click="addOrUpdate(true)"
  96. >
  97. 设计
  98. </el-button>
  99. <el-button
  100. type="primary"
  101. :loading="sureLoading"
  102. :disabled="sureDisabled"
  103. @click="addOrUpdate(!title)"
  104. >
  105. 确定
  106. </el-button>
  107. </div>
  108. </el-dialog>
  109. </div>
  110. </template>
  111. <script>
  112. import { get, post } from 'packages/js/utils/http'
  113. import Icon from 'packages/assets/images/dataSourceIcon/export'
  114. export default {
  115. name: 'EditForm',
  116. components: {
  117. },
  118. props: {
  119. type: {
  120. type: String,
  121. default: ''
  122. }
  123. },
  124. data () {
  125. return {
  126. resolutionRatioValue: '',
  127. resolutionRatio: {},
  128. resolutionRatioOptions: [
  129. {
  130. value: '1024*768',
  131. label: '1024*768'
  132. },
  133. {
  134. value: '1280*720',
  135. label: '1280*720'
  136. },
  137. {
  138. value: '1920*1080',
  139. label: '1920*1080'
  140. },
  141. {
  142. value: '2560*1440',
  143. label: '2560*1440'
  144. },
  145. {
  146. value: '3840*2160',
  147. label: '3840*2160'
  148. },
  149. {
  150. value: '5120*2880',
  151. label: '5120*2880'
  152. },
  153. {
  154. value: '7680*4320',
  155. label: '7680*4320'
  156. }
  157. ],
  158. formVisible: false,
  159. title: '', // 弹框标题(新增/编辑)
  160. dataForm: {
  161. id: '',
  162. type: '',
  163. name: '',
  164. icon: '',
  165. code: '',
  166. remark: '',
  167. iconColor: '#007aff',
  168. components: '',
  169. style: '',
  170. formType: '',
  171. formConfig: '',
  172. pageTemplateId: ''
  173. },
  174. dataFormRules: {
  175. name: [
  176. { required: true, message: '名称不能为空', trigger: 'blur' }
  177. ]
  178. },
  179. sureLoading: false,
  180. toDesignLoading: false,
  181. sureDisabled: false,
  182. toDesignDisabled: false
  183. }
  184. },
  185. computed: {
  186. },
  187. watch: {
  188. resolutionRatioValue (val) {
  189. if (val) {
  190. this.resolutionRatio.w = val.split('*')[0]
  191. this.resolutionRatio.h = val.split('*')[1]
  192. } else {
  193. this.resolutionRatio.w = this.type === 'component' ? 1024 : 1920
  194. this.resolutionRatio.h = this.type === 'component' ? 768 : 1080
  195. }
  196. }
  197. },
  198. mounted () {
  199. this.initResolution()
  200. },
  201. methods: {
  202. initResolution () {
  203. this.resolutionRatioValue = this.type === 'component' ? '1024*768' : '1920*1080'
  204. if (this.type === 'component') {
  205. this.resolutionRatio = {
  206. w: 1024,
  207. h: 768
  208. }
  209. } else {
  210. this.resolutionRatio = {
  211. w: 1920,
  212. h: 1080
  213. }
  214. }
  215. },
  216. // 关闭弹窗时
  217. closeAddDialog () {
  218. this.formVisible = false
  219. this.$refs.dataForm.resetFields()
  220. },
  221. // 初始化
  222. init (nodeData, parentNode) {
  223. this.title = ''
  224. const code = nodeData ? nodeData.code : ''
  225. this.formVisible = true
  226. this.$nextTick(() => {
  227. if (code) {
  228. get(`/bigScreen/design/info/code/${code}`).then((resp) => {
  229. this.$set(this, 'title', resp.name)
  230. this.$set(this.dataForm, 'name', resp.name)
  231. this.$set(this.dataForm, 'chartList', resp.chartList)
  232. this.$set(this.dataForm, 'code', resp.code)
  233. this.$set(this.dataForm, 'icon', resp.icon)
  234. this.$set(this.dataForm, 'iconColor', resp.iconColor)
  235. this.$set(this.dataForm, 'id', resp.id)
  236. this.$set(this.dataForm, 'parentCode', resp.parentCode === '0' ? '' : resp.parentCode)
  237. this.$set(this.dataForm, 'remark', resp.remark)
  238. this.$set(this.dataForm, 'style', resp.style)
  239. this.$set(this.dataForm, 'type', resp.type)
  240. this.$set(this.dataForm, 'orderNum', nodeData.orderNum)
  241. this.$set(this.dataForm, 'pageTemplateId', resp?.pageTemplateId)
  242. this.$set(this.dataForm, 'pageConfig', resp?.pageConfig)
  243. const { w, h } = resp.pageConfig
  244. this.resolutionRatio.w = w
  245. this.resolutionRatio.h = h
  246. this.resolutionRatioValue = `${w}*${h}`
  247. })
  248. } else {
  249. this.$set(this.dataForm, 'name', '')
  250. this.$set(this.dataForm, 'chartList', [])
  251. this.$set(this.dataForm, 'code', '')
  252. this.$set(this.dataForm, 'icon', Icon.getNameList()[0])
  253. this.$set(this.dataForm, 'iconColor', '#007aff')
  254. this.$set(this.dataForm, 'id', '')
  255. this.$set(this.dataForm, 'parentCode', parentNode.code)
  256. this.$set(this.dataForm, 'remark', '')
  257. this.$set(this.dataForm, 'style', '')
  258. this.$set(this.dataForm, 'type', this.type)
  259. this.$set(this.dataForm, 'orderNum', 0)
  260. this.$set(this.dataForm, 'pageTemplateId', '')
  261. this.$set(this.dataForm, 'pageConfig', {
  262. w: this.type === 'component' ? 1024 : 1920,
  263. h: this.type === 'component' ? 768 : 1080,
  264. bgColor: '#151a26',
  265. opacity: 100,
  266. customTheme: 'auto',
  267. bg: null,
  268. fitMode: 'auto'
  269. })
  270. this.resolutionRatio.w = this.type === 'component' ? 1024 : 1920
  271. this.resolutionRatio.h = this.type === 'component' ? 768 : 1080
  272. }
  273. })
  274. },
  275. // 点击确定时
  276. addOrUpdate (isToDesign = false) {
  277. this.addOrUpdateBigScreen(isToDesign)
  278. },
  279. // 大屏 新增/编辑
  280. async addOrUpdateBigScreen (isToDesign) {
  281. this.$refs.dataForm.validate(async (valid) => {
  282. if (!valid) {
  283. return
  284. }
  285. const addOrUpdateHandel = !this.dataForm.code
  286. ? (form) => post('/bigScreen/design/add', form)
  287. : (form) => post('/bigScreen/design/update', form)
  288. const form = {
  289. className: 'com.gccloud.dataroom.core.module.manage.dto.DataRoomPageDTO',
  290. chartList: this.dataForm.chartList,
  291. code: this.dataForm.code,
  292. icon: this.dataForm.icon,
  293. iconColor: this.dataForm.iconColor,
  294. id: this.dataForm.id,
  295. name: this.dataForm.name,
  296. parentCode: this.dataForm.parentCode,
  297. remark: this.dataForm.remark,
  298. style: this.dataForm.style,
  299. orderNum: this.dataForm.orderNum,
  300. pageConfig: { ...this.dataForm.pageConfig, w: this.resolutionRatio.w, h: this.resolutionRatio.h },
  301. pageTemplateId: this.dataForm.pageTemplateId,
  302. type: this.type || 'bigScreen'
  303. }
  304. if (isToDesign) {
  305. this.toDesignLoading = true
  306. this.sureDisabled = true
  307. } else {
  308. this.sureLoading = true
  309. this.toDesignDisabled = true
  310. }
  311. addOrUpdateHandel(form)
  312. .then((code) => {
  313. this.formVisible = false
  314. const message = this.dataForm.code ? '更新成功' : '新建成功'
  315. this.$message.success(message)
  316. this.$emit('refreshData', form, this.dataForm.id)
  317. if (isToDesign) {
  318. this.toDesignLoading = false
  319. this.sureDisabled = false
  320. form.code = code || this.dataForm.code
  321. this.toDesign({ ...form })
  322. } else {
  323. this.sureLoading = false
  324. this.toDesignDisabled = false
  325. }
  326. })
  327. .catch(() => {
  328. this.sureLoading = false
  329. this.toDesignLoading = false
  330. this.sureDisabled = false
  331. this.toDesignDisabled = false
  332. })
  333. })
  334. },
  335. // 跳转设计态
  336. toDesign (form) {
  337. const { href: bigScreenHref } = this.$router.resolve({
  338. path: window.BS_CONFIG?.routers?.designUrl || '/big-screen/design',
  339. query: {
  340. code: form.code
  341. }
  342. })
  343. window.open(bigScreenHref, '_self')
  344. }
  345. }
  346. }
  347. </script>
  348. <style lang="scss" scoped>
  349. @import '~packages/assets/style/bsTheme.scss';
  350. .el-scrollbar {
  351. height: 300px;
  352. overflow-x: hidden;
  353. /deep/ .el-scrollbar__view {
  354. overflow-x: hidden;
  355. }
  356. }
  357. .color-picker {
  358. display: flex;
  359. align-items: center;
  360. }
  361. .icon-svg {
  362. width: 25px;
  363. height: 25px;
  364. }
  365. .color-select {
  366. width: 350px;
  367. display: flex;
  368. margin-top: 5px;
  369. align-items: center;
  370. justify-content: space-between;
  371. div {
  372. width: 20px;
  373. height: 20px;
  374. cursor: pointer;
  375. position: relative;
  376. }
  377. ::v-deep .el-color-picker__trigger {
  378. top: 0;
  379. right: 0;
  380. width: 21px;
  381. height: 21px;
  382. padding: 0;
  383. }
  384. .el-icon-check {
  385. font-size: 20px;
  386. color: #ffffff;
  387. position: absolute;
  388. }
  389. }
  390. .icon-list {
  391. margin-top: 15px;
  392. padding: 5px;
  393. border-radius: 5px;
  394. border: 1px solid #e8e8e8;
  395. .el-button--mini {
  396. min-width: 37px;
  397. padding: 5px !important;
  398. border: 1px solid transparent !important;
  399. &:hover {
  400. background-color: rgba(217, 217, 217, 0.3);
  401. }
  402. }
  403. }
  404. .icon-uploader {
  405. width: 60px;
  406. height: 60px;
  407. border: 1px dashed #d9d9d9;
  408. border-radius: 6px;
  409. cursor: pointer;
  410. position: relative;
  411. overflow: hidden;
  412. }
  413. .icon-uploader-icon {
  414. font-size: 28px;
  415. color: #8c939d;
  416. width: 60px;
  417. height: 60px;
  418. line-height: 60px;
  419. text-align: center;
  420. }
  421. .icon {
  422. width: 60px;
  423. height: 60px;
  424. display: block;
  425. }
  426. .default-layout-box {
  427. display: flex;
  428. flex-wrap: wrap;
  429. .default-layout-item {
  430. cursor: pointer;
  431. margin: 9px;
  432. display: flex;
  433. flex-direction: column;
  434. align-items: center;
  435. .component-name {
  436. font-size: 12px;
  437. }
  438. .sampleImg {
  439. margin: 0 auto;
  440. width: 102px;
  441. height: 73px;
  442. display: block;
  443. }
  444. .img_dispaly {
  445. margin: 0 auto;
  446. text-align: center;
  447. width: 100px;
  448. height: 70px;
  449. line-height: 70px;
  450. background-color: #D7D7D7;
  451. color: #999;
  452. }
  453. .demonstration {
  454. text-align: center;
  455. }
  456. }
  457. .default-layout-item:hover {
  458. cursor: pointer;
  459. }
  460. /deep/.el-radio__label {
  461. display: none;
  462. }
  463. }
  464. /*滚动条样式*/
  465. /deep/::-webkit-scrollbar {
  466. width: 6px;
  467. border-radius: 4px;
  468. height: 4px;
  469. }
  470. /deep/::-webkit-scrollbar-thumb {
  471. background: #dddddd !important;
  472. border-radius: 10px;
  473. }
  474. .catalog-cascader {
  475. width: 100% !important;
  476. }
  477. </style>