material.vue
9.92 KB
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
<template>
<d2-container>
<el-card shadow="never">
<el-form :inline="true" :model="formInline" class="demo-form-inline" size="small">
<el-form-item label="物料名称:">
<el-input v-model="formInline.materialName"></el-input>
</el-form-item>
<el-form-item label="物料编码:">
<el-input v-model="formInline.materialCode"></el-input>
</el-form-item>
<el-form-item label="物料类别:">
<el-select v-model="formInline.materialType" placeholder="请选择">
<el-option value="" label="全部">全部</el-option>
<el-option v-for="(item,index) in materialList" :key="index" :value="item.materialType" :label="item.materialTypeName"></el-option>
<!-- <el-option value="1">硬件</el-option>
<el-option value="2">安装服务</el-option>
<el-option value="3">运营服务</el-option>
<el-option value="4">软件</el-option>
<el-option value="5">原材料</el-option>
<el-option value="6">配件</el-option>
<el-option value="7">其他</el-option> -->
</el-select>
</el-form-item>
<el-form-item label="设备类型:">
<el-select v-model="formInline.deviceTypeId" placeholder="请选择">
<el-option value="" label="全部">全部</el-option>
<el-option v-for="(item,index) in deviceList" :key="index" :value="item.id" :label="item.name"></el-option>
<!-- <el-option value="1">导航</el-option>
<el-option value="2">后视镜</el-option>
<el-option value="3">记录仪</el-option>
<el-option value="4">OBD</el-option>
<el-option value="5">记录仪</el-option>
<el-option value="6">GPS</el-option>
<el-option value="7">车充</el-option>
<el-option value="8">电子辅助</el-option> -->
</el-select>
</el-form-item>
<el-form-item label="是否扫码:">
<el-select v-model="formInline.deviceScanType" placeholder="请选择">
<el-option value="" label="全部">全部</el-option>
<el-option value="Y" label="是"></el-option>
<el-option value="N" label="否"></el-option>
</el-select>
</el-form-item>
<el-form-item label="创建人:">
<el-input v-model="formInline.createdBy"></el-input>
</el-form-item>
<el-form-item>
<el-button type="success" plain icon="el-icon-search" :loading="tableLoading" @click="getList()">搜索</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-refresh" plain @click="rest()">重置</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-download" :loading="exportLoading" @click="exportInfo()">导出</el-button>
</el-form-item>
</el-form>
</el-card>
<!-- 按钮区域 开始 -->
<div class="search_links_box">
<el-button type="success" plain size="small" icon="el-icon-plus" class="" @click="openDialog()">新增物料</el-button>
</div>
<!-- 按钮区域 end -->
<!-- 表格区域 开始 -->
<div class="table_box">
<el-table class="el_table" v-loading="tableLoading" :data="tableData" stripe style="width: 100%" size="small" border>
<el-table-column prop="materialCode" label="物料编码" show-overflow-tooltip />
<el-table-column prop="materialName" label="物料名称" show-overflow-tooltip />
<el-table-column prop="materialTypeName" label="物料类别" show-overflow-tooltip />
<el-table-column prop="deviceTypeName" label="设备类型" show-overflow-tooltip />
<el-table-column prop="deviceScanType" label="是否扫码" show-overflow-tooltip>
<template slot-scope="scope">{{SCANTYPELIST[scope.row.deviceScanType]}}</template>
</el-table-column>
<el-table-column prop="firstLevelName" label="归属物料大类" show-overflow-tooltip />
<el-table-column prop="createdBy" label="创建人" show-overflow-tooltip />
<!-- <el-table-column prop="saleSum" label="操作" width="80">
<template slot-scope="scope">
<el-button type="success" plain size="mini" @click="openDialog(scope.row.operateCode)">修改</el-button>
</template>
</el-table-column> -->
</el-table>
<div class="pagination_list">
<el-pagination background layout="sizes, total,prev, pager, next, jumper" :total="pageTotal" :page-size="pageSize" :page-sizes="pageSizes" @current-change="getList" @size-change="changePageSize" />
</div>
</div>
<!-- 表格区域 end -->
<!-- 弹框 开始 -->
<glsx-dialog :show="showDialog" :title="currentId?'修改物料':'新建物料'" width="600px" @closed="close">
<div>
<!-- <add-config ref="addConfigComponent" :id="currentId" v-if="showDialog" @change="onChange" /> -->
<add-material ref="addMaterialComponent" v-if="showDialog" @change="onChange"></add-material>
</div>
<div slot="footer">
<el-button type="success" size="small" @click="submit" :loading="ajaxLoading">确认</el-button>
<el-button type="default" size="small" @click="close">取消</el-button>
</div>
</glsx-dialog>
<!-- 弹框 end -->
</d2-container>
</template>
<script>
import { PAGEMATERIALINFO, PAGEKCWAREHOUSE, EXPORTMATERIALINFO } from '@/http/interface'
import {
GETJXCCOMMONLISTMATERIALTYPE,
GETJXCCOMMONLISTDEVICETYPE,
} from '@/http/public'
import GlsxDialog from '@/components/dialog/index'
import AddMaterial from './addMaterial'
export default {
components: {
GlsxDialog,
AddMaterial,
},
data() {
return {
formInline: {},
tableData: [],
tableLoading: false,
pageTotal: 0,
currentPage: 1,
pageSizes: [10, 20, 30, 40],
pageSize: 10,
tdWidth: 170,
longWidth: 300,
exportLoading: false,
showServiceList: [],
serviceList: [],
showDialog: false,
currentId: '',
ajaxLoading: false,
SCANTYPELIST: {
Y: '是',
N: '否',
},
materialList: [],
deviceList: [],
}
},
created() {},
mounted: function () {
this.getList()
this.getService()
this.getMaterial()
this.getDevice()
},
methods: {
/**
* 查询列表
*/
getList: function (current) {
const _this = this
const oParams = _this.getParams()
console.log(current)
oParams.pageNum = current || _this.currentPage
_this.tableLoading = true
PAGEMATERIALINFO(oParams).then((res) => {
console.log(res)
_this.tableLoading = false
if (res.returnCode == 0) {
let data = res.data || {}
let total = data.total || ''
let list = data.list || []
_this.tableData = list || []
_this.pageTotal = total || ''
}
})
},
/**
* 获取查询参数
*/
getParams: function () {
let _this = this;
const oParams = JSON.parse(JSON.stringify(_this.formInline))
if (oParams.materialCode) {
oParams.materialName = oParams.materialCode
};
oParams.pageSize = this.pageSize
return oParams
},
/**
* 每页展示
*/
changePageSize: function (e) {
this.pageSize = e
this.getList()
},
/**
* 导出列表
*/
exportInfo: function () {
const _this = this
const oParams = _this.getParams()
_this.exportLoading = true
EXPORTMATERIALINFO(oParams)
.then((res) => {
_this.exportLoading = false
})
.catch((error) => {
_this.exportLoading = false
})
},
/** 获取服务商列表 */
getService: function () {
let _this = this
let oParams = {}
oParams.pageNum = 1
oParams.pageSize = 999999
PAGEKCWAREHOUSE(oParams).then((res) => {
console.log(res)
if (res.returnCode != 0) {
return false
}
let _obj = res.data
let _list = _obj.list || []
_this.showServiceList = _list.slice(0, 31)
_this.serviceList = _list
})
},
/** 本地搜索服务商 */
onSearch: function (e) {
console.log(e)
let list = JSON.parse(JSON.stringify(this.serviceList))
let n = list.filter((k) => {
let m =
k.merchantName.indexOf(e) > -1 ||
k.merchantCode.toLocaleLowerCase().indexOf(e.toLocaleLowerCase()) > -1
console.log(m)
return m
})
console.log(n)
this.showServiceList = n || []
},
/** 打开弹框 */
openDialog: function (e) {
console.log(e)
this.showDialog = true
this.currentId = e || ''
},
/** 关闭弹框 */
close: function () {
this.showDialog = false
this.currentId = ''
},
/** 保存数据 */
submit: function () {
this.ajaxLoading = true
this.$refs.addMaterialComponent.submit()
},
/** 监听组件 */
onChange: function (e) {
this.ajaxLoading = false
if (e) {
this.close()
this.getList()
}
},
/** 显示物料数量 */
showTotal: function (row, id) {
let list = row || []
let o = list.find((k) => k.typeFlag == id)
let m = ''
m = o ? o.materialCode + '/' + o.materialName + ':' + o.total : ''
return m
},
// 获取物料类型
getMaterial: function () {
let _this = this
GETJXCCOMMONLISTMATERIALTYPE().then((res) => {
_this.materialList = res.data || []
})
},
// 获取设备类型
getDevice: function () {
let _this = this
GETJXCCOMMONLISTDEVICETYPE().then((res) => {
_this.deviceList = res.data || []
})
},
// 重置
rest: function () {
this.formInline = {}
this.getList()
},
},
}
</script>
<style lang="scss" scoped>
.table_box {
margin: 10px 0;
}
</style>