addCarrier.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  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://172.16.33.166:8080/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="http://172.16.33.166:8080/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="http://172.16.33.166:8080/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. let status = false;
  235. this.form1.carrierContactNumber = parseInt(this.form1.carrierContactNumber);
  236. if (!this.input) {
  237. this.$message.error("账号不能为空");
  238. }else if(this.input.length<3){
  239. this.$message.error("账号不能少于3位数!");
  240. }
  241. else if(!this.user_Name){
  242. this.$message.error("用户名不能为空");
  243. }else if (!this.form1.carrierName) {
  244. this.$message.error("承运商名称不能为空");
  245. } else if (!this.form1.carrierType) {
  246. this.$message.error("承运商类型不能为空");
  247. }
  248. // else if (!this.imageUrl1) {
  249. // this.$message.error("请上传运输证");
  250. // } else if (!this.imageUrl2) {
  251. // this.$message.error("请上传经营许可证");
  252. // } else if (!this.imageUrl3) {
  253. // this.$message.error("请上传营业执照");
  254. // }
  255. else {
  256. status = true;
  257. }
  258. if (this.form1.registerDate) {
  259. this.form1.registerDate = sjTime(this.form1.registerDate);
  260. }
  261. if (status) {
  262. let rand = "";
  263. for (let i = 0; i < 8; i++) {
  264. rand += Math.floor(Math.random() * 10);
  265. }
  266. let fromData = new FormData();
  267. fromData.append("userCode", this.input);
  268. fromData.append("userName", this.user_Name);
  269. fromData.append("orgCode", "chengyunshang");
  270. fromData.append("mobile", "133" + rand);
  271. fromData.append("email", "133" + rand + "@163.com");
  272. fromData.append("orgName", "承运商");
  273. fromData.append("groupId", "506514577756917769");
  274. fromData.append("companyId", "713710108567277568");
  275. fromData.append("orgId", "924126339513061376");
  276. this.$store
  277. .dispatch("system/usersManage/addUser", fromData)
  278. .then((res) => {
  279. console.log(1)
  280. if (res.code === "0") {
  281. let userId = res.data.userId;
  282. this.axios
  283. .post(
  284. "pass/v1/sysuserroles/addUserroles?userId=" +
  285. userId +
  286. "&userCode=" +
  287. this.input +
  288. "&roleId=924449091658846208"
  289. )
  290. .then((res) => {
  291. console.log(2)
  292. if (res.code == "0") {
  293. //图片地址
  294. let imageUrls = {
  295. //运输证
  296. imageUrl1: this.imageUrl1,
  297. //经营许可证
  298. imageUrl2: this.imageUrl2,
  299. //营业执照
  300. imageUrl3: this.imageUrl3,
  301. };
  302. //传给后端的数据
  303. let mapValue = {
  304. //承运商账号
  305. carrierSsoCode: this.input,
  306. //表单数据
  307. from: this.form1,
  308. //图片数据
  309. imageUrls: imageUrls,
  310. //sso的用户Id
  311. userId: userId,
  312. };
  313. this.axios
  314. .post("/api/v1/rms/insertCarrier", mapValue)
  315. .then((res) => {
  316. if (res.data.code == "200") {
  317. this.cancel();
  318. this.$message.success("添加成功");
  319. } else {
  320. this.axios
  321. .delete("pass/v1/sysusers/" + userId)
  322. .then((res) => {
  323. this.$message.error("添加失败");
  324. });
  325. }
  326. })
  327. .catch(() => {
  328. this.axios
  329. .delete("pass/v1/sysusers/" + userId)
  330. .then((res) => {
  331. this.$message.error("添加失败");
  332. });
  333. });
  334. }
  335. });
  336. }
  337. });
  338. }
  339. },
  340. // 取消
  341. cancel() {
  342. this.$router.push("/carrier");
  343. },
  344. },
  345. };
  346. </script>
  347. <style lang='scss' >
  348. .addCarrier {
  349. .user_code {
  350. display: flex;
  351. justify-content: center;
  352. margin: 10px;
  353. .text {
  354. display: flex;
  355. justify-content: center;
  356. align-items: center;
  357. margin-right: 10px;
  358. width: 40px;
  359. position: relative;
  360. left: 40px;
  361. }
  362. .input {
  363. width: 250px;
  364. }
  365. }
  366. .form_box {
  367. display: flex;
  368. justify-content: center;
  369. margin-left: 170px;
  370. margin-top: 15px;
  371. .el-form-item {
  372. display: flex;
  373. justify-content: center;
  374. .el-form-item__label {
  375. display: flex;
  376. align-items: center;
  377. }
  378. .el-form-item__content {
  379. width: 250px;
  380. .el-radio-group {
  381. width: 500px;
  382. }
  383. .el-date-editor {
  384. width: 250px;
  385. }
  386. .el-input__inner {
  387. width: 250px;
  388. }
  389. }
  390. }
  391. }
  392. .upload-demo {
  393. display: flex;
  394. justify-content: center;
  395. margin: 10px;
  396. .span {
  397. display: inline-block;
  398. width: 200px;
  399. height: 2px;
  400. }
  401. .el-button {
  402. width: 150px;
  403. margin-right: 10px;
  404. }
  405. .shippingCertificate,
  406. .businessLicense,
  407. .businessLicense1 {
  408. width: 250px;
  409. }
  410. }
  411. .site{
  412. position: relative;
  413. left: -50px;
  414. }
  415. span.text {
  416. position: relative;
  417. align-content: center;
  418. left: -35px;
  419. }
  420. .form-box {
  421. display: flex;
  422. justify-content: center;
  423. }
  424. .button_box {
  425. display: flex;
  426. justify-content: center;
  427. margin: 20px;
  428. .el-button {
  429. width: 100px;
  430. }
  431. }
  432. }
  433. </style>