<template>
|
<el-dialog :close-on-click-modal="false" :visible.sync="visible">
|
<el-table
|
:data="dataList"
|
border
|
@selection-change="handleSelectionChange"
|
v-loading="dataListLoading"
|
>
|
<el-table-column type="selection" width="55"> </el-table-column>
|
<template v-for="(col, index) in this.cols">
|
<el-table-column
|
:prop="col.prop"
|
:label="col.label"
|
header-align="center"
|
align="center"
|
>
|
</el-table-column>
|
</template>
|
</el-table>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="visible = false">取消</el-button>
|
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
|
</span>
|
</el-dialog>
|
</template>
|
|
<script>
|
import { getObj, addObj, putObj, getResource } from '@/api/aps/connector'
|
export default {
|
data() {
|
return {
|
cols: [
|
{ label: '资源编号', prop: 'resourceNo' },
|
{ label: '资源名称', prop: 'resourceName' },
|
{ label: '备注', prop: 'remark' },
|
{ label: '工作站id', prop: 'workstationId' }
|
],
|
dataListLoading: false,
|
dataList: [],
|
record: [],
|
visible: false,
|
fromId: '',
|
toId: '',
|
dataForm: {
|
id: 0,
|
fromResourceId: '',
|
toResourceId: '',
|
transportTime: ''
|
},
|
clickDateArr: []
|
}
|
},
|
methods: {
|
handleSelectionChange(val) {
|
this.record = val
|
},
|
init(id) {
|
this.visible = true
|
this.fromId = id
|
this.clickDateArr = []
|
this.getDataList()
|
},
|
getDataList() {
|
this.dataListLoading = true
|
getResource(
|
Object.assign({
|
current: this.pageIndex,
|
size: this.pageSize
|
}),
|
this.fromId
|
).then((response) => {
|
this.dataList = response.data.data.records
|
this.totalPage = response.data.data.total
|
})
|
this.dataListLoading = false
|
},
|
commit() {
|
const transferData = {
|
fromResourceId: this.fromId,
|
toResourceId: this.toId,
|
transportTime: ''
|
}
|
addObj(transferData).then((data) => {
|
this.$message.success('添加成功')
|
this.visible = false
|
this.$emit('refreshDataList')
|
})
|
},
|
// 表单提交
|
dataFormSubmit() {
|
var canClickFlag = true
|
this.clickDateArr.push(new Date().getTime())
|
if (this.clickDateArr.length > 1) {
|
if (
|
this.clickDateArr[this.clickDateArr.length - 1] -
|
this.clickDateArr[this.clickDateArr.length - 2] <
|
2000
|
) {
|
// 小于2秒则认为重复提交
|
canClickFlag = false
|
}
|
}
|
if (canClickFlag) {
|
for (let i = 0; i < this.record.length; i++) {
|
this.toId = this.record[i].id
|
this.commit()
|
}
|
}
|
}
|
}
|
}
|
</script>
|