mt-ck-wms-ui/src/views/basicData/VisualLayout.vue
2021-09-13 14:56:28 +08:00

188 lines
4.7 KiB
Vue

<!--
* @Author: zwq
* @Date: 2020-12-29 15:41:11
* @LastEditors: gtz
* @LastEditTime: 2021-03-11 19:50:03
* @Description:
-->
<template>
<div class="app-container">
<el-form
:model="listQuery"
:inline="true"
size="medium"
>
<el-form-item :label="$t('module.basicData.visual.areaName')" prop="name">
<el-input v-model="listQuery.name" :placeholder="['placeholder.input', $t('module.basicData.visual.areaName')] | i18nFilterForm" style="width:200px" clearable />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="getList()"> {{ 'btn.search' | i18nFilter }} </el-button>
<el-button type="primary" @click="addNew()"> {{ 'btn.add' | i18nFilter }} </el-button>
</el-form-item>
</el-form>
<base-table
:page="listQuery.current"
:limit="listQuery.size"
:table-config="tableProps"
:table-data="list"
:is-loading="listLoading"
@emitFun="emitFun"
>
<method-btn
slot="handleBtn"
:width="trueWidth"
:method-list="tableBtn"
@clickBtn="handleClick"
/>
</base-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="listQuery.current"
:limit.sync="listQuery.size"
@pagination="getList()"
/>
<VisualInfo-add v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getList" />
</div>
</template>
<script>
import { VisualList, VisualDelete } from '@/api/basicData/visual'
import VisualLocationInfo from './components/VisualLocationInfo.vue'
import VisualInfoAdd from './components/VisualInfo-add.vue'
import VisualImgInfo from './components/VisualImgInfo.vue'
import VisualPointInfo from './components/VisualPointInfo.vue'
// import VisualRouteInfo from './components/VisualRouteInfo.vue'
import BaseTable from '@/components/BaseTable'
import Pagination from '@/components/Pagination'
import MethodBtn from '@/components/BaseTable/subcomponents/MethodBtn'
import i18n from '@/lang'
const tableBtn = [
{
type: 'edit',
btnName: 'btn.edit'
},
{
type: 'delete',
btnName: 'btn.delete'
}
]
const tableProps = [
{
prop: 'name',
label: i18n.t('module.basicData.visual.areaName'),
align: 'center'
},
{
prop: 'source',
label: i18n.t('module.basicData.visual.annex'),
align: 'center',
subcomponent: VisualImgInfo
},
{
prop: 'equipmentPoint',
label: i18n.t('module.basicData.visual.locationInformation'),
align: 'center',
subcomponent: VisualPointInfo
},
{
prop: 'stock',
label: i18n.t('module.basicData.visual.stock'),
align: 'center',
subcomponent: VisualLocationInfo
}
// {
// prop: 'trajectory',
// label: i18n.t('module.basicData.visual.runningTrack'),
// align: 'center',
// subcomponent: VisualRouteInfo
// }
]
export default {
name: 'VisualInfo',
components: { Pagination, BaseTable, MethodBtn, VisualInfoAdd },
data() {
return {
addOrUpdateVisible: false,
tableBtn,
trueWidth: 200,
tableProps,
list: [],
total: 0,
listLoading: true,
listQuery: {
name: '',
current: 1,
size: 10,
type: 1
}
}
},
created() {
this.getList()
},
methods: {
handleClick(raw) {
console.log(raw)
if (raw.type === 'delete') {
this.$confirm(`${this.$t('deleteTip.header')}${raw.data.name}${this.$t('deleteTip.footer')}`, this.$t('deleteTip.tip'), {
confirmButtonText: this.$t('deleteTip.confirm'),
cancelButtonText: this.$t('deleteTip.cancel'),
type: 'warning'
}).then(() => {
VisualDelete(raw.data.id).then(response => {
this.$message({
message: this.$t('baseTip.OperationSucc'),
type: 'success',
duration: 1500,
onClose: () => {
this.getList()
}
})
})
}).catch(() => {})
} else {
this.addNew(raw.data.id)
}
},
getList() {
this.listLoading = true
VisualList(this.listQuery).then(response => {
if (response.data.records) {
this.list = response.data.records
} else {
this.list.splice(0, this.list.length)
}
this.total = response.data.total
this.listLoading = false
})
},
// 新增 / 修改
addNew(id) {
this.addOrUpdateVisible = true
this.$nextTick(() => {
this.$refs.addOrUpdate.init(id)
})
},
emitFun(val) {
if (val.type.indexOf('refresh') >= 0) {
this.getList()
}
}
}
}
</script>
<style scoped>
.edit-input {
padding-right: 100px;
}
.cancel-btn {
position: absolute;
right: 15px;
top: 10px;
}
</style>