addCarrier.vue 10 KB

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