pengjun 3 years ago
parent
commit
094fb1acf4
  1. 6
      src/assets/css/global.css
  2. 279
      src/components/customerOrg/customerOrgEdit.vue
  3. 30
      src/components/customerOrg/customerOrgTree.vue
  4. 3
      src/store/index.js

6
src/assets/css/global.css

@ -26,6 +26,12 @@
/* 表格行背景色样式 end */
/* 点击树结构项的选中颜色 */
.el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {
background-color: #409EFF;
}
.publicfontsize{
font-size: 18px;
}

279
src/components/customerOrg/customerOrgEdit.vue

@ -1,15 +1,14 @@
<template>
<div style="display:flex;">
<div> <!--overflow-y: scroll;height:200px;-->
<div style="display: flex">
<div>
<!--overflow-y: scroll;height:200px;-->
<el-form ref="form" :model="form" label-width="85px" :rules="rules" size="medium">
<el-row>
<el-col :span="8">
<el-form-item label="上级单位" prop="parentId">
<el-cascader v-model="form.parentId" :options="customerOrg.customerOrgTree" :props="{
checkStrictly: true,
expandTrigger: 'hover',
...customerOrg.treeprops,
}" :show-all-levels="false" clearable filterable disabled
<el-cascader v-model="form.parentId" :options="customerOrg.customerOrgTree"
:props="{checkStrictly: true,expandTrigger: 'hover',...customerOrg.treeprops,}"
:show-all-levels="false" clearable filterable disabled
:style="'width:' + Math.floor((window.pageWidth - 655) / 3) + 'px;'">
</el-cascader>
</el-form-item>
@ -26,19 +25,36 @@
</el-col>
<el-col :span="8">
<el-form-item label="体检中心" prop="organizationUnitId">
<el-select v-model="form.organizationUnitId" placeholder="请选择" filterable :disabled="peisid ? true:false"
:style="'width:' + Math.floor((window.pageWidth - 655) / 3) + 'px;'">
<el-option v-for="item in data.organizationdata" :key="item.id" :label="item.displayName"
:value="item.id" />
<el-select
v-model="form.organizationUnitId"
placeholder="请选择"
filterable
:disabled="peisid ? true : false"
:style="'width:' + Math.floor((window.pageWidth - 655) / 3) + 'px;'"
>
<el-option
v-for="item in data.organizationdata"
:key="item.id"
:label="item.displayName"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="单位性质" prop="orgTypeId">
<el-select v-model="form.orgTypeId" placeholder="请选择" filterable
:style="'width:' + Math.floor((window.pageWidth - 655) / 3) + 'px;'">
<el-option v-for="item in data.customerOrgType" :key="item.id" :label="item.displayName"
:value="item.id" />
<el-select
v-model="form.orgTypeId"
placeholder="请选择"
filterable
:style="'width:' + Math.floor((window.pageWidth - 655) / 3) + 'px;'"
>
<el-option
v-for="item in data.customerOrgType"
:key="item.id"
:label="item.displayName"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-col>
@ -86,7 +102,6 @@
<el-radio v-model="form.isActive" label="N">停用</el-radio>
-->
<el-checkbox v-model="form.isActiveBox" @change="changeBox('isActive')" />
</el-form-item>
</el-col>
</el-row>
@ -112,7 +127,12 @@
<el-row>
<el-col :span="12">
<el-form-item label="地址" prop="address">
<el-input v-model="form.address" placeholder="请输入地址" maxlength="50" show-word-limit />
<el-input
v-model="form.address"
placeholder="请输入地址"
maxlength="50"
show-word-limit
/>
</el-form-item>
</el-col>
<el-col :span="12">
@ -129,7 +149,13 @@
</el-col>
<el-col :span="7">
<el-form-item label="创建时间">
<el-date-picker v-model="form.creationTime" type="datetime" size="small" style="width: 100%" disabled />
<el-date-picker
v-model="form.creationTime"
type="datetime"
size="small"
style="width: 100%"
disabled
/>
</el-form-item>
</el-col>
<el-col :span="5">
@ -139,23 +165,34 @@
</el-col>
<el-col :span="7">
<el-form-item label="修改时间">
<el-date-picker v-model="form.lastModificationTime" type="datetime" size="small" style="width: 100%"
disabled />
<el-date-picker
v-model="form.lastModificationTime"
type="datetime"
size="small"
style="width: 100%"
disabled
/>
</el-form-item>
</el-col>
</el-row>
</el-form>
</div>
<!-- 按钮区域 -->
<div style="width:110px;margin-left: 10px; margin-top: 3%">
<div style="width: 110px; margin-left: 10px; margin-top: 3%">
<div class="btnList">
<el-button type="primary" @click="add('form','')" class="btnClass">新增单位</el-button>
<el-button type="primary" @click="add('form', '')" class="btnClass"
>新增单位</el-button
>
</div>
<div class="btnList">
<el-button type="primary" @click="add('form','child')" class="btnClass">新增子单位</el-button>
<el-button type="primary" @click="add('form', 'child')" class="btnClass"
>新增子单位</el-button
>
</div>
<div class="btnList">
<el-button type="success" @click="onSubmit('form')" class="btnClass">保存</el-button>
<el-button type="success" @click="onSubmit('form')" class="btnClass"
>保存</el-button
>
</div>
<div class="btnList">
<el-button type="danger" @click="del('form')" class="btnClass">删除</el-button>
@ -167,11 +204,11 @@
import { mapState, mapMutations } from "vuex";
import { getapi, postapi, putapi, deletapi } from "@/api/api";
import { tcdate, objCopy, deepCopy, arrayExistObj } from "../../utlis/proFunc";
import { getTreeNode, getTreePids} from "../../utlis/tree";
import { getTreeNode, getTreePids } from "../../utlis/tree";
export default {
components: {},
props: ['id'],
props: ["id"],
data() {
return {
isActiveBox: false,
@ -182,7 +219,7 @@ export default {
},
peisid: null,
form:{
form: {
id: "",
displayName: "",
shortName: "",
@ -201,16 +238,14 @@ export default {
isLockBox: false,
isActiveBox: true,
organizationUnitId: null,
creatorName:'',
creationTime:null,
lastModifierName:'',
lastModificationTime:null,
creatorName: "",
creationTime: null,
lastModifierName: "",
lastModificationTime: null,
}, //
rules: {
displayName: [
{ required: true, message: "请输入单位名称", trigger: "blur" },
],
displayName: [{ required: true, message: "请输入单位名称", trigger: "blur" }],
shortName: [{ required: true, message: "请输入单位简写", trigger: "blur" }],
organizationUnitId: [
{ required: true, message: "请输入体检中心", trigger: "blur" },
@ -222,8 +257,8 @@ export default {
},
created() {
this.peisid = window.sessionStorage.getItem('peisid');
if(!this.form.id){
this.peisid = window.sessionStorage.getItem("peisid");
if (!this.form.id) {
this.form.organizationUnitId = this.peisid;
}
},
@ -237,7 +272,6 @@ export default {
this.getOrgType();
this.getCustomerOrgRd(this.id);
},
computed: {
@ -248,42 +282,39 @@ export default {
changeBox(type) {
//
if(this.form[type + 'Box']){
this.form[type] = 'Y';
}else{
this.form[type] = 'N';
if (this.form[type + "Box"]) {
this.form[type] = "Y";
} else {
this.form[type] = "N";
}
},
//
getCustomerOrgRd(id) {
if(!id) return;
if (!id) return;
getapi(`/api/app/customer-org/${id}`).then((res) => {
if (res.code != -1) {
objCopy(res.data, this.form);
if (res.data.isActive == 'Y') {
if (res.data.isActive == "Y") {
this.form.isActiveBox = true;
} else {
this.form.isActiveBox = false;
}
if (res.data.isLock == 'Y') {
if (res.data.isLock == "Y") {
this.form.isLockBox = true;
} else {
this.form.isLockBox = false;
}
}
});
},
//
getoraniztion() {
getapi("/api/app/organization-units/organization-unit-by-is-peis").then(
(res) => {
getapi("/api/app/organization-units/organization-unit-by-is-peis").then((res) => {
this.data.organizationdata = res.data;
}
);
});
},
//
@ -294,7 +325,7 @@ export default {
},
//()
getCustomerOrgTree(oprType,body) {
getCustomerOrgTree(oprType, body) {
// getapi("/api/app/customerorg/getbycodeall").then((res) => {
// //customerOrgTree = res.data;
// console.log("res.data", res.data);
@ -302,24 +333,29 @@ export default {
// tcdate(this.customerOrg.customerOrgTree);
// });
switch (oprType) {
case 'insert':
case "insert":
let node = {
id: body.id,
displayName:body.displayName,
parentId:body.parentId
}
displayName: body.displayName,
parentId: body.parentId,
};
if(body.parentId){
let pNode = getTreeNode(this.customerOrg.customerOrgTree, "treeChildren", "id", body.parentId)
if(pNode.treeChildren){
pNode.treeChildren.push(node)
}else{
pNode.treeChildren = [node]
if (body.parentId) {
let pNode = getTreeNode(this.customerOrg.customerOrgTree,"treeChildren","id",body.parentId);
if (!pNode.treeChildren) this.$set(pNode, 'treeChildren', []);
//pNode.treeChildren = []
pNode.treeChildren.push(node);
} else {
this.customerOrg.customerOrgTree.push(node);
}
}else{
this.customerOrg.customerOrgTree.push(node)
this.customerOrg.defaultExpandedKeys = []
if(body.parentId){
this.customerOrg.defaultExpandedKeys.push(body.parentId)
}
this.customerOrg.defaultExpandedKeys.push(body.id)
this.customerOrg.treeCurrentNodekey = body.id;
//console.log("this.customerOrg.treeCurrentNodekey",this.customerOrg.treeCurrentNodekey);
break;
// "id": "3a0c5101-a6a6-e48a-36ec-33e7567a99e6",
@ -328,24 +364,40 @@ export default {
// "code": "00001",
// "treeChildren": [
case 'update':
let node2 = getTreeNode(this.customerOrg.customerOrgTree, "treeChildren", "id", body.id);
node2.displayName = body.displayName
case "update":
let node2 = getTreeNode(
this.customerOrg.customerOrgTree,
"treeChildren",
"id",
body.id
);
node2.displayName = body.displayName;
break;
case 'delete':
let lfind = -1
let pids = getTreePids(this.customerOrg.customerOrgTree,"treeChildren", 'parentId','id',body)
case "delete":
let lfind = -1;
let pids = getTreePids(
this.customerOrg.customerOrgTree,
"treeChildren",
"parentId",
"id",
body
);
//tree, childNodeName, pidName, idName, idVal getTreeNode(this.customerOrg.customerOrgTree, "treeChildren", "id", body);
//console.log('pids',pids,body)
if(!pids || pids.length < 1){
lfind = arrayExistObj(this.customerOrg.customerOrgTree, 'id', body)
if(lfind > - 1) this.customerOrg.customerOrgTree.splice(lfind,1)
}else{
let node3 = getTreeNode(this.customerOrg.customerOrgTree, "treeChildren", "id", pids[0]);
console.log('pids',pids,body)
if (!pids || pids.length < 2) {
lfind = arrayExistObj(this.customerOrg.customerOrgTree, "id", body);
if (lfind > -1) this.customerOrg.customerOrgTree.splice(lfind, 1);
} else {
let node3 = getTreeNode(
this.customerOrg.customerOrgTree,
"treeChildren",
"id",
pids[0]
);
//console.log('node3',node3)
lfind = arrayExistObj(node3.treeChildren, 'id', body)
if(lfind > - 1) node3.treeChildren.splice(lfind,1)
lfind = arrayExistObj(node3.treeChildren, "id", body);
if (lfind > -1) node3.treeChildren.splice(lfind, 1);
}
break;
default:
@ -393,66 +445,85 @@ export default {
//this.setData({ key: "customerOrg.customerOrgRd", value: res });
this.customerOrg.customerOrgId = res.data.id;
this.customerOrg.customerOrgRd = res.data;
this.getCustomerOrgTree('insert',res.data);
this.getCustomerOrgTree("insert", res.data);
}
});
} else {
//id
putapi(
`/api/app/customer-org/${this.customerOrg.customerOrgRd.id}`,
body
).then((res) => {
putapi(`/api/app/customer-org/${this.customerOrg.customerOrgRd.id}`, body).then(
(res) => {
if (res.code == 1) {
this.$message.success("更新 操作成功");
let lbody = {id:this.customerOrg.customerOrgRd.id,...body}
this.getCustomerOrgTree('update',lbody);
let lbody = { id: this.customerOrg.customerOrgRd.id, ...body };
this.getCustomerOrgTree("update", lbody);
}
});
}
);
}
});
},
//
async add(formName,child) {
async add(formName, child) {
await this.$refs[formName].resetFields();
if (child) {
if (!this.customerOrg.customerOrgId) {
this.$message.info("请先选择单位")
return
this.$message.info("请先选择单位");
return;
}
this.customerOrg.customerOrgRd.id = '';
this.customerOrg.customerOrgRd = { id: "", isLock: "N", isActive: "Y", parentId: this.customerOrg.customerOrgId };
this.customerOrg.customerOrgRd.id = "";
this.customerOrg.customerOrgRd = {
id: "",
isLock: "N",
isActive: "Y",
parentId: this.customerOrg.customerOrgId,
};
} else {
this.customerOrg.customerOrgRd = { id: "", isLock: "N", isActive: "Y", parentId: null };
this.customerOrg.customerOrgRd = {
id: "",
isLock: "N",
isActive: "Y",
parentId: null,
};
}
objCopy(this.customerOrg.customerOrgRd,this.form)
objCopy(this.customerOrg.customerOrgRd, this.form);
this.customerOrg.customerOrgId = "";
},
//
del(formName) {
if(!this.customerOrg.customerOrgRd.id){
this.$message.warning("请先选中要删除的节点")
return
}
//
//let node = deepCopy(getTreeNode(this.customerOrg.customerOrgTree,"treeChildren","id",this.customerOrg.customerOrgRd.id));
this.$confirm("此操作将永久删除该记录, 是否继续?", "提示", {
confirmButtonText: "是",
cancelButtonText: "否",
type: "warning",
}).then(() => {
})
.then(() => {
//console.log('{patientRegisterIds}',{patientRegisterIds})
return deletapi(`/api/app/customer-org/${this.customerOrg.customerOrgRd.id}`);
}).then((res) => {
if(res.Code != -1) {
})
.then((res) => {
if (res.code != -1) {
this.$message.success("删除 操作成功");
this.getCustomerOrgTree('delete',this.customerOrg.customerOrgRd.id);
this.getCustomerOrgTree("delete", this.customerOrg.customerOrgRd.id);
this.customerOrg.customerOrgRegisterList = []
this.customerOrg.contactPersonList = []
this.customerOrg.contactMethodList = []
this.setData({ key: "customerOrg.customerOrgRd", value: { id: "" } });
this.$refs[formName].resetFields();
}
}).catch((err) => {
if(err == 'cancel'){
})
.catch((err) => {
if (err == "cancel") {
this.$message.info("已取消删除");
}else{
} else {
this.$message.error("操作失败,原因:" + err);
}
});
@ -460,9 +531,9 @@ export default {
},
watch: {
'id'(newVal, oldVal) {
id(newVal, oldVal) {
console.log("watch getCustomerOrgRd newVal:", newVal, " oldVal:", oldVal);
if (newVal != oldVal && newVal != '') {
if (newVal != oldVal && newVal != "") {
this.getCustomerOrgRd(newVal);
}
},

30
src/components/customerOrg/customerOrgTree.vue

@ -1,5 +1,8 @@
<template>
<el-tree :data="customerOrg.customerOrgTree" :props="customerOrg.treeprops" @node-click="treeclick" highlight-current/>
<el-tree :data="customerOrg.customerOrgTree" :props="customerOrg.treeprops"
node-key="id"
:default-expanded-keys="customerOrg.defaultExpandedKeys"
@node-click="treeclick" highlight-current ref="customerOrgTree"/>
</template>
<script>
import { mapState, mapMutations } from "vuex";
@ -10,14 +13,18 @@ import { getTreePids} from "../../utlis/tree";
export default {
components: {},
data() {
return {};
return {
};
},
//<el-tree :data="$store.state.customerOrg.customerOrgTree" :props="$store.state.customerOrg.treeprops" @node-click="treeclick"></el-tree>
computed: {
...mapState(["customerOrg", "window"]),
},
//
created() { },
created() {
},
//
mounted() {
@ -120,8 +127,21 @@ export default {
//
this.getContactPersonList(data.id);
},
},
},
watch: {
"customerOrg.treeCurrentNodekey"(newVal,oldVal){
//console.log('watch:customerOrg.treeCurrentNodekey',newVal,oldVal)
if(newVal && newVal != oldVal){
this.$nextTick(() => {
this.$refs['customerOrgTree'].setCurrentKey(newVal);
})
}
},
},
};
</script>
<style scoped></style>
<style scoped>
@import "../../assets/css/global.css";
</style>

3
src/store/index.js

@ -30,9 +30,12 @@ export default new Vuex.Store({
customerOrg: {
//体检单位设置
customerOrgTree: [], //体检单位列表
defaultExpandedKeys:[], //当前选中树的节点
treeCurrentNodekey:'', //当前选中树的节点
treeprops: {
label: "displayName",
value: "id",
id: "id",
children: "treeChildren",
}, //树形组件的数据结构
customerOrgId: "", //当前单位ID(可根据此值是否为空,判断是新增还是编辑)

Loading…
Cancel
Save