“linengliang”
2023-08-23 ee79f53fd9385b087ebd7a93af638d91a9825d10
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
<template>
  <a-card :bordered="false">
    <a-button
      v-if="equipmentSelectionRows.length == 1 && this.dataSource.length == 0"
      @click="handleAdd"
      type="primary"
      icon="plus"
    >新增</a-button>
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination=false
        :loading="loading"
        @change="handleTableChange"
      >
 
        <template
          v-for="col in columns"
          :slot="col.dataIndex"
          slot-scope='text, record, index'
        >
          <div :key="col.dataIndex">
 
            <span v-if="col.dataIndex == 'remark'">
              <j-ellipsis
                :value="text"
                :length="10"
              />
            </span>
 
            <a-input-number
              :value="text"
              v-if="col.dataIndex == 'parametersValue'"
              @change="(e)=>handleChange(e, record.key, col, index)"
              style="width: 100%"
            />
 
            <span v-if="col.dataIndex == 'action'">
              <a-button
                type="primary"
                @click="handleEdit(record)"
              >提交</a-button>
            </span>
 
          </div>
        </template>
 
      </a-table>
    </div>
 
    <!-- 表单区域 -->
    <process-parameters-modal
      ref="modalForm"
      @ok="modalFormOk"
    ></process-parameters-modal>
 
  </a-card>
</template>
 
<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction, postAction } from '@/api/manage'
import JInput from '@/components/jeecg/JInput'
import Tooltip from 'ant-design-vue/es/tooltip'
import JEllipsis from "@/components/jeecg/JEllipsis";
 
import ProcessParametersModal from './ProcessParametersModal'
 
export default {
  name: "ProcessParametersList",
  mixins: [JeecgListMixin],
  components: {
    JInput,
    Tooltip,
    JEllipsis,
    ProcessParametersModal,
  },
  data() {
    return {
      description: '工艺参数',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: "center",
          customRender: function (t, r, index) {
            return parseInt(index) + 1;
          }
        },
        {
          title: '工艺参数编码',
          align: "center",
          dataIndex: 'processParametersNum',
        },
        {
          title: '工艺参数名称',
          align: "center",
          dataIndex: 'processParametersName',
        },
        {
          title: '计量单位',
          align: "center",
          dataIndex: 'processParametersUnitName',
        },
        {
          title: '参数值',
          align: "center",
          dataIndex: 'parametersValue',
          scopedSlots: {
            customRender: 'parametersValue'
          },
          width: 120,
        },
        {
          title: '备注',
          align: "center",
          dataIndex: 'remark',
          scopedSlots: {
            customRender: 'remark'
          },
        },
        {
          title: '操作',
          align: "center",
          dataIndex: 'action',
          scopedSlots: {
            customRender: 'action'
          },
          width: 100,
        },
      ],
      url: {
        list: "/eam/equipmentProcessParameters/list",
        edit: "/eam/equipmentProcessParameters/edit",
      },
      equipmentSelectionRows: [],
      equipmentId: '',
    }
  },
  watch: {
    equipmentId() {
      this.queryParam = {};
      this.queryParam.equipmentId = this.equipmentId;
      this.loadData(1);
    },
  },
  mounted() {
    this.$bus.$on('equipmentSelectionRows', (data) => {
      this.equipmentSelectionRows = data
    })
  },
  methods: {
 
    handleAdd: function () {
      this.$refs.modalForm.add();
      this.$refs.modalForm.title = "设备工艺参数绑定";
      this.$refs.modalForm.disableSubmit = false;
      this.$refs.modalForm.equipmentId = this.equipmentSelectionRows[0].id
    },
 
    modalFormOk() {
      this.loadData(1);
    },
 
    handleEdit(record) {
      this.loading = true;
      if (record.parametersValue === "" || record.parametersValue === null) {
        this.$message.warning("参考值不能为空!")
        this.loading = false;
        return
      }
      postAction(this.url.edit, record).then((res) => {
        if (res.success) {
          this.$message.success(res.message);
          this.loadData()
        } else {
          this.$message.warning(res.message);
        }
      }).finally(() => {
        this.loading = false;
      });
    },
 
    handleChange(value, key, column, index) {
      let that = this;
      const temp = [...that.dataSource];
      const target = temp.filter(item => key === item.key)[index];
      if (target) {
        target[column.dataIndex] = value;
        if ('parametersValue' == column.dataIndex) {
          target['parametersValue'] = value;
        }
        //显示带过来的数据
        that.dataSource = temp;
      }
    },
 
    loadData(arg) {
      if (!this.url.list) {
        this.$message.error("请设置url.list属性!")
        return
      }
      if (arg === 1) {
        this.ipagination.current = 1;
      }
      var params = this.getQueryParams();//查询条件
      if (this.equipmentId == '') {
        params.equipmentId = '-1';
      }
      this.loading = true;
      getAction(this.url.list, params).then((res) => {
        if (res.success) {
          this.dataSource = res.result.records || res.result;
          if (res.result.total) {
            this.ipagination.total = res.result.total;
          } else {
            this.ipagination.total = 0;
          }
        } else {
          this.$message.warning(res.message)
        }
      }).finally(() => {
        this.loading = false
      })
    },
  },
}
</script>
 
<style lang="less" scoped>
@import '~@assets/less/common.less';
/deep/ .frozenRowClass {
  color: #c9c9c9;
}
.success {
  color: green;
}
.error {
  color: red;
}
.fontweight {
  font-weight: bold;
}
.fontweightGreen {
  font-weight: bold;
  color: green;
}
.ant-card {
  margin-left: -30px;
  margin-right: -30px;
}
</style>