DesignFormDialog.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <el-dialog :title="title" :visible.sync="visible" width="700px" :before-close="handleClose" :top="top" :show-close=false>
  3. <el-form :model="formData" :rules="rules" ref="ruleForm">
  4. <el-form-item v-for="item in formConfig" :key="item.label" :label="item.label" :prop="item.prop" :label-width="labelWidth+'px'">
  5. <!-- 输入框 -->
  6. <el-input
  7. v-if="item.type === 'input'"
  8. v-model="formData[item.prop]"
  9. :disabled="item.disabled" :readonly="item.readonly"
  10. :style="{ width: item.width }"
  11. @change="item.change && item.change(formData[item.prop])"
  12. :placeholder="item.placeholder ? item.placeholder : ''" clearable :type="item.inputType">
  13. </el-input>
  14. <!-- 下拉框 -->
  15. <el-select
  16. v-if="item.type === 'selectObj'"
  17. v-model="formData[item.prop]"
  18. :disabled="item.disabled"
  19. :style="{ width: '100%' }"
  20. @change="item.change && item.change(formData[item.prop])"
  21. clearable
  22. filterable
  23. :multiple="item.multiple">
  24. <el-option
  25. v-for="(val, key) in item.selectList"
  26. :key="parseInt(key)"
  27. :label="val"
  28. :value="val">
  29. </el-option>
  30. </el-select>
  31. <!-- 富文本 -->
  32. <tinymce
  33. v-if="item.type === 'tinymce'"
  34. v-model="formData[item.prop]"
  35. :height="item.height"
  36. :width="item.width"
  37. style="display: inline-block"
  38. />
  39. <!-- <tinymce
  40. v-if="key=='Notes'"
  41. v-model="emailForm[key]"
  42. :height="240"/>
  43. <el-input v-model="emailForm[key]" :type="key=='Comments'?'textarea':''" :rows="5" clearable v-else></el-input> -->
  44. </el-form-item>
  45. </el-form>
  46. <div slot="footer" class="dialog-footer">
  47. <el-button type="primary" @click="handleSend">{{sendbtnCext}}</el-button>
  48. <el-button type="primary" @click="handleClose" plain>CANCEL</el-button>
  49. </div>
  50. </el-dialog>
  51. </template>
  52. <script>
  53. import Bus from "@/plugins/bus.js";
  54. import Tinymce from "@/components/Tinymce";
  55. export default {
  56. components: { Tinymce },
  57. props: {
  58. title:{
  59. type:String,
  60. default: 'Send Email'
  61. },
  62. // 表单域标签的宽度
  63. labelWidth: {
  64. type: Number,
  65. default: 95,
  66. },
  67. // 表单配置
  68. formConfig: {
  69. type: Array,
  70. required: true,
  71. },
  72. // 表单数据
  73. formData: {
  74. type: Object,
  75. required: true,
  76. },
  77. sendbtnCext:{
  78. type:String,
  79. default: 'SUBMIT REQUEST'
  80. },
  81. top:{
  82. type:String,
  83. default: '5vh'
  84. },
  85. isSendPdf:{
  86. type:Boolean,
  87. default: false
  88. },
  89. rules: {},
  90. visible: {
  91. type: Boolean,
  92. default: false
  93. },
  94. },
  95. methods:{
  96. handleClose(){
  97. this.$emit('update:visible', false)
  98. },
  99. handleSend(){
  100. this.$refs.ruleForm.validate((valid) => {
  101. if (valid) {
  102. if(this.isSendPdf){
  103. Bus.$emit("sendPdf");
  104. }else{
  105. this.$emit("handleSend");
  106. }
  107. } else {
  108. return false;
  109. }
  110. });
  111. }
  112. }
  113. };
  114. </script>
  115. <style lang="scss" scoped>
  116. :deep(.el-dialog__header){
  117. padding: 20px;
  118. border-bottom:1px solid #eee;
  119. }
  120. textarea{
  121. color:#606266;
  122. font-weight: 700;
  123. }
  124. .el-dialog__wrapper {
  125. display: flex;
  126. justify-content: center;
  127. align-items: center;
  128. }
  129. :deep(.el-dialog__body) {
  130. padding: 20px 20px 0;
  131. }
  132. </style>