<template>
  <section class="AppSeatManagement">
    <ai-list>
      <template slot="title">
        <ai-title title="席位管理" isShowBottomBorder></ai-title>
      </template>
      <template #content>
        <ai-search-bar>
          <template #left>
            <ai-select v-model="search.integralType" placeholder="请选择机位" @change="current=1, getTableData()"
              :selectList="dict.getDict('integralType')"/>
            <span class="tips">当前机位1有效期为：2024-06-24&nbsp;&nbsp;&nbsp;&nbsp;ip地址为：192.168.1.120</span>
          </template>
          <template #right>
            <el-button size="small" type="primary" @click="add('')">启动</el-button>
          </template>
        </ai-search-bar>
        <ai-table :tableData="tableData" :total="total" :current.sync="current" :size.sync="size"
                  @getList="getTableData()" :col-configs="colConfigs" :dict="dict">
          <el-table-column slot="num" label="监控群聊"  align="center">
            <template slot-scope="{ row }">
              <div @click="showDialog(row)" style="cursor: pointer;">110</div>
            </template>
          </el-table-column>
        </ai-table>
      </template>
    </ai-list>
    <ai-dialog
      title="监控群聊"
      :visible.sync="dialog"
      :destroyOnClose="true"
      width="720px"
      @closed="form={}" :customFooter="false">

    </ai-dialog>
  </section>

</template>

<script>
import { mapState } from "vuex";
export default {
  name: "AppSeatManagement",
  label: '席位管理',
  props: {
    instance: Function,
    dict: Object,
    permissions: Function,
    menuName:String
  },
  data() {
    return {
      search: {
        wordName: '',
        current: 1,
        size: 10,
      },
      tableData: [],
      size: 10,
      total: 0,
      current: 1,
      form: {
        wordName: '',
        // areaList: [],
        deptList: [],
      },
      dialog: false,
      flag: false,
    }
  },
  created() {
    this.$dict.load('integralType')
    this.getTableData()
  },
  computed: {
    ...mapState(['user']),
    colConfigs() {
      return [
        { prop: "wordName", label: '姓名', align: "left"},
        { prop: "createTime", label: '手机号'},
        { prop: "createUserName", label: '管辖区域'},
        { slot: "num", label: '监控群聊'},
        { prop: "departmentNames", label: '状态'},
      ]
    },
    rules() {
      return {
        wordName: [{required: true, message: '请输入敏感词', trigger: 'blur' }],
        // areaList: [{required: true, message: '请选择生效地区', trigger: 'blur' }],
        deptList: [{required: true, message: '请选择生效部门', trigger: 'blur' }],
      }
    },
  },
  methods: {
    getTableData() {
      this.instance.post(`/app/appsessionarchivekeywordinfo/list`,null,{
        params: {
          ...this.search,
          current: this.current,
          size: this.size,
          total: this.total,
          wordName: this.search.name
        }
      }).then(res => {
        if(res?.data) {
          this.tableData = res.data.records
          this.total = res.data.total
        }
      })
    },
    changeStatus(row, text, status) {
      this.$confirm(`确定${text}该关键词？`).then(() => {
        this.instance.post(`/app/appsessionarchivekeywordinfo/updateStatusById?id=${row.id}&status=${status}`).then(res => {
          if (res.code == 0) {
            this.$message.success('操作成功！')
            this.getTableData()
          }
        })
      })
    },
    showDialog(row) {
      this.form = {...row}
      this.form.deptList = []
      // this.form.areaList = this.form.areaIds.split(',')
      this.form.deptList = row.departmentIds.split(',')
      this.dialog = true
    },
  },
}
</script>

<style lang="scss" scoped>
.AppSeatManagement {
  height: 100%;

  .time-select {
    padding: 0 16px;
    height: 32px;
    line-height: 32px;
    border: 1px solid #d0d4dc;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    cursor: pointer;
    .el-icon-arrow-down {
      line-height: 32px;
    }
  }

  :deep .is-error {
    .time-select {
      border: 1px solid #f46!important;
    }
  }
  .tips {
    display: inline-block;
    color: #999;
    font-size: 14px;
    margin-left: 16px;
  }
}
</style>
