DiscountEdit.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. export default {
  25. components: { },
  26. mixins,
  27. props: {
  28. isShow: Boolean,
  29. curObj: Object
  30. },
  31. inject: ['parentData'],
  32. data() {
  33. return {
  34. formData: [],
  35. loading: true,
  36. cObj: {},
  37. posTips: '',
  38. }
  39. },
  40. watch: {
  41. isShow: function(val) {
  42. if (val) {
  43. if (val) {
  44. if (this.curObj.id) {
  45. this.$api.house.admestatebargaindetail({id: this.curObj.id}).then(res => {
  46. let curData = res || {}
  47. curData.startEndTime = [curData.start_at, curData.end_at]
  48. this.cObj = curData || {}
  49. this.getDef()
  50. })
  51. } else {
  52. this.cObj = this.curObj
  53. this.getDef()
  54. }
  55. }
  56. }
  57. },
  58. },
  59. methods: {
  60. getDef(fieldStr) {
  61. let params = { ...this.cObj }
  62. this.formData = [
  63. { label: '关联楼盘', rules: 1, key: 'estate_id', type: 'selectRemote',
  64. remoteParams: { skey: 'estate_name', api: `house.admestatelist`, opKey: 'estate_name', opVal: 'id' },
  65. remoteOptions: [{ keyRO: params.estate_name, valRO: params.estate_id }]
  66. },
  67. { label: '特价图片', rules: 1, key: 'pri_image', type: 'uploads', class: 'c-2' },
  68. { label: '排序', key: 'sort', class: 'c-2' },
  69. { label: '特价时间', label2: '开始时间', label3: '结束时间', key: 'startEndTime', type: 'datePicker', rules: 1},
  70. { label: '备注', key: 'remark', type: 'textarea', rules: 1},
  71. ]
  72. this.setDefaultValue(params)
  73. },
  74. close(str) {
  75. if (str === 'confirm') {
  76. this.$refs['ruleForm'].$refs['baseForm'].validate((valid) => {
  77. if (valid) {
  78. const oldform = this.$refs.ruleForm.baseForm
  79. const newForm = { ...oldform }
  80. if (this.curObj.id) newForm.id = this.curObj.id
  81. let apiStr = 'admestatebargainadd'
  82. if (newForm.id) apiStr = 'admestatebargainedit'
  83. newForm.start_at = newForm.startEndTime[0]
  84. newForm.end_at = newForm.startEndTime[1]
  85. delete newForm.startEndTime
  86. this.$api.house[apiStr](newForm).then(data => {
  87. this.$msgs(newForm.id ? '编辑成功' : '新增成功')
  88. this.$emit('close', newForm)
  89. })
  90. }
  91. })
  92. } else {
  93. this.$emit('close')
  94. this.setDefaultValue()
  95. }
  96. },
  97. }
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. @import '../../../../styles/libEdit.scss';
  102. .lib-edit {
  103. padding-top: 0;
  104. ::v-deep .el-form-item {
  105. margin-bottom: 10px;
  106. }
  107. ::v-deep .el-date-editor.el-input {
  108. width: 100%;
  109. }
  110. }
  111. ::v-deep .img-upload {
  112. height: 180px;
  113. overflow: hidden;
  114. .icon {
  115. width: 160px;
  116. }
  117. .img {
  118. width: 160px;
  119. }
  120. }
  121. </style>