选煤厂生产管理平台前端代码
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
<template>
  <el-dialog
    title="煤种"
    :close-on-click-modal="false"
    append-to-body
    width="60%"
    :visible.sync="visible"
  >
    <el-form
      :model="dataForm"
      ref="dataForm"
      @keyup.enter.native="dataFormSubmitHandle()"
    >
      <el-row>
        <el-col>
          <el-form-item>
            <el-table
              :data="dataList"
              border
              style="width: 100%">
              <el-table-column
                type="index"
                align="center"
                min-width="50"
                label="序号">
              </el-table-column>
              <el-table-column
                prop=""
                label="煤种"
                min-width="120"
                align="center">
                <template slot-scope="scope">
            <dict-select-tag style="width: 100%"
                             v-model="scope.row.mz"
                             placeholder="煤种"
                             :dictCode="dictCodeMz"
                             :clearable="true"/>
                </template>
              </el-table-column>
              <el-table-column
                prop=""
                label="比例"
                align="center"
                min-width="100">
                <template slot-scope="scope">
                  <el-input-number
                    v-model="scope.row.proportion"
                    :min="1"
                    label="比例"
                  ></el-input-number>
                </template>
              </el-table-column>
              <el-table-column
                prop=""
                label="操作"
                min-width="100"
                align="center">
                <template slot-scope="scope">
                  <el-button
                    @click.native.prevent="addExpressionRow(scope.$index, dataList)"
                    type="text"
                    size="small">
                    添加
                  </el-button>
                  <el-button
                    @click.native.prevent="deleteExpressionRow(scope.$index, dataList)"
                    type="text"
                    size="small">
                    删除
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
 
    <span slot="footer" class="dialog-footer">
      <el-button :loading="loading" @click="visible = false">取消</el-button>
      <el-button :loading="loading" type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>
 
<script>
import debounce from "lodash/debounce";
import DictSelectTag from "@/components/dict/dict-select-tag";
 
export default {
  components: { DictSelectTag },
  data() {
    return {
      visible: false,
      loading: false,
      dataForm: {
        mc:''
      },
      dictCodeMz:'',
      dataList:[{
            mz: " ",
            proportion: " ",
          }]
    };
  },
  methods: {
    init(mc,mclx) {
      this.visible = true;
      this.$nextTick(() => {
        this.$refs["dataForm"].resetFields();
        this.dataForm.mc = mc;
        this.dataList=[{
            mc: this.dataForm.mc,
            mz: "",
            proportion: "",
          }];
        if ("ymc" === mclx) {
          this.dictCodeMz = "ymmz";
        } else if ("cpc" === mclx) {
          this.dictCodeMz = "cpmz";
        }
        this.getList();
      });
    },
    // 获取信息
    getList() {
      this.$http
        .get(
          `/iailab-iems-coal-proddisp/warehouse/mcmz/list/${this.dataForm.mc}`
        )
        .then(({ data: res }) => {
          if (res.code !== 0) {
            return this.$message.error(res.msg);
          }
          if(res.data!=null){
          this.dataList = res.data
          }
        })
        .catch(() => {});
    },
    // 表单提交
    dataFormSubmit: debounce(
      function () {
        this.$refs["dataForm"].validate((valid) => {
          if (!valid) {
            return false;
          }
          this.loading = true;
          this.$http.post(
            "/iailab-iems-coal-proddisp/warehouse/mcmz/add",
            this.dataList
          )
            .then(({ data: res }) => {
              if (res.code !== 0) {
                return this.$message.error(res.msg);
              }
              this.$message({
                message: this.$t("prompt.success"),
                type: "success",
                duration: 500,
                onClose: () => {
                  this.visible = false;
                  this.$emit("refreshDataList");
                },
              });
              this.loading = false;
            })
            .catch(() => {});
        });
      },
      1000,
      { leading: true, trailing: false }
    ),
    //删除行
    deleteExpressionRow (index, rows) {
        if (!rows || rows.length === 1) {
          this.$message({
            message: '不能全部删除!',
            type: 'error',
            duration: 1500
          })
          return
        }
        rows.splice(index, 1)
      },
    //添加行
    addExpressionRow (index, rows) {
        let row = JSON.parse(JSON.stringify(rows[index]))
        rows.splice(index, 0, row)
      }
  },
};
</script>