123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368 |
- <style scoped>
- .user-panel {
- margin: 10px auto;
- }
- </style>
- <template>
- <el-dialog
- :visible.sync="showDialog"
- :title="title"
- :modal-append-to-body="false"
- style="text-align: left"
- @close="closeDialog"
- :close-on-click-modal="false"
- width="900px"
- >
- <div class="user-panel" v-loading="loading">
- <el-form
- ref="form"
- :model="formModel"
- :rules="ruleValidate"
- :label-width="'100px'"
- >
- <el-row>
- <el-col :span="12">
- <el-form-item label="企业名称" prop="companyName">
- <el-input
- v-model="formModel.companyName"
- placeholder="请输入企业名称"
- style="width: 300px"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="社会信用代码" prop="creditCode">
- <el-input
- v-model="formModel.creditCode"
- placeholder="请输入社会信用代码"
- style="width: 300px"
- ></el-input>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="12">
- <el-form-item label="所在地区" prop="region">
- <el-select
- v-model="formModel.region"
- filterable
- placeholder="请选择"
- style="width: 200px"
- >
- <el-option
- v-for="region in regionResult"
- :key="region.value"
- :label="region.name"
- :value="region.value"
- ></el-option>
- </el-select> </el-form-item
- ></el-col>
- <el-col :span="12">
- <el-form-item label="企业类型" prop="type">
- <el-select
- v-model="formModel.type"
- filterable
- placeholder="请选择"
- style="width: 200px"
- >
- <el-option
- v-for="type in typeResult"
- :key="type.value"
- :label="type.name"
- :value="type.value"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="12">
- <el-form-item label="所属行业" prop="industry">
- <el-select
- v-model="formModel.industry"
- filterable
- placeholder="请选择"
- style="width: 200px"
- >
- <el-option
- v-for="industry in industryResult"
- :key="industry.value"
- :label="industry.name"
- :value="industry.value"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="企业规模" prop="scale">
- <el-select
- v-model="formModel.scale"
- filterable
- placeholder="请选择"
- style="width: 200px"
- >
- <el-option
- v-for="scale in scaleResult"
- :key="scale.value"
- :label="scale.name"
- :value="scale.value"
- ></el-option> </el-select></el-form-item
- ></el-col>
- </el-row>
- <el-row>
- <el-col :span="12">
- <el-form-item label="营业执照" prop="businessLicenseUrl">
- <el-upload
- class="avatar-uploader"
- name="photoFile"
- :action="uploadUrl"
- :show-file-list="false"
- :headers="headers"
- :data="uploadData"
- :on-success="handleAvatarSuccess"
- :before-upload="beforeAvatarUpload"
- accept="image/png,image/jpeg"
- >
- <img v-if="fileUrl" :src="fileUrl" class="avatar" />
- <i v-else class="el-icon-plus avatar-uploader-icon"></i>
- </el-upload>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="24">
- <el-form-item label="企业地址" prop="address">
- <el-input
- v-model="formModel.address"
- placeholder="请输入企业地址"
- style="width: 80%"
- ></el-input> </el-form-item
- ></el-col>
- </el-row>
- <el-row>
- <el-col :span="24">
- <el-form-item label="企业介绍" prop="companyIntroduction">
- <el-input
- v-model="formModel.companyIntroduction"
- placeholder="请输入企业介绍"
- style="width: 80%"
- ></el-input> </el-form-item
- ></el-col>
- </el-row>
- <el-row>
- <el-col :span="24">
- <el-form-item label="企业家介绍" prop="enterpriserIntroduction">
- <el-input
- v-model="formModel.enterpriserIntroduction"
- placeholder="请输入企业家介绍"
- style="width: 80%"
- ></el-input> </el-form-item
- ></el-col>
- </el-row>
- </el-form>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="closeDialog">取 消</el-button>
- <el-button type="primary" @click="handleSubmit" :loading="submitting"
- >确 定</el-button
- >
- </span>
- </el-dialog>
- </template>
- <script>
- import Constant from "@/constant";
- import companyInfoApi from "@/api/base/companyInfo";
- import dataDictionaryApi from "@/api/sys/dataDictionary";
- import { getToken } from "@/utils/auth"; // get token from cookie
- export default {
- props: ["businessKey", "title"],
- data() {
- return {
- formModel: {},
- ruleValidate: {
- companyName: [
- { required: true, message: "企业名称不能为空", trigger: "blur" },
- ],
- type: [
- {
- required: true,
- message: "企业类型不能为空",
- trigger: "blur",
- },
- ],
- scale: [
- {
- required: true,
- message: "企业规模不能为空",
- trigger: "blur",
- },
- ],
- industry: [
- {
- required: true,
- message: "所属行业不能为空",
- trigger: "blur",
- },
- ],
- region: [
- {
- required: true,
- message: "所在地区不能为空",
- trigger: "blur",
- },
- ],
- },
- showDialog: true,
- loading: false,
- submitting: false,
- industryResult: [],
- regionResult: [],
- scaleResult: [],
- typeResult: [],
- //上传图片start
- uploadUrl: Constant.serverUrl + "/uploadPicture",
- uploadData: {
- subFolder: "companyInfo",
- },
- fileUrl: "",
- headers: {
- Authorization: getToken(),
- },
- //上传图片end
- };
- },
- created() {
- var self = this;
- dataDictionaryApi
- .findByCatalogName({
- catalogName: "企业类型",
- })
- .then((response) => {
- var jsonData = response.data;
- this.typeResult = jsonData.data;
- });
- dataDictionaryApi
- .findByCatalogName({
- catalogName: "企业规模",
- })
- .then((response) => {
- var jsonData = response.data;
- this.scaleResult = jsonData.data;
- });
- dataDictionaryApi
- .findByCatalogName({
- catalogName: "所属行业",
- })
- .then((response) => {
- var jsonData = response.data;
- this.industryResult = jsonData.data;
- });
- dataDictionaryApi
- .findByCatalogName({
- catalogName: "区域",
- })
- .then((response) => {
- var jsonData = response.data;
- this.regionResult = jsonData.data;
- });
- },
- methods: {
- closeDialog() {
- this.$emit("close", false);
- },
- handleSubmit() {
- var self = this;
- this.$refs["form"].validate((valid) => {
- if (valid) {
- (function () {
- var id = self.formModel.id;
- if (id == null || id.length == 0) {
- return companyInfoApi.add(self.formModel);
- } else {
- return companyInfoApi.update(self.formModel);
- }
- })().then(function (response) {
- var jsonData = response.data;
- if (jsonData.result) {
- self.$message({
- message: "保存成功!",
- type: "success",
- });
- self.$emit("close", true);
- } else {
- self.$message({
- message: jsonData.message + "",
- type: "warning",
- });
- self.$emit("close", false);
- }
- });
- }
- });
- },
- handleAvatarSuccess(res, file) {
- this.loading = false;
- var self = this;
- self.formModel.businessLicenseUrl = res.data;
- self.fileUrl =
- res.data + "?x-oss-process=image/resize,m_lfit,w_200";
- },
- beforeAvatarUpload(file) {
- this.loading = true;
- // const isJPG = file.type === "image/jpeg";
- const isLt2M = file.size / 1024 / 1024 < 2;
- // if (!isJPG) {
- // this.$message.error("上传图片只能是 JPG 格式!");
- // }
- if (!isLt2M) {
- this.$message.error("上传图片大小不能超过 2MB!");
- }
- return isLt2M;
- },
- },
- mounted: function () {
- var self = this;
- (function () {
- if (self.businessKey.length == 0) {
- return companyInfoApi.create();
- } else {
- return companyInfoApi.edit(self.businessKey);
- }
- })()
- .then((response) => {
- var jsonData = response.data;
- self.loading = false;
- if (jsonData.result) {
- self.formModel = jsonData.data;
- let businessLicenseUrl = self.formModel.businessLicenseUrl;
- if (businessLicenseUrl != null) {
- self.fileUrl =
- businessLicenseUrl +
- "?x-oss-process=image/resize,m_lfit,h_200";
- }
- } else {
- self.$message.error(jsonData.message + "");
- }
- })
- .catch((error) => {
- self.$message.error(error + "");
- });
- },
- };
- </script>
|