123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433 |
- <template>
- <!-- 添加承运商信息 -->
- <div class="addCarrier">
- <PageTitle>返回</PageTitle>
- <div class="user_code">
- <span class="text">账号</span>
- <div class="site">
- <el-input
- class="input"
- placeholder="请输入账号(必填项)"
- v-model="input"
- clearable
- >
- </el-input>
- </div>
- </div>
- <div class="user_code">
- <span class="text">用户名</span>
- <div class="site">
- <el-input
- class="input"
- placeholder="请输入用户名(必填项)"
- v-model="user_Name"
- clearable
- >
- </el-input>
- </div>
-
- </div>
- <div class="form_box" style="margin-right: 10rem">
- <dil-form :formId="330" v-model="form1"></dil-form>
- </div>
- <el-upload
- class="upload-demo"
- ref="upload1"
- action="http://localhost:8014/api/v1/rms/rmscarrier/uploadCarrier1"
- :before-upload="beforeUpload"
- :multiple="false"
- list-type="picture"
- :show-file-list="false"
- :on-success="handleAvatarSuccess"
- :on-error="onError(1)"
- >
- <span class="span"></span>
- <el-input
- class="shippingCertificate"
- placeholder="请选择运输证(必填项)"
- v-model="shippingCertificate"
- disabled
- >
- </el-input>
- <el-button size="small" type="primary" @click="upCLick(1)"
- >点击上传运输证</el-button
- >
- </el-upload>
- <el-upload
- class="upload-demo"
- ref="upload2"
- action="http://localhost:8014/api/v1/rms/rmscarrier/uploadCarrier1"
- :before-upload="beforeUpload"
- :multiple="false"
- list-type="picture"
- :show-file-list="false"
- :on-success="handleAvatarSuccess"
- :on-error="onError(2)"
- >
- <span class="span"></span>
- <el-input
- class="businessLicense"
- placeholder="请选择经营许可证(必填项)"
- v-model="businessLicense"
- disabled
- >
- </el-input>
- <el-button size="small" type="primary" @click="upCLick(2)"
- >点击上传经营许可证</el-button
- >
- </el-upload>
- <el-upload
- class="upload-demo"
- ref="upload3"
- action="http://localhost:8014/api/v1/rms/rmscarrier/uploadCarrier1"
- :before-upload="beforeUpload"
- :multiple="false"
- list-type="picture"
- :show-file-list="false"
- :on-success="handleAvatarSuccess"
- :on-error="onError(3)"
- >
- <span class="span"></span>
- <el-input
- class="businessLicense1"
- placeholder="请选择营业执照(必填项)"
- v-model="businessLicense1"
- disabled
- >
- </el-input>
- <el-button size="small" type="primary" @click="upCLick(3)"
- >点击上传营业执照</el-button
- >
- </el-upload>
- <div class="form-box f1">
- <el-button
- type="primary"
- v-if="this.form1.carrierType == '销售承运商'"
- @click="drawer = true"
- >添加中标区域信息</el-button
- >
- </div>
- <el-drawer :visible.sync="drawer" :direction="direction" size="40%">
- <el-input placeholder="请输入内容" v-model="inputText" clearable>
- </el-input>
- <el-button type="primary" class="btn" @click="onClick">
- <i class="el-icon-search"></i>查询
- </el-button>
- <div>
- <dilTable
- v-bind.sync="options"
- @radio-change="currentRadioChange"
- ></dilTable>
- </div>
- </el-drawer>
- <div class="button_box">
- <el-button @click="cancel">取消</el-button>
- <el-button type="primary" @click="makeSure">确定</el-button>
- </div>
- </div>
- </template>
- <script>
- import PageTitle from "@/components/Page/Title";
- import { sjTime } from "@/utils/sharedJsFile.js";
- export default {
- components: { PageTitle },
- data() {
- return {
- user_Name:'',
- //营业执照
- businessLicense1: null,
- //营业执照
- businessLicense: null,
- //运输证
- shippingCertificate: null,
- inputText: "",
- direction: "rtl",
- input: "",
- form1: {},
- drawer: false,
- options: {
- // first请求数据的地址
- requestUrl: "/api/v1/rms/getCarrierBidAreaList?apiId=406",
- selectionType: "radio",
- mapList: [],
- },
- imageUrl1: "",
- imageUrl2: "",
- imageUrl3: "",
- num: null,
- upBool: false,
- bidAreaId: null,
- };
- },
- created() {
- this.form1 = {
- carrierType: null,
- };
- },
- methods: {
- VerifyPhoneNumber(Phone) {
- 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}$/;
- if (!myreg.test(Phone)) {
- return false;
- } else {
- return true;
- }
- },
- upCLick(val) {
- this.num = val;
- },
- beforeUpload(file) {
- this.upBool = true;
- const isLt2M = file.size < 1024 * 1024 * 0.5;
- if (!isLt2M) {
- this.$message.error("上传文件大小不能超过500kb!");
- } else {
- let size = file.size / 1024;
- let _URL = window.URL || window.webkitURL;
- let img = new Image();
- img.src = _URL.createObjectURL(file);
- }
- return isLt2M;
- },
- onError(err) {
- if (this.upBool) {
- if (this.num == 1) {
- this.shippingCertificate = null;
- this.imageUrl1 = null;
- this.$message.error("上传失败");
- } else if (this.num == 2) {
- this.businessLicense = null;
- this.imageUrl2 = null;
- this.$message.error("上传失败");
- } else if (this.num == 3) {
- this.businessLicense1 = null;
- this.imageUrl3 = null;
- this.$message.error("上传失败");
- }
- }
- },
- handleAvatarSuccess(res, file) {
- console.log(res,file)
- if (res.code) {
- this.upBool = false;
- if (this.num == 1) {
- this.imageUrl1 = res.data;
- this.shippingCertificate = file.name;
- } else if (this.num == 2) {
- this.imageUrl2 = res.data;
- this.businessLicense = file.name;
- } else if (this.num == 3) {
- this.imageUrl3 =res.data;
- this.businessLicense1 = file.name;
- }
- this.$message.success("上传成功");
- }
- },
- onClick() {
- this.options.requestUrl =
- "/api/v1/rms/getCarrierBidAreaList?apiId=406&con=" + this.inputText;
- },
- currentRadioChange(selection) {
- this.bidAreaId = selection.bidAreaId;
- },
- makeSure() {
- let status = false;
- this.form1.carrierContactNumber = parseInt(this.form1.carrierContactNumber);
- if (!this.input) {
- this.$message.error("账号不能为空");
- }else if(this.input.length<3){
- this.$message.error("账号不能少于3位数!");
- }
- else if(!this.user_Name){
- this.$message.error("用户名不能为空");
- }else if (!this.form1.carrierName) {
- this.$message.error("承运商名称不能为空");
- } else if (!this.form1.carrierType) {
- this.$message.error("承运商类型不能为空");
- }
- // else if (!this.imageUrl1) {
- // this.$message.error("请上传运输证");
- // } else if (!this.imageUrl2) {
- // this.$message.error("请上传经营许可证");
- // } else if (!this.imageUrl3) {
- // this.$message.error("请上传营业执照");
- // }
- else {
- status = true;
- }
- if (this.form1.registerDate) {
- this.form1.registerDate = sjTime(this.form1.registerDate);
- }
- if (status) {
- let rand = "";
- for (let i = 0; i < 8; i++) {
- rand += Math.floor(Math.random() * 10);
- }
- let fromData = new FormData();
- fromData.append("userCode", this.input);
- fromData.append("userName", this.user_Name);
- fromData.append("orgCode", "chengyunshang");
- fromData.append("mobile", "133" + rand);
- fromData.append("email", "133" + rand + "@163.com");
- fromData.append("orgName", "承运商");
- fromData.append("groupId", "506514577756917769");
- fromData.append("companyId", "713710108567277568");
- fromData.append("orgId", "924126339513061376");
- this.$store
- .dispatch("system/usersManage/addUser", fromData)
- .then((res) => {
- console.log(1)
- if (res.code === "0") {
- let userId = res.data.userId;
- this.axios
- .post(
- "pass/v1/sysuserroles/addUserroles?userId=" +
- userId +
- "&userCode=" +
- this.input +
- "&roleId=924449091658846208"
- )
- .then((res) => {
- console.log(2)
- if (res.code == "0") {
- //图片地址
- let imageUrls = {
- //运输证
- imageUrl1: this.imageUrl1,
- //经营许可证
- imageUrl2: this.imageUrl2,
- //营业执照
- imageUrl3: this.imageUrl3,
- };
- //传给后端的数据
- let mapValue = {
- //承运商账号
- carrierSsoCode: this.input,
- //表单数据
- from: this.form1,
- //图片数据
- imageUrls: imageUrls,
- //sso的用户Id
- userId: userId,
- };
- this.axios
- .post("/api/v1/rms/insertCarrier", mapValue)
- .then((res) => {
- if (res.data.code == "200") {
- this.cancel();
- this.$message.success("添加成功");
- } else {
- this.axios
- .delete("pass/v1/sysusers/" + userId)
- .then((res) => {
- this.$message.error("添加失败");
- });
- }
- })
- .catch(() => {
- this.axios
- .delete("pass/v1/sysusers/" + userId)
- .then((res) => {
- this.$message.error("添加失败");
- });
- });
- }
- });
- }
- });
- }
- },
- // 取消
- cancel() {
- this.$router.push("/carrier");
- },
- },
- };
- </script>
- <style lang='scss' >
- .addCarrier {
- .user_code {
- display: flex;
- justify-content: center;
- margin: 10px;
- .text {
- display: flex;
- justify-content: center;
- align-items: center;
- margin-right: 10px;
- }
- .input {
- width: 250px;
- }
- }
- .form_box {
- display: flex;
- justify-content: center;
- margin-left: 170px;
- margin-top: 15px;
- .el-form-item {
- display: flex;
- justify-content: center;
- .el-form-item__label {
- display: flex;
- align-items: center;
- }
- .el-form-item__content {
- width: 250px;
- .el-radio-group {
- width: 500px;
- }
- .el-date-editor {
- width: 250px;
- }
- .el-input__inner {
- width: 250px;
- }
- }
- }
- }
- .upload-demo {
- display: flex;
- justify-content: center;
- margin: 10px;
- .span {
- display: inline-block;
- width: 200px;
- height: 2px;
- }
- .el-button {
- width: 150px;
- margin-right: 10px;
- }
- .shippingCertificate,
- .businessLicense,
- .businessLicense1 {
- width: 250px;
- }
- }
- .site{
- position: relative;
- left: 32px;
- }
- span.text {
- position: relative;
- align-content: center;
- left: -35px;
- }
- .form-box {
- display: flex;
- justify-content: center;
- }
- .button_box {
- display: flex;
- justify-content: center;
- margin: 20px;
- .el-button {
- width: 100px;
- }
- }
- }
- </style>
|