<template>
  <nm-form-vuetify-drawer ref="form" v-bind="form" v-on="on" :parent="parent" :title="title" placement="left" :visible.sync="visible_">
    <v-text-field v-model="form.model.nId" label="编码" :rules="form.rules.nIdRules"></v-text-field>

    <v-text-field v-model="form.model.name" label="名称" :rules="form.rules.nameRules"></v-text-field>

    <v-text-field v-model="form.model.description" label="描述" :rules="form.rules.descriptionRules"></v-text-field>

    <v-text-field v-model="form.model.status" label="状态" :rules="form.rules.statusRules"></v-text-field>

    <!-- <v-text-field v-model="form.model.materialNId" label="物料编码" :rules="form.rules.materialNIdRules"></v-text-field> -->
    <nm-material-entitypicker v-model="form.model.materialNId" @materialinfo="materialinfos"></nm-material-entitypicker>

    <!-- <v-text-field v-model="form.model.materialRevision" label="物料修订" :rules="form.rules.materialRevisionRules"></v-text-field>

    <v-text-field v-model="form.model.materialUId" label="物料uid" :rules="form.rules.materialUIdRules"></v-text-field> -->

    <!-- <v-text-field v-model="form.model.templateNId" label="模板编码" :rules="form.rules.templateNIdRules"></v-text-field> -->
    <v-combobox
      v-model="form.model.templateNId"
      :rules="form.rules.templateNId"
      :items="templateData"
      item-disabled="disabled"
      item-text="name"
      item-value="nId"
      label="模板编码"
      :isMultiple="isMultiple"
      outlined
      disable-lookup
      clearable
      solo
      :return-object="returnObject"
    ></v-combobox>

    <v-text-field v-model="form.model.quantity" label="数量" :rules="form.rules.quantityRules"></v-text-field>
  </nm-form-vuetify-drawer>
</template>
<script>
import { mixins } from 'xmanager-ui'
const { add, edit, update } = $api.materialApp.materialLot

export default {
  mixins: [mixins.formSave],
  data() {
    return {
      title: '物料批次',
      actions: { add, edit, update },
      parent: this,
      form: {
        model: {
          /** 名称 */
          name: '',
          /** 描述 */
          description: '',
          /** 状态 */
          status: '',
          /** 编码 */
          nId: '',
          /** 物料编码 */
          materialNId: '',
          /** 物料修订 */
          materialRevision: '',
          /** 物料uid */
          materialUId: '',
          /** 模板编码 */
          templateNId: '',
          /** 数量 */
          quantity: '',
          /** 是否冻结 */
          isFrozen: false,
          /** 是否锁定 */
          isLocked: false
        },
        rules: {
          nameRules: [],
          descriptionRules: [],
          statusRules: [],
          nIdRules: [v => !!v || '编码 is required'],
          materialNIdRules: [],
          materialRevisionRules: [],
          materialUIdRules: [],
          templateNIdRules: [],
          quantityRules: [],
          isFrozenRules: [],
          isLockedRules: []
        }
      }
    }
  },
  methods: {
    materialinfos: function(val) {
      console.log(val)
      this.form.model.materialNId = val
    }
  }
}
</script>
