add 添加模板文件; add 添加下载模板和上传功能
This commit is contained in:
parent
84887dc9ac
commit
30d577e65b
BIN
public/importTemplates/bomImport.xlsx
Normal file
BIN
public/importTemplates/bomImport.xlsx
Normal file
Binary file not shown.
BIN
public/importTemplates/orderImport.xlsx
Normal file
BIN
public/importTemplates/orderImport.xlsx
Normal file
Binary file not shown.
@ -7,15 +7,24 @@
|
||||
title="导入订单"
|
||||
:destroy-on-close="false"
|
||||
:close-on-click-modal="configs.clickModalToClose ?? true">
|
||||
<el-upload style="margin-top: 24px; text-align: center" drag :action="urls.importOrderUrl">
|
||||
<el-upload
|
||||
style="margin-top: 24px; text-align: center"
|
||||
drag
|
||||
:action="urls.importOrderUrl"
|
||||
:headers="uploadHeaders"
|
||||
:show-file-list="false"
|
||||
:on-error="handleError"
|
||||
:on-success="handleSuccess">
|
||||
<i class="el-icon-upload"></i>
|
||||
<div class="el-upload__text">
|
||||
将文件拖到此处,或<em>点击上传</em>
|
||||
将文件拖到此处,或
|
||||
<em>点击上传</em>
|
||||
</div>
|
||||
<div class="el-upload__tip" slot="tip">只能上传 Excel 文件</div>
|
||||
</el-upload>
|
||||
|
||||
<div slot="footer">
|
||||
<el-button type="success" @click="handleBtnClick({ name: 'download-template' })">下载模板</el-button>
|
||||
<el-button @click="handleBtnClick({ name: 'cancel' })">取消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
@ -10,8 +10,7 @@
|
||||
:id="$attrs.id"
|
||||
:head-title="headConfig.title"
|
||||
:head-config="{ fields: headConfig.form }"
|
||||
@btn-click="handleBtnClick"
|
||||
/>
|
||||
@btn-click="handleBtnClick" />
|
||||
<BaseListTable
|
||||
:key="headConfig.title"
|
||||
v-loading="tableLoading"
|
||||
@ -19,8 +18,7 @@
|
||||
:column-config="tableConfig.column"
|
||||
:table-data="dataList"
|
||||
@operate-event="handleOperate"
|
||||
:refresh-layout-key="refreshLayoutKey"
|
||||
/>
|
||||
:refresh-layout-key="refreshLayoutKey" />
|
||||
|
||||
<el-pagination
|
||||
@size-change="handleSizeChange"
|
||||
@ -29,8 +27,7 @@
|
||||
:page-sizes="[1, 5, 10, 20]"
|
||||
:page-size="listQuery.limit"
|
||||
:total="totalPage"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
></el-pagination>
|
||||
layout="total, sizes, prev, pager, next, jumper"></el-pagination>
|
||||
|
||||
<DialogJustForm
|
||||
modal-append-to-body
|
||||
@ -38,8 +35,7 @@
|
||||
v-if="renderDialog"
|
||||
fullscreen
|
||||
:configs="dialogConfig"
|
||||
@destroy-dialog="renderDialog = false"
|
||||
/>
|
||||
@destroy-dialog="renderDialog = false" />
|
||||
|
||||
<DialogWithMenu
|
||||
modal-append-to-body
|
||||
@ -47,14 +43,13 @@
|
||||
v-if="renderMenuDialog"
|
||||
fullscreen
|
||||
:configs="dialogConfig"
|
||||
@destroy-dialog="renderMenuDialog = false"
|
||||
/>
|
||||
@destroy-dialog="renderMenuDialog = false" />
|
||||
|
||||
<DialogUpload
|
||||
ref="uploadDialog"
|
||||
v-if="uploadDialogVisible"
|
||||
@destroy-dialog="uploadDialogVisible = false"
|
||||
/>
|
||||
@refresh-list="handleRefreshList" />
|
||||
</section>
|
||||
</template>
|
||||
|
||||
@ -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);
|
||||
});
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user