Commit 64383881 by 谢明辉

a

1 parent 2c4365cf
This diff could not be displayed because it is too large.
<template> <template>
<div id="login_box" @click.ctrl.meta.alt="manager"> <div id="login_box" @click.ctrl.meta.alt="manager">
<el-row type="flex" justify="center" align="middle" style="height:80%"> <el-row type="flex" justify="center" align="middle" style="height:80%">
<el-card class="box-card" shadow="hover" style="width:25%"> <el-card class="box-card" shadow="hover" style="min-width:25%">
<div slot="header" style="text-align:center" class="clearfix"> <div slot="header" style="text-align:center" class="clearfix">
<span style="font-size:24px">合同管理系统</span> <span style="font-size:24px">合同管理系统</span>
</div> </div>
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<el-form-item> <el-form-item>
<el-button-group> <el-button-group>
<el-button type="primary" @click="submitForm('login_form')">提交</el-button> <el-button type="primary" @click="submitForm('login_form')">提交</el-button>
<el-button @click="resetForm('login_form')">重置</el-button> <el-button @click="resetForm('login_form')">重置</el-button>
</el-button-group> </el-button-group>
</el-form-item> </el-form-item>
</el-form> </el-form>
...@@ -33,325 +33,328 @@ ...@@ -33,325 +33,328 @@
</template> </template>
<script> <script>
export default { export default {
name: "login", name: "login",
data() { data() {
return { return {
password_type: "password", password_type: "password",
view_password: "icon i-password-not-view", view_password: "icon i-password-not-view",
contract_base_url: disparch_data.contract_base_url, contract_base_url: this.$disparch_data.contract_base_url,
code_base_url: disparch_data.code_base_url, code_base_url: this.$disparch_data.code_base_url,
auth_base_url: disparch_data.auth_base_url, auth_base_url: this.$disparch_data.auth_base_url,
net_error: false, net_error: false,
form: { form: {
username: "", username: "",
password: "" password: ""
}, },
rules: { rules: {
username: [{ required: true, message: "请输入用户名", trigger: "blur" }] username: [{ required: true, message: "请输入用户名", trigger: "blur" }]
// password: [ // password: [
// { required: true, message: "请输入登录密码", trigger: "blur" } // { required: true, message: "请输入登录密码", trigger: "blur" }
// ] // ]
} }
}; };
},
methods: {
show_password() {
if (this.password_type == "password") {
(this.password_type = "text"),
(this.view_password = "icon i-password-view");
} else {
(this.password_type = "password"),
(this.view_password = "icon i-password-not-view");
}
}, },
submitForm(form) { methods: {
this.$refs[form].validate(valid => { show_password() {
if (valid) { if (this.password_type == "password") {
this.$Axios({ (this.password_type = "text"),
method: "post", (this.view_password = "icon i-password-view");
url: this.auth_base_url + "users/login", } else {
headers: { "Content-Type": "application/json" }, (this.password_type = "password"),
data: { (this.view_password = "icon i-password-not-view");
user_type: "user", }
username: this.form.username, },
password: this.form.password submitForm(form) {
} this.$refs[form].validate(valid => {
}) if (valid) {
.then(res => { this.$Axios({
if (res.data.ecode) { method: "post",
url: this.auth_base_url + "users/login",
headers: { "Content-Type": "application/json" },
data: {
user_type: "user",
username: this.form.username,
password: this.form.password
}
})
.then(res => {
if (res.data.ecode) {
this.$message({
message: res.data.enote,
type: "error"
});
} else {
window.localStorage.setItem("username", this.form.username);
sessionStorage.setItem("login_check", true);
sessionStorage.setItem("user_unid", res.data.user_unid);
sessionStorage.setItem("rtoken", res.data.rtoken);
sessionStorage.setItem(
"user_roles",
JSON.stringify(res.data.roles)
);
sessionStorage.setItem("user_name", res.data.user_name);
this.get_provinces();
this.get_contract_state_data();
this.get_contract_type_data();
this.get_amount_state_unid_data();
this.get_mainten_start_point_data();
this.get_product_line_type_data();
this.get_payment_type_data();
this.$router.push({ path: "/nav/main" });
}
})
.catch(err => {
this.$message({ this.$message({
message: res.data.enote, message: "登录错误",
type: "error" type: "error"
}); });
} else {
window.localStorage.setItem("username", this.form.username);
sessionStorage.setItem("login_check",true)
sessionStorage.setItem("user_unid",res.data.user_unid)
sessionStorage.setItem("rtoken",res.data.rtoken)
sessionStorage.setItem("user_roles",JSON.stringify(res.data.roles));
sessionStorage.setItem("user_name",res.data.user_name)
this.get_provinces();
this.get_contract_state_data();
this.get_contract_type_data();
this.get_amount_state_unid_data();
this.get_mainten_start_point_data();
this.get_product_line_type_data();
this.get_payment_type_data();
this.$router.push({ path: "/nav/main" });
}
})
.catch(err => {
this.$message({
message: "登录错误",
type: "error"
}); });
}); }
} });
}); },
}, resetForm(form) {
resetForm(form) { this.$refs[form].resetFields();
this.$refs[form].resetFields(); },
}, is_login() {},
is_login() {}, get_provinces() {
get_provinces() { this.$Axios({
this.$Axios({ method: "get",
method: "get", url: this.code_base_url + "countries/0E229CD043/provinces"
url: this.code_base_url + "countries/0E229CD043/provinces"
})
.then(response => {
sessionStorage.setItem(
"provinces",
JSON.stringify(response.data.list_data)
);
}) })
.catch(err => { .then(response => {
this.$router.push({ path: "/" }); sessionStorage.setItem(
this.$message({ "provinces",
message: "网络错误", JSON.stringify(response.data.list_data)
type: "error" );
})
.catch(err => {
this.$router.push({ path: "/" });
this.$message({
message: "网络错误",
type: "error"
});
}); });
}); },
}, get_contract_state_data() {
get_contract_state_data() { this.$Axios({
this.$Axios({ method: "get",
method: "get", url: this.code_base_url + "custom/cates/13BEFACBCF/codes"
url: this.code_base_url + "custom/cates/13BEFACBCF/codes"
})
.then(res => {
sessionStorage.setItem(
"contract_state_data",
JSON.stringify(res.data.list_data)
);
}) })
.catch(err => { .then(res => {
this.$router.push({ path: "/" }); sessionStorage.setItem(
this.$message({ "contract_state_data",
message: "网络错误", JSON.stringify(res.data.list_data)
type: "error" );
})
.catch(err => {
this.$router.push({ path: "/" });
this.$message({
message: "网络错误",
type: "error"
});
}); });
}); },
}, get_contract_type_data() {
get_contract_type_data() { this.$Axios({
this.$Axios({ method: "get",
method: "get", url: this.code_base_url + "custom/cates/8EC31D08A0/codes"
url: this.code_base_url + "custom/cates/8EC31D08A0/codes"
})
.then(res => {
sessionStorage.setItem(
"contract_type_data",
JSON.stringify(res.data.list_data)
);
}) })
.catch(err => { .then(res => {
this.$router.push({ path: "/" }); sessionStorage.setItem(
this.$message({ "contract_type_data",
message: "网络错误", JSON.stringify(res.data.list_data)
type: "error" );
})
.catch(err => {
this.$router.push({ path: "/" });
this.$message({
message: "网络错误",
type: "error"
});
}); });
}); },
}, get_amount_state_unid_data() {
get_amount_state_unid_data() { this.$Axios({
this.$Axios({ method: "get",
method: "get", url: this.code_base_url + "custom/cates/42407C5EF2/codes"
url: this.code_base_url + "custom/cates/42407C5EF2/codes"
})
.then(res => {
sessionStorage.setItem(
"amount_state_unid_data",
JSON.stringify(res.data.list_data)
);
}) })
.catch(err => { .then(res => {
this.$router.push({ path: "/" }); sessionStorage.setItem(
this.$message({ "amount_state_unid_data",
message: "网络错误", JSON.stringify(res.data.list_data)
type: "error" );
})
.catch(err => {
this.$router.push({ path: "/" });
this.$message({
message: "网络错误",
type: "error"
});
}); });
}); },
}, get_mainten_start_point_data() {
get_mainten_start_point_data() { this.$Axios({
this.$Axios({ method: "get",
method: "get", url: this.code_base_url + "custom/cates/55B997D596/codes"
url: this.code_base_url + "custom/cates/55B997D596/codes"
})
.then(res => {
sessionStorage.setItem(
"mainten_start_point_data",
JSON.stringify(res.data.list_data)
);
}) })
.catch(err => { .then(res => {
this.$router.push({ path: "/" }); sessionStorage.setItem(
this.$message({ "mainten_start_point_data",
message: "网络错误", JSON.stringify(res.data.list_data)
type: "error" );
})
.catch(err => {
this.$router.push({ path: "/" });
this.$message({
message: "网络错误",
type: "error"
});
}); });
}); },
}, get_product_line_type_data() {
get_product_line_type_data() { this.$Axios({
this.$Axios({ method: "get",
method: "get", url: this.code_base_url + "custom/cates/4FC51AD3C9/codes"
url: this.code_base_url + "custom/cates/4FC51AD3C9/codes"
})
.then(res => {
sessionStorage.setItem(
"product_line_type_data",
JSON.stringify(res.data.list_data)
);
}) })
.catch(err => { .then(res => {
this.$router.push({ path: "/" }); sessionStorage.setItem(
this.$message({ "product_line_type_data",
message: "网络错误", JSON.stringify(res.data.list_data)
type: "error" );
})
.catch(err => {
this.$router.push({ path: "/" });
this.$message({
message: "网络错误",
type: "error"
});
}); });
}); },
}, get_payment_type_data() {
get_payment_type_data() { this.$Axios({
this.$Axios({ method: "get",
method: "get", url: this.code_base_url + "custom/cates/215649FB93/codes"
url: this.code_base_url + "custom/cates/215649FB93/codes"
})
.then(res => {
sessionStorage.setItem(
"payment_type_data",
JSON.stringify(res.data.list_data)
);
}) })
.catch(err => { .then(res => {
this.$router.push({ path: "/" }); sessionStorage.setItem(
this.$message({ "payment_type_data",
message: "网络错误", JSON.stringify(res.data.list_data)
type: "error" );
})
.catch(err => {
this.$router.push({ path: "/" });
this.$message({
message: "网络错误",
type: "error"
});
}); });
}); },
}, get_salesperson() {
get_salesperson() { this.$Axios({
this.$Axios({ method: "get",
method: "get", url: this.auth_base_url + "users",
url: this.auth_base_url + "users", params: {
params: { norm_type: "employee"
norm_type: "employee" }
}
})
.then(response => {
sessionStorage.setItem(
"salesperson_unid_selected_data",
JSON.stringify(response.data.list_data)
);
}) })
.catch(err => { .then(response => {
this.$router.push({ path: "/" }); sessionStorage.setItem(
this.$message({ "salesperson_unid_selected_data",
message: "网络错误", JSON.stringify(response.data.list_data)
type: "error" );
})
.catch(err => {
this.$router.push({ path: "/" });
this.$message({
message: "网络错误",
type: "error"
});
}); });
}); },
}, get_contract_unid() {
get_contract_unid() { this.$Axios({
this.$Axios({ method: "get",
method: "get", url: this.contract_base_url + "codes"
url: this.contract_base_url + "codes"
})
.then(response => {
sessionStorage.setItem(
"contract_unid_selected_data",
JSON.stringify(response.data)
);
}) })
.catch(err => { .then(response => {
this.$router.push({ path: "/" }); sessionStorage.setItem(
this.$message({ "contract_unid_selected_data",
message: "网络错误", JSON.stringify(response.data)
type: "error" );
})
.catch(err => {
this.$router.push({ path: "/" });
this.$message({
message: "网络错误",
type: "error"
});
}); });
}); },
}, get_projects() {
get_projects() { this.$Axios({
this.$Axios({ method: "get",
method: "get", url: this.contract_base_url + "projects",
url: this.contract_base_url + "projects", headers: { "Content-Type": "application/json" }
headers: { "Content-Type": "application/json" }
})
.then(response => {
sessionStorage.setItem(
"project_unid_selected_data",
JSON.stringify(response.data)
);
}) })
.catch(err => { .then(response => {
this.$router.push({ path: "/" }); sessionStorage.setItem(
this.$message({ "project_unid_selected_data",
message: "网络错误", JSON.stringify(response.data)
type: "error" );
})
.catch(err => {
this.$router.push({ path: "/" });
this.$message({
message: "网络错误",
type: "error"
});
}); });
}); },
}, manager() {
manager() { sessionStorage.setItem("manager", "1");
sessionStorage.setItem('manager','1') sessionStorage.setItem("login_check", "1");
sessionStorage.setItem('login_check','1') this.get_provinces();
this.get_provinces(); this.get_contract_state_data();
this.get_contract_state_data(); this.get_contract_type_data();
this.get_contract_type_data(); this.get_amount_state_unid_data();
this.get_amount_state_unid_data(); this.get_mainten_start_point_data();
this.get_mainten_start_point_data(); this.get_product_line_type_data();
this.get_product_line_type_data(); this.get_payment_type_data();
this.get_payment_type_data(); this.$router.push({ path: "/nav/main" });
this.$router.push({ path: "/nav/main" }); },
}, get_customers() {
get_customers() { this.$Axios({
this.$Axios({ method: "get",
method: "get", url: this.contract_base_url + "customers",
url: this.contract_base_url + "customers", headers: { "Content-Type": "application/json" }
headers: { "Content-Type": "application/json" }
})
.then(response => {
sessionStorage.setItem(
"customer_unid_selected_data",
JSON.stringify(response.data)
);
}) })
.catch(err => { .then(response => {
this.$router.push({ path: "/" }); sessionStorage.setItem(
this.$message({ "customer_unid_selected_data",
message: "网络错误", JSON.stringify(response.data)
type: "error" );
})
.catch(err => {
this.$router.push({ path: "/" });
this.$message({
message: "网络错误",
type: "error"
});
}); });
}); }
},
mounted() {
this.form.username = localStorage.getItem("username");
} }
}, };
mounted() {
this.form.username = localStorage.getItem("username");
}
};
</script> </script>
<style scoped> <style scoped>
#login_box { #login_box {
height: 100%; height: 100%;
} }
#fankui{ #fankui {
text-align: center; text-align: center;
margin-top: 0; margin-top: 0;
} }
......
...@@ -22,12 +22,25 @@ ...@@ -22,12 +22,25 @@
<el-button type="primary" @click="project_name_add">添加</el-button> <el-button type="primary" @click="project_name_add">添加</el-button>
</el-col> </el-col>
</el-row> </el-row>
<el-row style="border-bottom:1px solid rgb(235, 238, 245);padding-bottom:18px">
<el-col :span="6">
<el-button class="add_button" type="primary" @click="add_login_user">添加登录用户</el-button>
</el-col>
</el-row>
<el-row> <el-row>
<el-col :span="6"> <el-col :span="6">
<el-button class="add_button" type="primary" @click="login_user_dialog_show = true">添加登录用户</el-button> <el-button class="add_button" type="primary" @click="product_line_type">产品线类型</el-button>
</el-col>
<el-col :span="6">
<el-button class="add_button" type="primary" @click="contract_statu">合同状态</el-button>
</el-col>
<el-col :span="6">
<el-button class="add_button" type="primary" @click="contract_type">合同性质</el-button>
</el-col>
<el-col :span="6">
<el-button class="add_button" type="primary" @click="amount_statu">账款状态</el-button>
</el-col> </el-col>
</el-row> </el-row>
<el-dialog id="login_user_dialog" title="添加登录户" :visible.sync="login_user_dialog_show" width="30%" :show-close="false"> <el-dialog id="login_user_dialog" title="添加登录户" :visible.sync="login_user_dialog_show" width="30%" :show-close="false">
<el-form :model="login_user_form" label-width="100px" label-position="left" :rules="login_user_form_rules" ref="login_user_form"> <el-form :model="login_user_form" label-width="100px" label-position="left" :rules="login_user_form_rules" ref="login_user_form">
<el-form-item label="用户类型" prop="role_unid"> <el-form-item label="用户类型" prop="role_unid">
...@@ -43,224 +56,236 @@ ...@@ -43,224 +56,236 @@
<el-input v-model="login_user_form.name" placeholder="姓名" style="width:100%"></el-input> <el-input v-model="login_user_form.name" placeholder="姓名" style="width:100%"></el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button @click="login_user_dialog_cancel()">取 消</el-button> <el-button @click="login_user_dialog_cancel()">取 消</el-button>
<el-button type="primary" @click="login_user_dialog_confirm()">确 定</el-button> <el-button type="primary" @click="login_user_dialog_confirm()">确 定</el-button>
</div> </div>
</el-dialog> </el-dialog>
<el-dialog :visible.sync="add_dialog_show" width="30%" :show-close="false" style="max-height:800px">
<el-input v-model="add_data.text"></el-input>
<el-button type="primary" style="width:100%;margin-bottom:20px;margin-top:5px" @click="add_to_database">添加</el-button>
<el-table :data="add_data.data" highlight-current-row border>
<el-table-column label="名称" prop="name" min-width="30%" align="center">
</el-table-column>
<el-table-column label="码" prop="code" min-width="30%" align="center">
</el-table-column>
<el-table-column label="操作" min-width="20%" align="center" fixed="right">
<template slot-scope="scope">
<el-button type="text" @click="delete_code(scope.row)">
删除
</el-button>
</template>
</el-table-column>
</el-table>
</el-dialog>
</el-card> </el-card>
</template> </template>
<script> <script>
export default { export default {
name: "manage", name: "manage",
data() { data() {
return { return {
login_user_dialog_show: false, add_dialog_show: false,
code_base_url: disparch_data.code_base_url, login_user_dialog_show: false,
contract_base_url: disparch_data.contract_base_url, code_base_url: this.$disparch_data.code_base_url,
auth_base_url: disparch_data.auth_base_url, contract_base_url: this.$disparch_data.contract_base_url,
contract_unid: null, auth_base_url: this.$disparch_data.auth_base_url,
customer_name: null, contract_unid: null,
salesperson: null, customer_name: null,
project_name: null, salesperson: null,
project_name: null,
roles: [], add_data: {
login_user_form: { text: null,
role_unid: "", data: [],
username: "", url: null
name: "",
password: "0000",
norm_type: "login"
},
login_user_form_rules: {
username: {
required: true,
pattern: /^[a-zA-Z]{2,8}$/,
message: "请输入2至8位英文",
trigger: "blur"
}, },
name: { roles: [],
required: true, login_user_form: {
message: "请输入用户姓名", role_unid: "",
trigger: "blur" username: "",
name: "",
password: "0000",
norm_type: "login"
}, },
role_unid: {
required: true, login_user_form_rules: {
message: "请选择用户类型", username: {
trigger: "blur" required: true,
pattern: /^[a-zA-Z]{2,8}$/,
message: "请输入2至8位英文",
trigger: "blur"
},
name: {
required: true,
message: "请输入用户姓名",
trigger: "blur"
},
role_unid: {
required: true,
message: "请选择用户类型",
trigger: "blur"
}
} }
} };
};
},
methods: {
contract_unid_add() {
if (this.contract_unid) {
this.$Axios({
method: "post",
data: { contract_unid: this.contract_unid },
url: this.contract_base_url,
headers: { "Content-Type": "application/json" }
})
.then(response => {
if (response.data.ecode == "200") {
this.contract_unid = null;
this.show_message("添加成功", "success");
} else if (response.data.ecode == "600") {
this.show_message("重复的合同编号", "error");
} else {
this.show_message("添加失败", "error");
}
})
.catch(err => {
console.log(err);
this.show_message("添加失败", "error");
});
} else {
this.show_message("请填写信息", "info");
}
}, },
customer_name_add() { methods: {
if (this.customer_name) { // -----------------------
product_line_type() {
this.add_data.url = this.code_base_url + "custom/cates/4FC51AD3C9/codes";
this.get_data(this.add_data.url);
},
contract_statu() {
this.add_data.url = this.code_base_url + "custom/cates/13BEFACBCF/codes";
this.get_data(this.add_data.url);
},
contract_type() {
this.add_data.url = this.code_base_url + "custom/cates/8EC31D08A0/codes";
this.get_data(this.add_data.url);
},
amount_statu() {
this.add_data.url = this.code_base_url + "custom/cates/42407C5EF2/codes";
this.get_data(this.add_data.url);
},
delete_code(data) {
this.$Axios({ this.$Axios({
method: "post", method:'delete',
url: this.contract_base_url + "customers", url:this.add_data.url + '/' + data.unid
data: { customer_name: this.customer_name }, }).then(res=>{
headers: { "Content-Type": "application/json" } this.show_message('删除成功','success')
this.get_data(this.add_data.url)
}) })
.then(response => {
if (response.data.ecode == "200") { },
this.customer_name = null; get_data(url) {
this.show_message("添加成功", "success"); this.$Axios.get(url).then(res => {
} else if (response.data.ecode == "600") { if (res.data.list_data) {
this.show_message("重复的客户名称", "error"); this.add_data.data = res.data.list_data;
} else { this.add_dialog_show = true;
this.show_message("添加失败", "error"); }
} });
}) },
.catch(err => { add_to_database() {
console.log(err); var code = 0;
this.show_message("添加失败", "error"); this.add_data.data.forEach(e => {
}); if (e.code > code) {
} else { code = e.code;
this.show_message("请填写信息", "info"); }
} });
}, code++;
salesperson_add(type) {
if (this.salesperson) {
this.$Axios({ this.$Axios({
method: "post", method: "post",
url: this.auth_base_url + "users", url: this.add_data.url,
data: { data: {
norm_type: type, name: this.add_data.text,
username: this.salesperson, note: this.add_data.text,
name: this.salesperson, code: code
password: "0000" }
}, }).then(res => {
headers: { "Content-Type": "application/json" } if (res.data.code == code) {
}) this.show_message("添加成功", "success");
.then(response => { this.add_data.text = null;
if (response.data.name) { this.get_data(this.add_data.url);
this.salesperson = null; }
this.show_message("添加成功", "success"); });
} },
// -----------------------
contract_unid_add() {
if (this.contract_unid) {
this.$Axios({
method: "post",
data: { contract_unid: this.contract_unid },
url: this.contract_base_url,
headers: { "Content-Type": "application/json" }
}) })
.catch(err => { .then(response => {
this.show_message("添加失败", "error"); if (response.data.ecode == "200") {
console.log(err.message); this.contract_unid = null;
}); this.show_message("添加成功", "success");
} else { } else if (response.data.ecode == "600") {
this.show_message("请填写信息", "info"); this.show_message("重复的合同编号", "error");
} } else {
}, this.show_message("添加失败", "error");
project_name_add() { }
if (this.project_name) { })
this.$Axios({ .catch(err => {
method: "post", console.log(err);
url: this.contract_base_url + "projects",
data: { project_name: this.project_name },
headers: { "Content-Type": "application/json" }
})
.then(response => {
this.project_name = null;
if (response.data.ecode == "200") {
this.show_message("添加成功", "success");
} else if (response.data.ecode == "600") {
this.show_message("重复的项目名称", "error");
} else {
this.show_message("添加失败", "error"); this.show_message("添加失败", "error");
} });
} else {
this.show_message("请填写信息", "info");
}
},
customer_name_add() {
if (this.customer_name) {
this.$Axios({
method: "post",
url: this.contract_base_url + "customers",
data: { customer_name: this.customer_name },
headers: { "Content-Type": "application/json" }
}) })
.catch(err => { .then(response => {
console.log(err); if (response.data.ecode == "200") {
this.show_message("添加失败", "error"); this.customer_name = null;
}); this.show_message("添加成功", "success");
} else { } else if (response.data.ecode == "600") {
this.show_message("请填写信息", "info"); this.show_message("重复的客户名称", "error");
} } else {
}, this.show_message("添加失败", "error");
show_message(message, type) { }
this.$message({ })
message: message, .catch(err => {
type: type, console.log(err);
center: true, this.show_message("添加失败", "error");
showClose: true, });
duration: 3000 } else {
}); this.show_message("请填写信息", "info");
}, }
get_roles() { },
this.$Axios({ salesperson_add(type) {
method: "get", if (this.salesperson) {
url: this.auth_base_url + "roles"
})
.then(response => {
if (response.data.list_data) {
this.roles = response.data.list_data;
}
})
.catch(err => {
console.log(err.message);
});
},
login_user_dialog_cancel() {
this.$refs["login_user_form"].resetFields();
this.login_user_dialog_show = false;
},
login_user_dialog_confirm() {
this.$refs["login_user_form"].validate(valid => {
if (valid) {
this.$Axios({ this.$Axios({
method: "post", method: "post",
url: this.auth_base_url + "users", url: this.auth_base_url + "users",
headers: { "Content-Type": "application/json" }, data: {
data: this.login_user_form norm_type: type,
username: this.salesperson,
name: this.salesperson,
password: "0000"
},
headers: { "Content-Type": "application/json" }
}) })
.then(res => { .then(response => {
if (res.data.user_unid) { if (response.data.name) {
this.$Axios({ this.salesperson = null;
method: "post", this.show_message("添加成功", "success");
url: }
this.auth_base_url + })
"users/" + .catch(err => {
res.data.user_unid + this.show_message("添加失败", "error");
"/roles", console.log(err.message);
headers: { "Content-Type": "application/json" }, });
data: { } else {
role_unid: this.login_user_form.role_unid this.show_message("请填写信息", "info");
} }
}) },
.then(res => { project_name_add() {
this.show_message("添加成功,默认密码: 0000", "success"); if (this.project_name) {
this.$refs["login_user_form"].resetFields(); this.$Axios({
this.login_user_dialog_show = false; method: "post",
}) url: this.contract_base_url + "projects",
.catch(err => { data: { project_name: this.project_name },
this.login_user_dialog_show = false; headers: { "Content-Type": "application/json" }
this.show_message("添加失败", "error"); })
}); .then(response => {
this.project_name = null;
if (response.data.ecode == "200") {
this.show_message("添加成功", "success");
} else if (response.data.ecode == "600") {
this.show_message("重复的项目名称", "error");
} else { } else {
this.show_message("添加失败", "error"); this.show_message("添加失败", "error");
} }
...@@ -269,14 +294,87 @@ export default { ...@@ -269,14 +294,87 @@ export default {
console.log(err); console.log(err);
this.show_message("添加失败", "error"); this.show_message("添加失败", "error");
}); });
} else {
this.show_message("请填写信息", "info");
} }
}); },
} show_message(message, type) {
}, this.$message({
created() { message: message,
this.get_roles(); type: type,
} center: true,
}; showClose: true,
duration: 3000
});
},
add_login_user() {
this.$Axios({
method: "get",
url: this.auth_base_url + "roles"
})
.then(response => {
if (response.data.list_data) {
this.roles = response.data.list_data;
this.login_user_dialog_show = true;
} else {
this.show_message("失败", "error");
}
})
.catch(err => {
this.show_message("失败", "error");
console.log(err.message);
});
},
login_user_dialog_cancel() {
this.$refs["login_user_form"].resetFields();
this.login_user_dialog_show = false;
},
login_user_dialog_confirm() {
this.$refs["login_user_form"].validate(valid => {
if (valid) {
this.$Axios({
method: "post",
url: this.auth_base_url + "users",
headers: { "Content-Type": "application/json" },
data: this.login_user_form
})
.then(res => {
if (res.data.user_unid) {
this.$Axios({
method: "post",
url:
this.auth_base_url +
"users/" +
res.data.user_unid +
"/roles",
headers: { "Content-Type": "application/json" },
data: {
role_unid: this.login_user_form.role_unid
}
})
.then(res => {
this.show_message("添加成功,默认密码: 0000", "success");
this.$refs["login_user_form"].resetFields();
this.login_user_dialog_show = false;
})
.catch(err => {
this.login_user_dialog_show = false;
this.show_message("添加失败", "error");
});
} else {
this.show_message("添加失败", "error");
}
})
.catch(err => {
console.log(err);
this.show_message("添加失败", "error");
});
}
});
}
},
created() {}
};
</script> </script>
<style scoped> <style scoped>
...@@ -289,7 +387,8 @@ export default { ...@@ -289,7 +387,8 @@ export default {
.add_button { .add_button {
display: inline-block; display: inline-block;
font-size: 18px; font-size: 18px;
width: 80%; width: 75%;
min-width: 200px;
margin-top: 20px; margin-top: 20px;
} }
......
...@@ -14,14 +14,14 @@ ...@@ -14,14 +14,14 @@
<i class="icon i-file"></i> <i class="icon i-file"></i>
<span slot="title">合同信息</span> <span slot="title">合同信息</span>
</el-menu-item> </el-menu-item>
<el-menu-item index="/nav/manage" v-show="management">
<i class="icon i-setting"></i>
<span slot="title">后台管理</span>
</el-menu-item>
<el-menu-item index="/nav/user"> <el-menu-item index="/nav/user">
<i class="icon i-user"></i> <i class="icon i-user"></i>
<span slot="title">个人管理</span> <span slot="title">个人管理</span>
</el-menu-item> </el-menu-item>
<el-menu-item index="/nav/manage" v-show="management">
<i class="icon i-setting"></i>
<span slot="title">后台管理</span>
</el-menu-item>
<el-menu-item index="" @click="exit"> <el-menu-item index="" @click="exit">
<i class="icon i-login"></i> <i class="icon i-login"></i>
<span slot="title">退出</span> <span slot="title">退出</span>
...@@ -39,65 +39,71 @@ ...@@ -39,65 +39,71 @@
</template> </template>
<script> <script>
export default { export default {
name: "HelloWorld", name: "HelloWorld",
data() { data() {
return { return {
management: false, management: false,
username: "", username: "",
department: "", department: "",
collapse: true, collapse: true,
contract_show: true, contract_show: true
}; };
}, },
methods: { methods: {
contract() { contract() {
if (sessionStorage.getItem("modify")) { if (sessionStorage.getItem("modify")) {
sessionStorage.removeItem("modify"); sessionStorage.removeItem("modify");
}
},
exit() {
this.$confirm("确认退出?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
sessionStorage.clear();
this.$router.push({ path: "/" });
})
.catch(() => {});
} }
}, },
exit() { beforeCreate() {
this.$confirm("确认退出?", "提示", { if (!sessionStorage.getItem("login_check")) {
confirmButtonText: "确定", alert("请登录");
cancelButtonText: "取消", this.$router.push({ path: "/" });
type: "warning" }
}) },
.then(() => { created() {
sessionStorage.clear(); if (
this.$router.push({ path: "/" }); sessionStorage.getItem("user_roles") != "null" &&
}) sessionStorage.getItem("user_roles")
.catch(() => {}); ) {
} var roles = JSON.parse(sessionStorage.getItem("user_roles"));
}, for (let i = 0; i < roles.length; i++) {
beforeCreate() { const e = roles[i];
if (!sessionStorage.getItem("login_check")) { if (e.role_unid == "91d5185d47e3bad099e17570b0dd0ed2") {
alert("请登录"); }
this.$router.push({ path: "/" });
}
},
created() {
if (sessionStorage.getItem("user_roles") != "null" && sessionStorage.getItem("user_roles")) {
var roles = JSON.parse(sessionStorage.getItem("user_roles"));
for (let i = 0; i < roles.length; i++) {
const e = roles[i];
if (e.role_unid == "91d5185d47e3bad099e17570b0dd0ed2") {
this.management = true;
} }
} else {
this.contract_show = false;
}
if (sessionStorage.getItem("user_name") === "Admin") {
this.management = true;
}
if (sessionStorage.getItem("manager")) {
this.management = true;
this.contract_show = true;
} }
}else{
this.contract_show = false;
}
if (sessionStorage.getItem("manager")) {
this.management = true;
this.contract_show = true;
} }
} };
};
</script> </script>
<style> <style>
.el-container > .el-main { .el-container > .el-main {
min-width: 1120px;
text-align: center; text-align: center;
padding-top: 0; padding-top: 0;
padding-left: 0; padding-left: 0;
...@@ -106,10 +112,10 @@ export default { ...@@ -106,10 +112,10 @@ export default {
} }
.el-container, .el-container,
.el-aside { .el-aside {
min-width: 167px;
height: 100%; height: 100%;
} }
.el-aside > .el-menu { .el-aside > .el-menu {
height: 100%; height: 100%;
} }
</style> </style>
...@@ -316,418 +316,428 @@ ...@@ -316,418 +316,428 @@
</template> </template>
<script> <script>
const twodecimalrule = { const twodecimalrule = {
pattern: /((^[1-9]\d*)|^0)(\.\d{2})$/, pattern: /((^[1-9]\d*)|^0)(\.\d{2})$/,
message: "请输入数字并保留两位小数", message: "请输入数字并保留两位小数",
trigger: "blur" trigger: "blur"
}; };
export default { export default {
name: "search", name: "search",
data() { data() {
return { return {
sales: false, sales: false,
salesperson_name: null, salesperson_name: null,
provinces: [], provinces: [],
cities: [], cities: [],
counties: [], counties: [],
code_base_url: disparch_data.code_base_url, code_base_url: this.$disparch_data.code_base_url,
contract_base_url: disparch_data.contract_base_url, contract_base_url: this.$disparch_data.contract_base_url,
month_list: [ month_list: [
"01", "01",
"02", "02",
"03", "03",
"04", "04",
"05", "05",
"06", "06",
"07", "07",
"08", "08",
"09", "09",
"10", "10",
"11", "11",
"12" "12"
], ],
contract_state_data: [], contract_state_data: [],
contract_type_data: [], contract_type_data: [],
product_line_type_data: [], product_line_type_data: [],
amount_state_unid_data: [], amount_state_unid_data: [],
search_form: { search_form: {
contract_unid: null, contract_unid: null,
salesperson_unid: null, salesperson_unid: null,
salesperson_name__like: null, salesperson_name__like: null,
project_name__like: null, project_name__like: null,
customer_name__like: null, customer_name__like: null,
guarantee_period: null, guarantee_period: null,
year: null, year: null,
month: null, month: null,
contract_state: null, contract_state: null,
contract_type: null, contract_type: null,
product_line_type: null, product_line_type: null,
acceptance_type: null, acceptance_type: null,
is_archive: null, is_archive: null,
amount_state_unid: null, amount_state_unid: null,
confirm_income_amount: null, confirm_income_amount: null,
province: null, province: null,
city: null, city: null,
// county: null, // county: null,
start_data: null, start_data: null,
end_date: null, end_date: null,
overdays_start_point: null, overdays_start_point: null,
overdays_end_point: null, overdays_end_point: null,
amount_start_point: null, amount_start_point: null,
amount_end_point: null, amount_end_point: null,
leave_amount_start_point: null, leave_amount_start_point: null,
leave_amount_end_point: null leave_amount_end_point: null
}, },
list_data: [], list_data: [],
limit: 10, limit: 10,
total_data: 0, total_data: 0,
current_page: 1, current_page: 1,
search_form_rules: { search_form_rules: {
confirm_income_amount: twodecimalrule, confirm_income_amount: twodecimalrule,
amount_start_point: twodecimalrule, amount_start_point: twodecimalrule,
amount_end_point: twodecimalrule, amount_end_point: twodecimalrule,
leave_amount_start_point: twodecimalrule, leave_amount_start_point: twodecimalrule,
leave_amount_end_point: twodecimalrule, leave_amount_end_point: twodecimalrule,
overdays_start_point: { overdays_start_point: {
pattern: /((^[1-9]\d*)|^0)$/, pattern: /((^[1-9]\d*)|^0)$/,
message: "请输入正确天数", message: "请输入正确天数",
trigger: "blur" trigger: "blur"
}, },
overdays_end_point: { overdays_end_point: {
pattern: /((^[1-9]\d*)|^0)$/, pattern: /((^[1-9]\d*)|^0)$/,
message: "请输入正确天数", message: "请输入正确天数",
trigger: "blur" trigger: "blur"
}
} }
} };
};
},
computed: {
year_list: function() {
var arr = [];
for (let i = 2000; i < 2041; i++) {
arr.push(i);
}
return arr;
}, },
offset() { computed: {
return (this.current_page - 1) * this.limit; year_list: function() {
}, var a = new Date().getFullYear();
guarantee_period_list() { var arr = [];
var arr = []; for (let i = a; i >= 2000; i--) {
var a = 6; arr.push(i);
for (let i = 0; i < 10; i++) { }
const element = (10)[i]; return arr;
arr.push(a); },
a += 6; offset() {
return (this.current_page - 1) * this.limit;
},
guarantee_period_list() {
var arr = [];
var a = 6;
for (let i = 0; i < 10; i++) {
const element = (10)[i];
arr.push(a);
a += 6;
}
return arr;
} }
return arr;
}
},
methods: {
import_click() {
document.getElementById("import_unview").click();
}, },
import_contract() { methods: {
if (!document.getElementById("import_unview").files[0]) { import_click() {
return; document.getElementById("import_unview").click();
} },
var form = new FormData(); import_contract() {
form.append("file", document.getElementById("import_unview").files[0]); if (!document.getElementById("import_unview").files[0]) {
this.$Axios({ return;
method: "post", }
url: this.contract_base_url + "import", var form = new FormData();
data: form form.append("file", document.getElementById("import_unview").files[0]);
}) this.$Axios({
.then(res => { method: "post",
if (res.data.ecode == "500") { url: this.contract_base_url + "import",
this.$message.error(res.data.enote); data: form
} else if (res.data.ecode == "200") { })
this.$message({ .then(res => {
type: "success", if (res.data.ecode == "500") {
message: "导入成功" this.$message.error(res.data.enote);
}); } else if (res.data.ecode == "200") {
} else if (res.data != [] && res.data[0].contract_unid) { this.$message({
var message = []; type: "success",
const h = this.$createElement; message: "导入成功"
res.data.forEach(e => { });
message.push(h("p", null, e.contract_unid)); } else if (res.data != [] && res.data[0].contract_unid) {
});
this.$message({
type: "warning",
message: "部分导入信息数据校验未通过,请检查后重新导入",
duration: 5000
});
this.$notify({
title: "校验未通过的合同的编号为:",
duration: 0,
message: h("p", null, message),
type: "error"
});
} else {
if (res.data.length > 0) {
var message = []; var message = [];
const h = this.$createElement; const h = this.$createElement;
res.data.forEach(e => { res.data.forEach(e => {
message.push(h("p", null, e)); message.push(h("p", null, e.contract_unid));
}); });
this.$message({ this.$message({
type: "warning", type: "warning",
message: "部分导入信息已存在,请检查后重新导入", message: "部分导入信息数据校验未通过,请检查后重新导入",
duration: 5000 duration: 5000
}); });
this.$notify({ this.$notify({
title: "重复的数据编号", title: "校验未通过的合同的编号为:",
duration: 0, duration: 0,
message: h("p", null, message), message: h("p", null, message),
type: "error" type: "error"
}); });
} else {
if (res.data.length > 0) {
var message = [];
const h = this.$createElement;
res.data.forEach(e => {
message.push(h("p", null, e));
});
this.$message({
type: "warning",
message: "部分导入信息已存在,请检查后重新导入",
duration: 5000
});
this.$notify({
title: "重复的数据编号",
duration: 0,
message: h("p", null, message),
type: "error"
});
}
} }
} var node = document.getElementById("import_unview");
var node = document.getElementById("import_unview"); node.value = "";
node.value = ""; })
}) .catch(err => {
.catch(err => { console.log(err.message);
console.log(err.message); });
}); },
}, // get start~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// get start~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ get_amount_state_unid_data() {
get_amount_state_unid_data() { this.$Axios({
this.$Axios({ method: "get",
method: "get", url: this.code_base_url + "custom/cates/42407C5EF2/codes"
url: this.code_base_url + "custom/cates/42407C5EF2/codes"
})
.then(res => {
this.amount_state_unid_data = res.data.list_data;
})
.catch(err => {});
},
get_contract_type_data() {
this.$Axios({
method: "get",
url: this.code_base_url + "custom/cates/8EC31D08A0/codes"
})
.then(res => {
this.contract_type_data = res.data.list_data;
}) })
.catch(err => {}); .then(res => {
}, this.amount_state_unid_data = res.data.list_data;
get_contract_state_data() { })
this.$Axios({ .catch(err => {});
method: "get", },
url: this.code_base_url + "custom/cates/13BEFACBCF/codes" get_contract_type_data() {
}) this.$Axios({
.then(res => { method: "get",
this.contract_state_data = res.data.list_data; url: this.code_base_url + "custom/cates/8EC31D08A0/codes"
}) })
.catch(err => {}); .then(res => {
}, this.contract_type_data = res.data.list_data;
get_product_line_type_data() { })
this.$Axios({ .catch(err => {});
method: "get", },
url: this.code_base_url + "custom/cates/4FC51AD3C9/codes" get_contract_state_data() {
}) this.$Axios({
.then(res => { method: "get",
this.product_line_type_data = res.data.list_data; url: this.code_base_url + "custom/cates/13BEFACBCF/codes"
}) })
.catch(err => {}); .then(res => {
}, this.contract_state_data = res.data.list_data;
get_provinces() { })
this.$Axios({ .catch(err => {});
method: "get", },
url: this.code_base_url + "countries/0E229CD043/provinces" get_product_line_type_data() {
}) this.$Axios({
.then(response => { method: "get",
this.provinces = response.data.list_data; url: this.code_base_url + "custom/cates/4FC51AD3C9/codes"
}) })
.catch(err => { .then(res => {
console.log(err.message); this.product_line_type_data = res.data.list_data;
}); })
}, .catch(err => {});
get_cities() { },
this.search_form.city = ""; get_provinces() {
// this.search_form.county = "";
if (this.search_form.province) {
this.$Axios({ this.$Axios({
method: "get", method: "get",
url: url: this.code_base_url + "countries/0E229CD043/provinces"
this.code_base_url +
"countries/0E229CD043/provinces/" +
this.search_form.province +
"/cities"
}) })
.then(response => { .then(response => {
this.cities = response.data.list_data; this.provinces = response.data.list_data;
}) })
.catch(err => { .catch(err => {
console.log(err.message); console.log(err.message);
}); });
} },
}, get_cities() {
get_counties() { this.search_form.city = "";
// this.search_form.county = ""; // this.search_form.county = "";
if (this.search_form.province && this.search_form.city) { if (this.search_form.province) {
this.$Axios({
method: "get",
url:
this.code_base_url +
"countries/0E229CD043/provinces/" +
this.search_form.province +
"/cities"
})
.then(response => {
this.cities = response.data.list_data;
})
.catch(err => {
console.log(err.message);
});
}
},
// get_counties() {
// // this.search_form.county = "";
// if (this.search_form.province && this.search_form.city) {
// this.$Axios({
// method: "get",
// url:
// this.code_base_url +
// "countries/0E229CD043/provinces/" +
// this.search_form.province +
// "/cities/" +
// this.search_form.city +
// "/counties"
// })
// .then(response => {
// this.counties = response.data.list_data;
// })
// .catch(err => {
// console.log(err.message);
// });
// }
// },
get_list_data() {
var a = this.search_form;
a.offset = this.offset;
a.limit = this.limit;
this.$Axios({ this.$Axios({
method: "get", methods: "get",
url: url: this.contract_base_url,
this.code_base_url + params: a,
"countries/0E229CD043/provinces/" + headers: { "Content-Type": "application/json" }
this.search_form.province +
"/cities/" +
this.search_form.city +
"/counties"
}) })
.then(response => { .then(response => {
this.counties = response.data.list_data; if (response.data.ecode == "500") {
this.$message.error("筛选异常");
return;
}
this.total_data = response.data.total_number;
this.list_data = response.data.list_data;
for (let i = 0; i < this.list_data.length; i++) {
const e = this.list_data[i];
for (let j = 0; j < this.contract_state_data.length; j++) {
const a = this.contract_state_data[j];
if (e.contract_state == a.code) {
this.list_data[i].contract_state_name = a.name;
}
}
for (let k = 0; k < this.product_line_type_data.length; k++) {
const b = this.product_line_type_data[k];
if (e.product_line_type == b.code) {
this.list_data[i].product_line_type_name = b.name;
}
}
if (!e.over_days) {
e.over_days = 0;
}
}
}) })
.catch(err => { .catch(err => {
console.log(err.message); console.log(err.message);
}); });
} },
}, get_year(date) {
get_list_data() { if (date) {
var a = this.search_form; return date.slice(0, 4);
a.offset = this.offset; }
a.limit = this.limit; },
this.$Axios({ get_month(date) {
methods: "get", if (date) {
url: this.contract_base_url, return date.slice(5, 7);
params: a, }
headers: { "Content-Type": "application/json" } },
})
.then(response => { // get end---------------------------------------------------------------------------------------------
if (response.data.ecode == "500") { reset() {
this.$message.error("筛选异常"); this.$refs["search_form"].resetFields();
return; },
}
this.total_data = response.data.total_number; commit() {
this.list_data = response.data.list_data; this.$refs["search_form"].validate(valid => {
for (let i = 0; i < this.list_data.length; i++) { if (valid) {
const e = this.list_data[i]; this.current_page = 1;
for (let j = 0; j < this.contract_state_data.length; j++) { sessionStorage.setItem(
const a = this.contract_state_data[j]; "search_condition",
if (e.contract_state == a.code) { JSON.stringify(this.search_form)
this.list_data[i].contract_state_name = a.name; );
} this.get_list_data();
} }else {
for (let k = 0; k < this.product_line_type_data.length; k++) { this.$message({
const b = this.product_line_type_data[k]; type:'warning',
if (e.product_line_type == b.code) { message:'请检查数据格式是否正确'
this.list_data[i].product_line_type_name = b.name; })
}
}
if (!e.over_days) {
e.over_days = 0;
}
} }
})
.catch(err => {
console.log(err.message);
}); });
}, },
get_year(date) { page_change(val) {
if (date) { this.search_form = JSON.parse(sessionStorage.getItem("search_condition"));
return date.slice(0, 4); this.current_page = val;
console.log(this.current_page);
this.get_list_data();
},
export_contract() {
this.$Axios({
method: "get",
url: this.contract_base_url + "export",
params: this.search_form,
responseType: "blob"
})
.then(res => {
let blob = new Blob([res.data], {
type: "application/vnd.ms-excel;charset=UTF-8"
});
// let ourl = URL.createObjectURL(blob);
// window.location.href = ourl;
var downloadElement = document.createElement("a");
var href = window.URL.createObjectURL(blob); //创建下载的链接
downloadElement.href = href;
downloadElement.download = "合同.xlsx"; //下载后文件名
document.body.appendChild(downloadElement);
downloadElement.click(); //点击下载
document.body.removeChild(downloadElement); //下载完成移除元素
window.URL.revokeObjectURL(href); //释放掉blob对象
})
.catch(err => {
console.log(err.message);
});
},
go_to(id) {
sessionStorage.setItem("modify", "1");
this.$router.push("/nav/contract/" + id);
} }
}, },
get_month(date) { created() {
if (date) { if (sessionStorage.getItem("user_roles") == "null") {
return date.slice(5, 7); this.salesperson_name = sessionStorage.getItem("user_name");
this.sales = true;
this.search_form.salesperson_unid = sessionStorage.getItem("user_unid");
}
if (sessionStorage.getItem("provinces")) {
this.provinces = JSON.parse(sessionStorage.getItem("provinces"));
} else {
this.get_provinces();
}
if (sessionStorage.getItem("amount_state_unid_data")) {
this.amount_state_unid_data = JSON.parse(
sessionStorage.getItem("amount_state_unid_data")
);
} else {
this.get_amount_state_unid_data();
}
if (sessionStorage.getItem("contract_type_data")) {
this.contract_type_data = JSON.parse(
sessionStorage.getItem("contract_type_data")
);
} else {
this.get_contract_type_data();
}
if (sessionStorage.getItem("contract_state_data")) {
this.contract_state_data = JSON.parse(
sessionStorage.getItem("contract_state_data")
);
} else {
this.get_contract_state_data();
}
if (sessionStorage.getItem("product_line_type_data")) {
this.product_line_type_data = JSON.parse(
sessionStorage.getItem("product_line_type_data")
);
} else {
this.get_product_line_type_data();
} }
},
// get end---------------------------------------------------------------------------------------------
reset() {
this.$refs["search_form"].resetFields();
},
commit() {
this.current_page = 1;
sessionStorage.setItem(
"search_condition",
JSON.stringify(this.search_form)
);
this.get_list_data();
},
page_change(val) {
this.search_form = JSON.parse(sessionStorage.getItem("search_condition"));
this.current_page = val;
console.log(this.current_page);
this.get_list_data();
},
export_contract() {
this.$Axios({
method: "get",
url: this.contract_base_url + "export",
params: this.search_form,
responseType: "blob"
})
.then(res => {
let blob = new Blob([res.data], {
type: "application/vnd.ms-excel;charset=UTF-8"
});
// let ourl = URL.createObjectURL(blob);
// window.location.href = ourl;
var downloadElement = document.createElement("a");
var href = window.URL.createObjectURL(blob); //创建下载的链接
downloadElement.href = href;
downloadElement.download = "合同.xlsx"; //下载后文件名
document.body.appendChild(downloadElement);
downloadElement.click(); //点击下载
document.body.removeChild(downloadElement); //下载完成移除元素
window.URL.revokeObjectURL(href); //释放掉blob对象
})
.catch(err => {
console.log(err.message);
});
},
go_to(id) {
sessionStorage.setItem("modify", "1");
this.$router.push("/nav/contract/" + id);
}
},
created() {
if (sessionStorage.getItem("user_roles") == "null") {
this.salesperson_name = sessionStorage.getItem("user_name");
this.sales = true;
this.search_form.salesperson_unid = sessionStorage.getItem("user_unid");
}
if (sessionStorage.getItem("provinces")) {
this.provinces = JSON.parse(sessionStorage.getItem("provinces"));
} else {
this.get_provinces();
}
if (sessionStorage.getItem("amount_state_unid_data")) {
this.amount_state_unid_data = JSON.parse(
sessionStorage.getItem("amount_state_unid_data")
);
} else {
this.get_amount_state_unid_data();
}
if (sessionStorage.getItem("contract_type_data")) {
this.contract_type_data = JSON.parse(
sessionStorage.getItem("contract_type_data")
);
} else {
this.get_contract_type_data();
}
if (sessionStorage.getItem("contract_state_data")) {
this.contract_state_data = JSON.parse(
sessionStorage.getItem("contract_state_data")
);
} else {
this.get_contract_state_data();
}
if (sessionStorage.getItem("product_line_type_data")) {
this.product_line_type_data = JSON.parse(
sessionStorage.getItem("product_line_type_data")
);
} else {
this.get_product_line_type_data();
} }
} };
};
</script> </script>
<style scoped> <style scoped>
......
...@@ -24,139 +24,141 @@ ...@@ -24,139 +24,141 @@
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="submitForm('password_form')">提交</el-button> <el-button-group>
<el-button @click="resetForm('password_form')">重置</el-button> <el-button type="primary" @click="submitForm('password_form')">提交</el-button>
<el-button type="warning" @click="resetForm('password_form')">重置</el-button>
</el-button-group>
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-card> </el-card>
</template> </template>
<script> <script>
export default { export default {
name: "user", name: "user",
data() { data() {
return { return {
new_password_type: "password", new_password_type: "password",
odd_password_type: "password", odd_password_type: "password",
new_password_view: "icon i-password-not-view", new_password_view: "icon i-password-not-view",
odd_password_view: "icon i-password-not-view", odd_password_view: "icon i-password-not-view",
rtoken: "", rtoken: "",
user_unid: "", user_unid: "",
auth_base_url: disparch_data.auth_base_url, auth_base_url: this.$disparch_data.auth_base_url,
password_form: { password_form: {
odd_password: "", odd_password: "",
new_password: "", new_password: "",
check_password: "" check_password: ""
},
password_form_rules: {
odd_password: {
required: true,
message: "请填写旧密码",
trigger: "blur"
}, },
new_password: [ password_form_rules: {
{ odd_password: {
pattern: /^[A-Za-z\d]{6,}$/,
message: "密码至少6位",
trigger: "blur"
},
{
required: true, required: true,
message: "必须填写新密码", message: "请填写旧密码",
trigger: "blur" trigger: "blur"
}, },
{ new_password: [
validator: (rule, value, callback) => { {
if (value == this.password_form.odd_password) { pattern: /^[A-Za-z0-9\x20-\x7f]{6,16}$/,
callback(new Error("新密码不能和旧密码相同")); message: "密码至少6位,至多16位",
} else callback(); trigger: "blur"
}, },
trigger: "blur" {
} required: true,
], message: "必须填写新密码",
check_password: [ trigger: "blur"
{
pattern: /^[A-Za-z\d]{6,}$/,
message: "密码至少6位",
trigger: "blur"
},
{
required: true,
message: "必须填写新密码",
trigger: "blur"
},
{
validator: (rule, value, callback) => {
if (value != this.password_form.new_password) {
callback(new Error("两次输入不一致"));
} else callback();
}, },
trigger: "blur" {
validator: (rule, value, callback) => {
if (value == this.password_form.odd_password) {
callback(new Error("新密码不能和旧密码相同"));
} else callback();
},
trigger: "blur"
}
],
check_password: [
{
pattern: /^[A-Za-z0-9\x20-\x7f]{6,16}$/,
message: "密码至少6位,至多16位",
trigger: "blur"
},
{
required: true,
message: "必须填写新密码",
trigger: "blur"
},
{
validator: (rule, value, callback) => {
if (value != this.password_form.new_password) {
callback(new Error("两次输入不一致"));
} else callback();
},
trigger: "blur"
}
]
}
};
},
methods: {
show_odd_password() {
if (this.odd_password_type == "password") {
this.odd_password_type = "text";
this.odd_password_view = "icon i-password-view";
} else {
this.odd_password_type = "password";
this.odd_password_view = "icon i-password-not-view";
}
},
show_new_password() {
if (this.new_password_type == "password") {
this.new_password_type = "text";
this.new_password_view = "icon i-password-view";
} else {
this.new_password_type = "password";
this.new_password_view = "icon i-password-not-view";
}
},
submitForm(form) {
this.$refs[form].validate(valid => {
if (valid) {
this.$Axios({
method: "post",
url: this.auth_base_url + "users/" + this.user_unid + "/password",
headers: { authorization: this.rtoken },
data: {
old_pwd: this.password_form.odd_password,
new_pwd: this.password_form.new_password
}
})
.then(response => {
if (response.data.user_unid) {
this.$message({
type: "success",
message: "修改成功"
});
this.resetForm("password_form");
}
})
.catch(err => {
this.$message.error("修改失败");
this.resetForm("password_form");
});
} }
] });
} },
}; resetForm(form) {
}, this.$refs[form].resetFields();
methods: {
show_odd_password() {
if (this.odd_password_type == "password") {
this.odd_password_type = "text";
this.odd_password_view = "icon i-password-view";
} else {
this.odd_password_type = "password";
this.odd_password_view = "icon i-password-not-view";
} }
}, },
show_new_password() { created() {
if (this.new_password_type == "password") { if (!sessionStorage.getItem("user_unid")) {
this.new_password_type = "text"; this.$router.push("/");
this.new_password_view = "icon i-password-view";
} else { } else {
this.new_password_type = "password"; this.rtoken = sessionStorage.getItem("rtoken");
this.new_password_view = "icon i-password-not-view"; this.user_unid = sessionStorage.getItem("user_unid");
} }
},
submitForm(form) {
this.$refs[form].validate(valid => {
if (valid) {
this.$Axios({
method: "post",
url: this.auth_base_url + "users/" + this.user_unid + "/password",
headers: { authorization: this.rtoken },
data: {
old_pwd: this.password_form.odd_password,
new_pwd: this.password_form.new_password
}
})
.then(response => {
if (response.data.user_unid) {
this.$message({
type: "success",
message: "修改成功"
});
this.resetForm("password_form");
}
})
.catch(err => {
this.$message.error("修改失败");
this.resetForm("password_form");
});
}
});
},
resetForm(form) {
this.$refs[form].resetFields();
}
},
created() {
if (!sessionStorage.getItem("user_unid")) {
this.$router.push("/");
} else {
this.rtoken = sessionStorage.getItem("rtoken");
this.user_unid = sessionStorage.getItem("user_unid");
} }
} };
};
</script> </script>
......
...@@ -9,7 +9,6 @@ import CollapseTransition from 'element-ui/lib/transitions/collapse-transition'; ...@@ -9,7 +9,6 @@ import CollapseTransition from 'element-ui/lib/transitions/collapse-transition';
import 'element-ui/lib/theme-chalk/index.css' import 'element-ui/lib/theme-chalk/index.css'
import '../static/city-data' import '../static/city-data'
// import "./mock" // import "./mock"
import '../static/disparch'
import './assets/icons/iconfont.css' import './assets/icons/iconfont.css'
import 'babel-polyfill' import 'babel-polyfill'
...@@ -76,6 +75,23 @@ Axios.interceptors.response.use((response) => { ...@@ -76,6 +75,23 @@ Axios.interceptors.response.use((response) => {
return Promise.reject(err); return Promise.reject(err);
}); });
{
if (window.location.host == 'localhost:8089') {
Vue.prototype.$disparch_data = {
code_base_url: "http://192.168.9.162:20080/api/v1/codes/",
contract_base_url: "http://192.168.9.162:20080/api/v1/financial/contracts/",
auth_base_url: "http://192.168.9.162:20080/api/v1/auth/"
}
} else {
var url = window.location.host;
Vue.prototype.$disparch_data = {
code_base_url: "http://" + url + "/api/v1/codes/",
contract_base_url: "http://" + url + "/api/v1/financial/contracts/",
auth_base_url: "http://" + url + "/api/v1/auth/"
}
}
}
new Vue({ new Vue({
......
disparch_data = {
code_base_url: "http://192.168.9.162:20080/api/v1/codes/",
contract_base_url: "http://192.168.9.162:20080/api/v1/financial/contracts/",
auth_base_url: "http://192.168.9.162:20080/api/v1/auth/"
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!