选煤厂生产管理平台前端代码
dongyukun
2024-12-10 5cc1d92af645c2f8f4f6d1d3777283b70df78ccd
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
<template>
  <Dialog v-model="visible" :title="!dataForm.id ? '新增' : '修改'">
    <el-form
      ref="dataForm"
      v-loading="formLoading"
      :model="dataForm"
      :rules="formRules"
      label-width="80px"
    >
      <el-row>
        <el-col :span="12">
          <el-form-item prop="lsh" label="流水号" label-width="120px">
            <el-input disabled v-model="dataForm.lsh" placeholder="流水号"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="type === 'monthly' ? '月份' : '年份'" prop="ny" label-width="120px">
            <el-date-picker
              style="width: 100%"
              v-if="type === 'monthly'"
              v-model="dataForm.ny"
              type="month"
              value-format="yyyy-MM"
              placeholder="选择月"/>
            <el-date-picker
              style="width: 100%"
              v-if="type === 'yearly'"
              v-model="dataForm.ny"
              type="year"
              value-format="yyyy"
              placeholder="选择年"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="编制人" prop="bzr" label-width="120px">
            <el-input v-model="dataForm.bzr" placeholder="编制人"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="编制时间" prop="bzsj" label-width="120px">
            <el-date-picker
              style="width: 100%"
              v-model="dataForm.bzsj"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="选择编制时间"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="4">
          <el-button type="primary" size="mini" @click="addDet">新增</el-button>
        </el-col>
      </el-row>
      <el-row style="margin-top: 1%">
        <el-table
          v-loading="detListLoading"
          :data="dataForm.detList"
          style="width: 100%;"
          border>
          <el-table-column type="index" header-align="center" align="center" width="50" label="序号"/>
          <el-table-column prop="mzCode" header-align="center" align="center" label="煤种">
            <template #default="scope">
              <el-form-item class="myCol" :prop="'detList.' + scope.$index + '.mzCode'"
                            :rules="dataRule.mzCode"
                            :show-message="false">
 
                  <el-select
                    style="width: 100%" size="mini" v-model="scope.mzCode"
                    placeholder="煤种"
                  >
                    <el-option
                      v-for="dict in getIntDictOptions(DICT_TYPE.PMS_CPMZ)"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    />
                  </el-select>
 
              </el-form-item>
            </template>
          </el-table-column>
          <el-table-column prop="dw" header-align="center" align="center" label="单位" width="85">
            <template #default="scope">
              <el-form-item class="myCol" :prop="'detList.' + scope.$index + '.dw'"
                            :rules="dataRule.dw"
                            :show-message="false">
                <el-input size="mini" v-model="scope.dw" placeholder="单位"/>
              </el-form-item>
            </template>
          </el-table-column>
          <el-table-column prop="cl" header-align="center" align="center" label="产量">
            <template #default="scope">
              <el-form-item class="myCol" :prop="'detList.' + scope.$index + '.cl'"
                            :rules="dataRule.cl"
                            :show-message="false">
                <el-input-number size="mini" style="width: 100%" :precision="2" v-model="scope.cl"
                                 placeholder="产量"
                                 :controls="false"/>
              </el-form-item>
            </template>
          </el-table-column>
          <el-table-column prop="hf" header-align="center" align="center" label="灰分(Ad%)">
            <template #default="scope">
              <el-form-item class="myCol" :prop="'detList.' + scope.$index + '.hf'"
                            :rules="dataRule.hf"
                            :show-message="false">
                <el-input-number size="mini" style="width: 100%" :precision="2" v-model="scope.hf"
                                 placeholder="灰分"
                                 :controls="false"/>
              </el-form-item>
            </template>
          </el-table-column>
          <el-table-column prop="lf" header-align="center" align="center" label="硫分(St,d%)">
            <template #default="scope">
              <el-form-item class="myCol" :prop="'detList.' + scope.$index + '.lf'"
                            :show-message="false">
                <el-input-number size="mini" style="width: 100%" :precision="2" v-model="scope.lf"
                                 placeholder="硫分"
                                 :controls="false"/>
              </el-form-item>
            </template>
          </el-table-column>
          <el-table-column prop="sf" header-align="center" align="center" label="水分(Mt%)">
            <template #default="scope">
              <el-form-item class="myCol" :prop="'detList.' + scope.$index + '.sf'"
                            :show-message="false">
                <el-input-number size="mini" style="width: 100%" :precision="2" v-model="scope.sf"
                                 placeholder="水分"
                                 :controls="false"/>
              </el-form-item>
            </template>
          </el-table-column>
          <el-table-column prop="mbrz" header-align="center" align="center" label="目标热值(Kcal/Kg)">
            <template #default="scope">
              <el-form-item class="myCol" :prop="'detList.' + scope.$index + '.mbrz'"
                            :show-message="false">
                <el-input-number size="mini" style="width: 100%" :precision="2" v-model="scope.mbrz"
                                 placeholder="目标热值"
                                 :controls="false"/>
              </el-form-item>
            </template>
          </el-table-column>
          <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center"
                           width="50">
            <template #default="scope">
              <el-button size="mini" type="text" icon="el-icon-delete"
                         @click="deleteDet(scope.$index)"
                         :disabled="dataForm.detList.length === 1"/>
            </template>
          </el-table-column>
        </el-table>
      </el-row>
    </el-form>
    <div>
      <slot name="footer">
        <el-button @click="visible = false">{{ $t('cancel') }}</el-button>
        <el-button type="primary" @click="dataFormSubmitHandle()"
                   :disabled="dataForm.detList.length === 0">{{
          $t('confirm') }}
        </el-button>
      </slot>
    </div>
  </dialog>
</template>
 
<script lang="ts" setup>
  import {getYM, getYMD} from '@/utils/dateUtil'
  import {FormRules} from "element-plus";
  import {ref, computed} from 'vue';
  import { ElMessage } from 'element-plus'
  import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
  defineOptions({name: 'ProdPlanAddOrUpdate'})
 
  const type = ref('')
  const visible = ref(false)
  const dataForm = reactive({
    id: '',
    unit2: '',
    ssdw: '',
    lsh: '',
    jhlb: type,
    ny: getYM(new Date()),
    bzr: '',
    bzsj: getYMD(new Date()),
    sslb: '',
    detList: []
  })
  const detListLoading = ref(false)
  const validateMzCode = (rule, value, callback) => {
    if (this.dataForm.detList.filter(item => item.mzCode === value).length > 1) {
      ElMessage({
        message: '煤种进行了重复选择',
        type: 'warning',
      })
      callback(new Error('煤种进行了重复选择'))
    } else {
      callback()
    }
  }
  const formRules = reactive < FormRules > ({
    ny: [
      {required: true, message: '不能为空', trigger: 'change'}
    ],
    bzr: [
      {required: true, message: '编制人不能为空', trigger: 'change'}
    ],
    bzsj: [
      {required: true, message: '编制时间不能为空', trigger: 'change'}
    ],
    sslb: [
      {required: true, message: '所属类别不能为空', trigger: 'change'}
    ],
    mzCode: [
      {required: true, trigger: 'change'},
      {validator: validateMzCode, trigger: 'change'}
    ],
    dw: [
      {required: true, trigger: 'change'}
    ],
    cl: [
      {required: true, trigger: 'blur'}
    ],
    hf: [
      {required: true, trigger: 'blur'}
    ],
    lf: [
      {required: true, trigger: 'blur'}
    ],
    sf: [
      {required: true, trigger: 'blur'}
    ],
    mbrz: [
      {required: true, trigger: 'blur'}
    ]
  })
 
  /** 打开弹窗 */
  const open = async () => {
    dialogVisible.value = true
    resetForm()
 
    this.dataForm.detList = []
    this.dataForm.bzr = this.$store.state.user.realName
    if (this.dataForm.id) {
      this.getInfo()
    }
  }
  /** 重置表单 */
  const resetForm = () => {
    dataForm.value = {
      id: '',
      unit2: '',
      ssdw: '',
      lsh: '',
      jhlb: type,
      ny: getYM(new Date()),
      bzr: '',
      bzsj: getYMD(new Date()),
      sslb: '',
      detList: []
    }
    dataForm.value?.resetFields()
  }
 
</script>
 
<style scoped>
  .myCol {
    margin-bottom: 0px
  }
</style>