addCapacity.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <!-- 添加运力信息 -->
  3. <div class="addCapacity">
  4. <PageTitle>返回</PageTitle>
  5. <div class="form_box" style="margin-right: 10rem">
  6. <dil-form :formId="309" v-model="form1" ref="from1"></dil-form>
  7. </div>
  8. <div class="elForm">
  9. <el-form
  10. :inline="true"
  11. class="demo-form-inline"
  12. label-width="80px"
  13. >
  14. <el-form-item label="选择承运商">
  15. <el-autocomplete
  16. class="inline-input"
  17. v-model="state"
  18. :fetch-suggestions="querySearch"
  19. placeholder="请输入承运商名称"
  20. :trigger-on-focus="false"
  21. @select="handleSelect"
  22. >
  23. <template slot-scope="{ item }">
  24. <div class="name">{{ item.carrierName }}</div>
  25. </template>
  26. </el-autocomplete>
  27. </el-form-item>
  28. </el-form>
  29. </div>
  30. <div class="button_box">
  31. <el-button @click="cancel">取消</el-button>
  32. <el-button type="primary" @click="makeSure">确定</el-button>
  33. </div>
  34. </div>
  35. </template>
  36. <script>
  37. import PageTitle from "@/components/Page/Title";
  38. import { getCookie } from "@/utils/util.js";
  39. export default {
  40. components: { PageTitle },
  41. data() {
  42. return {
  43. form1: {},
  44. value: undefined,
  45. carrierIds: null,
  46. state:null,
  47. userId:null,
  48. restaurants: [],
  49. accessToken:null,
  50. userCode:null,
  51. carrierUserId:null,
  52. carrierId:null
  53. };
  54. },
  55. created(){
  56. this.carrierUserId = getCookie("userId");
  57. console.log(this.carrierUserId ,'carrierUserId')
  58. },
  59. mounted() {
  60. this.axios.post(
  61. "api/v1/rms/getCarrierNameBySSOId?carrierSSOId=" + this.carrierUserId
  62. )
  63. .then((res) => {
  64. if(res.data.code == "200"){
  65. console.log(res.data.data)
  66. this.state = res.data.data.carrierName
  67. this.carrierIds = res.data.data.carrierId
  68. }
  69. })},
  70. methods: {
  71. //承运商弹出层
  72. handleSelect(item){
  73. this.carrierIds = item.carrierId
  74. item.carrierName = this.state
  75. },
  76. //以下是承运商边输边查搜索
  77. querySearch(queryString, cb) {
  78. this.axios.post('/api/v1/uc/getCarrierMesByLike?index='+queryString).then((res)=>{
  79. if(res.data.code == "200"){
  80. console.log(res.data.data)
  81. var restaurants = res.data.data
  82. console.log(restaurants,"restaurants");
  83. var results = queryString ? restaurants.filter(this.createFilter(queryString)) :restaurants;
  84. // 调用 callback 返回建议列表的数据
  85. cb(results);
  86. }
  87. })
  88. },
  89. createFilter(queryString) {
  90. return (restaurants) => {
  91. return (restaurants.value.toLowerCase().indexOf(queryString.toLowerCase()) > -1);
  92. };
  93. },
  94. //以上是承运商边输边查搜索
  95. deleteUser(userId){
  96. this.axios.delete("pass/v1/sysusers/" + userId) .then((res) => {
  97. this.$message.error("添加失败,车牌可能重复");
  98. });
  99. },
  100. insertRole(userId,userCode){
  101. this.axios
  102. .post(
  103. "pass/v1/sysuserroles/addUserroles?userId=" +
  104. userId +
  105. "&userCode=" +
  106. userCode +
  107. "&roleId=" +
  108. '923693668269953024'
  109. ).then((res) => {
  110. if (res.code === "0") {
  111. this.$message.success("操作成功");
  112. this.saveLoading = false;
  113. this.rolesTree.loading = false;
  114. } else {
  115. this.$message.error(res.message);
  116. }
  117. })
  118. },
  119. makeSure() {
  120. let RmsCapacity = {
  121. capacityTypeId: this.form1.capacityTypeId,
  122. capacityNumber: this.form1.capacityNumber.toUpperCase(),
  123. capacityCorlor: this.form1.capacityCorlor,
  124. capacityOwneris: this.form1.capacityOwneris,
  125. capacityVip: this.form1.capacityVip,
  126. capacityBlacklist: this.form1.capacityBlacklist,
  127. carrierId:this.carrierIds,
  128. state: this.state
  129. };
  130. if (
  131. RmsCapacity.capacityNumber == null ||
  132. RmsCapacity.capacityCorlor == null ||
  133. RmsCapacity.capacityOwneris == null ||
  134. RmsCapacity.capacityVip == null ||
  135. RmsCapacity.capacityBlacklist == null
  136. )
  137. this.$message.error("存在空值!");
  138. var formData = new FormData();
  139. formData.append("userName",this.form1.capacityNumber.toUpperCase())
  140. console.log(formData.get("userName"))
  141. console.log(formData.set("userName",this.form1.capacityNumber.toUpperCase()))
  142. console.log(formData)
  143. formData.append('userCode',this.form1.capacityNumber.toUpperCase())
  144. formData.append('orgCode','yunli')
  145. formData.append('orgName','运力')
  146. formData.append('groupId','506514577756917769')
  147. formData.append('companyId','713710108567277568')
  148. formData.append('orgId','924126716337721344')
  149. console.log(formData.get("userCode"))
  150. console.log(typeof formData)
  151. this.$store.dispatch("system/usersManage/addUser", formData).then((res) => {
  152. console.log(res);
  153. if (res.code === "0") {
  154. console.log(res.data.userId)
  155. this.userId = res.data.userId
  156. this.userCode = res.data.userCode
  157. RmsCapacity.ssoId = res.data.userId
  158. console.log(RmsCapacity)
  159. this.axios.post("/api/v1/rms/insertCapacity",RmsCapacity).then((res) => {
  160. console.log(res)
  161. if(res.data.code == '200'){
  162. this.insertRole(this.userId,this.userCode)
  163. this.$message.success("添加成功");
  164. this.$router.push('capacity')
  165. }
  166. else if(res.data.code == '201'){
  167. this.deleteUser(this.userId)
  168. }else{
  169. this.deleteUser(this.userId)
  170. }
  171. })
  172. } else {
  173. this.$message.error(res.message);
  174. }
  175. });
  176. },
  177. // 取消
  178. cancel() {
  179. this.$router.go(-1);
  180. },
  181. },
  182. };
  183. </script>
  184. <style lang='scss' >
  185. .addCapacity {
  186. .elForm {
  187. margin-left: 40%;
  188. }
  189. .form_box {
  190. width: 100%;
  191. margin-top: 30px;
  192. display: flex;
  193. justify-content: center;
  194. .el-form-item{
  195. display: flex;
  196. justify-content: center;
  197. .el-form-item__label{
  198. display: flex;
  199. align-items: center;
  200. }
  201. .el-form-item__content{
  202. .el-select{
  203. width: 250px;
  204. }
  205. .el-input{
  206. width: 250px;
  207. }
  208. }
  209. }
  210. }
  211. .inputBox{
  212. display: flex;
  213. justify-content: center;
  214. margin-bottom: 30px;
  215. .text{
  216. text-align: right;
  217. display: flex;
  218. align-items: center;
  219. margin-right: 5px;
  220. }
  221. .input{
  222. width: 250px;
  223. }
  224. }
  225. .button_box{
  226. display: flex;
  227. justify-content: center;
  228. .el-button{
  229. width: 80px;
  230. margin-right: 10px;
  231. }
  232. }
  233. }
  234. </style>