TrendUpdate.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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: '封顶价', rules: 1, 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'},
  62. ]
  63. this.setDefaultValue(params)
  64. },
  65. close(str) {
  66. if (str === 'confirm') {
  67. this.$refs['ruleForm'].$refs['baseForm'].validate((valid) => {
  68. if (valid) {
  69. const oldform = this.$refs.ruleForm.baseForm
  70. const newForm = { ...oldform }
  71. if (this.curObj.id) newForm.id = this.curObj.id
  72. let apiStr = 'admestatehousedynamicupdate'
  73. if (newForm.id) apiStr = 'admestatehousedynamicupdate'
  74. this.$api.house[apiStr](newForm).then(data => {
  75. this.$msgs(newForm.id ? '编辑成功' : '新增成功')
  76. this.$emit('close', newForm)
  77. })
  78. }
  79. })
  80. } else {
  81. this.$emit('close')
  82. this.setDefaultValue()
  83. }
  84. },
  85. }
  86. }
  87. </script>
  88. <style lang="scss" scoped>
  89. @import '../../../../styles/libEdit.scss';
  90. .lib-edit {
  91. padding-top: 0;
  92. ::v-deep .el-form-item {
  93. margin-bottom: 10px;
  94. }
  95. ::v-deep .el-date-editor.el-input {
  96. width: 100%;
  97. }
  98. }
  99. ::v-deep .img-upload {
  100. height: 180px;
  101. overflow: hidden;
  102. .icon {
  103. width: 160px;
  104. }
  105. .img {
  106. width: 160px;
  107. }
  108. }
  109. </style>