EditForm.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  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 Icon from 'data-room-ui/assets/images/dataSourceIcon/export'
  113. export default {
  114. name: 'EditForm',
  115. components: {
  116. },
  117. props: {
  118. },
  119. data () {
  120. return {
  121. resolutionRatioValue: '1920*1080',
  122. resolutionRatio: {
  123. w: 1920,
  124. h: 1080
  125. },
  126. resolutionRatioOptions: [
  127. {
  128. value: '1024*768',
  129. label: '1024*768'
  130. },
  131. {
  132. value: '1280*720',
  133. label: '1280*720'
  134. },
  135. {
  136. value: '1920*1080',
  137. label: '1920*1080'
  138. },
  139. {
  140. value: '2560*1440',
  141. label: '2560*1440'
  142. },
  143. {
  144. value: '3840*2160',
  145. label: '3840*2160'
  146. },
  147. {
  148. value: '5120*2880',
  149. label: '5120*2880'
  150. },
  151. {
  152. value: '7680*4320',
  153. label: '7680*4320'
  154. }
  155. ],
  156. formVisible: false,
  157. title: '', // 弹框标题(新增/编辑)
  158. dataForm: {
  159. id: '',
  160. type: 'bigScreen',
  161. name: '',
  162. icon: '',
  163. code: '',
  164. remark: '',
  165. iconColor: '#007aff',
  166. components: '',
  167. style: '',
  168. formType: '',
  169. formConfig: '',
  170. pageTemplateId: ''
  171. },
  172. dataFormRules: {
  173. name: [
  174. { required: true, message: '名称不能为空', trigger: 'blur' }
  175. ]
  176. },
  177. sureLoading: false,
  178. toDesignLoading: false,
  179. sureDisabled: false,
  180. toDesignDisabled: false
  181. }
  182. },
  183. computed: {},
  184. watch: {
  185. resolutionRatioValue (val) {
  186. if (val) {
  187. this.resolutionRatio.w = val.split('*')[0]
  188. this.resolutionRatio.h = val.split('*')[1]
  189. } else {
  190. this.resolutionRatio.w = 1920
  191. this.resolutionRatio.h = 1080
  192. }
  193. }
  194. },
  195. mounted () {},
  196. methods: {
  197. // 关闭弹窗时
  198. closeAddDialog () {
  199. this.formVisible = false
  200. this.$refs.dataForm.resetFields()
  201. },
  202. // 初始化
  203. init (nodeData, parentNode) {
  204. this.title = ''
  205. const code = nodeData ? nodeData.code : ''
  206. this.formVisible = true
  207. this.$nextTick(() => {
  208. if (code) {
  209. this.$dataRoomAxios.get(`/bigScreen/design/info/code/${code}`).then((resp) => {
  210. this.$set(this, 'title', resp.name)
  211. this.$set(this.dataForm, 'name', resp.name)
  212. this.$set(this.dataForm, 'chartList', resp.chartList)
  213. this.$set(this.dataForm, 'code', resp.code)
  214. this.$set(this.dataForm, 'icon', resp.icon)
  215. this.$set(this.dataForm, 'iconColor', resp.iconColor)
  216. this.$set(this.dataForm, 'id', resp.id)
  217. this.$set(this.dataForm, 'parentCode', resp.parentCode === '0' ? '' : resp.parentCode)
  218. this.$set(this.dataForm, 'remark', resp.remark)
  219. this.$set(this.dataForm, 'style', resp.style)
  220. this.$set(this.dataForm, 'type', resp.type)
  221. this.$set(this.dataForm, 'orderNum', nodeData.orderNum)
  222. this.$set(this.dataForm, 'pageTemplateId', resp?.pageTemplateId)
  223. this.$set(this.dataForm, 'pageConfig', resp?.pageConfig)
  224. if (this.dataForm.type === 'bigScreen') {
  225. const { w, h } = resp.pageConfig
  226. this.resolutionRatio.w = w
  227. this.resolutionRatio.h = h
  228. this.resolutionRatioValue = `${w}*${h}`
  229. }
  230. })
  231. } else {
  232. this.$set(this.dataForm, 'name', '')
  233. this.$set(this.dataForm, 'chartList', [])
  234. this.$set(this.dataForm, 'code', '')
  235. this.$set(this.dataForm, 'icon', Icon.getNameList()[0])
  236. this.$set(this.dataForm, 'iconColor', '#007aff')
  237. this.$set(this.dataForm, 'id', '')
  238. this.$set(this.dataForm, 'parentCode', parentNode.code)
  239. this.$set(this.dataForm, 'remark', '')
  240. this.$set(this.dataForm, 'style', '')
  241. this.$set(this.dataForm, 'type', this.dataForm.type)
  242. this.$set(this.dataForm, 'orderNum', 0)
  243. this.$set(this.dataForm, 'pageTemplateId', '')
  244. this.$set(this.dataForm, 'pageConfig', {
  245. w: '1920',
  246. h: '1080',
  247. bgColor: '#151a26',
  248. opacity: 100,
  249. customTheme: 'auto',
  250. bg: null,
  251. lightBgColor: '#f5f7fa',
  252. lightBg: null
  253. })
  254. if (this.dataForm.type === 'bigScreen') {
  255. this.resolutionRatio.w = '1920'
  256. this.resolutionRatio.h = '1080'
  257. }
  258. }
  259. })
  260. },
  261. // 点击确定时
  262. addOrUpdate (isToDesign = false) {
  263. this.addOrUpdateBigScreen(isToDesign)
  264. },
  265. // 大屏 新增/编辑
  266. async addOrUpdateBigScreen (isToDesign) {
  267. this.$refs.dataForm.validate(async (valid) => {
  268. if (!valid) {
  269. return
  270. }
  271. const addOrUpdateHandel = !this.dataForm.code
  272. ? (form) => this.$dataRoomAxios.post('/bigScreen/design/add', form)
  273. : (form) => this.$dataRoomAxios.post('/bigScreen/design/update', form)
  274. const form = {
  275. className: 'com.gccloud.dataroom.core.module.manage.dto.DataRoomPageDTO',
  276. chartList: this.dataForm.chartList,
  277. code: this.dataForm.code,
  278. icon: this.dataForm.icon,
  279. iconColor: this.dataForm.iconColor,
  280. id: this.dataForm.id,
  281. name: this.dataForm.name,
  282. parentCode: this.dataForm.parentCode,
  283. remark: this.dataForm.remark,
  284. style: this.dataForm.style,
  285. type: 'bigScreen',
  286. orderNum: this.dataForm.orderNum,
  287. pageConfig: this.dataForm.pageConfig,
  288. pageTemplateId: this.dataForm.pageTemplateId
  289. }
  290. if (isToDesign) {
  291. this.toDesignLoading = true
  292. this.sureDisabled = true
  293. } else {
  294. this.sureLoading = true
  295. this.toDesignDisabled = true
  296. }
  297. addOrUpdateHandel(form)
  298. .then((code) => {
  299. this.formVisible = false
  300. const message = this.dataForm.code ? '更新成功' : '新建成功'
  301. this.$message.success(message)
  302. this.$emit('refreshData', form, this.dataForm.id)
  303. if (isToDesign) {
  304. this.toDesignLoading = false
  305. this.sureDisabled = false
  306. form.code = code || this.dataForm.code
  307. this.toDesign({ ...form })
  308. } else {
  309. this.sureLoading = false
  310. this.toDesignDisabled = false
  311. }
  312. })
  313. .catch(() => {
  314. this.sureLoading = false
  315. this.toDesignLoading = false
  316. this.sureDisabled = false
  317. this.toDesignDisabled = false
  318. })
  319. })
  320. },
  321. // 跳转设计态
  322. toDesign (form) {
  323. const { href: bigScreenHref } = this.$router.resolve({
  324. path: window.BS_CONFIG?.routers?.designUrl || '/big-screen/design',
  325. query: {
  326. code: form.code
  327. }
  328. })
  329. window.open(bigScreenHref, '_self')
  330. }
  331. }
  332. }
  333. </script>
  334. <style lang="scss" scoped>
  335. @import '../assets/style/bsTheme.scss';
  336. .el-scrollbar {
  337. height: 300px;
  338. overflow-x: hidden;
  339. ::v-deep .el-scrollbar__view {
  340. overflow-x: hidden;
  341. }
  342. }
  343. .color-picker {
  344. display: flex;
  345. align-items: center;
  346. }
  347. .icon-svg {
  348. width: 25px;
  349. height: 25px;
  350. }
  351. .color-select {
  352. width: 350px;
  353. display: flex;
  354. margin-top: 5px;
  355. align-items: center;
  356. justify-content: space-between;
  357. div {
  358. width: 20px;
  359. height: 20px;
  360. cursor: pointer;
  361. position: relative;
  362. }
  363. ::v-deep .el-color-picker__trigger {
  364. top: 0;
  365. right: 0;
  366. width: 21px;
  367. height: 21px;
  368. padding: 0;
  369. }
  370. .el-icon-check {
  371. font-size: 20px;
  372. color: #ffffff;
  373. position: absolute;
  374. }
  375. }
  376. .icon-list {
  377. margin-top: 15px;
  378. padding: 5px;
  379. border-radius: 5px;
  380. border: 1px solid #e8e8e8;
  381. .el-button--mini {
  382. min-width: 37px;
  383. padding: 5px !important;
  384. border: 1px solid transparent !important;
  385. &:hover {
  386. background-color: rgba(217, 217, 217, 0.3);
  387. }
  388. }
  389. }
  390. .icon-uploader {
  391. width: 60px;
  392. height: 60px;
  393. border: 1px dashed #d9d9d9;
  394. border-radius: 6px;
  395. cursor: pointer;
  396. position: relative;
  397. overflow: hidden;
  398. }
  399. .icon-uploader-icon {
  400. font-size: 28px;
  401. color: #8c939d;
  402. width: 60px;
  403. height: 60px;
  404. line-height: 60px;
  405. text-align: center;
  406. }
  407. .icon {
  408. width: 60px;
  409. height: 60px;
  410. display: block;
  411. }
  412. .default-layout-box {
  413. display: flex;
  414. flex-wrap: wrap;
  415. .default-layout-item {
  416. cursor: pointer;
  417. margin: 9px;
  418. display: flex;
  419. flex-direction: column;
  420. align-items: center;
  421. .component-name {
  422. font-size: 12px;
  423. }
  424. .sampleImg {
  425. margin: 0 auto;
  426. width: 102px;
  427. height: 73px;
  428. display: block;
  429. }
  430. .img_dispaly {
  431. margin: 0 auto;
  432. text-align: center;
  433. width: 100px;
  434. height: 70px;
  435. line-height: 70px;
  436. background-color: #D7D7D7;
  437. color: #999;
  438. }
  439. .demonstration {
  440. text-align: center;
  441. }
  442. }
  443. .default-layout-item:hover {
  444. cursor: pointer;
  445. }
  446. ::v-deep .el-radio__label {
  447. display: none;
  448. }
  449. }
  450. /*滚动条样式*/
  451. ::v-deep ::-webkit-scrollbar {
  452. width: 6px;
  453. border-radius: 4px;
  454. height: 4px;
  455. }
  456. ::v-deep ::-webkit-scrollbar-thumb {
  457. background: #dddddd !important;
  458. border-radius: 10px;
  459. }
  460. .catalog-cascader {
  461. width: 100% !important;
  462. }
  463. </style>