调解系统PC端服务

test.vue 3.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <div>
  3. <el-form :model="dynamicValidateForm" ref="dynamicValidateForm" label-width="100px" class="demo-dynamic">
  4. <el-form-item prop="email" label="邮箱" :rules="[
  5. { required: true, message: '请输入邮箱地址', trigger: 'blur' },
  6. { type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur', 'change'] }
  7. ]">
  8. <el-input v-model="dynamicValidateForm.email"></el-input>
  9. </el-form-item>
  10. <div v-for="(item, index) in dynamicValidateForm.domains" :key="item.key">
  11. <el-form-item :label="'域名' + index" :prop="'domains.' + index + '.value.name'" :rules="{
  12. required: true, message: '域名不能为空', trigger: 'blur'
  13. }">
  14. <el-input v-model="item.value.name"></el-input>
  15. </el-form-item>
  16. <el-form-item :label="'链接' + index" :prop="'domains.' + index + '.value.url'" :rules="{
  17. required: true, message: '链接不能为空', trigger: 'blur'
  18. }">
  19. <el-input v-model="item.value.url"></el-input>
  20. </el-form-item>
  21. <el-button @click.prevent="removeDomain(item)">删除</el-button>
  22. </div>
  23. <el-form-item>
  24. <el-button type="primary" @click="submitForm('dynamicValidateForm')">提交</el-button>
  25. <el-button @click="addDomain">新增域名</el-button>
  26. <el-button @click="resetForm('dynamicValidateForm')">重置</el-button>
  27. </el-form-item>
  28. </el-form>
  29. </div>
  30. </template>
  31. <script>
  32. export default {
  33. data() {
  34. return {
  35. dynamicValidateForm: {
  36. domains: [{
  37. value: {
  38. name: "",
  39. url: ""
  40. }
  41. }],
  42. email: ''
  43. },
  44. data: { "applicant": { "id": 123, "caseAppliId": 5453163805296176, "userId": null, "applicantDeptId": null, "code": null, "compLegalPerson": null, "roleType": 1, "groupOrder": 2, "operatorFlag": 0, "phone": "17691225077", "email": "1129801211@qq.com", "name": "白贵勇", "home": "西安", "address": "西安", "idCard": "612429198708193335", "idType": null, "nationality": null, "birth": null, "sex": null, "resName": null }, "applicantAgent": null, "res": { "id": 124, "caseAppliId": 5453163805296176, "userId": null, "applicantDeptId": null, "code": null, "compLegalPerson": null, "roleType": 3, "groupOrder": 2, "operatorFlag": 0, "phone": "18792927508", "email": "1322446236@qq.com", "name": "王琼", "home": "西安", "address": "西安", "idCard": "14050219970814622X", "idType": null, "nationality": null, "birth": null, "sex": null, "resName": null }, "resAgent": null }
  45. };
  46. },
  47. methods: {
  48. submitForm(formName) {
  49. this.$refs[formName].validate((valid) => {
  50. if (valid) {
  51. alert('submit!');
  52. console.log(this.dynamicValidateForm);
  53. } else {
  54. console.log('error submit!!');
  55. return false;
  56. }
  57. });
  58. },
  59. resetForm(formName) {
  60. this.$refs[formName].resetFields();
  61. },
  62. removeDomain(item) {
  63. var index = this.dynamicValidateForm.domains.indexOf(item)
  64. if (index !== -1) {
  65. this.dynamicValidateForm.domains.splice(index, 1)
  66. }
  67. },
  68. addDomain() {
  69. this.dynamicValidateForm.domains.push({
  70. value: {
  71. name: "",
  72. key: Date.now()
  73. },
  74. });
  75. }
  76. }
  77. }
  78. </script>