<template>
  <section class="AppWebApps">
    <ai-list>
      <ai-title slot="title" title="web产品库" isShowBottomBorder/>
      <template #content>
        <ai-search-bar>
          <template #right>
            <el-input size="small" placeholder="搜索应用" v-model="search.name" clearable
                      @change="page.current=1,getTableData()"/>
          </template>
        </ai-search-bar>
        <ai-table :tableData="tableData" :total="page.total" :current.sync="page.current" :size.sync="page.size"
                  @getList="getTableData" :col-configs="colConfigs" :dict="dict"/>
      </template>
    </ai-list>
  </section>
</template>

<script>
import {mapState} from "vuex";

export default {
  name: "AppWebApps",
  label: "web产品库",
  props: {
    instance: Function,
    dict: Object,
    permissions: Function
  },
  computed: {
    ...mapState(['user'])
  },
  data() {
    return {
      search: {name: ""},
      page: {current: 1, size: 10, total: 0},
      tableData: [],
      colConfigs: [
        {label: "应用名称", prop: "label", width: 200},
        {label: "应用模块名", prop: "name", width: 200},
        {label: "产品库目录", prop: "libPath"},
      ]
    }
  },
  methods: {
    getTableData() {
      this.instance.post("/node/wechatapps/list", null, {
        params: {...this.page, ...this.search,type:'web'}
      }).then(res => {
        if (res?.data) {
          this.tableData = res.data?.records.map(e => ({...e, count: 0}))
          this.page.total = res.data.total
        }
      })
    }
  },
  created() {
    this.getTableData()
  }
}
</script>

<style lang="scss" scoped>
.AppWebApps {
}
</style>
