|
@@ -1,32 +1,30 @@
|
|
|
<template>
|
|
|
- <el-dialog
|
|
|
- center
|
|
|
- width="1024px"
|
|
|
- title="导入采销订单补录"
|
|
|
- :visible="innerVisible"
|
|
|
- :close-on-click-modal="false"
|
|
|
- @close="innerVisible = false; tableData = []"
|
|
|
- >
|
|
|
+ <el-dialog center width="1024px" title="导入采销订单补录" :visible="innerVisible" :close-on-click-modal="false"
|
|
|
+ @close="innerVisible = false; tableData = []">
|
|
|
<!-- <div style="margin-bottom:20px;display:flex;align-items:center">
|
|
|
<span style="color:red">*</span>
|
|
|
<p style="width:80px">项目经理:</p>
|
|
|
|
|
|
</div> -->
|
|
|
|
|
|
- <div v-if="tableData && tableData.length > 0" class="tr" style="padding: 10px 0 0 0">
|
|
|
+ <div v-if="tableData && tableData.length > 0" style="width:100%;display: flex;align-items: center;">
|
|
|
|
|
|
- <el-form>
|
|
|
- <project-manager
|
|
|
- size="mini"
|
|
|
- :isDetail="true"
|
|
|
- :value="ruleForm.manager"
|
|
|
- @searchChange="managerChange"
|
|
|
- />
|
|
|
- </el-form-item>
|
|
|
- </el-form>
|
|
|
+ <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="80px" style="width:100%">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="10">
|
|
|
+ <el-form-item label="项目经理" prop="managerid">
|
|
|
+ <project-manager size="mini" :isDetail="true" :value="ruleForm.managerid" @searchChange="managerChange" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
|
|
|
- <el-button :size="'mini'" @click="() => tableData = []">取消</el-button>
|
|
|
- <el-button type="primary" :size="'mini'" :loading="loading" @click="onSubmit">提交</el-button>
|
|
|
+ <el-col :span="14">
|
|
|
+ <el-form-item class="fr">
|
|
|
+ <el-button :size="'mini'" @click="() => tableData = []">取消</el-button>
|
|
|
+ <el-button type="primary" :size="'mini'" :loading="loading" @click="onSubmit">提交</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
</div>
|
|
|
|
|
|
<div v-else>
|
|
@@ -65,7 +63,17 @@ export default {
|
|
|
loading: false,
|
|
|
tableData: [],
|
|
|
ruleForm: {
|
|
|
- manager: ""
|
|
|
+ manager: "",
|
|
|
+ managerid: []
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ managerid: [
|
|
|
+ {
|
|
|
+ type: 'array',
|
|
|
+ required: true,
|
|
|
+ message: '请选择项目经理'
|
|
|
+ }
|
|
|
+ ]
|
|
|
},
|
|
|
table: {
|
|
|
stripe: true,
|
|
@@ -86,8 +94,10 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
managerChange(e) {
|
|
|
- const { id } = e;
|
|
|
- this.ruleForm.manager = id ? [id] : [];
|
|
|
+ const { id, label } = e;
|
|
|
+ this.ruleForm.managerid = id ? [id] : [];
|
|
|
+ this.ruleForm.manager = label
|
|
|
+ this.$refs.ruleForm.validateFields("managerid")
|
|
|
},
|
|
|
validateTableHeader(header, importHeader) {
|
|
|
let isHeaderOk = true;
|
|
@@ -391,34 +401,47 @@ export default {
|
|
|
this.validateFields(this.tableData);
|
|
|
},
|
|
|
async onSubmit() {
|
|
|
- if (!this.validateFields(this.tableData)) return;
|
|
|
+ try {
|
|
|
+ await this.$refs.ruleForm.validate()
|
|
|
+ if (!this.validateFields(this.tableData)) return;
|
|
|
+ const list = this.tableData.map(tableItem =>
|
|
|
+ requsetFields.reduce(
|
|
|
+ (prev, currentKey) => ({
|
|
|
+ ...prev,
|
|
|
+ workCode: "",
|
|
|
+ [currentKey]: tableItem[currentKey]
|
|
|
+ }),
|
|
|
+ {}
|
|
|
+ )
|
|
|
+ );
|
|
|
|
|
|
- const list = this.tableData.map(tableItem =>
|
|
|
- requsetFields.reduce(
|
|
|
- (prev, currentKey) => ({
|
|
|
- ...prev,
|
|
|
- workCode: "",
|
|
|
- [currentKey]: tableItem[currentKey]
|
|
|
- }),
|
|
|
- {}
|
|
|
- )
|
|
|
- );
|
|
|
+ this.loading = true;
|
|
|
+
|
|
|
+ const result = await asyncRequest.importOrder({
|
|
|
+ list:list.map((item) => ({
|
|
|
+ ...item,
|
|
|
+ ...this.ruleForm,
|
|
|
+ managerid:Array.isArray(this.ruleForm.managerid) ? this.ruleForm.managerid[0] : this.ruleForm.managerid
|
|
|
+ })),
|
|
|
+ ...this.ruleForm,
|
|
|
+ managerid:Array.isArray(this.ruleForm.managerid) ? this.ruleForm.managerid[0] : this.ruleForm.managerid
|
|
|
+ });
|
|
|
|
|
|
- this.loading = true;
|
|
|
- const result = await asyncRequest.importOrder({
|
|
|
- list
|
|
|
- });
|
|
|
- this.loading = false;
|
|
|
+ this.loading = false;
|
|
|
|
|
|
- switch (String(result.code)) {
|
|
|
- case "0":
|
|
|
- this.$message.success("导入成功");
|
|
|
- this.innerVisible = false;
|
|
|
- this.$emit("refresh");
|
|
|
- break;
|
|
|
- default:
|
|
|
- this.$message.warning(result.message);
|
|
|
- break;
|
|
|
+ switch (String(result.code)) {
|
|
|
+ case "0":
|
|
|
+ this.$message.success("导入成功");
|
|
|
+ this.innerVisible = false;
|
|
|
+ this.$emit("refresh");
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ this.$message.warning(result.message);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e)
|
|
|
}
|
|
|
}
|
|
|
}
|