<template>
  <view>
    <cu-custom bgColor="bg-gradual-blueness" :isBack="true">
      <block slot="backText">返回</block>
      <block slot="content">作业信息</block>
    </cu-custom>
    <view class="form">
      <view class="wui-form-list">
        <view class="cu-form-group">
          <view class="title">编号：</view>
          {{ form.NUMBERING }}
        </view>
        <view class="cu-form-group">
          <view class="title">吊装地点：</view>
          {{ form.HOISTING_LOCATION }}
        </view>
        <view class="cu-form-group">
          <view class="title">吊装机具：</view>
          {{ form.HOISTING_EQUIPMENT }}
        </view>
        <view class="cu-form-group">
          <view class="title">吊装作业负责人部门：</view>
          {{ form.LIFTING_OPERATION_MANAGER_DEPARTMENT_NAME }}
        </view>
        <view class="cu-form-group">
          <view class="title">吊装作业负责人：</view>
          {{ form.LIFTING_OPERATION_MANAGER_NAME }}
        </view>
        <view class="cu-form-group">
          <view class="title">安全监护人部门：</view>
          {{ form.SAFETY_GUARDIAN_DEPARTMENT_NAME }}
        </view>
        <view class="cu-form-group">
          <view class="title">安全监护人：</view>
          {{ form.SAFETY_GUARDIAN_NAME }}
        </view>
        <view class="cu-form-group">
          <view class="title">起重司机：</view>
        </view>
        <view class="cu-form-group">
          <uni-table border stripe emptyText="暂无更多数据" style="flex:1;margin: 20upx 0">
            <uni-tr>
              <uni-td>姓名</uni-td>
              <uni-td>作业证号</uni-td>
            </uni-tr>
            <uni-tr v-for="(item,index) in form.CRANE_DRIVER_NAME" :key="item">
              <uni-td>{{ form.CRANE_DRIVER_NAME[index] }}</uni-td>
              <uni-td>{{ form.CRANE_DRIVER_NUMBER[index] }}</uni-td>
            </uni-tr>
          </uni-table>
        </view>
        <view class="cu-form-group">
          <view class="title">作业开始时间：</view>
          {{ form.JOB_START_TIME }}
        </view>
        <view class="cu-form-group">
          <view class="title">作业结束时间：</view>
          {{ form.JOB_END_TIME }}
        </view>
        <view class="cu-form-group">
          <view class="title">指挥工：</view>
          {{ form.COMMANDER_NAME }}
        </view>
        <view class="cu-form-group">
          <view class="title">吊装作业内容：</view>
          {{ form.HOISTING_WORK_CONTENT }}
        </view>
        <view class="cu-form-group">
          <view class="title">起吊重物质量（吨）：</view>
          {{ form.LIFTING_WEIGHT }}
        </view>
        <view class="cu-form-group" v-if="form.WORK_LONGITUDE">
          <view class="title">作业地点经度：</view>
          <view>{{form.WORK_LONGITUDE}}</view>
        </view>
        <view class="cu-form-group" v-if="form.WORK_LATITUDE">
          <view class="title">作业地点纬度：</view>
          <view>{{form.WORK_LATITUDE}}</view>
        </view>
        <view style="padding: 20upx">
          <uni-table border stripe emptyText="暂无更多数据">
            <uni-tr>
              <uni-th align="center" style="font-weight: bold;width: 100upx">序号</uni-th>
              <uni-th align="center" style="font-weight: bold">安全措施</uni-th>
              <uni-th align="center" style="font-weight: bold;width: 180upx">操作</uni-th>
            </uni-tr>
            <uni-tr v-for="(item,index) in measuresList" :key="item.PROTECTIVE_MEASURES">
              <uni-td>{{ index + 1 }}</uni-td>
              <uni-td>{{ item.PROTECTIVE_MEASURES }}</uni-td>
              <uni-td>{{ item.STATUS == 1 ? '符合' : '不符合' }} </uni-td>
            </uni-tr>
          </uni-table>
        </view>
        <view class="cu-form-group">
          <view class="title">补充措施：</view>
        </view>
        <view class="ace-content" v-show="oldSupplementaryMeasures && oldSupplementaryMeasures.length > 0">
          <view class="add_pard_item" v-for="(item,index) of oldSupplementaryMeasures" :key="index">
            <view class="cu-form-textarea">
              <textarea disabled v-model="oldSupplementaryMeasures[index]"></textarea>
            </view>
          </view>
        </view>
        <view class="cu-form-textarea">
          <view class="cu-form-title">作业负责人意见:</view>
          <textarea v-model="form.CONSTRUCTION_JOB_MANAGER_OPINION" disabled placeholder="请输入作业负责人意见"></textarea>
        </view>
        <view class="cu-form-group">
          <view class="title">作业负责人签字：</view>
          <view>
            <view>
              <image :src="baseImgPath + form.CONSTRUCTION_JOB_MANAGER_SIGNER_PATH" style="width: 330upx;height: 260upx"></image>
            </view>
            <view style="text-align: center">{{form.CONSTRUCTION_JOB_MANAGER_SIGNER_TIME}}</view>
          </view>
        </view>
        <view class="cu-form-textarea">
          <view class="cu-form-title">作业单位负责人意见:</view>
          <textarea v-model="form.WORK_UNIT_MANAGER_OPINION" disabled placeholder="请输入作业单位负责人意见"></textarea>
        </view>
        <view class="cu-form-group">
          <view class="title">作业单位负责人签字：</view>
          <view>
            <view>
              <image :src="baseImgPath + form.WORK_UNIT_MANAGER_SIGNER_PATH" style="width: 330upx;height: 260upx"></image>
            </view>
            <view style="text-align: center">{{form.WORK_UNIT_MANAGER_SIGNER_TIME}}</view>
          </view>
        </view>
        <view class="cu-form-textarea">
          <view class="cu-form-title">分公司（中心）审批意见:</view>
          <textarea v-model="form.BRANCH_APPROVER_OPINION" disabled placeholder="请输入分公司（中心）审批意见"></textarea>
        </view>
        <view class="cu-form-group">
          <view class="title">分公司（中心）审批签字：</view>
          <view>
            <view>
              <image :src="baseImgPath + form.BRANCH_APPROVER_SIGNER_PATH" style="width: 330upx;height: 260upx"></image>
            </view>
            <view style="text-align: center">{{form.BRANCH_APPROVER_SIGNER_TIME}}</view>
          </view>
        </view>
      </view>
    </view>
    <view class="cu-bar btn-group" style="margin-top: 30upx;">
      <button class="cu-btn bg-blue margin-tb-sm lg" @click="$noMultipleClicks(goback)">返回</button>
    </view>
    <view class="padding flex flex-direction"></view>
  </view>
</template>

<script>
import {
  basePath,
  loginSession,
  baseImgPath,
  loginUser,
  formatDate
} from '@/common/tool.js';

export default {
  data() {
    return {
      baseImgPath,
      noClick: true,
      form: {
        HOISTING_ID: '',
        APPLY_DEPARTMENT_ID: '',
        APPLY_DEPARTMENT_NAME: '',
        APPLY_USER_ID: '',
        APPLY_USER_NAME: '',
        NUMBERING: '',
        HOISTING_LOCATION: '',
        HOISTING_EQUIPMENT: '',
        LIFTING_OPERATION_MANAGER_DEPARTMENT_NAME: '',
        LIFTING_OPERATION_MANAGER_DEPARTMENT_ID: '',
        LIFTING_OPERATION_MANAGER_NAME: '',
        LIFTING_OPERATION_MANAGER_INDEX: '',
        LIFTING_OPERATION_MANAGER_ID: '',
        SAFETY_GUARDIAN_DEPARTMENT_NAME: '',
        SAFETY_GUARDIAN_DEPARTMENT_ID: '',
        SAFETY_GUARDIAN_NAME: '',
        SAFETY_GUARDIAN_INDEX: '',
        SAFETY_GUARDIAN_ID: '',
        CRANE_DRIVER_NAME: [],
        CRANE_DRIVER_ID: [],
        CRANE_DRIVER_NUMBER: [],
        JOB_START_TIME: '',
        JOB_END_TIME: '',
        COMMANDER_INDEX: '',
        COMMANDER_NAME: '',
        COMMANDER_ID: '',
        HOISTING_WORK_CONTENT: '',
        LIFTING_WEIGHT: '',
        CONSTRUCTION_JOB_MANAGER_DEPARTMENT_NAME: '',
        CONSTRUCTION_JOB_MANAGER_DEPARTMENT_ID: '',
        CONSTRUCTION_JOB_MANAGER_INDEX: '',
        CONSTRUCTION_JOB_MANAGER_NAME: '',
        CONSTRUCTION_JOB_MANAGER_ID: '',
        WORK_UNIT_MANAGER_DEPARTMENT_NAME: '',
        WORK_UNIT_MANAGER_DEPARTMENT_ID: '',
        WORK_UNIT_MANAGER_NAME: '',
        WORK_UNIT_MANAGER_INDEX: '',
        WORK_UNIT_MANAGER_ID: '',
        BRANCH_APPROVER_DEPARTMENT_NAME: '',
        BRANCH_APPROVER_DEPARTMENT_ID: '',
        BRANCH_APPROVER_NAME: '',
        BRANCH_APPROVER_INDEX: '',
        BRANCH_APPROVER_ID: '',
        WORK_LONGITUDE: '',
        WORK_LATITUDE: '',
        OTHER_PROTECTIVE_MEASURES: ''
      },
      measuresList: [],
      oldSupplementaryMeasures: [],
      SupplementaryMeasures: [],
      imgList: [],
      modalShow: false,
    }
  },
  onLoad(event) {
    this.form.HOISTING_ID = event.id
    this.getData();
    loginSession();
  },
  methods: {
    getData() {
      var _this = this;
      uni.showLoading({
        title: '请稍候'
      })
      uni.request({
        url: basePath + '/app/hoisting/goEdit',
        method: 'POST',
        header: {
          'Content-type': 'application/x-www-form-urlencoded'
        },
        data: {
          HOISTING_ID: _this.form.HOISTING_ID,
        },
        success: (res) => {
          if ("success" == res.data.result) {
            _this.form = Object.assign(_this.form, res.data.pd);
            _this.measuresList = res.data.measuresList
            if (!_this.form.CRANE_DRIVER_ID) {
              _this.$set( _this.form, 'CRANE_DRIVER_ID', [] )
            } else {
              _this.form.CRANE_DRIVER_ID = _this.form.CRANE_DRIVER_ID.split(',')
            }
            if (!_this.form.CRANE_DRIVER_NAME) {
              _this.$set( _this.form, 'CRANE_DRIVER_NAME', [] )
            } else {
              _this.form.CRANE_DRIVER_NAME = _this.form.CRANE_DRIVER_NAME.split(',')
            }
            if (!_this.form.CRANE_DRIVER_NUMBER) {
              _this.$set( _this.form, 'CRANE_DRIVER_NUMBER', [] )
            } else {
              _this.form.CRANE_DRIVER_NUMBER = _this.form.CRANE_DRIVER_NUMBER.split(',')
            }
            if (_this.form.OTHER_PROTECTIVE_MEASURES) {
              this.oldSupplementaryMeasures = _this.form.OTHER_PROTECTIVE_MEASURES.split(';_;')
            }
            this.forbidEdit = true;
            uni.hideLoading();
          } else if ("exception" == res.data.result) {
            uni.showToast({
              title: '错误',
              duration: 2000
            });
          }
        }
      });
    },
    goback() {
      uni.navigateBack({
        delta: 1
      });
      uni.hideLoading();
    },
  }
}
</script>

<style>
.right_icon {
  position: relative;
  padding-right: 36upx;
  width: 200upx;
  text-align: right;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.right_icon ::after {
  font-family: cuIcon;
  display: block;
  content: "\e6a3";
  position: absolute;
  font-size: 17px;
  color: #8799a3;
  line-height: 50px;
  width: 30px;
  text-align: center;
  top: -28upx;
  bottom: 0;
  right: -22upx;
  margin: auto;
}

.modal_content {
  display: flex;
  text-align: left;
}

.modal_left {
  flex-basis: 50%;
  padding: 50upx 20upx;
  border-right: 1px solid #000000;
}

.modal_right {
  flex-basis: 50%;
  padding: 50upx;
}

.modal_left_title, .modal_right_title {
  font-size: 16px;
  color: #000000;
  font-weight: 700;
}

.checkbox-item {
  display: flex;
  align-items: center;
  padding: 0 30upx;
  min-height: 100upx;
  background-color: #ffffff;
  border-bottom: 1upx solid #ddd;
}

.checkbox-item:last-child {
  border-bottom: none;
}
</style>
