companyInfo-detail.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <style scoped>
  2. .user-panel {
  3. margin: 10px auto;
  4. }
  5. </style>
  6. <template>
  7. <el-dialog
  8. :visible.sync="showDialog"
  9. :title="title"
  10. :modal-append-to-body="false"
  11. style="text-align: left"
  12. @close="closeDialog"
  13. :close-on-click-modal="false"
  14. width="900px"
  15. >
  16. <div class="user-panel" v-loading="loading">
  17. <el-form
  18. ref="form"
  19. :model="formModel"
  20. :rules="ruleValidate"
  21. :label-width="'100px'"
  22. >
  23. <el-row>
  24. <el-col :span="12">
  25. <el-form-item label="企业名称" prop="companyName">
  26. <el-input
  27. v-model="formModel.companyName"
  28. placeholder="请输入企业名称"
  29. style="width: 300px"
  30. ></el-input>
  31. </el-form-item>
  32. </el-col>
  33. <el-col :span="12">
  34. <el-form-item label="社会信用代码" prop="creditCode">
  35. <el-input
  36. v-model="formModel.creditCode"
  37. placeholder="请输入社会信用代码"
  38. style="width: 300px"
  39. ></el-input>
  40. </el-form-item>
  41. </el-col>
  42. </el-row>
  43. <el-row>
  44. <el-col :span="12">
  45. <el-form-item label="所在地区" prop="region">
  46. <el-select
  47. v-model="formModel.region"
  48. filterable
  49. placeholder="请选择"
  50. style="width: 200px"
  51. >
  52. <el-option
  53. v-for="region in regionResult"
  54. :key="region.value"
  55. :label="region.name"
  56. :value="region.value"
  57. ></el-option>
  58. </el-select> </el-form-item
  59. ></el-col>
  60. <el-col :span="12">
  61. <el-form-item label="企业类型" prop="type">
  62. <el-select
  63. v-model="formModel.type"
  64. filterable
  65. placeholder="请选择"
  66. style="width: 200px"
  67. >
  68. <el-option
  69. v-for="type in typeResult"
  70. :key="type.value"
  71. :label="type.name"
  72. :value="type.value"
  73. ></el-option>
  74. </el-select>
  75. </el-form-item>
  76. </el-col>
  77. </el-row>
  78. <el-row>
  79. <el-col :span="12">
  80. <el-form-item label="所属行业" prop="industry">
  81. <el-select
  82. v-model="formModel.industry"
  83. filterable
  84. placeholder="请选择"
  85. style="width: 200px"
  86. >
  87. <el-option
  88. v-for="industry in industryResult"
  89. :key="industry.value"
  90. :label="industry.name"
  91. :value="industry.value"
  92. ></el-option>
  93. </el-select>
  94. </el-form-item>
  95. </el-col>
  96. <el-col :span="12">
  97. <el-form-item label="企业规模" prop="scale">
  98. <el-select
  99. v-model="formModel.scale"
  100. filterable
  101. placeholder="请选择"
  102. style="width: 200px"
  103. >
  104. <el-option
  105. v-for="scale in scaleResult"
  106. :key="scale.value"
  107. :label="scale.name"
  108. :value="scale.value"
  109. ></el-option> </el-select></el-form-item
  110. ></el-col>
  111. </el-row>
  112. <el-row>
  113. <el-col :span="12">
  114. <el-form-item label="营业执照" prop="businessLicenseUrl">
  115. <el-upload
  116. class="avatar-uploader"
  117. name="photoFile"
  118. :action="uploadUrl"
  119. :show-file-list="false"
  120. :headers="headers"
  121. :data="uploadData"
  122. :on-success="handleAvatarSuccess"
  123. :before-upload="beforeAvatarUpload"
  124. accept="image/png,image/jpeg"
  125. >
  126. <img v-if="fileUrl" :src="fileUrl" class="avatar" />
  127. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  128. </el-upload>
  129. </el-form-item>
  130. </el-col>
  131. </el-row>
  132. <el-row>
  133. <el-col :span="24">
  134. <el-form-item label="企业地址" prop="address">
  135. <el-input
  136. v-model="formModel.address"
  137. placeholder="请输入企业地址"
  138. style="width: 80%"
  139. ></el-input> </el-form-item
  140. ></el-col>
  141. </el-row>
  142. <el-row>
  143. <el-col :span="24">
  144. <el-form-item label="企业介绍" prop="companyIntroduction">
  145. <el-input
  146. v-model="formModel.companyIntroduction"
  147. placeholder="请输入企业介绍"
  148. style="width: 80%"
  149. ></el-input> </el-form-item
  150. ></el-col>
  151. </el-row>
  152. <el-row>
  153. <el-col :span="24">
  154. <el-form-item label="企业家介绍" prop="enterpriserIntroduction">
  155. <el-input
  156. v-model="formModel.enterpriserIntroduction"
  157. placeholder="请输入企业家介绍"
  158. style="width: 80%"
  159. ></el-input> </el-form-item
  160. ></el-col>
  161. </el-row>
  162. </el-form>
  163. </div>
  164. <span slot="footer" class="dialog-footer">
  165. <el-button @click="closeDialog">取 消</el-button>
  166. <el-button type="primary" @click="handleSubmit" :loading="submitting"
  167. >确 定</el-button
  168. >
  169. </span>
  170. </el-dialog>
  171. </template>
  172. <script>
  173. import Constant from "@/constant";
  174. import companyInfoApi from "@/api/base/companyInfo";
  175. import dataDictionaryApi from "@/api/sys/dataDictionary";
  176. import { getToken } from "@/utils/auth"; // get token from cookie
  177. export default {
  178. props: ["businessKey", "title"],
  179. data() {
  180. return {
  181. formModel: {},
  182. ruleValidate: {
  183. companyName: [
  184. { required: true, message: "企业名称不能为空", trigger: "blur" },
  185. ],
  186. type: [
  187. {
  188. required: true,
  189. message: "企业类型不能为空",
  190. trigger: "blur",
  191. },
  192. ],
  193. scale: [
  194. {
  195. required: true,
  196. message: "企业规模不能为空",
  197. trigger: "blur",
  198. },
  199. ],
  200. industry: [
  201. {
  202. required: true,
  203. message: "所属行业不能为空",
  204. trigger: "blur",
  205. },
  206. ],
  207. region: [
  208. {
  209. required: true,
  210. message: "所在地区不能为空",
  211. trigger: "blur",
  212. },
  213. ],
  214. },
  215. showDialog: true,
  216. loading: false,
  217. submitting: false,
  218. industryResult: [],
  219. regionResult: [],
  220. scaleResult: [],
  221. typeResult: [],
  222. //上传图片start
  223. uploadUrl: Constant.serverUrl + "/uploadPicture",
  224. uploadData: {
  225. subFolder: "companyInfo",
  226. },
  227. fileUrl: "",
  228. headers: {
  229. Authorization: getToken(),
  230. },
  231. //上传图片end
  232. };
  233. },
  234. created() {
  235. var self = this;
  236. dataDictionaryApi
  237. .findByCatalogName({
  238. catalogName: "企业类型",
  239. })
  240. .then((response) => {
  241. var jsonData = response.data;
  242. this.typeResult = jsonData.data;
  243. });
  244. dataDictionaryApi
  245. .findByCatalogName({
  246. catalogName: "企业规模",
  247. })
  248. .then((response) => {
  249. var jsonData = response.data;
  250. this.scaleResult = jsonData.data;
  251. });
  252. dataDictionaryApi
  253. .findByCatalogName({
  254. catalogName: "所属行业",
  255. })
  256. .then((response) => {
  257. var jsonData = response.data;
  258. this.industryResult = jsonData.data;
  259. });
  260. dataDictionaryApi
  261. .findByCatalogName({
  262. catalogName: "区域",
  263. })
  264. .then((response) => {
  265. var jsonData = response.data;
  266. this.regionResult = jsonData.data;
  267. });
  268. },
  269. methods: {
  270. closeDialog() {
  271. this.$emit("close", false);
  272. },
  273. handleSubmit() {
  274. var self = this;
  275. this.$refs["form"].validate((valid) => {
  276. if (valid) {
  277. (function () {
  278. var id = self.formModel.id;
  279. if (id == null || id.length == 0) {
  280. return companyInfoApi.add(self.formModel);
  281. } else {
  282. return companyInfoApi.update(self.formModel);
  283. }
  284. })().then(function (response) {
  285. var jsonData = response.data;
  286. if (jsonData.result) {
  287. self.$message({
  288. message: "保存成功!",
  289. type: "success",
  290. });
  291. self.$emit("close", true);
  292. } else {
  293. self.$message({
  294. message: jsonData.message + "",
  295. type: "warning",
  296. });
  297. self.$emit("close", false);
  298. }
  299. });
  300. }
  301. });
  302. },
  303. handleAvatarSuccess(res, file) {
  304. this.loading = false;
  305. var self = this;
  306. self.formModel.businessLicenseUrl = res.data;
  307. self.fileUrl =
  308. res.data + "?x-oss-process=image/resize,m_lfit,w_200";
  309. },
  310. beforeAvatarUpload(file) {
  311. this.loading = true;
  312. // const isJPG = file.type === "image/jpeg";
  313. const isLt2M = file.size / 1024 / 1024 < 2;
  314. // if (!isJPG) {
  315. // this.$message.error("上传图片只能是 JPG 格式!");
  316. // }
  317. if (!isLt2M) {
  318. this.$message.error("上传图片大小不能超过 2MB!");
  319. }
  320. return isLt2M;
  321. },
  322. },
  323. mounted: function () {
  324. var self = this;
  325. (function () {
  326. if (self.businessKey.length == 0) {
  327. return companyInfoApi.create();
  328. } else {
  329. return companyInfoApi.edit(self.businessKey);
  330. }
  331. })()
  332. .then((response) => {
  333. var jsonData = response.data;
  334. self.loading = false;
  335. if (jsonData.result) {
  336. self.formModel = jsonData.data;
  337. let businessLicenseUrl = self.formModel.businessLicenseUrl;
  338. if (businessLicenseUrl != null) {
  339. self.fileUrl =
  340. businessLicenseUrl +
  341. "?x-oss-process=image/resize,m_lfit,h_200";
  342. }
  343. } else {
  344. self.$message.error(jsonData.message + "");
  345. }
  346. })
  347. .catch((error) => {
  348. self.$message.error(error + "");
  349. });
  350. },
  351. };
  352. </script>