zhaowei
8 天以前 008245cbe95c63a80f9a255378a5ffbe25d15085
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
<template>
  <a-modal :visible="visible" :title="title" @cancel="$emit('handleCloseModal')" @ok="handleSubmit">
    <a-form-model ref="form" :model="model" :rules="validatorRules" :labelCol="labelCol" :wrapperCol="wrapperCol">
      <a-row>
        <a-col :span="24">
          <a-form-model-item label="车间" prop="productionId">
            <a-tree-select v-model="model.productionId" :treeData="workshopTreeData" placeholder="请选择车间"
                           :treeDefaultExpandedKeys="treeDefaultExpandedKeys"/>
          </a-form-model-item>
        </a-col>
        <a-col :span="24">
          <a-form-model-item label="问题内容" prop="content">
            <a-input v-model="model.content" placeholder="请输入内容"/>
          </a-form-model-item>
        </a-col>
      </a-row>
    </a-form-model>
  </a-modal>
</template>
 
<script>
  import { httpAction, getAction } from '@/api/manage'
 
  export default {
    name: 'ProblemFeedbackModal',
    components: {},
    props: {
      visible: {
        type: Boolean,
        default: false
      },
      title: {
        type: String
      },
      workshopTreeData: {
        type: Array
      },
      treeDefaultExpandedKeys: {
        type: Array
      }
    },
    data() {
      return {
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 }
        },
        validatorRules: {
          productionId: [
            { required: true, message: '请选择车间名称!' }
          ]
        },
        url: {
          add: '/mdc/mdcFeedback/add',
          edit: '/mdc/mdcFeedback/edit'
        }
      }
    },
    methods: {
      handleSubmit() {
        const that = this
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            let apiUrl = ''
            let method = ''
            if (!this.model.id) {
              apiUrl += this.url.add
              method = 'post'
            } else {
              apiUrl += this.url.edit
              method = 'put'
            }
            httpAction(apiUrl, this.model, method).then((res) => {
              if (res.success) {
                that.$notification.success({
                  message: '消息',
                  description: res.message
                })
                that.$emit('modalFormOk')
              } else {
                that.$notification.warning({
                  message: '消息',
                  description: res.message
                })
              }
            })
          }
        })
      }
    }
  }
</script>