<template>
  <el-dialog
    width="800px"
    :visible.sync="dialogVisible"
    :show-close="false"
    @close="close"
    @open="open"
  >
    <span slot="title" class="dialog-footer">
      <div class="crud-opts2">
        <span class="el-dialog__title2">月计划修改</span>
        <span class="crud-opts-right2">
          <!--左侧插槽-->
          <slot name="left" />
          <el-button slot="left" type="info" @click="dialogVisible = false">关闭</el-button>
          <el-button slot="left" type="primary" @click="submit">保存</el-button>
        </span>
      </div>
    </span>
    <el-form ref="form" style="border: 1px solid #cfe0df;margin-top: 10px;padding-top: 10px;" :inline="true" :model="form" size="mini" label-width="120px" label-suffix=":">
      <el-form-item label="计划月份" prop="plan_code">
        <label slot="label">计划月份:</label>
        <el-input v-model.trim="form.plan_month" disabled clearable style="width: 210px" />
      </el-form-item>
      <el-form-item label="任务号" prop="task_code">
        <label slot="label">任务号:</label>
        <el-input v-model.trim="form.task_code" style="width: 210px" disabled />
      </el-form-item>
      <el-form-item label="申报单位" prop="plan_org_name">
        <label slot="label">申报单位:</label>
        <el-input v-model.trim="form.plan_org_name" style="width: 210px" disabled />
      </el-form-item>
      <el-form-item label="关键设备" prop="device_id">
        <label slot="label">关键设备:</label>
        <el-select
          v-model="form.device_id"
          size="mini"
          placeholder="关键设备"
          class="filter-item"
          style="width: 210px"
        >
          <el-option
            v-for="item in Devices"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          /></el-select>
      </el-form-item>
      <el-form-item label="交货日期" prop="plan_finish_date">
        <label slot="label">交货日期:</label>
        <el-input v-model.trim="form.plan_finish_date" style="width: 210px" disabled />
      </el-form-item>
      <el-form-item label="牌号" prop="old_mark">
        <label slot="label">牌号:</label>
        <el-input v-model.trim="form.old_mark" style="width: 210px" disabled />
      </el-form-item>
      <el-form-item label="物料编码" prop="material_code">
        <label slot="label">物料编码:</label>
        <el-input v-model.trim="form.material_code" style="width: 210px" disabled />
      </el-form-item>
      <el-form-item label="系列" prop="product_series">
        <el-select
          v-model="form.product_series"
          placeholder=""
          style="width: 210px"
          class="filter-item"
          disabled
        >
          <el-option
            v-for="item in XLList"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="生产重量Kg" prop="fact_weight">
        <label slot="label">生产重量Kg:</label>
        <el-input-number
          v-model="form.fact_weight"
          :controls="false"
          :precision="0"
          disabled
          style="width: 210px"
        />
      </el-form-item>
      <el-form-item label="每批重量Kg" prop="standard_weight">
        <label slot="label">每批重量Kg:</label>
        <el-input-number
          v-model="form.standard_weight"
          :controls="false"
          :precision="0"
          disabled
          style="width: 210px"
        />
      </el-form-item>
      <el-form-item label="状态" prop="is_proc">
        <el-select
          v-model="form.is_proc"
          placeholder=""
          style="width: 210px"
          class="filter-item"
          disabled
        >
          <el-option
            v-for="item in dict.is_proc2"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="提交人" prop="update_optname">
        <label slot="label">提交人:</label>
        <el-input v-model.trim="form.update_optname" style="width: 210px" disabled />
      </el-form-item>
      <el-form-item label="提交时间" prop="update_time">
        <label slot="label">提交时间:</label>
        <el-input v-model.trim="form.update_time" style="width: 210px" disabled />
      </el-form-item>
      <el-form-item label="备注" prop="remark">
        <label slot="label">备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注:</label>
        <el-input v-model.trim="form.remark" style="width: 480px;" rows="3" type="textarea" disabled />
      </el-form-item>
    </el-form>
  </el-dialog>
</template>

<script>

import crudseriesProcessRoute from '@/api/wms/pdm/seriesProcessRoute'
import workorder from '@/api/wms/pdm/workorder'
import producetask from '@/api/wms/pdm/producetask'

export default {
  name: 'AddDialog',
  components: { },
  props: {
    dialogShow: {
      type: Boolean,
      default: false
    },
    rowmst: {
      type: Object
    }
  },
  dicts: ['product_series', 'is_proc2'],
  data() {
    return {
      dialogVisible: false,
      fullscreenLoading: false,
      Depts: [],
      Devices: [],
      XLList: [],
      form: {}
    }
  },
  watch: {
    dialogShow: {
      handler(newValue) {
        this.dialogVisible = newValue
      }
    },
    rowmst: {
      handler(newValue) {
        this.form = newValue
      }
    }
  },
  created() {
    crudseriesProcessRoute.getXLlist2().then(res => {
      this.XLList = res
    })
    workorder.getDepts().then(res => {
      this.Depts = res
    })
  },
  methods: {
    open() {
      producetask.getDevices({ product_series_id: this.form.product_series }).then(res => {
        this.Devices = res
      })
    },
    close() {
      this.$emit('update:dialogShow', false)
      this.form = {}
      this.$emit('AddChanged')
    },
    submit() {
      producetask.submit3(this.form).then(res => {
        this.$emit('update:dialogShow', false)
        this.form = {}
        this.$emit('AddChanged')
      })
    }
  }
}
</script>

<style>
.crud-opts2 {
  padding: 0 0;
  display: -webkit-flex;
  display: flex;
  align-items: center;
}
.crud-opts2 .crud-opts-right2 {
  margin-left: auto;
  padding: 4px 4px;
}
.input-with-select  {
  background-color: #fff;
}
</style>
