{
  template: '${tmpl}',
    data: function() {
      return {
        multipleSelection: [],
        isSingleSelect: false,
        bizCode: "",
        centerDialogVisible: false,
        activeIndex: "1",
        totalSum: 0,
        d: {},
        action: "",
        addressInfo: [],
        index: 0,
        orderId: "",
        stuff: {},
        showUploadStuff: false,
        siteid: "",
        dialogFormVisible: false,
        codelist: [],
        infoMsg: "",
        accounts: [],
        account_id: "",
        account_index: "",
        accountinfo: {},
      }
    },
  mounted: function() {
    var that = this;
    that.siteid = this.$router.history.current.query.siteid;
    if (that.siteid) {
      this.$refs.grid.linkInInitQuery("company_id", that.siteid);
    } else {
      this.$root.pushx({
        title: "站点业务统计",
        name: "/siteservicestatistic"
      });
      return;
    }
    this.$root.postReq("/web/uploadCtl/getOssConfig", "").then(function (d) {
      that.d["key"] = "key";
      that.d["Bucket"] = d.Bucket;
      that.d["OSSAccessKeyId"] = d.OSSAccessKeyId;
      that.d["Signature"] = d.Signature;
      that.d["policy"] = d.policy;
      that.d["success_action_status"] = d.success_action_status;
      that.action = d.url;
    });

  },
  created: function() {
  },

  methods: {
    profitClear(){
      this.$root.postReq("/web//orderCtl/orderSettlement", { company_id: this.siteid, account_id: this.account_id, codelist: this.codelist }).then(function (d) {
        if(d && d.code==1){
          that.$message.success("操作成功");
          that.$refs.grid.fetchData();
        }else{
          that.$message.warning(d.msg);
        }
      });
    },
    bankchange(d){
      var account = this.accounts[d];
      if (account) {
        this.accountinfo = account;
        this.account_id = account.id;
      }
    },
    btnvisbleMethod(row, btn){
      if (btn.key == "mydetail") {
        if (row.sveItemCode == "zzsbzc" || row.sveItemCode == "dlrfzzc" || row.sveItemCode == "dbsbzc") {
          return true;
        } else {
          return false;
        }
      }
      return true;
    },
    onColFormater(row, column, cellvalue, index){
      if (column.property == "created_at") {
        var date = new Date(row["created_at"]);
        var time = date.toLocaleDateString();
        console.log(time);
        return time;
      }
      if (column.property == "customerinfo.name") {
        if (!row.customerinfo) {
          return "---";
        } else {
          return row.customerinfo.name;
        }
      }
      if (column.property == "name") {
        if (!row["name"]) {
          return "---";
        } else {
          return row.name;
        }
      }
      if (column.property == "nclOneCodesNum") {
        if (!row["nclOneCodesNum"]) {
          return "---";
        } else {
          return row.nclOneCodesNum;
        }
      }
      if (column.property == "pfSettleProfit") {
        if (row["pfSettleProfit"] == 0) {
          return "未结算";
        } else {
          return "已结算";
        }

      }
      return cellvalue;
    },
    onRowClick(row, key, e){
      if (key == "mydetail") {
        if (row.sveItemType == "ip") {
          this.$root.pushx({
            title: "订单详情",
            name: "/tmOrderDetail",
            params: {
              orderNum: row.code
            }
          });
        }
      }
    },
    toolbarclick(key, b, selectedRows){
      if (key == "settlement") {
        var that = this;
        that.codelist = [];
        if (!selectedRows || selectedRows.length == 0) {
          this.$message.warning("请选择至少一条数据");
          return;
        }
        for (var i = 0; i < selectedRows.length; i++) {
          var row = selectedRows[i];
          that.codelist.push(row.code);
          if (row.orderFlowStatus != "5") {
            this.$message.warning("流程状态错误，含有非已完成状态的订单");
            return;
          }
        }
        this.$root.postReq("/web/moneyaccountCtl/findAllByCompanyId", { company_id: that.siteid }).then(function (d) {
          that.accounts = d.data;
        });
        this.dialogFormVisible = true;
      }

    },

  },
  computed: Vuex.mapState({
    count: state => state.count,
    headStyle: function () {
      return { "background-color": "white" };
    }
  }),
    vname: "gsb_sitestatisticorderlist"
}


