ke_junjie
2025-06-04 bb6e2230bb8ded3c5546bc4e4c282ee343754475
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
<template>
  <div class="maintaskEdit height overflow">
    <div class="centent-form overflowy-auto">
      <el-form
        class="margin-auto width90"
        ref="registerForm"
        :model="registerForm"
        size="mini"
        :rules="rules"
        label-position="left"
        label-width="100px"
      >
        <el-form-item label="任务类型:" prop="taskType">
          <el-select v-model="registerForm.taskType" @change="taskchange" clearable placeholder="请选择">
            <el-option
              v-for="(item, index) in taskTypeList"
              :key="index + 'taskType'"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="起始位:" prop="sourcePlace">
          <el-select v-model="registerForm.sourcePlace" filterable clearable placeholder="请选择">
            <el-option
              v-for="(item, index) in sourcePlaceList"
              :key="index + 'sourcePlace'"
              :label="item.placeName"
              :value="item.placeCode"
            >
            </el-option>
          </el-select>
        </el-form-item>
 
        <el-form-item label="目标位:" prop="toPlace">
          <el-select v-model="registerForm.toPlace" filterable clearable placeholder="请选择">
            <el-option
              v-for="(item, index) in toPlaceList"
              :key="index + 'toPlace'"
              :label="item.placeName"
              :value="item.placeCode"
            >
            </el-option>
          </el-select>
        </el-form-item>
 
        <el-form-item label="任务优先级:" prop="taskLevel">
          <el-input oninput="value=value.replace(/[^\d.]/g,'')" v-model="registerForm.taskLevel" clearable></el-input>
        </el-form-item>
        <el-form-item label="托盘号:" prop="containerName">
          <el-select
            v-model="registerForm.containerName"
            filterable
            remote
            reserve-keyword
            :remote-method="remoteMethod"
            :loading="remoloading"
            clearable
            placeholder="请选择"
          >
            <el-option
              v-for="(item, index) in containerNameList"
              :key="index + 'containerName'"
              :label="item.containerName"
              :value="item.containerName"
            >
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
    </div>
    <div class="maintaskEdit-button text-right margin-right15 margin-top2">
      <el-button type="primary" size="mini" class="form-buttom" @click="submitForm('registerForm')">提交</el-button>
      <el-button type="primary" size="mini" class="form-buttom" @click="$emit('cancel')">取消</el-button>
    </div>
  </div>
</template>
 
<script>
import { TaskAddOrUpdate } from '@/api/maintask';
import { ContainerSearch } from '@/api/palte';
import { getCache } from '@/utils/sessionStorage';
import { PlaceGetPlace } from '@/api/position';
export default {
  data() {
    return {
      registerForm: {
        sourcePlace: '',
        toPlace: '',
        taskType: '',
        taskStatus: '新建',
        userName: getCache('userInfo').userName,
        taskLevel: '',
        hasReaded: 0,
        containerName: ''
      },
      remoloading: false,
      sourcePlace: '', //起始位
      toPlace: '', //目标位
      sourcePlaceList: [],
      toPlaceList: [],
      taskTypeList: [
        {
          label: '入库',
          value: 1
        },
        {
          label: '出库',
          value: 2
        },
        {
          label: '移库',
          value: 3
        }
      ],
      containerNameList: [],
      disabled: false,
      createLineList: [],
 
      rules: {
        sourcePlace: { required: true, message: '请选择起始位', trigger: 'change' },
        toPlace: { required: true, message: '请选择目标位', trigger: 'change' },
        taskType: { required: true, message: '请选择任务类型', trigger: 'change' },
        taskLevel: { required: true, message: '请输入任务优先级', trigger: 'change' },
        containerName: { required: false, message: '请输入托盘号', trigger: 'change' }
      }
    };
  },
  props: {
    rowitem: {
      type: Object,
      default: {}
    }
  },
  mounted() {
    if (JSON.stringify(this.rowitem) != '{}') {
      this.registerForm = this.rowitem;
      this.sourcePlace = this.rowitem.sourcePlace; //起始位
      this.toPlace = this.rowitem.toPlace; //目标位
      this.registerForm.taskType =
        this.registerForm.taskType == '入库'
          ? 1
          : this.registerForm.taskType == '出库'
          ? 2
          : this.registerForm.taskType == '移库'
          ? 3
          : this.registerForm.taskType;
      this.disabled = true;
    } else {
      this.disabled = false;
    }
    this.ContainerSearch({ containerName: '' });
    this.sourcePlacePlaceGetPlace();
    this.toPlacePlacePlaceGetPlace();
  },
  methods: {
    //器具
    ContainerSearch(query) {
      const { containerName } = query;
      ContainerSearch('1&onePageNum=999', { containerName }).then(res => {
        if (res.code == 0) {
          let data = res.data || [];
          this.containerNameList = data;
        }
      });
    },
    remoteMethod(query) {
      if (query !== '') {
        this.remoloading = true;
        setTimeout(() => {
          this.remoloading = false;
          this.ContainerSearch({ containerName: query });
        }, 200);
      }
    },
    //起始位库位
    sourcePlacePlaceGetPlace() {
      let taskType = this.registerForm.taskType ? this.registerForm.taskType : 1;
      PlaceGetPlace({ isSourcePlace: 1, taskType: taskType }).then(res => {
        if (res.code == 0) {
          this.sourcePlaceList = res.data;
          if (this.registerForm.sourcePlace) {
            this.registerForm.sourcePlace = res.data.filter(item => {
              if (item.placeCode == this.registerForm.sourcePlace) {
                return item.placeName;
              }
            });
          }
        }
      });
    },
    //目标位
    toPlacePlacePlaceGetPlace() {
      let taskType = this.registerForm.taskType ? this.registerForm.taskType : 1;
      PlaceGetPlace({ isSourcePlace: 0, taskType: taskType }).then(res => {
        if (res.code == 0) {
          this.toPlaceList = res.data;
          if (this.registerForm.sourcePlace) {
            this.registerForm.toPlace = res.data.filter(item => {
              if (item.placeCode == this.registerForm.toPlace) {
                return item.placeName;
              }
            });
          }
        }
      });
    },
    //任务类型
    taskchange() {
      this.registerForm.sourcePlace = '';
      this.registerForm.toPlace = '';
      this.sourcePlaceList = [];
      this.toPlaceList = [];
      this.sourcePlacePlaceGetPlace();
      this.toPlacePlacePlaceGetPlace();
       let taskType = this.registerForm.taskType ? this.registerForm.taskType : 1;
      this.rules.containerName.message="";
      if(taskType==1)
      {
      this.rules.containerName.required=true;
 
      }else
      {
         this.rules.containerName.required=false;
      }
    },
    submitForm(registerForm) {
      console.log(this.registerForm);
      this.$refs[registerForm].validate(valid => {
        if (valid) {
          this.savloading = true;
          TaskAddOrUpdate(this.registerForm).then(res => {
            if (res.code == 0) {
              this.$message({
                type: 'success',
                message: '提交成功'
              });
              this.$emit('addsubmit');
            } else {
              this.$message({
                type: 'warning',
                message: '提交失败'
              });
            }
            this.savloading = false;
          });
        }
      });
    }
  },
  watch: {}
};
</script>
 
<style lang="scss" scoped>
.maintaskEdit {
  width: 98%;
  padding: 1%;
  .show-pwd {
    position: absolute;
    right: 10px;
    top: 3px;
    font-size: 16px;
    color: #889aa4;
    cursor: pointer;
    user-select: none;
  }
  .centent-form {
    height: 92%;
    width: 100%;
    margin: auto;
  }
  .maintaskEdit-button {
  }
  ::v-deep .el-form-item__content {
    width: 60%;
  }
  ::v-deep .el-select {
    width: 100%;
  }
}
</style>