VOL_常用记录!!

目录

  • 前端
    • 1.js如何获取当前时间(yy-MM-dd HH:MM:SS)
    • 2.http请求
    • 3.grid扩展js常用
  • 后端
    • 1.待补充


前端

1.js如何获取当前时间(yy-MM-dd HH:MM:SS)

getCurrentTime() {
      const now = new Date();
      return `${now.getFullYear()}-${(now.getMonth() + 1)
        .toString()
        .padStart(2, "0")}-${now.getDate().toString().padStart(2, "0")} ${now
        .getHours()
        .toString()
        .padStart(2, "0")}:${now.getMinutes().toString().padStart(2, "0")}:${now
        .getSeconds()
        .toString()
        .padStart(2, "0")}`;
    },

2.http请求

// 添加请求
submit() {
      let data = {
        delKeys: null,
        detailData: null,
        mainData: this.fields,
      };
      let Url = "api/表名/Add";
      this.http.post(Url, data, true).then((result) => {
        if (result.status == true) {
          this.$Message.success("提交成功");
          this.reset();
          this.$emit("call-parent-method");
        } else {
          this.$Message.success("失败" + reslut.message);
        }
      });
    },
//删除请求
        let url = "api/表名/del";
        this.http.post(url, [rows[0].PRODUCT_DETAIL_LIST_ID], false).then((reslut) => {
          if (reslut.status === true) {
            //删除行
            //this.$refs.table1.delRow();
            this.$Message.error("删除成功");
          } else {
            this.$Message.error("失败" + reslut.message);
          }
        });
//获取请求
        let Url = "api/表名/GetPageData";
        this.http.post(Url, {}, true).then((result) => {
          if (result.status == true) {
            // this.$Message.success("成功");
          } else {
            this.$Message.error("失败" + result.message);
          }
        });

3.grid扩展js常用

onInit() {
	// 1.grid的table单选
 	this.single = true;
 	//设置界面上最多可显示的按钮数量 
    this.maxBtnLength = 6; 	
 	// 2.选择数据
	this.editFormOptions.forEach(x => {
	        x.forEach(item => {
	          if (item.field == '选择的字段') {
	            //给编辑表单设置[选择数据]操作,extra具体配置见volform组件api
	            item.extra = {
	              icon: "el-icon-zoom-out",
	              text: "选择数据",
	              style: "color:#2196F3;font-size: 12px;cursor: pointer;",
	              click: item => {
	                this.$refs.modelBody.openDemo("RD_PROJECT_ModelBody");
	              }
	            }
	          }
	        })
	      })
	      
	// 3.grid添加按钮
      this.buttons.splice(2, 0, ...
        [{
          name: "查 看",
          icon: 'md-add',
          type: 'success',
          onClick: function () {
            let row = this.getSelectRows()
            if (row.length > 0) {
              this.$store.getters.data().hahaha = { obj: row[0].DEVELOPMENT_PROJECT_NO };
              $this.$refs.gridHeader.open2()
            }
            else {
              this.$Message.error('请选择一条数据');
              return
            }
          }
        }
        ]
      )
	
}

后端

1.待补充

你可能感兴趣的:(vue.js,vscode)