schangxiang@126.com
2025-09-10 3d43ffa3152110b7823f9fa6320c08a6ae02358a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<template>
  <div :ref="'settings'" class="settings-sub-container">
    <el-form ref="form" label-width="120px">
      <el-form-item label="库区名称">
        <template v-for="(item, index) in valueList">
          <el-input v-if="modifyInputVisible==item" v-model="modifyInputValue" :key="index" :ref="'modifyTagInput'+index" class="input-new-tag" size="small" @keyup.enter.native="modifyInputConfirm(item)" @blur="modifyInputConfirm(item)">
          </el-input>
          <el-tag v-else :key="index" :disable-transitions="false" closable @close="handleClose(item)" @click.native="modifyShowInput(item, index)">
            {{ item.value02 }}
          </el-tag>
 
        </template>
 
        <el-input v-if="addInputVisible" ref="addTagInput" v-model="addInputValue" class="input-new-tag" size="small" @keyup.enter.native="addInputConfirm" @blur="addInputConfirm">
        </el-input>
        <el-button v-else class="button-new-tag" size="small" @click="addShowInput">+ 添加项</el-button>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSave">保存</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
 
<script>
export default {
  name: "settings-consignor",
 
  components: {},
  data() {
    return {
      type_Id: 735, // 下拉框值类别ID
      valueList: [],
      addInputVisible: false,
      modifyInputVisible: false,
      addInputValue: "",
      modifyInputValue: ""
    };
  },
  mounted() {
    this.loadParam();
  },
  methods: {
    handleClose(tag) {
      this.valueList.splice(this.valueList.indexOf(tag), 1);
    },
 
    modifyShowInput(item, index) {
      this.modifyInputValue = item.value02;
      this.modifyInputVisible = item;
      this.$nextTick(_ => {
        this.$refs["modifyTagInput" + index][0].$refs.input.focus();
      });
    },
 
    modifyInputConfirm(item) {
      item.value02 = this.modifyInputValue;
      this.modifyInputVisible = false;
      this.modifyInputValue = "";
    },
 
    addShowInput() {
      this.addInputVisible = true;
      this.$nextTick(_ => {
        this.$refs.addTagInput.$refs.input.focus();
      });
    },
 
    addInputConfirm() {
      const addInputValue = this.addInputValue;
      if (addInputValue) {
        this.valueList.push({
          Params_Id: 0,
          UserProduct_Id: null,
          value02: addInputValue
        });
      }
      this.addInputVisible = false;
      this.addInputValue = "";
    },
    // 加载数据
    loadParam() {
      const url = "/api/sys/param/getValueList";
      var params = {
        type_Id: this.type_Id
      };
      var callback = res => {
        this.common.showMsg(res);
        // 获得参数值列表
        this.valueList = res.data || [];
      };
      var target = this.$refs["settings"];
      this.common.ajax(url, params, callback, target);
    },
    // 保存数据
    onSave() {
      var url = "/api/sys/param/saveParams";
      var params = {
        openNodeApi: true,
        type_Id: this.type_Id,
        valueList: this.valueList
      };
      var target = this.$refs["settings"];
      this.common.ajax(
        url,
        params,
        res => {
          this.common.showMsg(res);
        },
        target
      );
    }
  }
};
</script>
 
<style lang="scss">
.settings-sub-container {
  .el-tag + .el-tag {
    margin-left: 10px;
  }
  .button-new-tag {
    margin-left: 10px;
    height: 32px;
    line-height: 30px;
    padding-top: 0;
    padding-bottom: 0;
  }
  .input-new-tag {
    width: 90px;
    margin-left: 10px;
    margin-right: 10px;
    vertical-align: bottom;
  }
 
  .footer {
    width: 920px;
    padding: 40px 10px 20px;
    text-align: center;
    .msg {
      line-height: 1.5;
      margin-top: 30px;
      text-align: left;
      font-size: 14px;
    }
  }
  .demo.el-alert {
    display: inline-table;
    /deep/ .el-alert__icon {
      position: relative;
      top: 20px;
    }
  }
}
</style>