Browse Source

批量选择逻辑,中英文翻译

cxmo 9 months ago
parent
commit
83010fbbec

+ 1 - 0
src/lang/modules/DataSources/En.js

@@ -115,6 +115,7 @@ export default {
     add_loading_msg:'The loading time is approximately five minutes; closing the popup will not affect the loading process',
     add_max_msg: 'The number of additions has reached the upper limit (upper limit 150)!',
     ph_classify_name: 'Please select a category name',
+    batch_add_max_msg:'The number of indicators added in batch does not exceed 30',
   },
 
   /* un数据页面 */

+ 1 - 0
src/lang/modules/DataSources/Zh.js

@@ -114,6 +114,7 @@ export default {
     add_loading_msg:'加载时间大概五分钟,关闭弹窗不影响加载',
     add_max_msg: '添加数量已达上限(上限150)!',
     ph_classify_name: '请选择分类名称',
+    batch_add_max_msg:'批量添加指标数量不超过30个',
   },
 
   /* un数据页面 */

+ 130 - 11
src/views/dataEntry_manage/thirdBase/components/addIndicsDia.vue

@@ -13,39 +13,158 @@
         v-dialogDrag
     >
         <div class="dialog-container">
-            <el-form>
-                <el-form-item label="指标名称"></el-form-item>
-                <el-form-item label="指标目录"></el-form-item>
-                <el-form-item label="频度"></el-form-item>
-                <el-form-item label="单位"></el-form-item>
+            <el-form
+                ref="targetForm"
+                label-position="right"
+                label-width="120px"
+                hide-required-asterisk
+                :model="formData"
+                :rules="formRules"
+            >
+                <el-form-item :label="$t('Table.edb_name')" prop="edb_name">
+                    <el-input
+                    v-model="formData.edb_name"
+                    style="width: 80%"
+                    :placeholder="$t('Table.edb_name')"></el-input>
+                </el-form-item>
+                <el-form-item :label="$t('Edb.Detail.select_catalogue')" prop="menu">
+                    <el-cascader
+                    v-model="formData.menu"
+                    :options="options"
+                    :props="levelProps"
+                    style="width: 80%"
+                    clearable
+                    :placeholder="$t('CustomAnalysisPage.select_appropriate_category')"/>
+                </el-form-item>
+                <el-form-item :label="$t('Table.frequency')" prop="frequency">
+                    <el-select 
+                    v-model="formData.frequency" 
+                    :placeholder="$t('CustomAnalysisPage.select_frequency')" 
+                    style="width:80%"
+                    clearable>
+                        <el-option
+                            v-for="item in frequencyArr"
+                            :key="item.value"
+                            :label="item.label"
+                            :value="item.value">
+                        </el-option>
+                    </el-select>
+                </el-form-item>
+                <el-form-item :label="$t('Table.unit')">
+                    <selectUnit 
+                            v-model="formData.unit" 
+                            style="width: 80%"
+                        />
+                </el-form-item>
             </el-form>
         </div>
         <div class="footer-container" slot="footer">
-            <el-button type="primary" @click="handleAddEdb">保存</el-button>
-            <el-button type="primary" plain @click="$emit('close')">取消</el-button>
+            <el-button type="primary" @click="handleAddEdb">{{ $t('Dialog.confirm_save_btn') }}</el-button>
+            <el-button type="primary" plain @click="$emit('close')">{{ $t('Dialog.cancel_btn') }}</el-button>
         </div>
     </el-dialog>
 </template>
 
 <script>
+import { dataBaseInterface } from '@/api/api.js';
+import selectUnit from '@/components/selectUnit.vue';
+import { frequencySelectList } from '@/utils/defaultOptions';
 export default {
+    components: { selectUnit },
     props:{
         isOpenDialog:{
             type:Boolean,
             default:false
+        },
+        edbData:{
+            type:Object,
+            defalut:{}
+        }
+    },
+    computed:{
+        formRules(){
+            return {
+                edb_name:[
+                    { required: true, message: /* '指标名称不能为空' */this.$t('Edb.Valids.name_msg'), trigger: 'blur' },
+                ],
+                menu:[
+                    { required: true, message: /* '所属目录不能为空' */this.$t('Edb.Valids.menu_msg'), trigger: 'blur' },
+                ],
+                frequency:[
+                    { required: true, message: /* '频率不能为空' */this.$t('Edb.Valids.fre_msg'), trigger: 'blur' },
+                ],
+                unit:[
+                    { required: true, message: /* '单位不能为空' */this.$t('Edb.Valids.unit_msg'), trigger: 'blur' },
+                ],
+            }
+        }
+    },
+    watch:{
+        isOpenDialog(newval){
+            if(newval){
+                this.initDia()
+            }
         }
     },
     data() {
         return {
-
+            formData:{
+                code:'',
+                edb_name:'',
+                menu:'',
+                frequency:'',
+                unit:'',
+            },
+            options:[],
+            levelProps: {
+                label: 'ClassifyName',
+                value: 'ClassifyId',
+                children: 'Children',
+                emitPath: false,
+                checkStrictly: true
+            },
+            frequencyArr:frequencySelectList(),
         };
     },
     methods: {
-        handleAddEdb(){}
+        filterNodes(arr) {
+            arr.length &&
+                arr.forEach((item) => {
+                    item.Children.length && this.filterNodes(item.Children);
+                    if (!item.Children.length) {
+                        delete item.Children;
+                    }
+                });
+        },
+        // 获取指标分类列表
+        async getClassifyOpt(){
+            const res=await dataBaseInterface.menuListV3()
+            if (res.Ret !== 200) return
+            this.filterNodes(res.Data.AllNodes||[]);
+            this.options = res.Data.AllNodes || [];
+        },
+        handleAddEdb(){
+            //校验表单
+        },
+        initDia(){
+            this.getClassifyOpt()
+            const {IndexName,UnitName,FrequencyName,IndexCode} = this.edbData
+            this.formData = {
+                code:IndexCode,
+                edb_name:IndexName,
+                menu:'',
+                frequency:FrequencyName,
+                unit:UnitName
+            }
+        }
     },
 };
 </script>
 
-<style scoped lang="scss">
-
+<style lang="scss">
+.add-indics-dia{
+    .el-cascader .el-input {
+        width: 100%;
+    }
+}
 </style>

+ 87 - 13
src/views/dataEntry_manage/thirdBase/components/batchAddIndicsDia.vue

@@ -34,20 +34,30 @@
             <div class="select-table">
                 <el-table :data="edbList" border>
                     <el-table-column  type="selection" width="55" align="center"></el-table-column>
-                    <el-table-column label="指标ID" align="center" width="120" prop="edbId"></el-table-column>
-                    <el-table-column label="指标名称" align="center">
+                    <el-table-column :label="$t('Edb.Detail.e_id')" align="center" width="120" prop="edbId"></el-table-column>
+                    <el-table-column :label="$t('Table.edb_name')" align="center">
                         <template slot-scope="{row}">
-                            <el-input v-model="row.edbName"></el-input>
+                            <el-input v-model="row.edbName" :placeholder="$t('Table.edb_name')"></el-input>
                         </template>
                     </el-table-column>
                     <el-table-column :label="$t('Edb.Detail.e_fre')" align="center" width="140">
                         <template slot-scope="{row}">
-                            <el-select v-model="row.frequency"></el-select>
+                            <el-select 
+                                v-model="row.frequency" 
+                                :placeholder="$t('CustomAnalysisPage.select_frequency')" 
+                                clearable>
+                                <el-option
+                                    v-for="item in frequencyArr"
+                                    :key="item.value"
+                                    :label="item.label"
+                                    :value="item.value">
+                                </el-option>
+                            </el-select>
                         </template>
                     </el-table-column>
                     <el-table-column :label="$t('Edb.Detail.e_unit')" align="center" width="140">
                         <template slot-scope="{row}">
-                            <el-input v-model="row.unit"></el-input>
+                            <selectUnit v-model="row.unit" />
                         </template>
                     </el-table-column>
                     <!-- 操作 -->
@@ -58,6 +68,7 @@
                                 <el-radio :label="1"><!-- 分目录 -->{{$t('EtaBasePage.subdirectory_radio')}}</el-radio>
                                 <el-radio :label="2"><!-- 同目录 -->{{$t('EtaBasePage.directory_radio')}}</el-radio>
                             </el-radio-group>
+                            <el-cascader v-if="classifyType===2"></el-cascader>
                         </template>
                         <template slot-scope="{row,$index}">
                             <el-cascader 
@@ -70,16 +81,20 @@
                                     checkStrictly: true,
                                     emitPath:false
                                 }"
-                                :disabled="classifyType===1&&$index>0"
+                                style="width:100%;"
+                                :disabled="classifyType===2&&$index>0"
                             ></el-cascader>
                         </template>
                     </el-table-column>
+                    <div class="no-data" slot="empty">
+                        <tableNoData :text="$t('Table.prompt_slogan')"/>
+                    </div>
                 </el-table>
             </div>
         </div>
         <div class="footer-container" slot="footer">
-            <el-button type="primary" plain @click="$emit('close')">取消</el-button>
-            <el-button type="primary" @click="handleAddEdb">加入指标库</el-button>
+            <el-button type="primary" plain @click="$emit('close')">{{ $t('Dialog.cancel_btn') }}</el-button>
+            <el-button type="primary" @click="handleAddEdb">{{ $t('ManualEdbListPage.add_tobase_btn') }}</el-button>
         </div>
     </el-dialog>
 </template>
@@ -87,7 +102,10 @@
 <script>
 import { steelInterface } from "@/api/modules/thirdBaseApi";
 import { dataBaseInterface } from '@/api/api.js';
+import selectUnit from '@/components/selectUnit.vue';
+import { frequencySelectList } from '@/utils/defaultOptions';
 export default {
+    components:{ selectUnit },
     props:{
         isOpenDialog:{
             type:Boolean,
@@ -107,14 +125,15 @@ export default {
             searchName:'',
             searchClassify:'',
             classifyType:1,//1分目录 2同目录
+            frequencyArr:frequencySelectList(),
             edbList:[
                 /* {
                     edbId:'123456',
                     edbName:'指标名称指标名称',
                     frequency:'日度',
                     unit:'吨',
-                    classify:''
-                } */
+                    classify:'',
+                }, */
             ],
             edbClassifyList:[],//指标库目录
             selectEdbList:[]
@@ -159,16 +178,67 @@ export default {
                     edbName:'指标名称指标名称',
                     frequency:'日度',
                     unit:'吨',
-                    classify:''
-                }]
+                    classify:'',
+                },
+                {
+                    edbId:'654321',
+                    edbName:'22222',
+                    frequency:'日度',
+                    unit:'吨',
+                    classify:'',
+                },
+                {
+                    edbId:'77777',
+                    edbName:'11111',
+                    frequency:'日度',
+                    unit:'吨',
+                    classify:'',
+                },
+                {
+                    edbId:'888888',
+                    edbName:'指标名称指标名称',
+                    frequency:'日度',
+                    unit:'吨',
+                    classify:'',
+                },]
         },
         handleClassifyTypeChange(){},
         handleAddEdb(){
             //校验所选指标
+            if(!this.selectEdbList.length){
+                return this.$message.warning(this.$t('InputHolderAll.input_select_edb'))
+            }
+            if(this.selectEdbList.length>30){
+                return this.$message.warning(this.$t('SteelChemicalPage.batch_add_max_msg'))
+            }
+            //校验所选指标信息是否完整
+            if(this.classifyType===2&&!this.selectClassify){
+                /* return this.$message.warning(this.) */
+            }
+            
+            let messageList = [] //有问题的列表
+            this.selectEdbList.forEach((item)=>{
+                let checkResult = checkEdbData(item)
+                if(checkEdbData(item)){
+                    messageList.push(item)
+                }
+            })
+            //message轻提示 同时标出不完整的行
+            if(messageList.length){
+                
+                return
+            }
+            
+            //调用接口check是否有指标重名
+            //没有则batchAddEdb
+
+        },
+        checkEdbData(edbData){
+            return !(!edbData.edbName||!edbData.frequency||!edbData.unit||this.classifyType===1?(!edbData.classify):false)
         },
         batchAddEdb(){
             //获取添加结果
-            //有已存在的指标 弹窗提示
+            //有已存在的指标 emit将结果返回
             
         }
     },
@@ -190,6 +260,10 @@ export default {
         .select-box{
             margin-bottom:20px;
         }
+        .select-table{
+            max-height:600px;
+            overflow-y:auto;
+        }
     }
 }
 </style>

+ 2 - 0
src/views/dataEntry_manage/thirdBase/steelChemicalbase.vue

@@ -268,6 +268,8 @@
         :edbData="currentIndicData"
         @close="isAddIndicsDiaShow=false"
     />
+    <!-- 批量/单个加入回调弹窗 -->
+    <!-- <el-dialog></el-dialog>-->
   </div>
 
 </template>