IndexEdit.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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="700px"
  11. custom-class="xl-dialog"
  12. center
  13. >
  14. <base-form ref="ruleForm" class="lib-edit" :data="formData" :is-inline="false" label-width="110px" :insertSlotArr="[3,5]">
  15. <div slot="OI3" class="scoped-img-area">
  16. <div class="sia-title">更多图片</div>
  17. <div class="sia-op" v-for="(imgsrc,index) in imagesArr" :key="index">
  18. <img class="img" :src="imgsrc + '_adm0'" alt="img" @click="openbigImg(imgsrc + '_adm0')">
  19. <span class="close" @click="imgDel(index)"></span>
  20. </div>
  21. <el-upload
  22. class="sia-img"
  23. :action="`${domainUrl}/adm/upload/cloud`"
  24. :data="{logic_type: 'estate', token}"
  25. name="upload"
  26. :show-file-list="false"
  27. :on-success="roomAreaUploadSuccess"
  28. :before-upload="roomAreaUploadBefore"
  29. >
  30. <i class="el-icon-plus icon" />
  31. </el-upload>
  32. </div>
  33. <div slot="OI5" class="scoped-other-form">
  34. <el-form-item label="点位坐标" class="scoped-item-two item">
  35. 纬度N<el-input v-model="cObj.latitude" disabled />
  36. 经度E<el-input v-model="cObj.longitude" disabled />
  37. <el-button type="primary" class="map-btn" size="small" @click="handleMap">点击从地图获取</el-button>
  38. </el-form-item>
  39. </div>
  40. <div slot="footer" style="padding-top: 20px;">
  41. <el-button class="xl-form-btn t2" @click="close">关 闭</el-button>
  42. <el-button class="xl-form-btn t1" @click="close('confirm')">确定</el-button>
  43. </div>
  44. </base-form>
  45. </el-dialog>
  46. <handle-map :is-show="isShowMap" @close="closeMap" />
  47. <popup-big-img :is-show="bigImgShow" :src="`${bigImgSrc}`" @close="closebigImg" />
  48. </div>
  49. </template>
  50. <script>
  51. import handleMap from '@/components/Common/Map'
  52. import bigImgPopup from '_m/bigImgPopup.js'
  53. export default {
  54. components: { handleMap },
  55. mixins: [...mixins, bigImgPopup],
  56. props: {
  57. isShow: Boolean,
  58. curObj: Object
  59. },
  60. inject: ['parentData'],
  61. data() {
  62. let domainUrl = process.env.VUE_APP_BASE_API
  63. const token = window.sessionStorage.getItem('fp_token')
  64. return {
  65. imagesArr: [],
  66. domainUrl,
  67. token,
  68. formData: [],
  69. loading: true,
  70. cObj: {},
  71. isShowMap: false
  72. }
  73. },
  74. watch: {
  75. isShow: function(val) {
  76. if (val) {
  77. this.imagesArr = []
  78. if (this.curObj.id) {
  79. this.$api.facility.admfacilitydetail({id: this.curObj.id}).then(res => {
  80. let curData = res || {}
  81. this.cObj = curData || {}
  82. if (curData.images && curData.images.length > 0) this.imagesArr = curData.images.split(',')
  83. this.getDef()
  84. })
  85. } else {
  86. this.cObj = this.curObj
  87. this.getDef()
  88. }
  89. }
  90. },
  91. },
  92. methods: {
  93. imgDel (index) {
  94. this.imagesArr.splice(index, 1)
  95. this.imagesArr = [...this.imagesArr]
  96. },
  97. roomAreaUploadSuccess(res, file) {
  98. const data = res.data || {}
  99. let urls = this.imagesArr || []
  100. urls.push(`${data.url}`)
  101. this.imagesArr = urls
  102. this.imagesArr = [...this.imagesArr]
  103. },
  104. roomAreaUploadBefore(file) {
  105. const isJPGPNG = file.type === 'image/jpeg' || file.type === 'image/png'
  106. const isLtM = file.size / 1024 / 1024 < 10
  107. if (!isJPGPNG) {
  108. this.$message.error('上传图片只能是 JPG PNG GIF 格式!')
  109. }
  110. if (!isLtM) {
  111. this.$message.error('上传图片大小不能超过 10M!')
  112. }
  113. return isJPGPNG && isLt2M
  114. },
  115. getDef (str) {
  116. let params = { ...this.cObj }
  117. this.formData = [
  118. { label: '名称', key: 'name', class: 'c-2', rules: 1 },
  119. { label: '排序', key: 'sort', class: 'c-2', rules: 1 },
  120. { label: '主图', key: 'pri_image', type: 'cuImg',
  121. options: {
  122. w: 375,
  123. h: 250,
  124. }, class: 'c-2', rules: 1 },
  125. { label: '航拍背景图', key: 'vr_image', class: 'c-2', type: 'cuImg',
  126. options: {
  127. w: 375,
  128. h: 250,
  129. }
  130. },
  131. { label: '当前航拍key', key: 'vr_key', class: 'c-2'},
  132. { label: '地址', key: 'address' },
  133. { label: '备注', key: 'remarked', type: 'textarea' },
  134. ]
  135. // params.pri_image = this.IMadd(params.pri_image)
  136. if (!params.sort) params.sort = 1
  137. this.setDefaultValue(params)
  138. },
  139. close(str) {
  140. if (str === 'confirm') {
  141. this.$refs['ruleForm'].$refs['baseForm'].validate((valid) => {
  142. if (valid) {
  143. const oldform = this.$refs.ruleForm.baseForm
  144. const newForm = { ...oldform }
  145. newForm.longitude = this.cObj.longitude
  146. newForm.latitude = this.cObj.latitude
  147. // newForm.pri_image = this.IMdel(newForm.pri_image)
  148. if (this.imagesArr && this.imagesArr.length > 0) {
  149. newForm.images = this.imagesArr.join(',')
  150. }
  151. if (!newForm.longitude) return this.$msgw('请选择经度!')
  152. else if (!newForm.latitude) return this.$msgw('请选择纬度!')
  153. let apiStr = 'admfacilityadd'
  154. if (this.curObj.id) {
  155. newForm.id = this.curObj.id
  156. apiStr = 'admfacilityedit'
  157. }
  158. this.$api.facility[apiStr](newForm).then(data => {
  159. this.$msgs(this.curObj.id ? '编辑成功' : '新增成功')
  160. this.$emit('close', newForm)
  161. })
  162. }
  163. })
  164. } else {
  165. this.$emit('close')
  166. this.setDefaultValue()
  167. }
  168. },
  169. handleMap() { // 定位
  170. this.isShowMap = true
  171. const pointObj = {
  172. latitude: this.cObj.latitude || '',
  173. longitude: this.cObj.longitude || '',
  174. address: this.cObj.address || ''
  175. }
  176. this.$root.$emit('handleMap', pointObj)
  177. },
  178. closeMap(obj) {
  179. if (obj) {
  180. const oldform = this.$refs.ruleForm.baseForm
  181. const newForm = { ...oldform, ...obj }
  182. this.cObj = newForm
  183. this.setDefaultValue(newForm)
  184. }
  185. this.isShowMap = false
  186. }
  187. }
  188. }
  189. </script>
  190. <style lang="scss" scoped>
  191. @import '../../../../styles/libEdit.scss';
  192. .lib-edit {
  193. padding-top: 0;
  194. ::v-deep .el-form-item {
  195. margin-bottom: 10px;
  196. }
  197. ::v-deep .el-date-editor.el-input {
  198. width: 100%;
  199. }
  200. }
  201. .scoped-other-form {
  202. .scoped-item-two {
  203. .el-input {
  204. display: inline-block;
  205. width: 115px;
  206. margin: 0 10px;
  207. ::v-deep input {
  208. text-align: center;
  209. }
  210. }
  211. }
  212. }
  213. .map-btn{
  214. height: 36px;
  215. }
  216. .scoped-img-area {
  217. padding-left: 40px;
  218. margin-bottom: 20px;
  219. .sia-title {
  220. font-size: 14px;
  221. padding-bottom: 10px;
  222. color: #666;
  223. font-weight: bold;
  224. }
  225. .sia-op {
  226. display: inline-block;
  227. vertical-align: middle;
  228. margin-right: 10px;
  229. margin-bottom: 10px;
  230. border: 1px solid #f2f2f2;
  231. width: 80px;
  232. height: 80px;
  233. position: relative;
  234. &:hover {
  235. .img-big {
  236. display: block;
  237. }
  238. }
  239. .img {
  240. width: 80px;
  241. height: 80px;
  242. }
  243. .close {
  244. position: absolute;
  245. width: 20px;
  246. height: 20px;
  247. top: -10px;
  248. right: -10px;
  249. background: url(../../../../assets/icon_g_close.png) no-repeat;
  250. background-size: 20px;
  251. cursor: pointer;
  252. }
  253. .img-big {
  254. position: absolute;
  255. bottom: 0;
  256. left: 0;
  257. width: 400px;
  258. height: auto;
  259. display: none;
  260. box-shadow: 10px 10px 10px #ccc;
  261. z-index: 99;
  262. }
  263. }
  264. .sia-img {
  265. display: inline-block;
  266. vertical-align: middle;
  267. width: 80px;
  268. height: 80px;
  269. overflow: hidden;
  270. border: 1px dashed #999;
  271. margin-bottom: 10px;
  272. .el-icon-plus {
  273. color: #999;
  274. padding: 30px;
  275. }
  276. }
  277. }
  278. </style>