ThemeEdit.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 (this.curObj.id) {
  44. this.$api.house.admestatemoduledetail({id: this.curObj.id}).then(res => {
  45. let curData = res || {}
  46. this.cObj = curData || {}
  47. this.getDef()
  48. })
  49. } else {
  50. this.cObj = this.curObj
  51. this.getDef()
  52. }
  53. }
  54. },
  55. },
  56. methods: {
  57. getDef() {
  58. let disabled = false
  59. if (this.curObj.id) disabled = true
  60. const params = { ...this.cObj }
  61. params.module_type = this.parentData.curNavVal || ''
  62. this.formData = [
  63. { label: '所属模块', key: 'module_type', disabled, rules: 1, type: 'select', options: this.$dictData.module_type },
  64. { label: '所属楼盘', key: 'estate_id', rules: 1, type: 'selectRemote', changeHandle: this.deviceChange,
  65. remoteParams: { skey: 'estate_name', api: `house.admestatelist`, opKey: 'estate_name', opVal: 'id' },
  66. remoteOptions: [{ keyRO: params.estate_name, valRO: params.estate_id }]
  67. },
  68. { label: '排序', key: 'sort' },
  69. ]
  70. this.setDefaultValue(params)
  71. },
  72. close(str) {
  73. if (str === 'confirm') {
  74. this.$refs['ruleForm'].$refs['baseForm'].validate((valid) => {
  75. if (valid) {
  76. const oldform = this.$refs.ruleForm.baseForm
  77. const newForm = { ...oldform }
  78. if (this.curObj.id) {
  79. newForm.id = this.curObj.id
  80. }
  81. let apiStr = 'admestatemoduleadd'
  82. if (newForm.id) apiStr = 'admestatemoduleedit'
  83. this.$api.house[apiStr](newForm).then(data => {
  84. this.$msgs(newForm.id ? '编辑成功' : '新增成功')
  85. this.$emit('close', newForm)
  86. })
  87. }
  88. })
  89. } else {
  90. this.$emit('close')
  91. this.setDefaultValue()
  92. }
  93. }
  94. }
  95. }
  96. </script>
  97. <style lang="scss" scoped>
  98. @import '../../../../styles/libEdit.scss';
  99. .lib-edit {
  100. padding-top: 0;
  101. ::v-deep .el-form-item {
  102. margin-bottom: 10px;
  103. }
  104. ::v-deep .el-date-editor.el-input {
  105. width: 100%;
  106. }
  107. }
  108. </style>