diff --git a/public/importTemplates/bomImport.xlsx b/public/importTemplates/bomImport.xlsx new file mode 100644 index 0000000..59cc8b3 Binary files /dev/null and b/public/importTemplates/bomImport.xlsx differ diff --git a/public/importTemplates/orderImport.xlsx b/public/importTemplates/orderImport.xlsx new file mode 100644 index 0000000..531ae69 Binary files /dev/null and b/public/importTemplates/orderImport.xlsx differ diff --git a/src/views/modules/pms/order/components/DialogUpload.vue b/src/views/modules/pms/order/components/DialogUpload.vue index f3e456e..36ca3cc 100644 --- a/src/views/modules/pms/order/components/DialogUpload.vue +++ b/src/views/modules/pms/order/components/DialogUpload.vue @@ -7,15 +7,24 @@ title="导入订单" :destroy-on-close="false" :close-on-click-modal="configs.clickModalToClose ?? true"> - +
- 将文件拖到此处,或点击上传 + 将文件拖到此处,或 + 点击上传
只能上传 Excel 文件
+ 下载模板 取消
@@ -56,18 +65,38 @@ export default { this.visible = true; }, - /** handlers */ - handleSelectChange(col, eventValue) { - // console.log("[dialog] select change: ", col, eventValue); - this.$forceUpdate(); + fileTypeCheck() { + // 上传前检查文件类型: Boolean }, - handleComponentModelUpdate(propName, { subject, payload: { data } }) { - this.dataForm[propName] = JSON.stringify(data); - // console.log("[DialogJustForm] handleComponentModelUpdate", this.dataForm[propName]); + fileSizeCheck() { + // 上传前检查文件大小: Boolean }, - handleUpload() {}, + handleSuccess(response, file, fileList) { + // console.log("success response", response); + let message = ""; + let isError = false; + + if (typeof response === "object" && "msg" in response) message = response.msg; + if (typeof response === "object" && "data" in response) message = response.data.toString(); + if (typeof response === "string") { + message = response; + isError = true; + } + + this.handleClose(); + + this.$message({ + message, + type: isError ? "error" : "info", + duration: 2000, + }); + }, + + handleError(err, file, fileList) { + console.log("err", err); + }, handleBtnClick(payload) { if ("name" in payload) { @@ -75,10 +104,29 @@ export default { case "cancel": this.handleClose(); break; + case "download-template": + this.handleDownloadTemplate(); + break; } } }, + handleDownloadTemplate(filename) { + this.$notify({ + title: "提示", + message: "开始下载", + type: "success", + }); + + // 下载模板 + let a = document.createElement("a"); + a.href = "/importTemplates/orderImport.xlsx"; + a.download = filename ?? "orderTemplate.xlsx"; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + }, + handleUploadChange(file, fileList) { // console.log("[Upload] handleUploadChange...", file, fileList); }, @@ -122,6 +170,4 @@ export default { .dialog-just-form >>> .dialog-demo { text-align: center; } - - diff --git a/src/views/modules/pms/order/components/ListSectionWithHead.vue b/src/views/modules/pms/order/components/ListSectionWithHead.vue index e66350d..37514fc 100644 --- a/src/views/modules/pms/order/components/ListSectionWithHead.vue +++ b/src/views/modules/pms/order/components/ListSectionWithHead.vue @@ -10,8 +10,7 @@ :id="$attrs.id" :head-title="headConfig.title" :head-config="{ fields: headConfig.form }" - @btn-click="handleBtnClick" - /> + @btn-click="handleBtnClick" /> + :refresh-layout-key="refreshLayoutKey" /> + layout="total, sizes, prev, pager, next, jumper"> + @destroy-dialog="renderDialog = false" /> + @destroy-dialog="renderMenuDialog = false" /> + @refresh-list="handleRefreshList" /> @@ -111,14 +106,7 @@ export default { watch: { refreshKey(newVal) { // 外部触发更新列表 - this.getAList( - Object.assign( - {}, - this.listQuery, - this.extraSearchConditions, - this.params - ) - ); + this.getAList(Object.assign({}, this.listQuery, this.extraSearchConditions, this.params)); }, }, data() { @@ -139,14 +127,19 @@ export default { }; }, mounted() { - this.getAList( - Object.assign({}, this.listQuery, this.extraSearchConditions) - ); + this.getAList(Object.assign({}, this.listQuery, this.extraSearchConditions)); }, activated() { this.refreshLayoutKey = this.layoutTable(); }, methods: { + handleRefreshList() { + setTimeout(() => { + this.uploadDialogVisible = false; + }, 300); + this.getAList(Object.assign({}, this.listQuery, this.extraSearchConditions)); + }, + getAList(payload) { if (this.pageUrl != "#") { this.tableLoading = true; @@ -208,14 +201,7 @@ export default { type: "success", duration: 2000, onClose: () => { - this.getAList( - Object.assign( - {}, - this.listQuery, - this.extraSearchConditions, - this.params - ) - ); + this.getAList(Object.assign({}, this.listQuery, this.extraSearchConditions, this.params)); this.$emit("refresh-tables", ["ongoing"]); }, }); @@ -237,15 +223,11 @@ export default { case "destroy-order": // 结束订单 case "end-order": { - this.$confirm( - `确定${type === "end-order" ? "结束订单" : "废除订单"}?`, - "提示", - { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning", - } - ) + this.$confirm(`确定${type === "end-order" ? "结束订单" : "废除订单"}?`, "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning", + }) .then(() => { return this.$http.post("/pms/order/end", data, { headers: { @@ -261,14 +243,7 @@ export default { type: "success", duration: 2000, onClose: () => { - this.getAList( - Object.assign( - {}, - this.listQuery, - this.extraSearchConditions, - this.params - ) - ); + this.getAList(Object.assign({}, this.listQuery, this.extraSearchConditions, this.params)); this.$emit("refresh-tables", ["finished"]); }, }); @@ -308,14 +283,7 @@ export default { .then(({ data: res }) => { if (res.code === 0) { // success - this.getAList( - Object.assign( - {}, - this.listQuery, - this.extraSearchConditions, - this.params - ) - ); + this.getAList(Object.assign({}, this.listQuery, this.extraSearchConditions, this.params)); } else { // failed throw new Error(res.msg); @@ -331,15 +299,11 @@ export default { } case "delete": { // 确认是否删除 - return this.$confirm( - `确定要删除 "${data.code ?? data.id}" 吗?`, - "提示", - { - confirmButtonText: "确认", - cancelButtonText: "我再想想", - type: "warning", - } - ) + return this.$confirm(`确定要删除 "${data.code ?? data.id}" 吗?`, "提示", { + confirmButtonText: "确认", + cancelButtonText: "我再想想", + type: "warning", + }) .then(() => { // this.$http.delete(this.urls.base + `/${data}`).then((res) => { this.$http({ @@ -350,14 +314,7 @@ export default { if (res.code === 0) { this.$message.success("删除成功!"); // 获取数据 - this.getAList( - Object.assign( - {}, - this.listQuery, - this.extraSearchConditions, - this.params - ) - ); + this.getAList(Object.assign({}, this.listQuery, this.extraSearchConditions, this.params)); } }); }) @@ -395,24 +352,13 @@ export default { // 处理时间段 if (!!payload.timerange) { const [startTime, endTime] = payload["timerange"]; - this.params.startTime = moment(startTime).format( - "YYYY-MM-DDTHH:mm:ss" - ); - this.params.endTime = moment(endTime).format( - "YYYY-MM-DDTHH:mm:ss" - ); + this.params.startTime = moment(startTime).format("YYYY-MM-DDTHH:mm:ss"); + this.params.endTime = moment(endTime).format("YYYY-MM-DDTHH:mm:ss"); } delete this.params.timerange; } // 发起请求 - this.getAList( - Object.assign( - {}, - this.listQuery, - this.extraSearchConditions, - this.params - ) - ); + this.getAList(Object.assign({}, this.listQuery, this.extraSearchConditions, this.params)); break; } case "新增": @@ -436,25 +382,11 @@ export default { handleSizeChange(newSize) { this.listQuery.page = 1; this.listQuery.limit = newSize; - this.getAList( - Object.assign( - {}, - this.listQuery, - this.extraSearchConditions, - this.params - ) - ); + this.getAList(Object.assign({}, this.listQuery, this.extraSearchConditions, this.params)); }, handlePageChange(newPage) { - this.getAList( - Object.assign( - {}, - this.listQuery, - this.extraSearchConditions, - this.params - ) - ); + this.getAList(Object.assign({}, this.listQuery, this.extraSearchConditions, this.params)); }, /** 打开对话框 */ @@ -463,10 +395,7 @@ export default { this.$nextTick(() => { // console.log("init dialog", row_id, detail_mode); - this.$refs["order-dialog"].init( - /** some args... */ row_id, - detail_mode - ); + this.$refs["order-dialog"].init(/** some args... */ row_id, detail_mode); }); },