|
@@ -0,0 +1,308 @@
|
|
|
+<template>
|
|
|
+ <div v-loading="loading">
|
|
|
+ <div class="form-box">
|
|
|
+ <el-form
|
|
|
+ label-position="top"
|
|
|
+ :model="form"
|
|
|
+ ref="form"
|
|
|
+ :rules="formRules"
|
|
|
+ label-width="100px"
|
|
|
+ >
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item
|
|
|
+ :label="$t('product_material.customer.customerCode')"
|
|
|
+ prop="code"
|
|
|
+ >
|
|
|
+ <el-input
|
|
|
+ v-model="form.code"
|
|
|
+ :placeholder="$t('pleaseInput')"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1"></el-col>
|
|
|
+ <el-col :span="15">
|
|
|
+ <el-form-item label=".">
|
|
|
+ <span>不输入则自动生成,自动编码规则示例:C00001</span>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <el-form-item
|
|
|
+ :label="$t('product_material.customer.customerName')"
|
|
|
+ prop="name"
|
|
|
+ >
|
|
|
+ <el-input
|
|
|
+ v-model="form.name"
|
|
|
+ :placeholder="$t('pleaseInput')"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item :label="$t('product_material.customer.address')" required>
|
|
|
+ <el-row :gutter="10">
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label-width="0" prop="countryId">
|
|
|
+ <el-select
|
|
|
+ v-model="form.countryId"
|
|
|
+ :placeholder="$t('product_material.customer.country')"
|
|
|
+ style="width: 100%"
|
|
|
+ @change="countryChange"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in countryData"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.chineseName"
|
|
|
+ :value="item.id"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label-width="0" prop="provinceId">
|
|
|
+ <el-select
|
|
|
+ v-model="form.provinceId"
|
|
|
+ :placeholder="$t('product_material.customer.province')"
|
|
|
+ style="width: 100%"
|
|
|
+ @change="provinceChange"
|
|
|
+ :disabled="!provinceData.length > 0"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in provinceData"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.id"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label-width="0" prop="cityId">
|
|
|
+ <el-select
|
|
|
+ v-model="form.cityId"
|
|
|
+ :placeholder="$t('product_material.customer.city')"
|
|
|
+ style="width: 100%"
|
|
|
+ :disabled="!provinceData.length > 0 && !cityData.length > 0"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in cityData"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.id"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="" prop="detailedAddress">
|
|
|
+ <el-input
|
|
|
+ v-model="form.detailedAddress"
|
|
|
+ :placeholder="$t('pleaseInput')"
|
|
|
+ type="textarea"
|
|
|
+ rows="4"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item
|
|
|
+ :label="$t('product_material.customer.contactInfo')"
|
|
|
+ required
|
|
|
+ >
|
|
|
+ <el-row :gutter="10">
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label-width="0" prop="contacts">
|
|
|
+ <el-input
|
|
|
+ v-model="form.contacts"
|
|
|
+ :placeholder="$t('pleaseInput')"
|
|
|
+ >
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="16">
|
|
|
+ <el-form-item label-width="0" prop="phone">
|
|
|
+ <el-input v-model="form.phone" :placeholder="$t('pleaseInput')">
|
|
|
+ <template>
|
|
|
+ <div slot="prepend">+ 86</div>
|
|
|
+ </template>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item :label="$t('product_material.customer.enclosure')">
|
|
|
+ <el-upload
|
|
|
+ class="upload-demo"
|
|
|
+ action="/api/service-file/uploadFile"
|
|
|
+ :headers="uploadHeader"
|
|
|
+ :on-preview="handlePreview"
|
|
|
+ :on-remove="handleRemove"
|
|
|
+ :on-success="handleSuccess"
|
|
|
+ multiple
|
|
|
+ :file-list="fileList"
|
|
|
+ >
|
|
|
+ <el-button size="small" type="primary">点击上传</el-button>
|
|
|
+ </el-upload>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="备注" prop="remark">
|
|
|
+ <el-input
|
|
|
+ v-model="form.remark"
|
|
|
+ :placeholder="$t('pleaseInput')"
|
|
|
+ type="textarea"
|
|
|
+ rows="4"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ <div style="text-align: center; margin-top: 15px">
|
|
|
+ <el-button size="small" @click="handleCancel"
|
|
|
+ >{{ $t("cancel") }}
|
|
|
+ </el-button>
|
|
|
+ <el-button type="primary" size="small" @click="handleSubmit">
|
|
|
+ {{ $t("submit") }}</el-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { getToken } from "@/util/auth";
|
|
|
+import { getRegionData } from "@/api/system/common.js";
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: "addCustomer",
|
|
|
+ components: {},
|
|
|
+ props: {
|
|
|
+ form: {
|
|
|
+ type: Object,
|
|
|
+ default: () => {},
|
|
|
+ },
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ uploadHeader: {
|
|
|
+ Authorization: "Basic c2FiZXI6c2FiZXJfc2VjcmV0",
|
|
|
+ "Blade-Auth": "bearer " + getToken(),
|
|
|
+ },
|
|
|
+ countryData: [],
|
|
|
+ provinceData: [],
|
|
|
+ cityData: [],
|
|
|
+ loading: false,
|
|
|
+ formRules: {
|
|
|
+ countryId: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message:
|
|
|
+ this.$t("pleaseSelect") +
|
|
|
+ this.$t("product_material.customer.country"),
|
|
|
+ trigger: "change",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ provinceId: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message:
|
|
|
+ this.$t("pleaseSelect") +
|
|
|
+ this.$t("product_material.customer.province"),
|
|
|
+ trigger: "change",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ cityId: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message:
|
|
|
+ this.$t("pleaseSelect") +
|
|
|
+ this.$t("product_material.customer.city"),
|
|
|
+ trigger: "change",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ type: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message:
|
|
|
+ this.$t("pleaseSelect") +
|
|
|
+ this.$t("product_material.customer.customerType"),
|
|
|
+ trigger: "change",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ name: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message:
|
|
|
+ this.$t("pleaseInput") +
|
|
|
+ this.$t("product_material.customer.customerName"),
|
|
|
+ trigger: "blur",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ contacts: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message:
|
|
|
+ this.$t("pleaseInput") +
|
|
|
+ this.$t("product_material.customer.contacts"),
|
|
|
+ trigger: "blur",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ phone: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message:
|
|
|
+ this.$t("pleaseInput") +
|
|
|
+ this.$t("product_material.customer.contactNumber"),
|
|
|
+ trigger: "blur",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ fileList: [],
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ getRegionData({ parentId: "", type: "1" }).then((res) => {
|
|
|
+ this.countryData = res.data.data;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ handleSubmit() {
|
|
|
+ this.$refs.form.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ this.loading = true;
|
|
|
+ this.$emit("submit");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleCancel() {
|
|
|
+ this.$emit("cancel");
|
|
|
+ },
|
|
|
+ countryChange(val) {
|
|
|
+ getRegionData({ parentId: val, type: "2" }).then((res) => {
|
|
|
+ this.provinceData = res.data.data;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ provinceChange(val) {
|
|
|
+ getRegionData({ parentId: val, type: "3" }).then((res) => {
|
|
|
+ this.cityData = res.data.data;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleSuccess(response, file, fileList) {
|
|
|
+ this.form.fileInfoList = fileList;
|
|
|
+ },
|
|
|
+ handleRemove(response, file, fileList) {
|
|
|
+ this.form.fileInfoList = fileList;
|
|
|
+ },
|
|
|
+ handlePreview() {},
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.form-box {
|
|
|
+ height: calc(100vh - 280px);
|
|
|
+ overflow: auto;
|
|
|
+ box-sizing: border-box;
|
|
|
+ padding: 10px;
|
|
|
+}
|
|
|
+</style>
|