YangYuGang
2025-03-11 7462fd192326d7cf3418b6185ca437b2667cbeab
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
<!--
 * @Description: file content
 * @Author: Ben Lin
 * @version: 
 * @Date: 2024-06-27 00:25:26
 * @LastEditors: Ben Lin
 * @LastEditTime: 2024-06-27 10:58:04
-->
<template>
  <div class="step1">
    <div class="w-120 m-auto">
      <BasicForm @register="register">
        <template #add="{ field }">
          <a-button
            v-if="field"
            class="mt-1 ml-1"
            size="small"
            @click="handleSelectItem"
            preIcon="search|svg"
          />
          <GeneralModal @register="registerItemAdd" @success="handleItemSuccess" />
        </template>
      </BasicForm>
      <Divider />
      <h3>说明</h3>
      <h4>选择客户</h4>
      <p> 选择该产品的客户,以便添加针对客户的工艺路线。 </p>
    </div>
  </div>
</template>
<script lang="ts" setup>
  import { BasicForm, useForm } from '@/components/Form';
  import { step1Schemas } from './data';
  import GeneralModal from '/@/views/components/GeneralModal.vue';
  import { Select, Input, Divider } from 'ant-design-vue';
  import { useModal } from '/@/components/Modal';
  import { useI18n } from '/@/hooks/web/useI18n';
 
  const emit = defineEmits(['next']);
  const { t } = useI18n();
  const [registerItemAdd, { openModal: openItemModal }] = useModal();
  const [register, { setFieldsValue, validate }] = useForm({
    labelWidth: 100,
    schemas: step1Schemas,
    actionColOptions: {
      span: 14,
    },
    showResetButton: false,
    submitButtonOptions: {
      text: '下一步',
    },
    submitFunc: customSubmitFunc,
  });
 
  async function customSubmitFunc() {
    try {
      const values = await validate();
      emit('next', values);
    } catch (error) {
      //
    }
  }
 
  /**
   * @description: 弹出选择框
   * @param {*} item
   * @return {*}
   */
  function handleSelectItem(item) {
    openItemModal(true, {
      title: '客户列表',
      schemas: [
        {
          field: 'CUST_CODE',
          component: 'Input',
          label: '客户编码',
          colProps: {
            span: 12,
          },
        },
      ],
      ItemColumns: [
        {
          title: t('客户编码'),
          dataIndex: 'CUST_CODE',
          resizable: true,
          sorter: true,
          width: 200,
        },
        {
          title: t('客户名称'),
          dataIndex: 'CUST_NAME_CN',
          resizable: true,
          sorter: true,
          width: 180,
        },
      ],
      tableName: 'BAS_CUSTOMER',
      rowKey: 'CUST_CODE',
      searchInfo: { TABLE_NAME: 'BAS_CUSTOMER' },
    });
  }
 
  /**
   * @description: 弹出选择框选择成功后事件
   * @param {*} d
   * @param {*} u
   * @return {*}
   */
  function handleItemSuccess(d, u) {
    setFieldsValue({
      CUST_CODE: d.values['val'],
      CUST_ID: d.values['id'],
    });
  }
</script>
<style lang="less" scoped>
  .step1 {
    &-form {
      width: 450px;
      margin: 0 auto;
    }
 
    h3 {
      margin: 0 0 12px;
      color: @text-color-base;
      font-size: 16px;
      line-height: 32px;
    }
 
    h4 {
      margin: 0 0 4px;
      color: @text-color-base;
      font-size: 14px;
      line-height: 22px;
    }
 
    p {
      color: @text-color-base;
    }
  }
 
  .pay-select {
    width: 20%;
  }
 
  .pay-input {
    width: 70%;
  }
</style>