Model.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <el-drawer
  3. :title="title"
  4. :modal-append-to-body="false"
  5. :modal="false"
  6. :wrapper-closable="false"
  7. size="36%"
  8. :visible.sync="dialogVisible"
  9. >
  10. <el-form
  11. ref="ruleForm"
  12. :model="formData"
  13. :rules="rules"
  14. label-position="right"
  15. label-width="160px"
  16. >
  17. <el-form-item label="时差阈值" required>
  18. <el-input-number v-model="formData.transTimedifferenceThreshold" placeholder="时差阈值(分钟)" :controls="false" />
  19. </el-form-item>
  20. <el-form-item label="载物差阈值" required>
  21. <el-input-number v-model="formData.transWeightdifferenceThreshold" placeholder="载物差阈值(吨)" :controls="false" />
  22. </el-form-item>
  23. </el-form>
  24. <div class="btn-group">
  25. <el-button type="primary" @click="submitForm('ruleForm')">确定</el-button>
  26. <el-button class="cancel-btn" @click="dialogVisible = false">取消</el-button>
  27. </div>
  28. </el-drawer>
  29. </template>
  30. <script>
  31. import { createThreshold, updateThreshold } from '@/api/threshold'
  32. export default {
  33. name: 'CameraModel',
  34. data() {
  35. return {
  36. title: '载物评估阈值',
  37. ops: {
  38. bar: {
  39. keepShow: false,
  40. background: 'rgba(144, 147, 153, 0.4)',
  41. onlyShowBarOnScroll: false
  42. }
  43. },
  44. dialogVisible: false,
  45. CameraCats: [],
  46. goaf: [],
  47. formData: {
  48. transTimedifferenceThreshold: 0,
  49. transWeightdifferenceThreshold: 0
  50. },
  51. rules: {}
  52. }
  53. },
  54. methods: {
  55. // Show Add Dialog
  56. showAddModel() {
  57. this.resetFormData()
  58. this.actionType = 'ADD'
  59. this.title = '新增载物评估阈值配置'
  60. this.dialogVisible = true
  61. },
  62. // Show Edit Dialog
  63. showEditModel(data) {
  64. this.resetFormData()
  65. this.actionType = 'UPDATE'
  66. this.title = '修改载物评估阈值配置'
  67. this.dialogVisible = true
  68. this.formData = data
  69. },
  70. // Reset Form Data
  71. resetFormData() {
  72. this.formData = {
  73. transTimedifferenceThreshold: 0,
  74. transWeightdifferenceThreshold: 0
  75. }
  76. },
  77. // 提交
  78. submitForm(formName) {
  79. this.$refs[formName].validate((valid) => {
  80. if (valid) {
  81. switch (this.actionType) {
  82. case 'ADD':
  83. createThreshold(this.formData)
  84. .then((resp) => {
  85. const { code, msg } = resp
  86. if (code === 0) {
  87. this.dialogVisible = false
  88. this.$message.success(msg)
  89. this.formSuccess()
  90. } else {
  91. this.$message.error(msg)
  92. }
  93. })
  94. break
  95. case 'UPDATE':
  96. updateThreshold(this.formData)
  97. .then((resp) => {
  98. const { code, msg } = resp
  99. if (code === 0) {
  100. this.dialogVisible = false
  101. this.$message.success(msg)
  102. this.formSuccess()
  103. } else {
  104. this.$message.error(msg)
  105. }
  106. })
  107. break
  108. }
  109. } else {
  110. this.$message.error('error submit!!')
  111. return false
  112. }
  113. })
  114. },
  115. formSuccess() {
  116. this.$emit('formSuccess')
  117. },
  118. resetFormField(formName) {
  119. this.$refs[formName].resetFields()
  120. },
  121. deeepClone(params) {
  122. return JSON.parse(JSON.stringify(params))
  123. }
  124. }
  125. }
  126. </script>
  127. <style lang="scss" scoped>
  128. .btn-group {
  129. padding-left: 160px;
  130. margin-top: 50px;
  131. }
  132. .safe-area {
  133. color: #fff;
  134. display: flex;
  135. flex-wrap: wrap;
  136. .safe-area-item {
  137. margin: 0 5px 10px 0;
  138. width: 20%;
  139. min-width: 120px;
  140. }
  141. .el-input__inner {
  142. text-align: left !important;
  143. }
  144. }
  145. ::v-deep.el-select-tree {
  146. .label {
  147. color: #606266 !important;
  148. }
  149. .el-tree-node.is-current > .el-tree-node__content,
  150. .el-tree-node__content:hover {
  151. background-color: #fff !important;
  152. color: #606266;
  153. }
  154. }
  155. </style>