<script setup>
|
|
import {reactive, ref} from "vue";
|
import {useRouter} from 'vue-router'
|
import request from "@/utils/request";
|
import deepClone from "@/utils/deepClone";
|
import {ElMessage} from "element-plus";
|
import { useI18n } from 'vue-i18n'
|
import {changeFilterEvent, filterChanged} from "@/hook"
|
//语言获取
|
const { t } = useI18n()
|
let router=useRouter()
|
//定义数据返回结果
|
let produceList = ref([])
|
//定义接收加载表头下拉数据
|
const titleSelectJson = ref({
|
processType: [],
|
|
})
|
const size = ref<'default' | 'large' | 'small'>('default')
|
|
const value1 = ref('')
|
let dialogTableVisible = ref(false)
|
|
const getBasicData = ref({
|
id: '',
|
basic_type: '',
|
basic_name: '',
|
d_basic_name: '',
|
})
|
const getTableRow = (row,type) =>{
|
switch (type) {
|
case 'edit' :{
|
request.post(`/basicDataProduce/openSelectId/${row.id}`).then((res) => {
|
if (res.code == 200) {
|
|
getBasicData.value = res.data.data[0]
|
dialogTableVisible.value=true
|
//router.push({path: '/main/productionBasicData/SelectProductionBasicData', query: {random:Math.random()}})
|
} else {
|
|
ElMessage.warning(res.msg)
|
|
}
|
})
|
break
|
}
|
case 'delete':{
|
request.post(`/basicDataProduce/deleteBasic/${row.id}`).then((res) => {
|
if (res.code == 200) {
|
ElMessage.success(t('workOrder.deleteOk'))
|
router.push({path: '/main/productionBasicData/SelectProductionBasicData', query: {random:Math.random()}})
|
} else {
|
|
ElMessage.warning(res.msg)
|
|
}
|
})
|
break
|
}
|
case 'setType':{
|
alert('我接收到子组件传送的反审状态')
|
break
|
}
|
}
|
}
|
|
//表尾求和
|
const sumNum = (list, field) => {
|
let count = 0
|
list.forEach(item => {
|
count += Number(item[field])
|
})
|
return count.toFixed(2)
|
}
|
|
const hasDecimal = (value) => {
|
const regex = /\./; // 定义正则表达式,查找小数点
|
return regex.test(value); // 返回true/false
|
}
|
|
//首次加载
|
request.post(`/basicDataProduce/selectBasic`).then((res) => {
|
if (res.code == 200) {
|
produceList = produceList.value.concat(deepClone(res.data.data))
|
titleSelectJson.value.processType = res.data.process;
|
xGrid.value.reloadData(produceList)
|
gridOptions.loading = false
|
} else {
|
ElMessage.warning(res.msg)
|
}
|
})
|
|
//子组件接收参数
|
const xGrid = ref()
|
const gridOptions = reactive({
|
border: "full",//表格加边框
|
keepSource: true,//保持源数据
|
align: 'center',//文字居中
|
stripe:true,//斑马纹
|
rowConfig: {isCurrent: true, isHover: true,height: 30},//鼠标移动或选择高亮
|
id: 'CustomerList',
|
showFooter: true,//显示脚
|
printConfig: {},
|
importConfig: {},
|
exportConfig: {},
|
scrollY:{ enabled: true },//开启虚拟滚动
|
showOverflow:true,
|
columnConfig: {
|
resizable: true,
|
useKey: true
|
},
|
filterConfig: { //筛选配置项
|
//remote: true
|
},
|
customConfig: {
|
storage: true
|
},
|
editConfig: {
|
trigger: 'click',
|
mode: 'row',
|
showStatus: true
|
},//表头参数
|
columns:[
|
{type:'expand',fixed:"left",slots: { content:'content' },width: 50},
|
{title: '操作', width: 140, slots: { default: 'button_slot' },fixed:"left"},
|
{field: 'id', width: 60, title: 'id',filters:[{ data: '' }],slots: { filter: 'num1_filter' },filterMethod: filterChanged,},
|
{field: 'basic_type',width: 370, title: '类型', showOverflow:"ellipsis" ,filters:[{ data: '' }],slots: { filter: 'num1_filter' },filterMethod: filterChanged},
|
{field: 'basic_name', width: 330,title: '名称', filters:[{ data: '' }],slots: { filter: 'num1_filter' },filterMethod: filterChanged},
|
{field: 'd_basic_name',width: 330, title: '类别'},
|
],
|
//表头按钮
|
toolbarConfig: {
|
// buttons: [{
|
//
|
// }],
|
// import: false,
|
// export: true,
|
// print: true,
|
zoom: true,
|
custom: true
|
},
|
data: [
|
|
],//table body实际数据
|
//脚部求和
|
footerMethod ({ columns, data }) {//页脚函数
|
let footList=['','','','']
|
return[
|
columns.map((column, columnIndex) => {
|
if (columnIndex === 0) {
|
return '合计:'
|
}
|
if (footList.includes(column.field)) {
|
return sumNum(data, column.field)
|
}
|
return ''
|
})
|
]
|
}
|
|
})
|
|
const updateBasic = () => {
|
let id = getBasicData.value.id
|
let process = getBasicData.value.d_basic_name
|
let name = getBasicData.value.basic_name
|
let type = getBasicData.value.basic_type
|
request.post(`/basicDataProduce/updateBasic/${id}/${process}/${name}/${type}`).then((res) => {
|
if (res.code == 200) {
|
ElMessage.success(t('processCard.modifySuccessfully'))
|
router.push({path: '/main/productionBasicData/SelectProductionBasicData', query: {random:Math.random()}})
|
} else {
|
|
ElMessage.warning(res.msg)
|
}
|
})
|
}
|
|
|
</script>
|
|
<template>
|
<div class="main-div-customer">
|
<vxe-grid
|
max-height="100%"
|
class="mytable-scrollbar"
|
ref="xGrid"
|
v-bind="gridOptions"
|
|
>
|
<!-- @toolbar-button-click="toolbarButtonClickEvent"-->
|
<!-- 下拉显示所有信息插槽-->
|
<template #content="{ row }">
|
<ul class="expand-wrapper">
|
<li v-for="(item,index) in gridOptions.columns" v-show="item.field!=undefined ">
|
<span style="font-weight: bold">{{ item.title + ': ' }}</span>
|
<span v-if="hasDecimal(item.field)">{{ row[item.field.split('.')[0]][item.field.split('.')[1]] }}</span>
|
<span v-else>{{ row[item.field] }}</span>
|
|
</li>
|
</ul>
|
</template>
|
|
<!--左边固定显示的插槽-->
|
<template #button_slot="{ row }">
|
<el-button @click="getTableRow(row,'edit');" link type="primary" size="small">{{$t('basicData.edit')}}</el-button>
|
<el-button @click="getTableRow(row,'delete')" link type="primary" size="small">删除</el-button>
|
</template>
|
|
<template #num1_filter="{ column, $panel }">
|
<div>
|
<div v-for="(option, index) in column.filters" :key="index">
|
<input type="text" v-model="option.data" @input="changeFilterEvent($event, option, $panel)"/>
|
</div>
|
</div>
|
</template>
|
|
|
</vxe-grid>
|
|
<el-dialog v-model="dialogTableVisible" title="基础数据修改">
|
<el-row>
|
<el-col :span="2">
|
<el-text>id:</el-text>
|
</el-col>
|
<el-col :span="3">
|
<el-input v-model="getBasicData.id" readonly autocomplete="off" style="width: 220px"/>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="2">
|
<el-text>类型:</el-text>
|
</el-col>
|
<el-col :span="3">
|
<el-input v-model="getBasicData.basic_type" readonly autocomplete="off" style="width: 220px"/>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="2">
|
<el-text>名称:</el-text>
|
</el-col>
|
<el-col :span="3">
|
<el-input v-model="getBasicData.basic_name" autocomplete="off" style="width: 220px"/>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="2">
|
<el-text>类别:</el-text>
|
</el-col>
|
<el-col :span="3">
|
<!-- <el-input v-model="getBasicData.d_basic_name" autocomplete="off" style="width: 220px"/>-->
|
<el-select v-model="getBasicData.d_basic_name" clearable placeholder="" style="width: 220px"
|
>
|
<el-option
|
v-for="item in titleSelectJson['processType']"
|
:key="item.id"
|
:label="item.basic_name"
|
:value="item.basic_name"
|
/>
|
</el-select>
|
</el-col>
|
</el-row>
|
|
<template #footer>
|
<span class="dialog-footer">
|
<el-button @click="dialogTableVisible = false">取消</el-button>
|
<el-button type="primary" @click="updateBasic">
|
修改
|
</el-button>
|
</span>
|
</template>
|
</el-dialog>
|
</div>
|
</template>
|
|
<style scoped>
|
.main-div-customer{
|
width: 99%;
|
height: 100%;
|
}
|
.el-row{
|
margin: 10px;
|
}
|
</style>
|