修改问题

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

@ -54,8 +54,8 @@ export default {
}, },
title: { title: {
type: String, type: String,
default: '新增' default: '新增',
} },
}, },
data() { data() {
return { return {
@ -69,6 +69,7 @@ export default {
dropdownVisible: false, dropdownVisible: false,
bindTimer: null, bindTimer: null,
total: 0, total: 0,
isSearching: false, //
}; };
}, },
watch: { watch: {
@ -100,7 +101,14 @@ export default {
let timeout = null; let timeout = null;
return (...args) => { return (...args) => {
clearTimeout(timeout); 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) { 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.reset();
this.debounceSearch(); this.debounceSearch();
}, },
@ -229,9 +255,10 @@ export default {
}, },
async initEcho() { async initEcho() {
if (this.isSearching || this.searchText) return;
const val = this.localValue; const val = this.localValue;
// (!val || !this.echoApi)&& // (!val || !this.echoApi)&&
if (this.title=='新增') return; if (this.title === '新增' || !val) return;
// //
if (this.multiple && Array.isArray(val)) { if (this.multiple && Array.isArray(val)) {

@ -1,6 +1,12 @@
<template> <template>
<div> <div>
<el-dialog title="设置工艺能力" v-model="setCrewShow" :before-close="cancel" width="60%" @open="open"> <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" <!-- <avue-crud ref="crud" :option="option" :data="data" @row-update="rowUpdate" @row-save="rowSave"
@row-click="handleRowClick"> @row-click="handleRowClick">
<template #menu="{ row, index }"> <template #menu="{ row, index }">
@ -15,22 +21,22 @@
</template> </template>
</avue-crud> --> </avue-crud> -->
<div> <div>
<el-button type="primary" @click="insertEvent()" <el-button type="primary" @click="insertEvent()">插入一行</el-button>
>插入一行</el-button
>
<el-button plain type="danger" @click="remove">删除选择行</el-button> <el-button plain type="danger" @click="remove">删除选择行</el-button>
<!-- <el-button type="primary" @click="handleSave">保存</el-button> --> <!-- <el-button type="primary" @click="handleSave">保存</el-button> -->
</div> </div>
<div style="margin-top: 20px"> <div style="margin-top: 20px">
<el-table <el-table :data="capacityList" @select="selectChange">
:data="capacityList"
@select="selectChange"
>
<el-table-column type="selection" width="55px"></el-table-column> <el-table-column type="selection" width="55px"></el-table-column>
<el-table-column align="center" label="工艺能力" prop="id"> <el-table-column align="center" label="工艺能力" prop="id">
<template #default="scope"> <template #default="scope">
<el-select v-model="scope.row.id"> <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> </el-select>
</template> </template>
</el-table-column> </el-table-column>
@ -38,7 +44,6 @@
<template #default="scope"> <template #default="scope">
<jhSelect <jhSelect
:value="scope.row.planner" :value="scope.row.planner"
@input="val => (scope.row.planner = val)"
placeholder="请搜索选择" placeholder="请搜索选择"
api-url="/blade-system/user/page" api-url="/blade-system/user/page"
echo-api="/blade-system/user/page" echo-api="/blade-system/user/page"
@ -49,9 +54,8 @@
total-key="total" total-key="total"
label-key="realName" label-key="realName"
value-key="id" value-key="id"
search-key="id" search-key="realName"
:debounce-time="500" :debounce-time="500"
@change="changeTeacher"
:title="'修改'" :title="'修改'"
/> />
<!-- <el-select v-model="scope.row.planner" remote filterable :remote-method="getPlanner"> <!-- <el-select v-model="scope.row.planner" remote filterable :remote-method="getPlanner">
@ -66,7 +70,6 @@
</el-select> --> </el-select> -->
<jhSelect <jhSelect
:value="scope.row.dispatcher" :value="scope.row.dispatcher"
@input="val => (scope.row.dispatcher = val)"
placeholder="请搜索选择" placeholder="请搜索选择"
api-url="/blade-system/user/page" api-url="/blade-system/user/page"
echo-api="/blade-system/user/page" echo-api="/blade-system/user/page"
@ -77,9 +80,8 @@
total-key="total" total-key="total"
label-key="realName" label-key="realName"
value-key="id" value-key="id"
search-key="id" search-key="realName"
:debounce-time="500" :debounce-time="500"
@change="changeTeacher"
:title="'修改'" :title="'修改'"
/> />
</template> </template>
@ -101,21 +103,21 @@
</div> </div>
</template> </template>
<script> <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'; import jhSelect from '@/components/jh-select/index.vue';
export default { export default {
props: { props: {
setCraftAbilityOpen: { setCraftAbilityOpen: {
type: Boolean, type: Boolean,
default: false default: false,
}, },
ocId: { ocId: {
type: Number, type: Number,
default: null default: null,
} },
}, },
components: { components: {
jhSelect jhSelect,
}, },
data() { data() {
return { return {
@ -130,28 +132,29 @@ export default {
}; };
}, },
mounted() { mounted() {
this.getAbilityData() this.getAbilityData();
this.getAbilitySelect() this.getAbilitySelect();
}, },
methods: { methods: {
getAbilitySelect() { getAbilitySelect() {
getAbility().then(res => { getAbility().then(res => {
this.abilityList = res.data.data this.abilityList = res.data.data;
}) });
}, },
async getAbilityData() { async getAbilityData() {
const res = await getCraftAbility({ const res = await getCraftAbility({
id:this.ocId id: this.ocId,
}) });
this.capacityList = res.data.data this.capacityList = res.data.data;
// const user = await getAllUser({current:1,size:9999}) // const user = await getAllUser({current:1,size:9999})
// this.plannerList = user.data.data.records // this.plannerList = user.data.data.records
// this.dispatcherList = user.data.data.records // this.dispatcherList = user.data.data.records
this.capacityList.map(item => { this.capacityList.map(item => {
item.dispatcher = item.dispatcher==null||item.dispatcher==-1?'':item.dispatcher + '' item.dispatcher =
item.planner = item.planner==null||item.planner==-1?'':item.planner + '' item.dispatcher == null || item.dispatcher == -1 ? '' : item.dispatcher + '';
item.isBatch = item.isBatch == '1' ? true : false item.planner = item.planner == null || item.planner == -1 ? '' : item.planner + '';
item._select = false item.isBatch = item.isBatch == '1' ? true : false;
item._select = false;
// if(item.dispatcherName != ''){ // if(item.dispatcherName != ''){
// getAllUser({realName:item.dispatcherName}).then(res =>{ // getAllUser({realName:item.dispatcherName}).then(res =>{
// const mergedData = [...this.dispatcherList, ...res.data.data.records]; // const mergedData = [...this.dispatcherList, ...res.data.data.records];
@ -170,8 +173,8 @@ export default {
// this.plannerList = uniqueData // this.plannerList = uniqueData
// }) // })
// } // }
}) });
this.setCrewShow = this.setCraftAbilityOpen this.setCrewShow = this.setCraftAbilityOpen;
}, },
getPlanner(query) { getPlanner(query) {
// if(query == ''){ // if(query == ''){
@ -207,36 +210,36 @@ export default {
}, },
insertEvent() { insertEvent() {
const record = { _select: false }; const record = { _select: false };
this.capacityList.push(record) this.capacityList.push(record);
}, },
selectChange(list, row) { selectChange(list, row) {
row._select = !row._select; row._select = !row._select;
}, },
remove() { remove() {
let arr = this.capacityList.filter((item) => item._select); let arr = this.capacityList.filter(item => item._select);
if (arr.length != 0) { if (arr.length != 0) {
this.$confirm("确定将选择数据删除?", { this.$confirm('确定将选择数据删除?', {
confirmButtonText: "确定", confirmButtonText: '确定',
cancelButtonText: "取消", cancelButtonText: '取消',
type: "warning", type: 'warning',
}).then(() => { }).then(() => {
if (this.rowId) { if (this.rowId) {
let deleteData = this.capacityList.filter((item) => item._select); let deleteData = this.capacityList.filter(item => item._select);
this.deleteTidArr = deleteData.filter((item) => item.tidId); this.deleteTidArr = deleteData.filter(item => item.tidId);
} }
let deleteArr = this.capacityList.filter((item) => !item._select); let deleteArr = this.capacityList.filter(item => !item._select);
this.capacityList = deleteArr; this.capacityList = deleteArr;
}); });
} else { } else {
this.$message.error("请至少选择一条数据进行操作!"); this.$message.error('请至少选择一条数据进行操作!');
} }
}, },
handleRowClick(row) { handleRowClick(row) {
this.$message({ this.$message({
showClose: true, showClose: true,
message: '序号: ' + row.id, message: '序号: ' + row.id,
type: 'success' type: 'success',
}) });
}, },
open() { open() {
// this.formData.ocId = this.id; // this.formData.ocId = this.id;
@ -249,31 +252,31 @@ export default {
// } // }
}, },
submit() { submit() {
console.log('ca----------',this.capacityList) console.log('ca----------', this.capacityList);
if (this.capacityList.length == 0) { if (this.capacityList.length == 0) {
this.$message.error('请至少新增一条数据') this.$message.error('请至少新增一条数据');
return return;
} }
let data = [] let data = [];
this.capacityList.map(item => { this.capacityList.map(item => {
data.push({ data.push({
id: item.id, id: item.id,
planner: item.planner, planner: item.planner,
dispatcher: item.dispatcher, dispatcher: item.dispatcher,
isBatch:item.isBatch ? '1' : '0' isBatch: item.isBatch ? '1' : '0',
}) });
}) });
let params = { let params = {
id: this.ocId, id: this.ocId,
crafs:data crafs: data,
} };
saveCraft(params).then(res => { saveCraft(params).then(res => {
if (res.data.code === 200) { if (res.data.code === 200) {
this.$message.success('工艺能力设置成功'); this.$message.success('工艺能力设置成功');
this.cancel(true) this.cancel(true);
} }
}) });
// this.cancel(false) // this.cancel(false)
// this.$refs.form.validate((valid) => { // this.$refs.form.validate((valid) => {
@ -294,13 +297,12 @@ export default {
this.cancel(false); this.cancel(false);
}, },
cancel(isRefresh) { cancel(isRefresh) {
this.setCrewShow = false this.setCrewShow = false;
this.formData = { ocId: null }; this.formData = { ocId: null };
// this.$refs.form.resetFields(); // this.$refs.form.resetFields();
this.$emit('cancel', typeof isRefresh === 'boolean' && isRefresh); this.$emit('cancel', typeof isRefresh === 'boolean' && isRefresh);
}
}, },
},
}; };
</script> </script>

Loading…
Cancel
Save