addCapacity.vue 6.5 KB

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