<template>
  <div>
    <Curd
      :columns="columns"
      :api-conf="apiConf"
      :form-items="formItems"
    />
  </div>
</template>
<script>
import base from "~/templates/base";
import Curd from "../../components/smallCommon/Curd.vue";

export default {
  name: "organized",
  extends: base,
  components: {
    Curd
  },
  data() {
    return {
      deviceTypes: [],
      columns: [
        {
          dataIndex: 'name',
          key: 'name',
          title: '工序名称'
        },
        {
          dataIndex: 'organizedType',
          key: 'organizedType',
          title: '工序类型'
        },
        {
          dataIndex: 'order',
          key: 'order',
          title: '排序'
        }
      ],
      apiConf: {
        listApi: {api: '/api/Organized/list', method: 'get', noPage: true},
        deleteApi: {api: '/api/Organized/remove', method: 'delete', paramsType: 'Array'},
        editApi: {api: '/api/Organized/update', method: 'put'},
        addApi: {api: '/api/Organized/add', method: 'post',}
      }
    }
  },


  computed: {
    formItems() {
      const self = this
      return [
        {
          type: 'input',
          key: 'name',
          label: '工序名称',
          isSearch: true,
          placeholder: '请输入工序名称',
          rules: [
            {required: true, message: '请输入工序名称'}
          ]
        },

        {
          type: 'select',
          key: 'organizedType',
          label: '工序类型',
          children: []
        },
        {
          type: 'input',
          key: 'order',
          label: '排序'
        }
      ]
    }
  },
  created() {
    this.getMenus()
  },
  methods: {
    getMenus() {
      this.$get('/api/Device/GetDeviceTypes').then(({data}) => {
        this.deviceTypes = Object.keys(data).map(item => ({
          label: data[item],
          value: item
        }))
      })
    }
  }
}
</script>
<style scoped lang="less">

</style>
