gaoluyang
2026-06-16 e65bfa1d46d255f307eaa057665f01c8bde0e122
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
<template>
  <FormDialog
    v-model="isShow"
    title="编辑工序"
    width="800px"
    @confirm="handleSubmit"
    @cancel="closeModal"
  >
    <el-form label-width="180px" :model="formState" label-position="top" ref="formRef">
      <el-form-item
          label="部件:"
          prop="name"
          :rules="[
              {
              required: true,
              message: '请输入部件',
            },
            {
              max: 100,
              message: '最多100个字符',
            }
          ]">
        <el-input v-model="formState.name" />
      </el-form-item>
      <el-form-item label="工序编号" prop="no">
        <el-input v-model="formState.no"  />
      </el-form-item>
      <el-form-item
          label="工序类型"
          prop="processType"
          :rules="[
              {
              required: true,
              message: '请选择工序类型',
            }
          ]"
      >
        <el-select v-model="formState.processType" placeholder="请选择工序类型" style="width: 100%">
          <el-option v-for="item in processTypeOptions"
                     :key="item"
                     :label="item"
                     :value="item" />
        </el-select>
      </el-form-item>
      <el-form-item label="计划工时(小时)" prop="salaryQuota">
        <el-input v-model="formState.salaryQuota" type="number" :step="0.5" />
      </el-form-item>
      <el-form-item label="计划人员" prop="planPerson">
        <el-select v-model="formState.planPerson"
                   placeholder="请选择计划人员"
                   clearable
                   filterable
                   style="width: 100%">
          <el-option v-for="item in employeeOptions"
                     :key="item.id"
                     :label="item.staffName"
                     :value="item.id" />
        </el-select>
      </el-form-item>
      <el-form-item label="计划执行人员" prop="executor">
        <el-select v-model="formState.executor"
                   placeholder="请选择计划执行人员"
                   clearable
                   filterable
                   style="width: 100%">
          <el-option v-for="item in employeeOptions"
                     :key="item.id"
                     :label="item.staffName"
                     :value="item.id" />
        </el-select>
      </el-form-item>
      <el-form-item label="是否质检" prop="isQuality">
        <el-switch v-model="formState.isQuality" :active-value="true" inactive-value="false"/>
      </el-form-item>
      <el-form-item label="是否入库" prop="inbound">
        <el-switch v-model="formState.inbound" :active-value="true" inactive-value="false"/>
      </el-form-item>
      <el-form-item label="是否报工" prop="reportWork">
        <el-switch v-model="formState.reportWork" :active-value="true" inactive-value="false"/>
      </el-form-item>
      <el-form-item label="备注" prop="remark">
        <el-input v-model="formState.remark" type="textarea" />
      </el-form-item>
    </el-form>
  </FormDialog>
</template>
 
<script setup>
import { ref, computed, getCurrentInstance, watch, onMounted } from "vue";
import { update } from "@/api/productionManagement/productionProcess.js";
import { staffOnJobListPage } from "@/api/personnelManagement/staffOnJob.js";
import FormDialog from "@/components/Dialog/FormDialog.vue";
 
const props = defineProps({
  visible: {
    type: Boolean,
    required: true,
  },
 
  record: {
    type: Object,
    required: true,
  }
});
 
const emit = defineEmits(['update:visible', 'completed']);
 
const processTypeOptions = [
  "机加工",
  "刮板冷芯制作",
  "管路组对",
  "罐体连接及调试",
  "测试打压",
  "其他",
];
 
const employeeOptions = ref([]);
 
const formState = ref({
  id: props.record.id,
  name: props.record.name,
  no: props.record.no,
  processType: props.record.processType || '',
  remark: props.record.remark,
  salaryQuota: props.record.salaryQuota,
  planPerson: props.record.planPerson || null,
  executor: props.record.executor || null,
  isQuality: props.record.isQuality,
  inbound: props.record.inbound,
  reportWork: props.record.reportWork,
});
 
const isShow = computed({
  get() {
    return props.visible;
  },
  set(val) {
    emit('update:visible', val);
  },
});
 
watch(() => props.record, (newRecord) => {
  if (newRecord && isShow.value) {
    formState.value = {
      id: newRecord.id,
      name: newRecord.name || '',
      no: newRecord.no || '',
      processType: newRecord.processType || '',
      remark: newRecord.remark || '',
      salaryQuota: newRecord.salaryQuota || '',
      planPerson: newRecord.planPerson || null,
      executor: newRecord.executor || null,
      isQuality: props.record.isQuality,
      inbound: newRecord.inbound,
      reportWork: newRecord.reportWork,
    };
  }
}, { immediate: true, deep: true });
 
watch(() => props.visible, (visible) => {
  if (visible && props.record) {
    formState.value = {
      id: props.record.id,
      name: props.record.name || '',
      no: props.record.no || '',
      processType: props.record.processType || '',
      remark: props.record.remark || '',
      salaryQuota: props.record.salaryQuota || '',
      planPerson: props.record.planPerson || null,
      executor: props.record.executor || null,
      isQuality: props.record.isQuality,
      inbound: props.record.inbound,
      reportWork: props.record.reportWork,
    };
  }
});
 
let { proxy } = getCurrentInstance()
 
const closeModal = () => {
  isShow.value = false;
};
 
const handleSubmit = () => {
  proxy.$refs["formRef"].validate(valid => {
    if (valid) {
      update(formState.value).then(res => {
        isShow.value = false;
        emit('completed');
        proxy.$modal.msgSuccess("提交成功");
      })
    }
  })
};
 
const loadEmployees = async () => {
  try {
    const res = await staffOnJobListPage({ current: -1, size: -1, staffState: 1 });
    employeeOptions.value = res.data?.records || [];
  } catch (error) {
    console.error("加载员工列表失败", error);
  }
};
 
onMounted(() => {
  loadEmployees();
});
 
defineExpose({
  closeModal,
  handleSubmit,
  isShow,
});
</script>