<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="sellDetailId"  class="is-required">
            <el-input v-model="temp.sellDetailId" placeholder="销售细单id" />
          </el-form-item>

          <el-form-item label="会员id" prop="memberId"  class="is-required">
            <el-input v-model="temp.memberId" placeholder="会员id" />
          </el-form-item>

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

          <el-form-item label="1开卡 2续卡 3项目 4商品" prop="sellType"  class="is-required">
            <el-input v-model="temp.sellType" placeholder="1开卡 2续卡 3项目 4商品" />
          </el-form-item>

          <el-form-item label="会员卡id" prop="memberCardId"  class="is-required">
            <el-input v-model="temp.memberCardId" placeholder="会员卡id" />
          </el-form-item>

          <el-form-item label="商品ID" prop="productId"  class="is-required">
            <el-input v-model="temp.productId" placeholder="商品ID" />
          </el-form-item>

          <el-form-item label="商品名" prop="productName"  class="is-required">
            <el-input v-model="temp.productName" placeholder="商品名" />
          </el-form-item>

          <el-form-item label="商品数量" prop="count"  class="is-required">
            <el-input v-model="temp.count" placeholder="商品数量" />
          </el-form-item>

          <el-form-item label="折扣" prop="discount"  class="is-required">
            <el-input v-model="temp.discount" placeholder="折扣" />
          </el-form-item>

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

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

          <el-form-item label="卡项ID" prop="cardId"  class="is-required">
            <el-input v-model="temp.cardId" placeholder="卡项ID" />
          </el-form-item>

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

          <el-form-item label="赠送金额" prop="giveAmount"  class="is-required">
            <el-input v-model="temp.giveAmount" placeholder="赠送金额" />
          </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="0正常 1取消" prop="sellStatus"  class="is-required">
            <el-input v-model="temp.sellStatus" 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 {addSellDetail} from "@/api/business/sellDetail/sellDetail";
import {setRequiredFields} from "@/utils";
const requiredFields = []
export default {
  name: "addForm",
  data() {
    return {
      rules: setRequiredFields(requiredFields),
      dialogVisible: false,
      temp: {
        sellDetailId:'',
        memberId:'',
        sellId:'',
        sellType:'',
        memberCardId:'',
        productId:'',
        productName:'',
        count:'',
        discount:'',
        amount:'',
        realAmount:'',
        cardId:'',
        cardName:'',
        giveAmount:'',
        shopId:'',
        shopName:'',
        createName:'',
        createTime:'',
        createId:'',
        updateTime:'',
        updateName:'',
        updateId:'',
        sellStatus:'',
      },
    }
  },
  methods: {
    open() {
      this.dialogVisible = true
    },
    submit() {
      this.$refs['dataForm'].validate((valid) => {
        if (valid) {
          addSellDetail(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>
