<template>
  <div class="flex-full" style="height: 40%">
    <data-grid :model="model" partial='list' class="list_area table_sy" v-ref:grid >
      <template partial='head'>
        <tr>
          <th style="text-align: center;">序号</th>
          <th style="text-align: center;">移入（移出）原因</th>
          <th style="text-align: center;">管控级别</th>
          <th style="text-align: center;">限制功能</th>
          <th style="text-align: center;">备注</th>
          <th style="text-align: center;">操作状态</th>
          <th style="text-align: center;">操作时间</th>
          <th style="text-align: center;">操作人</th>
        </tr>
      </template>
      <template partial='body'>
        <tr>
          <td style="text-align: center;">{{$index+1}}</td>
          <td style="text-align: center;">{{row.f_comments}}</td>
          <td style="text-align: center;">{{row.f_level}}</td>
          <td style="text-align: center;">{{$parent.$parent.formatFunction(row.f_function)}}</td>
          <td style="text-align: center;">{{row.f_remark}}</td>
          <td style="text-align: center;">{{row.f_opr_state}}</td>
          <td style="text-align: center;">{{row.f_operate_date}}</td>
          <td style="text-align: center;">{{row.f_operator}}</td>
        </tr>
      </template>
      <template partial='foot'></template>
    </data-grid>
  </div>
</template>

<script>
import {HttpResetClass} from 'vue-client'

let initGen = async function (self, val) {
  let http = new HttpResetClass()
  console.log(self.$login.f, '================')
  let res = await http.load('POST', 'rs/sql/sale_getBlackListRecord', {data: {condition: `t.f_userinfo_id='${self.data.f_userinfo_id}' and f_orgid = '${self.$login.f.orgid}'` }}, {resolveMsg: null, rejectMsg: null})
  self.model = Object.assign({}, self.model, val)
  self.model.rows = res.data
}
export default {
  props: ['data'],
  data () {
    return {
      model: {
        rows: []
      }
    }
  },
  watch: {
    'data' (val) {
      if (val) {
        initGen(this, val)
      }
    }},

  ready () {
    initGen(this, this.data)
  },
  methods: {
    formatFunction (functionString) {
      if (!functionString) return ''
      try {
        // 解析 JSON 字符串为数组
        let functionArray = JSON.parse(functionString)
        // 将数组转换为用逗号分隔的字符串
        return functionArray.join(', ')
      } catch (e) {
        // 如果解析失败，返回原始字符串
        return functionString
      }
    }
  }

}
</script>
<style>

</style>

