Commit dafd19cc by 谢明辉

a

1 parent 2235725d
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item prop="password"> <el-form-item prop="password">
<el-input type="password" v-model="form.password" auto-complete="off"> <el-input type="password" v-model="form.password" auto-complete="off" @keydown.enter="submitForm('login_form')">
<template slot="prepend">密码</template> <template slot="prepend">密码</template>
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
...@@ -31,17 +31,16 @@ export default { ...@@ -31,17 +31,16 @@ export default {
name: "login", name: "login",
data() { data() {
return { return {
auth_base_url: disparch_data.auth_base_url,
form: { form: {
username: "", username: "",
password: "" password: ""
}, },
rules: { rules: {
username: [ username: [{ required: true, message: "请输入用户名", trigger: "blur" }]
{ required: true, message: "请输入用户名", trigger: "blur" } // password: [
], // { required: true, message: "请输入登录密码", trigger: "blur" }
password: [ // ]
{ required: true, message: "请输入登录密码", trigger: "blur" }
]
} }
}; };
}, },
...@@ -49,28 +48,53 @@ export default { ...@@ -49,28 +48,53 @@ export default {
submitForm(form) { submitForm(form) {
this.$refs[form].validate(valid => { this.$refs[form].validate(valid => {
if (valid) { if (valid) {
console.log(valid);
console.log(this.form.username);
console.log(this.form.password);
window.localStorage.setItem("username", this.form.username); window.localStorage.setItem("username", this.form.username);
window.sessionStorage.setItem("loginCheck", true); window.sessionStorage.setItem("loginCheck", true);
window.sessionStorage.setItem("username", this.form.username); this.$Axios({
this.$router.push({ path: "/nav/search" }); 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.sessionStorage.setItem("username", this.form.username);
window.sessionStorage.setItem("user_unid", res.data.user_unid);
window.sessionStorage.setItem('user_roles',JSON.stringify(res.data.roles));
this.$router.push({ path: "/nav/search" });
}
})
.catch(err => {
this.$message({
message: "登录错误",
type: "error"
});
});
} }
}); });
}, },
resetForm(form) { resetForm(form) {
this.$refs[form].resetFields(); this.$refs[form].resetFields();
} },
is_login() {}
}, },
mounted() { mounted() {
this.form.username = localStorage.getItem("username"); this.form.username = localStorage.getItem("username");
}, }
}; };
</script> </script>
<style scoped> <style scoped>
#login_box { #login_box {
height: 100% height: 100%;
} }
</style> </style>
...@@ -4,13 +4,51 @@ ...@@ -4,13 +4,51 @@
<span style="font-size:24px">后台管理</span> <span style="font-size:24px">后台管理</span>
</div> </div>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<el-row type="flex" justify="start" style="text-align :left"> <el-row type="flex" justify="start" style="text-align :left;border-bottom:1px solid #ebeef5;padding-bottom:18px">
<el-col :span="6"> <el-col :span="6">
<el-input class="input" v-model="contract_unid" placeholder="合同编号"></el-input> <el-input class="input" v-model="contract_unid" placeholder="合同编号"></el-input>
<el-button type="primary" @click="contract_unid_add">添加</el-button> <el-button type="primary" @click="contract_unid_add">添加</el-button>
</el-col> </el-col>
<el-col :span="6">
<el-input class="input" v-model="customer_name" placeholder="客户名称"></el-input>
<el-button type="primary" @click="customer_name_add">添加</el-button>
</el-col>
<el-col :span="6">
<el-input class="input" v-model="salesperson" placeholder="销售员"></el-input>
<el-button type="primary" @click="salesperson_add('employee')">添加</el-button>
</el-col>
<el-col :span="6">
<el-input class="input" v-model="project_name" placeholder="项目名称"></el-input>
<el-button type="primary" @click="project_name_add">添加</el-button>
</el-col>
</el-row>
<el-row>
<el-button class="add_button" type="text" @click="login_user_dialog_show = true">添加登录用户</el-button>
</el-row> </el-row>
<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-item label="用户类型" prop="role_unid">
<el-select v-model="login_user_form.role_unid" clearable placeholder="用户类型" style="width:100%">
<el-option v-for="item in roles" :key="item.role_unid" :label="item.name" :value="item.role_unid">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="用户名" prop="username">
<el-input v-model="login_user_form.username" placeholder="用户名" style="width:100%"></el-input>
</el-form-item>
<el-form-item label="姓名" prop="name">
<el-input v-model="login_user_form.name" placeholder="姓名" style="width:100%"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="login_user_dialog_cancel()">取 消</el-button>
<el-button type="primary" @click="login_user_dialog_confirm()">确 定</el-button>
</div>
</el-dialog>
</el-card> </el-card>
</template> </template>
<script> <script>
...@@ -18,35 +56,187 @@ export default { ...@@ -18,35 +56,187 @@ export default {
name: "manage", name: "manage",
data() { data() {
return { return {
login_user_dialog_show: false,
code_base_url: disparch_data.code_base_url, code_base_url: disparch_data.code_base_url,
contract_base_url: disparch_data.contract_base_url, contract_base_url: disparch_data.contract_base_url,
contract_unid: null auth_base_url: disparch_data.auth_base_url,
contract_unid: null,
customer_name: null,
salesperson: null,
project_name: null,
roles: [],
login_user_form: {
role_unid: "",
username: "",
name: "",
password: "0000",
norm_type: "login"
},
login_user_form_rules: {
username: {
required: true,
pattern: /^[a-z]{2,8}$/,
message: "请输入2至8位英文",
trigger: "blur"
},
name: {
required: true,
message: "请输入用户姓名",
trigger: "blur"
},
role_unid: {
required: true,
message: "请选择用户类型",
trigger: "blur"
}
}
}; };
}, },
methods: { methods: {
contract_unid_add() { contract_unid_add() {
this.$Axios({ if (this.contract_unid) {
method: "post", this.$Axios({
data: { contract_unid: this.contract_unid }, method: "post",
url: this.contract_base_url data: { contract_unid: this.contract_unid },
}).then(response => { url: this.contract_base_url,
this.contract_unid = null; headers: { "Content-Type": "application/json" }
if (response.data.encode = '200') { }).then(response => {
this.show_message("添加成功",'success') this.contract_unid = null;
}else { if (response.data.ecode == "200") {
this.show_message('添加失败','error') this.show_message("添加成功", "success");
} } else {
}); 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" }
}).then(response => {
this.customer_name = null;
if (response.data.ecode == "200") {
this.show_message("添加成功", "success");
} else {
this.show_message("添加失败", "error");
}
});
} else {
this.show_message("请填写信息", "info");
}
},
salesperson_add(type) {
if (this.salesperson) {
this.$Axios({
method: "post",
url: this.auth_base_url + "users",
data: {
norm_type: type,
username: this.salesperson,
name: this.salesperson,
password: "0000"
},
headers: { "Content-Type": "application/json" }
}).then(response => {
this.salesperson = null;
this.show_message("添加成功", "success");
});
} else {
this.show_message("请填写信息", "info");
}
}, },
show_message(message,type){ project_name_add() {
if (this.project_name) {
this.$Axios({
method: "post",
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 {
this.show_message("添加失败", "error");
}
});
} else {
this.show_message("请填写信息", "info");
}
},
show_message(message, type) {
this.$message({ this.$message({
message:message, message: message,
type:type, type: type,
center:true, center: true,
showClose:true, showClose: true,
duration:1500 duration: 1500
});
},
get_roles() {
this.$Axios({
method: "get",
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({
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("添加成功", "success");
this.$refs["login_user_form"].resetFields();
this.login_user_dialog_show = false;
console.log(res.data);
})
.catch(err => {
this.show_message("添加失败", "error");
});
} else {
this.show_message("添加失败", "error");
}
});
}
});
} }
},
created() {
this.get_roles();
} }
}; };
</script> </script>
...@@ -55,5 +245,10 @@ export default { ...@@ -55,5 +245,10 @@ export default {
.input { .input {
width: 200px; width: 200px;
} }
.add_button {
font-size: 20px;
padding-top: 18px;
color: #409eff;
}
</style> </style>
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
<el-col :span="6"> <el-col :span="6">
<el-form-item label="合同状态" prop="contract_state"> <el-form-item label="合同状态" prop="contract_state">
<el-select v-model="search_form.contract_state" clearable> <el-select v-model="search_form.contract_state" clearable>
<el-option v-for="(value,index) in contract_state_data" :key="index" :label="value" :value="index+1"> <el-option v-for="item in contract_state_data" :key="item.code" :label="item.name" :value="item.code">
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
<el-col :span="6"> <el-col :span="6">
<el-form-item label="合同性质" prop="contract_type"> <el-form-item label="合同性质" prop="contract_type">
<el-select v-model="search_form.contract_type" clearable> <el-select v-model="search_form.contract_type" clearable>
<el-option v-for="(value,index) in contract_type_data" :key="index" :label="value" :value="index+1"> <el-option v-for="item in contract_type_data" :key="item.code" :label="item.name" :value="item.code">
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
<el-col :span="6"> <el-col :span="6">
<el-form-item label="产品线类型" prop="product_line_type"> <el-form-item label="产品线类型" prop="product_line_type">
<el-select v-model="search_form.product_line_type" clearable> <el-select v-model="search_form.product_line_type" clearable>
<el-option v-for="(value,index) in product_line_type_data" :key="index" :label="value" :value="index+1"> <el-option v-for="item in product_line_type_data" :key="item.code" :label="item.name" :value="item.code">
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
<el-col :span="6"> <el-col :span="6">
<el-form-item label="账款状态" prop="amount_state_unid"> <el-form-item label="账款状态" prop="amount_state_unid">
<el-select v-model="search_form.amount_state_unid" clearable> <el-select v-model="search_form.amount_state_unid" clearable>
<el-option v-for="(value,index) in amount_state_unid_data" :key="index" :label="value" :value="index+1"> <el-option v-for="item in amount_state_unid_data" :key="item.code" :label="item.name" :value="item.code">
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
...@@ -318,7 +318,7 @@ const twodecimalrule = { ...@@ -318,7 +318,7 @@ const twodecimalrule = {
trigger: "blur" trigger: "blur"
}; };
export default { export default {
name:'search', name: "search",
data() { data() {
return { return {
provinces: [], provinces: [],
...@@ -340,10 +340,10 @@ export default { ...@@ -340,10 +340,10 @@ export default {
"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: {
salesperson_name__like: null, salesperson_name__like: null,
project_name__like: null, project_name__like: null,
...@@ -368,7 +368,7 @@ export default { ...@@ -368,7 +368,7 @@ export default {
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: [],
...@@ -392,15 +392,15 @@ export default { ...@@ -392,15 +392,15 @@ export default {
offset() { offset() {
return (this.current_page - 1) * this.limit; return (this.current_page - 1) * this.limit;
}, },
guarantee_period_list(){ guarantee_period_list() {
var arr = []; var arr = [];
var a = 6; var a = 6;
for (let i = 0; i < 10; i ++) { for (let i = 0; i < 10; i++) {
const element = 10[i]; const element = (10)[i];
arr.push(a); arr.push(a);
a += 6; a += 6;
} }
return arr return arr;
} }
}, },
methods: { methods: {
...@@ -444,6 +444,46 @@ export default { ...@@ -444,6 +444,46 @@ export default {
// remote--------------------------------------------------------------------------------- // remote---------------------------------------------------------------------------------
// get start~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // get start~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
get_amount_state_unid_data() {
this.$Axios({
method: "get",
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 => {});
},
get_contract_state_data() {
this.$Axios({
method: "get",
url: this.code_base_url + "custom/cates/13BEFACBCF/codes"
})
.then(res => {
this.contract_state_data = res.data.list_data;
})
.catch(err => {});
},
get_product_line_type_data() {
this.$Axios({
method: "get",
url: this.code_base_url + "custom/cates/4FC51AD3C9/codes"
})
.then(res => {
this.product_line_type_data = res.data.list_data;
})
.catch(err => {});
},
get_provinces() { get_provinces() {
this.$Axios({ this.$Axios({
method: "get", method: "get",
...@@ -511,6 +551,21 @@ export default { ...@@ -511,6 +551,21 @@ export default {
.then(response => { .then(response => {
this.total_data = response.data.total_number; this.total_data = response.data.total_number;
this.list_data = response.data.list_data; 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;
}
}
}
}) })
.catch(err => { .catch(err => {
console.log(err.message); console.log(err.message);
...@@ -541,28 +596,44 @@ export default { ...@@ -541,28 +596,44 @@ export default {
this.search_form = JSON.parse(sessionStorage.getItem("search_form")); this.search_form = JSON.parse(sessionStorage.getItem("search_form"));
this.current_page = val; this.current_page = val;
console.log(this.current_page); console.log(this.current_page);
this.list_data = this.get_list_data().data; this.get_list_data();
}, },
export_contract() { export_contract() {
this.$Axios({ this.$Axios({
method:"get", method: "get",
url:this.contract_base_url + "export", url: this.contract_base_url + "export",
params:this.search_form, params: this.search_form,
responseType:"blob" 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;
}).catch(err => {
console.log(err.message);
}) })
.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){ go_to(id) {
this.$router.push('/nav/contract/'+id); this.$router.push("/nav/contract/" + id);
} }
}, },
created() { created() {
this.get_provinces(); this.get_provinces();
this.get_amount_state_unid_data();
this.get_contract_type_data();
this.get_contract_state_data();
this.get_product_line_type_data();
} }
}; };
</script> </script>
......
disparch_data = { disparch_data = {
code_base_url: "http://192.168.9.162:20080/api/v1/codes/", 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/", 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!