TrendEdit.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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 ? '编辑楼盘数据' : '添加楼盘数据'"
  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: 'estate_id', type: 'selectRemote', changeHandle: this.estateChange,
  58. remoteParams: { skey: 'estate_name', api: `house.admestatelist`, opKey: 'estate_name', opVal: 'id' },
  59. remoteOptions: [{ keyRO: params.estate_name, valRO: params.estate_id }]
  60. },
  61. { label: '所属区域', rules: 1, key: 'area_type', type: 'select', options: this.$dictData.area_type},
  62. { label: `面积产品户型`, label2: `快捷选择工具`, key: `HT`, type: 'select', options: this.roomAreaList, changeHandle: this.htChange,},
  63. { label: '产品类型', rules: 1, key: 'product_type', type: 'select', options: this.$dictData.product_type, class: 'c-2'},
  64. { label: '户型面积', rules: 1, key: 'house_square', class: 'c-2', type: 'inputFont', appendFont: '㎡'},
  65. ]
  66. this.setDefaultValue(params)
  67. },
  68. estateChange (estate_id, op, cur) {
  69. if (estate_id) {
  70. this.$api.house.admestatehousearealist({estate_id}).then(res => {
  71. const list = res.list || []
  72. const htObj = arrToObj(this.$dictData.house_type)
  73. const ptObj = arrToObj(this.$dictData.product_type)
  74. list.map(item => {
  75. item.key = `${item.area}㎡-${ptObj[item.product_type]}-${htObj[item.house_type]}`
  76. item.key2 = `${htObj[item.house_type]}`
  77. item.val = item.id
  78. })
  79. this.roomAreaList = [...list]
  80. this.cObj.estate_id = estate_id
  81. this.cObj.area_type = cur.area_type
  82. this.cObj.HT = ''
  83. this.cObj.product_type = ''
  84. this.cObj.house_square = ''
  85. this.getDef('edit')
  86. })
  87. } else {
  88. this.cObj = {}
  89. this.getDef('edit')
  90. }
  91. },
  92. htChange (val) {
  93. this.roomAreaList.forEach(ra => {
  94. if (val === ra.id) {
  95. this.cObj.product_type = ra.product_type
  96. this.cObj.house_square = ra.area
  97. this.cObj.HT = val
  98. this.getDef('edit')
  99. }
  100. return
  101. })
  102. },
  103. close(str) {
  104. if (str === 'confirm') {
  105. this.$refs['ruleForm'].$refs['baseForm'].validate((valid) => {
  106. if (valid) {
  107. const oldform = this.$refs.ruleForm.baseForm
  108. const newForm = { ...oldform }
  109. if (this.curObj.id) newForm.id = this.curObj.id
  110. let apiStr = 'admestatehousedynamicadd'
  111. if (newForm.id) apiStr = 'admestatehousedynamicedit'
  112. this.$api.house[apiStr](newForm).then(data => {
  113. this.$msgs(newForm.id ? '编辑成功' : '新增成功')
  114. this.$emit('close', newForm)
  115. })
  116. }
  117. })
  118. } else {
  119. this.$emit('close')
  120. this.setDefaultValue()
  121. }
  122. },
  123. }
  124. }
  125. </script>
  126. <style lang="scss" scoped>
  127. @import '../../../../styles/libEdit.scss';
  128. .lib-edit {
  129. padding-top: 0;
  130. ::v-deep .el-form-item {
  131. margin-bottom: 10px;
  132. }
  133. ::v-deep .el-date-editor.el-input {
  134. width: 100%;
  135. }
  136. }
  137. ::v-deep .img-upload {
  138. height: 180px;
  139. overflow: hidden;
  140. .icon {
  141. width: 160px;
  142. }
  143. .img {
  144. width: 160px;
  145. }
  146. }
  147. </style>