选煤厂生产管理平台前端代码
Jay
2024-12-10 58a8ee8eebcf13656445486333d2d3f3e02c938f
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
<template>
  <Dialog width="60%" v-model="dialogVisible" :title="dialogTitle">
    <el-tabs>
      <el-tab-pane label="浮沉实验台账">
        <el-form :model="formData" :rules="formRules" ref="formRef"  v-loading="formLoading"
                 label-width="120px">
          <el-row>
            <el-col :span="12">
              <el-form-item prop="code" label="流水号">
                <el-input size="mini" disabled v-model="formData.code" placeholder="流水号"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item prop="ny" label="年月">
                <el-date-picker
                    style="width: 100%"
                    v-model="formData.ny"
                    type="month"
                    value-format="YYYY-MM"
                    placeholder="年月"/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item prop="syrq" label="实验日期">
                <el-date-picker
                    style="width: 100%"
                    v-model="formData.syrq"
                    type="date"
                    placeholder="实验日期"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item prop="mz" label="煤种">
                <el-select v-model="formData.mz" placeholder="煤种"
                           clearable >
                  <el-option
                    v-for="dict in getStrDictOptions(DICT_TYPE.YMMZ)"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item prop="fcfa" label="浮沉方案">
                <el-select v-model="formData.fcfa" placeholder="浮沉方案"
                           clearable >
                  <el-option
                    v-for="dict in getStrDictOptions(DICT_TYPE.FCFA)"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item prop="drl" label="调入量">
                <el-input-number v-model="formData.drl" placeholder="调入量" :min="0"/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item prop="bz" label="备注">
                <el-input size="mini" v-model="formData.bz" placeholder="备注" type="textarea"
                          :rows="2"/>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-tab-pane>
      <el-tab-pane label="浮沉数据">
        <el-form :inline="true">
          <el-form-item>
            <el-upload
                class="upload-demo"
                :action="action"
                :on-success="handleExcel"
                :multiple="false"
                :show-file-list="false"
                :on-change="changeFile"
                :file-list="fileList">
              <el-button size="mini" type="primary">点击上传</el-button>
            </el-upload>
          </el-form-item>
          <el-form-item>
            <el-button size="mini" type="success" @click="downloadExcel">下载模板</el-button>
          </el-form-item>
        </el-form>
        <el-form :model="formData" :rules="dataRule" ref="formDataDet"
                 label-width="120px">
          <el-table
              :data="formData.detList"
              border
              height="400"
              style="width: 100%;">
            <el-table-column prop="mdjName" label="密度级" header-align="center"
                             align="center"/>
            <el-table-column label="综合累计" header-align="center">
              <el-table-column prop="zhljcl" label="产率(%)" header-align="center" align="center">
                <template #default="scope">
                  <el-input-number v-model="scope.row.zhljcl"
                                   size="mini"
                                   placeholder="产率(%)"
                                   :precision="2"
                                   :controls="false"
                                   :min="0"
                                   :max="100" class="curves-det-input"/>
                </template>
              </el-table-column>
              <el-table-column prop="zhljhf" label="灰分(%)" header-align="center" align="center">
                <template #default="scope">
                  <el-input-number v-model="scope.row.zhljhf"
                                   size="mini"
                                   placeholder="灰分(%)"
                                   :precision="2"
                                   :controls="false"
                                   :min="0"
                                   :max="100" class="curves-det-input"/>
                </template>
              </el-table-column>
            </el-table-column>
            <el-table-column label="浮物累计" header-align="center" >
              <el-table-column prop="fwljcl" label="产率(%)" header-align="center" align="center">
                <template #default="scope">
                  <el-input-number v-model="scope.row.fwljcl"
                                   :disabled="true"
                                   size="mini"
                                   placeholder="产率(%)"
                                   :precision="2"
                                   :controls="false"
                                   :min="0"
                                   :max="100" class="curves-det-input"/>
                </template>
              </el-table-column>
              <el-table-column prop="fwljhf" label="灰分(%)" header-align="center" align="center">
                <template #default="scope">
                  <el-input-number v-model="scope.row.fwljhf"
                                   :disabled="true"
                                   size="mini"
                                   placeholder="灰分(%)"
                                   :precision="2"
                                   :controls="false"
                                   :min="0"
                                   :max="100" class="curves-det-input"/>
                </template>
              </el-table-column>
            </el-table-column>
            <el-table-column label="沉物累计" header-align="center" >
              <el-table-column prop="cwljcl" label="产率(%)" header-align="center" align="center">
                <template #default="scope">
                  <el-input-number v-model="scope.row.cwljcl"
                                   :disabled="true"
                                   size="mini"
                                   placeholder="产率(%)"
                                   :precision="2"
                                   :controls="false"
                                   :min="0"
                                   :max="100" class="curves-det-input"/>
                </template>
              </el-table-column>
              <el-table-column prop="cwljhf" label="灰分(%)" header-align="center" align="center">
                <template #default="scope">
                  <el-input-number v-model="scope.row.cwljhf"
                                   :disabled="true"
                                   size="mini"
                                   placeholder="灰分(%)"
                                   :precision="2"
                                   :controls="false"
                                   :min="0"
                                   :max="100" class="curves-det-input"/>
                </template>
              </el-table-column>
            </el-table-column>
            <el-table-column prop="md" label="密度" header-align="center" align="center" >
              <template #default="scope">
                <el-input-number v-model="scope.row.md"
                                 size="mini"
                                 placeholder="密度"
                                 :precision="2"
                                 :controls="false"
                                 :min="0"
                                 :max="100" class="curves-det-input"/>
              </template>
            </el-table-column>
            <el-table-column prop="hl" label="±0.1含量" header-align="center" align="center" >
              <template #default="scope">
                <el-input-number v-model="scope.row.hl"
                                 :disabled="true"
                                 size="mini"
                                 placeholder="±0.1含量"
                                 :precision="2"
                                 :controls="false"
                                 :min="0"
                                 :max="100" class="curves-det-input"/>
              </template>
            </el-table-column>
            <el-table-column prop="lf" label="硫分(%)" header-align="center" align="center" >
              <template #default="scope">
                <el-input-number v-model="scope.row.lf"
                                 size="mini"
                                 placeholder="硫分(%)"
                                 :precision="2"
                                 :controls="false"
                                 :min="0"
                                 :max="100" class="curves-det-input"/>
              </template>
            </el-table-column>
          </el-table>
        </el-form>
      </el-tab-pane>
    </el-tabs>
    <template #footer>
      <el-button :disabled="formLoading" type="primary" @click="submitForm()">确定</el-button>
      <el-button @click="dialogVisible = false">取消</el-button>
    </template>
  </Dialog>
</template>
 
<script lang="ts" setup>
  import * as WashCurvesApi from '@/api/xmcpms/coal-quality/analysis/wash-curves/index'
  import {DICT_TYPE, getStrDictOptions} from '@/utils/dict'
 
  defineOptions({name: ' WashCurvesForm'})
 
  const {t} = useI18n() // 国际化
  const message = useMessage() // 消息弹窗
  const dialogVisible = ref(false) // 弹窗的是否展示
  const dialogTitle = ref('') // 弹窗的标题
  const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
  const formType = ref('') // 表单的类型:create - 新增;update - 修改
  const formRef = ref() // 表单 Ref
  const formData = ref({
    id: undefined,
    code: undefined,
    ny: undefined,
    syrq: undefined,
    mz: undefined,
    drl: undefined,
    fcfa: undefined,
    bz: undefined,
    detList: []
  })
 
  const open = async (type: string, id?: string) => {
    dialogVisible.value = true
    dialogTitle.value = t('action.' + type)
    formType.value = type
    resetForm()
    //修改时,设置数据
    if (id) {
      formLoading.value = true
      try {
        formData.value = await WashCurvesApi.getWashCurvesInfo(id)
      } finally {
        formLoading.value = false
      }
    }
  }
  defineExpose({ open }) // 提供 open 方法,用于打开弹窗
 
  /** 提交表单 */
  const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
  const submitForm = async () => {
    // 校验表单
    if (!formRef) return
    const valid = await formRef.value.validate()
    if (!valid) return
    // 提交请求
    formLoading.value = true
    try {
      const data = formData.value as WashCurvesApi.WashCurvesVO
      if (formType.value === 'create') {
        await WashCurvesApi.createWashCurves(data)
        message.success(t('common.createSuccess'))
      } else {
        await WashCurvesApi.updateWashCurves(data)
        message.success(t('common.updateSuccess'))
      }
      dialogVisible.value = false
      // 发送操作成功的事件
      emit('success')
    } finally {
      formLoading.value = false
    }
  }
 
  /** 重置表单 */
  const resetForm = () => {
    formData.value = {
      id: undefined,
      code: undefined,
      ny: undefined,
      syrq: undefined,
      mz: undefined,
      drl: undefined,
      fcfa: undefined,
      bz: undefined,
      detList: []
    }
    formRef.value?.resetFields()
  }
 
</script>
<style>
  .curves-det-input {
    width: 100%;
  }
</style>