GoodsBox.vue
5.24 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
<template>
<el-dialog title="选择产品" :close-on-click-modal="false" :visible.sync="visible"
class="NCC-dialog NCC-dialog_center" lock-scroll append-to-body width="1000px">
<div class="NCC-common-layout">
<div class="NCC-common-layout-left">
<el-scrollbar class="NCC-common-el-tree-scrollbar">
<el-tree ref="treeBox" v-loading="treeLoading"
:element-loading-text="$t('common.loadingText')" :data="treeData" :props="defaultProps"
default-expand-all highlight-current :expand-on-click-node="false" node-key="id"
@node-click="handleNodeClick" class="NCC-common-el-tree">
<span class="custom-tree-node" slot-scope="{ node }">
<i class="el-icon-notebook-2" />
<span class="text">{{node.label}}</span>
</span>
</el-tree>
</el-scrollbar>
</div>
<div class="NCC-common-layout-center">
<el-row class="NCC-common-search-box" :gutter="16">
<el-form @submit.native.prevent>
<el-col :span="6">
<el-form-item label="产品编号">
<el-input v-model="query.code" placeholder="请输入" clearable />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="产品名称">
<el-input v-model="query.fullName" placeholder="请输入" clearable />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="search()">查询</el-button>
<el-button icon="el-icon-refresh-right" @click="reset()">重置</el-button>
</el-form-item>
</el-col>
</el-form>
<div class="NCC-common-search-box-right">
<el-tooltip effect="dark" content="刷新" placement="top">
<el-link icon="icon-ym icon-ym-Refresh NCC-common-head-icon" :underline="false"
@click="refresh()" />
</el-tooltip>
</div>
</el-row>
<div class="NCC-common-layout-main NCC-flex-main">
<NCC-table v-loading="listLoading" :data="list" hasC
@selection-change="handleSelectionChange" :border="false">
<el-table-column prop="code" label="产品编码" />
<el-table-column prop="fullName" label="产品名称" />
<el-table-column prop="qty" label="库存" />
</NCC-table>
<pagination :total="total" :page.sync="listQuery.currentPage"
:limit.sync="listQuery.pageSize" @pagination="getGoodsList" />
</div>
</div>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false">{{$t('common.cancelButton')}}</el-button>
<el-button type="primary" @click="select()">{{$t('common.confirmButton')}}</el-button>
</span>
</el-dialog>
</template>
<script>
import { getGoodsList, getProductClassify } from '@/api/extend/saleOrder'
export default {
data() {
return {
defaultProps: {
children: 'children',
label: 'fullName'
},
treeLoading: false,
treeData: [],
visible: false,
listLoading: true,
query: {
classifyId: '',
code: '',
fullName: '',
},
listQuery: {
currentPage: 1,
pageSize: 20,
sort: 'desc',
sidx: ''
},
list: [],
total: 0,
checked: []
}
},
methods: {
init() {
this.visible = true
this.listLoading = true
this.getProductClassify()
},
getProductClassify() {
this.treeLoading = true
getProductClassify().then(res => {
this.treeData = res.data.list
this.$nextTick(() => {
this.query.classifyId = this.treeData[0].children[0].id
this.$refs.treeBox.setCurrentKey(this.query.classifyId)
this.treeLoading = false
this.getGoodsList()
})
})
},
getGoodsList() {
this.listLoading = true
const query = {
...this.listQuery,
...this.query
}
getGoodsList(query).then(res => {
this.list = res.data.list
this.total = res.data.pagination.total
this.listLoading = false
})
},
handleNodeClick(data) {
if (this.query.classifyId === data.id) return
this.query.classifyId = data.id
this.reset()
},
search() {
this.listQuery = {
currentPage: 1,
pageSize: 20,
sort: 'desc',
sidx: ''
}
this.getGoodsList()
},
refresh() {
this.getGoodsList()
},
select() {
if (!this.checked.length) return
this.visible = false
this.$emit('choice', this.checked)
},
handleSelectionChange(val) {
this.checked = val
},
reset() {
this.query.code = ''
this.query.fullName = ''
this.search()
}
}
}
</script>
<style lang="scss" scoped>
>>> .el-dialog__body {
height: 60vh;
padding: 0 0 10px !important;
display: flex;
flex-direction: column;
overflow: hidden;
.NCC-common-layout-left {
margin-right: 1px;
}
.NCC-common-search-box {
margin-bottom: 0;
.NCC-common-search-box-right {
padding: 10px 10px 0 0;
}
}
}
</style>