addCarrier.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. <template>
  2. <!-- 添加承运商信息 -->
  3. <div class="addCarrier">
  4. <PageTitle>返回</PageTitle>
  5. <div class="user_code">
  6. <span class="text">账号</span>
  7. <el-input
  8. class="input"
  9. placeholder="请输入账号(必填项)"
  10. v-model="input"
  11. clearable
  12. >
  13. </el-input>
  14. </div>
  15. <div class="user_code">
  16. <span class="text">用户名</span>
  17. <el-input
  18. class="input"
  19. placeholder="请输入用户名(必填项)"
  20. v-model="user_Name"
  21. clearable
  22. >
  23. </el-input>
  24. </div>
  25. <div class="form_box" style="margin-right: 10rem">
  26. <dil-form :formId="330" v-model="form1"></dil-form>
  27. </div>
  28. <el-upload
  29. class="upload-demo"
  30. ref="upload1"
  31. action="http://192.168.1.112:8070/api/v1/rms/rmscarrier/uploadCarrier1"
  32. :before-upload="beforeUpload"
  33. :multiple="false"
  34. list-type="picture"
  35. :show-file-list="false"
  36. :on-success="handleAvatarSuccess"
  37. :on-error="onError(1)"
  38. >
  39. <span class="span"></span>
  40. <el-input
  41. class="shippingCertificate"
  42. placeholder="请选择运输证(必填项)"
  43. v-model="shippingCertificate"
  44. disabled
  45. >
  46. </el-input>
  47. <el-button size="small" type="primary" @click="upCLick(1)"
  48. >点击上传运输证</el-button
  49. >
  50. </el-upload>
  51. <el-upload
  52. class="upload-demo"
  53. ref="upload2"
  54. action="http://192.168.1.112:8070/api/v1/rms/rmscarrier/uploadCarrier2"
  55. :before-upload="beforeUpload"
  56. :multiple="false"
  57. list-type="picture"
  58. :show-file-list="false"
  59. :on-success="handleAvatarSuccess"
  60. :on-error="onError(2)"
  61. >
  62. <span class="span"></span>
  63. <el-input
  64. class="businessLicense"
  65. placeholder="请选择经营许可证(必填项)"
  66. v-model="businessLicense"
  67. disabled
  68. >
  69. </el-input>
  70. <el-button size="small" type="primary" @click="upCLick(2)"
  71. >点击上传经营许可证</el-button
  72. >
  73. </el-upload>
  74. <el-upload
  75. class="upload-demo"
  76. ref="upload3"
  77. action="http://192.168.1.112:8070/api/v1/rms/rmscarrier/uploadCarrier3"
  78. :before-upload="beforeUpload"
  79. :multiple="false"
  80. list-type="picture"
  81. :show-file-list="false"
  82. :on-success="handleAvatarSuccess"
  83. :on-error="onError(3)"
  84. >
  85. <span class="span"></span>
  86. <el-input
  87. class="businessLicense1"
  88. placeholder="请选择营业执照(必填项)"
  89. v-model="businessLicense1"
  90. disabled
  91. >
  92. </el-input>
  93. <el-button size="small" type="primary" @click="upCLick(3)"
  94. >点击上传营业执照</el-button
  95. >
  96. </el-upload>
  97. <div class="form-box f1">
  98. <el-button
  99. type="primary"
  100. v-if="this.form1.carrierType == '销售承运商'"
  101. @click="drawer = true"
  102. >添加中标区域信息</el-button
  103. >
  104. </div>
  105. <el-drawer :visible.sync="drawer" :direction="direction" size="40%">
  106. <el-input placeholder="请输入内容" v-model="inputText" clearable>
  107. </el-input>
  108. <el-button type="primary" class="btn" @click="onClick">
  109. <i class="el-icon-search"></i>查询
  110. </el-button>
  111. <div>
  112. <dilTable
  113. v-bind.sync="options"
  114. @radio-change="currentRadioChange"
  115. ></dilTable>
  116. </div>
  117. </el-drawer>
  118. <div class="button_box">
  119. <el-button @click="cancel">取消</el-button>
  120. <el-button type="primary" @click="makeSure">确定</el-button>
  121. </div>
  122. </div>
  123. </template>
  124. <script>
  125. import PageTitle from "@/components/Page/Title";
  126. import { sjTime } from "@/utils/sharedJsFile.js";
  127. export default {
  128. components: { PageTitle },
  129. data() {
  130. return {
  131. user_Name:'',
  132. //营业执照
  133. businessLicense1: null,
  134. //营业执照
  135. businessLicense: null,
  136. //运输证
  137. shippingCertificate: null,
  138. inputText: "",
  139. direction: "rtl",
  140. input: "",
  141. form1: {},
  142. drawer: false,
  143. options: {
  144. // first请求数据的地址
  145. requestUrl: "/api/v1/rms/getCarrierBidAreaList?apiId=406",
  146. selectionType: "radio",
  147. mapList: [],
  148. },
  149. imageUrl1: "",
  150. imageUrl2: "",
  151. imageUrl3: "",
  152. num: null,
  153. upBool: false,
  154. bidAreaId: null,
  155. };
  156. },
  157. created() {
  158. this.form1 = {
  159. carrierType: null,
  160. };
  161. },
  162. methods: {
  163. VerifyPhoneNumber(Phone) {
  164. var myreg=/^(13[0-9]|14[5|7]|15[0|1|2|3|4|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$/;
  165. if (!myreg.test(Phone)) {
  166. return false;
  167. } else {
  168. return true;
  169. }
  170. },
  171. upCLick(val) {
  172. this.num = val;
  173. },
  174. beforeUpload(file) {
  175. this.upBool = true;
  176. const isLt2M = file.size < 1024 * 1024 * 0.5;
  177. if (!isLt2M) {
  178. this.$message.error("上传文件大小不能超过500kb!");
  179. } else {
  180. let size = file.size / 1024;
  181. let _URL = window.URL || window.webkitURL;
  182. let img = new Image();
  183. img.src = _URL.createObjectURL(file);
  184. }
  185. return isLt2M;
  186. },
  187. onError(err) {
  188. if (this.upBool) {
  189. if (this.num == 1) {
  190. this.shippingCertificate = null;
  191. this.imageUrl1 = null;
  192. this.$message.error("上传失败");
  193. } else if (this.num == 2) {
  194. this.businessLicense = null;
  195. this.imageUrl2 = null;
  196. this.$message.error("上传失败");
  197. } else if (this.num == 3) {
  198. this.businessLicense1 = null;
  199. this.imageUrl3 = null;
  200. this.$message.error("上传失败");
  201. }
  202. }
  203. },
  204. handleAvatarSuccess(res, file) {
  205. if (res.code) {
  206. this.upBool = false;
  207. if (this.num == 1) {
  208. this.imageUrl1 = URL.createObjectURL(file.raw);
  209. this.shippingCertificate = file.name;
  210. } else if (this.num == 2) {
  211. this.imageUrl2 = URL.createObjectURL(file.raw);
  212. this.businessLicense = file.name;
  213. } else if (this.num == 3) {
  214. this.imageUrl3 = URL.createObjectURL(file.raw);
  215. this.businessLicense1 = file.name;
  216. }
  217. this.$message.success("上传成功");
  218. }
  219. },
  220. onClick() {
  221. this.options.requestUrl =
  222. "/api/v1/rms/getCarrierBidAreaList?apiId=406&con=" + this.inputText;
  223. },
  224. currentRadioChange(selection) {
  225. this.bidAreaId = selection.bidAreaId;
  226. },
  227. makeSure() {
  228. let status = false;
  229. this.form1.carrierContactNumber = parseInt(this.form1.carrierContactNumber);
  230. if (!this.input) {
  231. this.$message.error("账号不能为空");
  232. } else if(!this.user_Name){
  233. this.$message.error("用户名不能为空");
  234. }else if (!this.form1.carrierName) {
  235. this.$message.error("承运商名称不能为空");
  236. } else if (!this.form1.carrierType) {
  237. this.$message.error("承运商类型不能为空");
  238. }else if(!this.form1.contactsName){
  239. this.$message.error("联系人不能为空");
  240. }else if(!this.form1.carrierContactNumber){
  241. this.$message.error("联系电话不能为空");
  242. }else if (!this.imageUrl1) {
  243. this.$message.error("请上传运输证");
  244. } else if (!this.imageUrl2) {
  245. this.$message.error("请上传经营许可证");
  246. } else if (!this.imageUrl3) {
  247. this.$message.error("请上传营业执照");
  248. }else {
  249. status = true;
  250. }
  251. if (this.form1.registerDate) {
  252. this.form1.registerDate = sjTime(this.form1.registerDate);
  253. }
  254. if (status) {
  255. let rand = "";
  256. for (let i = 0; i < 8; i++) {
  257. rand += Math.floor(Math.random() * 10);
  258. }
  259. let fromData = new FormData();
  260. fromData.append("userCode", this.input);
  261. fromData.append("userName", this.user_Name);
  262. fromData.append("orgCode", "chengyunshang");
  263. fromData.append("mobile", "133" + rand);
  264. fromData.append("email", "133" + rand + "@163.com");
  265. fromData.append("orgName", "承运商");
  266. fromData.append("groupId", "506514577756917769");
  267. fromData.append("companyId", "713710108567277568");
  268. fromData.append("orgId", "924126339513061376");
  269. this.$store
  270. .dispatch("system/usersManage/addUser", fromData)
  271. .then((res) => {
  272. console.log(1)
  273. if (res.code === "0") {
  274. let userId = res.data.userId;
  275. this.axios
  276. .post(
  277. "pass/v1/sysuserroles/addUserroles?userId=" +
  278. userId +
  279. "&userCode=" +
  280. this.input +
  281. "&roleId=924449091658846208"
  282. )
  283. .then((res) => {
  284. console.log(2)
  285. if (res.code == "0") {
  286. //图片地址
  287. let imageUrls = {
  288. //运输证
  289. imageUrl1: this.imageUrl1,
  290. //经营许可证
  291. imageUrl2: this.imageUrl2,
  292. //营业执照
  293. imageUrl3: this.imageUrl3,
  294. };
  295. //传给后端的数据
  296. let mapValue = {
  297. //表单数据
  298. from: this.form1,
  299. //图片数据
  300. imageUrls: imageUrls,
  301. //sso的用户Id
  302. userId: userId,
  303. };
  304. this.axios
  305. .post("/api/v1/rms/insertCarrier", mapValue)
  306. .then((res) => {
  307. console.log(2)
  308. if (res.data.code == "200") {
  309. this.cancel();
  310. this.$message.success("添加成功");
  311. } else {
  312. this.axios
  313. .delete("pass/v1/sysusers/" + userId)
  314. .then((res) => {
  315. this.$message.error("添加失败");
  316. });
  317. }
  318. })
  319. .catch(() => {
  320. this.axios
  321. .delete("pass/v1/sysusers/" + userId)
  322. .then((res) => {
  323. this.$message.error("添加失败");
  324. });
  325. });
  326. }
  327. });
  328. }
  329. });
  330. }
  331. },
  332. // 取消
  333. cancel() {
  334. this.$router.push("/carrier");
  335. },
  336. },
  337. };
  338. </script>
  339. <style lang='scss' >
  340. .addCarrier {
  341. .user_code {
  342. display: flex;
  343. justify-content: center;
  344. margin: 10px;
  345. .text {
  346. display: flex;
  347. justify-content: center;
  348. align-items: center;
  349. margin-right: 10px;
  350. }
  351. .input {
  352. width: 250px;
  353. }
  354. }
  355. .form_box {
  356. display: flex;
  357. justify-content: center;
  358. margin-left: 170px;
  359. margin-top: 15px;
  360. .el-form-item {
  361. display: flex;
  362. justify-content: center;
  363. .el-form-item__label {
  364. display: flex;
  365. align-items: center;
  366. }
  367. .el-form-item__content {
  368. width: 250px;
  369. .el-radio-group {
  370. width: 500px;
  371. }
  372. .el-date-editor {
  373. width: 250px;
  374. }
  375. .el-input__inner {
  376. width: 250px;
  377. }
  378. }
  379. }
  380. }
  381. .upload-demo {
  382. display: flex;
  383. justify-content: center;
  384. margin: 10px;
  385. .span {
  386. display: inline-block;
  387. width: 200px;
  388. height: 2px;
  389. }
  390. .el-button {
  391. width: 150px;
  392. margin-right: 10px;
  393. }
  394. .shippingCertificate,
  395. .businessLicense,
  396. .businessLicense1 {
  397. width: 250px;
  398. }
  399. }
  400. .form-box {
  401. display: flex;
  402. justify-content: center;
  403. }
  404. .button_box {
  405. display: flex;
  406. justify-content: center;
  407. margin: 20px;
  408. .el-button {
  409. width: 100px;
  410. }
  411. }
  412. }
  413. </style>