buildFlow.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <div :loading="loading">
  3. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  4. <el-form-item label="故障名称" prop="errorAppearance">
  5. <el-input v-model="form.errorAppearance" placeholder="请输入故障名称" :readonly="readonly"/>
  6. </el-form-item>
  7. <el-form-item label="排故流程" prop="flowEncode">
  8. <el-input
  9. :readonly="readonly"
  10. v-model="form.flowEncode"
  11. type="textarea"
  12. placeholder="请输入排故流程"
  13. />
  14. </el-form-item>
  15. </el-form>
  16. <div>
  17. <el-button v-show="!readonly" type="primary" @click="submitForm">确 定</el-button>
  18. <el-button v-show="!readonly" @click="cancel">取 消</el-button>
  19. </div>
  20. </div>
  21. </template>
  22. <script>
  23. import { updateFlow, addFlow, getFlow } from "@/api/suport/flow";
  24. export default {
  25. props: {
  26. subTask: {
  27. type: Object,
  28. },
  29. readonly: {
  30. type: Boolean,
  31. },
  32. },
  33. data() {
  34. return {
  35. loading: false,
  36. // 弹出层标题
  37. title: "",
  38. // 是否显示弹出层
  39. open: false,
  40. // 表单参数
  41. form: {},
  42. // 表单校验
  43. rules: {},
  44. };
  45. },
  46. created() {
  47. this.getResult()
  48. },
  49. methods: {
  50. getResult(){
  51. this.loading = true
  52. getFlow(this.subTask.id).then(response => {
  53. if(response.data){
  54. this.form = response.data
  55. }
  56. this.loading = false
  57. });
  58. },
  59. /** 提交按钮 */
  60. submitForm() {
  61. this.$refs["form"].validate((valid) => {
  62. if (valid) {
  63. this.form.subTaskId = this.subTask.id
  64. if (this.form.id != null) {
  65. updateFlow(this.form).then((response) => {
  66. this.$modal.msgSuccess("修改成功");
  67. this.open = false;
  68. this.$emit("closeInfo");
  69. });
  70. } else {
  71. addFlow(this.form).then((response) => {
  72. this.$modal.msgSuccess("新增成功");
  73. this.open = false;
  74. this.$emit("closeInfo");
  75. });
  76. }
  77. }
  78. });
  79. },
  80. // 取消按钮
  81. cancel() {
  82. this.open = false;
  83. this.reset();
  84. },
  85. // 表单重置
  86. reset() {
  87. this.form = {
  88. id: null,
  89. name: null,
  90. desc: null,
  91. createBy: null,
  92. createTime: null,
  93. updateBy: null,
  94. updateTime: null,
  95. };
  96. },
  97. },
  98. };
  99. </script>