cuilei
2 天以前 c69af876655527743762614dfdbb3af5e21f0fb8
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
<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    switchFullscreen
    @ok="handleOk"
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
    @cancel="handleCancel"
    cancelText="关闭">
 
    <a-spin :spinning="confirmLoading">
      <j-form-container :disabled="formDisabled">
        <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
          <a-row :gutter="24">
            <a-col :span="12">
              <a-form-model-item label="报工订单" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orderId">
                <a-select
                  v-model="model.orderId"
                  :options="workOrderOptions"
                  placeholder="请选择报工订单">
                </a-select>
              </a-form-model-item>
            </a-col>
            <a-col :span="12">
              <a-form-model-item label="报工工单" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="workOrderCode">
                <a-input
                  v-model="model.workOrderCode"
                  :disabled="true"
                  placeholder="请选择报工工单">
                </a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="12">
              <a-form-model-item label="产线" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="factoryId_dictText">
                <a-input
                  v-model="model.factoryId_dictText"
                  :disabled="true"
                  placeholder="请选择产线">
                </a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="12">
              <a-form-model-item label="报工数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="quantity">
                <a-input-number
                  v-model="model.quantity"
                  placeholder="请填写报工数量"
                  style="width: 100%"
                  :min="0">
                </a-input-number>
              </a-form-model-item>
            </a-col>
          </a-row>
        </a-form-model>
      </j-form-container>
    </a-spin>
  </j-modal>
</template>
 
<script>
import { postAction, getAction } from '@api/manage'
 
export default {
  name: 'MesProductionWorkOrderRepublishModal',
  data () {
    return {
      title: '报工',
      width: 800,
      visible: false,
      disableSubmit: false,
      confirmLoading: false,
      model: {},
      validatorRules: {
      },
      labelCol: {
        xs: { span: 24 },
        sm: { span: 6 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 18 },
      },
      url: {
        republish: '/mesproductionworkorder/mesProductionWorkOrder/republish',
        selectReportWorkOrderList: '/mes/productionOrder/selectReportWorkOrderList'
      },
      workOrderOptions: []
    }
  },
  computed: {
    formDisabled(){
      return this.disabled
    },
  },
  methods: {
    add (record) {
      // 重置表单
      this.$refs.form && this.$refs.form.resetFields()
      // 设置初始值
      this.model = Object.assign({}, record);
      getAction(this.url.selectReportWorkOrderList, {materialNumber: record.materialNumber}).then(res => {
        if (res.success) {
          this.workOrderOptions = res.result
        }
      })
      this.visible = true
    },
    close () {
      this.$emit('close');
      this.visible = false;
    },
    handleOk () {
      this.$refs.form.validate(valid => {
        if (valid) {
          this.confirmLoading = true
          let formData = {
            id: this.model.id,
            planQuantity: this.model.planQuantity,
            republishReason: this.model.republishReason
          }
          postAction(this.url.republish, formData).then(res => {
            if (res.success) {
              this.$message.success(res.message)
              this.submitCallback()
            } else {
              this.$message.warning(res.message)
            }
          }).finally(() => {
            this.confirmLoading = false
          })
        }
      })
    },
    submitCallback(){
      this.$emit('ok');
      this.visible = false;
    },
    handleCancel () {
      this.close()
    }
  }
}
</script>