diff --git a/api/app/service/chanpin.js b/api/app/service/chanpin.js index 0f3118a..131d525 100644 --- a/api/app/service/chanpin.js +++ b/api/app/service/chanpin.js @@ -26,6 +26,10 @@ class ChanpinService extends Service { let res = await modelLocal.updateMany({ _id: { $in: paramsLocal.ids } }, { isExit: 0, update_at: Date.now() }) returnData.hasError = false returnData.msg = "数据删除成功" + } else if (subType === "delAll") { + await modelLocal.deleteMany({ "update_at": { $lt: Date.now() + 1000 * 60 * 60 * 24 } }) + returnData.hasError = false + returnData.msg = "数据已全部删除" } else if (subType === "edit") { paramsLocal = paramsLocal.list[0] paramsLocal["update_at"] = Date.now(); diff --git a/api/app/service/dingdan.js b/api/app/service/dingdan.js index d4675e2..02cef9f 100644 --- a/api/app/service/dingdan.js +++ b/api/app/service/dingdan.js @@ -167,6 +167,7 @@ class DingdanService extends Service { item["xiangtiaoma"] = _.get(chanpinItemA, [0, "xiangtiaoxingma"], "") item["zuidaxiangtiaoma"] = _.get(chanpinItemA, [0, "zuidaxiangzhuangtiaoma"], "") } else if (chanpinItemB.length) { + item.isNotSale = false item["huohao"] = _.get(chanpinItemB, [0, "daima"], "") item["chanpindaima"] = _.get(chanpinItemB, [0, "daima"], "") item["zuixiaodanweitiaoma"] = _.get(chanpinItemB, [0, "tiaoxingma"], "") @@ -182,6 +183,7 @@ class DingdanService extends Service { item["xiangtiaoma"] = _.get(chanpinItemB, [0, "xiangtiaoxingma"], "") item["zuidaxiangtiaoma"] = _.get(chanpinItemB, [0, "zuidaxiangzhuangtiaoma"], "") } else if (chanpinItemC.length) { + item.isNotSale = false item["huohao"] = _.get(chanpinItemC, [0, "daima"], "") item["chanpindaima"] = _.get(chanpinItemC, [0, "daima"], "") item["zuixiaodanweitiaoma"] = _.get(chanpinItemC, [0, "tiaoxingma"], "") diff --git a/api/app/service/user.js b/api/app/service/user.js index fe653b1..2c82ac6 100644 --- a/api/app/service/user.js +++ b/api/app/service/user.js @@ -26,6 +26,10 @@ class UserService extends Service { let res = await modelLocal.updateMany({ _id: { $in: paramsLocal.ids } }, { isExit: 0, update_at: Date.now() }) returnData.hasError = false returnData.msg = "数据删除成功" + } else if (subType === "delAll") { + await modelLocal.deleteMany({ "update_at": { $lt: Date.now() + 1000 * 60 * 60 * 24 } }) + returnData.hasError = false + returnData.msg = "数据已全部删除" } else if (subType === "edit") { paramsLocal = paramsLocal.list[0] paramsLocal["update_at"] = Date.now(); diff --git a/front/src/renderer/src/views/chanpin.vue b/front/src/renderer/src/views/chanpin.vue index 09a040e..385ab65 100644 --- a/front/src/renderer/src/views/chanpin.vue +++ b/front/src/renderer/src/views/chanpin.vue @@ -13,6 +13,12 @@ 删除 + + + + + 清空 +
@@ -328,7 +334,33 @@ export default { }) }) - } + }, + //删除全部数据 + delAll() { + ElMessageBox.confirm( + `是否删除全部数据?此操作不可逆!`, + '危险操作', + { + confirmButtonText: '确认', + cancelButtonText: '取消', + type: 'danger', + } + ) + .then(async () => { + let params = { + subType: "delAll", + url: "/api/chanpinInfo", + } + await this.updateSeach(params) + await this.searchData() + }) + .catch(() => { + ElMessage({ + type: 'info', + message: '取消删除', + }) + }) + }, }, async mounted() { this.tableHeader = _.filter(tableHeaderLocal, o => o.tableShow) diff --git a/front/src/renderer/src/views/user.vue b/front/src/renderer/src/views/user.vue index bbd4865..800f5f1 100644 --- a/front/src/renderer/src/views/user.vue +++ b/front/src/renderer/src/views/user.vue @@ -13,6 +13,12 @@ 删除 + + + + + 清空 +
@@ -329,7 +335,33 @@ export default { }) }) - } + }, + //删除全部数据 + delAll() { + ElMessageBox.confirm( + `是否删除全部数据?此操作不可逆!`, + '危险操作', + { + confirmButtonText: '确认', + cancelButtonText: '取消', + type: 'danger', + } + ) + .then(async () => { + let params = { + subType: "delAll", + url: "/api/userInfo", + } + await this.updateSeach(params) + await this.searchData() + }) + .catch(() => { + ElMessage({ + type: 'info', + message: '取消删除', + }) + }) + }, }, async mounted() { this.tableHeader = _.filter(tableHeaderLocal, o => o.tableShow)