xiangpei
2025-03-18 6c66123ec863c89a25b3e36e3e4059423beb0854
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
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
<template>
  <div class="basic-info">
    <el-form ref="demoFormRef" :disabled="disabled" :model="legalPersonForm" class="dialog_form">
      <el-row :gutter="20">
<!--        <el-col :span="6">-->
<!--          <el-form-item label="项目总投额" label-width="120px" prop="investmentType" style="width: 100%">-->
<!--            <el-input v-model="legalPersonForm.totalInvestment" class="item" clearable maxlength="255" style="width: 90%"-->
<!--                      placeholder="请输入"/>-->
<!--            <span class="money">万元</span>-->
<!--          </el-form-item>-->
<!--        </el-col>-->
        <el-col :span="12">
          <el-form-item label="项目单位" label-width="120px" prop="investmentType"
                        >
            <el-select
              v-model="legalPersonForm.projectUnit"
              filterable
              placeholder="请选择或输入"
              style="width: 100%;"
              @change="handleSelectChange"
              remote
              :remote-method="handleBlur"
            >
              <el-option
                v-for="item in options"
                :key="item.id"
                :label="item.projectUnit"
                :value="item.id"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
 
 
        <el-col :span="6">
          <el-form-item label="项目单位类型" label-width="120px" prop="projectType" style="width: 100%">
            <el-select
              v-model="legalPersonForm.projectUnitType"
              clearable
              placeholder="请选择"
              style="width: 100%"
            >
              <el-option v-for="item in dict.type.sys_unit_type" :key="item.value" :label="item.label"
                         :value="item.value"/>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="登记注册类型" label-width="120px" prop="projectType" style="width: 100%">
            <el-select
              v-model="legalPersonForm.registrationType"
              clearable
              placeholder="请选择"
              style="width: 100%"
            >
              <el-option v-for="item in dict.type.sys_registration_type" :key="item.value" :label="item.label"
                         :value="item.value"/>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="控股情况" label-width="120px" prop="projectType" style="width: 100%">
            <el-select
              v-model="legalPersonForm.holdingSituation"
              clearable
              placeholder="请选择"
              style="width: 100%"
            >
              <el-option v-for="item in dict.type.sys_holding_situation" :key="item.value" :label="item.label"
                         :value="item.value"/>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="证照类型" label-width="120px" prop="projectstatus" style="width: 100%">
            <el-select
              v-model="legalPersonForm.certificateType"
              clearable
              placeholder="请选择"
              style="width: 100%"
            >
              <el-option v-for="item in dict.type.sys_license_type" :key="item.value" :label="item.label"
                         :value="item.value"/>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="证件号码" label-width="120px" prop="investmentType" style="width: 100%">
            <el-input v-model.trim="legalPersonForm.certificateNumber" class="item" clearable maxlength="255"
                      placeholder="请输入"/>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="注册地址" label-width="120px" prop="investmentType" style="width: 100%">
            <el-input v-model.trim="legalPersonForm.registeredAddress" class="item" clearable maxlength="255"
                      placeholder="请输入"/>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="注册资金" label-width="120px" prop="projectType" style="width: 100%">
            <el-input v-model.trim="legalPersonForm.registeredCapital" class="item" clearable maxlength="255"
                      placeholder="请输入"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="法人代表" label-width="120px" prop="investmentType" style="width: 100%">
            <el-input v-model.trim="legalPersonForm.legalRepresentative" class="item" clearable maxlength="255"
                      placeholder="请输入"/>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="固定电话" label-width="120px" prop="investmentType" style="width: 100%">
            <el-input v-model.trim="legalPersonForm.fixedPhone" class="item" clearable maxlength="255"
                      placeholder="请输入"/>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="法人身份证号" label-width="120px" prop="projectType" style="width: 100%">
            <el-input v-model.trim="legalPersonForm.legalPersonIdcard" class="item" clearable maxlength="255"
                      placeholder="请输入"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="项目联系人" label-width="120px" prop="investmentType" style="width: 100%">
            <el-input v-model.trim="legalPersonForm.projectContactPerson" class="item" clearable maxlength="255"
                      placeholder="请输入"/>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="移动电话" label-width="120px" prop="investmentType" style="width: 100%">
            <el-input v-model.trim="legalPersonForm.phone" class="item" clearable maxlength="255" placeholder="请输入"/>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="联系人身份证号" label-width="120px" prop="projectType" style="width: 100%">
            <el-input v-model.trim="legalPersonForm.contactIdcard" class="item" clearable maxlength="255"
                      placeholder="请输入"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="微信号" label-width="120px" prop="investmentType" style="width: 100%">
            <el-input v-model.trim="legalPersonForm.wechat" class="item" clearable maxlength="255" placeholder="请输入"/>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="联系人通讯地址" label-width="120px" prop="investmentType" style="width: 100%">
            <el-input v-model.trim="legalPersonForm.contactAddress" class="item" clearable maxlength="255"
                      placeholder="请输入"/>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="邮政编码" label-width="120px" prop="projectType" style="width: 100%">
            <el-input v-model.trim="legalPersonForm.postCode" class="item" clearable maxlength="255" placeholder="请输入"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="电子邮箱" label-width="120px" prop="investmentType" style="width: 100%">
            <el-input v-model="legalPersonForm.email" class="item" clearable maxlength="255" placeholder="请输入"/>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>
 
<script>
 
import Cookies from "js-cookie";
import {
  addProjectUnitRegistrationInfo,
  editProjectUnitRegistrationInfo,
  getProjectUnitRegistrationInfoById,
  getUnitRegistrationInfoByName
} from "@/api/projectEngineering/projectUnitRegistrationInfo";
 
export default {
  dicts: ['sys_unit_type', 'sys_registration_type', 'sys_holding_situation', 'sys_license_type'],
  name: 'LegalPersonForm',
  props: {
    disabled: {
      type: Boolean,
      default: false,
      required: true
    },
  },
  data() {
    return {
      //项目单位选择框
      selectProjectUnit:'',
      projectForm: {},
      //单位法人信息
      options:[],
      legalPersonForm: {
        // id: '',
        // totalInvestment: '',
        projectUnit: '',
        // projectUnitType: '',
        // registrationType: '',
        // holdingSituation: '',
        // certificateType: '',
        // certificateNumber: '',
        // registeredAddress: '',
        // registeredCapital: '',
        // projectId: '',
        // legalRepresentative: '',
        // fixedPhone: '',
        // legalPersonIdcard: '',
        // projectContactPerson: '',
        // phone: '',
        // contactIdcard: '',
        // wechat: '',
        // contactAddress: '',
        // postCode: '',
        // email: ''
      },
    }
  },
  mounted() {
    const legalPersonForm = localStorage.getItem("legalPersonForm");
    const projectForm = localStorage.getItem("projectForm");
 
    const parsedLegalPersonForm = legalPersonForm ? JSON.parse(legalPersonForm) : null;
    const parsedProjectForm = projectForm ? JSON.parse(projectForm) : null;
    if (parsedLegalPersonForm) {
      this.legalPersonForm = parsedLegalPersonForm
    }
    if (parsedProjectForm) {
      this.projectForm = parsedProjectForm
    }
    // 如果路由存在id且没有缓存,视为编辑或查看,调用api
    if (this.$route.query.projectId && !parsedLegalPersonForm) {
      this.getProjectUnitRegistrationInfo();
    }
 
    this.legalPersonForm.projectId = this.projectForm.id;
 
  },
  beforeDestroy() {
    if(Object.keys(this.legalPersonForm).length !==0)  localStorage.setItem("legalPersonForm", JSON.stringify(this.legalPersonForm));
  },
  methods: {
 
    handleSelectChange(row) {
      if (this.options !== null) {
        this.options.forEach(item => {
          if (item.id === row) {
            this.legalPersonForm = item;
            this.legalPersonForm.id = null;
          }
        })
      }
 
    },
    //项目单位输入时触发
    handleBlur(query){
 
      this.legalPersonForm.projectUnit = query;
      if (this.legalPersonForm.projectUnit !== null && this.legalPersonForm.projectUnit !== '' && this.legalPersonForm.projectUnit !== undefined){
        getUnitRegistrationInfoByName(this.legalPersonForm).then(res =>{
          this.options = res.data;
        })
      }
    },
    getProjectUnitRegistrationInfo() {
      getProjectUnitRegistrationInfoById(this.$route.query.projectId).then(res => {
        this.legalPersonForm = res.data;
      });
    },
    submit() {
      if (!this.projectForm.id) {
        this.$message.error("请先保存投资管理基本信息")
      } else {
        this.legalPersonForm.projectId = this.projectForm.id;
        if (this.legalPersonForm.id) {
          editProjectUnitRegistrationInfo(this.legalPersonForm).then(response => {
            this.$modal.msgSuccess("修改成功");
            //跳转到下个组件
            this.$emit('toNext', 4);
          });
        } else {
          addProjectUnitRegistrationInfo(this.legalPersonForm).then(response => {
            this.$modal.msgSuccess("新增成功");
            this.legalPersonForm.id = response.data
            //跳转到下个组件
            this.$emit('toNext', 4);
          });
        }
      }
    },
  },
  watch: {
    'legalPersonForm.projectUnit':{
      deep:true,
      handler(newVal) {
        if (newVal === null || newVal === ''){
          this.options = null;
        }
      }
    },
    legalPersonForm: {
      deep: true,
      handler(newVal) {
        this.$emit('legalPersonForm', newVal)
      }
    },
 
 
 
  }
}
</script>
 
<style lang="scss" scoped>
.item {
  width: 100%;
}
 
.input-row {
  display: flex;
  width: 100%;
 
  .input-item {
    width: 100%;
  }
}
.money {
  font-size: 12px;
  margin-left: 2px;
  color: #909399;
}
.map-btn {
  width: 32px;
  height: 32px;
  background: #c6d6ff;
  border: 1px solid #3369ff;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
 
  img {
    width: 20px;
  }
}
</style>