<template>
  <basic-container>
    <avue-crud :option="option" :table-loading="loading" :data="data" v-model:page="page" v-model="form" ref="crud"
      @row-update="rowUpdate" @row-save="rowSave" @row-del="rowDel" @search-change="searchChange"
      @search-reset="searchReset" @selection-change="selectionChange" @current-change="currentChange"
      @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad">
      <template #craftMan="{ row }">
        {{ row.craftMan.userName }}
      </template>
      <template #mecMan="{ row }">
        {{ row.mecMan.userName }}
      </template>
    </avue-crud>
  </basic-container>
</template>

<script>
export default {
  data() {
    return {
      loading: false,
      data: [],
      form: {},
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      option: {
        tip: false,
        height: 'auto',
        calcHeight: 32,
        columnSort: true,
        // simplePage: true,
        searchShow: true,
        searchMenuSpan: 6,
        searchIcon: true,
        searchIndex: 3,
        tree: false,
        border: true,
        index: true,
        selection: true,
        viewBtn: false,
        delBtn: false,
        addBtn: false,
        editBtn: false,
        editBtnText: '修改',
        viewBtnText: '详情',
        viewBtnIcon: ' ',
        delBtnIcon: ' ',
        editBtnIcon: ' ',
        labelWidth: 120,
        // menuWidth: 330,
        dialogWidth: 600,
        dialogClickModal: false,
        searchEnter: true,
        filterBtn: true,
        searchShowBtn: false,
        excelBtn: true,
        showOverflowTooltip: true,
        align: 'center',
        column: [
          {
            label: '试验项目',
            prop: 'tpProject',
            search: false,
            sortable: true,
            filter: true,
            addDisplay: false,
            editDisplay: false,
            viewDisplay: false,
            span: 24,
            width: 200,
            rules: [
              {
                required: true,
                message: '请输入试验项目',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '试验条件',
            prop: 'tpCondition',
            search: false,
            sortable: true,
            filter: true,
            addDisplay: false,
            editDisplay: false,
            viewDisplay: false,
            span: 24,
            width: 200,
            rules: [
              {
                required: true,
                message: '请输入试验条件',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '试验标准',
            prop: 'tpStandard',
            search: false,
            sortable: true,
            filter: true,
            addDisplay: false,
            editDisplay: false,
            viewDisplay: false,
            span: 24,
            width: 200,
            rules: [
              {
                required: true,
                message: '请输入试验标准',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '试验件',
            prop: 'testPieceTitle',
            type: 'select',
            search: false,
            sortable: true,
            filter: true,
            span: 24,
            width: 200,
            dicData: [
              {
                label: '零件',
                value: 1
              },
              {
                label: '试片',
                value: 0
              }
            ]
          },
          {
            label: '主管工艺',
            prop: 'craftMan',
            search: false,
            sortable: true,
            filter: true,
            span: 24,
            width: 200,
          },
          {
            label: '试验员',
            prop: 'mecMan',
            search: false,
            sortable: true,
            editDisplay: false,
            filter: true,
            addDisplay: false,
            span: 24,
            width: 200,
            rules: [
              {
                required: true,
                message: '请输入试验员',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '试验周期',
            prop: 'textCycle',
            search: false,
            sortable: true,
            filter: true,
            span: 24,
            width: 200,
          },
          {
            label: '提前下发天数',
            prop: 'beforeDays',
            search: false,
            sortable: true,
            filter: true,
            span: 24,
            width: 200,
          },
          {
            label: '超期提醒天数',
            prop: 'remDays',
            search: false,
            sortable: true,
            filter: true,
            span: 24,
            width: 200,
          },
          {
            label: '更新时间',
            prop: 'updateTime',
            search: false,
            sortable: true,
            filter: true,
            span: 24,
            width: 200,
          },
        ]
      }
    }
  },
  mounted() {

  },
  methods: {
    onLoad() {
      this.data = [
        {
          id: 1, tpProject: '盐雾试验', tpCondition: '32小时', tpStandard: 'xxxx标准',
          testPieceTitle: '零件', testPiece: 0,
          craftMan: { userName: '张三' },
          mecMan: { userName: '李四' },
          textCycle:'一年四次',beforeDays:20,remDays:7,updateTime:'2024-10-11 12:32:11'
        },
        {
          id: 2, tpProject: '盐雾试验', tpCondition: '32小时', tpStandard: 'xxxx标准',
          testPieceTitle: '零件', testPiece: 0,
          craftMan: { userName: '张三' },
          mecMan: { userName: '李四' },
          textCycle:'一年四次',beforeDays:20,remDays:7,updateTime:'2024-10-11 12:32:11'
        },
        {
          id: 3, tpProject: '盐雾试验', tpCondition: '32小时', tpStandard: 'xxxx标准',
          testPieceTitle: '零件', testPiece: 0,
          craftMan: { userName: '张三' },
          mecMan: { userName: '李四' },
          textCycle:'一年四次',beforeDays:20,remDays:7,updateTime:'2024-10-11 12:32:11'
        },
        {
          id: 4, tpProject: '盐雾试验', tpCondition: '32小时', tpStandard: 'xxxx标准',
          testPieceTitle: '零件', testPiece: 0,
          craftMan: { userName: '张三' },
          mecMan: { userName: '李四' },
          textCycle:'一年四次',beforeDays:20,remDays:7,updateTime:'2024-10-11 12:32:11'
        },
      ]
      this.page.total = this.data.length
    }
  }
}
</script>

<style></style>