|
|
<template> <div class="box"> <div style="width: 95%"> <el-card> <el-table :data="tableData" style="width: 100%" row-key="id" class="el-table__body-wrapper tbody" @row-click="rowick" highlight-current-row > <el-table-column prop="id" label="编号" width="300"> </el-table-column> <el-table-column prop="displayName" label="名称" width=""> </el-table-column> <el-table-column prop="creatorName" label="创建者" width=""> </el-table-column> <el-table-column prop="creationTime" label="创建时间" width="200"> <template slot-scope="scope"> {{ scope.row.creationTime | dateFormat }} </template> </el-table-column> <el-table-column prop="lastModifierName" label="修改者" width=""> </el-table-column> <el-table-column prop="lastModificationTime" label="修改时间" width="200" > <template slot-scope="scope"> {{ scope.row.lastModificationTime | dateFormat }} </template> </el-table-column> <el-table-column label="操作" width=""> <template> <el-tag class="move" style="cursor: move; margin-left: 15px" draggable="true" > <i class="el-icon-d-caret" style="width: 1rem; height: 1rem" ></i> </el-tag> </template> </el-table-column> </el-table> <!-- --> <span style="margin-top: 10px; padding: 5px; margin-left: 28.8%" >项目类别</span > <el-select v-model="values" placeholder="请选择" @change="ischangs" style="margin-top: 5px" > <el-option v-for="item in projectid" :key="item.id" :label="item.displayName" :value="item.id" > </el-option> </el-select> <span style="margin-left: 10%; padding: 5px">搜索选择</span> <el-select value-key="id" filterable v-model="flitvalues" placeholder="请选择" style="margin-top: 5px" @change="diagnosisitem" > <el-option v-for="item in filetelists" :key="item.id" :label="item.displayName" :value="item" > </el-option> </el-select> <div class="mainbox"> <div class="mainleftbox"> <div class="weixuan">未选项目</div> <div v-for="(item, index) in leftdata" :key="index" @click="clickPaixu(item, index)" @dblclick="shuanji(item, index)" :class="num === index ? 'activetext' : ''" style="" > <div>{{ item.displayName }}</div> </div> </div> <div class="Selectbutton"> <div style="margin-top: 10px"> <el-button @click="addall" >全添加<i class="el-icon-caret-right"></i ><i class="el-icon-caret-right"></i ></el-button> </div> <div style="margin-top: 10px"> <el-button @click="addobj" style="width: 111px" >添加<i class="el-icon-caret-right"></i> </el-button> </div> <div style="margin-top: 10px"> <el-button @click="removeright" style="width: 111px" >移去<i class="el-icon-caret-left"></i> </el-button> </div> <div style="margin-top: 10px"> <el-button @click="allclear" >全移去<i class="el-icon-caret-left"></i ><i class="el-icon-caret-left"></i> </el-button> </div> </div> <div class="mainleftbox"> <div class="weixuan">已选项目</div> <div v-for="(item, index) in rightdata" :key="index" @click="rightindex(item, index)" @dblclick="rightdelite(item, index)" :class="nums === index ? 'activetext' : ''" > <div>{{ item.displayName }}</div> </div> </div> </div> <div class="confirmcancellation"> <el-button :disabled="isdislob" @click="Onsubmit">确定</el-button> <el-button :disabled="isdislob">取消</el-button> </div> </el-card> <el-dialog :title="title == 1 ? '新增' : '编辑'" :visible.sync="dialogVisible" width="75%" :close-on-click-modal="false" > <el-form ref="form" :model="form" label-width="100px" :rules="rules"> <el-row> <el-col :span="8"> <el-form-item label="名称" prop="displayName"> <el-input ref="refinput" v-model="form.displayName" style="width: 100%" maxlength="1" ></el-input> </el-form-item ></el-col> </el-row> </el-form> <span slot="footer" class="dialog-footer"> <el-button @click="dialogVisible = false">取 消</el-button> <el-button type="primary" @click="onsbmint">确 定</el-button> </span> </el-dialog> </div> <!-- 按钮区域 --> <div style="margin-left: 10px; margin-top: 3.5%"> <el-button type="primary" @click="add">新增</el-button> <div style="margin-top: 10px"> <el-button type="primary" @click="edit">编辑</el-button> </div> <div style="margin-top: 10px"> <el-button type="danger" @click="delets">删除</el-button> </div> <div style="margin-top: 10px"> <el-button type="primary" @click="topping">置顶</el-button> </div> <div style="margin-top: 10px"> <el-button type="primary" @click="toppings">置底</el-button> </div> <div style="margin-top: 10px"> <el-button type="primary" :disabled="isshow" @click="assertion" >排序</el-button > </div> <div style="margin-top: 10px"> <el-button type="primary" :disabled="isshow" @click="cancellation" >取消</el-button > </div> </div> </div></template><script>import Sortable from "sortablejs";import { postapi, getapi, putapi, deletapi } from "@/api/api";import { projectlist } from "@/request/commonapi";import { examinationgender, diagsislist } from "@/request/systemapi";export default { data() { return { num: 0, rightdata: [], //右侧数据
leftdata: [], //左侧数据
projectid: [], filetelists: [], flitvalues: [], values: "", isshow: true, isdislob: true, rules: { displayName: [ { required: true, message: "请输入名称", trigger: "blur" }, ], itemTypeId: [ { required: true, message: "请选择项目类别", trigger: "blur" }, ], suggestionName: [ { required: true, message: "请输入建议名称", trigger: "blur" }, ], isIll: [{ required: true, message: "请选择是疾病", trigger: "blur" }], isSummaryTemplate: [ { required: true, message: "请选择是总检模板", trigger: "blur" }, ], forSexId: [ { required: true, message: "请选择适用性别", trigger: "blur" }, ], diagnosisLevelId: [ { required: true, message: "请选择诊断级别", trigger: "blur" }, ], }, pages: { Filter: "", SkipCount: 0, MaxResultCount: 100, Sorting: "displayOrder desc", }, tableData: [], initTableData: [], dialogVisible: false, title: 1, form: { displayName: "", itemTypeId: "", suggestionName: "", isIll: "", isSummaryTemplate: "", forSexId: "", diagnosisLevelId: "", }, isIll: [ { value: "Y", label: "是", }, { value: "N", label: "否", }, ], //是疾病
isSummaryTemplate: [ { value: "Y", label: "是", }, { value: "N", label: "否", }, ], //是总监模板
itemTypeId: [], //项目类别
forSexId: [], //性别
diagnosisLevelId: [], //诊断级别
ary1: [], ary2: [], nums: 0, curRow: {}, diagonsisitemtype: [], //搜索选择
flitvalues: "", }; }, created() { this.getlist(); this.gitprojectcategory(); }, mounted() { this.rowDrop(); this.getdiagnosisitem(); }, methods: { diagnosisitem(v) { this.rightdata.forEach(item=>{ }) console.log(v); this.rightdata.push({ displayName: v.displayName }); }, //获取搜索选择
getdiagnosisitem() { getapi("/api/app/item").then((res) => { this.filetelists = res.data.items; console.log(res); }); }, Onsubmit() { let sampleGroupId = this.form.id; console.log(this.form.id); console.log(this.rightdata); let sdate = []; this.rightdata.forEach((element) => { let sss = { sampleGroupId: sampleGroupId, asbitemId: element.id }; sdate.push(sss); }); // this.leftdata.forEach((element) => {
// let sss = { sampleGroupId: sampleGroupId, asbitemId: element.id };
// sdate.push(sss);
// });
console.log(sdate); if (sampleGroupId == undefined) { this.$message.warning("请选择列表"); } else { postapi("/api/app/item-template-detail/many", sdate).then((res) => { this.$message.success("操作成功"); this.isdislob = true; }); } }, //q全移去
allclear() { this.isdislob = false; if (this.rightdata.length > 0) { this.ary1 = this.rightdata; this.ary2 = this.leftdata; this.updatedate(); this.rightdata = []; } }, //右移动
removeright() { this.isdislob = false; if (this.rightdata.length > 0) { this.rightdata.splice(this.num, 1); this.leftdata.push(this.leftobj); this.isdislob = true; this.updatedate(); } }, //左侧添加按钮
addobj() { this.isdislob = false; if (this.leftdata.length > 0) { this.leftdata.splice(this.num, 1); this.rightdata.push(this.rightobj); } }, //全添加
addall() { this.isdislob = false; if (this.leftdata.length > 0) { this.ary1 = this.leftdata; this.ary2 = this.rightdata; this.updatedate(); this.leftdata = []; } }, //左侧双击事件
shuanji(item, index) { this.isdislob = false; console.log(item); this.leftdata.splice(index, 1); this.rightdata.push(item); }, clickPaixu(item, index) { this.rightobj = item; this.num = index; console.log(this.num); }, //获取项目类别 3a0b0b10-719f-5824-6956-8cb70f204013
gitprojectcategory() { getapi("/api/app/item-type/by-code-all").then((res) => { this.projectid = res.data; }); }, //ary1 需要追加的数据 ary2目标数组
updatedate() { this.ary1.forEach((item) => { let iscz = false; this.ary2.forEach((item2) => { if (item2.id == item.id) { iscz = true; } }); if (!iscz) { console.log(item.id); this.ary2.push(item); // this.allid.push({ id: item.id });
} }); }, //项目类别选择
ischangs(v) { console.log(v); getapi(`/api/app/diagnosis/in-item-type/${v}`).then((res) => { console.log(res); this.leftdata = res.data; }); }, //取消排序
cancellation() { this.$message.info("取消操作"); this.isshow = true; this.getlist(); }, //确定排序
assertion() { const result = []; this.tableData.forEach((item, index) => { // index 从0开始的, 你的displayOrder从大到小排
console.log(item.id); // const currentDisplayOrder = this.tableData.length -1
const currentDisplayOrder = this.initTableData[index].displayOrder; if (item.displayOrder != currentDisplayOrder) { // 如果它的displayOrder和它当前所在的位置不同代表挪动过位置
result.push({ id: item.id, displayOrder: currentDisplayOrder }); } }); putapi("/api/app/diagnosistemplate/updatesortmany", { itemList: result, }).then((res) => { this.$message.success("操作成功"); this.isshow = true; this.getlist(); }); }, //初始化
rowDrop() { this.$nextTick(() => { const tbody = document.querySelector(".el-table__body-wrapper tbody"); const _this = this; Sortable.create(tbody, { handle: ".move", animation: 300, // 指定父元素下可被拖拽的子元素
// draggable: ".module-manager .el-table__row",
onEnd({ newIndex, oldIndex }) { // console.log(arr);
_this.isshow = false; const currRow = _this.tableData.splice(oldIndex, 1)[0]; _this.tableData.splice(newIndex, 0, currRow); _this.tableData.map((item, index) => { if (index == newIndex && index == oldIndex) { // console.log(item, "新数据");
} else if (index == oldIndex) { } else if (index == newIndex) { } }); console.log(_this.tableData.map((item) => item.displayOrder)); }, }); }); }, toppings() { this.form = { ...this.curRow }; if (this.form.id == undefined) { this.$message.warning("请选择操作的数据"); } else { putapi( `/api/app/diagnosistemplate/updatemanysort?id=${ this.form.id }&SortType=${2}`
).then((res) => { this.$message.success("操作成功"); this.getlist(); }); } }, topping() { this.form = { ...this.curRow }; if (this.form.id == undefined) { this.$message.warning("请选择操作的数据"); } else { putapi( `/api/app/diagnosistemplate/updatemanysort?id=${ this.form.id }&SortType=${1}`
).then((res) => { this.$message.success("操作成功"); this.getlist(); }); } }, //删除
delets(row) { this.form = { ...this.curRow }; if (this.form.id == undefined) { this.$message.warning("请选择删除的数据"); } else { this.$confirm("是否确认删除,是否继续?", "提示", { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning", }) .then(() => { deletapi(`/api/app/diagnosis-template/${this.form.id}`).then( (res) => { this.$message.success("删除成功"); this.getlist(); } ); }) .catch(() => { this.$message.info("已取消操作"); }); } }, //编辑弹框
edit(row) { this.form = { ...this.curRow }; if (this.form.id == undefined) { this.$message.warning("请选择操作的数据"); } else { //项目类别
projectlist().then((res) => { this.itemTypeId = res.data.items; }); //性别
examinationgender().then((res) => { this.forSexId = res.data; }); //诊断级别
diagsislist().then((res) => { this.diagnosisLevelId = res.data.items; }); this.title = 2;
this.dialogVisible = true; } }, //确定新增或者编辑
onsbmint() { this.$refs.form.validate((v) => { if (v) { if (this.title == 1) { postapi("/api/app/diagnosis-template", this.form).then((res) => { this.$message.success("新增成功"); this.getlist(); this.dialogVisible = false; }); } else if (this.title == 2) { putapi( `/api/app/diagnosis-template/${this.form.id}`, this.form ).then((res) => { this.$message.success("修改成功"); this.getlist(); this.dialogVisible = false; }); } } }); // postapi('/api/app/diagnosis',this)
}, //新增弹框
add() { this.dialogVisible = true; this.title = 1; this.form = {}; this.$nextTick(() => { this.$refs.refinput.focus(); });
//项目类别
projectlist().then((res) => { this.itemTypeId = res.data.items; }); //性别
examinationgender().then((res) => { this.forSexId = res.data; }); //诊断级别
diagsislist().then((res) => { this.diagnosisLevelId = res.data.items; }); }, rowick(row) { getapi(`/api/app/diagnosis-template/${row.id}`).then((res) => { this.curRow = { ...res.data }; // this.form = res.data;
}); getapi(`/api/app/diagnosis-template/${row.id}`).then((res) => { console.log(res); let dq = res.data; if (dq.length > 0) { this.rightdata = []; dq.forEach((element) => { let bb = { displayName: element.displayName, id: element.id }; this.rightdata.push(bb); }); } }); //诊断模板包含的诊断
getapi( `/api/app/diagnosis-template-detail/diagnosis-template-in-diagnosis?DiagnosisTemplateId=${row.id}` ).then((res) => { this.rightdata = res.data; console.log(res, "诊断"); }); console.log(row); }, getlist() { getapi("/api/app/diagnosis-template/in-filter", this.pages).then( (res) => { this.initTableData = [...res.data.items]; this.tableData = res.data.items; console.log(res); } ); }, },};</script><style scoped>.confirmcancellation { margin-left: 45%;}.Selectbutton { margin-left: 3%;}.activetext { background: rgb(185, 203, 235);}.weixuan { text-align: center; line-height: 20px; background: rgb(185, 203, 235);}.mainleftbox { width: 200px; height: 240px; border: 1px solid #ccc; margin-left: 6%;}.mainbox { display: flex; justify-content: center; margin-top: 20px;}.box { display: flex;}</style>
|