Blame view

src/views/system/modules/newsOrderPart.vue 9.2 KB
陈翱 authored
1
2
3
4
5
6
7
8
9
10
11
12
<template>
  <a-modal
    :width="modalWidth"
    :style="modalStyle"
    :visible="visible"
    :confirmLoading="confirmLoading"
    :maskClosable="false"
    @cancel="handleCancel">
    <template slot="footer">
      <a-button @click="handleCancel">关闭</a-button>
    </template>
    <a-spin :spinning="confirmLoading">
13
      <a-form :form="form">
陈翱 authored
14
        <a-row>
15
          <a-col :span="24/3">
陈翱 authored
16
            <a-form-item label="工作令" :labelCol="labelCol" :wrapperCol="wrapperCol">
17
              <a-input v-decorator="['workNo']" disabled></a-input>
陈翱 authored
18
19
            </a-form-item>
          </a-col>
20
          <a-col :span="24/3">
陈翱 authored
21
            <a-form-item label="物料编码:" :labelCol="labelCol" :wrapperCol="wrapperCol">
22
              <a-input v-decorator="['cno']" placeholder="请输入物料编码" disabled></a-input>
陈翱 authored
23
24
            </a-form-item>
          </a-col>
25
        </a-row>
陈翱 authored
26
27
28
29
30
31
32
33
34
35
36
        <a-row>
          <a-col :span="24/3">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="采购"
              hasFeedback>
              <a-switch checkedChildren="订阅" unCheckedChildren="不订阅" @change="onChose" v-model="visibleCheck"/>
            </a-form-item>
          </a-col>
陈翱 authored
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
          <a-col :span="24/3">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="到货"
              hasFeedback>
              <a-switch checkedChildren="订阅" unCheckedChildren="不订阅" @change="onChose2" v-model="visibleCheck2"/>
            </a-form-item>
          </a-col>
          <a-col :span="24/3">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="入库"
              hasFeedback>
              <a-switch checkedChildren="订阅" unCheckedChildren="不订阅" @change="onChose3" v-model="visibleCheck3"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="24/3">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="领料"
              hasFeedback>
              <a-switch checkedChildren="订阅" unCheckedChildren="不订阅" @change="onChose4" v-model="visibleCheck4"/>
            </a-form-item>
          </a-col>
          <a-col :span="24/3">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="制作"
              hasFeedback>
              <a-switch checkedChildren="订阅" unCheckedChildren="不订阅" @change="onChose5" v-model="visibleCheck5"/>
            </a-form-item>
          </a-col>
          <a-col :span="24/3">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="工艺"
              hasFeedback>
              <a-switch checkedChildren="订阅" unCheckedChildren="不订阅" @change="onChose6" v-model="visibleCheck6"/>
            </a-form-item>
          </a-col>
        </a-row>
陈翱 authored
86
87
88
        <a-row>
          <a-col :span="24" style="text-align: center" class="table-page-search-submitButtons">
陈翱 authored
89
90
91
92
            <a-button type="primary" @click="submitForm" icon="check-circle">提 交</a-button>
          </a-col>
        </a-row>
93
      </a-form>
陈翱 authored
94
95
96
97
98
99
    </a-spin>
  </a-modal>
</template>

<script>
100
101
import {httpAction} from '@/api/manage'
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
陈翱 authored
102
import pick from 'lodash.pick'
103
陈翱 authored
104
105
export default {
  name: 'PbomTypeForm',
106
107
  mixins: [JeecgListMixin],
  components: {},
陈翱 authored
108
109
110
111
  props: {
    //流程表单data
    formData: {
      type: Object,
112
113
      default: () => {
      },
陈翱 authored
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
      required: false
    },
    //表单模式:true流程表单 false普通表单
    formBpm: {
      type: Boolean,
      default: false,
      required: false
    },
    //表单禁用
    disabled: {
      type: Boolean,
      default: false,
      required: false
    }
  },
129
  data() {
陈翱 authored
130
131
132
    return {
      visible: false,
      modalWidth: '50%',
133
      modalStyle: {'top': '20px'},
陈翱 authored
134
      form: this.$form.createForm(this),
135
      excludeFlag: "",
陈翱 authored
136
      visibleCheck: false,
137
      excludeFlag2: "",
陈翱 authored
138
      visibleCheck2: false,
139
      excludeFlag3: "",
陈翱 authored
140
      visibleCheck3: false,
141
      excludeFlag4: "",
陈翱 authored
142
      visibleCheck4: false,
143
      excludeFlag5: "",
陈翱 authored
144
      visibleCheck5: false,
145
      excludeFlag6: "",
陈翱 authored
146
147
      visibleCheck6: false,
      model: {},
148
149
150
      no: '',
      flag: false,
      flag2: false,
陈翱 authored
151
      labelCol: {
152
153
        xs: {span: 24},
        sm: {span: 5},
陈翱 authored
154
155
      },
      wrapperCol: {
156
157
        xs: {span: 24},
        sm: {span: 16},
陈翱 authored
158
159
      },
      confirmLoading: false,
160
161
162
163
164
165
166
167
168
169
170
171
172
      validatorRules: {},
      searchOptions: [{
        text: "外协",
        value: "外协"
      }, {
        text: "自制",
        value: "自制"
      }, {
        text: "外购",
        value: "外购"
      }, {
        text: "工序外协",
        value: "工序外协"
陈翱 authored
173
174
      }],
      url: {
175
        list: "1",
陈翱 authored
176
177
178
179
180
181
182
        add: "/news/userNewsOrder/add",
        edit: "/pbom_type/pbomType/edit",
        queryById: "/pbom_type/pbomType/queryById"
      }
    }
  },
  computed: {
183
184
185
    formDisabled() {
      if (this.formBpm === true) {
        if (this.formData.disabled === false) {
陈翱 authored
186
187
188
189
190
191
          return false
        }
        return true
      }
      return this.disabled
    },
192
193
194
    showFlowSubmitButton() {
      if (this.formBpm === true) {
        if (this.formData.disabled === false) {
陈翱 authored
195
196
197
198
199
200
201
          return true
        }
      }
      return false
    },

  },
202
  created() {
陈翱 authored
203
204
205
206
    //如果是流程中表单,则需要加载流程表单data
    this.showFlowData();
  },
  methods: {
207
    add() {
陈翱 authored
208
209
      this.edit({});
    },
210
211
    edit(record, workNo) {
      this.visible = true;
陈翱 authored
212
      this.form.resetFields();
213
      this.no = record.cno;
陈翱 authored
214
215
216
      this.model = Object.assign({}, record);
      this.visible = true;
      this.$nextTick(() => {
217
        this.form.setFieldsValue(pick(this.model, 'cno', 'uuid', 'f04', 'code'))
陈翱 authored
218
        this.form.setFieldsValue({
219
          workNo: workNo
陈翱 authored
220
221
        })
      })
222
223
224
225
      if (record.purchase == '1') {
        this.visibleCheck = true
      } else {
        this.visibleCheck = false
陈翱 authored
226
      }
227
228
229
230
      if (record.arrival == '1') {
        this.visibleCheck2 = true
      } else {
        this.visibleCheck2 = false
陈翱 authored
231
      }
232
233
234
235
      if (record.warehousing == '1') {
        this.visibleCheck3 = true
      } else {
        this.visibleCheck3 = false
陈翱 authored
236
      }
237
238
239
240
      if (record.picking == '1') {
        this.visibleCheck4 = true
      } else {
        this.visibleCheck4 = false
陈翱 authored
241
      }
242
243
244
245
      if (record.make == '1') {
        this.visibleCheck5 = true
      } else {
        this.visibleCheck5 = false
陈翱 authored
246
      }
247
248
249
250
      if (record.craft == '1') {
        this.visibleCheck6 = true
      } else {
        this.visibleCheck6 = false
陈翱 authored
251
252
      }
    },
253
    handleCancel() {
陈翱 authored
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
      this.visible = false
    },

    onChose(checked) {
      if (checked) {
        this.excludeFlag = 1
        this.visibleCheck = true
      } else {
        this.excludeFlag = 0
        this.visibleCheck = false
      }
    },

    onChose2(checked) {
      if (checked) {
        this.excludeFlag2 = 1
        this.visibleCheck2 = true
      } else {
        this.excludeFlag2 = 0
        this.visibleCheck2 = false
      }
    },

    onChose3(checked) {
      if (checked) {
        this.excludeFlag3 = 1
        this.visibleCheck3 = true
      } else {
        this.excludeFlag3 = 0
        this.visibleCheck3 = false
      }
    },

    onChose4(checked) {
      if (checked) {
        this.excludeFlag4 = 1
        this.visibleCheck4 = true
      } else {
        this.excludeFlag4 = 0
        this.visibleCheck4 = false
      }
    },

    onChose5(checked) {
      if (checked) {
        this.excludeFlag5 = 1
        this.visibleCheck5 = true
      } else {
        this.excludeFlag5 = 0
        this.visibleCheck5 = false
      }
    },

    onChose6(checked) {
      if (checked) {
        this.excludeFlag6 = 1
        this.visibleCheck6 = true
      } else {
        this.excludeFlag6 = 0
        this.visibleCheck6 = false
      }
    },
317
    submitForm() {
陈翱 authored
318
319
320
321
322
323
324
      const that = this;
      // 触发表单验证
      this.form.validateFields((err, values) => {
        if (!err) {
          that.confirmLoading = true;
          let httpurl = '';
          let method = '';
325
          httpurl += this.url.add;
陈翱 authored
326
327
328
329
330
331
332
333
334
          method = 'post';
          let formData = Object.assign(this.model, values);
          formData.no = this.no
          formData.purchase = this.excludeFlag
          formData.arrival = this.excludeFlag2
          formData.warehousing = this.excludeFlag3
          formData.picking = this.excludeFlag4
          formData.make = this.excludeFlag5
          formData.craft = this.excludeFlag6
335
336
          httpAction(httpurl, formData, method).then((res) => {
            if (res.success) {
陈翱 authored
337
338
339
340
341
              that.$message.success(res.message);
              this.visible = false
              that.$emit('ok');
              that.$emit('fatherMethod', '');
342
            } else {
陈翱 authored
343
344
345
346
347
348
349
350
351
              that.$message.warning(res.message);
            }
          }).finally(() => {
            that.confirmLoading = false;
          })
        }

      })
    },
352
353
    popupCallback(row) {
      this.form.setFieldsValue(pick(row, 'cno', 'uuid', 'f04', 'code'))
陈翱 authored
354
355
356
357
    },
  }
}
</script>