中航光电热表web
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

635 lines
17 KiB

9 months ago
<template>
<basic-container>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
v-model="form"
v-model:page="page"
ref="crud"
@row-del="rowDel"
@row-save="rowSave"
@row-update="rowUpdate"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
:before-open="beforeOpen"
@sort-change="sortChange"
:permission="permissionList"
>
<template #menu-left>
<el-button
type="danger"
plain
v-if="permission.processCapability_del"
@click="handleDelete()"
>删除</el-button
>
</template>
9 months ago
<template #menu-right>
<span style="display: inline-flex; margin-right: 12px">
<avue-select
v-model="slectForm.wtName"
placeholder="请选择能力类型"
type="tree"
:dic="slectDic"
:filterable="true"
:props="{
label: 'dictValue',
value: 'dictKey',
}"
style="width: 200px; margin-right: 12px"
v-if="permission.processCapability_batchSettings"
></avue-select>
<el-button
type="primary"
v-if="permission.processCapability_batchSettings"
@click="batchSet()"
>
批量设置
</el-button>
<el-button
type="primary"
v-if="permission.processCapability_import"
@click="handleImport"
>
导入
</el-button>
</span>
</template>
9 months ago
<template #localArea-form="{ type }">
<el-input
v-if="type == 'add' || 'edit'"
v-model="form.localArea"
@input="validateSmallBat"
></el-input>
</template>
<template #name="{ row }">
<i :class="row.source" style="margin-right: 5px" />
<span>{{ row.name }}</span>
</template>
<template #source="{ row }">
<div style="text-align: center">
<i :class="row.source" />
</div>
</template>
</avue-crud>
7 months ago
<!-- 导入 -->
<basic-import
v-if="isShowImport"
title="导入"
:isShow="isShowImport"
templateUrl="/blade-desk/BA/craftAbility/downloadExcelTemplate"
templateName="工艺能力模板.xls"
importUrl="/blade-desk/BA/craftAbility/importExcel"
@closeDialog="closeDialog"
></basic-import>
</basic-container>
9 months ago
</template>
<script>
import { mapGetters } from 'vuex';
import {
getList,
getPlateSmall,
addProcessAbility,
updateProcessAbility,
deleteProcessAbility,
saveProcessAbility,
} from '@/api/basicData/processCapability';
import { getDictionary } from '@/api/system/dict';
import basicImport from '@/components/basic-import/main.vue';
import { getDecimal } from '@/utils/formatter';
9 months ago
export default {
7 months ago
components: {
basicImport,
7 months ago
},
data() {
return {
isShowImport: false,
slectForm: {
wtName: '',
},
slectDic: [],
form: {},
query: {},
loading: true,
selectionList: [],
parentId: '',
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
formOption: {
menuSpan: 12,
enter: true,
menuBtn: false,
column: [
{
label: '',
prop: 'wtName',
type: 'select',
filterable: true,
props: {
label: 'dictValue',
value: 'dictKey',
9 months ago
},
dicUrl: '/blade-system/dict/dictionary?code=ProcessCapabilityType',
},
],
},
option: {
columnSort: true,
tip: false,
height: 'auto',
calcHeight: 32,
simplePage: false,
searchShow: true,
searchMenuSpan: 6,
dialogWidth: 600,
border: true,
selection: true,
viewBtn: true,
addBtnIcon: ' ',
viewBtnIcon: ' ',
delBtnIcon: ' ',
editBtnIcon: ' ',
menuWidth: 100,
dialogClickModal: false,
excelBtn: true,
viewBtn: false,
editBtnText: '修改',
refreshBtn: false,
searchShowBtn: false,
gridBtn: false,
searchIndex: 3,
searchIcon: true,
searchLabelPosition: 'left',
searchGutter: 24,
searchSpan: 6,
menuAlign: 'center',
gridBtn: false,
searchMenuPosition: 'right',
align: 'center',
labelWidth: 100,
searchLabelWidth: 'auto',
column: [
{
label: '编码',
prop: 'caCode',
search: true,
sortable: 'custom',
span: 12,
rules: [
{
required: true,
message: '请输入编码',
trigger: 'blur',
},
],
},
{
label: '名称',
prop: 'caName',
span: 12,
sortable: 'custom',
search: true,
rules: [
{
required: true,
message: '请输入名称',
trigger: 'blur',
},
],
},
// {
// label: "镀种小类",
// prop: "bpsId",
// type:'select',
// span:24,
// sortable: 'custom',
// search: true,
// dicUrl:"/api/blade-desk/BA/PlatingSmall/listForSelect",
// props:{
// label:'bpsName',
// value:"id"
// },
// rules: [
// {
// required: true,
// message: "请选择镀种小类",
// trigger: "blur",
// },
// ],
// },
{
label: '能力类型',
span: 12,
prop: 'wxLimit',
// bind: "bsWorkType.wtName",
sortable: 'custom',
search: true,
type: 'select',
filterable: true,
formatter: (row, value, label, column) => {
// -1 转换为空字符串
if (value === -1 || value === '') {
return '';
}
// 显示匹配的字典值
const dictItem = this.slectDic.find(item => item.dictKey == value);
return dictItem ? dictItem.dictValue : value;
},
props: {
label: 'dictValue',
value: 'dictKey',
9 months ago
},
dicUrl: '/blade-system/dict/dictionary?code=ProcessCapabilityType',
rules: [
{
required: false,
message: '请选择能力类型',
trigger: 'click',
},
],
width: 200,
},
3 months ago
{
label: '外协限制',
prop: 'wtId',
type: 'select',
span: 12,
dicUrl: '/blade-system/dict/dictionary?code=WxLimit',
3 months ago
props: {
label: 'dictValue',
value: 'dictKey',
3 months ago
},
width: 200,
3 months ago
},
{
label: '厂内比例(%)',
prop: 'inRate',
3 months ago
type: 'number',
span: 12,
3 months ago
controls: false,
max: 100,
3 months ago
rules: [
{
required: true,
message: '请输入厂内比例',
trigger: 'change',
3 months ago
},
],
change: val => {
console.log('val==========', val);
this.form.outRate = 100 - val.value;
},
width: 200,
3 months ago
},
{
label: '外协比例(%)',
prop: 'outRate',
3 months ago
type: 'number',
disabled: true,
span: 12,
3 months ago
controls: false,
rules: [
{
required: true,
message: '请输入外协比例',
trigger: 'change',
3 months ago
},
],
width: 200,
3 months ago
},
{
label: '局部镀订单面积(dm²)',
prop: 'localArea',
3 months ago
type: 'number',
span: 24,
3 months ago
controls: false,
labelWidth: 140,
width: 200,
3 months ago
},
{
label: '修改时间',
prop: 'updateTime',
sortable: 'custom',
search: true,
searchRange: true,
display: false,
hide: true,
type: 'date',
valueFormat: 'YYYY-MM-DD',
format: 'YYYY-MM-DD',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间',
},
{
label: '修改时间',
prop: 'updateTime',
sortable: 'custom',
search: false,
display: false,
type: 'date',
width: 200,
},
],
},
data: [],
};
},
computed: {
...mapGetters(['userInfo', 'permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.processCapability_add, false),
delBtn: this.validData(this.permission.processCapability_del, false),
editBtn: this.validData(this.permission.processCapability_edit, false),
};
9 months ago
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
9 months ago
},
},
methods: {
validateSmallBat(value) {
this.form.localArea = getDecimal(value, 5);
},
getType() {
getTypeData().then(res => {});
},
closeDialog(val) {
this.isShowImport = false;
if (val) {
// 重新加载列表数据,导入后的数据可能需要特殊处理
setTimeout(() => {
this.onLoad();
}, 500);
}
},
// 导入前处理数据
beforeUpload(file) {
// 可以在这里添加文件验证逻辑
console.log('导入文件:', file);
return true;
},
7 months ago
// 点击导入按钮
handleImport() {
this.isShowImport = true;
7 months ago
},
getDictionary() {
getDictionary({ code: 'ProcessCapabilityType' }).then(res => {
this.slectDic = res.data.data;
});
},
// 批量设置
batchSet() {
if (this.selectionList.length === 0) {
return this.$message.error('请先选择数据再进行操作!');
}
if (this.slectForm.wtName == '') {
return this.$message.error('请先选择能力类型!');
}
if (this.slectForm.wtName) {
this.$confirm('请确认此操作!', '提示', {
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning',
}).then(() => {
saveProcessAbility({
ids: this.selectionList.map(item => item.id),
wxLimit: this.slectForm.wtName,
}).then(res => {
if (res.data.code === 200) {
this.$message.success('设置成功');
this.onLoad();
}
});
});
}
},
initData() {
// getMenuTree().then(res => {
// const column = this.findObject(this.option.column, 'parentId');
// column.dicData = res.data.data;
// });
},
handleAdd(row) {
this.parentId = row.id;
const column = this.findObject(this.option.column, 'parentId');
column.value = row.id;
column.addDisabled = true;
this.$refs.crud.rowAdd();
},
// 保存
rowSave(row, done, loading) {
const submitData = { ...row };
// 处理空值,将空字符串转换为 -1
if (submitData.wtId === '' || submitData.wtId === null || submitData.wtId === undefined) {
3 months ago
submitData.wtId = '';
}
if (submitData.bpsId === '' || submitData.bpsId === null || submitData.bpsId === undefined) {
3 months ago
submitData.bpsId = '';
}
if (
submitData.wxLimit === '' ||
submitData.wxLimit === null ||
submitData.wxLimit === undefined
) {
3 months ago
submitData.wxLimit = '';
}
addProcessAbility(submitData)
.then(res => {
if (res.data.code == 200) {
this.$message.success('新增成功');
this.onLoad();
done();
}
})
.catch(() => {
loading();
});
},
// 修改
rowUpdate(row, index, done, loading) {
const submitData = { ...row };
// 处理空值,将空字符串转换为 -1
if (submitData.wtId === '' || submitData.wtId === null || submitData.wtId === undefined) {
3 months ago
submitData.wtId = '';
}
if (submitData.bpsId === '' || submitData.bpsId === null || submitData.bpsId === undefined) {
3 months ago
submitData.bpsId = '';
}
if (
submitData.wxLimit === '' ||
submitData.wxLimit === null ||
submitData.wxLimit === undefined
) {
3 months ago
submitData.wxLimit = '';
}
if (
submitData.localArea === '' ||
submitData.localArea === null ||
submitData.localArea === undefined
) {
submitData.localArea = '';
3 months ago
}
updateProcessAbility(submitData)
.then(res => {
if (res.data.code == 200) {
this.$message.success('修改成功');
this.onLoad();
done();
}
})
.catch(() => {
loading();
});
},
rowDel(row, index, done) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(() => {
deleteProcessAbility({
ids: row.id,
}).then(res => {
if (res.data.code == 200) {
this.$message.success('删除成功');
this.onLoad();
}
});
});
},
handleDelete() {
if (this.selectionList.length == 0) {
this.$message.error('请至少选择一条数据!');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(() => {
deleteProcessAbility({
ids: this.selectionList.map(item => item.id).join(','),
}).then(res => {
if (res.data.code == 200) {
this.$message.success('删除成功');
this.onLoad();
}
});
});
},
// 重置
searchReset() {
this.query = {};
this.parentId = 0;
this.onLoad(this.page);
},
// 搜索
searchChange(params, done) {
this.query = params;
this.parentId = '';
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
// 选中表格数据
selectionChange(list) {
this.selectionList = list;
console.log(67676, this.selectionList);
},
//
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
// 打开弹框 前操作 打开表单前会执行beforeOpen方法
beforeOpen(done, type) {
if (['edit', 'view'].includes(type)) {
// 处理 -1 转换为空字符串
this.form.bpsId = this.form.bpsId && this.form.bpsId !== -1 ? this.form.bpsId + '' : '';
this.form.wtId = this.form.wtId && this.form.wtId !== -1 ? this.form.wtId + '' : '';
}
done();
},
// 关闭 弹框 关闭表单前会执行beforeClose方法,
beforeClose(done) {
this.parentId = '';
const column = this.findObject(this.option.column, 'parentId');
column.value = '';
column.addDisabled = false;
done();
},
// 切换 页码
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
// 切换页面 数量
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
// 排序
sortChange({ prop, order }) {
this.query.descs = undefined;
this.query.ascs = undefined;
let orderByFieldKey = order === 'descending' ? 'descs' : 'ascs';
this.query[orderByFieldKey] = !prop
? undefined
: prop.replace(/([a-z])([A-Z0-9])/g, '$1_$2').toUpperCase();
// // 重新加载数据
this.onLoad(this.page, this.query);
},
// 加载页面数据
onLoad(page, params = {}) {
this.loading = true;
let param = {
descs: 'CA_CODE',
...this.query,
startTime:
this.query.updateTime && this.query.updateTime.length != 0 && this.query.updateTime[0],
endTime:
this.query.updateTime && this.query.updateTime.length != 0 && this.query.updateTime[1],
};
const { updateTime, ...searchParam } = param;
getList({
current: this.page.currentPage,
size: this.page.pageSize,
...searchParam,
}).then(res => {
3 months ago
res.data.data.records.map(item => {
item.localArea = item.localArea == -1 ? '' : item.localArea;
});
this.data = res.data.data.records;
this.page.total = res.data.data.total;
this.loading = false;
});
9 months ago
},
},
9 months ago
mounted() {
this.getDictionary();
},
};
</script>