Blame view

ant-design-vue-jeecg/src/views/system/receipt/modules/QualityHeaderForm.vue 7.66 KB
肖超群 authored
1
2
3
4
5
6
<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <!-- 主表单区域 -->
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
pengyongcheng authored
7
          <a-col :span="24">
肖超群 authored
8
            <a-form-model-item label="编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="code">
pengyongcheng authored
9
              <a-input v-model="model.code" placeholder="请输入编码"></a-input>
肖超群 authored
10
11
            </a-form-model-item>
          </a-col>
pengyongcheng authored
12
          <a-col :span="24">
肖超群 authored
13
            <a-form-model-item label="类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="type">
pengyongcheng authored
14
              <a-input v-model="model.type" placeholder="请输入类型"></a-input>
肖超群 authored
15
16
            </a-form-model-item>
          </a-col>
pengyongcheng authored
17
          <a-col :span="24">
肖超群 authored
18
            <a-form-model-item label="货主编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="companyCode">
pengyongcheng authored
19
              <a-input v-model="model.companyCode" placeholder="请输入货主编码"></a-input>
肖超群 authored
20
21
            </a-form-model-item>
          </a-col>
pengyongcheng authored
22
          <a-col :span="24">
肖超群 authored
23
            <a-form-model-item label="上游单号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="referCode">
pengyongcheng authored
24
              <a-input v-model="model.referCode" placeholder="请输入上游单号"></a-input>
肖超群 authored
25
26
            </a-form-model-item>
          </a-col>
pengyongcheng authored
27
          <a-col :span="24">
肖超群 authored
28
            <a-form-model-item label="供应商编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="supplierCode">
pengyongcheng authored
29
              <a-input v-model="model.supplierCode" placeholder="请输入供应商编码"></a-input>
肖超群 authored
30
31
            </a-form-model-item>
          </a-col>
pengyongcheng authored
32
          <a-col :span="24">
肖超群 authored
33
            <a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
pengyongcheng authored
34
              <a-input v-model="model.remark" placeholder="请输入备注"></a-input>
肖超群 authored
35
36
37
38
39
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
pengyongcheng authored
40
    <!-- 子表单区域 -->
肖超群 authored
41
42
43
44
45
46
47
48
49
50
51
52
53
    <a-tabs v-model="activeKey" @change="handleChangeTabs">
      <a-tab-pane tab="质检单详情" :key="refKeys[0]" :forceRender="true">
        <j-vxe-table
          keep-source
          :ref="refKeys[0]"
          :loading="qualityDetailTable.loading"
          :columns="qualityDetailTable.columns"
          :dataSource="qualityDetailTable.dataSource"
          :maxHeight="300"
          :disabled="formDisabled"
          :rowNumber="true"
          :rowSelection="true"
          :toolbar="true"
pengyongcheng authored
54
        />
肖超群 authored
55
56
57
58
59
60
61
      </a-tab-pane>
    </a-tabs>
  </a-spin>
</template>

<script>
pengyongcheng authored
62
63
64
65
import {JVxeTableModelMixin} from '@/mixins/JVxeTableModelMixin.js'
import {JVXETypes} from '@/components/jeecg/JVxeTable'
import {getRefPromise, VALIDATE_FAILED} from '@/components/jeecg/JVxeTable/utils/vxeUtils.js'
import JFormContainer from '@/components/jeecg/JFormContainer'
肖超群 authored
66
pengyongcheng authored
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
export default {
  name: 'QualityHeaderForm',
  mixins: [JVxeTableModelMixin],
  components: {
    JFormContainer,
  },
  data() {
    return {
      labelCol: {
        xs: {span: 24},
        sm: {span: 5},
      },
      wrapperCol: {
        xs: {span: 24},
        sm: {span: 16},
      },
      model: {},
      // 新增时子表默认添加几行空数据
      addDefaultRowNum: 1,
      validatorRules: {
肖超群 authored
87
        code: [
pengyongcheng authored
88
          {required: true, message: this.$t('system.inputCode')},
肖超群 authored
89
        ],
pengyongcheng authored
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
      },
      refKeys: ['qualityDetail',],
      tableKeys: ['qualityDetail',],
      activeKey: 'qualityDetail',
      // 质检单详情
      qualityDetailTable: {
        loading: false,
        dataSource: [],
        columns: [
          {
            title: '物料编码',
            key: 'materialCode',
            type: JVXETypes.input,
            width: "200px",
            placeholder: '请输入${title}',
            defaultValue: '',
          },
          {
            title: '物料名称',
            key: 'materialName',
            type: JVXETypes.input,
            width: "200px",
            placeholder: '请输入${title}',
            defaultValue: '',
肖超群 authored
114
          },
pengyongcheng authored
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
          {
            title: '物料规格',
            key: 'materialSpec',
            type: JVXETypes.input,
            width: "200px",
            placeholder: '请输入${title}',
            defaultValue: '',
          },
          {
            title: '物料单位',
            key: 'materialUnit',
            type: JVXETypes.input,
            width: "200px",
            placeholder: '请输入${title}',
            defaultValue: '',
          },
          {
            title: '单据数量',
            key: 'qty',
            type: JVXETypes.input,
            width: "200px",
            placeholder: '请输入${title}',
            defaultValue: '',
          },
          {
            title: '库存状态',
            key: 'inventoryStatus',
            type: JVXETypes.input,
            width: "200px",
            placeholder: '请输入${title}',
            defaultValue: '',
          },
          {
            title: '批次',
            key: 'batch',
            type: JVXETypes.input,
            width: "200px",
            placeholder: '请输入${title}',
            defaultValue: '',
          },
          {
            title: '批号',
            key: 'lot',
            type: JVXETypes.input,
            width: "200px",
            placeholder: '请输入${title}',
            defaultValue: '',
          },
          {
            title: '项目号',
            key: 'project',
            type: JVXETypes.input,
            width: "200px",
            placeholder: '请输入${title}',
            defaultValue: '',
          },
          {
            title: '单据状态',
            key: 'status',
            type: JVXETypes.input,
            width: "200px",
            placeholder: '请输入${title}',
            defaultValue: '',
          },
        ]
      },
      url: {
        add: "/receipt/qualityHeader/add",
        edit: "/receipt/qualityHeader/edit",
        queryById: "/receipt/qualityHeader/queryById",
        qualityDetail: {
          list: '/receipt/qualityHeader/queryQualityDetailByMainId'
        },
肖超群 authored
188
      }
pengyongcheng authored
189
190
191
192
193
194
195
196
197
198
199
200
201
    }
  },
  props: {
    //表单禁用
    disabled: {
      type: Boolean,
      default: false,
      required: false
    }
  },
  computed: {
    formDisabled() {
      return this.disabled
肖超群 authored
202
    },
pengyongcheng authored
203
204
205
206
207
208
  },
  created() {
  },
  methods: {
    addBefore() {
      this.qualityDetailTable.dataSource = []
肖超群 authored
209
    },
pengyongcheng authored
210
211
212
    getAllTable() {
      let values = this.tableKeys.map(key => getRefPromise(this, key))
      return Promise.all(values)
肖超群 authored
213
    },
pengyongcheng authored
214
215
216
217
218
219
220
221
222
    /** 调用完edit()方法之后会自动调用此方法 */
    editAfter() {
      this.$nextTick(() => {
      })
      // 加载子表数据
      if (this.model.id) {
        let params = {id: this.model.id}
        this.requestSubTableData(this.url.qualityDetail.list, params, this.qualityDetailTable)
      }
肖超群 authored
223
    },
pengyongcheng authored
224
225
226
227
228
229
230
231
232
233
234
235
    //校验所有一对一子表表单
    validateSubForm(allValues) {
      return new Promise((resolve, reject) => {
        Promise.all([]).then(() => {
          resolve(allValues)
        }).catch(e => {
          if (e.error === VALIDATE_FAILED) {
            // 如果有未通过表单验证的子表,就自动跳转到它所在的tab
            this.activeKey = e.index == null ? this.activeKey : this.refKeys[e.index]
          } else {
            console.error(e)
          }
肖超群 authored
236
        })
pengyongcheng authored
237
238
239
240
241
242
243
244
245
246
247
248
249
      })
    },
    /** 整理成formData */
    classifyIntoFormData(allValues) {
      let main = Object.assign(this.model, allValues.formValue)
      return {
        ...main, // 展开
        qualityDetailList: allValues.tablesValue[0].tableData,
      }
    },
    validateError(msg) {
      this.$message.error(msg)
    },
肖超群 authored
250
251

  }
pengyongcheng authored
252
}
肖超群 authored
253
254
255
256
</script>

<style scoped>
</style>