wangrong
2026-08-30 4c949c0dc9bcae785c281c9d8125295f09810b15
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<script lang="ts" setup>
import { computed, reactive, ref } from 'vue'
import { deepCopy } from '@/utils/utils'
import { useEmitt } from '@/hooks/web/useEmitt'
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
import { storeToRefs } from 'pinia'
import { ElMessage } from 'element-plus-secondary'
const loading = ref(false)
const subject = ref()
const subjectDialogShow = ref(false)
const dvMainStore = dvMainStoreWithOut()
const { canvasViewInfo } = storeToRefs(dvMainStore)
 
const state = reactive({
  viewId: null
})
const curDataSetParamsInfo = ref([])
 
const resetForm = () => {
  subject.value.clearValidate()
  subjectDialogShow.value = false
}
const subjectForm = ref(null)
const rules = ref({})
 
const optInit = item => {
  if (item) {
    state.viewId = item.id
    const chartInfo = canvasViewInfo.value[state.viewId]
    curDataSetParamsInfo.value = deepCopy(chartInfo.calParams)
    subjectDialogShow.value = true
  }
}
 
const saveSubject = () => {
  if (disabledCheck.value) {
    ElMessage.error('请输入正确参数')
    return
  }
  canvasViewInfo.value[state.viewId]['calParams'] = curDataSetParamsInfo.value
  useEmitt().emitter.emit('calcData-' + state.viewId, canvasViewInfo.value[state.viewId])
  resetForm()
}
 
const disabledCheck = computed(() => {
  return (
    !curDataSetParamsInfo.value ||
    (curDataSetParamsInfo.value &&
      curDataSetParamsInfo.value.filter(item => item.value === null || item.value === undefined)
        .length > 0)
  )
})
 
const statesCheck = () => {
  return subjectDialogShow.value
}
 
const handleDialogClick = e => {
  e.preventDefault()
  e.stopPropagation()
}
 
defineExpose({
  optInit,
  statesCheck,
  resetForm
})
</script>
 
<template>
  <el-dialog
    v-loading="loading"
    title="计算参数输入"
    v-model="subjectDialogShow"
    width="400px"
    :before-close="resetForm"
    @click="handleDialogClick"
  >
    <el-form
      v-if="subjectDialogShow"
      label-position="top"
      ref="subject"
      :model="subjectForm"
      :rules="rules"
      @submit.prevent
    >
      <el-form-item
        v-for="paramsItem in curDataSetParamsInfo"
        :key="paramsItem"
        class="form-item"
        :prop="'value_' + paramsItem.name"
      >
        <template #label>
          <label class="m-label">
            计算字段[{{ paramsItem.name }}] <span style="color: red">*</span>
          </label>
        </template>
        <el-input-number
          style="width: 100%"
          v-model="paramsItem.value"
          placeholder="请输入一个数字"
          controls-position="right"
        />
      </el-form-item>
    </el-form>
    <template #footer>
      <el-button secondary @click="resetForm()">取消</el-button>
      <el-button type="primary" @click="saveSubject()">确认</el-button>
    </template>
  </el-dialog>
</template>
 
<style lang="less" scoped>
:deep(.ed-dialog__header) {
  text-align: left;
}
.m-label {
  color: #1f2329;
  font-size: 14px;
  font-style: normal;
  font-weight: 400;
  line-height: 14px;
  display: inline-block;
}
.form-item {
  margin-bottom: 16px;
  :deep(.ed-form-item__label) {
    line-height: 14px !important;
  }
 
  :deep(.ed-input__inner) {
    font-size: 14px !important;
  }
 
  :deep(.ed-form-item__error) {
    top: 88%;
  }
  .ed-input {
    --ed-input-height: 32px !important;
  }
 
  &:last-child {
    margin-bottom: 0;
  }
 
  :deep(.avatar-uploader-container) {
    margin-bottom: 0px;
  }
}
</style>