<!--
 * @Author: zqm
 * @Date: 2021-06-29 09:08:16
 * @LastEditTime: 2022-02-16 10:01:48
 * @LastEditors: Please set LastEditors
 * @Description: 全部重置按钮
 * @FilePath: \taxFormToolFramework\src\components\allDeleteButton.vue
-->
<template>
  <div>
    <el-button ref="allDeleteButton" type="primary" size="small" plain :disabled="state=='success'" @click="allDeleteFun">全部重置</el-button>
  </div>
</template>
<script>
export default {
  name: "allDeleteButton",
  props: {
    deleteProp: { type: Object, default: () => ({}) },
    state: { type: String, default: "" }
  },
  data() {
    return {
    }
  },
  methods: {
    allDeleteFun() {
      var _self = this;
      var title = "全部重置";
      var message = "该功能会清空当前凭证种类下的所有已填写报表数据，确定要重置当前凭证种类下的所有报表吗？";
      this.$confirm(message, title, {
        confirmButtonText: '全部重置',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        _self.confirm()
      }).catch(() => {
      });
    },
    confirm(type) {
      this.$store.commit("loading", true);
      var tableData = this.$store.state.data.engines;
      this.$parent.$parent.$emit('changeSelected', "allDeleteFun");
      var _self = this;
      var deleteUrl = interfacePrefix + config.allDelete;
      var deleteData = this.$store.state.data.bblxHeader;
      this.ajax.post(deleteUrl, deleteData,
        function (data) {
          if (data.returnCode == "00") {
            _self.$message({ message: "当前凭证种类全部重置完毕！", type: 'success' });
            var menuList = _self.$store.state.data.menuList
            for (var i = 0; i < menuList.length; i++) {
              var obj = menuList[i];
              obj.verificationState = 'empty'
            }
            _self.$parent.$parent.$parent.$parent.menuSelect(menuList[0], "open");
          }
        }, "json", true);
    },
  },
}
</script>
<style scoped>
</style>