FormDialog.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <el-dialog :lock-scroll="false" :title="title" :visible.sync="visible" width="700px" :before-close="handleClose" :top="top" :show-close=false>
  3. <el-form :model="emailForm" :rules="rules" ref="ruleForm">
  4. <el-form-item v-for="(item) in comEnquiryConfig" :key="item.prop" :label="item.prop" :label-width="labelWidth+'px'" :prop="item.prop"
  5. :style="{ marginBottom: marginBottom+'px' }">
  6. <span v-if="item.type === 'text'">{{ emailForm[item.prop] }}</span>
  7. <el-input v-if="item.type === 'input'" v-model="emailForm[item.prop]" :type="item.type" clearable ></el-input>
  8. <el-input v-else-if="item.type === 'textarea'" type="textarea" v-model="emailForm[item.prop]" :rows="5" clearable ></el-input>
  9. <tinymce v-else-if="item.type === 'tinymce'"
  10. v-model="emailForm[item.prop]"
  11. :height="240"/>
  12. <el-select
  13. v-else-if="item.type === 'select' && item.isShow"
  14. clearable
  15. filterable
  16. v-model="emailForm[item.prop]"
  17. :placeholder="item.placeholder ? item.placeholder : 'Please select'">
  18. <el-option
  19. v-for="i in item.selectlist"
  20. :key="i.id"
  21. :label="i.name"
  22. :value="i.name">
  23. </el-option>
  24. </el-select>
  25. <el-checkbox-group
  26. v-else-if="item.type === 'checkbox'" v-model="emailForm[item.prop]">
  27. <el-checkbox v-for="(i,k) in item.selectlist" :label="k+1" :key="k">{{ i }}</el-checkbox>
  28. </el-checkbox-group>
  29. </el-form-item>
  30. </el-form>
  31. <div slot="footer" class="dialog-footer">
  32. <el-button type="primary" @click="handleSend" :loading="$store.state.product.loading">{{sendbtnCext}}</el-button>
  33. <el-button type="info" @click="handleClose" plain>{{cancelbtnCext}}</el-button>
  34. </div>
  35. </el-dialog>
  36. </template>
  37. <script>
  38. import Tinymce from "@/components/Tinymce";
  39. import { mapMutations } from "vuex";
  40. export default {
  41. components: { Tinymce },
  42. props: {
  43. title:{
  44. type:String,
  45. default: 'Send Email'
  46. },
  47. sendbtnCext:{
  48. type:String,
  49. default: 'Send Enquiry'
  50. },
  51. cancelbtnCext:{
  52. type:String,
  53. default: 'Cancel'
  54. },
  55. top:{
  56. type:String,
  57. default: '5vh'
  58. },
  59. isSendPdf:{
  60. type:Boolean,
  61. default: false
  62. },
  63. emailForm: {},
  64. enquiryConfig: [],
  65. rules: {},
  66. labelWidth: {
  67. type: Number,
  68. default: 150
  69. },
  70. marginBottom: {
  71. type: Number,
  72. default: 20
  73. },
  74. visible: {
  75. type: Boolean,
  76. default: false
  77. },
  78. },
  79. data() {
  80. return {
  81. downloading:false
  82. }
  83. },
  84. computed:{
  85. comEnquiryConfig(){
  86. return this.enquiryConfig.filter(item=>{
  87. if(!item.hasOwnProperty('isShow') || item.isShow) {
  88. return item
  89. }
  90. })
  91. }
  92. },
  93. methods:{
  94. ...mapMutations('product',['setLoading']),
  95. handleClose(){
  96. this.$emit('update:visible', false)
  97. },
  98. handleSend(){
  99. this.$refs.ruleForm.validate((valid) => {
  100. if (valid) {
  101. this.setLoading(true);
  102. if(this.isSendPdf){
  103. // Bus.$emit("sendPdf");
  104. this.$emit("handleSend");
  105. }else{
  106. this.$emit("handleSend");
  107. }
  108. } else {
  109. return false;
  110. }
  111. });
  112. }
  113. }
  114. };
  115. </script>
  116. <style lang="scss" scoped>
  117. $deep-blue:#004a9b;
  118. :deep(.el-dialog__header){
  119. padding: 20px;
  120. border-bottom:1px solid #eee;
  121. }
  122. .el-form .el-select{
  123. width: 100%;
  124. }
  125. textarea{
  126. color:#606266;
  127. font-weight: 700;
  128. }
  129. .el-dialog__wrapper {
  130. display: flex;
  131. justify-content: center;
  132. align-items: center;
  133. }
  134. button {
  135. background-color: $deep-blue;
  136. border-color: $deep-blue;
  137. &:hover{
  138. background-color: #013269;
  139. }
  140. }
  141. </style>