<!--
 * @Author: zqm
 * @Date: 2021-06-28 16:14:36
 * @LastEditTime: 2022-03-26 11:08:13
 * @LastEditors: Please set LastEditors
 * @Description: 提取数据按钮
 * @FilePath: \taxFormToolFramework\src\components\extractDataButton.vue
-->
<template>
  <div>
    <el-button ref="extractDataButton" type="primary" size="small" :plain="extractDataProp.isPlain" :disabled="state=='success'" @click="extractDataFun">提取数据</el-button>
  </div>
</template>
<script>
export default {
  name: "extractDataButton",
  props: {
    extractDataProp: { type: Object, default: () => ({}) },
    state: { type: String, default: "" }
  },
  methods: {
    extractDataFun() {
      this.$parent.$parent.$emit('changeSelected', "extractDataButton");
      var _self = this;
      var getUrl = interfacePrefix + config.requestAddress.getData;
      var item = Enumerable.From(this.$store.state.data.menuList).Where(function (val) {
        return val.bbDm + '_' + val.detailPcdm == _self.$store.state.data.defaultMenu
      }).ToArray()[0];
      item.initOrBjqsBz = "all";
      delete item.initData;
      delete item.tableData;
      this.ajax.post(getUrl, item, function (data) {
        if (data.returnCode == '00') {
          var init = data.content.init;
          var bjqsData = data.content.bjqsData;
          var initData = {};
          if (init != null) {
            if (JSON.stringify(bjqsData) == "{}") {
              item.initData = init;
            } else {
              item.initData = _self.getInitData(init, bjqsData);
            }
          }
          var tableData = _self.$store.state.data.engines;
          tableData.updataInitData(item.initData, function (e) {
            if (e == 1) {
              _self.$message({ message: '提取数据成功！', type: 'success' });
              _self.$store.commit("saveDisable", false);
            }
          })
        }
      }, "json", true);
    }
  }
}
</script>
<style scoped>
</style>