修改问题

dev-scheduling
zhangdi 2 months ago
parent 956c222f0d
commit 5ad03e9304
  1. 41
      src/components/jh-select/index.vue
  2. 496
      src/views/oem/oemCustomer/setCraftAbility.vue

@ -52,10 +52,10 @@ export default {
type: String,
default: '', // id
},
title:{
title: {
type: String,
default: '新增'
}
default: '新增',
},
},
data() {
return {
@ -69,6 +69,7 @@ export default {
dropdownVisible: false,
bindTimer: null,
total: 0,
isSearching: false, //
};
},
watch: {
@ -100,7 +101,14 @@ export default {
let timeout = null;
return (...args) => {
clearTimeout(timeout);
timeout = setTimeout(() => func.apply(this, args), wait);
// /
const validArgs = args
.map(arg => {
if (arg && arg.target) return arg.target.value; //
return arg;
})
.filter(arg => arg != null);
timeout = setTimeout(() => func.apply(this, validArgs), wait);
};
},
@ -172,7 +180,25 @@ export default {
},
handleSearch(val) {
this.searchText = val;
//
let searchVal = '';
// InputEvent
if (val && typeof val === 'object' && val.target) {
searchVal = (val.target.value || '').trim();
}
//
else {
searchVal = String(val || '').trim();
}
//
this.searchText = searchVal;
this.localValue = searchVal;
//
this.isSearching = true;
this.reset();
this.debounceSearch();
},
@ -210,7 +236,7 @@ export default {
//
async getEchoData(val) {
try {
const params = { [this.echoParamsKey]: val==null?'':val };
const params = { [this.echoParamsKey]: val == null ? '' : val };
let res;
if (this.echoMethod.toLowerCase() === 'post') {
res = await axios.post(this.echoApi, params);
@ -229,9 +255,10 @@ export default {
},
async initEcho() {
if (this.isSearching || this.searchText) return;
const val = this.localValue;
// (!val || !this.echoApi)&&
if (this.title=='新增') return;
if (this.title === '新增' || !val) return;
//
if (this.multiple && Array.isArray(val)) {

@ -1,7 +1,13 @@
<template>
<div>
<el-dialog title="设置工艺能力" v-model="setCrewShow" :before-close="cancel" width="60%" @open="open">
<!-- <avue-crud ref="crud" :option="option" :data="data" @row-update="rowUpdate" @row-save="rowSave"
<div>
<el-dialog
title="设置工艺能力"
v-model="setCrewShow"
:before-close="cancel"
width="60%"
@open="open"
>
<!-- <avue-crud ref="crud" :option="option" :data="data" @row-update="rowUpdate" @row-save="rowSave"
@row-click="handleRowClick">
<template #menu="{ row, index }">
<el-button text type="primary" :icon="row.$cellEdit ? 'el-icon-plus' : 'el-icon-edit'"
@ -14,74 +20,70 @@
</el-button>
</template>
</avue-crud> -->
<div>
<el-button type="primary" @click="insertEvent()"
>插入一行</el-button
>
<div>
<el-button type="primary" @click="insertEvent()">插入一行</el-button>
<el-button plain type="danger" @click="remove">删除选择行</el-button>
<!-- <el-button type="primary" @click="handleSave">保存</el-button> -->
</div>
<div style="margin-top: 20px">
<el-table
:data="capacityList"
@select="selectChange"
>
<el-table :data="capacityList" @select="selectChange">
<el-table-column type="selection" width="55px"></el-table-column>
<el-table-column align="center" label="工艺能力" prop="id">
<template #default="scope">
<el-select v-model="scope.row.id">
<el-option v-for="item in abilityList" :key="item.id" :label="item.caName" :value="item.id"></el-option>
<el-option
v-for="item in abilityList"
:key="item.id"
:label="item.caName"
:value="item.id"
></el-option>
</el-select>
</template>
</el-table-column>
<el-table-column align="center" label="计划员" prop="planner">
<template #default="scope">
<jhSelect
:value="scope.row.planner"
@input="val => (scope.row.planner = val)"
placeholder="请搜索选择"
api-url="/blade-system/user/page"
echo-api="/blade-system/user/page"
echoParamsKey="ids"
echo-method="get"
api-method="get"
list-key="records"
total-key="total"
label-key="realName"
value-key="id"
search-key="id"
:debounce-time="500"
@change="changeTeacher"
:title="'修改'"
/>
<!-- <el-select v-model="scope.row.planner" remote filterable :remote-method="getPlanner">
<jhSelect
:value="scope.row.planner"
placeholder="请搜索选择"
api-url="/blade-system/user/page"
echo-api="/blade-system/user/page"
echoParamsKey="ids"
echo-method="get"
api-method="get"
list-key="records"
total-key="total"
label-key="realName"
value-key="id"
search-key="realName"
:debounce-time="500"
:title="'修改'"
/>
<!-- <el-select v-model="scope.row.planner" remote filterable :remote-method="getPlanner">
<el-option v-for="item in plannerList" :key="item.id" :label="item.realName" :value="item.id"></el-option>
</el-select> -->
</template>
</el-table-column>
<el-table-column align="center" label="调度员" prop="dispatcher">
<template #default="scope">
<!-- <el-select v-model="scope.row.dispatcher" remote filterable :remote-method="getDispatcher">
<!-- <el-select v-model="scope.row.dispatcher" remote filterable :remote-method="getDispatcher">
<el-option v-for="item in dispatcherList" :key="item.id" :label="item.realName" :value="item.id"></el-option>
</el-select> -->
<jhSelect
:value="scope.row.dispatcher"
@input="val => (scope.row.dispatcher = val)"
placeholder="请搜索选择"
api-url="/blade-system/user/page"
echo-api="/blade-system/user/page"
echoParamsKey="ids"
echo-method="get"
api-method="get"
list-key="records"
total-key="total"
label-key="realName"
value-key="id"
search-key="id"
:debounce-time="500"
@change="changeTeacher"
:title="'修改'"
/>
<jhSelect
:value="scope.row.dispatcher"
placeholder="请搜索选择"
api-url="/blade-system/user/page"
echo-api="/blade-system/user/page"
echoParamsKey="ids"
echo-method="get"
api-method="get"
list-key="records"
total-key="total"
label-key="realName"
value-key="id"
search-key="realName"
:debounce-time="500"
:title="'修改'"
/>
</template>
</el-table-column>
<el-table-column align="center" label="是否大批量" prop="isBatch">
@ -91,216 +93,216 @@
</el-table-column>
</el-table>
</div>
<template #footer>
<div class="dialog-footer">
<el-button @click="cancel()">取消</el-button>
<el-button type="primary" @click="submit()"> 确认</el-button>
</div>
</template>
<template #footer>
<div class="dialog-footer">
<el-button @click="cancel()">取消</el-button>
<el-button type="primary" @click="submit()"> 确认</el-button>
</div>
</template>
</el-dialog>
</div>
</div>
</template>
<script>
import {getCraftAbility,getAbility,getAllUser,saveCraft} from "@/api/basicData/oemCustomer"
import { getCraftAbility, getAbility, getAllUser, saveCraft } from '@/api/basicData/oemCustomer';
import jhSelect from '@/components/jh-select/index.vue';
export default {
props: {
setCraftAbilityOpen: {
type: Boolean,
default: false
},
ocId: {
type: Number,
default: null
}
props: {
setCraftAbilityOpen: {
type: Boolean,
default: false,
},
ocId: {
type: Number,
default: null,
},
},
components: {
jhSelect,
},
data() {
return {
setCrewShow: false,
loading: false,
formData: {},
abilityList: [],
plannerList: [],
dispatcherList: [],
capacityList: [],
data: [],
};
},
mounted() {
this.getAbilityData();
this.getAbilitySelect();
},
methods: {
getAbilitySelect() {
getAbility().then(res => {
this.abilityList = res.data.data;
});
},
async getAbilityData() {
const res = await getCraftAbility({
id: this.ocId,
});
this.capacityList = res.data.data;
// const user = await getAllUser({current:1,size:9999})
// this.plannerList = user.data.data.records
// this.dispatcherList = user.data.data.records
this.capacityList.map(item => {
item.dispatcher =
item.dispatcher == null || item.dispatcher == -1 ? '' : item.dispatcher + '';
item.planner = item.planner == null || item.planner == -1 ? '' : item.planner + '';
item.isBatch = item.isBatch == '1' ? true : false;
item._select = false;
// if(item.dispatcherName != ''){
// getAllUser({realName:item.dispatcherName}).then(res =>{
// const mergedData = [...this.dispatcherList, ...res.data.data.records];
// const uniqueData = Array.from(
// new Map(mergedData.map(item => [item.id, item])).values()
// );
// this.dispatcherList = uniqueData
// })
// }
// if(item.plannerName != ''){
// getAllUser({realName:item.plannerName}).then(res =>{
// const mergedData = [...this.plannerList, ...res.data.data.records];
// const uniqueData = Array.from(
// new Map(mergedData.map(item => [item.id, item])).values()
// );
// this.plannerList = uniqueData
// })
// }
});
this.setCrewShow = this.setCraftAbilityOpen;
},
getPlanner(query) {
// if(query == ''){
// getAllUser({
// current:1,
// size:9999
// }).then(res =>{
// this.plannerList = res.data.data.records
// })
// }else{
// getAllUser({
// realName:query
// }).then(res =>{
// this.plannerList = res.data.data.records
// })
// }
},
getDispatcher(query) {
// if(query == ''){
// getAllUser({
// current:1,
// size:9999
// }).then(res =>{
// this.dispatcherList = res.data.data.records
// })
// }else{
// getAllUser({
// realName:query
// }).then(res =>{
// this.dispatcherList = res.data.data.records
// })
// }
},
components: {
jhSelect
insertEvent() {
const record = { _select: false };
this.capacityList.push(record);
},
data() {
return {
setCrewShow: false,
loading: false,
formData: {},
abilityList:[],
plannerList:[],
dispatcherList:[],
capacityList:[],
data: [],
};
selectChange(list, row) {
row._select = !row._select;
},
mounted() {
this.getAbilityData()
this.getAbilitySelect()
remove() {
let arr = this.capacityList.filter(item => item._select);
if (arr.length != 0) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(() => {
if (this.rowId) {
let deleteData = this.capacityList.filter(item => item._select);
this.deleteTidArr = deleteData.filter(item => item.tidId);
}
let deleteArr = this.capacityList.filter(item => !item._select);
this.capacityList = deleteArr;
});
} else {
this.$message.error('请至少选择一条数据进行操作!');
}
},
methods: {
getAbilitySelect(){
getAbility().then(res =>{
this.abilityList = res.data.data
})
},
async getAbilityData(){
const res = await getCraftAbility({
id:this.ocId
})
this.capacityList = res.data.data
// const user = await getAllUser({current:1,size:9999})
// this.plannerList = user.data.data.records
// this.dispatcherList = user.data.data.records
this.capacityList.map(item =>{
item.dispatcher = item.dispatcher==null||item.dispatcher==-1?'':item.dispatcher + ''
item.planner = item.planner==null||item.planner==-1?'':item.planner + ''
item.isBatch = item.isBatch == '1' ? true : false
item._select = false
// if(item.dispatcherName != ''){
// getAllUser({realName:item.dispatcherName}).then(res =>{
// const mergedData = [...this.dispatcherList, ...res.data.data.records];
// const uniqueData = Array.from(
// new Map(mergedData.map(item => [item.id, item])).values()
// );
// this.dispatcherList = uniqueData
// })
// }
// if(item.plannerName != ''){
// getAllUser({realName:item.plannerName}).then(res =>{
// const mergedData = [...this.plannerList, ...res.data.data.records];
// const uniqueData = Array.from(
// new Map(mergedData.map(item => [item.id, item])).values()
// );
// this.plannerList = uniqueData
// })
// }
})
this.setCrewShow = this.setCraftAbilityOpen
},
getPlanner(query){
// if(query == ''){
// getAllUser({
// current:1,
// size:9999
// }).then(res =>{
// this.plannerList = res.data.data.records
// })
// }else{
// getAllUser({
// realName:query
// }).then(res =>{
// this.plannerList = res.data.data.records
// })
// }
},
getDispatcher(query){
// if(query == ''){
// getAllUser({
// current:1,
// size:9999
// }).then(res =>{
// this.dispatcherList = res.data.data.records
// })
// }else{
// getAllUser({
// realName:query
// }).then(res =>{
// this.dispatcherList = res.data.data.records
// })
// }
},
insertEvent(){
const record = { _select: false };
this.capacityList.push(record)
},
selectChange(list, row) {
row._select = !row._select;
},
remove() {
let arr = this.capacityList.filter((item) => item._select);
if (arr.length != 0) {
this.$confirm("确定将选择数据删除?", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}).then(() => {
if (this.rowId) {
let deleteData = this.capacityList.filter((item) => item._select);
this.deleteTidArr = deleteData.filter((item) => item.tidId);
}
let deleteArr = this.capacityList.filter((item) => !item._select);
this.capacityList = deleteArr;
});
} else {
this.$message.error("请至少选择一条数据进行操作!");
}
},
handleRowClick(row) {
this.$message({
showClose: true,
message: '序号: ' + row.id,
type: 'success'
})
},
open() {
// this.formData.ocId = this.id;
// if (this.id != null) {
// this.$ajax.get('bsOemCustomer/getByKey/' + this.id).then((res) => {
// if (this.$ifAjax(res)) {
// this.formData = res.data;
// }
// });
// }
},
submit() {
console.log('ca----------',this.capacityList)
if(this.capacityList.length == 0){
this.$message.error('请至少新增一条数据')
return
}
let data = []
this.capacityList.map(item =>{
data.push({
id:item.id,
planner:item.planner,
dispatcher:item.dispatcher,
isBatch:item.isBatch ? '1' : '0'
})
})
let params = {
id:this.ocId,
crafs:data
}
handleRowClick(row) {
this.$message({
showClose: true,
message: '序号: ' + row.id,
type: 'success',
});
},
open() {
// this.formData.ocId = this.id;
// if (this.id != null) {
// this.$ajax.get('bsOemCustomer/getByKey/' + this.id).then((res) => {
// if (this.$ifAjax(res)) {
// this.formData = res.data;
// }
// });
// }
},
submit() {
console.log('ca----------', this.capacityList);
if (this.capacityList.length == 0) {
this.$message.error('请至少新增一条数据');
return;
}
let data = [];
this.capacityList.map(item => {
data.push({
id: item.id,
planner: item.planner,
dispatcher: item.dispatcher,
isBatch: item.isBatch ? '1' : '0',
});
});
let params = {
id: this.ocId,
crafs: data,
};
saveCraft(params).then(res =>{
if(res.data.code === 200){
this.$message.success('工艺能力设置成功');
this.cancel(true)
}
})
saveCraft(params).then(res => {
if (res.data.code === 200) {
this.$message.success('工艺能力设置成功');
this.cancel(true);
}
});
// this.cancel(false)
// this.$refs.form.validate((valid) => {
// if (valid) {
// this.$ajax
// .post('bsOemCustomer/setPassword', this.formData)
// .then((res) => {
// if (this.$ifAjax(res)) {
// this.$message.success(this.$t('global.saveOk'));
// this.cancel(true);
// }
// });
// }
// });
},
// this.cancel(false)
// this.$refs.form.validate((valid) => {
// if (valid) {
// this.$ajax
// .post('bsOemCustomer/setPassword', this.formData)
// .then((res) => {
// if (this.$ifAjax(res)) {
// this.$message.success(this.$t('global.saveOk'));
// this.cancel(true);
// }
// });
// }
// });
},
onCancel() {
this.cancel(false);
},
cancel(isRefresh) {
this.setCrewShow = false
onCancel() {
this.cancel(false);
},
cancel(isRefresh) {
this.setCrewShow = false;
this.formData = { ocId: null };
// this.$refs.form.resetFields();
this.$emit('cancel', typeof isRefresh === 'boolean' && isRefresh);
}
this.formData = { ocId: null };
// this.$refs.form.resetFields();
this.$emit('cancel', typeof isRefresh === 'boolean' && isRefresh);
},
},
};
</script>

Loading…
Cancel
Save