CreateWorkTrouble.vue 4.07 KB
Newer Older
纪泽龙's avatar
纪泽龙 committed
1 2 3 4 5 6 7 8 9
<template>
  <el-dialog
    :title="title"
    :visible.sync="open"
    :close="close"
    width="800px"
    append-to-body
  >
    <el-form ref="form" :model="form" :rules="rules" label-width="130px">
纪泽龙's avatar
纪泽龙 committed
10 11
      <el-form-item label="隐患名称" prop="troubleName">
        <font>{{ form.troubleName }}</font>
纪泽龙's avatar
纪泽龙 committed
12
      </el-form-item>
纪泽龙's avatar
纪泽龙 committed
13 14
      <el-form-item label="隐患类型" prop="troubleType">
        <font>{{ form.troubleType }}</font>
纪泽龙's avatar
纪泽龙 committed
15
      </el-form-item>
纪泽龙's avatar
纪泽龙 committed
16 17
      <el-form-item label="隐患级别" prop="troubleLevel">
        <font>{{ form.troubleLevel }}</font>
纪泽龙's avatar
纪泽龙 committed
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
      </el-form-item>
      <el-form-item label="工单名称" prop="orderName">
        <el-input v-model="form.orderName" placeholder="请输入工单名称" />
      </el-form-item>
      <el-form-item label="指定执行人员" prop="appointInspector">
        <el-select
          v-model="form.appointInspector"
          placeholder="请选择执行人员"
          clearable
          size="small"
          @change="setUserId"
        >
          <el-option
            v-for="item in inspector"
            :key="item.userId"
            :label="item.nickName"
            :value="item.userId"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="工单描述" prop="remarks">
        <el-input
          type="textarea"
          v-model="form.remarks"
          placeholder="请输入工单描述"
        />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button :loading="loading" type="primary" @click="submitForm"
        >确 定</el-button
      >
      <!-- <el-button @click="cancel">取 消</el-button> -->
      <el-button @click.stop="close">取 消</el-button>
    </div>
  </el-dialog>
</template>
<script>
import { inspectorList } from "@/api/system/user";
import { addBasicsInfo } from "@/api/workOrder/basicsInfo";
import { getDeviceAlarm } from "@/api/dataMonitoring/deviceAlarm";

export default {
  //隐患工单
  props: {
    // 传进来一些内容
    content: {
      type: Object,
    },
  },

  data() {
    return {
      form: {
纪泽龙's avatar
纪泽龙 committed
72 73 74
        troubleName: "",
        troubleType: "",
        troubleLevel: "",
纪泽龙's avatar
纪泽龙 committed
75 76 77 78 79 80
        orderName: "",
        appointInspector: "",
        remarks: "",
      },
      gaoMap: "",
      open: false,
81
      title: "隐患生成工单",
纪泽龙's avatar
纪泽龙 committed
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
      inspector: [],
      loading: false,
      alarmId: "",
      rules: {
        orderName: [
          { required: true, message: "工单名称不能为空", trigger: "blur" },
        ],
        appointInspector: [
          { required: true, message: "请选择巡检人员", trigger: "blur" },
        ],
      },
    };
  },

  created() {
    // this.alarmId && this.handleIssue(this.alarmId);
纪泽龙's avatar
纪泽龙 committed
98
    console.log("this.form");
纪泽龙's avatar
纪泽龙 committed
99 100 101 102
  },
  watch: {
    open(value, oldValue) {
      if (value) {
纪泽龙's avatar
纪泽龙 committed
103 104 105 106 107
        this.getInspectorList()
        console.log("this.form",this.form);
        
        // console.log(this.alarmId);
        // this.handleIssue(this.alarmId);
纪泽龙's avatar
纪泽龙 committed
108 109 110 111
      }
    },
  },
  methods: {
纪泽龙's avatar
纪泽龙 committed
112 113 114 115 116 117 118 119
    // handleIssue(alarmId) {
    //   this.getInspectorList();
    //   getDeviceAlarm(alarmId).then((response) => {
    //     this.form = response.data;
    //     this.open = true;
    //     this.title = "填写工单信息";
    //   });
    // },
纪泽龙's avatar
纪泽龙 committed
120 121 122 123 124 125 126 127 128 129 130 131 132 133

    getInspectorList() {
      this.loading = true;
      inspectorList().then((response) => {
        this.inspector = response.data;
        this.loading = false;
      });
    },
    setUserId(val) {
      this.form.appointInspector = val;
    },
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
纪泽龙's avatar
纪泽龙 committed
134 135
          this.form.resourceId = this.form.troubleId;
          this.form.orderType = "2";
纪泽龙's avatar
纪泽龙 committed
136 137 138 139
          addBasicsInfo(this.form).then((response) => {
            if (response.code == 200) {
              this.msgSuccess("生成工单成功");
              this.open = false;
纪泽龙's avatar
纪泽龙 committed
140 141
              console.log(response.msg);
              this.$emit("callback", response.msg);
纪泽龙's avatar
纪泽龙 committed
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
            }
          });
        }
      });
    },
    close() {
      console.log("关闭");
      this.open = false;
    },
  },
};
</script>

<style>
</style>