formModel.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <ele-form-dialog
  3. v-bind="formConfig"
  4. v-model="formFieldsData"
  5. v-dialogDrag
  6. :title="title"
  7. :request-fn="handleFormSubmit"
  8. :visible.sync="DialogVisible"
  9. custom-class="abow_dialog"
  10. label-width="100px"
  11. label-position="left"
  12. :dialogAttrs="{ 'close-on-click-modal': false,'top':'8vh'}"
  13. />
  14. </template>
  15. <script>
  16. import EleForm from 'vue-ele-form';
  17. import Vue from 'vue';
  18. import EleFormImageUploader from 'vue-ele-form-image-uploader';
  19. Vue.use(EleForm, {
  20. // 对所有具有上传属性的组件适用
  21. upload: {
  22. fileSize: 10
  23. },
  24. })
  25. // 注册 image-uploader 组件
  26. Vue.component('image-uploader', EleFormImageUploader)
  27. export default {
  28. props: ["formModelVisible", "title"],
  29. data() {
  30. return {
  31. formData: {},
  32. formFieldsData: {
  33. wind_id: "",
  34. number: "",
  35. production_date: "",
  36. install_date:"",
  37. supplier:"",
  38. info: "",
  39. location:'',
  40. name:'',
  41. img:'',
  42. },
  43. url: "fan",
  44. formConfig: {
  45. formDesc: {
  46. wind_id: {
  47. type: "cascader",
  48. label: "所属风场",
  49. isOptions: true,
  50. options: [],
  51. required: true,
  52. attrs: {
  53. props: {
  54. label: "name",
  55. value: "id",
  56. emitPath: false,
  57. checkStrictly: true
  58. }
  59. }
  60. },
  61. name: {
  62. type: "input",
  63. label: "名称",
  64. required:true,
  65. },
  66. number: {
  67. type: "input",
  68. label: "编号",
  69. required:true,
  70. },
  71. supplier: {
  72. type: "input",
  73. label: "供应商"
  74. },
  75. location: {
  76. type: "input",
  77. label: "位置",
  78. required:true
  79. },
  80. production_date: {
  81. type: "date",
  82. label: "生产日期",
  83. required:true
  84. },
  85. install_date: {
  86. type: "date",
  87. label: "安装日期",
  88. required:true
  89. },
  90. img:{
  91. label:"上传图片",
  92. type:"image-uploader",
  93. attrs: {
  94. multiple: {
  95. type: true,
  96. },
  97. limit: 3,
  98. fileSize: 3,
  99. drag: true,
  100. action: process.env.VUE_APP_BASE_API+'/osspolicy',
  101. responseFn (response, file) {
  102. return file.url
  103. }
  104. }
  105. },
  106. info: {
  107. type: "textarea",
  108. label: "备注"
  109. }
  110. },
  111. order: ["wind_id","number","name", "supplier", "production_date","install_date","location","img","info"]
  112. }
  113. };
  114. },
  115. created() {
  116. this.$http.get("wind").then(response => {
  117. this.formConfig.formDesc.wind_id.options = response.data;
  118. });
  119. },
  120. methods: {
  121. handleFormSubmit(data) {
  122. this.$parent.handleSubmit();
  123. },
  124. handleRequest(data) {
  125. return Promise.resolve();
  126. },
  127. handleRequestSuccess() {
  128. this.$message.success("发送成功");
  129. }
  130. },
  131. computed: {
  132. DialogVisible: {
  133. set(val) {
  134. this.$emit("sendVal", val); // 表示将子组件改变的值传递给父组件
  135. },
  136. get() {
  137. return this.formModelVisible; // 表示获取父组件的值
  138. }
  139. }
  140. }
  141. };
  142. </script>