import { required } from '@/components/template/rules_verify.js'
import { orderBaseList } from '@/api/workOrderPool.js'
import { tableDataParsing } from '@/utils/common.js'
export default {
  props: {
    recordSelected: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
      columns: []
    }
  },
  watch: {
    recordSelected: {
      handler() {
        this.orderInfo.recordSelected = [...this.recordSelected.map(item => ({ ...item }))]
      },
      deep: true,
      immediate: true
    }
  },
  created() {
    orderBaseList({ pageNum: 1, pageSize: 1, params: [{ param: 'a.id', compare: '=', value: '0' }] }).then(res => {
      this.columns = tableDataParsing(res.fieldBeans.filter(item => !~['orderFlags', 'orderType'].indexOf(item.jname)))
    })
  },
  computed: {
    selectedItems() {
      return [
        {
          name: 'slot-component',
          md: 24,
          formItemAttributes: {
            label: '',
            'label-width': '0px',
            prop: 'recordSelected',
            rules: [...required]
          },
          render: (h, { props }) => {
            return (
              <div>
                <zj-table columns={this.columns} table-data={this.orderInfo.recordSelected} />
              </div>
            )
          }
        }
      ]
    }
  }
}
