{
  template: '${tmpl}',
    data: function() {
      return {
        d: {},
        action: "",
        multipleSelection: [],
        returnofficialUrls: [],
        isSingleSelect: false,
        title: "",
        type: "",
        description: "",
        officialＴype: "1",
        topaddr: "1",
        dialogFormVisible: false,
        form: {
          name: "",
          mobile: "",
          address: ""
        },
        formLabelWidth: '120px',
        options: [],
        addrinfo: [],
        row: null
      }
    },
  mounted: function() {
    var obj = {};
    var that = this;
    this.$root.postReq("/web/useraddrCtl/fetchAllAddress", obj).then(function (d) {
      d.data.forEach(a => {
        var s = { value: a.address, label: a.address };
        var info = { name: a.name, address: a.address, mobile: a.mobile };
        that.options.push(s);
        that.addrinfo.push(info);
      });
    })
  },
  created: function() {

  },
  methods: {
    onColFormater(row, column, cellvalue, index){
      return cellvalue;
    },
    addrinfos(a, b){
      var i = this.addrinfo.findIndex(f => f.address == a);
      this.form.name = this.addrinfo[i].name;
      this.form.mobile = this.addrinfo[i].mobile;
    },
    uploadsuccess(results, fileList){
      this.title = "";
      this.type = "";
      this.description = "";
    },
    error(err){
      this.$message.warning(`上传失败，请重新上传`);
    },
    tohistory(){
      this.top = 1;
    },
    addapplyaddr(){
      var row = this.row;
      row.name = this.form.name;
      row.mobile = this.form.mobile;
      row.address = this.form.address;
      row.officialMailType = "2";
      row.version += 1;
      this.$root.postReq("/web/tmofficialCtl/update", row).then(rd => {
        if (rd.status == 0) {
          this.dialogFormVisible = false;
        }
      }).catch(function (e) {
        that.$message.warning(`操作失败，请刷新页面后重新操作`);
      });
    },
    updateTmStatus(){
      var that = this;
      const loading = this.$loading({
        lock: true,
        text: 'Loading',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
      if (that.returnofficialUrls.length == 0) {
        loading.close();
        that.$message.warning(`请点击上传按钮进行文件上传!`);
        return;
      }
      var obj = { "officialＴype": this.officialＴype, "urlList": this.returnofficialUrls };
      that.$root.postReq("/web/tmofficialCtl/putReturnReceip", obj).then(function (d) {
        console.log(d);
        loading.close();
        if (d.code == "1") {
          if (d.failed.length > 0) {
            that.type = "error";
            that.title = d.failed.length + " 个文件更新商标状态错误，错误文件如下：";
            that.description = d.failed.join('，');
          } else {
            that.type = "success";
            that.title = that.returnofficialUrls.length + " 个文件更新商标状态成功";
          }
        }
        else {
          that.$message.warning(`2222操作失败，请刷新页面后重新操作!`);
        }
      }).catch(function (e) {
        loading.close();
        that.$message.warning(`3333操作失败，请刷新页面后重新操作`);
      });
    },
    handleSelectionChange: function(val) {
      this.multipleSelection = val;
      console.log(val);
    },
    addaddr: function() {
      this.$root.pushx({
        title: "",
        name: "/useraddr"
      });
    },
    onRowClick(row, key, e){
      if (key == "upload") {
        window.open(row.officialFileUrl);
      }
      if (key == "applymail") {
        this.form.name = row.name;
        this.form.mobile = row.mobile;
        this.form.address = row.address;
        this.row = row;
        this.dialogFormVisible = true;
      }
      if (key == "mydetail") {
        debugger;
        this.$root.pushx({
          title: "订单详情",
          name: "/tmOrderDetail",
          params: {
            orderNum: row.trademark.order.code
          }
        });
      }
    },
    toolbarclick(key, b, selectedRows){
      console.log(key, "key??????????????????????????????????????");
      if (key == "batchDownload") {
        console.log(selectedRows, "batchDownload...................");

        if (!selectedRows) {
          this.$message({
            type: 'warning',
            message: '请至少选择一行数据!'
          });
          return;
        }
        const loading = this.$loading({
          lock: true,
          text: 'Loading',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        });
        var that = this;
        this.$root.postReq("/web/tmofficialCtl/batchDownload", { "selectedRows": selectedRows }).then(d => {
          loading.close();
          if (d.code == 1) {
            window.open(d.url);
            that.fetchData();
          } else {
            this.$message({
              type: 'false',
              message: d.msg
            });
            that.fetchData();
          }
        });
      }
    },
    btnvisbleMethod(row, btn){
      if (row.trademark.order.sveItemType == "ip" && row.trademark.order.producttype_id == 1) {
        return true;
      } else {
        if (btn.key == "mydetail") {
          return false;
        }
      }
      if (row.officialType != "5") {
        if (btn.key == "applymail") {
          return false;
        }
      }
      return true;
    },
  },
  computed: Vuex.mapState({
    count: state => state.count,
    headStyle: function () {
      return { "background-color": "white" };
    }
  }),
    vname: "gsb_tmofficial"
}
