<template>
    <div class="app-container detail" style="background-color: rgb(238, 241, 245);">
      <div style="background-color: rgb(252, 252, 252);padding-top: 10px;">
        <span style="color: #31EAEA;font-weight: 900;margin-left: 15px;">工单信息</span>
        <el-steps :active="active" finish-status="success" simple prop="orderStatus" style="margin-top: 20px">
            <el-step title="未接收" ></el-step>
            <el-step title="已接收" ></el-step>
            <el-step title="进行中" ></el-step>
            <el-step title="已反馈" ></el-step>
            <el-step title="已归档" ></el-step>
        </el-steps>
        <el-divider></el-divider>
        <div style="width: 100%;height: 200px;margin-bottom: 40px;">
          <div style="color: #31EAEA;width: 100%;height: 40px;">
            <ul><li>详细信息</li></ul>
          </div>
          <el-form ref="form" v-model="form" :rules="rules" label-width="100px" style="float: left;margin-left: 50px;">
              <el-form-item label="工单类型:" prop="orderType">
                <!-- <template slot-scope="scope">
                  <span>{{ scope.row.orderType}}</span>
                </template> -->
                <font>{{form.orderType}}</font>
              </el-form-item>
              <el-form-item label="工单编号:" prop="orderId">
                <font>{{form.orderId}}</font>
              </el-form-item>
              <el-form-item label="工单名称:" prop="orderName">
                <font>{{form.orderName}}</font>
              </el-form-item>
              <el-form-item label="指定执行人员:" prop="appointInspectorName">
                <font>{{form.appointInspectorName}}</font>
              </el-form-item>
              <el-form-item label="设备类型:" prop="actualInspector">
                <font>{{form.actualInspector}}</font>
              </el-form-item>  
          </el-form>
          <el-form ref="form" v-model="form" :rules="rules" label-width="100px" style="float: left;">
              <el-form-item label="设备编号:" prop="deviceId">
                <font>{{form.deviceId}}</font>
              </el-form-item>
              <el-form-item label="设备位置:" prop="remarks">
                <font>{{form.remarks}}</font>
              </el-form-item>
              <el-form-item label="创建时间:" prop="allotTime">
                <font>{{form.allotTime}}</font>
              </el-form-item>
              <el-form-item label="更新时间:" prop="actualTime">
                <font>{{form.actualTime}}</font>
              </el-form-item>
              <el-form-item label="工单描述:" prop="actualTime">
                <font>{{form.actualTime}}</font>
              </el-form-item> 
          </el-form>
          <div id="marbox" style="width: 700px;height: 180px;float: left;border: 1px solid rgb(218, 213, 213);">
            <div style="width: 100%;height: 100%" id="container"></div>
          </div>
        </div>
        
        <el-divider></el-divider>
        <div style="color: #31EAEA;width: 100%;height: 40px;">
          <ul><li>接单信息</li></ul>
        </div>
        <el-form ref="form" v-model="form" :rules="rules" label-width="100px" style="margin-left: 50px;">
            <el-form-item label="接单人:" prop="actualInspectorName">
              <font>{{form.actualInspectorName}}</font>
            </el-form-item>
            <el-form-item label="接单时间:" prop="actualTime">
              <font>{{form.actualTime}}</font>
            </el-form-item>  
        </el-form>
        <el-divider></el-divider>
        <div style="width: 100%;font-weight: 600;height: 250px;">
          <div style="color: #31EAEA;width: 100%;height: 40px;">
            <ul><li>反馈信息</li></ul>
          </div>
          <div style="width: 95%;height: 200px;float: right;">
            <el-upload style="width:20%;float: left;"
              action="#"
              list-type="picture-card"
              :auto-upload="false">
                <i slot="default" class="el-icon-plus"></i>
                <div slot="file" slot-scope="{file}">
                  <img
                    class="el-upload-list__item-thumbnail"
                    :src="file.url" alt=""
                  >
                  <span class="el-upload-list__item-actions">
                    <span
                      class="el-upload-list__item-preview"
                      @click="handlePictureCardPreview(file)"
                    >
                      <i class="el-icon-zoom-in"></i>
                    </span>
                    <span
                      v-if="!disabled"
                      class="el-upload-list__item-delete"
                      @click="handleDownload(file)"
                    >
                      <i class="el-icon-download"></i>
                    </span>
                    <span
                      v-if="!disabled"
                      class="el-upload-list__item-delete"
                      @click="handleRemove(file)"
                    >
                      <i class="el-icon-delete"></i>
                    </span>
                  </span>
                </div>
            </el-upload>
            <el-form ref="form" v-model="form" :rules="rules" label-width="100px" style="float: left;width: 50%;">
                <el-form-item label="反馈信息:" prop="actualInspector">
                  <font>{{form.actualInspector}}</font>
                </el-form-item>
                <el-form-item label="反馈时间:" prop="actualTime">
                  <font>{{form.actualTime}}</font>
                </el-form-item> 
                <el-form-item label="是否解决:" prop="actualTime">
                  <font>{{form.actualTime}}</font>
                </el-form-item>  
            </el-form>
          </div>
         
        </div>
        
        <div style="width: 100%;">
          <el-button
          size="medium"
          type="text"
          icon="el-icon-back"
          @click="$router.go(-1)"
        >返回</el-button>
      </div>
    </div>   
    </div>
  </template>
  
  <script>
   
  import { listBasicsInfo, getBasicsInfo, delBasicsInfo, addBasicsInfo, updateBasicsInfo, exportBasicsInfo } from "@/api/workOrder/basicsInfo";
  import gaodeMap from "utils/gaodeMap.js"
  import {map} from "utils/gaodeMap.js"
export default {
    name: "BasicsInfo",
    components: {
    },
    data() {
      return {
        dialogImageUrl: '',
        dialogVisible: false,
        disabled: false,
        imageUrl: '',
        // 遮罩层
        loading: true,
        // 导出遮罩层
        exportLoading: false,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 工单基础信息表格数据
        basicsInfoList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 工单状态字典
        typeOptions: [],
        pickerOptions:[],
        // 工单类型字典
        ordertypeOptions: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          orderType: null,
          orderName: null,
          orderStatus: null,
          appointInspector: null,
          allotTime: null,
          actualInspector: null,
          actualTime: null,
          remarks: null
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {
        },
        active : 0,
        orderId : ""
      };
    },
    created() {
      // 如果是跳转来的，则接受初始化参数
      // this.user_id = this.$route.query.id; //详细信息页接收参数
      console.log(this.$route.query.orderId,"12234==========")
      this.orderId = this.$route.query.orderId;
      
      this.getList();
      this.getDicts("t_order_status").then(response => {
        this.typeOptions = response.data;
      });
      this.getDicts("t_order_type").then(response => {
        this.ordertypeOptions = response.data;
      });
      this.getBasicsInfo();
    },
    mounted(){
     let map =  new gaodeMap("平山"); 

    },
    methods: {
      handleRemove(file) {
        console.log(file);
      },
      handlePictureCardPreview(file) {
        this.dialogImageUrl = file.url;
        this.dialogVisible = true;
      },
      handleDownload(file) {
        console.log(file);
      },
      /** 查询工单基础信息列表 */
      getList() {
        this.loading = true;
        listBasicsInfo(this.queryParams).then(response => {
          this.basicsInfoList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      getBasicsInfo (){
        getBasicsInfo(this.orderId).then(response =>{
          this.form = response.data;
          this.active = parseInt(response.data.orderStatus) + 1;
console.log("response.data",response.data)
        });

      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          orderId: null,
          orderType: null,
          orderName: null,
          orderStatus: "0",
          createTime: null,
          appointInspector: null,
          allotTime: null,
          actualInspector: null,
          actualTime: null,
          remarks: null
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.orderId)
        this.single = selection.length!==1
        this.multiple = !selection.length
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.open = true;
        this.title = "添加工单基础信息";
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.reset();
        const orderId = row.orderId || this.ids
        getBasicsInfo(orderId).then(response => {
          this.form = response.data;
          this.open = true;
          this.title = "修改工单基础信息";
        });
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["form"].validate(valid => {
          if (valid) {
            if (this.form.orderId != null) {
              updateBasicsInfo(this.form).then(response => {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              });
            } else {
              addBasicsInfo(this.form).then(response => {
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              });
            }
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const orderIds = row.orderId || this.ids;
        this.$confirm('是否确认删除工单基础信息编号为"' + orderIds + '"的数据项?', "警告", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning"
          }).then(function() {
            return delBasicsInfo(orderIds);
          }).then(() => {
            this.getList();
            this.msgSuccess("删除成功");
          }).catch(() => {});
      },
      /** 导出按钮操作 */
      handleExport() {
        const queryParams = this.queryParams;
        this.$confirm('是否确认导出所有工单基础信息数据项?', "警告", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning"
          }).then(() => {
            this.exportLoading = true;
            return exportBasicsInfo(queryParams);
          }).then(response => {
            this.download(response.msg);
            this.exportLoading = false;
          }).catch(() => {});
      }
    }
  }
  </script>
  <style>
    .detail .el-form{
        width: 20%;
    }
    .detail .el-form-item{
        margin-bottom: 0px;
    }
    .avatar-uploader{
        width: 25%;
        float: left;
    }
    .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
  li{
    font-size: 15px;
    font-weight: 900;
  }
  </style>