Kaynağa Gözat

数据指标:指标规则计算去除模型名称

Xiao_123 3 hafta önce
ebeveyn
işleme
d77136a9e2

+ 68 - 4
src/views/dataGovernance/dataIndicator/components/edit.vue

@@ -32,6 +32,7 @@
                 @input="updateContent"
               >
               </div>
+              <v-btn class="ml-3 contenteditable-box-btn1" color="primary" @click="handleRuleValidate" :loading="ruleValidateLoading">规则效验</v-btn>
               <v-btn class="contenteditable-box-btn" color="primary" @click="handleCodeGenerate" :loading="codeLoading">代码生成</v-btn>
               <div class="labelTxt" :class="{'active': indicator}">指标计算规则</div>
             </div>
@@ -97,11 +98,47 @@
 
       </div>
     </v-overlay>
+
+    <!-- 指标规则效验结果 -->
+    <v-navigation-drawer
+      v-model="ruleValidateDrawer"
+      absolute
+      temporary
+      right
+      width="50%"
+      style="z-index: var(--zIndex-drawers);"
+    >
+      <div class="pa-3" style="color: black;">规则效验结果</div>
+      <v-divider></v-divider>
+      <m-table
+        class="px-3 mt-2"
+        :headers="[
+          { text: '变量名', value: 'variable' },
+          { text: '匹配名称', value: 'name_zh' }
+        ]"
+        :loading="false"
+        :items="ruleValidateItems"
+        :disable-sort="true"
+        :show-select="false"
+        :is-tools="false"
+      >
+        <template #name_zh="{ item }">
+          <v-tooltip v-if="item.findit === 1" left>
+            <template v-slot:activator="{ on, attrs }">
+              <span v-bind="attrs" v-on="on" class="defaultLink">{{ item.name_zh }}</span>
+            </template>
+            <span>{{ item.name_zh }}</span>
+          </v-tooltip>
+          <span v-else>{{ item.name_zh }}</span>
+        </template>
+      </m-table>
+    </v-navigation-drawer>
   </div>
 </template>
 
 <script>
 import MCard from '@/components/MCard'
+import MTable from '@/components/List/table.vue'
 import DataList from './dataList'
 import IndicatorList from './indicatorList'
 import EditBase from './editBase'
@@ -112,7 +149,8 @@ export default {
     MCard,
     EditBase,
     DataList,
-    IndicatorList
+    IndicatorList,
+    MTable
   },
   props: {
     itemData: {
@@ -128,6 +166,8 @@ export default {
       panels: [],
       show: false,
       codeLoading: false,
+      ruleValidateLoading: false,
+      ruleValidateDrawer: false,
       indicator: '',
       readonly: true,
       sendBtn: [
@@ -142,7 +182,8 @@ export default {
       ],
       pythonCode: '',
       isEditRules: false,
-      selected: []
+      selected: [],
+      ruleValidateItems: []
     }
   },
   mounted () {
@@ -193,7 +234,7 @@ export default {
         { label: 'data-belong', value: belong.id },
         { label: 'contenteditable', value: 'false' }
       ]
-      this.insertCode(`${node.name_zh}(${belong.name_zh})`, attribute)
+      this.insertCode(`${node.name_zh}`, attribute)
       this.updateContent()
     },
     handleChangeIndicator (item) {
@@ -201,7 +242,7 @@ export default {
         { label: 'data-id', value: item.id },
         { label: 'contenteditable', value: 'false' }
       ]
-      this.insertCode(`${item.name_zh}(指标)`, attribute)
+      this.insertCode(`${item.name_zh}`, attribute)
       this.updateContent()
     },
     htmlStringToNode (htmlString) {
@@ -209,6 +250,24 @@ export default {
       const doc = parser.parseFromString(htmlString, 'text/html')
       return doc.body
     },
+    // 指标计算规则效验
+    async handleRuleValidate () {
+      if (!this.indicator) {
+        this.$snackbar.error('请输入指标计算规则')
+        return
+      }
+      this.ruleValidateLoading = true
+      const oHtml = this.htmlStringToNode(this.indicator)
+      try {
+        const { data } = await api.dataIndicatorRuleValidate({ formula: oHtml.innerText })
+        this.ruleValidateItems = data || []
+        this.ruleValidateDrawer = true
+      } catch (error) {
+        this.$snackbar.error(error)
+      } finally {
+        this.ruleValidateLoading = false
+      }
+    },
     // 生成代码
     async handleCodeGenerate () {
       if (!this.indicator) {
@@ -375,6 +434,11 @@ export default {
     right: 10px;
     bottom: 10px;
   }
+  &-btn1 {
+    position: absolute;
+    right: 116px;
+    bottom: 10px;
+  }
   .contenteditable {
     border: 1px solid #999;
     padding: 12px;