基础数据-外协分派管理-新增排序与权限

dev-scheduling
ysn 1 month ago
parent c6af258443
commit ac3490771a
  1. 446
      src/views/oem/outsourcingAssignmentControl/index.vue

@ -15,19 +15,43 @@
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
@sort-change="sortChange"
:permission="permissionList"
>
<template #menu-left>
<el-button type="danger" @click="handleDelete">删除 </el-button>
<el-button type="primary" @click="handleSave">保存 </el-button>
<el-button
type="danger"
v-if="permission.outsourcingAssignmentControl_del"
@click="handleDelete"
>
删除
</el-button>
<el-button
type="primary"
v-if="permission.outsourcingAssignmentControl_save"
@click="handleSave"
>
保存
</el-button>
</template>
<template #oemId="scope">
<el-select v-model="scope.row.oemId" @change="handleSupplierChange(scope.row)">
<el-option v-for="item in supplierData" :key="item.id" :label="item.ocName" :value="item.id"></el-option>
<el-option
v-for="item in supplierData"
:key="item.id"
:label="item.ocName"
:value="item.id"
></el-option>
</el-select>
</template>
<template #platingId="scope">
<el-select v-model="scope.row.platingId" filterable>
<el-option v-for="item in scope.row.abilityData" :key="item.id" :label="item.caName" :value="item.id"></el-option>
<el-option
v-for="item in scope.row.abilityData"
:key="item.id"
:label="item.caName"
:value="item.id"
></el-option>
</el-select>
</template>
<template #dsPart="scope">
@ -35,51 +59,71 @@
<el-option v-for="item in partData" :key="item.id" :label="item.partCode" :value="item.id"></el-option>
</el-select> -->
<jhSelect
:value="scope.row.dsPart"
@input="val => (scope.row.dsPart = val)"
placeholder="请搜索选择"
api-url="/blade-desk/dsPart/listNew"
echo-api="/blade-desk/dsPart/listNew"
echoParamsKey="id"
echo-method="get"
api-method="get"
list-key="records"
total-key="total"
label-key="partCode"
value-key="id"
search-key="partCode"
:debounce-time="500"
:title="'修改'"
/>
:value="scope.row.dsPart"
@input="val => (scope.row.dsPart = val)"
placeholder="请搜索选择"
api-url="/blade-desk/dsPart/listNew"
echo-api="/blade-desk/dsPart/listNew"
echoParamsKey="id"
echo-method="get"
api-method="get"
list-key="records"
total-key="total"
label-key="partCode"
value-key="id"
search-key="partCode"
:debounce-time="500"
:title="'修改'"
/>
</template>
<template #assignScale="scope">
<el-input-number style="width:98%;" v-model="scope.row.assignScale" controls-position="right"></el-input-number>
<el-input-number
style="width: 98%"
v-model="scope.row.assignScale"
controls-position="right"
></el-input-number>
</template>
<template #menu-right>
<!-- <el-button type="primary" icon="el-icon-printer" @click="handleDelete">打印
</el-button> -->
<el-button type="primary" @click="handleImport">导入 </el-button>
<el-button
type="primary"
v-if="permission.outsourcingAssignmentControl_import"
@click="handleImport"
>导入
</el-button>
</template>
<template #proportion="{ row }">
<span>{{ row.proportion ? row.proportion + "%" : "0%" }}</span>
<span>{{ row.proportion ? row.proportion + '%' : '0%' }}</span>
</template>
</avue-crud>
<!-- 导入 -->
<basic-import v-if="isShowImport" title="导入" :isShow="isShowImport"
<!-- 导入 -->
<basic-import
v-if="isShowImport"
title="导入"
:isShow="isShowImport"
templateUrl="/blade-desk/BA/PlanAssignSteer/downloadExcelTemplate"
templateName="外协分派管理模板.xls"
importUrl="/blade-desk/BA/PlanAssignSteer/importExcel"
@closeDialog="closeDialog"></basic-import>
@closeDialog="closeDialog"
></basic-import>
</basic-container>
</template>
<script>
import basicImport from '@/components/basic-import/main.vue'
import {getList,getSupplier,getProcessAbility,getPartList,submitBat,remove} from "@/api/basicData/outsourcingAssignmentControl"
import basicImport from '@/components/basic-import/main.vue';
import {
getList,
getSupplier,
getProcessAbility,
getPartList,
submitBat,
remove,
} from '@/api/basicData/outsourcingAssignmentControl';
import jhSelect from '@/components/jh-select/index.vue';
import { mapGetters } from 'vuex';
export default {
components: { basicImport,jhSelect },
components: { basicImport, jhSelect },
data() {
return {
isShowImport: false,
@ -89,17 +133,17 @@ export default {
currentPage: 1,
total: 0,
},
query:{},
supplierData:[],
abilityData:[],
partData:[],
query: {},
supplierData: [],
abilityData: [],
partData: [],
data: [],
option: {
index: false,
addRowBtn: true,
addBtnText:"插入一行",
addRowBtnText: "插入一行",
height: "auto",
addBtnText: '插入一行',
addRowBtnText: '插入一行',
height: 'auto',
calcHeight: 32,
tip: false,
// size: "medium",
@ -115,10 +159,10 @@ export default {
addBtn: false,
delBtn: false,
editBtn: true,
editBtnText: "修改",
viewBtnIcon: " ",
delBtnIcon: " ",
editBtnIcon: " ",
editBtnText: '修改',
viewBtnIcon: ' ',
delBtnIcon: ' ',
editBtnIcon: ' ',
labelWidth: 120,
menuWidth: 150,
dialogWidth: 600,
@ -132,48 +176,48 @@ export default {
columnSort: true,
showOverflowTooltip: true,
menu: false,
searchLabelPosition: "left",
searchLabelPosition: 'left',
searchGutter: 24,
searchSpan: 6,
menuAlign: "left",
menuAlign: 'left',
gridBtn: false,
searchMenuPosition: "right",
addBtnIcon: " ",
viewBtnIcon: " ",
delBtnIcon: " ",
editBtnIcon: " ",
align: "center",
searchMenuPosition: 'right',
addBtnIcon: ' ',
viewBtnIcon: ' ',
delBtnIcon: ' ',
editBtnIcon: ' ',
align: 'center',
column: [
{
label: "供应商",
prop: "oemId",
label: '供应商',
prop: 'oemId',
// bind: "bsOemCustomer.ocCode",
sortable: true,
sortable: 'custom',
filter: true,
span: 24,
minWidth: 150,
search: false,
type: "select",
rules: [{ required: true, message: "请输入分派比例", trigger: "blur" }],
type: 'select',
rules: [{ required: true, message: '请输入分派比例', trigger: 'blur' }],
},
{
label: "工艺能力",
prop: "platingId",
label: '工艺能力',
prop: 'platingId',
// bind: "bsCraftAbility.caId",
sortable: true,
sortable: 'custom',
filter: true,
span: 24,
minWidth: 150,
type: "select",
type: 'select',
search: true,
filterable: true,
// cell: true,
// type: "select",
dicUrl:"/api/blade-desk/BA/craftAbility/findList",
props:{
dicUrl: '/api/blade-desk/BA/craftAbility/findList',
props: {
label: 'caName',
value:'id'
}
value: 'id',
},
// dicData: [
// {
// value: 1,
@ -187,11 +231,11 @@ export default {
// rules: [{ required: true, message: "", trigger: "blur" }],
},
{
label: "零件",
prop: "dsPart",
label: '零件',
prop: 'dsPart',
// bind: "dsPart.partId",
sortable: true,
type: "select",
sortable: 'custom',
type: 'select',
filter: true,
span: 24,
search: false,
@ -211,48 +255,48 @@ export default {
// rules: [{ required: true, message: "", trigger: "blur" }],
},
{
label: "分派比例(%)",
prop: "assignScale",
label: '分派比例(%)',
prop: 'assignScale',
width: 150,
sortable: true,
sortable: 'custom',
filter: true,
span: 24,
search: false,
display: false,
// cell: true,
rules: [{ required: true, message: "请输入分派比例", trigger: "blur" }],
rules: [{ required: true, message: '请输入分派比例', trigger: 'blur' }],
},
{
label: "日分派量(d㎡)",
prop: "assign",
sortable: true,
label: '日分派量(d㎡)',
prop: 'assign',
sortable: 'custom',
filter: true,
width: 150,
span: 24,
search: false,
},
{
label: "厂家周累计分派量(dm²)",
prop: "weekAssign",
sortable: true,
label: '厂家周累计分派量(dm²)',
prop: 'weekAssign',
sortable: 'custom',
filter: true,
span: 24,
search: false,
width: 200,
},
{
label: "分类周累计分派量(dm²)",
prop: "classifyAssign",
sortable: true,
label: '分类周累计分派量(dm²)',
prop: 'classifyAssign',
sortable: 'custom',
filter: true,
span: 24,
search: false,
width: 200,
},
{
label: "比例偏差因子",
prop: "factor",
sortable: true,
label: '比例偏差因子',
prop: 'factor',
sortable: 'custom',
filter: true,
span: 24,
search: false,
@ -260,129 +304,134 @@ export default {
},
],
},
selectionList:[],
partLoading:false,
selectionList: [],
partLoading: false,
};
},
computed: {
...mapGetters(['permission']),
permissionList() {
return {
addRowBtn: this.validData(this.permission.outsourcingAssignmentControl_addRow, false),
};
},
},
mounted() {
this.getSupplierData()
this.getSupplierData();
// this.getAbility()
// this.getPartData()
},
methods: {
selectionChange(list){
this.selectionList = list
selectionChange(list) {
this.selectionList = list;
},
searchChange(params, done){
this.query = params
this.page.currentPage = 1
this.onLoad()
done()
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad();
done();
},
searchReset(){
this.query = {}
this.onLoad()
searchReset() {
this.query = {};
this.onLoad();
},
currentChange(currentPage){
this.page.currentPage = currentPage
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize){
this.page.pageSize = pageSize
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange(){
this.onLoad()
refreshChange() {
this.onLoad();
},
//
handleImport() {
this.isShowImport = true
this.isShowImport = true;
},
closeDialog(val) {
this.isShowImport = false
if(val){
this.onLoad()
this.isShowImport = false;
if (val) {
this.onLoad();
}
},
handleSave(){
submitBat(this.data).then(res =>{
if(res.data.code == 200){
this.$message.success("保存成功")
this.onLoad()
handleSave() {
submitBat(this.data).then(res => {
if (res.data.code == 200) {
this.$message.success('保存成功');
this.onLoad();
}
})
});
},
handleDelete(){
if(this.selectionList.length == 0){
this.$message.error('请至少选择一条数据')
return
handleDelete() {
if (this.selectionList.length == 0) {
this.$message.error('请至少选择一条数据');
return;
}
this.$confirm("确定将选择数据删除?", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}).then(() =>{
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(() => {
remove({
ids:this.selectionList.map(item => item.id).join(',')
}).then(res =>{
if(res.data.code == 200){
this.$message.success('删除成功')
this.onLoad()
ids: this.selectionList.map(item => item.id).join(','),
}).then(res => {
if (res.data.code == 200) {
this.$message.success('删除成功');
this.onLoad();
}
})
})
});
});
},
getSupplierData(){
getSupplier().then(res =>{
this.supplierData = res.data.data
})
getSupplierData() {
getSupplier().then(res => {
this.supplierData = res.data.data;
});
},
getAbility(){
getProcessAbility().then(res =>{
this.abilityData = res.data.data
})
getAbility() {
getProcessAbility().then(res => {
this.abilityData = res.data.data;
});
},
queryPart(query,index){
console.log('query----------------',query)
console.log('index----------------',index)
this.partLoading = true
if(query){
queryPart(query, index) {
console.log('query----------------', query);
console.log('index----------------', index);
this.partLoading = true;
if (query) {
getPartList({
current:1,
size:50,
partCode:query
}).then(res =>{
this.partData = res.data.data.records
this.partLoading = false
})
}else{
current: 1,
size: 50,
partCode: query,
}).then(res => {
this.partData = res.data.data.records;
this.partLoading = false;
});
} else {
getPartList({
current:1,
size:50,
}).then(res =>{
this.partData = res.data.data.records
let tmp = this.partData.find(item => item.id == this.data[index].dsPart)
if(!tmp){
current: 1,
size: 50,
}).then(res => {
this.partData = res.data.data.records;
let tmp = this.partData.find(item => item.id == this.data[index].dsPart);
if (!tmp) {
getPartList({
current:1,
size:50,
partCode:this.data[index].partCode
}).then(res =>{
this.partData = [...this.partData,...res.data.data.records]
this.partLoading = false
})
}else{
this.partLoading = false
current: 1,
size: 50,
partCode: this.data[index].partCode,
}).then(res => {
this.partData = [...this.partData, ...res.data.data.records];
this.partLoading = false;
});
} else {
this.partLoading = false;
}
})
});
}
},
getPartData(){
getPartList().then(res =>{
this.partData = res.data.data
})
getPartData() {
getPartList().then(res => {
this.partData = res.data.data;
});
},
// onLoad() {
// this.loading = true;
@ -409,30 +458,42 @@ export default {
//
handleSupplierChange(row) {
if (row.oemId) {
getProcessAbility({ supplierId: row.oemId }).then(res => {
row.abilityData = res.data.data || [];
//
row.platingId = '';
}).catch(() => {
row.abilityData = [];
row.platingId = '';
});
getProcessAbility({ supplierId: row.oemId })
.then(res => {
row.abilityData = res.data.data || [];
//
row.platingId = '';
})
.catch(() => {
row.abilityData = [];
row.platingId = '';
});
} else {
row.abilityData = [];
row.platingId = '';
}
},
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);
},
async onLoad() {
this.loading = true;
try {
const res = await getList({
current: this.page.currentPage,
size: this.page.pageSize,
...this.query
...this.query,
});
const records = res.data.data.records;
// 1. platingId select value
records.forEach(item => {
item.platingId = item.platingId ? String(item.platingId) : '';
@ -440,23 +501,23 @@ export default {
// 2.
// 使 Promise.all
const abilityPromises = records.map(async (item) => {
const abilityPromises = records.map(async item => {
if (item.oemId) {
try {
const abilityRes = await getProcessAbility({
supplierId: item.oemId
supplierId: item.oemId,
});
item.abilityData = abilityRes.data.data || []
item.abilityData = abilityRes.data.data || [];
// item
// this.$set(item, 'abilityData', abilityRes.data.data || []);
} catch (e) {
console.error('获取工艺能力失败', e);
// this.$set(item, 'abilityData', []);
item.abilityData = []
item.abilityData = [];
}
} else {
// this.$set(item, 'abilityData', []);
item.abilityData = []
item.abilityData = [];
}
});
@ -464,12 +525,11 @@ export default {
// 3. data
this.data = records;
this.data.forEach(item=>{
item.oemId = item.oemId==null?'':item.oemId+''
item.platingId = item.platingId==null?'':item.platingId+''
item.dsPart = item.dsPart==null?'':item.dsPart+''
})
this.data.forEach(item => {
item.oemId = item.oemId == null ? '' : item.oemId + '';
item.platingId = item.platingId == null ? '' : item.platingId + '';
item.dsPart = item.dsPart == null ? '' : item.dsPart + '';
});
this.page.total = res.data.data.total;
} catch (error) {
console.error(error);

Loading…
Cancel
Save