<style scoped lang="less">
.scrollable {
  /*height: 700px;*/
  overflow-x: hidden;
}

::-webkit-scrollbar {
  width: 7px;
}

::-webkit-scrollbar-thumb {
  opacity: 0.5;
  border-radius: 3.5px;
  background-color: #888888;
}

.from-second-title {
  height: 16px;
  line-height: 16px;
  margin-left: 24px;
  /*margin: 15px 0;*/
  margin-bottom: 15px;
  padding-left: 4px;
  border-left: 2px solid #3477cb;
}

.title {
  font-family: Microsoft YaHei;
  margin-left: 4px;
  font-size: 14px;
  color: #222222;
  letter-spacing: 0;
  text-align: left;
}
</style>
<template>
  <div class="modal_content">
    <Modal
      v-model="modal_visible"
      title="选择单据"
      @on-cancel="handleCancel"
      :closable="true"
      :mask-closable="false"
      :fullscreen="true"
    >
      <gms-bill-form
        :templateName="selectBill"
        :id="billId"
        :type="billId ? 'load' : 'init'"
        v-if="selectBill"
        ref="copyRefs"
      ></gms-bill-form>
      <div slot="footer" style="height: 0"></div>
    </Modal>
  </div>
</template>

<script>
export default {
  data() {
    return {
      billId: "",
      modal_visible: false,
      bill: null,
      data: {},
      selectBill: "",
      ignoreFields:[],
    };
  },
  created() {},
  mounted() {},
  props: {},
  methods: {
    getNewBillId() {
      let that = this;
      let billdefine= this.bill.curForm.content.billdefine;
      GAMS.Util.invokeServer({
        path: "/gms/bill/newed/" + billdefine,
        type: "GET",
        contentType: "application/json",
      })
        .then(
          function (data, textStatus, response) {
            that.$nextTick(() => {
              //需要考虑其他忽略的字段
              //处理主表忽略字段置为空 id取一个新值
              that.$refs.copyRefs.context.bill.getMasterData().setValue('id', data.content.id ? data.content.id : GAMS.Util.newId());
              that.$refs.copyRefs.context.bill.getMasterData().setValue("billCode",data.content.billCode);
              that.ignoreFields.forEach(v=> {
                if(v && (v!='id'||v!='billCode')){
                  that.$refs.copyRefs.context.bill.getMasterData().setValue(v,null);
                }
              })
              //处理子表忽略字段置为空
              let tableObj = that.$refs.copyRefs.context.bill.getAllSubData();
              if(tableObj){
                for(let i in tableObj){
                  tableObj[i].forEach(element => {
                    that.ignoreFields.forEach(v=> {
                      if(v){
                        element.setValue(v, null);
                      }
                    })
                  });
                }
              }
            })
          }.bind(this)
        )
        .catch((XMLHttpRequest, textStatus, errorThrown) => {});
    },
    handleCancel() {
      this.modal_visible = false;
    },
  },
  watch: {},
};
</script>