TableEdit.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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="80px">
  4. <el-form-item label="编码" prop="code">
  5. <el-input placeholder="请输入" class="inputs" v-model.trim="form.code" autocomplete="off"></el-input>
  6. </el-form-item>
  7. <el-form-item label="名称" prop="name">
  8. <el-input placeholder="请输入" class="inputs" v-model.trim="form.name" autocomplete="off"></el-input>
  9. </el-form-item>
  10. <el-form-item label="型号" prop="model">
  11. <el-input placeholder="请输入" class="inputs" v-model.trim="form.model" autocomplete="off"></el-input>
  12. </el-form-item>
  13. <el-form-item label="统一编码" prop="uniformcode">
  14. <el-input placeholder="请输入" class="inputs" v-model.trim="form.uniformcode" autocomplete="off"></el-input>
  15. </el-form-item>
  16. <el-form-item label="场站编号" prop="windpowerstationid">
  17. <el-input placeholder="请输入" class="inputs" v-model.trim="form.windpowerstationid" autocomplete="off"></el-input>
  18. </el-form-item>
  19. <!-- <el-form-item label="类型" prop="type">
  20. <el-select class="inputs" v-model="form.type" placeholder="请选择">
  21. <el-option
  22. v-for="item in typeOptions"
  23. :key="item.value"
  24. :label="item.label"
  25. :value="item.value">
  26. </el-option>
  27. </el-select>
  28. </el-form-item> -->
  29. </el-form>
  30. <div slot="footer" class="dialog-footer">
  31. <el-button @click="close">取 消</el-button>
  32. <el-button type="primary" @click="save">确 定</el-button>
  33. </div>
  34. </el-dialog>
  35. </template>
  36. <script>
  37. import api from '@/api/pointConfiguration'
  38. import axios from "axios";
  39. export default {
  40. name: 'TableEdit',
  41. props: {
  42. options: {
  43. type: Array,
  44. default: []
  45. },
  46. },
  47. data() {
  48. return {
  49. typeOptions: [
  50. {value: '风机计算', label:'风机计算'},
  51. {value: '场站计算', label:'场站计算'},
  52. {value: '风机基础点', label:'风机基础点'},
  53. ],
  54. form: {
  55. id: '',
  56. code: '',
  57. name: '',
  58. model: '',
  59. uniformcode: '',
  60. windpowerstationid: '',
  61. },
  62. rules: {
  63. code: [{ required: true, trigger: 'blur', message: '请输入' }],
  64. name: [{ required: true, trigger: 'blur', message: '请输入' }],
  65. model: [{ required: true, trigger: 'blur', message: '请输入' }],
  66. uniformcode: [{ required: true, trigger: 'blur', message: '请输入' }],
  67. windpowerstationid: [{ required: true, trigger: 'blur', message: '请输入' }],
  68. },
  69. title: '',
  70. dialogFormVisible: false,
  71. idAdd: true,
  72. }
  73. },
  74. created() { },
  75. methods: {
  76. showEdit(row) {
  77. if (!row) {
  78. this.title = '添加'
  79. this.idAdd = true
  80. } else {
  81. this.title = '编辑'
  82. this.idAdd = false
  83. this.form = Object.assign({}, row)
  84. }
  85. this.dialogFormVisible = true
  86. },
  87. close() {
  88. this.$refs['form'].resetFields()
  89. this.form = this.$options.data().form
  90. this.dialogFormVisible = false
  91. this.$emit('fetch-data')
  92. },
  93. save() {
  94. this.$refs['form'].validate(async (valid) => {
  95. if (valid) {
  96. api.addWindpowerstationpointnew(this.form).then(res => {
  97. if (res.data) {
  98. this.$message({
  99. type: 'success',
  100. message: '添加成功!'
  101. });
  102. this.$emit('save-success');
  103. this.dialogFormVisible = false
  104. }
  105. })
  106. } else {
  107. return false
  108. }
  109. })
  110. },
  111. handleChange() {
  112. },
  113. },
  114. }
  115. </script>
  116. <style lang="less" scoped>
  117. .inputs {
  118. width: 200px;
  119. }
  120. </style>