<template>
  <div>
    <p>算法策略</p>
    <p-table ref="table"
             bordered
             :remote-url="url"
             row-key="stItemLocatorLId"
             :columns="cols"
             :data-source.sync="data"
             :remoteParams="remoteParams"
             :autoLoad="false"
             :rowSelectType="false"
             :hasRowCount="false"
             :colorTransformRow="false"
             size="small">
    </p-table>

  </div>
</template>
<script>
import { cols3 } from "../config/columns";
import { api } from "../api";

export default {
  props: {
    stItemLocatorHId: {
      type: String,
      default: null
    }
  },

  data() {
    return {
      url: api.queryAlgorithm,
      cols: cols3,
      data: [],
      visible: true,
      remoteParams: {},
    }
  },

  watch: {
    stItemLocatorHId(val) {
      if (val) this.remoteParams = { stItemLocatorHId: val };
    }
  },

  methods: {

    clickRow() { },

    addItem() {
      this.visible = true;
    },

    delItem(item) {
      this.$confirm({
        content: this.$lang('是否确定删除?'),
        onOk: () => {
          return this.handleDels({ idList: [item.stItemLocatorHId] });
        }
      });
    },

    editorItem() {

    },

    reloadTable() {
      this.$refs.table.reload();
    },

    handleDels(p) {
      return delItems(p).then(res => {
        if (!res.success) {
          this.$exception(res.message);
          return;
        }
        this.$message.success('删除成功');
        this.reloadTable();
      });
    },


  }


}
</script>
<style scoped>
.btn {
  color: #2b80ff;
  margin-right: 10px;
  cursor: pointer;
}
.btn:hover {
  text-decoration: underline;
}
</style>


