|
|
@@ -297,7 +297,7 @@
|
|
|
<el-row>
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="玛氏岗位" prop="workstationId">
|
|
|
- <el-select size="small" v-model="form.workstationIds" placeholder="请选择" :popper-append-to-body="false" multiple clearable
|
|
|
+ <el-select size="small" v-model="form.workstationIds" placeholder="请选择" :popper-append-to-body="false" multiple
|
|
|
@remove-tag="removeTag" >
|
|
|
<el-option :value="selectTreeValue" class="setstyle" disabled>
|
|
|
<el-input class="setinput" size="mini" placeholder="输入关键字进行过滤" clearable v-model="filterText"></el-input>
|
|
|
@@ -534,7 +534,6 @@ export default {
|
|
|
addTag(node) {
|
|
|
this.selectTreeValue.push({ id: node.id, label: node.label });
|
|
|
this.form.workstationIds.push(node.label);
|
|
|
-
|
|
|
// 更新树的选中状态
|
|
|
this.$nextTick(() => {
|
|
|
this.$refs.treeRef.setCheckedNodes(this.selectTreeValue.map(item => ({ id: item.id, label: item.label })));
|
|
|
@@ -564,25 +563,21 @@ export default {
|
|
|
|
|
|
// 编辑回显选中节点
|
|
|
editTag(workstationIds) {
|
|
|
- console.log(workstationIds,'workstationIds')
|
|
|
const workstationNames = workstationIds.map(workstationId => {
|
|
|
const record = this.MarsWordStationOptions.find(record => record.workstationId === workstationId);
|
|
|
return record ? { id: record.workstationId, label: record.workstationName } : null;
|
|
|
}).filter(node => node !== null);
|
|
|
|
|
|
- // 更新到 form
|
|
|
- this.form.workstationIds = workstationNames.map(node => node.label);
|
|
|
-
|
|
|
- // 同步树选中状态
|
|
|
- this.selectTreeValue = workstationNames;
|
|
|
this.$nextTick(() => {
|
|
|
this.$refs.treeRef.setCheckedNodes(workstationNames);
|
|
|
});
|
|
|
+ this.form.workstationIds = workstationNames.map(node => node.name);
|
|
|
},
|
|
|
// 节点选中
|
|
|
handleCheckChange(data, checked, indeterminate) {
|
|
|
if (checked) {
|
|
|
this.addTag(data); // 调用 addTag 方法
|
|
|
+
|
|
|
} else {
|
|
|
this.removeTag(data.label); // 调用 removeTag 方法
|
|
|
|
|
|
@@ -680,6 +675,16 @@ export default {
|
|
|
handleAdd() {
|
|
|
this.reset();
|
|
|
this.getTreeselect();
|
|
|
+ // 清空选中节点并重置 form.workstationIds
|
|
|
+ this.$nextTick(() => {
|
|
|
+ if (this.$refs.treeRef) {
|
|
|
+ this.$refs.treeRef.setCheckedKeys([]);
|
|
|
+ this.form.workstationIds = [];
|
|
|
+ } else {
|
|
|
+ console.error('treeRef is not defined');
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
getUser().then(response => {
|
|
|
this.postOptions = response.posts;
|
|
|
this.roleOptions = response.roles;
|
|
|
@@ -732,6 +737,12 @@ export default {
|
|
|
this.$refs["form"].validate(valid => {
|
|
|
if (valid) {
|
|
|
if (this.form.userId != undefined) {
|
|
|
+ // 文字转换
|
|
|
+ const workstationIds = this.form.workstationIds.map(deviceName => {
|
|
|
+ const record = this.MarsWordStationOptions.find(record => record.workstationName == deviceName);
|
|
|
+ return record ? record.workstationId : null;
|
|
|
+ }).filter(id => id !== null);
|
|
|
+ this.form.workstationIds=workstationIds
|
|
|
updateUser(this.form).then(response => {
|
|
|
this.$modal.msgSuccess("修改成功");
|
|
|
this.open = false;
|