update 订单,设备的获取方式

This commit is contained in:
lb 2023-04-17 17:01:40 +08:00
parent 37371fc023
commit 891a75556b
6 changed files with 165 additions and 62 deletions

View File

@ -14,7 +14,8 @@
:headers="uploadHeaders" :headers="uploadHeaders"
:show-file-list="false" :show-file-list="false"
:on-error="handleError" :on-error="handleError"
:on-success="handleSuccess"> :on-success="handleSuccess"
:before-upload="handleBeforeUploadCheck">
<i class="el-icon-upload"></i> <i class="el-icon-upload"></i>
<div class="el-upload__text"> <div class="el-upload__text">
将文件拖到此处 将文件拖到此处
@ -109,6 +110,23 @@ export default {
// : Boolean // : Boolean
}, },
handleBeforeUploadCheck(file) {
if (typeof file !== "object") return false;
if (!("name" in file) || !("type" in file)) return false;
const isXlsx =
file.name.split(".").pop() === "xlsx" &&
file.type === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
const isXls = file.name.split(".").pop() === "xls" && file.type === "application/vnd.ms-excel";
if (isXls || isXlsx) return true;
// false
this.$message({
message: "仅支持上传 Excel(.xls, .xlsx) 文件",
type: "error",
duration: 1500,
});
return false;
},
handleSuccess(response, file, fileList) { handleSuccess(response, file, fileList) {
// console.log("success response", response); // console.log("success response", response);

View File

@ -161,8 +161,20 @@ export default function () {
props: [ props: [
{ type: "index", label: "序号" }, { type: "index", label: "序号" },
{ prop: "material", label: "物料", isEditField: true }, { prop: "material", label: "物料", isEditField: true },
{ width: 130, prop: "qty", label: "配方物料重量", filter: (val) => (!!val ? val + " kg" : "-"), isEditField: true }, {
{ width: 130, prop: "sumqty", label: "配方总重量", filter: (val) => (!!val ? val + " kg" : "-"), isEditField: true }, width: 130,
prop: "qty",
label: "配方物料重量",
filter: (val) => (!!val ? val + " kg" : "-"),
isEditField: true,
},
{
width: 130,
prop: "sumqty",
label: "配方总重量",
filter: (val) => (!!val ? val + " kg" : "-"),
isEditField: true,
},
{ prop: "percent", label: "配比 [%]", filter: (val) => (!!val ? val + " %" : "-"), isEditField: true }, { prop: "percent", label: "配比 [%]", filter: (val) => (!!val ? val + " %" : "-"), isEditField: true },
{ prop: "remark", label: "备注", isEditField: true }, { prop: "remark", label: "备注", isEditField: true },
{ prop: "createTime", label: "添加时间", filter: timeFilter }, { prop: "createTime", label: "添加时间", filter: timeFilter },
@ -251,7 +263,8 @@ export default function () {
copyUrl: "/pms/bom/copy", copyUrl: "/pms/bom/copy",
subase: "/pms/bomMaterial", subase: "/pms/bomMaterial",
subpage: "/pms/bomMaterial/page", subpage: "/pms/bomMaterial/page",
importOrderUrl: '/pms/order/importExcelBom', // 导入的api importUrl: "/pms/order/importExcelBom", // 导入的api
templateUrl: "/importTemplates/bomImport.xlsx",
}, },
}; };
} }

View File

@ -1,43 +1,49 @@
<template> <template>
<el-dialog <el-dialog
class="dialog-just-form" class="dialog-just-form"
style="padding: 40px" style="padding: 32px"
:fullscreen="fullscreen" :fullscreen="fullscreen"
:visible="visible" :visible="visible"
@close="handleClose" @close="handleClose"
:destroy-on-close="false" :destroy-on-close="false"
:close-on-click-modal="configs.clickModalToClose ?? true" :close-on-click-modal="configs.clickModalToClose ?? true">
>
<!-- title --> <!-- title -->
<div slot="title" class="dialog-title" style="padding: 40px 40px 0"> <div slot="title" class="dialog-title">
<h1 class=""> <h2 class="">
{{ detailMode ? "查看详情" : dataForm.id ? "修改订单" : "新增订单" }} {{ detailMode ? "查看详情" : dataForm.id ? "修改订单" : "新增订单" }}
</h1> </h2>
</div> </div>
<!-- form --> <!-- form -->
<el-form ref="dataForm" :model="dataForm" v-loading="loadingStatus" style="padding: 0 40px"> <el-form ref="dataForm" :model="dataForm" v-loading="loadingStatus" size="small">
<el-row v-for="(row, rowIndex) in configs.form.rows" :key="'row_' + rowIndex" :gutter="20"> <el-row v-for="(row, rowIndex) in configs.form.rows" :key="'row_' + rowIndex" :gutter="20">
<el-col v-for="(col, colIndex) in row" :key="colIndex" :span="24 / row.length" :class="{ h0: col.hidden }"> <el-col v-for="(col, colIndex) in row" :key="colIndex" :span="24 / row.length" :class="{ h0: col.hidden }">
<!-- 通过多个 col === null 可以控制更灵活的 span 大小 --> <!-- 通过多个 col === null 可以控制更灵活的 span 大小 -->
<el-form-item v-if="col !== null" :label="col.label" :prop="col.prop" :rules="col.rules || null"> <el-form-item v-if="col !== null" :label="col.label" :prop="col.prop" :rules="col.rules || null">
<el-input v-if="col.input" v-model="dataForm[col.prop]" clearable :disabled="detailMode" v-bind="col.elparams" /> <el-input
v-if="col.input"
v-model="dataForm[col.prop]"
clearable
:disabled="detailMode"
v-bind="col.elparams" />
<el-cascader <el-cascader
v-if="col.cascader" v-if="col.cascader"
v-model="dataForm[col.prop]" v-model="dataForm[col.prop]"
:options="col.options" :options="col.options"
:disabled="detailMode" :disabled="detailMode"
v-bind="col.elparams" v-bind="col.elparams"></el-cascader>
></el-cascader>
<el-select <el-select
v-if="col.select" v-if="col.select"
v-model="dataForm[col.prop]" v-model="dataForm[col.prop]"
clearable clearable
:disabled="detailMode" :disabled="detailMode"
v-bind="col.elparams" v-bind="col.elparams"
@change="handleSelectChange(col, $event)" @change="handleSelectChange(col, $event)">
> <el-option
<el-option v-for="(opt, optIdx) in col.options" :key="'option_' + optIdx" :label="opt.label" :value="opt.value" /> v-for="(opt, optIdx) in col.options"
:key="'option_' + optIdx"
:label="opt.label"
:value="opt.value" />
</el-select> </el-select>
<el-switch <el-switch
v-if="col.switch" v-if="col.switch"
@ -45,10 +51,18 @@
:active-value="col.activeValue ?? 1" :active-value="col.activeValue ?? 1"
:inactive-value="col.activeValue ?? 0" :inactive-value="col.activeValue ?? 0"
@change="handleSwitchChange" @change="handleSwitchChange"
:disabled="detailMode" />
<el-input
v-if="col.textarea"
type="textarea"
v-model="dataForm[col.prop]"
:disabled="detailMode" :disabled="detailMode"
/> v-bind="col.elparams" />
<el-input v-if="col.textarea" type="textarea" v-model="dataForm[col.prop]" :disabled="detailMode" v-bind="col.elparams" /> <el-date-picker
<el-date-picker v-if="col.datetime" v-model="dataForm[col.prop]" :disabled="detailMode" v-bind="col.elparams" /> v-if="col.datetime"
v-model="dataForm[col.prop]"
:disabled="detailMode"
v-bind="col.elparams" />
<div class="" v-if="col.component" style="margin: 42px 0 0"> <div class="" v-if="col.component" style="margin: 42px 0 0">
<!-- 下面这个 component 几乎是为 富文本 quill 定制的了... TODO后续可能会根据业务需求创建新的版本 --> <!-- 下面这个 component 几乎是为 富文本 quill 定制的了... TODO后续可能会根据业务需求创建新的版本 -->
@ -58,8 +72,7 @@
@update:modelValue="handleComponentModelUpdate(col.prop, $event)" @update:modelValue="handleComponentModelUpdate(col.prop, $event)"
:modelValue="dataForm[col.prop] ?? ''" :modelValue="dataForm[col.prop] ?? ''"
:mode="detailMode ? 'detail' : dataForm.id ? 'edit' : 'create'" :mode="detailMode ? 'detail' : dataForm.id ? 'edit' : 'create'"
v-bind="col.bind" v-bind="col.bind" />
/>
</div> </div>
<!-- add more... --> <!-- add more... -->
</el-form-item> </el-form-item>
@ -68,11 +81,15 @@
</el-form> </el-form>
<!-- footer --> <!-- footer -->
<div slot="footer" style="padding: 0 40px 0"> <div slot="footer">
<template v-for="(operate, index) in configs.form.operations"> <template v-for="(operate, index) in configs.form.operations">
<el-button v-if="showButton(operate)" :key="'operation_' + index" :type="operate.type" @click="handleBtnClick(operate)">{{ <el-button
operate.label v-if="showButton(operate)"
}}</el-button> :key="'operation_' + index"
:type="operate.type"
@click="handleBtnClick(operate)">
{{ operate.label }}
</el-button>
</template> </template>
<el-button @click="handleBtnClick({ name: 'cancel' })">取消</el-button> <el-button @click="handleBtnClick({ name: 'cancel' })">取消</el-button>
</div> </div>
@ -88,8 +105,7 @@ export default {
name: "DialogJustForm", name: "DialogJustForm",
components: {}, components: {},
props: { props: {
configs: { configs: { type: Object,
type: Object,
default: () => ({ default: () => ({
clickModalToClose: true, clickModalToClose: true,
forms: null, forms: null,
@ -112,26 +128,34 @@ export default {
if (col.fetchData) if (col.fetchData)
col.fetchData().then(({ data: res }) => { col.fetchData().then(({ data: res }) => {
// console.log("[DialogJustForm fetchData -->]", res.data.list); if (res.code === 0) {
if (res.code === 0 && res.data.list) { if (typeof res.data === "object" && "list" in res.data) {
if ("injectTo" in col) { if ("injectTo" in col) {
// //
cachedList[col.prop] = res.data.list; cachedList[col.prop] = res.data.list;
}
this.$set(
col,
"options",
res.data.list.map((i) => ({
label: col.optionLabel ? i[col.optionLabel] : i.name,
value: col.optionValue ? i[col.optionValue] : i.id,
}))
);
} else if (Array.isArray(res.data)) {
this.$set(
col,
"options",
res.data.map((i) => ({
label: col.optionLabel ? i[col.optionLabel] : i.name,
value: col.optionValue ? i[col.optionValue] : i.id,
}))
);
} }
this.$set(
col,
"options",
res.data.list.map((i) => ({
label: col.optionLabel ? i[col.optionLabel] : i.name,
value: col.optionValue ? i[col.optionValue] : i.id,
}))
);
// col.options = res.data.list;
} else { } else {
// error
col.options.splice(0); col.options.splice(0);
} }
// dataForm[col.prop] = col.default ?? null; // not perfect!
}); });
else if (col.fetchTreeData) { else if (col.fetchTreeData) {
// parentId 0 // parentId 0
@ -157,7 +181,7 @@ export default {
cachedList, cachedList,
detailMode: false, detailMode: false,
baseDialogConfig: null, baseDialogConfig: null,
visible: false visible: false,
}; };
}, },
mounted() { mounted() {
@ -242,7 +266,7 @@ export default {
/** init **/ /** init **/
init(id, detailMode) { init(id, detailMode) {
this.visible = true this.visible = true;
// console.log("[DialogJustForm] init", this.dataForm, id, detailMode); // console.log("[DialogJustForm] init", this.dataForm, id, detailMode);
if (this.$refs.dataForm) { if (this.$refs.dataForm) {
// console.log("[DialogJustForm] clearing form validation..."); // console.log("[DialogJustForm] clearing form validation...");
@ -340,7 +364,9 @@ export default {
const { startTime, endTime } = this.dataForm; const { startTime, endTime } = this.dataForm;
httpPayload = { httpPayload = {
...httpPayload, ...httpPayload,
startTime: startTime ? moment(startTime).format("YYYY-MM-DDTHH:mm:ss") : moment().format("YYYY-MM-DDTHH:mm:ss"), startTime: startTime
? moment(startTime).format("YYYY-MM-DDTHH:mm:ss")
: moment().format("YYYY-MM-DDTHH:mm:ss"),
endTime: endTime ? moment(endTime).format("YYYY-MM-DDTHH:mm:ss") : moment().format("YYYY-MM-DDTHH:mm:ss"), endTime: endTime ? moment(endTime).format("YYYY-MM-DDTHH:mm:ss") : moment().format("YYYY-MM-DDTHH:mm:ss"),
}; };
} }
@ -422,7 +448,7 @@ export default {
this.visible = false; this.visible = false;
setTimeout(() => { setTimeout(() => {
this.$emit('destroy-dialog') this.$emit("destroy-dialog");
// this.resetForm(); // this.resetForm();
// this.$emit("update:dialogVisible", false); // this.$emit("update:dialogVisible", false);
}, 200); }, 200);

View File

@ -4,13 +4,13 @@
:visible="visible" :visible="visible"
@close="handleClose" @close="handleClose"
width="30%" width="30%"
title="导入订单" :title="title"
:destroy-on-close="false" :destroy-on-close="false"
:close-on-click-modal="configs.clickModalToClose ?? true"> :close-on-click-modal="configs.clickModalToClose ?? true">
<el-upload <el-upload
style="margin-top: 24px; text-align: center" style="margin-top: 24px; text-align: center"
drag drag
:action="urls.importOrderUrl" :action="actionUrl"
:headers="uploadHeaders" :headers="uploadHeaders"
:show-file-list="false" :show-file-list="false"
:on-error="handleError" :on-error="handleError"
@ -20,11 +20,21 @@
将文件拖到此处 将文件拖到此处
<em>点击上传</em> <em>点击上传</em>
</div> </div>
<div class="el-upload__tip" slot="tip">只能上传 Excel 文件</div> <div class="el-upload__tip" slot="tip">{{ hint }}</div>
</el-upload> </el-upload>
<div slot="footer"> <div slot="footer">
<el-button type="success" @click="handleBtnClick({ name: 'download-template' })">下载模板</el-button> <el-button
type="success"
@click="
handleBtnClick({
name: 'download-template',
filename: savedFilename,
url: templateUrl,
})
">
下载模板
</el-button>
<el-button @click="handleBtnClick({ name: 'cancel' })">取消</el-button> <el-button @click="handleBtnClick({ name: 'cancel' })">取消</el-button>
</div> </div>
</el-dialog> </el-dialog>
@ -38,6 +48,23 @@ import Cookies from "js-cookie";
export default { export default {
name: "DialogUpload", name: "DialogUpload",
props: { props: {
title: {
type: String,
default: "导入",
},
hint: {
hint: String,
default: "只能上传 Excel 文件",
},
filename: {
hint: String,
default: "default_file.xlsx",
},
url: {
//
hint: String,
default: "/importTemplates/orderImport.xlsx",
},
configs: { configs: {
type: Object, type: Object,
default: () => ({ default: () => ({
@ -59,6 +86,15 @@ export default {
token: Cookies.get("token") || "", token: Cookies.get("token") || "",
}; };
}, },
actionUrl() {
return window.SITE_CONFIG["apiURL"] + this.urls.importUrl;
},
savedFilename() {
return "templateUrl" in this.urls ? this.urls.templateUrl.split("/").pop() : this.filename;
},
templateUrl() {
return "templateUrl" in this.urls ? this.urls.templateUrl : this.url ?? "#";
},
}, },
methods: { methods: {
init(data) { init(data) {
@ -75,6 +111,16 @@ export default {
handleSuccess(response, file, fileList) { handleSuccess(response, file, fileList) {
// console.log("success response", response); // console.log("success response", response);
if ("code" in response && response.code === 500) {
this.$message({
message: response.msg,
type: "error",
duration: 1500,
});
return;
}
let message = ""; let message = "";
let isError = false; let isError = false;
@ -105,13 +151,13 @@ export default {
this.handleClose(); this.handleClose();
break; break;
case "download-template": case "download-template":
this.handleDownloadTemplate(); this.handleDownloadTemplate(payload.filename, payload.url);
break; break;
} }
} }
}, },
handleDownloadTemplate(filename) { handleDownloadTemplate(filename, href) {
this.$notify({ this.$notify({
title: "提示", title: "提示",
message: "开始下载,请稍后检查浏览器的下载选项或者下载目录", message: "开始下载,请稍后检查浏览器的下载选项或者下载目录",
@ -120,7 +166,7 @@ export default {
// //
let a = document.createElement("a"); let a = document.createElement("a");
a.href = "/importTemplates/orderImport.xlsx"; a.href = href;
a.download = filename ?? "orderTemplate.xlsx"; a.download = filename ?? "orderTemplate.xlsx";
document.body.appendChild(a); document.body.appendChild(a);
a.click(); a.click();
@ -136,7 +182,6 @@ export default {
setTimeout(() => { setTimeout(() => {
this.$emit("destroy-dialog"); this.$emit("destroy-dialog");
// this.$emit("update:dialogVisible", false);
}, 200); }, 200);
}, },
}, },

View File

@ -48,6 +48,7 @@
<DialogUpload <DialogUpload
ref="uploadDialog" ref="uploadDialog"
v-if="uploadDialogVisible" v-if="uploadDialogVisible"
title="导入订单"
@destroy-dialog="uploadDialogVisible = false" @destroy-dialog="uploadDialogVisible = false"
@refresh-list="handleRefreshList" /> @refresh-list="handleRefreshList" />
</section> </section>
@ -58,7 +59,7 @@ import BaseListTable from "./BaseListTable.vue";
import BaseSearchForm from "./BaseSearchForm.vue"; import BaseSearchForm from "./BaseSearchForm.vue";
import DialogJustForm from "./DialogJustForm.vue"; import DialogJustForm from "./DialogJustForm.vue";
import DialogWithMenu from "./DialogWithMenu.vue"; import DialogWithMenu from "./DialogWithMenu.vue";
import DialogUpload from "./DialogUpload.vue"; import DialogUpload from "@/components/DialogUpload.vue";
import moment from "moment"; import moment from "moment";
// const dictList = JSON.parse(localStorage.getItem("dictList")); // const dictList = JSON.parse(localStorage.getItem("dictList"));

View File

@ -340,7 +340,7 @@ export default function () {
options: [], options: [],
optionLabel: "code", optionLabel: "code",
rules: { required: true, message: "必填项不能为空", trigger: "blur" }, rules: { required: true, message: "必填项不能为空", trigger: "blur" },
fetchData: () => this.$http.get("/pms/equipment/page", { params: { limit: 999, page: 1, name: "" } }), fetchData: () => this.$http.get("/pms/equipment/search", { params: { equipmentTypeCode: 'Press' } }),
elparams: { placeholder: "请选择压机号", filterable: true }, elparams: { placeholder: "请选择压机号", filterable: true },
}, },
], ],
@ -389,7 +389,7 @@ export default function () {
options: [], options: [],
optionLabel: "code", optionLabel: "code",
rules: { required: true, message: "必填项不能为空", trigger: "blur" }, rules: { required: true, message: "必填项不能为空", trigger: "blur" },
fetchData: () => this.$http.get("/pms/equipment/page", { params: { limit: 999, page: 1, name: "" } }), fetchData: () => this.$http.get("/pms/equipment/search", { params: { equipmentTypeCode: 'Mix' } }),
elparams: { placeholder: "请选择混料机号", filterable: true }, elparams: { placeholder: "请选择混料机号", filterable: true },
}, },
{ {
@ -398,7 +398,7 @@ export default function () {
prop: "kiln", prop: "kiln",
options: [], options: [],
optionLabel: "code", optionLabel: "code",
fetchData: () => this.$http.get("/pms/equipment/page", { params: { limit: 999, page: 1, name: "" } }), fetchData: () => this.$http.get("/pms/equipment/search", { params: { equipmentTypeCode: 'Kiln' } }),
elparams: { placeholder: "请选择隧道窑号", filterable: true }, elparams: { placeholder: "请选择隧道窑号", filterable: true },
}, },
{ {