Просмотр исходного кода

fix:修改物料领料出库信息导入逻辑

liujiayin 3 лет назад
Родитель
Сommit
30277a4042

+ 98 - 25
src/business/platform/data/templaterender/components/import-columns-dialog.vue

@@ -1,28 +1,46 @@
 <template>
-  <el-dialog class="import-columns-dialog" :visible.sync="dialogTableVisible" append-to-body width="70%" title="导入数据"
-    @close="closeDialog" @open="openDialog">
+  <el-dialog class="import-columns-dialog"
+             :visible.sync="dialogTableVisible"
+             append-to-body
+             width="70%"
+             title="导入数据"
+             @close="closeDialog"
+             @open="openDialog">
     <!-- <span slot="title">
       <label style="font-size:18px;">导入数据</label>
       <i class="el-icon-warning" style="font-size:12px;margin-left:5px;color:#E6A23C;">数据库元数据的格式,否则针对key-vue存储的数据会有误!</i>
     </span> -->
-    <el-steps :active="active" finish-status="success" align-center class="steps">
+    <el-steps :active="active"
+              finish-status="success"
+              align-center
+              class="steps">
       <el-step title="上传Excel" />
       <el-step title="预览数据" />
       <el-step title="选择字段" />
       <el-step title="导入数据" />
     </el-steps>
     <el-row class="manual-operation">
-      <el-col v-if="active === 1 || active === 2" :span="24" class="buttonGround">
-        <el-button style="margin-top: 12px;" @click="before">上一步</el-button>
-        <el-button style="margin-top: 12px;" @click="after">下一步</el-button>
+      <el-col v-if="active === 1 || active === 2"
+              :span="24"
+              class="buttonGround">
+        <el-button style="margin-top: 12px;"
+                   @click="before">上一步</el-button>
+        <el-button style="margin-top: 12px;"
+                   @click="after">下一步</el-button>
       </el-col>
       <!-- 上传Excel -->
-      <el-col v-if="active === 0" :span="24" class="upload-the-excel">
+      <el-col v-if="active === 0"
+              :span="24"
+              class="upload-the-excel">
         <div class="upload-the-excel-detail">您可以便捷地将Excel中的数据导入到该表单中。</div>
-        <el-upload drag :before-upload="beforeUpload" action="https://www.bpmhome.cn/post" accept=".xls,.xlsx">
+        <el-upload drag
+                   :before-upload="beforeUpload"
+                   action="https://www.bpmhome.cn/post"
+                   accept=".xls,.xlsx">
           <i class="el-icon-upload" />
           <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
-          <div slot="tip" class="el-upload__tip">
+          <div slot="tip"
+               class="el-upload__tip">
             <i style="color:red">Excel文件请符合以下标准:</i>
             <dl>
               <li>仅支持xls或xlsx格式的文件</li>
@@ -35,8 +53,14 @@
         </el-upload>
       </el-col>
       <!-- 预览数据 -->
-      <el-col v-if="active === 1" :span="24" class="preview-the-data">
-        <el-table ref="table" v-bind="tableData" border :height="tableHeight - tableHeight / 9" style="width: 100%">
+      <el-col v-if="active === 1"
+              :span="24"
+              class="preview-the-data">
+        <el-table ref="table"
+                  v-bind="tableData"
+                  border
+                  :height="tableHeight - tableHeight / 9"
+                  style="width: 100%">
           <el-table-column>
             <template slot="header">
               <div class="cell">1</div>
@@ -45,35 +69,53 @@
               <div class="cell">{{ scope.$index + 2 }}</div>
             </template>
           </el-table-column>
-          <el-table-column v-for="(item, index) in tableData.columns" :key="index" :prop="item.prop"
-            :label="item.label" />
+          <el-table-column v-for="(item, index) in tableData.columns"
+                           :key="index"
+                           :prop="item.prop"
+                           :label="item.label" />
         </el-table>
         <div class="form-control">
-          以第 <el-input-number v-model="input" :min="1" />行作为表单各字段的名称
+          以第 <el-input-number v-model="input"
+                           :min="1" />行作为表单各字段的名称
         </div>
       </el-col>
       <!-- 选择字段 -->
-      <el-col v-if="active === 2" :span="24" class="select-fields">
-        <el-table ref="selectFieldsTable" border :height="tableHeight - tableHeight / 9" row-key="title"
-          :data="selectFieldsTableData" style="width: 100%">
+      <el-col v-if="active === 2"
+              :span="24"
+              class="select-fields">
+        <el-table ref="selectFieldsTable"
+                  border
+                  :height="tableHeight - tableHeight / 9"
+                  row-key="title"
+                  :data="selectFieldsTableData"
+                  style="width: 100%">
           <el-table-column>
             <template slot="header">
               <div class="cell">导入</div>
             </template>
             <template slot-scope="scope">
-              <el-checkbox :disabled="scope.row.disabled" :checked="scope.row.checked"
-                @change="handleChange(scope.$index, scope.row)" />
+              <el-checkbox :disabled="scope.row.disabled"
+                           :checked="scope.row.checked"
+                           @change="handleChange(scope.$index, scope.row)" />
             </template>
           </el-table-column>
-          <el-table-column prop="title" label="标题" width="180" />
-          <el-table-column prop="dataType" label="数据类型" />
+          <el-table-column prop="title"
+                           label="标题"
+                           width="180" />
+          <el-table-column prop="dataType"
+                           label="数据类型" />
         </el-table>
       </el-col>
       <!-- 导入数据 -->
-      <el-col v-if="active === 4" :span="24" class="import-data">
+      <el-col v-if="active === 4"
+              :span="24"
+              class="import-data">
         <div style="display: flex; margin-top: 20px; height: 100px;">
-          <div v-if="!show" class="transition-box importing" style="color:white;">导入中...</div>
-          <div v-if="show" class="transition-box imported">导入成功!只导入数据库元数据的格式,否则针对key-vue存储的数据会有误!</div>
+          <div v-if="!show"
+               class="transition-box importing"
+               style="color:white;">导入中...</div>
+          <div v-if="show"
+               class="transition-box imported">导入成功!只导入数据库元数据的格式,否则针对key-vue存储的数据会有误!</div>
         </div>
       </el-col>
     </el-row>
@@ -282,6 +324,7 @@ export default {
       }
       switch (formKey) {
         case 'lhwljbxx':
+          // 物料基本信息
           await curdPost('sql', gysmlSql).then(gysmlRes => {
             let gysmlDatas = gysmlRes.variables.data
             tableData.forEach(data => {
@@ -307,6 +350,7 @@ export default {
           })
           break;
         case 'lhkcglxq':
+          // 库存管理
           await curdPost('sql', gysmlSql).then(gysmlRes => {
             let gysmlDatas = gysmlRes.variables.data
             tableData.forEach(data => {
@@ -337,6 +381,36 @@ export default {
             })
           })
           break;
+        case 'llckwlxx':
+          // 领料物料信息
+          await curdPost('sql', gysmlSql).then(gysmlRes => {
+            let gysmlDatas = gysmlRes.variables.data
+            tableData.forEach(data => {
+              const obj = {}
+              for (var d in data) {
+                for (var f in fields) {
+                  if (d === fields[f]) {
+                    if (fields[f] == '供应商') {
+                      var gysID = gysmlDatas.filter((v) => {
+                        return trim(v.gong_ying_shang_m) == trim(data[d])
+                      }).length !== 0 ? gysmlDatas.filter((v) => {
+                        return trim(v.gong_ying_shang_m) == trim(data[d])
+                      })[0].id_ : ''
+                      obj[f] = gysID
+                    } else {
+                      obj[f] = trim(data[d])
+                    }
+                    // if (obj[f] == '技术验收') {
+                    //   obj['jiShuYanShou'] = '已技术验收'
+                    // }
+                  }
+                }
+              }
+              obj['biaoMing'] = 't_crkjlx'
+              saveData.push(obj)
+            })
+          })
+          break;
         default:
           tableData.forEach(data => {
             const obj = {}
@@ -391,7 +465,6 @@ export default {
     }
 
     .upload-the-excel {
-
       .el-upload-dragger,
       .el-upload {
         width: 100%;