IndexEdit.vue 5.2 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="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. </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. isShowMap: false
  38. }
  39. },
  40. watch: {
  41. isShow: function(val) {
  42. if (val) {
  43. if (val) {
  44. if (this.curObj.id) {
  45. this.$api.house.adminformationdetail({id: this.curObj.id}).then(res => {
  46. let curData = res || {}
  47. this.cObj = curData || {}
  48. this.getDef()
  49. })
  50. } else {
  51. this.cObj = this.curObj
  52. this.getDef()
  53. }
  54. }
  55. }
  56. },
  57. },
  58. methods: {
  59. getDef() {
  60. const params = { ...this.cObj }
  61. const disabled = false
  62. const remoteOptionsIds = []
  63. if (params.estate_list) {
  64. params.estate_id_list = params.estate_list.map(item => {
  65. remoteOptionsIds.push({ keyRO: item.estate_name, valRO: item.id })
  66. return item.id
  67. })
  68. } else {
  69. params.estate_id_list = []
  70. }
  71. // if (params.id) disabled = true
  72. this.formData = [
  73. { label: '标题', key: 'title' },
  74. { label: '链接', key: 'link' },
  75. { label: '分类', key: 'information_category', type: 'select', class: 'c-2', options: this.$dictData.information_category, changeHandle: this.cateChange },
  76. { label: '作者', key: 'author', class: 'c-2' },
  77. { label: '状态', key: 'hide_status', type: 'select', class: 'c-2', options: this.$dictData.hide_status },
  78. { label: '发布时间', key: 'create_at', class: 'c-2', type: 'datePicker', type2: 'date'},
  79. { label: '主图', key: 'pri_image', type: 'upload', class: 'c-2' },
  80. { label: '关联楼盘', key: 'estate_id_list', type: 'selectRemote', multiple: true, changeHandle: this.deviceChange,
  81. remoteParams: { skey: 'estate_name', api: `house.admestatelist?search_EQ_status=1`, opKey: 'estate_name', opVal: 'id' },
  82. remoteOptions: remoteOptionsIds
  83. },
  84. { label: '关联区域', key: 'area_type', type: 'select', multiple: true, options: this.$dictData.area_type },
  85. ]
  86. this.setDefaultValue(params)
  87. },
  88. cateChange (val) {
  89. let params = {...this.$refs.ruleForm.baseForm}
  90. let imgURL= ''
  91. if (val === 'hlzt') imgURL= 'http://icon.honglounews.com/news_hlzt.jpg'
  92. if (val === 'hljy' || val === 'xqsc') imgURL= 'http://icon.honglounews.com/news_hljy.jpg'
  93. if (val === 'bkfx') imgURL= 'http://icon.honglounews.com/news_bkfx.jpg'
  94. if (val === 'lppc') imgURL= 'http://icon.honglounews.com/news_lppc.jpg'
  95. if (val === 'lpwd') imgURL= 'http://icon.honglounews.com/news_lpwd.jpg'
  96. if (val === 'hlpd') imgURL= 'http://icon.honglounews.com/news_hlpd.jpg'
  97. if (val === 'lszt') imgURL= 'http://icon.honglounews.com/news_lszt.jpg'
  98. if (val === 'zcjd') imgURL= 'http://icon.honglounews.com/news_zcjd.jpg'
  99. if (val === 'esf') imgURL= 'http://icon.honglounews.com/news_esf.jpg'
  100. if (val === 'lsdt') imgURL= 'http://icon.honglounews.com/news_lsdt.jpg'
  101. params.pri_image = imgURL
  102. this.setDefaultValue(params)
  103. },
  104. close(str) {
  105. if (str === 'confirm') {
  106. this.$refs['ruleForm'].$refs['baseForm'].validate((valid) => {
  107. if (valid) {
  108. const oldform = this.$refs.ruleForm.baseForm
  109. const newForm = { ...oldform }
  110. if (this.curObj.id) newForm.id = this.curObj.id
  111. if (newForm.estate_id_list && newForm.estate_id_list.length > 0) {
  112. newForm.estate_id_list = newForm.estate_id_list.join(',')
  113. } else {
  114. newForm.estate_id_list = ''
  115. }
  116. if (newForm.area_type) newForm.area_type = newForm.area_type.join(',')
  117. let apiStr = 'adminformationadd'
  118. newForm.news_type = 'gzh'
  119. if (!newForm.create_at) delete newForm.create_at
  120. if (newForm.id) apiStr = 'adminformationedit'
  121. this.$api.house[apiStr](newForm).then(data => {
  122. this.$msgs(newForm.id ? '编辑成功' : '新增成功')
  123. this.$emit('close', newForm)
  124. })
  125. }
  126. })
  127. } else {
  128. this.$emit('close')
  129. this.setDefaultValue()
  130. }
  131. }
  132. }
  133. }
  134. </script>
  135. <style lang="scss" scoped>
  136. @import '../../../../styles/libEdit.scss';
  137. .lib-edit {
  138. padding-top: 0;
  139. ::v-deep .el-form-item {
  140. margin-bottom: 10px;
  141. }
  142. ::v-deep .el-date-editor.el-input {
  143. width: 100%;
  144. }
  145. }
  146. </style>