IndexEditSelf.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <div>
  3. <el-drawer
  4. v-loading="loading"
  5. :show-close="false"
  6. :title="curObj.id ? '编辑资讯' : '新增资讯'"
  7. :wrapper-closable="false"
  8. :close-on-press-escape="false"
  9. :visible.sync="isShow"
  10. size="960px"
  11. custom-class="xl-drawer"
  12. direction="rtl"
  13. >
  14. <base-form ref="ruleForm" class="lib-edit" :data="formData" :is-inline="false" label-width="110px">
  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. <div class="scoped-textarea" slot="otherItem">
  20. <div class="st-text">房票科技</div>
  21. <tinymce v-model="content" :height="500" />
  22. </div>
  23. </base-form>
  24. </el-drawer>
  25. </div>
  26. </template>
  27. <script>
  28. import Tinymce from '@/components/Tinymce'
  29. export default {
  30. components: { Tinymce },
  31. mixins,
  32. props: {
  33. isShow: Boolean,
  34. curObj: Object
  35. },
  36. inject: ['parentData'],
  37. data() {
  38. return {
  39. formData: [],
  40. loading: true,
  41. cObj: {},
  42. content: '',
  43. }
  44. },
  45. watch: {
  46. isShow: function(val) {
  47. if (val) {
  48. if (val) {
  49. if (this.curObj.id) {
  50. this.$api.house.adminformationdetail({id: this.curObj.id}).then(res => {
  51. let curData = res || {}
  52. this.cObj = curData || {}
  53. this.getDef()
  54. })
  55. } else {
  56. this.cObj = this.curObj
  57. this.getDef()
  58. }
  59. }
  60. }
  61. },
  62. },
  63. methods: {
  64. getDef() {
  65. const params = { ...this.cObj }
  66. const disabled = false
  67. const remoteOptionsIds = []
  68. if (params.estate_list) {
  69. params.estate_id_list = params.estate_list.map(item => {
  70. remoteOptionsIds.push({ keyRO: item.estate_name, valRO: item.id })
  71. return item.id
  72. })
  73. } else {
  74. params.estate_id_list = []
  75. }
  76. // if (params.id) disabled = true
  77. this.formData = [
  78. { label: '标题', key: 'title' },
  79. { label: '分类', key: 'information_category', type: 'select', class: 'c-2', options: this.$dictData.information_category },
  80. { label: '作者', key: 'author', class: 'c-2' },
  81. { label: '状态', key: 'hide_status', type: 'select', class: 'c-2', options: this.$dictData.hide_status },
  82. { label: '主图', key: 'pri_image', type: 'upload', class: 'c-2' },
  83. { label: '关联楼盘', key: 'estate_id_list', type: 'selectRemote', multiple: true, changeHandle: this.deviceChange,
  84. remoteParams: { skey: 'estate_name', api: `house.admestatelist?search_EQ_status=1`, opKey: 'estate_name', opVal: 'id' },
  85. remoteOptions: remoteOptionsIds
  86. },
  87. ]
  88. this.setDefaultValue(params)
  89. },
  90. close(str) {
  91. if (str === 'confirm') {
  92. this.$refs['ruleForm'].$refs['baseForm'].validate((valid) => {
  93. if (valid) {
  94. const oldform = this.$refs.ruleForm.baseForm
  95. const newForm = { ...oldform }
  96. if (this.curObj.id) newForm.id = this.curObj.id
  97. if (newForm.estate_id_list && newForm.estate_id_list.length > 0) {
  98. newForm.estate_id_list = newForm.estate_id_list.join(',')
  99. } else {
  100. newForm.estate_id_list = ''
  101. }
  102. let apiStr = 'adminformationadd'
  103. if (newForm.id) apiStr = 'adminformationedit'
  104. if (this.content) {
  105. newForm.content = this.content
  106. } else {
  107. this.$msg('请输入资讯文章内容')
  108. return
  109. }
  110. this.$api.house[apiStr](newForm).then(data => {
  111. this.$msgs(newForm.id ? '编辑成功' : '新增成功')
  112. this.$emit('close', newForm)
  113. })
  114. }
  115. })
  116. } else {
  117. this.$emit('close')
  118. this.setDefaultValue()
  119. }
  120. }
  121. }
  122. }
  123. </script>
  124. <style lang="scss" scoped>
  125. @import '../../../../styles/libEdit.scss';
  126. @import '../../../../styles/libEdit.scss';
  127. .lib-edit {
  128. width: 900px;
  129. padding-top: 0;
  130. padding-left: 0;
  131. padding-bottom: 40px;
  132. ::v-deep .el-form-item {
  133. margin-bottom: 10px;
  134. }
  135. ::v-deep .el-date-editor.el-input {
  136. width: 100%;
  137. }
  138. }
  139. .scoped-textarea {
  140. width: 100%;
  141. position: relative;
  142. .st-text {
  143. position: absolute;
  144. bottom: 2px;
  145. right: 14px;
  146. background: #fff;
  147. font-size: 12px;
  148. z-index: 999999;
  149. height: 30px;
  150. line-height: 32px;
  151. padding-left: 10px;
  152. padding-right: 10px;
  153. color: #595959;
  154. user-select: none;
  155. }
  156. }
  157. </style>