<template>
  <normalTable
    :is-select="false"
    :sequence="true"
    rowKey="w_functionid"
    ref="list"
    size="small"
    :param="param"
    :columns="utils.TBLayout('serveTable')"
  >
    <template #tb_cell="{ data }">
      <div v-if="data.column.dataIndex == 'isasyn'">
        {{ data.record.isasyn ? "异步" : "同步" }}
      </div>
      <div
        v-else-if="data.column.dataIndex == 'func'"
        style="display: flex; align-items: center"
      >
        <span>{{ data.record.func }}</span>
        <a-tag
          color="blue"
          size="small"
          v-if="data.record.issystem"
          style="margin-left: 10px"
          >系统</a-tag
        >
      </div>
      <div v-else-if="data.column.dataIndex == 'w_dataparamids'">
        <a-tag
          color="blue"
          v-for="item in data.record.dataparam"
          :key="item.w_functionid"
          >{{ item.paramname }}</a-tag
        >
      </div>
      <div v-else>
        {{ data.record[data.column.dataIndex] }}
      </div>
    </template>
    <template #operation>
      <div style="display: flex; margin-bottom: 16px">
        <div style="margin-right: 16px">
          <span>调用方式：</span>
          <a-select
            ref="select"
            v-model:value="param.content.where.isasyn"
            placeholder="选择调用方式"
            style="width: 200px"
            @change="
              param.content.pageNumber = 1;
              $refs.list.listData();
            "
            allowClear
          >
            <a-select-option value="0">同步</a-select-option>
            <a-select-option value="1">异步</a-select-option>
          </a-select>
        </div>
      </div>
    </template>
  </normalTable>
</template>

<script setup>
import listTemp from "@/components/listTemplate/index.vue";
import normalTable from "@/template/normalTable/index.vue";
import customBtn from "@/components/customHandleBtn/index.vue";
import Edit from "./modules/Edit.vue";
import { useBaseStore } from "@/stores/modules/base";
import { ref, defineProps, defineEmits, onMounted } from "vue";
import { useRouter } from "vue-router";
import Api from "@/api/api";
import utils from "@/utils/utils";
let list = ref();
let base = useBaseStore();
let router = useRouter();
let emit = defineEmits([]);
let props = defineProps(["data", "disabled", "mode"]);
let param = ref({
  id: 20230613162702,
  content: {
    ownertable: "w_device",
    ownerid: router.currentRoute.value.query.id,
    pageNumber: 1,
    pageSize: 20,
    mode: props.mode,
    where: {
      condition: "",
      isasyn: undefined,
    },
  },
});
let searchType = ref([
  { label: "搜索", key: "condition", type: "input" },
  {
    label: "调用方式",
    key: "isasyn",
    type: "select",
    dataSource: [
      { remarks: "同步", value: "同步" },
      { remarks: "异步", value: "异步" },
    ],
  },
]);
let typeList = ref([]);

onMounted(async () => {
  let res = await base.optiontypeselect("datatype");
  typeList.value = res.data;
  console.log(typeList.value);
});

let getList = () => {
  list.value.listData();
};

defineExpose({
  param,
  getList,
});
</script>

<style scoped>
</style>
