<!-- 搜索表单 -->
<template>
  <seekPage :seekList="seekList" :formLength="3" @search="search"></seekPage>
</template>
<script>
  import { getFactoryarea } from '@/api/saleOrder';
  export default {
    data() {
      return {
        statusList: [
          { label: '草稿', value: -1 },
          { label: '失效', value: 0 },
          { label: '生效', value: 1 }
        ],
        options_factory: []
      };
    },
    mounted() {
      this.getFactoryarea();
    },
    computed: {
      // 表格列配置
      seekList() {
        return [
          {
            label: '工艺路线编码:',
            value: 'code',
            type: 'input',
            placeholder: '请输入'
          },
          {
            label: '工艺路线名称:',
            value: 'name',
            type: 'input',
            placeholder: '请输入'
          },
          {
            label: '状态:',
            value: 'status',
            type: 'select',
            placeholder: '请选择',
            planList: this.statusList
          },
          {
            label: '所属工厂:',
            value: 'factoriesId',
            type: 'select',
            placeholder: '请选择',
            planList: this.options_factory
          }
        ];
      }
    },
    methods: {
      /* 搜索 */
      search(e) {
        this.$emit('search', {
          ...e
        });
      },
      // 获取工厂数据
      getFactoryarea() {
        let par = {
          type: 1,
          size: 9999
        };
        getFactoryarea(par).then((res) => {
          if (res.list && res.list.length > 0) {
            this.options_factory = res.list.map((el) => {
              return {
                value: el.id,
                label: el.name
              };
            });
          }
        });
      }
    }
  };
</script>
