<template>
  <div>
    <el-form :model="inputQuery" :rules="formRules" ref="dataForm" label-width="120px" border>
      <el-row type="flex">
        <el-col :span="11">
          <el-form-item label="单据类型名称" prop="originName">
            <el-input v-model="inputQuery.originName" :disabled="!isAdd" size="small" placeholder="请输入内容" style="width: 90%"></el-input>
          </el-form-item>
        </el-col>

        <el-col :span="11">
          <el-form-item label="单据类型代码" prop="originAction">
            <el-input v-model="inputQuery.originAction" :disabled="!isAdd" size="small" placeholder="请输入内容" style="width: 90%"></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row type="flex">
        <el-col :span="11">
          <el-form-item label="目标单据类型" prop="targetAction">
            <el-select v-model="inputQuery.targetAction" placeholder="请选择" clearable size="small" style="width: 90%">
              <el-option
                v-for="item in busTypes"
                :key="item.action"
                :label="item.name"
                :value="item.action">
                <span style="float: left"> {{item.name}}</span>
                <span style="float: right; color: #8492a6; font-size: 13px">{{item.action}}</span>
              </el-option>

            </el-select>
          </el-form-item>
        </el-col>

        <el-col :span="11">
          <el-form-item label="启用状态" prop="enable">
            <el-select v-model="inputQuery.enable"
                       size="small"
                       placeholder="启用状态"
                       style="width: 90%"
                       clearable
                       >
              <el-option label="启用" :value="true"></el-option>
              <el-option label="禁用" :value="false"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row type="flex">
        <el-col :span="11">
          <el-form-item label="类型">
            <el-select v-model="inputQuery.type"
                       size="small"
                       placeholder="类型"
                       style="width: 90%"
                       clearable
            >
              <el-option label="耗材领用" :value="1"></el-option>
              <el-option label="产品申购" :value="2"></el-option>
              <el-option label="采购计划" :value="3"></el-option>
              <el-option label="盘点转单" :value="4"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row type="flex">
        <el-col :span="23" type="flex">
          <el-form-item prop="comments">
            <label slot="label">备&emsp;&emsp;注</label>
            <el-input v-model="inputQuery.remark" size="small" style="width: 90%" type="textarea"
                      row="3"></el-input>
          </el-form-item>
        </el-col>
      </el-row>

    </el-form>
  </div>
</template>

<script>

import {getBusTypeList} from "@/api/basic/busType";

export default {
  name: "BusTypePreModify",
  props: {
    inputQuery: {
      type: Object,
      required: true,
    },
  },

  data() {
    return {
      filterQuery: {
        enabled: true,
        isBuType: true,
      },
      busTypes: [],
      isAdd: false,
      formRules: {
        originName: [
          {
            required: true,
            message: "单据类型名称不能为空",
            trigger: "blur"
          }
        ],
        originAction: [
          {
            required: true,
            message: "单据类型代码不能为空",
            trigger: "blur"
          }
        ],
        targetAction: [
          {
            required: true,
            message: "目标单据类型不能为空",
            trigger: "blur"
          }
        ],
        enable: [
          {
            required: true,
            message: "请选择启用状态",
            trigger: "blur"
          }
        ],
        type: [
          {
            required: true,
            message: "请选择类型",
            trigger: "blur"
          }
        ],
      },
      typeMap: {
        1: "耗材领用",
        2: "产品申购",
        3: "采购计划",
        4: "盘点转单"
      },
    }
  },
  methods: {
    getBusType() {
      let params = {
        enable: true
      };
      getBusTypeList(params).then((res) => {
        if (res.code === 20000) {
          this.busTypes = res.data.list || [];
        }
      })
    }
  },

  created() {
    if (this.inputQuery.originAction == null) {
      this.isAdd = true;
    }
    this.getBusType();
  }
}
</script>

<style scoped>

</style>
