TableEdit.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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="150px">
  4. <el-row>
  5. <el-col :span="12">
  6. <el-form-item label="编号" prop="id"><el-input class="inputs" v-model="form.id" autocomplete="off" :disabled="!idAdd?true:false"></el-input></el-form-item>
  7. </el-col>
  8. <el-col :span="12">
  9. <el-form-item label="编码" prop="nemCode"><el-input class="inputs" v-model="form.nemCode" 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="form.name" autocomplete="off"></el-input></el-form-item>
  13. </el-col>
  14. <el-col :span="12">
  15. <el-form-item label="单位" prop="valueUnit"><el-input class="inputs" v-model="form.valueUnit" autocomplete="off"></el-input></el-form-item>
  16. </el-col>
  17. <el-col :span="12">
  18. <el-form-item label="英文名称" prop="englishName"><el-input class="inputs" v-model="form.englishName" autocomplete="off"></el-input></el-form-item>
  19. </el-col>
  20. <el-col :span="12">
  21. <el-form-item label="类型编号" prop="typeId"><el-input class="inputs" v-model="form.typeId" autocomplete="off"></el-input></el-form-item>
  22. </el-col>
  23. <el-col :span="12">
  24. <el-form-item label="最大值" prop="maxval"><el-input class="inputs" v-model="form.maxval" autocomplete="off"></el-input></el-form-item>
  25. </el-col>
  26. <el-col :span="12">
  27. <el-form-item label="最小值" prop="minval"><el-input class="inputs" v-model="form.minval" autocomplete="off"></el-input></el-form-item>
  28. </el-col>
  29. <el-col :span="12">
  30. <el-form-item label="合理最大值" prop="reasonableMaxval"><el-input class="inputs" v-model="form.reasonableMaxval" autocomplete="off"></el-input></el-form-item>
  31. </el-col>
  32. <el-col :span="12">
  33. <el-form-item label="合理最小值" prop="reasonableMinval"><el-input class="inputs" v-model="form.reasonableMinval" autocomplete="off"></el-input></el-form-item>
  34. </el-col>
  35. <el-col :span="12">
  36. <el-form-item label="统一编码" prop="uniformCode"><el-input class="inputs" v-model="form.uniformCode" autocomplete="off"></el-input></el-form-item>
  37. </el-col>
  38. <el-col :span="12">
  39. <el-form-item label="部件编号" prop="logicalUnitId"><el-input class="inputs" v-model="form.logicalUnitId" autocomplete="off"></el-input></el-form-item>
  40. </el-col>
  41. </el-row>
  42. </el-form>
  43. <div slot="footer" class="dialog-footer">
  44. <el-button @click="close">取 消</el-button>
  45. <el-button type="primary" @click="save">确 定</el-button>
  46. </div>
  47. </el-dialog>
  48. </template>
  49. <script>
  50. import api from '@/api/realtimeDatabaseConfiguration'
  51. import dayjs from "dayjs";
  52. export default {
  53. name: 'TableEdit',
  54. props: {
  55. options: {
  56. type: Array,
  57. default: []
  58. },
  59. stationList: {
  60. type: Array,
  61. default: []
  62. },
  63. },
  64. data() {
  65. return {
  66. form: {
  67. id: "",
  68. nemCode: "",
  69. name: "",
  70. valueUnit: "",
  71. englishName: "",
  72. typeId: "",
  73. maxval: "",
  74. minval: "",
  75. reasonableMaxval: "",
  76. reasonableMinval: "",
  77. uniformCode: "",
  78. logicalUnitId: "",
  79. },
  80. rules: {
  81. id: [{ required: true, trigger: 'blur', message: '请输入' }],
  82. nemCode: [{ required: true, trigger: 'blur', message: '请输入' }],
  83. name: [{ required: true, trigger: 'blur', message: '请输入' }],
  84. valueUnit: [{ required: true, trigger: 'blur', message: '请输入' }],
  85. englishName: [{ required: true, trigger: 'blur', message: '请输入' }],
  86. typeId: [{ required: true, trigger: 'blur', message: '请输入' }],
  87. maxval: [{ required: true, trigger: 'blur', message: '请输入' }],
  88. minval: [{ required: true, trigger: 'blur', message: '请输入' }],
  89. reasonableMaxval: [{ required: true, trigger: 'blur', message: '请输入' }],
  90. reasonableMinval: [{ required: true, trigger: 'blur', message: '请输入' }],
  91. uniformCode: [{ required: true, trigger: 'blur', message: '请输入' }],
  92. logicalUnitId: [{ required: true, trigger: 'blur', message: '请输入' }],
  93. },
  94. title: '',
  95. dialogFormVisible: false,
  96. idAdd: true,
  97. }
  98. },
  99. created() { },
  100. methods: {
  101. changeDate() {
  102. this.$forceUpdate()
  103. },
  104. showEdit(row) {
  105. if (!row) {
  106. this.title = '添加'
  107. this.idAdd = true
  108. } else {
  109. this.title = '编辑'
  110. this.idAdd = false
  111. this.form = Object.assign({}, row)
  112. }
  113. this.dialogFormVisible = true
  114. },
  115. close() {
  116. this.$refs['form'].resetFields()
  117. this.form = this.$options.data().form
  118. this.dialogFormVisible = false
  119. this.$emit('fetch-data')
  120. },
  121. save() {
  122. this.$refs['form'].validate(async (valid) => {
  123. if (valid) {
  124. api.addTesting(this.form).then(res => {
  125. if (res.data) {
  126. this.$message({
  127. type: 'success',
  128. message: '添加成功!'
  129. });
  130. this.$emit('save-success');
  131. this.dialogFormVisible = false
  132. }
  133. })
  134. } else {
  135. return false
  136. }
  137. })
  138. },
  139. handleChange() {
  140. },
  141. onBlur(val, param) {
  142. if (typeof (this.form[param]) !== 'number') {
  143. this.form[param] = val.replace(/[^0-9]/ig, "")
  144. }
  145. },
  146. },
  147. }
  148. </script>
  149. <style lang="less" scoped>
  150. .inputs {
  151. width: 200px;
  152. }
  153. .lists {
  154. display: flex;
  155. flex-direction: row;
  156. align-items: center;
  157. justify-content: space-between;
  158. }
  159. </style>