<template>
  <div>
    <p>将按当前查询结果批量审核未确认状态的单据，是否继续？</p>
    <DialogFooter
      confirmText="继续"
      :onCancel="onCancel"
      :onConfirm="onConfirm"
    ></DialogFooter>
  </div>
</template>

<script>
import DialogFooter from '@yunque/component/modal/commonModal/dialog-footer.vue'

const R3 = window.R3;
const { network, urlSearchParams } = R3;

export default {
  name: 'SearchAudit',

  components: {
    DialogFooter,
  },

  data() {
    return {
      formData: {}
    };
  },

  created() {
    this.getFormData()
  },

  methods: {
    async getFormData() {
      const dom = document.querySelector(".ListsForm-box");
      if (dom) {
        const vm = dom.__vue__
        const data = await vm.getFormData();
        this.formData = data
      }
    },


    audit() {
      const options = this.formData.COLOR_BLOCK;
      if(options){
        const transparentOptionIndex = options.findIndex(item => item === '无颜色标签');
        if (transparentOptionIndex > -1) {
          this.formData.COLOR_BLOCK.splice(transparentOptionIndex, 1, 'is null');
        }
      }
      const params = {
        searchdata: {
          table: 'T_V_OMSONLINEORDER',
          startindex: 0,
          range: 10,
          fixedcolumns: this.formData,
          column_include_uicontroller: true,
          isolr: true,
          getsumfileds: true
        }
      }

      network.post('/p/cs/audit/order/auto', urlSearchParams(params)).then(res => {
        if(res.data.code === 0) {
          this.$Message.success(res.data.message);
        }
      }).finally(() => {
        this.close()
      })
    },

    onConfirm() {
      this.audit()
    },

    close() {
      this.$emit('closeActionDialog', false);
    },

    onCancel() {
      this.close()
    }
  },
};
</script>

<style lang="less" scoped>
</style>
