<template>
  <div>
    <el-table v-loading="loading" :data="tableList" border stripe>
      <el-table-column v-for="col in columns" :prop="col.prop" :key="col.prop" :label="col.label" />
      <el-table-column label="发送方式" min-width="150">
        <template #default="{ row }">
          <el-checkbox-group v-model="row.sendType" size="small" @change="rowChange(row)">
            <el-checkbox :label="1"> 微信 </el-checkbox>
            <el-checkbox :label="2"> 微信群 </el-checkbox>
          </el-checkbox-group>
        </template>
      </el-table-column>
      <el-table-column label="微信群名称" min-width="150">
        <template #default="{ row }">
          <span v-if="!row.edit">{{ row.wxGroup }}</span>
          <el-input v-else v-model="row.wxGroup" size="small" clearable @blur="rowChange(row)" />
        </template>
      </el-table-column>
      <el-table-column label="操作" width="100">
        <template #default="{ row }">
          <div>
            <el-button type="primary" style="padding: 5px 0" text @click="row.edit = true">
              修改群名称
            </el-button>
          </div>
          <div>
            <el-button type="primary" style="padding: 5px 0" text @click="row.edit = true">
              修改发送时间
            </el-button>
          </div>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script setup name="WXSetting">
const loading = ref(false)
const tableList = ref([
  {
    name: '分配通知',
    sendType: []
  },
  {
    name: '发货通知',
    sendType: []
  },
  {
    name: '月业绩排名',
    sendType: []
  }
])
const columns = [
  {
    label: '消息名称',
    prop: 'name'
  },
  {
    label: '解释说明',
    prop: 'remark'
  },
  {
    label: '发送频率',
    prop: 'sendFrequency'
  },
  {
    label: '发送时间',
    prop: 'sendTime'
  }
]

async function rowChange(row) {
  try {
    console.log(row)
  } finally {
    row.edit = false
  }
}
</script>

<style lang="scss" scoped></style>
