【前端】智能库房综合管理系统前端项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
3.9 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <!--表单组件-->
  3. <!-- :before-close="crud.cancelCU" -->
  4. <el-dialog class="binding-params-dialog" :close-on-click-modal="false" :visible.sync="bingParamsVisible" title="绑定参数" @closed="handleClose">
  5. <span class="dialog-right-top" />
  6. <span class="dialog-left-bottom" />
  7. <div class="setting-dialog">
  8. <div class="head-container">
  9. <el-form ref="form" :model="form" inline :rules="rules" size="small" label-width="80px">
  10. <el-form-item label="参数ID" prop="paramId">
  11. <el-input v-model="form.paramId" style="width: 150px;" />
  12. </el-form-item>
  13. <el-form-item label="参数名称" prop="paramName">
  14. <el-input v-model="form.paramName" style="width: 150px;" />
  15. </el-form-item>
  16. <el-form-item label="单位值" prop="unit">
  17. <el-input v-model="form.unit" style="width: 150px;" />
  18. </el-form-item>
  19. <el-button class="filter-item" size="mini" type="primary" @click="add">添加</el-button>
  20. </el-form>
  21. </div>
  22. <el-table ref="table" :loading="loading" :data="params" height="calc(100vh - 582px)">
  23. <el-table-column type="index" label="序号" width="80" align="center" />
  24. <el-table-column prop="paramId" label="参数ID" align="center" />
  25. <el-table-column prop="paramName" label="参数名称" align="center" />
  26. <el-table-column prop="unit" label="单位值" align="center" />
  27. <el-table-column label="操作" align="center">
  28. <template slot-scope="scope">
  29. <el-button size="mini" icon="el-icon-delete" class="delete-btn" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
  30. </template>
  31. </el-table-column>
  32. </el-table>
  33. </div>
  34. </el-dialog>
  35. </template>
  36. <script>
  37. import crudMethod from '@/api/storeManage/deviceManage/param'
  38. export default {
  39. name: 'BingParams',
  40. data() {
  41. return {
  42. rules: {
  43. paramId: [
  44. { required: true, message: '请输入参数ID', trigger: 'blur' }
  45. ],
  46. paramName: [
  47. { required: true, message: '请输入参数名称', trigger: 'blur' }
  48. ],
  49. unit: [
  50. { required: true, message: '请输入单位值', trigger: 'blur' }
  51. ]
  52. },
  53. params: [],
  54. form: {},
  55. deviceInfoId: null,
  56. loading: false,
  57. bingParamsVisible: false
  58. }
  59. },
  60. methods: {
  61. handleDelete(index, row) {
  62. crudMethod.del(row.id).then((res) => {
  63. this.params.splice(index, 1)
  64. })
  65. },
  66. add() {
  67. this.$refs.form.validate((valid) => {
  68. if (valid) {
  69. this.form.deviceInfoId = this.deviceInfoId
  70. this.form.sequence = this.params.reduce((prev, cur) => { return { sequence: Math.max(prev.sequence, cur.sequence) } }, { sequence: 0 }).sequence + 1
  71. crudMethod.add(this.form).then((res) => {
  72. this.loading = true
  73. crudMethod.getParams({ deviceInfoId: this.deviceInfoId }).then((data) => {
  74. this.params.splice(0, this.params.length, ...data)
  75. this.resetForm()
  76. this.loading = false
  77. })
  78. })
  79. } else {
  80. return false
  81. }
  82. })
  83. },
  84. handleClose() {
  85. this.resetForm()
  86. this.$refs.form.clearValidate()
  87. },
  88. resetForm() {
  89. this.form.paramId = ''
  90. this.form.paramName = ''
  91. this.form.unit = ''
  92. }
  93. }
  94. }
  95. </script>
  96. <style lang="scss" scoped>
  97. .binding-params-dialog {
  98. ::v-deep .el-dialog{
  99. width: 950px !important;
  100. }
  101. ::v-deep .el-dialog__body{
  102. padding: 0;
  103. }
  104. ::v-deep form{
  105. display: flex;
  106. justify-content: space-around;
  107. }
  108. ::v-deep .el-form-item--small.el-form-item {
  109. margin-bottom: 0;
  110. }
  111. }
  112. .delete-btn{
  113. background-color: #F65163;
  114. border-color: #F65163;
  115. }
  116. .head-container .filter-item {
  117. width: 76px;
  118. height: 32px;
  119. display: inline-block;
  120. vertical-align: middle;
  121. background-color: #3a99fd;
  122. }
  123. </style>