TrendUpdate.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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="curObj.id ? `更新${curObj.estate_name}数据` : 'un'"
  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="100px">
  15. <div slot="footer" style="padding-top: 20px;">
  16. <el-button class="xl-form-btn t2" @click="close">关 闭</el-button>
  17. <el-button class="xl-form-btn t1" @click="close('confirm')">确定</el-button>
  18. </div>
  19. </base-form>
  20. </el-dialog>
  21. </div>
  22. </template>
  23. <script>
  24. import { arrToObj } from '@/utils'
  25. export default {
  26. components: { },
  27. mixins,
  28. props: {
  29. isShow: Boolean,
  30. curObj: Object
  31. },
  32. inject: ['parentData'],
  33. data() {
  34. return {
  35. formData: [],
  36. loading: true,
  37. cObj: {},
  38. roomAreaList: [],
  39. }
  40. },
  41. watch: {
  42. isShow: function(val) {
  43. if (val) {
  44. if (this.curObj.id) {
  45. this.cObj = JSON.parse(JSON.stringify(this.curObj))
  46. } else {
  47. this.cObj = {}
  48. }
  49. this.getDef()
  50. }
  51. },
  52. },
  53. methods: {
  54. getDef(fieldStr) {
  55. let params = { ...this.cObj }
  56. this.formData = [
  57. { label: '起价', rules: 1, key: 'price_min', type: 'inputFont', appendFont: '元', class: 'c-2'},
  58. { label: '封顶价', key: 'price_max', type: 'inputFont', appendFont: '元', class: 'c-2'},
  59. { label: '现场折扣', key: 'scene_discount'},
  60. { label: '实际折扣', key: 'actual_discount'},
  61. { label: '最新动态', key: 'dynamic', type: 'textarea', class: 'c-2'},
  62. { label: '动态图片', key: 'dynamic_img', type: 'uploads', class: 'c-2'},
  63. { label: '在售楼栋', key: 'on_sale'},
  64. { label: '待售楼栋', key: 'for_sale'},
  65. { label: '推荐房源', key: 'recommend'},
  66. ]
  67. this.setDefaultValue(params)
  68. },
  69. close(str) {
  70. if (str === 'confirm') {
  71. this.$refs['ruleForm'].$refs['baseForm'].validate((valid) => {
  72. if (valid) {
  73. const oldform = this.$refs.ruleForm.baseForm
  74. const newForm = { ...oldform }
  75. if (this.curObj.id) newForm.id = this.curObj.id
  76. let apiStr = 'admestatehousedynamicupdate'
  77. if (newForm.id) apiStr = 'admestatehousedynamicupdate'
  78. this.$api.house[apiStr](newForm).then(data => {
  79. this.$msgs(newForm.id ? '编辑成功' : '新增成功')
  80. this.$emit('close', newForm)
  81. })
  82. }
  83. })
  84. } else {
  85. this.$emit('close')
  86. this.setDefaultValue()
  87. }
  88. },
  89. }
  90. }
  91. </script>
  92. <style lang="scss" scoped>
  93. @import '../../../../styles/libEdit.scss';
  94. .lib-edit {
  95. padding-top: 0;
  96. ::v-deep .el-form-item {
  97. margin-bottom: 10px;
  98. }
  99. ::v-deep .el-date-editor.el-input {
  100. width: 100%;
  101. }
  102. }
  103. ::v-deep .img-upload {
  104. height: 180px;
  105. overflow: hidden;
  106. .icon {
  107. width: 160px;
  108. }
  109. .img {
  110. width: 160px;
  111. }
  112. }
  113. </style>