<template>
  <div class="varianceReconciliation">
    <div class="chooseStorageForm SplitForm minPiecesForm">
      <Form
        ref="formValidate"
        :label-width="80"
        inline
        v-for="(item,index) in VariceFormList"
        :key="item.tid"
        class="chooseStorageBox"
      >
        <FormItem
          label="平台单号:"
        >
          {{ item.tid }}
        </FormItem>
        <FormItem
          label="差异金额"
        >
          <Input
            v-model="item.amount"
            disabled
            placeholder=""
          />
        </FormItem>
      </Form>
    </div>
    <div class="bottomBtnBox">
      <Button
        size="small"
        class="cancelBtn"
        ghost
        @click="close()"
      >
        取消
      </Button>
      <Button
        type="primary"
        size="small"
        class="sureBtn"
        @click="sureVarianceReconciliation"
      >
        确定
      </Button>
    </div>
  </div>
</template>
<script>
  const R3 = window.R3;

  const { network } = R3;
  export default {
    props: {
      idArray: {// 可获取明细表勾选的明细ID
        type: [Array, Object],
        default: () => {}
      },
      selectRowData: {// 获取ID用于多选,获取勾选的明细对应的row内的数据
        type: [Array, Object],
        default: () => {}
      },
      externalOptions: {
        type: Object,
        default: ()=>{}
      },
    },
    created() {
      this.getVariceFormList();
      console.log(this.externalOptions.selectRowData)
    },
    data() {
      return {
        VariceFormList:[]
      };
    },
    methods: {
      getVariceFormList() {
        let list = [];
        this.externalOptions.selectRowData.forEach(item => {
          let obj = {
            tid: !item.SOURCECODE.val ? '0' : item.SOURCECODE.val,
            amount: !item.DIFFERENCESAMOUNT.val ? '0' : item.DIFFERENCESAMOUNT.val,
          }
          list.push(obj)
        })
        this.VariceFormList = list;
      },
      sureVarianceReconciliation() {
        let params = {
          ids: this.externalOptions.idArray
        };
        let url = '/p/cs/differencesReconciliation'
        const {tableName} = window.vm.$route.params
        if (tableName === 'T_OMSSTATEACCOUNTMONTH') {
          url = '/p/cs/differencesReconciliation/month';
        }

        network.post(url, params).then((res) => {
          if (res.data.code == 0) {
            // this.$Message.success(res.data.message);
            this.$Modal.fcWarning({
              title: '提示',
              mask: true,
              content: res.data.message
            });
            // this.close();
            document.querySelector('#refresh').click(); // 标准列表刷新按钮
            this.$emit('closeActionDialog', true);
          } else {
            // this.$message.error(res.data.message);
          }
        });
      },
      close() {
        // 成功关闭弹框
        this.$parent.close();
      }
    }
    
  };
</script>
<style scoped lang='less'>
  .varianceReconciliation {
    width: 600px;
  }
  .chooseStorageForm {
    max-height: 300px;
    overflow-y: scroll;
  }
  .chooseStorageBox.ark-form-inline .ark-form-item{
    width: 47%;
    margin-bottom: 6px;
  }
  .bottomBtnBox {
      width: calc(100% + 32px);
      margin: 16px auto 0px;
      margin-left: -16px;
      text-align: center;
      border-top: 1px solid #DEDEDE;
      padding-top: 16px;
      .cancelBtn,.sureBtn {
        width: 72px;
        height: 32px;
        font-size: 12px;
      }
      .cancelBtn {
        color: #909399;
        border: 1px solid #DADADA;
        margin-right: 8px;
      }
  }
</style>
