<template>
  <ListView
    :table-config="tableConfig"
    :dialog-configs="dialogConfigs"
    :listQueryExtra="[{ key: code }]"
    attach-list-query-extra="key"
    :trigger-update="triggerUpdateKey"
  />
</template>

<script>
import initConfig from "./config";
import ListView from "@/views/atomViews/ListView.vue";

export default {
  name: "BomDetailsView",
  components: { ListView },
  provide() {
    return {
      urls: this.allUrls,
    };
  },
  computed: {
    // 配方编码
    code() {
      return this.$route.query.code || "";
    },
  },
  data() {
    const { tableConfig, urls, dialogConfigs } = initConfig.call(this);
    return {
      tableConfig,
      allUrls: urls,
      dialogConfigs,
			triggerUpdateKey: ''
    };
  },
  watch: {
    $route: {
      handler: function (route) {
        if (route.query.code) {
          this.triggerUpdateKey = Math.random().toString();
          //console.log("[$oute changed] val.query.name", route.query.code, this.triggerUpdateKey);
        }
      },
      immediate: true,
      deep: true,
    },
  },
};
</script>

<style scoped></style>
