editDialog.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <div>
  3. <el-dialog
  4. v-dialog-drag
  5. class="dialog"
  6. title="指标编辑"
  7. :visible.sync="dialogVisible"
  8. width="460px"
  9. left
  10. @before-close="close"
  11. >
  12. <el-divider></el-divider>
  13. <div class="container">
  14. <el-scrollbar style="height: 100%">
  15. <el-form
  16. ref="form"
  17. :model="form"
  18. label-position="left"
  19. label-width="75px"
  20. >
  21. <el-form-item label="指标名称:">
  22. <el-input v-model="form.name"></el-input>
  23. </el-form-item>
  24. <el-form-item label="默认值:">
  25. <el-input
  26. type="number"
  27. v-model="form.defaultValue"
  28. ></el-input>
  29. </el-form-item>
  30. <el-form-item label="比较值:">
  31. <el-input
  32. type="number"
  33. v-model="form.compare"
  34. ></el-input>
  35. </el-form-item>
  36. <el-form-item label="计算规则:">
  37. <el-input v-model="form.rule"></el-input>
  38. </el-form-item>
  39. </el-form>
  40. </el-scrollbar>
  41. </div>
  42. <div
  43. slot="footer"
  44. class="dialog-footer"
  45. >
  46. <el-button
  47. style="background: #2ea8e6; color: #fff"
  48. @click="close"
  49. >取消</el-button>
  50. <el-button
  51. type="primary"
  52. style="background: #2ea8e6"
  53. @click="submitForm('form')"
  54. >确认</el-button>
  55. </div>
  56. </el-dialog>
  57. </div>
  58. </template>
  59. <script>
  60. import api from "@/api/systemConfig/api";
  61. export default {
  62. props: {
  63. update: {
  64. type: Function,
  65. },
  66. beforeFrom: {
  67. type: Object,
  68. },
  69. },
  70. data() {
  71. return {
  72. dialogVisible: false,
  73. form: {},
  74. action: "",
  75. };
  76. },
  77. methods: {
  78. submitForm() {
  79. const loading = this.$loading({
  80. lock: true,
  81. text: "更新中,请稍后!",
  82. spinner: "el-icon-loading",
  83. background: "rgba(0, 0, 0, 0.7)",
  84. customClass: "systemConfigLoading",
  85. });
  86. this.form.defaultValue =
  87. this.form.defaultValue.replace(/ /g, "") == ""
  88. ? "0"
  89. : this.form.compare;
  90. this.form.compare =
  91. this.form.compare.replace(/ /g, "") == "" ? "0" : this.form.compare;
  92. api
  93. .updateIndex({ data: JSON.stringify(this.form) })
  94. .then((result) => {
  95. loading.close();
  96. if (result.data.code == 0) {
  97. this.$message({
  98. type: "success",
  99. message: "指标更新成功!",
  100. });
  101. this.update();
  102. this.dialogVisible = false;
  103. } else {
  104. this.$message({
  105. type: "error",
  106. message: "指标更新失败!",
  107. });
  108. }
  109. })
  110. .catch((err) => {
  111. loading.close();
  112. this.$message({
  113. type: "error",
  114. message: "指标更新失败!",
  115. });
  116. });
  117. },
  118. close() {
  119. this.dialogVisible = false;
  120. },
  121. },
  122. watch: {
  123. beforeFrom(newVal) {
  124. this.form = JSON.parse(JSON.stringify(newVal));
  125. },
  126. },
  127. };
  128. </script>
  129. <style lang="less" scoped>
  130. .container {
  131. height: 230px;
  132. padding: 10px 10px;
  133. }
  134. .el-form {
  135. .el-form-item {
  136. margin: 10px 0 0 40px;
  137. width: 400px;
  138. /deep/.el-form-item__label {
  139. padding: 0;
  140. font-size: 15px;
  141. }
  142. /deep/.el-input__inner {
  143. width: 300px;
  144. height: 30px;
  145. }
  146. .life {
  147. /deep/.el-input__inner {
  148. width: 270px !important;
  149. }
  150. }
  151. .person {
  152. /deep/.el-input__inner {
  153. width: 285px !important;
  154. }
  155. }
  156. .note {
  157. /deep/.el-input__inner {
  158. width: 330px !important;
  159. }
  160. }
  161. }
  162. }
  163. // .dialog-footer {
  164. // // display: flex;
  165. // // margin-top: 10px;
  166. // }
  167. // /deep/.el-dialog {
  168. // height: 30vh;
  169. // }
  170. // /deep/.el-dialog__title {
  171. // margin-right: 330px;
  172. // }
  173. /deep/.el-dialog__header {
  174. padding-bottom: 0;
  175. color: #333333;
  176. }
  177. /deep/.el-dialog__headerbtn {
  178. font-size: 25px;
  179. }
  180. /deep/.el-dialog__body {
  181. padding: 0;
  182. }
  183. /deep/.el-divider--horizontal {
  184. display: block;
  185. height: 1px;
  186. width: 95%;
  187. margin: 0;
  188. margin-left: 2.5%;
  189. }
  190. /deep/.el-dialog__footer {
  191. padding: 0;
  192. }
  193. .el-button {
  194. width: 100px;
  195. height: 30px;
  196. text-align: center;
  197. margin: 30px;
  198. padding: 5px;
  199. }
  200. </style>