diff --git a/src/components/commonTable/CommonTable.vue b/src/components/commonTable/CommonTable.vue index 370aaee..195bbef 100644 --- a/src/components/commonTable/CommonTable.vue +++ b/src/components/commonTable/CommonTable.vue @@ -7,12 +7,12 @@
- + - + @@ -21,11 +21,11 @@ {{ scope.row.creationTime ? moment(scope.row.creationTime).format("yyyy-MM-DD HH:mm:ss") : "" }} - + @@ -53,10 +53,10 @@ 删除
- 置顶 + 置顶
- 置底 + 置底
保存排序 @@ -111,8 +111,8 @@ export default { computed: { ...mapState(["personnelUnit", "window", "dict", "dialogWin", "dataTransOpts"]), - tableHeight(){ - let h = this.window.pageHeight < 600 ? 600:this.window.pageHeight + tableHeight() { + let h = this.window.pageHeight < 600 ? 600 : this.window.pageHeight return h - this.window.pageHeaderHeight - this.window.cardHeaderHeight - this.window.pageMarginHeight - 260 }, }, @@ -127,7 +127,7 @@ export default { this.dataTransOpts.tableS.common_table.id = '' this.rowDrop(); - + }, mounted() { @@ -140,13 +140,29 @@ export default { dddw, deepCopy, + getList(body) { + // body = { + // "commonTableTypeId": "string", + // "keyWord": "string" + // } + this.commonTables = [] + if(!body.commonTableTypeId) return + postapi('/api/app/CommonTable/GetList', body).then(res => { + if (res.code > -1) { + this.commonTables = res.data + this.rowDrop() + } + }) + + }, + // 确定排序 btnSort() { - const result = []; + let result = []; this.commonTables.forEach((item, index) => { result.push({ id: item.id, displayOrder: index }); }); - putapi("/api/app/customerorggroup/updatesortmany", { + postapi("/api/app/CommonTable/UpdateSortMany", { itemList: result, }).then((res) => { console.log("操作成功"); @@ -156,47 +172,27 @@ export default { //初始化Sortable组件 rowDrop() { - // this.$nextTick(() => { - // const tbody = document.querySelector(".el-table__body-wrapper tbody"); - // const _this = this; - // Sortable.create(tbody, { - // handle: ".move", - // animation: 300, - // onEnd({ newIndex, oldIndex }) { - // _this.isDrag = false; - // const currRow = _this.commonTables.splice(oldIndex, 1)[0]; - // _this.commonTables.splice(newIndex, 0, currRow); - // _this.commonTables.map((item, index) => { - // if (index == newIndex && index == oldIndex) { - // } else if (index == oldIndex) { - // } else if (index == newIndex) { - // } - // }); - // console.log(_this.commonTables.map((item) => item.displayOrder)); - // }, - // }); - // }); - + // console.log('rowDrop detail') this.$nextTick(() => { - const el = document.querySelector(".el-table__body-wrapper tbody"); - //console.log('el0',el) - const that = this; + let el = document.querySelector("#commonTables tbody"); + // console.log('el0',el) + let that = this; Sortable.create(el, { handle: ".move", animation: 300, //拖拽结束 onEnd({ newIndex, oldIndex }) { that.isDrag = true; - const currRow = that.commonTables.splice(oldIndex, 1)[0]; + let currRow = that.commonTables.splice(oldIndex, 1)[0]; that.commonTables.splice(newIndex, 0, currRow); - console.log("el", el); + // console.log("el", el); }, }); }); }, - //置底 - btnSetBottom() { + // 置顶 置底 + btnSetTopOrBottom(sortType) { if (!this.dataTransOpts.tableS.common_table.id) { this.$message.warning("请选择操作的数据"); return; @@ -204,32 +200,16 @@ export default { let lfind = arrayExistObj(this.commonTables, "id", this.dataTransOpts.tableS.common_table.id); let currentRow = {}; - putapi( - `/api/app/customerorggroup/updatemanysort?id=${this.dataTransOpts.tableS.common_table.id}&SortType=2` + postapi('/api/app/CommonTable/UpdateManySort', { commonTableId: this.dataTransOpts.tableS.common_table.id, sortType } ).then((res) => { console.log("操作成功"); currentRow = this.commonTables.splice(lfind, 1)[0]; //删除并赋值 - this.commonTables.push(currentRow); - this.$refs["commonTables"].setCurrentRow(currentRow); - }); - }, - - //置顶 - btnSetTop() { - if (!this.dataTransOpts.tableS.common_table.id) { - this.$message.warning("请选择操作的数据"); - return; - } - - let lfind = arrayExistObj(this.commonTables, "id", this.dataTransOpts.tableS.common_table.id); - let currentRow = {}; + if (sortType == 2) { + this.commonTables.push(currentRow); + } else { + this.commonTables.unshift(currentRow); + } - putapi( - `/api/app/customerorggroup/updatemanysort?id=${this.dataTransOpts.tableS.common_table.id}&SortType=1` - ).then((res) => { - console.log("操作成功"); - currentRow = this.commonTables.splice(lfind, 1)[0]; - this.commonTables.unshift(currentRow); this.$refs["commonTables"].setCurrentRow(currentRow); }); }, @@ -248,15 +228,6 @@ export default { //获取初始数据 dictInit() { - //获取单位列表 - getapi("/api/app/customer-org/parent-all").then((res) => { - if (res.code != -1) { - this.customerOrgAll = res.data; - let lfind = arrayExistObj(this.customerOrgAll, "id", this.dict.personOrgId); - if (lfind > -1) this.customerOrgAll.splice(lfind, 1); - this.customerOrg = deepCopy(this.customerOrgAll); - } - }); }, @@ -269,15 +240,15 @@ export default { // 新增(编辑调用时,传入id值) 弹框 btnAdd(id) { - - if (!id) this.dataTransOpts.tableS.common_table.id = '' + if (!id) this.dataTransOpts.tableS.common_table.id = '' this.CommonTableEditParams = { id, commonTableTypeId: this.dataTransOpts.tableS.common_table_type.id, } - + this.dataTransOpts.refresh.common_table.S++ this.dialogWin.CommonTableEdit = true; + }, //编辑弹框 @@ -295,10 +266,6 @@ export default { this.$message.warning("请选择需要操作的数据"); return; } - if (this.customerOrgRegister.isComplete.toUpperCase() == "Y") { - this.$message.warning("该单位体检次数已完成,不允许删除分组"); - return; - } this.$confirm("此操作将永久删除该记录, 是否继续?", "提示", { confirmButtonText: "是", @@ -306,17 +273,13 @@ export default { type: "warning", }) .then(() => { - return deletapi(`/api/app/customer-org-group/${this.dataTransOpts.tableS.common_table.id}`); + return postapi('/api/app/CommonTable/Delete', {commonTableId:this.dataTransOpts.tableS.common_table.id}); }) .then((res) => { if (res.code != -1) { console.log("删除成功"); let lfind = arrayExistObj(this.commonTables, "id", this.dataTransOpts.tableS.common_table.id); - if (lfind > -1) this.commonTables.splice(lfind, 1); - this.dataTransOpts.tableS.common_table.id = '' - setTimeout(() => { - this.dataTransOpts.refresh.common_table_detail.M++ - }, 20); + if (lfind > -1) this.commonTables.splice(lfind, 1); } }) .catch((err) => { @@ -332,7 +295,7 @@ export default { let id = this.dataTransOpts.tableS.common_table.id if (id) { // 点编辑 或 新增有提交 - getapi(`/api/app/customer-org-group/${id}`) + postapi('/api/app/CommonTable/Get', { commonTableId: id }) .then(res => { if (res.code != -1) { let lfind = -1 @@ -350,24 +313,23 @@ export default { // 更新 common_table_detail 参数 this.curCommonTable = deepCopy(res.data); - this.curCommonTable.isComplete = this.customerOrgRegister.isComplete; } }) } else { // 点 新增 但未提交 this.dataTransOpts.tableS.common_table.id = this.curCommonTable.id || '' - } + } }, }, //监听事件 watch: { // 刷新公共表数据 - "dataTransOpts.refresh.common_table.M":{ + "dataTransOpts.refresh.common_table.M": { // immediate:true, handler(newVal, oldVal) { - console.log(`watch 公共表分类 newVal:${newVal} oldVal:${oldVal} commonTableTypeId: ${this.dataTransOpts.tableS.common_table_type.id}`); - if(newVal != oldVal) this.close_dialogWinCommonTableEdit(); + console.log(`watch 公共表分类 newVal:${newVal} oldVal:${oldVal} commonTableTypeId: ${this.dataTransOpts.tableS.common_table_type.id}`); + if (newVal != oldVal) this.getList({ commonTableTypeId: this.dataTransOpts.tableS.common_table_type.id }); } }, }, diff --git a/src/components/commonTable/CommonTableEdit.vue b/src/components/commonTable/CommonTableEdit.vue index cbd48b1..98b9a98 100644 --- a/src/components/commonTable/CommonTableEdit.vue +++ b/src/components/commonTable/CommonTableEdit.vue @@ -1,11 +1,11 @@