|
@@ -152,14 +152,12 @@ export default {
|
|
|
data() {
|
|
|
var isnumber = (rule, value, callback) => {
|
|
|
debugger
|
|
|
- var reg = "^[1]+[2,3,4,5,6,7,8,9]+\d{9}";//小数点左边最高16位,小数点右边最多4位
|
|
|
+ var reg = /^1[3456789]\d{9}$/;//小数点左边最高16位,小数点右边最多4位
|
|
|
if (reg.test(value)) {
|
|
|
callback();
|
|
|
- } else if (value == "" && value == null && value == undefined) {
|
|
|
- callback(new Error("请输入加价百分比"));
|
|
|
- } else {
|
|
|
- callback(new Error("输入正确的数字,小数点后可1到2位"));
|
|
|
- }
|
|
|
+ } else
|
|
|
+ callback(new Error("请输入正确的手机号"));
|
|
|
+
|
|
|
|
|
|
};
|
|
|
return {
|
|
@@ -216,7 +214,7 @@ export default {
|
|
|
{ required: true, message: '公司地址不能为空', trigger: 'change' }
|
|
|
],
|
|
|
ContactUserId: [
|
|
|
- { required: true, message: '公司地址不能为空', trigger: 'change' }
|
|
|
+ { required: true, message: '负责人不能为空', trigger: 'change' }
|
|
|
],
|
|
|
Tel: [
|
|
|
{ validator: isnumber, message: '请输入正确的手机号', trigger: 'change' }
|
|
@@ -295,50 +293,57 @@ export default {
|
|
|
upDateBtn() {
|
|
|
debugger
|
|
|
var that = this
|
|
|
- if (that.updata.Id != 0) {
|
|
|
- if (that.updata.CompanyName == "" || that.updata.CompanyName == undefined) {
|
|
|
- that.$message.error("公司名称不能为空");
|
|
|
- return
|
|
|
- }
|
|
|
- if (that.updata.CompanyCode == "") {
|
|
|
- that.$message.error("公司code不能为空");
|
|
|
- return
|
|
|
- }
|
|
|
- if (that.updata.Address == "") {
|
|
|
- that.$message.error("公司地址不能为空");
|
|
|
- return
|
|
|
- }
|
|
|
- if (that.updata.ContactUserId == 0) {
|
|
|
- that.$message.error("请选择公司负责人");
|
|
|
- return
|
|
|
- }
|
|
|
+ that.$refs.updata.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
|
|
|
- debugger;
|
|
|
- var url = "http://localhost:5256/api/System/EditCompany"
|
|
|
- var that = this
|
|
|
- that.$axios({
|
|
|
- method: 'post',
|
|
|
- url: url,
|
|
|
- headers: {
|
|
|
- Authorization: 'Bearer ' + that.token
|
|
|
- },
|
|
|
- data: that.updata
|
|
|
- }).then(function (res) {
|
|
|
- console.log(res)
|
|
|
- debugger
|
|
|
- if (res.data.code == 200) {
|
|
|
- that.$message({
|
|
|
- message: '修改成功!',
|
|
|
- type: 'success'
|
|
|
- });
|
|
|
- that.upDataVisible = false
|
|
|
- that.company();
|
|
|
- } else {
|
|
|
- that.$message.error('保修改失败!');
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
+ if (that.updata.Id != 0) {
|
|
|
+ if (that.updata.CompanyName == "" || that.updata.CompanyName == undefined) {
|
|
|
+ that.$message.error("公司名称不能为空");
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (that.updata.CompanyCode == "") {
|
|
|
+ that.$message.error("公司code不能为空");
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (that.updata.Address == "") {
|
|
|
+ that.$message.error("公司地址不能为空");
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (that.updata.ContactUserId == 0) {
|
|
|
+ that.$message.error("请选择公司负责人");
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
+ debugger;
|
|
|
+ var url = "http://localhost:5256/api/System/EditCompany"
|
|
|
+ var that = this
|
|
|
+ that.$axios({
|
|
|
+ method: 'post',
|
|
|
+ url: url,
|
|
|
+ headers: {
|
|
|
+ Authorization: 'Bearer ' + that.token
|
|
|
+ },
|
|
|
+ data: that.updata
|
|
|
+ }).then(function (res) {
|
|
|
+ console.log(res)
|
|
|
+ debugger
|
|
|
+ if (res.data.code == 200) {
|
|
|
+ that.$message({
|
|
|
+ message: '修改成功!',
|
|
|
+ type: 'success'
|
|
|
+ });
|
|
|
+ that.upDataVisible = false
|
|
|
+ that.company();
|
|
|
+ } else {
|
|
|
+ that.$message.error('保修改失败!');
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.$message.error('请完善信息在保存!');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
//关闭修改框
|
|
|
handleClose(done) {
|
|
@@ -390,71 +395,79 @@ export default {
|
|
|
this.addDataVisible = true
|
|
|
|
|
|
},
|
|
|
+
|
|
|
addDateBtn() {
|
|
|
debugger
|
|
|
- var that = this
|
|
|
- this.adddata.ContactUserId = this.valueUserValue
|
|
|
- this.adddata.ParentCompanyId = this.valueCompanyValue
|
|
|
- this.adddata.CreateUserId = JSON.parse(localStorage.getItem('userinif')).userInfo.userId
|
|
|
- if (that.adddata.CompanyName == "" || that.updata.CompanyName == undefined) {
|
|
|
- that.$message.error("公司名称不能为空");
|
|
|
- return
|
|
|
- }
|
|
|
- if (that.adddata.CompanyCode == "") {
|
|
|
- that.$message.error("公司code不能为空");
|
|
|
- return
|
|
|
- }
|
|
|
- if (that.adddata.Address == "") {
|
|
|
- that.$message.error("公司地址不能为空");
|
|
|
- return
|
|
|
- }
|
|
|
- if (that.adddata.ContactUserId == 0) {
|
|
|
- that.$message.error("请选择公司负责人");
|
|
|
- return
|
|
|
- }
|
|
|
- if (that.adddata.Tel == "") {
|
|
|
- that.$message.error("请输入手机号");
|
|
|
- return
|
|
|
- } else {
|
|
|
- var reg = /^1[3456789]\d{9}$/;
|
|
|
- if (!reg.test(that.adddata.Tel)) {
|
|
|
- that.$message.error("请输入有效的手机号");
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
+ this.$refs.adddata.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ var that = this
|
|
|
+ this.adddata.ContactUserId = this.valueUserValue
|
|
|
+ this.adddata.ParentCompanyId = this.valueCompanyValue
|
|
|
+ this.adddata.CreateUserId = JSON.parse(localStorage.getItem('userinif')).userInfo.userId
|
|
|
+ if (that.adddata.CompanyName == "" || that.updata.CompanyName == undefined) {
|
|
|
+ that.$message.error("公司名称不能为空");
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (that.adddata.CompanyCode == "") {
|
|
|
+ that.$message.error("公司code不能为空");
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (that.adddata.Address == "") {
|
|
|
+ that.$message.error("公司地址不能为空");
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (that.adddata.ContactUserId == 0) {
|
|
|
+ that.$message.error("请选择公司负责人");
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (that.adddata.Tel == "") {
|
|
|
+ that.$message.error("请输入手机号");
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ var reg = /^1[3456789]\d{9}$/;
|
|
|
+ if (!reg.test(that.adddata.Tel)) {
|
|
|
+ that.$message.error("请输入有效的手机号");
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- var url = "http://localhost:5256/api/System/AddCompany"
|
|
|
+ var url = "http://localhost:5256/api/System/AddCompany"
|
|
|
|
|
|
- that.$axios({
|
|
|
- method: 'post',
|
|
|
- url: url,
|
|
|
- headers: {
|
|
|
- Authorization: 'Bearer ' + that.token
|
|
|
- },
|
|
|
- data: that.adddata
|
|
|
- }).then(function (res) {
|
|
|
- console.log(res)
|
|
|
- debugger
|
|
|
- if (res.data.code == 200) {
|
|
|
- that.$message({
|
|
|
- message: '添加成功!',
|
|
|
- type: 'success'
|
|
|
- });
|
|
|
- debugger
|
|
|
- that.addDataVisible = false;
|
|
|
- that.adddata.CreateUserId = 0
|
|
|
- that.adddata.CompanyCode = ""
|
|
|
- that.adddata.CompanyName = ""
|
|
|
- that.adddata.Address = ""
|
|
|
- that.adddata.ContactUserId = 0
|
|
|
- that.adddata.Tel = ""
|
|
|
- that.adddata.ParentCompanyId = 0
|
|
|
- that.adddata.Remark = ""
|
|
|
- that.valueUserValue = 0
|
|
|
- that.valueCompanyValue = 0
|
|
|
- that.company();
|
|
|
+ that.$axios({
|
|
|
+ method: 'post',
|
|
|
+ url: url,
|
|
|
+ headers: {
|
|
|
+ Authorization: 'Bearer ' + that.token
|
|
|
+ },
|
|
|
+ data: that.adddata
|
|
|
+ }).then(function (res) {
|
|
|
+ console.log(res)
|
|
|
+ debugger
|
|
|
+ if (res.data.code == 200) {
|
|
|
+ that.$message({
|
|
|
+ message: '添加成功!',
|
|
|
+ type: 'success'
|
|
|
+ });
|
|
|
+ debugger
|
|
|
+ that.addDataVisible = false;
|
|
|
+ that.adddata.CreateUserId = 0
|
|
|
+ that.adddata.CompanyCode = ""
|
|
|
+ that.adddata.CompanyName = ""
|
|
|
+ that.adddata.Address = ""
|
|
|
+ that.adddata.ContactUserId = 0
|
|
|
+ that.adddata.Tel = ""
|
|
|
+ that.adddata.ParentCompanyId = 0
|
|
|
+ that.adddata.Remark = ""
|
|
|
+ that.valueUserValue = 0
|
|
|
+ that.valueCompanyValue = 0
|
|
|
+ that.company();
|
|
|
+ } else {
|
|
|
+ that.$message.error('添加失败!');
|
|
|
+ }
|
|
|
+ })
|
|
|
} else {
|
|
|
- that.$message.error('添加失败!');
|
|
|
+ this.$message.error('请完善信息在保存!');
|
|
|
+ return false;
|
|
|
}
|
|
|
})
|
|
|
},
|