IndexEdit.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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="400px"
  11. custom-class="xl-dialog"
  12. center
  13. >
  14. <base-form ref="ruleForm" :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. }
  37. },
  38. watch: {
  39. isShow: function(val) {
  40. if (val) {
  41. this.getDef()
  42. }
  43. },
  44. },
  45. methods: {
  46. getDef() {
  47. let params = { ...this.curObj }
  48. this.formData = [
  49. { label: '活动楼盘', key: 'estate_id', rules: 1, type: 'selectRemote', changeHandle: this.estateChange,
  50. remoteParams: { skey: 'estate_name', api: `house.admestatelist`, opKey: 'estate_name', opVal: 'id' },
  51. remoteOptions: [
  52. { keyRO: params.estate_name, valRO: params.estate_id }
  53. ]
  54. },
  55. { label: '截止时间', key: 'end_at', rules: 1, type: 'datePicker', type2: 'date' },
  56. { label: '分类', key: 'activity_type', rules: 1, type: 'select', options: this.$dictData.activity_type},
  57. { label: '备注', key: 'remark', rules: 1, type: 'textarea'},
  58. ]
  59. this.setDefaultValue(params)
  60. },
  61. close(str) {
  62. if (str === 'confirm') {
  63. this.$refs['ruleForm'].$refs['baseForm'].validate((valid) => {
  64. if (valid) {
  65. const oldform = this.$refs.ruleForm.baseForm
  66. const newForm = { ...oldform }
  67. if (this.curObj.id) newForm.id = this.curObj.id
  68. let apiStr = 'admactivityadd'
  69. if (newForm.id) apiStr = 'admactivityedit'
  70. this.$api.other[apiStr](newForm).then(data => {
  71. this.$msgs(newForm.id ? '编辑成功' : '新增成功')
  72. this.$emit('close', newForm)
  73. })
  74. }
  75. })
  76. } else {
  77. this.$emit('close')
  78. this.setDefaultValue()
  79. }
  80. },
  81. }
  82. }
  83. </script>
  84. <style lang="scss" scoped>
  85. @import '../../../../styles/libEdit.scss';
  86. .lib-edit {
  87. padding-top: 0;
  88. ::v-deep .el-form-item {
  89. margin-bottom: 10px;
  90. }
  91. ::v-deep .el-date-editor.el-input {
  92. width: 100%;
  93. }
  94. }
  95. ::v-deep .img-upload {
  96. height: 40px;
  97. overflow: hidden;
  98. .el-upload {
  99. height: 35px;
  100. }
  101. .icon {
  102. width: 110px;
  103. height: 35px;
  104. line-height: 35px;
  105. font-size: 20px;
  106. }
  107. .img {
  108. width: 110px;
  109. height: 35px;
  110. }
  111. }
  112. </style>