IndexEdit.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. curEstateList: [],
  38. }
  39. },
  40. watch: {
  41. isShow: function(val) {
  42. if (val) {
  43. this.getDef()
  44. }
  45. },
  46. },
  47. methods: {
  48. getDef() {
  49. let params = {...this.curObj}
  50. this.formData = [
  51. { label: '姓名', key: 'name', class: 'c-2', rules: 1 },
  52. { label: '电话', key: 'phone', class: 'c-2', rules: 1 },
  53. { label: '性别', key: 'sex', rules: 1, type: 'select', options: this.$dictData.sex },
  54. { label: '备注', label2: '备注', key: 'demand', type: 'textarea' },
  55. ]
  56. this.setDefaultValue(params)
  57. },
  58. close(str) {
  59. if (str === 'confirm') {
  60. this.$refs['ruleForm'].$refs['baseForm'].validate((valid) => {
  61. if (valid) {
  62. const oldform = this.$refs.ruleForm.baseForm
  63. const newForm = { ...oldform }
  64. if (this.curObj.id) {
  65. newForm.id = this.curObj.id
  66. }
  67. let apiStr = 'admcustomeradd'
  68. if (newForm.id) apiStr = 'admcustomeredit'
  69. newForm.phone_type = 1
  70. this.$api.cust[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. </style>