<!--
 * @Author: zhp
 * @Date: 2023-01-31 09:49:36
 * @LastEditTime: 2023-05-17 15:00:50
 * @LastEditors: zhp
 * @Description: 
-->
<template>
  <span>
    <el-button type="text" @click="emitClick()">同步所有关联产品</el-button>
  </span>
</template>

<script>
// import { addDynamicRoute } from '@/router'
export default {
  props: {
    injectData: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {
      urlOptions: {
        syncURL: "/basic/qmsProduct/connectAllProduct"
      },
    }
  },
  methods: {
    // 子级
    emitClick() {
      const data = {
        id: this.injectData.id,
        finishInspection: this.injectData.finishInspection,
        incomingInspection: this.injectData.incomingInspection,
        outInspection: this.injectData.outInspection,
        processInspection: this.injectData.outInspection
      }
      this.$http.put(this.urlOptions.syncURL, { data }).then(({ data }) => {
        if (data && data.code === 0) {
          this.$message({
            message: "操作成功",
            type: "success",
            duration: 1500,
            onClose: () => {
              this.$message.error(data.msg);
            },
          });
        } else {
          this.$message.error(data.msg)
        }
      });
      // 路由参数
      // const routeParams = {
      //   routeName: `${this.$route.name}__${this.injectData.id}`,
      //   title: `${this.$route.meta.title} - ${this.injectData.dictType}`,
      //   path: 'sys/dict-data',
      //   params: {
      //     dictTypeId: this.injectData.id
      //   }
      // }
      // 动态路由
      // addDynamicRoute(routeParams, this.$router)
    }
  }
}
</script>
