hejianhao
2025-04-16 dab2d210ca06c1faa514c6388fbd5de1ab355360
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
<template>
  <div class="box-a">
    <v-header title="新增/编辑社单位"></v-header>
    <div style="max-width: 800px">
      <el-form
        ref="form"
        label-width="140px"
      >
        <el-form-item
          required
          label="单位名称:"
        >
          <el-input
            :maxlength="35"
            v-model="os.comName"
            @input="toGanDiaoFuhao(os.comName,'comName')"
          ></el-input>
        </el-form-item>
        <el-form-item
          required
          label="详细地址:"
        >
          <el-input
            @blur="address"
            :maxlength="35"
            v-model="os.address"
            placeholder="请按照格式:必须以 xx社区开头"
            @input="toGanDiaoFuhao(os.address,'address')"
          ></el-input>
        </el-form-item>
        <el-form-item
          required
          label="所属地:"
        >
          <el-input
            readonly
            :value="Territory.text"
          ></el-input>
        </el-form-item>
        <el-form-item
          required
          label="公司法人:"
        >
          <el-input
            :maxlength="15"
            v-model="os.legalPerson"
            @input="toGanDiaoFuhao(os.legalPerson,'legalPerson')"
          ></el-input>
        </el-form-item>
        <el-form-item
          required
          label="负责人:"
        >
          <el-input
            v-model="os.leader"
            :maxlength="15"
            @input="toGanDiaoFuhao(os.leader,'leader')"
          ></el-input>
        </el-form-item>
        <el-form-item
          required
          label="联系方式:"
        >
          <el-input
            v-model="os.contactsPhone"
            :maxlength="11"
            @input="toGanDiaoFeiNum(os.contactsPhone,'contactsPhone')"
          ></el-input>
        </el-form-item>
        <el-form-item
          required
          label="人员规模:"
        >
          <el-input
            :maxlength="4"
            v-model="os.scope"
            @input="toGanDiaoFeiNum(os.scope,'scope')"
          ></el-input>
        </el-form-item>
        <el-form-item
          required
          label="统一社会信用码:"
        >
          <el-input
            :maxlength="18"
            v-model="os.creditCode"
            @input="toGanDiaoFeiNum(os.creditCode,'creditCode')"
          ></el-input>
        </el-form-item>
      </el-form>
      <div>
        <el-button
          @click="sub()"
          size="medium"
          type="primary"
        >确认</el-button>
        <el-button
          @click="back"
          size="medium"
        >取消</el-button>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: [],
  components: {},
  data() {
    return {
      os: {
        comName: "",
        provinceAdcode: "",
        cityAdcode: "",
        districtAdcode: "",
        address: "",
        legalPerson: "",
        leader: "",
        contactsPhone: "",
        scope: "",
        creditCode: "",
      },
      Territory: {},
      options: [],
      options1: [],
      options2: [],
    };
  },
  created() {
    if (this.$route.query.id) {
      this.os.id = this.$route.query.id;
      this.detail(this.os.id);
    }
    this.province();
    this.belongs();
  },
  methods: {
    toGanDiaoFuhao(str, name) {
      this.os[name] = (str + "").replace(
        /[\ |\~|\`|\!|\@|\#|\$|\%|\^|\&|\*|\(|\)|\-|\_|\+|\=|\||\\|\[|\]|\{|\}|\;|\:|\"|\'|\,|\<|\.|\>|\/|\?/\,/\。/\;/\:/\“/\”/\》/\《/\|/\{/\}/\、/\!/\~/\`]/g,
        ""
      );
    },
    toGanDiaoFeiNum(n, name) {
      n += "";
      this.os[name] = isNaN(n) ? n.substring(0, n.length - 1) : n;
    },
    province() {
      //省
      this.$api.get(
        "common/data/province",
        "",
        (e) => {
          this.options = e;
        },
        (err) => {
          console.log(err);
        }
      );
    },
    city1() {
      //市
      this.os.cityAdcode = "";
      this.os.districtAdcode = "";
      this.city();
    },
    city() {
      //市
      this.$api.get(
        "common/data/city?provinceAdcode=" + this.os.provinceAdcode,
        "",
        (e) => {
          this.options1 = e;
        },
        (err) => {
          console.log(err);
        }
      );
    },
    district1() {
      //区县
      this.os.districtAdcode = "";
      this.district();
    },
    district() {
      //区县
      this.$api.get(
        "common/data/district?cityAdcode=" + this.os.cityAdcode,
        "",
        (e) => {
          this.options2 = e;
        }
      );
    },
    back() {
      this.$router.back();
    },
    sub() {
      if (this.os.comName === "") {
        return demo.toast("请输入单位名称");
      }
      if (this.os.address === "") {
        return demo.toast("请输入详细地址");
      }
      if (!this.Territory.text) {
        return demo.toast("请输入正确格式的详细地址以进行匹配");
      }
      if (this.os.legalPerson === "") {
        return demo.toast("请输入公司法人");
      }
      if (this.os.leader === "") {
        return demo.toast("请输入负责人");
      }
      if (this.os.contactsPhone === "") {
        return demo.toast("请输入联系方式");
      }
      if (this.os.scope === "") {
        return demo.toast("请输入人员规模");
      }
      if (this.os.creditCode === "") {
        return demo.toast("请输入统一社会信用码");
      }
      if (isNaN(this.os.scope)) {
        return demo.toast("请正确输入人员规模");
      }
      this.$api.post("common/data/company/save", this.os, (e) => {
        this.back();
        // console.log(e);
      });
    },
    address() {
      //
      // this.os.address
      let index = this.os.address.indexOf("社区");
      if (index != -1) {
        let str = this.os.address.slice(0, index + 2);
        this.belongs(str);
      }
    },
    belongs(str) {
      let data = {
        actName: str,
        // actName:'东郊记忆1号'
      };
      this.$api.post("common/data/company/belongs", data, (e) => {
        if (e === null) {
          for (let i in this.Territory) {
            this.Territory[i] = "";
          }
          return demo.toast("请输入正确格式的详细地址以进行匹配");
        }
        this.os.provinceAdcode = e.provinceAdcode;
        this.os.cityAdcode = e.cityAdcode;
        this.os.districtAdcode = e.districtAdcode;
        this.Territory = e;
        this.$set(
          this.Territory,
          "text",
          `${e.provinceName}${e.cityName}${e.districtName}${e.communityName}${e.streetName}`
        );
        // this.Territory.text = `${e.provinceName}${e.cityName}${e.districtName}${e.communityName}${e.streetName}`
      });
    },
    detail(id) {
      //查询详情
      this.$api.get("common/data/company/detail?id=" + id, "", (e) => {
        this.os = e;
        this.address();
        // this.city()
        // this.district()
      });
    },
  },
  computed: {},
};
</script>
<style scoped>
.box-a {
  overflow: scroll;
}
</style>