addCarrier.vue 12 KB

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