IndexEdit.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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="760px"
  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">
  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. loading: false,
  36. formData: [],
  37. cObj: {},
  38. }
  39. },
  40. watch: {
  41. isShow: function(val) {
  42. if (val) {
  43. if (this.curObj.id) {
  44. this.$api.other.admchannelsdetail({id: this.curObj.id}).then(res => {
  45. this.cObj = res || {}
  46. this.getDef()
  47. })
  48. } else {
  49. this.getDef()
  50. }
  51. }
  52. },
  53. },
  54. methods: {
  55. getDef (str) {
  56. let params = {}
  57. params = { ...this.cObj }
  58. if (str === 'edit') {
  59. params = {...this.$refs.ruleForm.baseForm, ...params}
  60. }
  61. if (!params.hide_status) params.hide_status = '1'
  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. this.formData = [
  72. { label: '发布时间', key: 'publish_at', type: 'datePicker', type2: 'date', rules: 1},
  73. { label: '标题', key: 'title', rules: 1},
  74. { label: '状态', rules: 1, key: 'hide_status', class: 'c-2', type: 'select', options: this.$dictData.hide_status},
  75. { label: '视频分类', key: 'channels_type', class: 'c-2', type: 'select', options: this.$dictData.channels_type},
  76. { label: '封面图', rules: 1, key: 'cover', class: 'c-2', type: 'cuImg',
  77. options: {
  78. w: 175,
  79. h: 225,
  80. }
  81. },
  82. { label: '自定义标签', class: 'c-2', key: 'custom_tag', type: 'textarea' },
  83. { label: '视频ID', rules: 1, key: 'feed_id', type: 'textarea' },
  84. { label: '关联楼盘', key: 'estate_id_list', type: 'selectRemote', multiple: true, changeHandle: this.deviceChange,
  85. remoteParams: { skey: 'estate_name', api: `house.admestatelist`, opKey: 'estate_name', opVal: 'id' },
  86. remoteOptions: remoteOptionsIds
  87. },
  88. ]
  89. this.setDefaultValue(params)
  90. },
  91. close (str) {
  92. if (str === 'confirm') {
  93. this.$refs['ruleForm'].$refs['baseForm'].validate((valid) => {
  94. if (valid) {
  95. const oldform = this.$refs.ruleForm.baseForm
  96. const newForm = { ...oldform }
  97. if (this.curObj.id) newForm.id = this.curObj.id
  98. newForm.custom_tag = newForm.custom_tag.replace(/,|、|\/|\\/g, ',')
  99. let apiStr = 'admchannelsadd'
  100. if (this.curObj.id) apiStr = 'admchannelsedit'
  101. if (newForm.estate_id_list && newForm.estate_id_list.length > 0) {
  102. newForm.estate_id_list = newForm.estate_id_list.join(',')
  103. } else {
  104. newForm.estate_id_list = ''
  105. }
  106. this.$api.other[apiStr](newForm).then(data => {
  107. this.$msgs(newForm.id ? '编辑成功' : '新增成功')
  108. this.cObj = {}
  109. this.$emit('close', newForm)
  110. })
  111. }
  112. })
  113. } else {
  114. this.$emit('close')
  115. this.cObj = {}
  116. this.setDefaultValue()
  117. }
  118. },
  119. }
  120. }
  121. </script>
  122. <style lang="scss" scoped>
  123. @import '../../../../styles/libEdit.scss';
  124. .lib-edit {
  125. padding-top: 0;
  126. padding-left: 0;
  127. padding-bottom: 40px;
  128. ::v-deep .el-form-item {
  129. margin-bottom: 10px;
  130. }
  131. ::v-deep .el-date-editor.el-input {
  132. width: 100%;
  133. }
  134. }
  135. </style>