mt-ck-wms-ui/src/views/report-manage/components/viewSubstrate.vue

196 lines
4.6 KiB
Vue
Raw Normal View History

2022-03-05 19:43:42 +08:00
<!--
* @Descripttion:
* @version:
* @Author: fzq
* @Date: 2022-03-05 15:55:45
* @LastEditors: fzq
2022-03-13 14:44:14 +08:00
* @LastEditTime: 2022-03-11 11:08:53
2022-03-05 19:43:42 +08:00
-->
<template>
<div class="app-container">
<!-- <div style="margin:10px 50px">
<el-button type="success" @click="goback()">{{ 'btn.back' | i18nFilter }}</el-button>
<el-button type="primary" @click="addNew()">{{ 'btn.add' | i18nFilter }}</el-button>
</div> -->
2022-03-13 14:44:14 +08:00
<div style="title">{{ storageCode }}:{{ num }}
2022-03-05 19:43:42 +08:00
<el-button type="success" style="back" @click="goback()">{{ 'btn.back' | i18nFilter }}</el-button>
</div>
<base-table
:page="listQuery.current"
:limit="listQuery.size"
:table-config="tableProps"
:table-data="list"
:is-loading="listLoading"
>
<method-btn
slot="handleBtn"
:width="trueWidth"
:method-list="tableBtn"
@clickBtn="handleClick"
/>
</base-table>
<edit-substrate v-if="addOrUpdateVisible" :id="listQuery.id" ref="addOrUpdate" @refreshDataList="getList" />
</div>
</template>
<script>import i18n from '@/lang'
import { listSubstrate, deleSubstrate } from '@/api/report-manage/report'
import editSubstrate from './edit-substrate.vue'
import BaseTable from '@/components/BaseTable'
import MethodBtn from '@/components/BaseTable/subcomponents/MethodBtn'
/**
* 表格表头配置项 TypeScript接口注释
* tableConfig<ConfigItem> = []
*
* Interface ConfigItem = {
* prop: string,
* label: string,
* width: string,
* align: string,
* subcomponent: function,
* filter: function
* }
*
*
*/
const tableBtn = [
{
type: 'edit',
btnName: 'btn.edit'
},
{
type: 'delete',
btnName: 'btn.delete'
}
]
const tableProps = [
{
prop: 'substrateCode',
label: i18n.t('module.report.substrate.substrateCode'),
align: 'center'
},
{
prop: 'location',
label: i18n.t('module.report.substrate.location'),
align: 'center'
},
{
prop: 'storeTime',
label: i18n.t('module.report.substrate.storeTime'),
align: 'center'
},
{
prop: 'substrateStatus',
label: i18n.t('module.report.substrate.substrateStatus'),
align: 'center'
}
]
export default {
name: 'ViewSubstrate',
components: { BaseTable, MethodBtn, editSubstrate },
filters: {
statusFilter(status) {
const statusMap = {
published: 'success',
draft: 'info',
deleted: 'danger'
}
return statusMap[status]
}
},
data() {
return {
addOrUpdateVisible: false,
num: '',
2022-03-13 14:44:14 +08:00
storageCode: this.$t('module.basicData.visual.TipsBefore'),
2022-03-05 19:43:42 +08:00
tableBtn,
trueWidth: 200,
tableProps,
list: [],
listLoading: true,
listQuery: {
current: 1,
size: 10,
2022-03-10 21:15:33 +08:00
storageBoxCode: '',
storageBoxId: ''
2022-03-05 19:43:42 +08:00
}
}
},
created() {
2022-03-10 21:15:33 +08:00
this.listQuery.storageBoxCode = this.$route.query.code
this.listQuery.storageBoxId = this.$route.query.id
2022-03-05 19:43:42 +08:00
this.getList()
},
methods: {
handleClick(raw) {
if (raw.type === 'delete') {
this.$confirm(`${this.$t('module.basicData.visual.TipsBefore')}[${raw.data.substrateCode}]?`, this.$t('module.basicData.visual.Tips'), {
confirmButtonText: this.$t('module.basicData.visual.confirmButtonText'),
cancelButtonText: this.$t('module.basicData.visual.cancelButtonText'),
type: 'warning'
}).then(() => {
// console.log(raw.data)
deleSubstrate(raw.data).then(response => {
this.$message({
message: this.$t('module.basicData.visual.success'),
type: 'success',
duration: 1500,
onClose: () => {
this.getList()
}
})
})
}).catch(() => {})
} else {
this.addNew(raw.data.id)
}
},
getList() {
this.listLoading = true
2022-03-13 14:44:14 +08:00
this.num = this.listQuery.storageBoxCode
2022-03-05 19:43:42 +08:00
this.listQuery.code = this.$route.query.code
console.log(this.listQuery)
listSubstrate(this.listQuery).then(response => {
2022-03-10 21:15:33 +08:00
console.log(response)
2022-03-05 19:43:42 +08:00
if (response.data) {
this.list = response.data
console.log(this.list)
} else {
this.list.splice(0, this.list.length)
}
this.listLoading = false
})
},
// 新增 / 修改
addNew(id) {
this.addOrUpdateVisible = true
2022-03-06 19:36:26 +08:00
this.$nextTick(() => {
this.$refs.addOrUpdate.init(id)
})
2022-03-05 19:43:42 +08:00
},
goback() {
this.$router.go(-1)
}
}
}
</script>
<style scoped>
.title {
left: 150px;
}
.edit-input {
padding-right: 100px;
}
.cancel-btn {
position: absolute;
right: 15px;
top: 10px;
}
.back {
right: 20px;
}
</style>