<template>
  <div>
    <el-dialog
      :close-on-click-modal="false"
      top="8vh"
      width="40%"
      :visible.sync="dialogVisible"
      center
      @close="handleCancel"
    >
      <div class="el-dialog-div">
      <el-form
        :rules="rules"
        ref="dataForm"
        :model="temp"
        label-position="right"
        label-width="120px"
        style="height: 90%;"
      >

                <el-form-item label="库存单id" prop="stockId" class="is-required">
          <el-input v-model="temp.stockId" placeholder="库存单id" />
        </el-form-item>

        <el-form-item label="库存单表头" prop="stockTitle" class="is-required">
          <el-input v-model="temp.stockTitle" placeholder="库存单表头" />
        </el-form-item>

        <el-form-item label="库存单编号" prop="stockNo" class="is-required">
          <el-input v-model="temp.stockNo" placeholder="库存单编号" />
        </el-form-item>

        <el-form-item label="0正常 1审核完毕 2取消" prop="stockStatus" class="is-required">
          <el-input v-model="temp.stockStatus" placeholder="0正常 1审核完毕 2取消" />
        </el-form-item>

        <el-form-item label="门店id" prop="shopId" class="is-required">
          <el-input v-model="temp.shopId" placeholder="门店id" />
        </el-form-item>

        <el-form-item label="门店名" prop="shopName" class="is-required">
          <el-input v-model="temp.shopName" placeholder="门店名" />
        </el-form-item>

        <el-form-item label="创建人" prop="createName" class="is-required">
          <el-input v-model="temp.createName" placeholder="创建人" />
        </el-form-item>

        <el-form-item label="创建时间" prop="createTime" class="is-required">
          <el-input v-model="temp.createTime" placeholder="创建时间" />
        </el-form-item>

        <el-form-item label="创建人id" prop="createId" class="is-required">
          <el-input v-model="temp.createId" placeholder="创建人id" />
        </el-form-item>

        <el-form-item label="修改时间" prop="updateTime" class="is-required">
          <el-input v-model="temp.updateTime" placeholder="修改时间" />
        </el-form-item>

        <el-form-item label="修改人" prop="updateName" class="is-required">
          <el-input v-model="temp.updateName" placeholder="修改人" />
        </el-form-item>

        <el-form-item label="修改人id" prop="updateId" class="is-required">
          <el-input v-model="temp.updateId" placeholder="修改人id" />
        </el-form-item>

        <el-form-item label="审核人ID" prop="checkId" class="is-required">
          <el-input v-model="temp.checkId" placeholder="审核人ID" />
        </el-form-item>

        <el-form-item label="审核人姓名" prop="checkName" class="is-required">
          <el-input v-model="temp.checkName" placeholder="审核人姓名" />
        </el-form-item>

        <el-form-item label="审核时间" prop="checkTime" class="is-required">
          <el-input v-model="temp.checkTime" placeholder="审核时间" />
        </el-form-item>

        <el-form-item label="类型 1入库 2出库" prop="stockType" class="is-required">
          <el-input v-model="temp.stockType" placeholder="类型 1入库 2出库" />
        </el-form-item>

        <el-form-item label="金额" prop="stockMoney" class="is-required">
          <el-input v-model="temp.stockMoney" placeholder="金额" />
        </el-form-item>

        <el-form-item label="入库类型" prop="stockInType" class="is-required">
          <el-input v-model="temp.stockInType" placeholder="入库类型" />
        </el-form-item>

        <el-form-item label="出库类型" prop="stockOutType" class="is-required">
          <el-input v-model="temp.stockOutType" placeholder="出库类型" />
        </el-form-item>

        <el-form-item label="乐观锁字段" prop="version" class="is-required">
          <el-input v-model="temp.version" placeholder="乐观锁字段" />
        </el-form-item>

        <el-form-item label="0正常 1删除" prop="deleted" class="is-required">
          <el-input v-model="temp.deleted" placeholder="0正常 1删除" />
        </el-form-item>

      </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="handleCancel">取 消</el-button>
        <el-button type="primary" @click="submit">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { editStock } from "@/api/business/stock/stock";
import {setRequiredFields} from "@/utils";
const requiredFields = []

export default {
  name: "editForm",
  data() {
    return {
      rules: setRequiredFields(requiredFields),
      dialogVisible: false,
      temp: {
        stockId:'',
        stockTitle:'',
        stockNo:'',
        stockStatus:'',
        shopId:'',
        shopName:'',
        createName:'',
        createTime:'',
        createId:'',
        updateTime:'',
        updateName:'',
        updateId:'',
        checkId:'',
        checkName:'',
        checkTime:'',
        stockType:'',
        stockMoney:'',
        stockInType:'',
        stockOutType:'',
        version:'',
        deleted:'',
      },
    }
  },
  methods: {
    open(row) {
      this.temp = this.$options.data().temp
      this.temp = row
      this.dialogVisible = true
    },
    submit() {
      this.$refs['dataForm'].validate((valid) => {
        if (valid) {
          editStock(this.temp).then(response => {
            this.handleCancel()
            this.$emit('ok', response.data)
          })
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    handleCancel() {
      //初始化
      this.temp = this.$options.data().temp
      this.dialogVisible = false
      this.$refs['dataForm'].resetFields()
    }
  },
}
</script>

<style scoped>

</style>
