{
  template: '${tmpl}',
    data: function() {
      return {
        d: {},
        action: "",
        multipleSelection: [],
        returnofficialUrls: [],
        isSingleSelect: false,
        top: 1,
        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){
      if (column.property == "created_at") {
        var date = new Date(row["created_at"]);
        var time = date.toLocaleDateString();
        return time;
      }
      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.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(`操作失败，请刷新页面后重新操作!`);
        }
      }).catch(function (e) {
        loading.close();
        that.$message.warning(`操作异常，请刷新页面后重新操作`);
      });
    },
    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;
      }
    },
    toolbarclick(key, b, selectedRows){
      if (key == "news") {
        this.top = 2;
      }
    },
    btnvisbleMethod(row, btn){
      if (row.officialMailType != "2") {
        if (btn.key == "applymail") {
          return false;
        }
      }
      return true;
    },
  },
  computed: Vuex.mapState({
    count: state => state.count,
    headStyle: function () {
      return { "background-color": "white" };
    }
  }),
    vname: "gsb_tmofficial"
}
