<script setup>
|
|
import {computed, nextTick, onMounted, reactive, ref, toRefs} from "vue";
|
import {useRouter, useRoute} from 'vue-router'
|
import request from "@/utils/request";
|
import {ElMessage} from "element-plus";
|
import {changeFilterEvent, filterChanged} from "@/hook"
|
import userInfo from "@/stores/userInfo"
|
import {useI18n} from 'vue-i18n'
|
import {addListener, toolbarButtonClickEvent} from "@/hook/mouseMove";
|
//语言获取
|
const {t} = useI18n()
|
const route = useRoute()
|
const user = userInfo()
|
let router = useRouter()
|
|
//定义接收加载表头下拉数据
|
const titleSelectJson = ref({
|
processType: [],
|
|
})
|
//第一次加载数据
|
request.post(`/basicDataProduce/selectProcess`).then((res) => {
|
if (res.code == 200) {
|
|
titleSelectJson.value.processType = res.data.process;
|
} else {
|
ElMessage.warning(res.msg)
|
}
|
})
|
|
onMounted(() => {
|
//启用表格拖动选中
|
addListener(xGrid.value, gridOptions)
|
})
|
|
//子组件接收参数
|
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: 'seq', fixed: "left", title: '自序', width: 50},
|
{
|
field: 'basicName',
|
title: '班组名称',
|
width: 600,
|
editRender: {name: 'input', attrs: {placeholder: ''}},
|
|
},
|
{
|
field: 'basicCategory',
|
title: '所在工序',
|
editRender: {},
|
slots: {default: 'basicCategory_default', edit: 'basicCategory'}
|
},
|
],
|
//表头按钮
|
toolbarConfig: {
|
buttons: [
|
{code: 'removeRow', name: t('basicData.delete'), status: 'primary', icon: 'vxe-icon-delete'},
|
{code: 'addRow', name: t('reportingWorks.increase'), status: 'primary', icon: 'vxe-icon-square-plus'},
|
{code: 'save', name: '保存', status: 'primary', icon: 'vxe-icon-save'},
|
],
|
// 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 teamGridEvents = {
|
toolbarButtonClick({code}) {
|
const $grid = xGrid.value
|
if ($grid) {
|
switch (code) {
|
case 'addRow': {
|
$grid.insertAt({})
|
break
|
}
|
case 'removeRow': {
|
let result = toolbarButtonClickEvent()
|
if (result) {
|
$grid.remove(result.row)
|
}
|
break
|
}
|
case 'save': {
|
const tableData = $grid.getTableData().fullData
|
//console.log(tableData)
|
let teamGroupData = ref({
|
basicDataProduce: tableData
|
})
|
request.post("/basicDataProduce/saveTeamGroup", teamGroupData.value).then((res) => {
|
if (res.code == 200) {
|
ElMessage.success("保存成功")
|
//router.push('/main/processCard/SplittingDetails?orderId=${orderId}')
|
router.push({
|
path: '/main/productionBasicData/AddTeamGroup',
|
query: {random: Math.random()}
|
})
|
|
//location.reload();
|
} else {
|
ElMessage.warning(res.msg)
|
}
|
})
|
break
|
}
|
}
|
}
|
}
|
}
|
|
const size = ref<'default' | 'large' | 'small'>('default')
|
|
const value1 = ref('')
|
|
|
</script>
|
|
<template>
|
<div class="main-div-customer">
|
<vxe-grid
|
ref="xGrid"
|
class="mytable-scrollbar"
|
max-height="100%"
|
height="650px"
|
v-bind="gridOptions"
|
v-on="teamGridEvents"
|
@filter-change="filterChanged"
|
|
>
|
|
<template #num1_filter="{ column, $panel }">
|
<div>
|
<div v-for="(option, index) in column.filters" :key="index">
|
<input v-model="option.data" type="type" @input="changeFilterEvent($event, option, $panel)"/>
|
</div>
|
</div>
|
</template>
|
<template #basicCategory="{ row }">
|
<vxe-select v-model="row.basicCategory"
|
clearable
|
filterable
|
placeholder="">
|
<vxe-option v-for="item in titleSelectJson.processType"
|
:key="item.basic_name"
|
:label="item.basic_name"
|
:value="item.basic_name"/>
|
</vxe-select>
|
</template>
|
<template #basicCategory_default="{ row }">
|
<span>{{ row.basicCategory }}</span>
|
</template>
|
|
</vxe-grid>
|
|
</div>
|
</template>
|
|
<style scoped>
|
.main-div-customer {
|
width: 99%;
|
height: 100%;
|
}
|
.vxe-grid {
|
/* 禁用浏览器默认选中 */
|
-webkit-user-select: none;
|
-moz-user-select: none;
|
-ms-user-select: none;
|
user-select: none;
|
}
|
</style>
|