|
|
@@ -1,349 +1,343 @@
|
|
1
|
1
|
<template>
|
|
2
|
2
|
<div>
|
|
3
|
3
|
<el-card :body-style="cardBodyStyle">
|
|
4
|
|
- <el-form :inline="true" label-position="right" label-width="100px">
|
|
5
|
|
- <el-form-item label="" class="no-show-error-message">
|
|
6
|
|
- <el-input v-model="queryParams.material" size="small" placeholder="请输入物料名称或编码" style="width:300px;float: left;margin-right: 10px;"></el-input>
|
|
7
|
|
- <el-input v-model="queryParams.standard" size="small" placeholder="请输入钢种" style="width:300px;float: left;margin-right: 10px;"></el-input>
|
|
8
|
|
- <el-button v-prevent-re-click type="primary" plain @click="handleSearch">查询</el-button>
|
|
9
|
|
- <el-button v-prevent-re-click type="primary" @click="handleAdd">新增</el-button>
|
|
10
|
|
- </el-form-item>
|
|
|
4
|
+ <el-form :model="query" label-width="auto" label-position="right">
|
|
|
5
|
+ <el-row :gutter="10">
|
|
|
6
|
+ <el-col :span="5">
|
|
|
7
|
+ <el-form-item label="物料名称/编码" style="margin-bottom: 0px;">
|
|
|
8
|
+ <el-input v-model="query.material" clearable placeholder="请输入物料名称或编码" style="width:100%;"></el-input>
|
|
|
9
|
+ </el-form-item>
|
|
|
10
|
+ </el-col>
|
|
|
11
|
+ <el-col :span="5">
|
|
|
12
|
+ <el-form-item label="钢种" style="margin-bottom: 0px;">
|
|
|
13
|
+ <el-input v-model="query.standard" clearable placeholder="请输入钢种" style="width:100%;"></el-input>
|
|
|
14
|
+ </el-form-item>
|
|
|
15
|
+ </el-col>
|
|
|
16
|
+ <el-col :span="4">
|
|
|
17
|
+ <el-form-item label="" style="margin-bottom: 0px; margin-top: 5px;">
|
|
|
18
|
+ <el-button type="primary" @click="handleSearch">查询</el-button>
|
|
|
19
|
+ <el-button type="success" @click="insertDialog">新增</el-button>
|
|
|
20
|
+ </el-form-item>
|
|
|
21
|
+ </el-col>
|
|
|
22
|
+ </el-row>
|
|
11
|
23
|
</el-form>
|
|
12
|
24
|
</el-card>
|
|
13
|
25
|
|
|
14
|
26
|
<el-card :body-style="cardBodyStyle">
|
|
15
|
|
- <el-table :data="tableData" border v-loading="loading" style="width: 100%">
|
|
16
|
|
- <el-table-column prop="materialName" label="物料名称" width="150" header-align="center" align="center" show-overflow-tooltip>
|
|
17
|
|
- </el-table-column>
|
|
18
|
|
- <el-table-column prop="materialCode" label="物料编码" width="120" header-align="center" align="center" show-overflow-tooltip>
|
|
19
|
|
- </el-table-column>
|
|
20
|
|
- <el-table-column prop="materialStandard" label="钢种" width="150" header-align="center" align="center" show-overflow-tooltip>
|
|
21
|
|
- </el-table-column>
|
|
22
|
|
- <el-table-column prop="materialModel" label="尺寸" width="120" header-align="center" align="center" show-overflow-tooltip>
|
|
23
|
|
- </el-table-column>
|
|
24
|
|
- <el-table-column prop="materialAttr1" label="属性1" width="120" header-align="center" align="center" show-overflow-tooltip>
|
|
25
|
|
- </el-table-column>
|
|
26
|
|
- <el-table-column prop="materialAttr2" label="属性2" width="120" header-align="center" align="center" show-overflow-tooltip>
|
|
27
|
|
- </el-table-column>
|
|
28
|
|
- <el-table-column prop="materialAttr3" label="属性3" width="120" header-align="center" align="center" show-overflow-tooltip>
|
|
29
|
|
- </el-table-column>
|
|
30
|
|
- <el-table-column prop="materialAttr4" label="属性4" width="120" header-align="center" align="center" show-overflow-tooltip>
|
|
31
|
|
- </el-table-column>
|
|
32
|
|
- <el-table-column prop="materialAttr5" label="属性5" width="120" header-align="center" align="center" show-overflow-tooltip>
|
|
|
27
|
+ <el-table :data="tableData" border highlight-current-row @selection-change="handleSelectionChange" :height="height">
|
|
|
28
|
+ <el-table-column type="selection" fixed></el-table-column>
|
|
|
29
|
+ <el-table-column type="index" label="序号" align="center" width="60">
|
|
|
30
|
+ <template #default="scope">
|
|
|
31
|
+ <span>{{ scope.$index + (currentPage - 1) * pageSize + 1 }}</span>
|
|
|
32
|
+ </template>
|
|
33
|
33
|
</el-table-column>
|
|
34
|
|
- <el-table-column label="操作" width="200" header-align="center" align="center" fixed="right">
|
|
|
34
|
+ <el-table-column prop="materialName" label="物料名称" width="150" header-align="center" align="center" show-overflow-tooltip></el-table-column>
|
|
|
35
|
+ <el-table-column prop="materialCode" label="物料编码" width="120" header-align="center" align="center" show-overflow-tooltip></el-table-column>
|
|
|
36
|
+ <el-table-column prop="materialStandard" label="钢种" width="150" header-align="center" align="center" show-overflow-tooltip></el-table-column>
|
|
|
37
|
+ <el-table-column prop="materialModel" label="尺寸" width="120" header-align="center" align="center" show-overflow-tooltip></el-table-column>
|
|
|
38
|
+ <el-table-column prop="materialAttr1" label="属性1" width="120" header-align="center" align="center" show-overflow-tooltip></el-table-column>
|
|
|
39
|
+ <el-table-column prop="materialAttr2" label="属性2" width="120" header-align="center" align="center" show-overflow-tooltip></el-table-column>
|
|
|
40
|
+ <el-table-column prop="materialAttr3" label="属性3" width="120" header-align="center" align="center" show-overflow-tooltip></el-table-column>
|
|
|
41
|
+ <el-table-column prop="materialAttr4" label="属性4" width="120" header-align="center" align="center" show-overflow-tooltip></el-table-column>
|
|
|
42
|
+ <el-table-column prop="materialAttr5" label="属性5" width="120" header-align="center" align="center" show-overflow-tooltip></el-table-column>
|
|
|
43
|
+ <el-table-column label="操作" header-align="center" align="center" width="200px" fixed="right">
|
|
35
|
44
|
<template #default="scope">
|
|
36
|
|
- <el-button plain type="warning" size="mini" @click="handleEdit(scope.row)">编辑</el-button>
|
|
37
|
|
- <el-button plain type="danger" size="mini" @click="handleDelete(scope.row)">删除</el-button>
|
|
|
45
|
+ <el-button plain type="warning" @click="handleEdit(scope.row)">编辑</el-button>
|
|
|
46
|
+ <el-button plain type="danger" @click="handleRemove(scope.row)">删除</el-button>
|
|
38
|
47
|
</template>
|
|
39
|
48
|
</el-table-column>
|
|
40
|
49
|
</el-table>
|
|
|
50
|
+ </el-card>
|
|
41
|
51
|
|
|
42
|
|
- <el-pagination
|
|
43
|
|
- @size-change="handleSizeChange"
|
|
44
|
|
- @current-change="handleCurrentChange"
|
|
45
|
|
- :current-page="pagination.currentPage"
|
|
46
|
|
- :page-sizes="pagination.pageSizes"
|
|
47
|
|
- :page-size="pagination.pageSize"
|
|
48
|
|
- layout="total, sizes, prev, pager, next, jumper"
|
|
49
|
|
- :total="pagination.totalRows">
|
|
|
52
|
+ <el-card :body-style="cardBodyStyle">
|
|
|
53
|
+ <el-pagination :current-page="currentPage" :page-size="pageSize" :page-sizes="pageSizes" :total="totalRows"
|
|
|
54
|
+ background layout="total, sizes, prev, pager, next, jumper"
|
|
|
55
|
+ @size-change="handleSizeChange"
|
|
|
56
|
+ @current-change="handleCurrentChange">
|
|
50
|
57
|
</el-pagination>
|
|
51
|
58
|
</el-card>
|
|
52
|
59
|
|
|
53
|
60
|
<!-- 新增/编辑对话框 -->
|
|
54
|
|
- <el-dialog
|
|
55
|
|
- :close-on-click-modal="false"
|
|
56
|
|
- :title="form.id ? '编辑物料' : '新增物料'"
|
|
57
|
|
- v-model="dialogVisible"
|
|
58
|
|
- width="600px">
|
|
59
|
|
- <el-form :model="form" label-width="100px" :rules="rules" ref="formRef">
|
|
60
|
|
- <el-form-item label="物料名称" prop="materialName">
|
|
61
|
|
- <el-input v-model="form.materialName" style="width: 400px;" placeholder="请输入物料名称"></el-input>
|
|
62
|
|
- </el-form-item>
|
|
63
|
|
- <el-form-item label="物料编码" prop="materialCode">
|
|
64
|
|
- <el-input v-model="form.materialCode" style="width: 400px;" placeholder="请输入物料编码"></el-input>
|
|
65
|
|
- </el-form-item>
|
|
66
|
|
- <el-form-item label="钢种" prop="materialStandard">
|
|
67
|
|
- <el-input v-model="form.materialStandard" style="width: 400px;" placeholder="请输入钢种"></el-input>
|
|
68
|
|
- </el-form-item>
|
|
69
|
|
- <el-form-item label="尺寸">
|
|
70
|
|
- <el-input v-model="form.materialModel" style="width: 400px;" placeholder="请输入尺寸"></el-input>
|
|
71
|
|
- </el-form-item>
|
|
72
|
|
- <el-form-item label="属性1">
|
|
73
|
|
- <el-input v-model="form.materialAttr1" style="width: 400px;" placeholder="请输入属性1"></el-input>
|
|
74
|
|
- </el-form-item>
|
|
75
|
|
- <el-form-item label="属性2">
|
|
76
|
|
- <el-input v-model="form.materialAttr2" style="width: 400px;" placeholder="请输入属性2"></el-input>
|
|
77
|
|
- </el-form-item>
|
|
78
|
|
- <el-form-item label="属性3">
|
|
79
|
|
- <el-input v-model="form.materialAttr3" style="width: 400px;" placeholder="请输入属性3"></el-input>
|
|
80
|
|
- </el-form-item>
|
|
81
|
|
- <el-form-item label="属性4">
|
|
82
|
|
- <el-input v-model="form.materialAttr4" style="width: 400px;" placeholder="请输入属性4"></el-input>
|
|
83
|
|
- </el-form-item>
|
|
84
|
|
- <el-form-item label="属性5">
|
|
85
|
|
- <el-input v-model="form.materialAttr5" style="width: 400px;" placeholder="请输入属性5"></el-input>
|
|
86
|
|
- </el-form-item>
|
|
87
|
|
- </el-form>
|
|
|
61
|
+ <el-dialog class="diaClass" :close-on-click-modal="false" draggable :title="dialogTitle" v-model="dialogVisible" width="50%" top="5vh">
|
|
|
62
|
+ <el-card>
|
|
|
63
|
+ <el-form :model="form" label-width="120px" label-position="right" inline ref="ruleFormRef" :rules="rules">
|
|
|
64
|
+ <el-row>
|
|
|
65
|
+ <el-col :span="12">
|
|
|
66
|
+ <el-form-item label="物料名称" prop="materialName">
|
|
|
67
|
+ <el-input v-model="form.materialName" maxlength="100" placeholder="请输入物料名称"></el-input>
|
|
|
68
|
+ </el-form-item>
|
|
|
69
|
+ </el-col>
|
|
|
70
|
+ <el-col :span="12">
|
|
|
71
|
+ <el-form-item label="物料编码" prop="materialCode">
|
|
|
72
|
+ <el-input v-model="form.materialCode" maxlength="100" placeholder="请输入物料编码"></el-input>
|
|
|
73
|
+ </el-form-item>
|
|
|
74
|
+ </el-col>
|
|
|
75
|
+ <el-col :span="12">
|
|
|
76
|
+ <el-form-item label="钢种" prop="materialStandard">
|
|
|
77
|
+ <el-input v-model="form.materialStandard" maxlength="50" placeholder="请输入钢种"></el-input>
|
|
|
78
|
+ </el-form-item>
|
|
|
79
|
+ </el-col>
|
|
|
80
|
+ <el-col :span="12">
|
|
|
81
|
+ <el-form-item label="尺寸">
|
|
|
82
|
+ <el-input v-model="form.materialModel" maxlength="50" placeholder="请输入尺寸"></el-input>
|
|
|
83
|
+ </el-form-item>
|
|
|
84
|
+ </el-col>
|
|
|
85
|
+ <el-col :span="12">
|
|
|
86
|
+ <el-form-item label="属性1">
|
|
|
87
|
+ <el-input v-model="form.materialAttr1" maxlength="50" placeholder="请输入属性1"></el-input>
|
|
|
88
|
+ </el-form-item>
|
|
|
89
|
+ </el-col>
|
|
|
90
|
+ <el-col :span="12">
|
|
|
91
|
+ <el-form-item label="属性2">
|
|
|
92
|
+ <el-input v-model="form.materialAttr2" maxlength="50" placeholder="请输入属性2"></el-input>
|
|
|
93
|
+ </el-form-item>
|
|
|
94
|
+ </el-col>
|
|
|
95
|
+ <el-col :span="12">
|
|
|
96
|
+ <el-form-item label="属性3">
|
|
|
97
|
+ <el-input v-model="form.materialAttr3" maxlength="50" placeholder="请输入属性3"></el-input>
|
|
|
98
|
+ </el-form-item>
|
|
|
99
|
+ </el-col>
|
|
|
100
|
+ <el-col :span="12">
|
|
|
101
|
+ <el-form-item label="属性4">
|
|
|
102
|
+ <el-input v-model="form.materialAttr4" maxlength="50" placeholder="请输入属性4"></el-input>
|
|
|
103
|
+ </el-form-item>
|
|
|
104
|
+ </el-col>
|
|
|
105
|
+ <el-col :span="12">
|
|
|
106
|
+ <el-form-item label="属性5">
|
|
|
107
|
+ <el-input v-model="form.materialAttr5" maxlength="50" placeholder="请输入属性5"></el-input>
|
|
|
108
|
+ </el-form-item>
|
|
|
109
|
+ </el-col>
|
|
|
110
|
+ </el-row>
|
|
|
111
|
+ </el-form>
|
|
|
112
|
+ </el-card>
|
|
88
|
113
|
<template #footer>
|
|
89
|
114
|
<div class="dialog-footer">
|
|
90
|
|
- <el-button type="success" @click="handleSave">保存</el-button>
|
|
91
|
|
- <el-button type="danger" @click="handleCancelSave">取消</el-button>
|
|
|
115
|
+ <el-button type="success" plain @click="handleSave(ruleFormRef)">保存</el-button>
|
|
|
116
|
+ <el-button type="danger" plain @click="handleCancelSave">取消</el-button>
|
|
92
|
117
|
</div>
|
|
93
|
118
|
</template>
|
|
94
|
119
|
</el-dialog>
|
|
95
|
120
|
</div>
|
|
96
|
121
|
</template>
|
|
97
|
122
|
|
|
98
|
|
-<script>
|
|
99
|
|
-import axios from '@/axios'
|
|
100
|
|
-export default {
|
|
101
|
|
- name: 'MaterialManagement',
|
|
102
|
|
- data() {
|
|
103
|
|
- return {
|
|
104
|
|
- // 表格数据
|
|
105
|
|
- tableData: [],
|
|
106
|
|
- loading: false,
|
|
107
|
|
-
|
|
108
|
|
- // 分页参数
|
|
109
|
|
- pagination: {
|
|
110
|
|
- currentPage: 1,
|
|
111
|
|
- totalRows: 0,
|
|
112
|
|
- pageSizes: [50, 100, 200, 500],
|
|
113
|
|
- pageSize: 50
|
|
114
|
|
- },
|
|
|
123
|
+<script setup>
|
|
|
124
|
+import {getCurrentInstance, onMounted, reactive, ref} from 'vue'
|
|
|
125
|
+import tools from '@/tools'
|
|
|
126
|
+import { ElMessage, ElMessageBox } from 'element-plus'
|
|
115
|
127
|
|
|
116
|
|
- // 查询条件
|
|
117
|
|
- queryParams: {
|
|
118
|
|
- material: '',
|
|
119
|
|
- standard: ''
|
|
120
|
|
- },
|
|
|
128
|
+const {
|
|
|
129
|
+ proxy
|
|
|
130
|
+} = getCurrentInstance()
|
|
121
|
131
|
|
|
122
|
|
- // 对话框控制
|
|
123
|
|
- dialogVisible: false,
|
|
|
132
|
+const cardBodyStyle = ref(tools.style.card)
|
|
|
133
|
+const inputStyle = ref(tools.style.input)
|
|
124
|
134
|
|
|
125
|
|
- // 表单数据
|
|
126
|
|
- form: {
|
|
127
|
|
- id: '',
|
|
128
|
|
- materialName: '',
|
|
129
|
|
- materialCode: '',
|
|
130
|
|
- materialStandard: '',
|
|
131
|
|
- materialModel: '',
|
|
132
|
|
- materialAttr1: '',
|
|
133
|
|
- materialAttr2: '',
|
|
134
|
|
- materialAttr3: '',
|
|
135
|
|
- materialAttr4: '',
|
|
136
|
|
- materialAttr5: ''
|
|
137
|
|
- },
|
|
|
135
|
+/**
|
|
|
136
|
+ * 查询相关
|
|
|
137
|
+ */
|
|
|
138
|
+const query = ref({
|
|
|
139
|
+ material: '',
|
|
|
140
|
+ standard: ''
|
|
|
141
|
+})
|
|
138
|
142
|
|
|
139
|
|
- // 表单验证规则
|
|
140
|
|
- rules: {
|
|
141
|
|
- materialName: [
|
|
142
|
|
- { required: true, message: '物料名称不能为空', trigger: 'blur' }
|
|
143
|
|
- ],
|
|
144
|
|
- materialCode: [
|
|
145
|
|
- { required: true, message: '物料编码不能为空', trigger: 'blur' }
|
|
146
|
|
- ],
|
|
147
|
|
- materialStandard: [
|
|
148
|
|
- { required: true, message: '钢种不能为空', trigger: 'blur' }
|
|
149
|
|
- ]
|
|
150
|
|
- },
|
|
|
143
|
+const form = ref({
|
|
|
144
|
+ id: '',
|
|
|
145
|
+ materialName: '',
|
|
|
146
|
+ materialCode: '',
|
|
|
147
|
+ materialStandard: '',
|
|
|
148
|
+ materialModel: '',
|
|
|
149
|
+ materialAttr1: '',
|
|
|
150
|
+ materialAttr2: '',
|
|
|
151
|
+ materialAttr3: '',
|
|
|
152
|
+ materialAttr4: '',
|
|
|
153
|
+ materialAttr5: ''
|
|
|
154
|
+})
|
|
151
|
155
|
|
|
152
|
|
- // 样式
|
|
153
|
|
- cardBodyStyle: {
|
|
154
|
|
- padding: '10px'
|
|
155
|
|
- }
|
|
156
|
|
- }
|
|
157
|
|
- },
|
|
|
156
|
+const tableData = ref([])
|
|
158
|
157
|
|
|
159
|
|
- // 界面渲染完毕调用 - 初始化表格数据
|
|
160
|
|
- mounted() {
|
|
161
|
|
- this.getTableData()
|
|
162
|
|
- },
|
|
163
|
|
-
|
|
164
|
|
- methods: {
|
|
165
|
|
- /**
|
|
166
|
|
- * 获取表格数据
|
|
167
|
|
- */
|
|
168
|
|
- getTableData() {
|
|
169
|
|
- this.loading = true
|
|
170
|
|
- const url = 'sto/Material/query'
|
|
171
|
|
- const params = {
|
|
172
|
|
- page: this.pagination.currentPage,
|
|
173
|
|
- rows: this.pagination.pageSize,
|
|
174
|
|
- material: this.queryParams.material,
|
|
175
|
|
- standard: this.queryParams.standard
|
|
176
|
|
- }
|
|
177
|
|
-
|
|
178
|
|
- axios.get(url, { params })
|
|
179
|
|
- .then(response => {
|
|
180
|
|
- this.loading = false
|
|
181
|
|
- if (response.data.code === '0') {
|
|
182
|
|
- this.tableData = response.data.data.records
|
|
183
|
|
- this.pagination.totalRows = response.data.data.total
|
|
184
|
|
- } else {
|
|
185
|
|
- this.$message.error('查询失败!' + response.data.msg)
|
|
186
|
|
- }
|
|
187
|
|
- })
|
|
188
|
|
- .catch(error => {
|
|
189
|
|
- this.loading = false
|
|
190
|
|
- this.$message.error('查询失败!' + error.message)
|
|
191
|
|
- })
|
|
192
|
|
- },
|
|
|
158
|
+/**
|
|
|
159
|
+ * 分页相关
|
|
|
160
|
+ */
|
|
|
161
|
+const currentPage = ref(1)
|
|
|
162
|
+const totalRows = ref(0)
|
|
|
163
|
+const pageSizes = ref([10, 20, 30, 40])
|
|
|
164
|
+const pageSize = ref(10)
|
|
193
|
165
|
|
|
194
|
|
- /**
|
|
195
|
|
- * 修改每页条数
|
|
196
|
|
- */
|
|
197
|
|
- handleSizeChange(val) {
|
|
198
|
|
- this.pagination.pageSize = val
|
|
199
|
|
- this.pagination.currentPage = 1
|
|
200
|
|
- this.getTableData()
|
|
201
|
|
- },
|
|
|
166
|
+/**
|
|
|
167
|
+ * 对话框相关
|
|
|
168
|
+ */
|
|
|
169
|
+const dialogVisible = ref(false)
|
|
|
170
|
+const dialogTitle = ref('新增物料')
|
|
|
171
|
+const ruleFormRef = ref()
|
|
202
|
172
|
|
|
203
|
|
- /**
|
|
204
|
|
- * 修改当前页
|
|
205
|
|
- */
|
|
206
|
|
- handleCurrentChange(val) {
|
|
207
|
|
- this.pagination.currentPage = val
|
|
208
|
|
- this.getTableData()
|
|
209
|
|
- },
|
|
|
173
|
+const rules = reactive({
|
|
|
174
|
+ materialName: [
|
|
|
175
|
+ {required: true, message: '物料名称不能为空', trigger: 'blur'},
|
|
|
176
|
+ ],
|
|
|
177
|
+ materialCode: [
|
|
|
178
|
+ {required: true, message: '物料编码不能为空', trigger: 'blur'},
|
|
|
179
|
+ ],
|
|
|
180
|
+ materialStandard: [
|
|
|
181
|
+ {required: true, message: '钢种不能为空', trigger: 'blur'},
|
|
|
182
|
+ ]
|
|
|
183
|
+})
|
|
210
|
184
|
|
|
211
|
|
- /**
|
|
212
|
|
- * 查询
|
|
213
|
|
- */
|
|
214
|
|
- handleSearch() {
|
|
215
|
|
- this.pagination.currentPage = 1
|
|
216
|
|
- this.getTableData()
|
|
217
|
|
- },
|
|
|
185
|
+/**
|
|
|
186
|
+ * 方法定义
|
|
|
187
|
+ */
|
|
|
188
|
+const handleSearch = () => {
|
|
|
189
|
+ currentPage.value = 1
|
|
|
190
|
+ getTableData()
|
|
|
191
|
+}
|
|
218
|
192
|
|
|
219
|
|
- /**
|
|
220
|
|
- * 新增
|
|
221
|
|
- */
|
|
222
|
|
- handleAdd() {
|
|
223
|
|
- this.dialogVisible = true
|
|
224
|
|
- this.resetForm()
|
|
225
|
|
- },
|
|
|
193
|
+const handleSizeChange = (val) => {
|
|
|
194
|
+ pageSize.value = val
|
|
|
195
|
+ getTableData()
|
|
|
196
|
+}
|
|
226
|
197
|
|
|
227
|
|
- /**
|
|
228
|
|
- * 编辑
|
|
229
|
|
- */
|
|
230
|
|
- handleEdit(row) {
|
|
231
|
|
- this.dialogVisible = true
|
|
232
|
|
- this.$nextTick(() => {
|
|
233
|
|
- this.form = { ...row }
|
|
234
|
|
- })
|
|
235
|
|
- },
|
|
|
198
|
+const handleCurrentChange = (val) => {
|
|
|
199
|
+ currentPage.value = val
|
|
|
200
|
+ getTableData()
|
|
|
201
|
+}
|
|
236
|
202
|
|
|
237
|
|
- /**
|
|
238
|
|
- * 保存(新增和编辑)
|
|
239
|
|
- */
|
|
240
|
|
- handleSave() {
|
|
241
|
|
- this.$refs.formRef.validate((valid) => {
|
|
242
|
|
- if (!valid) {
|
|
243
|
|
- this.$message.warning('请完善表单信息')
|
|
244
|
|
- return
|
|
245
|
|
- }
|
|
|
203
|
+const insertDialog = () => {
|
|
|
204
|
+ form.value = {
|
|
|
205
|
+ id: '',
|
|
|
206
|
+ materialName: '',
|
|
|
207
|
+ materialCode: '',
|
|
|
208
|
+ materialStandard: '',
|
|
|
209
|
+ materialModel: '',
|
|
|
210
|
+ materialAttr1: '',
|
|
|
211
|
+ materialAttr2: '',
|
|
|
212
|
+ materialAttr3: '',
|
|
|
213
|
+ materialAttr4: '',
|
|
|
214
|
+ materialAttr5: ''
|
|
|
215
|
+ }
|
|
|
216
|
+ dialogTitle.value = '新增物料'
|
|
|
217
|
+ dialogVisible.value = true
|
|
|
218
|
+}
|
|
246
|
219
|
|
|
247
|
|
- const url = 'sto/Material/save'
|
|
248
|
|
- const params = {
|
|
249
|
|
- json: JSON.stringify(this.form)
|
|
|
220
|
+const handleSave = (ruleFormRef) => {
|
|
|
221
|
+ if (!ruleFormRef) return
|
|
|
222
|
+ ruleFormRef.validate((valid) => {
|
|
|
223
|
+ if (valid) {
|
|
|
224
|
+ const url = 'sto/Material/save'
|
|
|
225
|
+ const param = {
|
|
|
226
|
+ json: JSON.stringify(form.value)
|
|
|
227
|
+ }
|
|
|
228
|
+ proxy.$axios.post(url, param).then(response => {
|
|
|
229
|
+ if (response.data.code == 0) {
|
|
|
230
|
+ ElMessage({
|
|
|
231
|
+ message: '保存成功',
|
|
|
232
|
+ type: 'success',
|
|
|
233
|
+ })
|
|
|
234
|
+ dialogVisible.value = false
|
|
|
235
|
+ handleSearch()
|
|
|
236
|
+ } else {
|
|
|
237
|
+ ElMessage({
|
|
|
238
|
+ type: 'error',
|
|
|
239
|
+ message: '操作失败: ' + response.data.msg
|
|
|
240
|
+ })
|
|
250
|
241
|
}
|
|
251
|
|
-
|
|
252
|
|
- axios.post(url, params)
|
|
253
|
|
- .then(response => {
|
|
254
|
|
- if (response.data.code === '0') {
|
|
255
|
|
- this.$message.success(this.form.id ? '更新成功' : '新增成功')
|
|
256
|
|
- this.dialogVisible = false
|
|
257
|
|
- this.getTableData()
|
|
258
|
|
- } else {
|
|
259
|
|
- this.$message.error('操作失败!' + response.data.msg)
|
|
260
|
|
- }
|
|
261
|
|
- })
|
|
262
|
|
- .catch(error => {
|
|
263
|
|
- this.$message.error('操作失败!' + error.message)
|
|
264
|
|
- })
|
|
265
|
242
|
})
|
|
266
|
|
- },
|
|
|
243
|
+ }
|
|
|
244
|
+ })
|
|
|
245
|
+}
|
|
267
|
246
|
|
|
268
|
|
- /**
|
|
269
|
|
- * 取消保存
|
|
270
|
|
- */
|
|
271
|
|
- handleCancelSave() {
|
|
272
|
|
- this.dialogVisible = false
|
|
273
|
|
- this.resetForm()
|
|
274
|
|
- },
|
|
|
247
|
+const handleCancelSave = () => {
|
|
|
248
|
+ dialogVisible.value = false
|
|
|
249
|
+}
|
|
275
|
250
|
|
|
276
|
|
- /**
|
|
277
|
|
- * 删除
|
|
278
|
|
- */
|
|
279
|
|
- handleDelete(row) {
|
|
280
|
|
- this.$confirm(
|
|
281
|
|
- `确定删除物料 "${row.materialName}" 吗?`,
|
|
282
|
|
- '提示',
|
|
283
|
|
- {
|
|
284
|
|
- confirmButtonText: '确认',
|
|
285
|
|
- cancelButtonText: '取消',
|
|
286
|
|
- type: 'warning',
|
|
287
|
|
- draggable: true,
|
|
288
|
|
- }
|
|
289
|
|
- )
|
|
290
|
|
- .then(() => {
|
|
291
|
|
- const url = 'sto/Material/remove'
|
|
292
|
|
- const params = {
|
|
293
|
|
- id: row.id,
|
|
294
|
|
- }
|
|
|
251
|
+const handleEdit = (row) => {
|
|
|
252
|
+ const url = 'sto/Material/queryByPK'
|
|
|
253
|
+ const param = {
|
|
|
254
|
+ id: row.id
|
|
|
255
|
+ }
|
|
|
256
|
+ proxy.$axios.get(url, param).then(response => {
|
|
|
257
|
+ if (response.data.code == '0') {
|
|
|
258
|
+ form.value = response.data.data
|
|
|
259
|
+ dialogTitle.value = '编辑物料'
|
|
|
260
|
+ dialogVisible.value = true
|
|
|
261
|
+ } else {
|
|
|
262
|
+ ElMessage.error('操作失败!' + response.data.msg)
|
|
|
263
|
+ }
|
|
|
264
|
+ })
|
|
|
265
|
+}
|
|
295
|
266
|
|
|
296
|
|
- axios.post(url, params)
|
|
297
|
|
- .then(response => {
|
|
298
|
|
- if (response.data.code === '0') {
|
|
299
|
|
- this.$message.success('删除成功!')
|
|
300
|
|
- this.getTableData()
|
|
301
|
|
- } else {
|
|
302
|
|
- this.$message.error('删除失败!' + response.data.msg)
|
|
303
|
|
- }
|
|
304
|
|
- })
|
|
305
|
|
- .catch(error => {
|
|
306
|
|
- this.$message.error('删除失败!' + error.message)
|
|
307
|
|
- })
|
|
308
|
|
- })
|
|
309
|
|
- .catch(() => {
|
|
310
|
|
- this.$message.info('已取消删除')
|
|
311
|
|
- })
|
|
312
|
|
- },
|
|
|
267
|
+const handleRemove = (row) => {
|
|
|
268
|
+ ElMessageBox.confirm(
|
|
|
269
|
+ `确定删除物料 "${row.materialName}" 吗?`,
|
|
|
270
|
+ '提示', {
|
|
|
271
|
+ confirmButtonText: '确认',
|
|
|
272
|
+ cancelButtonText: '取消',
|
|
|
273
|
+ type: 'warning',
|
|
|
274
|
+ draggable: true,
|
|
|
275
|
+ }
|
|
|
276
|
+ ).then(() => {
|
|
|
277
|
+ const url = 'sto/Material/remove'
|
|
|
278
|
+ const param = {
|
|
|
279
|
+ id: row.id
|
|
|
280
|
+ }
|
|
|
281
|
+ proxy.$axios.get(url, param).then(response => {
|
|
|
282
|
+ if (response.data.code == '0') {
|
|
|
283
|
+ ElMessage({
|
|
|
284
|
+ type: 'success',
|
|
|
285
|
+ message: '删除成功!',
|
|
|
286
|
+ })
|
|
|
287
|
+ getTableData()
|
|
|
288
|
+ } else {
|
|
|
289
|
+ ElMessage.error('操作失败!' + response.data.msg)
|
|
|
290
|
+ }
|
|
|
291
|
+ })
|
|
|
292
|
+ }).catch(() => {
|
|
|
293
|
+ ElMessage({
|
|
|
294
|
+ type: 'info',
|
|
|
295
|
+ message: '已取消',
|
|
|
296
|
+ })
|
|
|
297
|
+ })
|
|
|
298
|
+}
|
|
313
|
299
|
|
|
|
300
|
+const handleSelectionChange = (val) => {
|
|
|
301
|
+ multipleSelection.value = val
|
|
|
302
|
+}
|
|
314
|
303
|
|
|
315
|
|
- /**
|
|
316
|
|
- * 重置表单
|
|
317
|
|
- */
|
|
318
|
|
- resetForm() {
|
|
319
|
|
- this.$nextTick(() => {
|
|
320
|
|
- if (this.$refs.formRef) {
|
|
321
|
|
- this.$refs.formRef.resetFields()
|
|
322
|
|
- }
|
|
323
|
|
- this.form = {
|
|
324
|
|
- id: '',
|
|
325
|
|
- materialName: '',
|
|
326
|
|
- materialCode: '',
|
|
327
|
|
- materialStandard: '',
|
|
328
|
|
- materialModel: '',
|
|
329
|
|
- materialAttr1: '',
|
|
330
|
|
- materialAttr2: '',
|
|
331
|
|
- materialAttr3: '',
|
|
332
|
|
- materialAttr4: '',
|
|
333
|
|
- materialAttr5: ''
|
|
334
|
|
- }
|
|
335
|
|
- })
|
|
336
|
|
- }
|
|
|
304
|
+const getTableData = () => {
|
|
|
305
|
+ const url = 'sto/Material/query'
|
|
|
306
|
+ const param = {
|
|
|
307
|
+ page: currentPage.value,
|
|
|
308
|
+ rows: pageSize.value,
|
|
|
309
|
+ material: query.value.material,
|
|
|
310
|
+ standard: query.value.standard
|
|
337
|
311
|
}
|
|
|
312
|
+ proxy.$axios.get(url, param).then(response => {
|
|
|
313
|
+ if (response.data.code == '0') {
|
|
|
314
|
+ tableData.value = response.data.data.records
|
|
|
315
|
+ totalRows.value = response.data.data.total
|
|
|
316
|
+ } else {
|
|
|
317
|
+ ElMessage.error('操作失败!' + response.data.msg)
|
|
|
318
|
+ }
|
|
|
319
|
+ })
|
|
|
320
|
+}
|
|
|
321
|
+
|
|
|
322
|
+const height = ref(600)
|
|
|
323
|
+const updateViewportHeight = () => {
|
|
|
324
|
+ height.value = window.innerHeight * 0.65
|
|
338
|
325
|
}
|
|
|
326
|
+
|
|
|
327
|
+const multipleSelection = ref([])
|
|
|
328
|
+
|
|
|
329
|
+onMounted(() => {
|
|
|
330
|
+ getTableData()
|
|
|
331
|
+ updateViewportHeight()
|
|
|
332
|
+ window.addEventListener('resize', updateViewportHeight)
|
|
|
333
|
+})
|
|
339
|
334
|
</script>
|
|
340
|
335
|
|
|
341
|
336
|
<style scoped>
|
|
342
|
|
-.no-show-error-message {
|
|
343
|
|
- margin-bottom: 0;
|
|
|
337
|
+::v-deep .diaClass .el-form-item {
|
|
|
338
|
+ width: 100%
|
|
344
|
339
|
}
|
|
345
|
|
-
|
|
346
|
|
-.dialog-footer {
|
|
347
|
|
- text-align: center;
|
|
|
340
|
+::v-deep .el-dialog__body {
|
|
|
341
|
+ background-color: #F2F6FC;
|
|
348
|
342
|
}
|
|
349
|
343
|
</style>
|