<template>
  <view>
	   
    <u-popup v-model="isShow" mode="left" :border-radius="10" :closeable="true" @close="fnCancel" width="100%" height="100%">
		<u-row gutter="12">
		  <u-col span="12">
		    <view :style="{ textAlign: 'center', height: '60px', lineHeight: '60px' }">
		      <text :style="{ fontSize: '40rpx', fontWeight: 500, color: '#1D2129' }">待修设备</text>
		    </view>
		  </u-col>
		  <u-col span="12">
      <u-form :model="dataItem" :rules="rules" ref="dataItem" :errorType="['toast']" label-position="left" label-width="250" label-align="center">
        <u-form-item label="设备编号" prop="text">
          <text>{{ dataItem.eqmtNo }}</text>
        </u-form-item>
        <u-form-item label="设备名称" prop="text">
          <text>{{ dataItem.eqmtName }}</text>
        </u-form-item>
        <u-form-item label="品牌型号" prop="text" >
          <text>{{ dataItem.specName }}</text>
        </u-form-item>
        <u-form-item label="报修人员" prop="text" >
          <text>{{ dataItem.reportUserName }}</text>
        </u-form-item>
        <u-form-item label="报修时间" prop="text" >
          <text>{{ fnFormat(dataItem.reportTime) }}</text>
        </u-form-item>
        <u-form-item label="维修结果" prop="radio" required >
          <u-radio-group v-model="dataItem.repairResult">
            <u-radio v-for="(item, index) in radioList" :key="index" :name="item.id">{{ item.fullName }} </u-radio>
          </u-radio-group>
        </u-form-item>
        <u-form-item label="维修完成时间" prop="date" label-width="250" required >
          <jnpf-date-time type="date" v-model="dataItem.repairFinishTime" format="yyyy-MM-dd"></jnpf-date-time>
        </u-form-item>
      </u-form>
	  </u-col>
	  </u-row>
      <view class="buttom-actions">
        <u-button class="buttom-btn" @click="jnpf.goBack">取消</u-button>
        <u-button class="buttom-btn" type="primary" @click="fnOk">保存</u-button>
        <!-- <u-button class="buttom-btn" type="warning" @click="submit">保存草稿</u-button> -->
      </view>
    </u-popup>
    <u-top-tips ref="uTips"></u-top-tips>
  </view>
</template>

<script>
  import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js'
  import { mapGetters } from 'vuex'
  import { fix } from '@/api/yys/eqmt.js'
  import dayjs from 'dayjs'
  export default {
    components: {},
    mixins: [],
    data() {
      return {
        isShow: false,
        dataItem: {},
        reportMemberList: [],
        text: '设备编号',
        rules: {
          // radio: [{
          // 	required: true,
          // 	message: '请选择任意一种单选',
          // 	trigger: 'change'
          // }],
          // time: [{
          // 	required: true,
          // 	message: '请选择时间',
          // 	trigger: 'change',
          // }],
          // date: [{
          // 	required: true,
          // 	message: '请选择日期',
          // 	trigger: 'change',
          // 	type: 'number'
          // }],
        },
        radioList: [
          {
            fullName: '维修后正常',
            id: '1',
          },
          {
            fullName: '暂时无法修复',
            id: '0',
          },
        ],
        treeData: [],
      }
    },
    watch: {},
    computed: {},
    onLoad(params) {},
    onUnload() {},
    methods: {
      init(dataItem) {
        // this.fnReportMemberList();
        this.dataItem = dataItem
        switch (this.dataItem.groupType) {
          case '1':
            this.dataItem.qualifiedNum = this.dataItem.prodReportList[0]['qualifiedNum']
            this.dataItem.qualifiedNum = this.dataItem.prodReportList[0]['qualifiedNum']
            break
          case '2':
            this.dataItem.defectiveNum = this.dataItem.packageReportList[0]['defectiveNum']
            this.dataItem.qualifiedNum = this.dataItem.packageReportList[0]['qualifiedNum']
            break
          default:
            break
        }
        this.isShow = true
      },
      fnCancel() {
        this.dataItem = {}
        this.isShow = false
      },
      fnOk() {
        if (!this.dataItem.repairResult) {
          uni.showToast({
            title: '请选择维修结果',
            icon: 'none',
          })
          return
        }
		if (!this.dataItem.repairFinishTime) {
		  uni.showToast({
		    title: '请选择维修完成时间',
		    icon: 'none',
		  })
		  return
		}
        this.dataItem.eqmtNo = this.dataItem.eqmtNo
        let _params = {
          ...this.dataItem,
        }
        console.log(_params)
        fix(_params)
          .then(res => {
            if (res.code == 200) {
              this.$emit('evtRefresh')
            }
          })
          .catch(err => {
            console.log(err)
          })
        this.fnCancel()
      },
      fnFormat(time, fmtStr = 'YYYY-MM-DD') {
        return dayjs(time).format(fmtStr)
      },
    },
  }
</script>

<style lang="scss" scoped>
  /deep/.u-th {
    width: 100%;
    height: 32px;
  }
  /deep/.u-td {
    width: 100%;
    height: 32px;
  }
</style>
