<!doctype html>
|
<html>
|
<head>
|
<meta charset="utf-8">
|
<title>联系人管理</title>
|
<script src="../../../js/vue/vue.js"></script>
|
<script src="../../../js/vue/element-ui/lib/index.js"></script>
|
<script src="../../../js/vue/page.js"></script>
|
<script src="../../../js/myelement.js"></script>
|
<!-- <script src="../../../data/data.js"></script> -->
|
<script src="../setting.js"></script>
|
|
<link href="../../../js/vue/element-ui/lib/theme-chalk/index.css" rel="stylesheet">
|
<link href="../../../css/myelement.css" rel="stylesheet">
|
<link href="../../../css/iconfont.css" rel="stylesheet">
|
<link href="../../../css/page.css" rel="stylesheet">
|
<link href="//at.alicdn.com/t/font_2374495_mkoo966o0uo.css" rel="stylesheet">
|
</head>
|
|
<body>
|
<div id="vbody">
|
<div id="page_root">
|
<div class="topbar">
|
<span>{{title}}</span>
|
|
<div style="float: right; margin-right: 24px;">
|
<el-button-group>
|
<el-button v-if="buttons.download" :disabled="buttons.download.disabled" icon="el-icon-download" @click="onDownload">导出</el-button>
|
<el-button v-if="buttons.upload" :disabled="buttons.upload.disabled" icon="el-icon-upload2" @click="onUpload">导入</el-button>
|
</el-button-group>
|
|
<el-button-group style="margin-left: 3px;">
|
<el-button icon="el-icon-refresh" @click="onRefresh">刷新</el-button>
|
<el-button v-if="buttons.append" :disabled="buttons.append.disabled" icon="el-icon-plus" @click="onNewRecord">添加</el-button>
|
<el-button v-if="buttons.edit" :disabled="buttons.edit.disabled" @click="setEditTableData" >{{isEditTableData ? '取消编辑' : '在线编辑'}}</el-button>
|
</el-button-group>
|
|
</div>
|
</div>
|
|
<div class="topbar-line">
|
<div class="query-icon">
|
<i class="iconfont icon-query"></i>
|
</div>
|
<div class="query-bar">
|
<el-form label-position='left' label-width="100px" :inline="true" :model="formInline" class="demo-form-inline">
|
<el-form-item label="联系人名称:" style="line-height: 40px;">
|
<el-input size="mini" v-model="formInline.field1" placeholder="请输入" style="width: 140px;"></el-input>
|
</el-form-item>
|
|
<el-form-item label="上级联系人:" style="line-height: 40px;">
|
<el-input size="mini" v-model="formInline.field6" placeholder="请输入" style="width: 140px;"></el-input>
|
</el-form-item>
|
<el-form-item>
|
<el-button @click="onQuery">查 询</el-button>
|
<el-button @click="onInitQuery">重 置</el-button>
|
</el-form-item>
|
</el-form>
|
</div>
|
</div>
|
|
<div class="versionNo">
|
<h-table
|
v-if="isRefresh"
|
ref="table1"
|
:table-fields="table_Fields"
|
:table-data="tableData"
|
:is-edit-table-data="isEditTableData"
|
:pagesize="pagesize"
|
:pagenum="pagenum"
|
:total="total"
|
:table-height="tableHeight2"
|
|
v-on:get-data="getData"
|
v-on:edit-data="editData"
|
v-on:del-data="delData"
|
>
|
</h-table>
|
</div>
|
|
<el-dialog :visible.sync="rowTableDialog" width="60%">
|
<div slot="title" class="dialog-title">
|
<i class="iconfont icon-customermanagement"></i>
|
<span> {{formAttr.title}} </span>
|
</div>
|
<h-form
|
ref="form1"
|
:form-attr="formAttr"
|
:table-fields="tableFields"
|
:form-data="formData"
|
v-on:show-popup="showPopup"
|
>
|
</h-form>
|
|
<div slot="footer" class="dialog-footer">
|
<el-button @click="rowTableDialog = false">取 消</el-button>
|
<el-button type="primary" @click="saveRowTable">保 存</el-button>
|
</div>
|
</el-dialog>
|
|
<el-dialog title="选择" :visible.sync="popupByFieldsDialog">
|
{{selectFormField.field}}
|
{{selectFormField.dataurl}}
|
|
<div slot="footer" class="dialog-footer" >
|
<el-button @click="popupByFieldsDialog = false">取 消</el-button>
|
<el-button type="primary" @click="saveFormValByField('123')">确 定</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
|
<div id="page_loading" style="position: absolute; top:0px; width: 100vw; height: 100vh;">
|
<div class="spinner">
|
<div class="cube1"></div>
|
<div class="cube2"></div>
|
</div>
|
</div>
|
</div>
|
|
<script type="text/javascript">
|
var role = Root.role;
|
var setting = getSetting("contact_list", role.code);
|
new Vue({
|
el: "#vbody",
|
data: {
|
title: "联系人管理",
|
page: setting.page,
|
buttons: setting.buttons,
|
|
formInline: {},
|
|
isRefresh: true,
|
table_Fields: [
|
{field: "id", name: "id", isshow: "F"},
|
{field: "field5", name: "parentid", isshow: "F"},
|
{field: "field1", name: "联系人名称", isshow: "T", align: "center", width: "150", required: true, disabled:false},
|
{field: "field2", name: "性别", isshow: "T", colspan: 2, align: "center",width: "150",required: true, type:"select", options: [{label: "男",value: "Y"}, {label: "女",value: "N"}]},
|
{field: "field3", name: "类型", isshow: "T", align: "center"},
|
{field: "field6", name: "上级联系人", isshow: "T", align: "center", width: "150",colspan: 2, type:"cascader", options: [], props:{value: "id", label: "field1", checkStrictly: true}},
|
{field: "field8", name: "E-Mail", isshow: "T", align: "center"},
|
{field: "field9", name: "电话", isshow: "T", align: "center"},
|
{field: "field7", name: "状态Code", isshow: "F",align: "center", width: "150" , type:"select", options: [{label: "有效",value: "Y"}, {label: "无效",value: "N"}]},
|
{field: "field4", name: "状态", isshow: "T",align: "center", width: "150"},
|
],
|
|
tableFields: [
|
{field: "id", name: "id", isshow: "F"},
|
{field: "field6", name: "上级联系人名称", isshow: "F"},
|
{field: "field1", name: "联系人名称", isshow: "T", align: "center", width: "150", required: true, disabled:false},
|
{field: "field2", name: "性别", isshow: "T", colspan: 1, align: "center",width: "150",required: true, type:"select", options: [{label: "男",value: "Y"}, {label: "女",value: "N"}]},
|
{field: "field3", name: "类型", isshow: "T", colspan: 1},
|
{field: "field4", name: "", isshow: "F"},
|
{field: "field5", name: "上级联系人", colspan: 1, isshow: "T", align: "center", width: "150",colspan: 1, type:"cascader", options: [], props:{value: "id", label: "field1", checkStrictly: true}},
|
{field: "field8", name: "E-Mail", isshow: "T", colspan: 1},
|
{field: "field9", name: "电话", isshow: "T", colspan: 1},
|
{field: "field7", name: "状态", isshow: "T", colspan: 1, align: "center", width: "150" , type:"select", options: [{label: "有效",value: "Y"}, {label: "无效",value: "N"}]},
|
],
|
istree: false,
|
treeDataObj: {},
|
operationtype: "",
|
tableData_old: [],
|
tableData_new: [],
|
tableData2: [],
|
tableData: [],
|
tableHeight2: 520,
|
urlImg2: "./img/wushuju.png",
|
isEditTableData:false,
|
|
pagesize: 10,
|
pagenum: 1,
|
total: 0,
|
rowTableDialog: false,
|
selectrow: {},
|
|
formAttr: {
|
istitle: false,
|
title: "联系人管理",
|
columnnumber: 3,
|
labelwidth: "100px",
|
labelposition: "right",
|
size: "medium",
|
border: "10px solid #c6c6c600"
|
},
|
tableFields2: [],
|
formData: {},
|
popupByFieldsDialog: false,
|
selectFormField:{},
|
},
|
created() {
|
this.tableData_new = dataRoot.database.contacts;
|
this.tableData_old = clone(dataRoot.database.contacts);
|
this.tableData2 = this.tableData_new;
|
},
|
|
mounted() {
|
this.getTree();
|
this.initTableData();
|
this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
|
document.getElementById('page_root').style.display = "block";
|
document.getElementById('page_loading').style.display = "none";
|
});
|
},
|
|
methods:{
|
getTree() {
|
this.defaultExpandedKeys = [];
|
this.istree = false;
|
let treeDataList = this.tableData_new;
|
treeDataList.map(e=>{
|
this.treeDataObj[e.id] = e;
|
});
|
let treeData_ = ArrayToTree(treeDataList, "field1", "field5");
|
treeData_.map(e=>{
|
this.defaultExpandedKeys.push(e.id);
|
});
|
this.tableFields[6].options = treeData_;
|
this.treeData = treeData_;
|
this.istree = true;
|
},
|
//表格
|
setEditTableData() {
|
this.isRefresh = false;
|
this.isEditTableData = !this.isEditTableData;
|
this.initTableData();
|
},
|
initTableData() {
|
let me = this;
|
this.total = this.tableData2.length;
|
this.tableData = this.tableData2.slice((this.pagenum-1)*this.pagesize, this.pagenum * this.pagesize);
|
this.tableData.map(e=>{
|
e.field4 = e.field7 == "N" ? "无效" : "有效";
|
})
|
|
if(this.tableData.length > 0){
|
this.$nextTick(function(){
|
this.isRefresh = true;
|
this.$nextTick(function(){
|
let header_height = me.$refs.table1.$el.getElementsByClassName('el-table__header-wrapper')[0].offsetHeight;
|
let row_height = me.$refs.table1.$el.getElementsByClassName('el-table__row')[0].offsetHeight || 40;
|
let body_width = me.$refs.table1.$el.getElementsByClassName('el-table__body')[0].offsetWidth;
|
let body_wrapper_width = me.$refs.table1.$el.getElementsByClassName('el-table__body-wrapper')[0].offsetWidth;
|
this.tableHeight2 = header_height + (row_height * this.pagesize) + this.pagesize/4.5;
|
if((body_width - body_wrapper_width)>5){
|
this.tableHeight2 += 20
|
}
|
})
|
})
|
}
|
},
|
|
getData(page) {
|
this.pagesize = page.pagesize;
|
this.pagenum = page.pagenum;
|
this.doQuery();
|
},
|
editData(scope) {
|
|
this.selectrow = scope.row;
|
let formnodeData_ = clone(scope.row);
|
|
this.openMsg1("edit", scope.row);
|
},
|
getparent(parentid, parents) {
|
if (this.treeDataObj[parentid].field5){
|
parents.unshift(this.treeDataObj[parentid].field5);
|
this.getparent(this.treeDataObj[parentid].field5, parents);
|
}
|
else {
|
return parents;
|
}
|
},
|
delData(scope) {
|
let me = this;
|
let row = scope.row;
|
let index_ = scope.$index;
|
|
Root.confirm('确定删除-' + row.field1 + '-吗?', '删除提示', {
|
confirmButtonText: '删除',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
me.tableData_new.remove(row);
|
me.tableData2.remove(row);
|
me.doQuery();
|
Root.message({
|
type: 'success',
|
message: '删除成功!'
|
});
|
}).catch(() => {
|
Root.message({
|
type: 'info',
|
message: '已取消删除'
|
});
|
});
|
},
|
saveRowTable() {
|
if (this.operationnodetype == "edit") {//修改
|
this.tableFields.map(e=>{
|
if (e.id == this.formnodeData.id) {
|
for(var k in this.formnodeData) {
|
e[k] = this.formnodeData[k]
|
}
|
//e = clone(this.formnodeData);
|
e.field5 = this.formnodeData.field6[this.formnodeData.field6.length-1]
|
}
|
});
|
}
|
else {//新增
|
let formnodeData_ = {};
|
for(var k in this.formnodeData) {
|
formnodeData_[k] = this.formnodeData[k];
|
}
|
formnodeData_.id= id++;
|
formnodeData_.field5= this.formnodeData.field6[this.formnodeData.field6.length-1];
|
this.tableFields.push(formnodeData_);
|
}
|
|
this.getTree();
|
},
|
|
//表单
|
showPopup(obj) {
|
this.selectFormField = obj.obj;
|
this.popupByFieldsDialog = true;
|
},
|
saveFormValByField(val) {
|
this.popupByFieldsDialog = false;
|
this.$refs.form1.setFormValByField(this.selectFormField, val)
|
},
|
|
onVersionSelect(obj) {
|
this.currentVersion = obj;
|
},
|
onDownload() {
|
Root.message('这是一条消息提示');
|
},
|
onUpload() {
|
|
},
|
onQuery() {
|
this.pagenum = 1;
|
this.doQuery();
|
},
|
doQuery() {
|
let result = this.tableData_new.filter(item => {
|
let bo = true;
|
for(var k in this.formInline) {
|
let k_val = this.formInline[k];
|
let bo_ = item[k].toLowerCase().indexOf(k_val.toLowerCase()) > -1;
|
if (!bo_) {
|
return false;
|
}
|
}
|
return bo;
|
});
|
this.tableData2 = result;
|
this.initTableData();
|
},
|
|
onInitQuery() {
|
this.formInline = {};
|
this.tableData2 = this.tableData_new;
|
this.initTableData();
|
},
|
onRefresh() {
|
this.formInline = {};
|
this.tableData_new = this.tableData_old;
|
this.tableData2 = this.tableData_new;
|
this.initTableData();
|
},
|
onNewRecord() {
|
//this.operationtype = "add";
|
//this.rowTableDialog = true;
|
this.tableFields;
|
this.selectrow = {};
|
this.formData = {};
|
this.openMsg1('add');
|
},
|
openMsg1(code, row) {
|
let me = this;
|
this.tableData_new = dataRoot.database.contacts;
|
let tableData_new_obj = {};
|
this.tableData_new.map(e=>{
|
tableData_new_obj[e.id] = e;
|
}),
|
Root.popupParames = {
|
width: "900px",
|
//height: "580px",
|
url: "../md/customer/contact_edit.html",
|
callback: function(obj, callback) {
|
me.saveRowTable_popup(obj);
|
if (callback) {
|
callback();
|
}
|
}
|
};
|
if (code == "edit") {
|
this.operationtype = "edit";
|
Root.popupParames.data = row;
|
}
|
else {
|
this.operationtype = "add";
|
}
|
//Root.showSubItem(parames);
|
Root.popupParames.tableFields = this.tableFields;
|
Root.popupParames.tableFields_new = tableData_new_obj;
|
Root.showPopup(Root.popupParames);
|
},
|
|
saveRowTable_popup(obj) {
|
let formData_ = obj.row;
|
let operationtype_ = this.operationtype;
|
formData_.field2 = formData_.field2 == "N" ? "女" : "男";
|
formData_.field4 = formData_.field7 == "N" ? "无效" : "有效";
|
if (operationtype_ == "edit") {//修改
|
for (var k in formData_) {
|
this.selectrow[k] = formData_[k];
|
}
|
}
|
else {//新增
|
this.tableData_new.push(formData_);
|
this.doQuery();
|
}
|
},
|
}
|
});
|
</script>
|
<style>
|
|
</style>
|
</body>
|
</html>
|