informationInfo-detail.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <style scoped>
  2. .user-panel {
  3. margin: 10px auto;
  4. }
  5. </style>
  6. <template>
  7. <el-dialog
  8. :visible.sync="showDialog"
  9. :title="title"
  10. :modal-append-to-body="false"
  11. style="text-align:left;"
  12. @close="closeDialog"
  13. :close-on-click-modal="false"
  14. width="35%"
  15. >
  16. <div class="user-panel" v-loading="loading">
  17. <el-form ref="form" :model="formModel" :rules="ruleValidate" :label-width="'100px'">
  18. <el-form-item label="解决方案" prop="returnContent">
  19. <el-input type="textarea"
  20. :rows="10"
  21. v-model="formModel.returnContent" placeholder="请输入解决方案" style="width:300px">
  22. </el-input>
  23. </el-form-item>
  24. </el-form>
  25. </div>
  26. <span slot="footer" class="dialog-footer">
  27. <el-button @click="closeDialog">取 消</el-button>
  28. <el-button type="primary" @click="handleSubmit" :loading="submitting">确 定</el-button>
  29. </span>
  30. </el-dialog>
  31. </template>
  32. <script>
  33. import Constant from "@/constant";
  34. import informationInfoApi from "@/api/base/informationInfo";
  35. export default {
  36. props: ["businessKey", "title"],
  37. data() {
  38. return {
  39. ruleValidate: {
  40. returnContent: [
  41. { required: true, message: "解决方案不能为空", trigger: "blur" }
  42. ],
  43. },
  44. formModel: {
  45. id:"",
  46. returnContent:"",
  47. },
  48. showDialog: true,
  49. loading: false,
  50. submitting: false,
  51. };
  52. },
  53. methods: {
  54. closeDialog() {
  55. this.$emit("close", false);
  56. },
  57. handleSubmit() {
  58. var self = this;
  59. this.$refs["form"].validate(valid => {
  60. if (valid) {
  61. (function() {
  62. var id = self.formModel.id;
  63. if (id == null || id.length == 0) {
  64. return informationInfoApi.add(self.formModel);
  65. } else {
  66. return informationInfoApi.update(self.formModel);
  67. }
  68. })().then(function(response) {
  69. var jsonData = response.data;
  70. if (jsonData.result) {
  71. self.$message({
  72. message: "保存成功!",
  73. type: "success"
  74. });
  75. self.$emit("close", true);
  76. } else {
  77. self.$message({
  78. message: jsonData.message + "",
  79. type: "warning"
  80. });
  81. self.$emit("close", false);
  82. }
  83. });
  84. }
  85. });
  86. }
  87. },
  88. mounted: function() {
  89. var self = this;
  90. (function() {
  91. if (self.businessKey.length == 0) {
  92. return informationInfoApi.create();
  93. } else {
  94. return informationInfoApi.edit(self.businessKey);
  95. }
  96. })()
  97. .then(response => {
  98. var jsonData = response.data;
  99. self.loading = false;
  100. if (jsonData.result) {
  101. self.formModel = jsonData.data;
  102. } else {
  103. self.$message.error(jsonData.message + "");
  104. }
  105. })
  106. .catch(error => {
  107. self.$message.error(error + "");
  108. });
  109. }
  110. };
  111. </script>