|
|
|
|
@ -32,7 +32,7 @@
|
|
|
|
|
<el-table
|
|
|
|
|
ref="materialTable"
|
|
|
|
|
v-loading="loading"
|
|
|
|
|
:data="displayList"
|
|
|
|
|
:data="materialList"
|
|
|
|
|
height="420"
|
|
|
|
|
border
|
|
|
|
|
highlight-current-row
|
|
|
|
|
@ -53,7 +53,19 @@
|
|
|
|
|
</el-table>
|
|
|
|
|
|
|
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
|
|
<span style="float: left; color: #909399;">共 {{ displayList.length }} 条</span>
|
|
|
|
|
<span style="float: left; color: #909399;">共 {{ total }} 条</span>
|
|
|
|
|
<el-pagination
|
|
|
|
|
v-show="total > 0"
|
|
|
|
|
style="display: inline-block; margin-right: 12px;"
|
|
|
|
|
background
|
|
|
|
|
small
|
|
|
|
|
:current-page.sync="queryParams.pageNum"
|
|
|
|
|
:page-size.sync="queryParams.pageSize"
|
|
|
|
|
layout="prev, pager, next"
|
|
|
|
|
:total="total"
|
|
|
|
|
@current-change="getList"
|
|
|
|
|
@size-change="getList"
|
|
|
|
|
/>
|
|
|
|
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
|
|
|
|
<el-button type="primary" @click="handleConfirm">确 定</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
@ -61,7 +73,7 @@
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import { listAllMaterialInfo } from '@/api/base/materialInfo'
|
|
|
|
|
import { listMaterialInfo } from '@/api/base/materialInfo'
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: 'MaterialSelector',
|
|
|
|
|
@ -78,13 +90,14 @@ export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
loading: false,
|
|
|
|
|
loaded: false,
|
|
|
|
|
total: 0,
|
|
|
|
|
queryParams: {
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
materialCode: '',
|
|
|
|
|
materialName: ''
|
|
|
|
|
},
|
|
|
|
|
materialList: [],
|
|
|
|
|
displayList: [],
|
|
|
|
|
currentRow: null
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
@ -101,38 +114,35 @@ export default {
|
|
|
|
|
methods: {
|
|
|
|
|
handleOpen() {
|
|
|
|
|
this.resetQuery()
|
|
|
|
|
if (!this.loaded) {
|
|
|
|
|
this.loadMaterialList()
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.syncCurrentSelection()
|
|
|
|
|
},
|
|
|
|
|
loadMaterialList() {
|
|
|
|
|
getList() {
|
|
|
|
|
this.loading = true
|
|
|
|
|
listAllMaterialInfo()
|
|
|
|
|
listMaterialInfo(this.queryParams)
|
|
|
|
|
.then(response => {
|
|
|
|
|
this.materialList = response.data || []
|
|
|
|
|
this.loaded = true
|
|
|
|
|
const data = response && response.data ? response.data : response
|
|
|
|
|
this.materialList = data && data.rows ? data.rows : []
|
|
|
|
|
this.total = data && data.total ? data.total : this.materialList.length
|
|
|
|
|
this.syncCurrentSelection()
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
this.materialList = []
|
|
|
|
|
this.total = 0
|
|
|
|
|
this.currentRow = null
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
this.loading = false
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleQuery() {
|
|
|
|
|
const codeKeyword = (this.queryParams.materialCode || '').trim().toLowerCase()
|
|
|
|
|
const nameKeyword = (this.queryParams.materialName || '').trim().toLowerCase()
|
|
|
|
|
this.displayList = this.materialList.filter(item => {
|
|
|
|
|
const materialCode = (item.materialCode || '').toLowerCase()
|
|
|
|
|
const materialName = (item.materialName || '').toLowerCase()
|
|
|
|
|
return materialCode.includes(codeKeyword) && materialName.includes(nameKeyword)
|
|
|
|
|
})
|
|
|
|
|
this.syncCurrentSelection()
|
|
|
|
|
this.queryParams.pageNum = 1
|
|
|
|
|
this.getList()
|
|
|
|
|
},
|
|
|
|
|
resetQuery() {
|
|
|
|
|
this.queryParams.pageNum = 1
|
|
|
|
|
this.queryParams.pageSize = 10
|
|
|
|
|
this.queryParams.materialCode = ''
|
|
|
|
|
this.queryParams.materialName = ''
|
|
|
|
|
this.handleQuery()
|
|
|
|
|
this.getList()
|
|
|
|
|
},
|
|
|
|
|
handleCurrentChange(row) {
|
|
|
|
|
this.currentRow = row
|
|
|
|
|
@ -150,7 +160,7 @@ export default {
|
|
|
|
|
this.dialogVisible = false
|
|
|
|
|
},
|
|
|
|
|
syncCurrentSelection() {
|
|
|
|
|
this.currentRow = this.displayList.find(item => item.materialCode === this.selectedMaterialCode) || null
|
|
|
|
|
this.currentRow = this.materialList.find(item => item.materialCode === this.selectedMaterialCode) || null
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
if (this.$refs.materialTable) {
|
|
|
|
|
this.$refs.materialTable.setCurrentRow(this.currentRow || null)
|
|
|
|
|
|