Files
mt-ck-wms-ui/src/views/basicData/Equipment/equipmentInfo.vue
2022-03-10 21:15:33 +08:00

225 lines
5.4 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!--
* @Author: zwq
* @Date: 2020-12-29 15:41:11
* @LastEditors: fzq
* @LastEditTime: 2022-03-10 15:09:41
* @Description:
-->
<template>
<div class="app-container">
<head-form
:placeholder-name="placeholderName"
:key-name="keyName"
@getDataList="getList"
@add="addNew"
/>
<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>
<pagination
v-show="total > 0"
:total="total"
:page.sync="listQuery.current"
:limit.sync="listQuery.size"
@pagination="getList()"
/>
</div>
</template>
<script>import i18n from '@/lang'
import { equipmentInfoList, equipmentInfoDelete } from '@/api/basicData/Equipment/equipmentInfo'
import HeadForm from '@/components/basicData/HeadForm'
import BaseTable from '@/components/BaseTable'
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
import MethodBtn from '@/components/BaseTable/subcomponents/MethodBtn'
import { timeFormatter } from '@/filters'
// import dataDict from '@/filters/DataDict'
/**
* 表格表头配置项 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'
},
{
type: 'detail',
btnName: 'btn.detail'
}
]
const tableProps = [
{
prop: 'createTime',
label: i18n.t('module.basicData.factory.createTime'),
filter: timeFormatter,
align: 'center'
},
{
prop: 'name',
label: i18n.t('module.basicData.equipment.EquipmentName'),
align: 'center'
},
{
prop: 'code',
label: i18n.t('module.basicData.equipment.EquipmentCode'),
align: 'center'
},
{
prop: 'typeName',
label: i18n.t('module.basicData.equipment.EquipmentType'),
align: 'center'
},
{
prop: 'enName',
label: i18n.t('module.basicData.visual.EnglishName'),
align: 'center'
},
{
prop: 'abbr',
label: i18n.t('module.basicData.equipment.shortName'),
align: 'center'
}
// {
// prop: 'estatus',
// label: i18n.t('module.basicData.visual.CurrentState'),
// filter: dataDict('enableState'),
// align: 'center'
// }
]
export default {
name: 'EquipmentInfo',
components: { Pagination, BaseTable, MethodBtn, HeadForm },
filters: {
statusFilter(status) {
const statusMap = {
published: 'success',
draft: 'info',
deleted: 'danger'
}
return statusMap[status]
}
},
data() {
return {
keyName: this.$t('module.basicData.equipment.EquipmentCode'),
placeholderName: this.$t('module.basicData.equipment.EquipmentCode'),
tableBtn,
trueWidth: 240,
tableProps,
list: [{
typeName: ''
}],
total: 0,
listLoading: true,
listQuery: {
current: 1,
size: 10
}
}
},
created() {
this.getList()
},
methods: {
handleClick(raw) {
if (raw.type === 'delete') {
this.$confirm(`${this.$t('module.basicData.visual.TipsBefore')}[${raw.data.name}]?`, this.$t('module.basicData.visual.Tips'), {
confirmButtonText: this.$t('module.basicData.visual.confirmButtonText'),
cancelButtonText: this.$t('module.basicData.visual.cancelButtonText'),
type: 'warning'
}).then(() => {
equipmentInfoDelete(raw.data.id).then(response => {
this.$message({
message: this.$t('module.basicData.visual.success'),
type: 'success',
duration: 1500,
onClose: () => {
this.getList()
}
})
})
}).catch(() => {})
} else if (raw.type === 'edit') {
this.addNew(raw.data.id)
} else {
this.addNew(raw.data.id, true)
}
},
getList(key) {
this.listLoading = true
this.listQuery.name = key
this.listQuery.code = key
equipmentInfoList(this.listQuery).then(response => {
console.log(response)
if (response.data.records) {
this.list = response.data.records
// 1是物流设备2是工艺设备与equipmentType进行替换
for (var x = 0; x < this.list.length; x++) {
if (this.list[x].equipmentType === '1') {
this.list[x].typeName = this.$t('module.basicData.cache.logisticsEquipment')
} else if (this.list[x].equipmentType === '2') {
this.list[x].typeName = this.$t('module.basicData.cache.processEquipment')
}
}
} else {
this.list.splice(0, this.list.length)
}
this.total = response.data.total
this.listLoading = false
console.log(this.list)
})
},
// 新增 / 修改
addNew(id, isdetail) {
this.$router.push({
name: 'equipmentInfoAdd',
query: {
id: id,
isdetail: isdetail
}
})
}
}
}
</script>
<style scoped>
.edit-input {
padding-right: 100px;
}
.cancel-btn {
position: absolute;
right: 15px;
top: 10px;
}
</style>