<template>
  <div class="app-container">
    <div class="questionBox">
      <el-table :data="tableData" border style="margin-bottom: 15px;">
        <el-table-column prop="date" label="成员"></el-table-column>
        <el-table-column prop="name" label="工号"></el-table-column>
        <el-table-column prop="address" label="部门"></el-table-column>
        <el-table-column label="比例">
          <template #default="scope">
            <span v-show="scope.$index !== editIndex">{{ scope.row.value }}</span>
            <el-input
              v-show="scope.$index === editIndex"
              v-model="scope.row.value"
            ></el-input>
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template #default="{ row }">
            <div style="display: flex;">
              <el-button link @click="handleEdit(row)">编辑</el-button>
              <el-button type="primary" link @click="handleSave">保存</el-button>
              <el-button type="danger" link @click="handleDelete(row)"
                >删除</el-button
              >
            </div>
          </template>
        </el-table-column>
      </el-table>
        <el-button class="mt-4" style="width: 100%" @click="onAddItem">
          新增坐席
        </el-button>
    </div>
    <!-- 创建工单 -->
  <el-dialog
    v-model="centerDialogVisibleAddWorkorder"
    title="新增坐席"
    center
    width="30%"
    :modal="true"
    :show-close="true"
  >
  <el-form-item label="请选择坐席" label-width="200px">
    <el-cascader :options="options" :props="props2" clearable />
  </el-form-item>
  
  </el-dialog>
  </div>
</template>

<script setup>
import { onMounted, ref, watch } from 'vue';

const { proxy } = getCurrentInstance();
const centerDialogVisibleAddWorkorder = ref(false);
const onAddItem = () => {
  console.log('新增')
  centerDialogVisibleAddWorkorder.value = true;
}

const tableData = ref([
  {
    date: '1',
    name: 'Tom',
    address: '1',
    value: '1'
  },
  {
    date: '1',
    name: 'Tom',
    address: '1',
    value: '2'
  },
  {
    date: '1',
    name: 'Tom',
    address: '1',
    value: '3'
  },
  {
    date: '1',
    name: 'Tom',
    address: '1',
    value: '4'
  }
])
const editIndex = ref(-1)
const handleEdit = (row) => {
  editIndex.value = tableData.value.indexOf(row)
}
const handleSave = () => {
  editIndex.value = -1
  console.log(tableData.value)
}
const handleDelete = (row) => {
  tableData.value.splice(tableData.value.indexOf(row), 1)
}


const props = defineProps({
  getDefaultInfo: {
    type: Object,
    default: () => ({}),
  }
});

const props2 = {
  multiple: true,
  checkStrictly: true,
}

const options = [
  {
    value: 'guide',
    label: 'Guide',
    children: [
      {
        value: 'disciplines',
        label: 'Disciplines',
        children: [
          {
            value: 'consistency',
            label: 'Consistency',
          },
          {
            value: 'feedback',
            label: 'Feedback',
          },
          {
            value: 'efficiency',
            label: 'Efficiency',
          },
          {
            value: 'controllability',
            label: 'Controllability',
          },
        ],
      },
      {
        value: 'navigation',
        label: 'Navigation',
        children: [
          {
            value: 'side nav',
            label: 'Side Navigation',
          },
          {
            value: 'top nav',
            label: 'Top Navigation',
          },
        ],
      },
    ],
  },
  {
    value: 'component',
    label: 'Component',
    children: [
      {
        value: 'basic',
        label: 'Basic',
        children: [
          {
            value: 'layout',
            label: 'Layout',
          },
          {
            value: 'color',
            label: 'Color',
          },
          {
            value: 'typography',
            label: 'Typography',
          },
          {
            value: 'icon',
            label: 'Icon',
          },
          {
            value: 'button',
            label: 'Button',
          },
        ],
      },
      {
        value: 'form',
        label: 'Form',
        children: [
          {
            value: 'radio',
            label: 'Radio',
          },
          {
            value: 'checkbox',
            label: 'Checkbox',
          },
          {
            value: 'input',
            label: 'Input',
          },
          {
            value: 'input-number',
            label: 'InputNumber',
          },
          {
            value: 'select',
            label: 'Select',
          },
          {
            value: 'cascader',
            label: 'Cascader',
          },
          {
            value: 'switch',
            label: 'Switch',
          },
          {
            value: 'slider',
            label: 'Slider',
          },
          {
            value: 'time-picker',
            label: 'TimePicker',
          },
          {
            value: 'date-picker',
            label: 'DatePicker',
          },
          {
            value: 'datetime-picker',
            label: 'DateTimePicker',
          },
          {
            value: 'upload',
            label: 'Upload',
          },
          {
            value: 'rate',
            label: 'Rate',
          },
          {
            value: 'form',
            label: 'Form',
          },
        ],
      },
      {
        value: 'data',
        label: 'Data',
        children: [
          {
            value: 'table',
            label: 'Table',
          },
          {
            value: 'tag',
            label: 'Tag',
          },
          {
            value: 'progress',
            label: 'Progress',
          },
          {
            value: 'tree',
            label: 'Tree',
          },
          {
            value: 'pagination',
            label: 'Pagination',
          },
          {
            value: 'badge',
            label: 'Badge',
          },
        ],
      },
      {
        value: 'notice',
        label: 'Notice',
        children: [
          {
            value: 'alert',
            label: 'Alert',
          },
          {
            value: 'loading',
            label: 'Loading',
          },
          {
            value: 'message',
            label: 'Message',
          },
          {
            value: 'message-box',
            label: 'MessageBox',
          },
          {
            value: 'notification',
            label: 'Notification',
          },
        ],
      },
      {
        value: 'navigation',
        label: 'Navigation',
        children: [
          {
            value: 'menu',
            label: 'Menu',
          },
          {
            value: 'tabs',
            label: 'Tabs',
          },
          {
            value: 'breadcrumb',
            label: 'Breadcrumb',
          },
          {
            value: 'dropdown',
            label: 'Dropdown',
          },
          {
            value: 'steps',
            label: 'Steps',
          },
        ],
      },
      {
        value: 'others',
        label: 'Others',
        children: [
          {
            value: 'dialog',
            label: 'Dialog',
          },
          {
            value: 'tooltip',
            label: 'Tooltip',
          },
          {
            value: 'popover',
            label: 'Popover',
          },
          {
            value: 'card',
            label: 'Card',
          },
          {
            value: 'carousel',
            label: 'Carousel',
          },
          {
            value: 'collapse',
            label: 'Collapse',
          },
        ],
      },
    ],
  },
  {
    value: 'resource',
    label: 'Resource',
    children: [
      {
        value: 'axure',
        label: 'Axure Components',
      },
      {
        value: 'sketch',
        label: 'Sketch Templates',
      },
      {
        value: 'docs',
        label: 'Design Documentation',
      },
    ],
  },
]

</script>
