addCarrier.vue 12 KB

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