<!--
 * @Author: zhp
 * @Date: 2023-11-06 15:15:30
 * @LastEditTime: 2023-11-07 19:38:13
 * @LastEditors: zhp
 * @Description:
-->
<template>
  <el-dialog :visible.sync="dialogVisible" width="50%" :before-close="handleClose">
    <small-title slot="title" :no-padding="true">
      {{ '详情' }}
    </small-title>
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()"
      label-width="auto">
      <el-row :gutter="24">
        <el-col :span="8">
          <el-form-item label="工单号" prop="workOrderId">
            <el-select v-model="dataForm.workOrderId" placeholder="请选择工单号" disabled>
              <el-option v-for="dict in workOrderList" :key="dict.id" :label="dict.name" :value="dict.id" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="班组" prop="teamId">
            <el-select v-model="dataForm.teamId" placeholder="请选择班组" disabled>
              <el-option v-for="dict in teamList" :key="dict.id" :label="dict.name" :value="dict.id" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="数量" prop="sum">
            <el-input v-model="dataForm.sum" placeholder="请输入数量" disabled />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="产线" prop="lineId">
            <el-select v-model="dataForm.lineId" placeholder="请选择产线" disabled>
              <el-option v-for="dict in lineList" :key="dict.id" :label="dict.name" :value="dict.id" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="报废原因" prop="detId">
            <el-select v-model="dataForm.detId" placeholder="请选择报废原因" disabled>
              <el-option v-for="dict in detList" :key="dict.id" :label="dict.name" :value="dict.id" />
            </el-select>
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="报废时间" prop="logTime">
            <el-date-picker v-model="dataForm.logTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" disabled
              placeholder="选择日期">
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="来源" prop="source">
            <el-select v-model="dataForm.source" placeholder="请选择来源" disabled>
              <el-option v-for="dict in sourceList" :key="dict.id" :label="dict.name" :value="dict.id" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="描述" prop="description">
            <el-input v-model="dataForm.description" placeholder="请输入描述" disabled />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="备注" prop="remark">
            <el-input v-model="dataForm.remark" placeholder="备注" disabled />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </el-dialog>

</template>

<script>
import basicAdd from '../../../core/mixins/basic-add';
import {
  createQualityScrapLog, updateQualityScrapLog, getQualityScrapLog, getWorkOrderList,
  getTeamList, getDetList,getLineList } from "@/api/base/qualityScrapLog";
import { getList,} from "@/api/base/qualityScrapType";
import SmallTitle from './SmallTitle';
export default {
  components: {
    SmallTitle,
  },
	mixins: [basicAdd],
	data() {
		return {
			urlOptions: {
			  isGetCode: false,
        // codeURL: getCode,
        createURL: createQualityScrapLog,
        updateURL: updateQualityScrapLog,
        infoURL: getQualityScrapLog,
      },
      lineList:[],
      typeList: [],
      workOrderList: [],
      detList:[],
      teamList: [],
      sourceList: [
        {
          id: 1,
          name: '手动',
        },
        {
          id: 2,
          name: '自动',
        }
      ],
      dialogVisible:false,
			dataForm: {
        id: undefined,
        logTime: undefined,
        source:1,
        detId: undefined,
        workOrderId: null,
        teamId: undefined,
        num: undefined,
        lineId:undefined,
        description:undefined,
        // description: undefined,
        remark: undefined,
			},
			// materialList: [],
			dataRule: {
				// materialId: [{ required: true, message: "", trigger: "blur" }],
        workOrderId: [{ required: true, message: "工单号不能为空", trigger: "change" }],
        num: [{ required: true, message: "数量不能为空", trigger: "blur" }],
        detId: [{ required: true, message: "报废原因不能为空", trigger: "change" }],

        logTime: [{ required: true, message: "报废时间不能为空", trigger: "change" }],
      }
		};
	},
	mounted() {
		// this.getDict()
    console.log('我看看', this.dataForm)
    this.getCurrentTime()
	},
  methods: {
    init() {
      this.dialogVisible = true
    },
    getCurrentTime() {
      // new Date().Format("yyyy-MM-dd HH:mm:ss")
      this.dataForm.logTime = new Date()
      // this.dataForm.logTime = year + "-" + month + "-" + day;
      console.log(this.dataForm.logTime);
    },
		// async getDict() {
		// 	// 物料列表
    //   const res = await getList()
    //   this.typeList = res.data
    //   getWorkOrderList().then((res) => {
    //     console.log(res);
    //     // console.log(response);
    //     this.workOrderList = res.data.map((item) => {
    //       return {
    //         name: item.name,
    //         id: item.id
    //       }
    //     })
    //     // console.log(this.formConfig[0].selectOptions);
    //     // this.listQuery.total = response.data.total;
    //   })
    //   getLineList().then((res) => {
    //     console.log(res);
    //     // console.log(response);
    //     this.lineList = res.data.map((item) => {
    //       return {
    //         name: item.name,
    //         id: item.id
    //       }
    //     })
    //     // console.log(this.formConfig[0].selectOptions);
    //     // this.listQuery.total = response.data.total;
    //   })
    //   getDetList().then((res) => {
    //     console.log(res);
    //     // console.log(response);
    //     this.workOrderList = res.data.map((item) => {
    //       return {
    //         name: item.name,
    //         id: item.id
    //       }
    //     })
    //     // console.log(this.formConfig[0].selectOptions);
    //     // this.listQuery.total = response.data.total;
    //   })
    //   getTeamList().then((res) => {
    //     console.log(res);
    //     // console.log(response);
    //     this.teamList = res.data.map((item) => {
    //       return {
    //         name: item.name,
    //         id: item.id
    //       }
    //     })
    //     // console.log(this.formConfig[0].selectOptions);
    //     // this.listQuery.total = response.data.total;
    //   })
		// },
		// setMaterialCode() {
		// 	const chooseM = this.materialList.filter(item => {
		// 		return item.id === this.dataForm.materialId
		// 	})
		// 	this.dataForm.materialCode = chooseM[0].code
		// }
	},
};
</script>
