addCarrier.vue 12 KB

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