TableEdit.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <el-dialog :title="title" :visible.sync="dialogFormVisible" width="800px" @close="close">
  3. <el-form ref="form" :model="form" :rules="rules" label-width="170px">
  4. <el-row>
  5. <el-col :span="12">
  6. <el-form-item label="id" prop="id"><el-input :disabled="idAdd" class="inputs" v-model.trim="form.id" autocomplete="off"></el-input></el-form-item>
  7. </el-col>
  8. <el-col :span="12">
  9. <el-form-item label="公司编号" prop="companyid"><el-input class="inputs" v-model.trim="form.companyid" autocomplete="off"></el-input></el-form-item>
  10. </el-col>
  11. <el-col :span="12">
  12. <el-form-item label="名称" prop="name"><el-input class="inputs" v-model.trim="form.name" autocomplete="off"></el-input></el-form-item>
  13. </el-col>
  14. <el-col :span="12">
  15. <el-form-item label="别名" prop="aname"><el-input class="inputs" v-model.trim="form.aname" autocomplete="off"></el-input></el-form-item>
  16. </el-col>
  17. <el-col :span="12">
  18. <el-form-item label="风电装机容量" prop="windcapacity"><el-input class="inputs" v-model.trim="form.windcapacity" autocomplete="off"></el-input></el-form-item>
  19. </el-col>
  20. <el-col :span="12">
  21. <el-form-item label="风电容量单位" prop="windcapacityunit"><el-input class="inputs" v-model.trim="form.windcapacityunit" autocomplete="off"></el-input></el-form-item>
  22. </el-col>
  23. <el-col :span="12">
  24. <el-form-item label="风电装机数量" prop="windquantity"><el-input class="inputs" v-model.trim="form.windquantity" autocomplete="off"></el-input></el-form-item>
  25. </el-col>
  26. <el-col :span="12">
  27. <el-form-item label="光伏装机容量" prop="capacity"><el-input class="inputs" v-model.trim="form.capacity" autocomplete="off"></el-input></el-form-item>
  28. </el-col>
  29. <el-col :span="12">
  30. <el-form-item label="光伏容量单位" prop="capacityunit"><el-input class="inputs" v-model.trim="form.capacityunit" autocomplete="off"></el-input></el-form-item>
  31. </el-col>
  32. <el-col :span="12">
  33. <el-form-item label="光伏装机数量集中" prop="quantityjz"><el-input class="inputs" v-model.trim="form.quantityjz" autocomplete="off"></el-input></el-form-item>
  34. </el-col>
  35. <el-col :span="12">
  36. <el-form-item label="光伏装机数量组串" prop="quantityzc"><el-input class="inputs" v-model.trim="form.quantityzc" autocomplete="off"></el-input></el-form-item>
  37. </el-col>
  38. <el-col :span="12">
  39. <el-form-item label="接入风电装机容量2" prop="jrwindcapacity"><el-input class="inputs" v-model.trim="form.jrwindcapacity" autocomplete="off"></el-input></el-form-item>
  40. </el-col>
  41. <el-col :span="12">
  42. <el-form-item label="接入风电容量单位2" prop="jrwindcapacityunit"><el-input class="inputs" v-model.trim="form.jrwindcapacityunit" autocomplete="off"></el-input></el-form-item>
  43. </el-col>
  44. <el-col :span="12">
  45. <el-form-item label="接入风电装机数量2" prop="jrwindquantity"><el-input class="inputs" v-model.trim="form.jrwindquantity" autocomplete="off"></el-input></el-form-item>
  46. </el-col>
  47. <el-col :span="12">
  48. <el-form-item label="接入光伏装机容量2" prop="jrcapacity"><el-input class="inputs" v-model.trim="form.jrcapacity" autocomplete="off"></el-input></el-form-item>
  49. </el-col>
  50. <el-col :span="12">
  51. <el-form-item label="接入光伏容量单位2" prop="jrcapacityunit"><el-input class="inputs" v-model.trim="form.jrcapacityunit" autocomplete="off"></el-input></el-form-item>
  52. </el-col>
  53. <el-col :span="12">
  54. <el-form-item label="接入光伏装机数量集中" prop="jrquantityjz"><el-input class="inputs" v-model.trim="form.jrquantityjz" autocomplete="off"></el-input></el-form-item>
  55. </el-col>
  56. <el-col :span="12">
  57. <el-form-item label="接入光伏装机数量组串" prop="jrquantityzc"><el-input class="inputs" v-model.trim="form.jrquantityzc" autocomplete="off"></el-input></el-form-item>
  58. </el-col>
  59. </el-row>
  60. </el-form>
  61. <div slot="footer" class="dialog-footer">
  62. <el-button @click="close">取 消</el-button>
  63. <el-button type="primary" @click="save">确 定</el-button>
  64. </div>
  65. </el-dialog>
  66. </template>
  67. <script>
  68. import api from '@/api/station'
  69. export default {
  70. name: 'TableEdit',
  71. props: {
  72. options: {
  73. type: Array,
  74. default: []
  75. },
  76. },
  77. data() {
  78. return {
  79. form: {
  80. id: '',
  81. companyid:'',
  82. name:'',
  83. aname:'',
  84. windcapacity:'',
  85. windcapacityunit:'',
  86. windquantity:'',
  87. capacity:'',
  88. capacityunit:'',
  89. quantityjz:'',
  90. quantityzc:'',
  91. jrwindcapacity:'',
  92. jrwindcapacityunit:'',
  93. jrwindquantity:'',
  94. jrcapacity:'',
  95. jrcapacityunit:'',
  96. jrquantityjz:'',
  97. jrquantityzc:'',
  98. },
  99. rules: {
  100. id: [{ required: true, trigger: 'blur', message: '请输入' }],
  101. companyid: [{ required: true, trigger: 'blur', message: '请输入' }],
  102. name: [{ required: true, trigger: 'blur', message: '请输入' }],
  103. aname: [{ required: true, trigger: 'blur', message: '请输入' }],
  104. windcapacity: [{ required: true, trigger: 'blur', message: '请输入' }],
  105. windcapacityunit: [{ required: true, trigger: 'blur', message: '请输入' }],
  106. windquantity: [{ required: true, trigger: 'blur', message: '请输入' }],
  107. capacity: [{ required: true, trigger: 'blur', message: '请输入' }],
  108. capacityunit: [{ required: true, trigger: 'blur', message: '请输入' }],
  109. quantityjz: [{ required: true, trigger: 'blur', message: '请输入' }],
  110. quantityzc: [{ required: true, trigger: 'blur', message: '请输入' }],
  111. jrwindcapacity: [{ required: true, trigger: 'blur', message: '请输入' }],
  112. jrwindcapacityunit: [{ required: true, trigger: 'blur', message: '请输入' }],
  113. jrwindquantity: [{ required: true, trigger: 'blur', message: '请输入' }],
  114. jrcapacity: [{ required: true, trigger: 'blur', message: '请输入' }],
  115. jrcapacityunit: [{ required: true, trigger: 'blur', message: '请输入' }],
  116. jrquantityjz: [{ required: true, trigger: 'blur', message: '请输入' }],
  117. jrquantityzc: [{ required: true, trigger: 'blur', message: '请输入' }],
  118. },
  119. title: '',
  120. dialogFormVisible: false,
  121. idAdd: true,
  122. }
  123. },
  124. created() { },
  125. methods: {
  126. showEdit(row) {
  127. if (!row) {
  128. this.title = '添加'
  129. this.idAdd = false
  130. } else {
  131. this.title = '编辑'
  132. this.idAdd = true
  133. this.form = Object.assign({}, row)
  134. }
  135. this.dialogFormVisible = true
  136. },
  137. close() {
  138. this.$refs['form'].resetFields()
  139. this.form = this.$options.data().form
  140. this.dialogFormVisible = false
  141. this.$emit('fetch-data')
  142. },
  143. save() {
  144. this.$refs['form'].validate(async (valid) => {
  145. if (valid) {
  146. if(this.title === "添加"){
  147. api.addSave(this.form).then(res => {
  148. if (res.data) {
  149. this.$message({
  150. type: 'success',
  151. message: '操作成功!'
  152. });
  153. this.$emit('save-success');
  154. this.dialogFormVisible = false
  155. }
  156. })
  157. } else {
  158. api.editSave(this.form).then(res => {
  159. if (res.data) {
  160. this.$message({
  161. type: 'success',
  162. message: '操作成功!'
  163. });
  164. this.$emit('save-success');
  165. this.dialogFormVisible = false
  166. }
  167. })
  168. }
  169. } else {
  170. return false
  171. }
  172. })
  173. },
  174. handleChange() {
  175. },
  176. },
  177. }
  178. </script>
  179. <style lang="less" scoped>
  180. .inputs {
  181. width: 200px;
  182. }
  183. </style>