hbchen 1 anno fa
parent
commit
c1fcb3e42a

+ 168 - 0
src/views/dataEntry_manage/thirdBase/components/batchAddEdbDia.vue

@@ -0,0 +1,168 @@
+<template>
+  <el-dialog
+    :visible.sync="isOpenDialog"
+    :close-on-click-modal="false"
+    :modal-append-to-body="false"
+    top="5vh"
+    title="添加指标"
+    @close="cancelHandle"
+    custom-class="dialog"
+    center
+    width="800px"
+  >
+    <div
+    v-loading="isAddLoading"
+    element-loading-text="加载时间大概五分钟,关闭弹窗不影响加载"
+    element-loading-spinner="el-icon-loading">
+      <div class="dialog-main">
+        <el-form :model="edbForm" ref="edbFormDataListRef" >
+          <el-table :data="edbForm.edbDataList" max-height="500px">
+            <el-table-column label="指标ID">
+              <template slot-scope="{row,$index}">
+                <el-form-item :prop="`edbDataList.${$index}.edbId`" 
+                :rules="[{required:true,message:'指标ID不能为空',trigger:'blur'},
+                          {validator:checkAge,trigger:'blur'}]">
+                  <el-input v-model.trim="row.edbId" placeholder="请输入指标ID"></el-input>
+                </el-form-item>
+              </template>
+            </el-table-column>
+            <el-table-column label="所属分类">
+              <template slot-scope="{row,$index}">
+                <el-form-item :prop="`edbDataList.${$index}.classify`" 
+                :rules="{required:true,message:'所属分类不能为空',trigger:'blur'}">
+                  <el-cascader
+                    class="classify-cascader"
+                    v-model="row.classify"
+                    :options="classifyOptions"
+                    :key="$index"
+                    :props="{
+                      label: 'ClassifyName',
+                      value: 'BaseFromMysteelChemicalClassifyId',
+                      children: 'Children',
+                      emitPath: false,
+                    }"
+                    placeholder="请选择分类"
+                  />
+                </el-form-item>
+              </template>
+            </el-table-column>
+            <el-table-column label="操作" width="80px">
+              <template slot-scope="{row,$index}">
+                <span v-if="edbForm.edbDataList.length>1" @click="delEdbItem($index)">删除</span>
+                <span v-if="$index==(edbForm.edbDataList.length-1)" @click="addEdbItem(row,`edbDataList.${$index}`)">添加</span>
+              </template>
+            </el-table-column>
+          </el-table>
+        </el-form>
+      </div>
+      <div class="dia-bot">
+        <el-button type="primary" style="margin-right: 20px" @click="saveHandle"
+          >保存</el-button
+        >
+        <el-button type="primary" plain @click="cancelHandle">取消</el-button>
+      </div>
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+  export default {
+    props: {
+      isOpenDialog: {
+        type: Boolean,
+      },
+      classifyList: {
+        type: Array,
+      },
+    },
+    watch: {
+      isOpenDialog(newval) {
+        if (newval) {
+          let classifyArr = _.cloneDeep(this.classifyList);
+          this.filterNodes(classifyArr);
+          this.classifyOptions = classifyArr;
+        }
+      },
+    },
+    data(){
+      this.checkAge=(rule, value, callback) => {
+        // 不能输入中文和空格
+        let reg = /[\u4e00-\u9fa5]+|\s+/
+        if(reg.test(value)){
+          return callback(new Error('不能输入中文和空格'))
+        }
+      }
+      return{
+        isAddLoading: false,
+        classifyOptions:[],
+        edbForm:{edbDataList:[{edbId:'',classify:''}]}
+      }
+    },
+    methods:{
+      saveHandle(){
+        this.$refs.edbFormDataListRef.validate((valid)=>{
+          if(valid){
+            console.log('验证通过');
+          }else{
+            this.$message.error("验证不通过,请检查")
+          }
+        })
+      },
+      /* 取消 */
+      cancelHandle() {
+        this.isAddLoading = false;
+        this.edbForm={edbDataList:[{edbId:'',classify:''}]}
+        this.$refs.edbFormDataListRef.resetFields();
+        this.$emit("update:isOpenDialog", false);
+      },
+      // 递归改变第三级目录结构
+      filterNodes(arr) {
+        arr.length &&
+          arr.forEach((item) => {
+            item.Children &&
+              item.Children.length &&
+              this.filterNodes(item.Children);
+            if (item.Level === 2) {
+              delete item.Children;
+            }
+          });
+      },
+      addEdbItem(row,prop){
+        let propArray=Object.keys(row).map(key=> prop+'.'+key )
+        console.log(row,'row',propArray,'propArray');
+        let errorFlag=false
+        this.$refs.edbFormDataListRef.validateField(propArray,(error)=>{
+          if(error){
+            errorFlag=true
+          }
+        })
+        if(errorFlag) return 
+        if(this.edbForm.edbDataList.length>=100){
+          this,$message.warning('添加数量已达上限(上限100)!')
+          return 
+        }
+        this.edbForm.edbDataList.push({edbId:'',classify:row.classify})
+      },
+      delEdbItem(index){
+        this.edbForm.edbDataList.splice(index,1)
+      }
+    }
+  }
+</script>
+
+<style lang="scss" scoped>
+.dialog-main {
+  padding-left: 50px;
+}
+
+.dia-bot {
+  margin: 52px 0 30px;
+  display: flex;
+  justify-content: center;
+}
+</style>
+<style lang="scss">
+// .dialog-main .classify-cascader .el-input {
+//   width: 100%;
+// }
+</style>

+ 15 - 15
src/views/dataEntry_manage/thirdBase/components/targetDialog.vue

@@ -48,7 +48,7 @@
               :disabled="edbForm.edb_id"
             />
           </el-form-item>
-          <el-form-item>
+          <!-- <el-form-item>
             <template slot="label">
               <span>
                 更新频度
@@ -96,7 +96,7 @@
                 </el-option>
               </el-select>
             </div>
-          </el-form-item>
+          </el-form-item> -->
         </el-form>
       </div>
       <div class="dia-bot">
@@ -144,19 +144,19 @@ export default {
     },
   },
   computed: {
-    timeArr() {
-      //30间隔的时间数组
-      const timeArrays = new Array(48).fill("").map((item, index) => {
-        let time_val = index * 30;
-        let hour = Math.floor(time_val / 60);
-        let min = time_val % 60;
-        let time =
-          (hour < 10 ? "0" + hour : hour) + ":" + (min === 0 ? "00" : min);
+    // timeArr() {
+    //   //30间隔的时间数组
+    //   const timeArrays = new Array(48).fill("").map((item, index) => {
+    //     let time_val = index * 30;
+    //     let hour = Math.floor(time_val / 60);
+    //     let min = time_val % 60;
+    //     let time =
+    //       (hour < 10 ? "0" + hour : hour) + ":" + (min === 0 ? "00" : min);
 
-        return time;
-      });
-      return timeArrays;
-    },
+    //     return time;
+    //   });
+    //   return timeArrays;
+    // },
   },
   data() {
     return {
@@ -177,7 +177,7 @@ export default {
           { required: true, message: "指标ID不能为空" },
         ],
       },
-      frequencyArr: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
+      // frequencyArr: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
     };
   },
   methods: {

+ 16 - 6
src/views/dataEntry_manage/thirdBase/steelChemicalbase.vue

@@ -4,7 +4,7 @@
       <div class="left-top">
         <div>
           <el-button v-permission="permissionBtn.dataSourcePermission.mysteelData_add"
-          type="primary" size="medium" @click="addTargetHandle"
+          type="primary" size="medium" @click="addTargetBatch"
             >新增指标</el-button
           >
           <el-button
@@ -231,6 +231,10 @@
       :edbForm="edbForm"
       @successCallback="addSuccessCallback"
     />
+    <!-- 批量添加指标弹窗 -->
+    <batch-add-edb-dia :isOpenDialog.sync="batchAddDiaShow" :classifyList="classifyList">
+
+    </batch-add-edb-dia>
   </div>
 </template>
 
@@ -239,11 +243,12 @@ import lzTable from "@/components/lzTable.vue";
 import { steelInterface } from "@/api/modules/thirdBaseApi";
 import mDialog from "@/components/mDialog.vue";
 import targetDialog from "./components/targetDialog.vue";
+import batchAddEdbDia from "./components/batchAddEdbDia.vue";
 import leftMixin from "./mixins/leftMixin.js";
 export default {
   name: "",
   mixins: [leftMixin],
-  components: { lzTable, mDialog, targetDialog },
+  components: { lzTable, mDialog, targetDialog,batchAddEdbDia },
   data() {
     return {
       dataloading: false,
@@ -284,6 +289,8 @@ export default {
 
       addTargetDialog: false, //添加指标弹窗
       edbForm: {},
+      //批量添加指标弹窗
+      batchAddDiaShow:false
     };
   },
   methods: {
@@ -600,12 +607,15 @@ export default {
       this.openClassifyDia = false;
     },
 
+    // /* 添加指标 */
+    // addTargetHandle() {
+    //   this.edbForm = {};
+    //   this.addTargetDialog = true;
+    // },
     /* 添加指标 */
-    addTargetHandle() {
-      this.edbForm = {};
-      this.addTargetDialog = true;
+    addTargetBatch() {
+      this.batchAddDiaShow = true;
     },
-
     /* 指标刷新 */
     edbRefreshHandle() {
       this.isRefresh = true;