|
|
@@ -15,13 +15,13 @@
|
|
|
<el-row>
|
|
|
<el-col :span="6">
|
|
|
<el-input
|
|
|
- v-model="searchKey"
|
|
|
- placeholder="输入设备编码或名称"
|
|
|
+ v-model="code"
|
|
|
+ placeholder="请输入产品编码"
|
|
|
size="small"
|
|
|
></el-input>
|
|
|
</el-col>
|
|
|
<el-col :span="6" style="margin-left:10px">
|
|
|
- <el-button type="primary" size="small" @click="searchByKeyWords">搜索</el-button>
|
|
|
+ <el-button type="primary" size="small" @click="reload">搜索</el-button>
|
|
|
<el-button size="small" @click="reset">重置</el-button>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
@@ -30,39 +30,22 @@
|
|
|
<el-col :span="6" class="tree_col">
|
|
|
<AssetTree
|
|
|
@handleNodeClick="handleNodeClick"
|
|
|
- @setRootId="setRootId"
|
|
|
- :type="'5'"
|
|
|
+ id="9"
|
|
|
:paramsType="'type'"
|
|
|
ref="treeList"
|
|
|
/>
|
|
|
</el-col>
|
|
|
- <el-col :span="18" class="table_col">
|
|
|
- <el-table
|
|
|
- :data="tableData"
|
|
|
- height="450"
|
|
|
- highlight-current-row
|
|
|
- @current-change="handleCurrentChange"
|
|
|
- >
|
|
|
- <el-table-column label="物品编码" prop="code" width="200"></el-table-column>
|
|
|
- <el-table-column label="物品名称" prop="name"></el-table-column>
|
|
|
- <el-table-column label="牌号" prop="classificationUrl"></el-table-column>
|
|
|
- <el-table-column label="型号" prop="specification">>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column type='selection' width="55"></el-table-column>
|
|
|
- </el-table>
|
|
|
- <div class="pagination">
|
|
|
- <el-pagination
|
|
|
- background
|
|
|
- layout="total, sizes, prev, pager, next, jumper"
|
|
|
- :total="pagination.total"
|
|
|
- :page-sizes="[5, 10, 20, 50, 100]"
|
|
|
- :page-size="pagination.size"
|
|
|
- :current-page.sync="pagination.page"
|
|
|
- @current-change="handleCurrent"
|
|
|
- @size-change="handleSize"
|
|
|
- >
|
|
|
- </el-pagination>
|
|
|
- </div>
|
|
|
+ <el-col :span="18" class="table_col">
|
|
|
+ <ele-pro-table
|
|
|
+ ref="equiTable"
|
|
|
+ :columns="columns"
|
|
|
+ :datasource="datasource"
|
|
|
+ :selection.sync="selection"
|
|
|
+ cache-key="systemRoleTable"
|
|
|
+ row-key="id"
|
|
|
+ @done="setSelect"
|
|
|
+ >
|
|
|
+ </ele-pro-table>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</div>
|
|
|
@@ -75,196 +58,123 @@
|
|
|
|
|
|
<script>
|
|
|
import AssetTree from '@/components/AssetTree';
|
|
|
+ import { getList } from '@/api/classifyManage/itemInformation';
|
|
|
export default {
|
|
|
components: {
|
|
|
AssetTree
|
|
|
},
|
|
|
+ props: {
|
|
|
+ selectList:Array,
|
|
|
+ },
|
|
|
data () {
|
|
|
return {
|
|
|
- equipmentdialog: false,
|
|
|
- defaultExpandedKeys: [],
|
|
|
- tableData: [],
|
|
|
- currentTreeData: {},
|
|
|
- params: {},
|
|
|
- selectedRow: {},
|
|
|
- pagination: {
|
|
|
- page: 1,
|
|
|
- size: 10,
|
|
|
- total: 0
|
|
|
- },
|
|
|
- searchKey:null,
|
|
|
- ids:[],
|
|
|
- treeData:[],
|
|
|
- requestApi: null,
|
|
|
-
|
|
|
- current:null,
|
|
|
- rootId:null
|
|
|
+ equipmentdialog: false,
|
|
|
+ columns: [
|
|
|
+ {
|
|
|
+ width: 45,
|
|
|
+ type: 'selection',
|
|
|
+ columnKey: 'selection',
|
|
|
+ align: 'center',
|
|
|
+ reserveSelection: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ columnKey: 'index',
|
|
|
+ label: '序号',
|
|
|
+ type: 'index',
|
|
|
+ width: 55,
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'code',
|
|
|
+ label: '物品编码',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 110,
|
|
|
+ slot: 'code'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'name',
|
|
|
+ label: '物品名称',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 110
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'brandNum',
|
|
|
+ label: '牌号',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 110
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'modelType',
|
|
|
+ label: '型号',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 110
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ tableList:[],
|
|
|
+ categoryLevelId:null,
|
|
|
+ code:null,
|
|
|
+ selection:[]
|
|
|
}
|
|
|
},
|
|
|
- // components: { vTreeList },
|
|
|
+
|
|
|
watch: {
|
|
|
- // equipmentdialog (val) {
|
|
|
- // if (val) {
|
|
|
- // this.$nextTick(() => {
|
|
|
- // const treeList = this.$refs.commonTree.treeList
|
|
|
- // this.defaultExpandedKeys = [treeList[0].id]
|
|
|
- // this.handleNodeClick(treeList[0])
|
|
|
- // })
|
|
|
- // }
|
|
|
- // }
|
|
|
+
|
|
|
},
|
|
|
methods: {
|
|
|
+ async datasource ({ page, limit }) {
|
|
|
+ const params = {
|
|
|
+ code:this.code,
|
|
|
+ pageNum: page,
|
|
|
+ size: limit,
|
|
|
+ categoryLevelId: this.categoryLevelId
|
|
|
+ }
|
|
|
+ const data = await getList(params)
|
|
|
+ this.tableList = data.list
|
|
|
+ return data
|
|
|
+ },
|
|
|
open(){
|
|
|
this.equipmentdialog = true
|
|
|
+ this.setSelect()
|
|
|
},
|
|
|
- handleNodeClick (info) {
|
|
|
- this.current = info
|
|
|
+ handleNodeClick (data) {
|
|
|
+ this.categoryLevelId = data.id;
|
|
|
+ this.reload();
|
|
|
},
|
|
|
- // 获取根节点id
|
|
|
- setRootId(id){
|
|
|
- this.rootId = id
|
|
|
+ reload () {
|
|
|
+ this.$refs.equiTable.reload();
|
|
|
},
|
|
|
-
|
|
|
-
|
|
|
handleClose () {
|
|
|
this.equipmentdialog = false
|
|
|
+ this.$refs.equiTable.clearSelection()
|
|
|
},
|
|
|
+ reset(){
|
|
|
+ this.code = null
|
|
|
+ this.reload()
|
|
|
+ },
|
|
|
+ // 设置选中
|
|
|
+ setSelect(){
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.tableList.forEach(row => {
|
|
|
+ this.selectList.forEach(selected => {
|
|
|
+ if (selected.productCode === row.code) {
|
|
|
+ this.$refs.equiTable.toggleRowSelection(row, true)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 选择
|
|
|
+ selected(){
|
|
|
+ this.$emit('choose',this.selection)
|
|
|
+ this.handleClose()
|
|
|
+ }
|
|
|
|
|
|
- handleCurrent (page) {
|
|
|
- this.pagination.page = page
|
|
|
- this._getList(this.params)
|
|
|
- },
|
|
|
- handleSize (size) {
|
|
|
- this.pagination.page = 1
|
|
|
- this.pagination.size = size
|
|
|
- this._getList(this.params)
|
|
|
- },
|
|
|
-
|
|
|
- // 树点击事件
|
|
|
- // handleNodeClick (data, node) {
|
|
|
- // // 只点击叶子节点请求表格数据
|
|
|
- // if (data.id === this.currentTreeData.id) return
|
|
|
- // if(data.children){
|
|
|
- // this.ids = []
|
|
|
- // this.treeData = []
|
|
|
- // this._getTreeDataId(data)
|
|
|
- // }else{
|
|
|
- // this.ids = [data.id]
|
|
|
- // }
|
|
|
- // // if (this.currentTreeData.id === data.id || data.children) return
|
|
|
- // // this.params = { classificationIdList: [data.id] }
|
|
|
- // this.currentTreeData = data
|
|
|
- // this.params = { classificationId: parseInt(this.currentTreeData.id) }
|
|
|
- // this._getList(this.params)
|
|
|
- // },
|
|
|
-
|
|
|
- // 封装递归获取树id
|
|
|
- _getTreeDataId (tree) {
|
|
|
- let data = tree
|
|
|
- data.children.map(item => {
|
|
|
- if (item.children) {
|
|
|
- let tempChildren = []
|
|
|
- tempChildren = Array.from(item.children)
|
|
|
- this.treeData.push(data, ...tempChildren)
|
|
|
- }
|
|
|
- if (!item.children) {
|
|
|
- this.treeData.push(data, item)
|
|
|
- }
|
|
|
- })
|
|
|
- for (let i = 0; i < this.treeData.length; i++) {
|
|
|
- if (this.treeData[i].id) {
|
|
|
- this.ids.push(this.treeData[i].id)
|
|
|
- }
|
|
|
- }
|
|
|
- this.ids = [...new Set(this.ids)]
|
|
|
- },
|
|
|
-
|
|
|
-
|
|
|
- // 封装 - 获取设备列表数据
|
|
|
- async _getList (params) {
|
|
|
- const pageParams = {
|
|
|
- page: this.pagination.page,
|
|
|
- size: this.pagination.size
|
|
|
- }
|
|
|
- let res = await getAssetsList(pageParams, params)
|
|
|
- // console.log(res)
|
|
|
- this.tableLoading = false
|
|
|
- if (res.success) {
|
|
|
- this.tableData = res.data.records
|
|
|
- this.pagination.total = res.data.total
|
|
|
- } else {
|
|
|
- this.$message.error(res.code)
|
|
|
- }
|
|
|
- // switch (this.currentTreeData.parentName) {
|
|
|
- // case '生产设备':
|
|
|
- // this.requestApi = getList
|
|
|
- // break;
|
|
|
- // case '舟皿':
|
|
|
- // this.requestApi = getBoatList
|
|
|
- // break;
|
|
|
- // case '周转车':
|
|
|
- // this.requestApi = getTurnoverCarList
|
|
|
- // break;
|
|
|
- // case '模具':
|
|
|
- // this.requestApi = getMouldList
|
|
|
- // break;
|
|
|
- // }
|
|
|
- // this.handleList(params, this.requestApi)
|
|
|
- },
|
|
|
-
|
|
|
- async handleList (params, requestApi) {
|
|
|
- try {
|
|
|
- const pageParams = {
|
|
|
- page: this.pagination.page,
|
|
|
- size: this.pagination.size
|
|
|
- }
|
|
|
- let res = await requestApi(pageParams, params)
|
|
|
- // console.log(res)
|
|
|
- this.tableLoading = false
|
|
|
- if (res.success) {
|
|
|
- this.tableData = res.data.records
|
|
|
- this.pagination.total = res.data.total
|
|
|
- } else {
|
|
|
- this.$message.error(res.code)
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- this.tableLoading = false
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- // 表格选中行
|
|
|
- handleCurrentChange (row) {
|
|
|
- if(row){
|
|
|
- this.selectedRow = row
|
|
|
- this.selectedRow.equiTypeId = this.currentTreeData.id
|
|
|
- this.selectedRow.equiTypeName = this.currentTreeData.name
|
|
|
- }
|
|
|
- },
|
|
|
|
|
|
- // 选择的设备行
|
|
|
- selected () {
|
|
|
- this.selectedRow.parentName = this.currentTreeData.parentName
|
|
|
- this.$emit('submit', this.selectedRow)
|
|
|
- this.handleClose()
|
|
|
- },
|
|
|
- // 弹窗 - 按关键字搜索
|
|
|
- searchByKeyWords () {
|
|
|
- // console.log(this.searchMsg)
|
|
|
- if(!this.currentTreeData){
|
|
|
- this.$message.warning('请先选择设备!')
|
|
|
- return
|
|
|
- }
|
|
|
- this.pagination.page = 1
|
|
|
- this.params = { searchKey: this.searchKey , classificationId: parseInt(this.currentTreeData.id) }
|
|
|
- this._getList(this.params)
|
|
|
- },
|
|
|
- // 重置
|
|
|
- reset(){
|
|
|
- this.pagination.page = 1
|
|
|
- this.searchKey = ''
|
|
|
- this.params = { searchKey:this.searchKey , classificationId: parseInt(this.currentTreeData.id) }
|
|
|
- this._getList(this.params)
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
</script>
|