MapImgEdit.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <div>
  3. <el-dialog
  4. v-loading="loading"
  5. :show-close="false"
  6. :close-on-click-modal="false"
  7. :visible.sync="isShow"
  8. :title="'添加图案操作'"
  9. :fullscreen="false"
  10. width="400px"
  11. custom-class="xl-dialog"
  12. center
  13. >
  14. <base-form ref="ruleForm" :data="formData" :is-inline="false" label-width="70px">
  15. </base-form>
  16. <div class="scoped-img-quick">
  17. <div class="t">快速选择图标</div>
  18. <div :class="curImgUrl === item.url ? 'op cur' : 'op'" v-for="(item, i) in imgArr" @click="imgHandle(item)" :key="i">
  19. <img :src="item.url" alt="img" class="img">
  20. </div>
  21. </div>
  22. <div class="xl-form">
  23. <div class="xl-form-footer">
  24. <el-button class="xl-form-btn t2" @click="close">关 闭</el-button>
  25. <el-button v-if="curObj.obj" class="xl-form-btn t1" @click="close('confirm')">保存</el-button>
  26. <el-button v-else class="xl-form-btn t3" @click="close('confirm')">去画图</el-button>
  27. </div>
  28. </div>
  29. </el-dialog>
  30. </div>
  31. </template>
  32. <script>
  33. import { arrToObj } from '@/utils'
  34. export default {
  35. components: { },
  36. mixins,
  37. props: {
  38. isShow: Boolean,
  39. curObj: Object,
  40. },
  41. data() {
  42. return {
  43. loading: false,
  44. formData: [],
  45. curImgUrl: '',
  46. imgArr: [
  47. {url: 'https://img2.honglounews.com/20221205054341-4368.png'},
  48. {url: 'https://img2.honglounews.com/20221205054412-6635.png'},
  49. ],
  50. cObj: {},
  51. }
  52. },
  53. watch: {
  54. isShow: function(val) {
  55. if (val) {
  56. this.cObj = JSON.parse(JSON.stringify(this.curObj))
  57. this.getDef()
  58. }
  59. },
  60. },
  61. methods: {
  62. getDef (str) {
  63. let params = { ...this.curObj.obj }
  64. if (str === 'color') {
  65. const oldform = this.$refs.ruleForm.baseForm
  66. params = {...oldform}
  67. params.icon = this.curImgUrl
  68. }
  69. if (!params.text) params.text = '标题示例'
  70. if (!params.icon) params.icon = 'https://img2.honglounews.com/20221205054341-4368.png'
  71. this.formData = [
  72. { label: '站点', key: 'text', rules: 1},
  73. { label: '图标', key: 'icon', type: 'uploads', rules: 1 },
  74. ]
  75. this.setDefaultValue(params)
  76. },
  77. imgHandle (item) {
  78. this.curImgUrl = item.url
  79. this.getDef('color')
  80. },
  81. close (str) {
  82. if (str === 'confirm') {
  83. this.$refs['ruleForm'].$refs['baseForm'].validate((valid) => {
  84. if (valid) {
  85. const oldform = this.$refs.ruleForm.baseForm
  86. const newForm = { ...oldform }
  87. if (this.curObj.obj) {
  88. this.$emit('close', newForm, 'edit')
  89. } else {
  90. this.$emit('close', newForm)
  91. }
  92. this.setDefaultValue()
  93. }
  94. })
  95. } else {
  96. this.$emit('close')
  97. this.setDefaultValue()
  98. }
  99. },
  100. }
  101. }
  102. </script>
  103. <style lang="scss" scoped>
  104. @import '../../../../styles/libEdit.scss';
  105. .lib-edit {
  106. padding-top: 0;
  107. ::v-deep .el-date-editor.el-input {
  108. width: 100%;
  109. }
  110. ::v-deep .el-textarea__inner {
  111. height: 300px;
  112. }
  113. }
  114. .scoped-img-quick {
  115. margin-bottom: 20px;
  116. .t {
  117. color: #313131;
  118. }
  119. .op {
  120. display: inline-block;
  121. vertical-align: middle;
  122. width: 44px;
  123. height: 44px;
  124. color: #fff;
  125. cursor: pointer;
  126. text-align: center;
  127. margin-right: 10px;
  128. &.cur {
  129. border: 2px solid #19be6b;
  130. }
  131. .img {
  132. width: 40px;
  133. height: 40px;
  134. }
  135. }
  136. }
  137. </style>