addDeliveryAttorney.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. <template>
  2. <!-- 添加提货委托 -->
  3. <div class="shipTransport">
  4. <page-title>返回</page-title>
  5. <div class="form">
  6. <div class="form_box">
  7. <dil-form :formId="113" v-model="form1" ref="from1"></dil-form>
  8. <el-form>
  9. <div class="preview-group">
  10. <el-form-item label="承运单位:">
  11. <el-select
  12. v-model="carrierId"
  13. filterable >
  14. <el-option
  15. v-for="carrier in carriers"
  16. :key="carrier.id"
  17. :label="carrier.label"
  18. :value="carrier.id">
  19. </el-option>
  20. </el-select>
  21. </el-form-item>
  22. <el-form-item label="提货单位:">
  23. <el-select
  24. v-model="downSwimPortId"
  25. filterable >
  26. <el-option
  27. v-for="carrier in carriers"
  28. :key="carrier.id"
  29. :label="carrier.label"
  30. :value="carrier.id">
  31. </el-option>
  32. </el-select>
  33. </el-form-item>
  34. <el-form-item label="到达港:">
  35. <el-select
  36. v-model="portId"
  37. filterable >
  38. <el-option
  39. v-for="port in ports"
  40. :key="port.portId"
  41. :label="port.portName"
  42. :value="port.portId">
  43. </el-option>
  44. </el-select>
  45. </el-form-item>
  46. </div>
  47. </el-form>
  48. </div>
  49. <div class="liulan">
  50. <el-button type="primary" class="btn" @click="onDrawer">浏览</el-button>
  51. </div>
  52. </div>
  53. <!-- 确定和取消 -->
  54. <div class="button_box">
  55. <el-button @click="cancel">取消</el-button>
  56. <el-button type="primary" @click="makeSure" :loading="isLoading">确定</el-button>
  57. </div>
  58. <!-- 模态框 -->
  59. <el-drawer
  60. :visible.sync="drawer"
  61. :direction="direction"
  62. :before-close="handleClose"
  63. size="50%"
  64. >
  65. <el-input
  66. placeholder="请输入内容"
  67. v-model="input"
  68. style="margin-top: 10px; margin-left: 20px; width: 250px"
  69. clearable
  70. >
  71. </el-input>
  72. <el-button
  73. type="primary"
  74. class="btn"
  75. @click="onclick()"
  76. style="margin-bottom: 15px"
  77. >
  78. <i class="el-icon-search"></i>查询
  79. </el-button>
  80. <dilTable
  81. v-bind.sync="options"
  82. @radio-change="currentRadioChange1"
  83. ></dilTable>
  84. </el-drawer>
  85. </div>
  86. </template>
  87. <script>
  88. import PageTitle from "@/components/Page/Title";
  89. import { sjTime, isNumber } from "@/utils/sharedJsFile";
  90. import { getCookie } from "@/utils/util.js";
  91. export default {
  92. components: { PageTitle },
  93. data() {
  94. return {
  95. isLoading:false,
  96. input: "",
  97. carrierId:null,//承运单位id
  98. carriers:[],
  99. downSwimPortId:null,//提货单位id
  100. downSwimPorts:[],
  101. portId:null,//到达港id
  102. ports:[],
  103. drawer: false,
  104. direction: "rtl",
  105. options: {
  106. requestUrl: "/api/v1/tms/getBatchListForAttorney?apiId=375",
  107. selectionType: "radio",
  108. maplist: [],
  109. },
  110. batchIds: "",
  111. form1: {},
  112. value: undefined,
  113. value2: undefined,
  114. };
  115. },
  116. computed: {
  117. a1() {
  118. return this.form1.attorneyPickupContactPerson;
  119. },
  120. },
  121. watch: {
  122. a1() {
  123. this.getPersonInfo();
  124. },
  125. },
  126. created() {
  127. this.form1 = {
  128. downSwimPortId: 11,
  129. attorneyTime: new Date(),
  130. };
  131. },
  132. mounted() {
  133. this.$set(this.form1, "requesterGroupId", 1); //委托单位(requesterGroupId)承运单位(carrierId)转移到提货委托
  134. this.$set(this.form1, "carrierId", 11);
  135. this.getCarriers();
  136. this.getPorts();
  137. },
  138. methods: {
  139. //查询所有承运单位和提货单位
  140. getCarriers(){
  141. this.axios.get("/api/v1/tms/getPortName").then((res) => {
  142. if (res.data.code == 200) {
  143. //赋值
  144. this.carriers=res.data.data;
  145. this.downSwimPorts=res.data.data;
  146. } else {
  147. this.$message({
  148. type: "warning",
  149. message: res.data.data,
  150. });
  151. }
  152. });
  153. },
  154. //查询所有港口
  155. getPorts(){
  156. this.axios.post("/api/v1/rms/getPortName?index=").then((res) => {
  157. if (res.data.code == 200) {
  158. //赋值
  159. this.ports=res.data.data;
  160. } else {
  161. this.$message({
  162. type: "warning",
  163. message: res.data.data,
  164. });
  165. }
  166. });
  167. },
  168. getPersonInfo() {
  169. console.log(this.form1);
  170. console.log("我尽力了");
  171. this.axios
  172. .post(
  173. "/api/v1/tms/getPersonByName?personName=" +
  174. this.form1.attorneyPickupContactPerson
  175. )
  176. .then((res) => {
  177. console.log(this.form1);
  178. this.$set(this.form1, "attorenyPickupIdcard", res.data.data.personId);
  179. this.$set(
  180. this.form1,
  181. "attorneyContactTelephone",
  182. res.data.data.personPhone
  183. );
  184. console.log(this.form1);
  185. });
  186. },
  187. onDrawer() {
  188. this.drawer = true;
  189. },
  190. onclick() {
  191. this.options.requestUrl =
  192. "/api/v1/tms/getBatchListForAttorney?apiId=375&con=" + this.input;
  193. },
  194. handleClose(done) {
  195. done();
  196. },
  197. currentRadioChange1(selection) {
  198. this.maplist = selection;
  199. if (JSON.stringify(this.maplist).length > 2) {
  200. this.$set(
  201. this.form1,
  202. "batchId",
  203. selection.resultForeignShipName + selection.materialName
  204. );
  205. this.batchIds = selection.batchId;
  206. }
  207. },
  208. // 确定
  209. makeSure() {
  210. this.isLoading=true;
  211. // 判断用户是否输入了批次号
  212. if (this.batchIds == "" || this.batchIds == undefined) {
  213. this.$message.warning("请选择批次号");
  214. this.isLoading=false;
  215. return;
  216. }
  217. let AmsshipDeliveryAttorney = {
  218. carrierId: this.carrierId, //委托单位(requesterGroupId)承运单位(carrierId)转移到提货委托
  219. requesterGroupId: this.form1.requesterGroupId,
  220. downSwimPortId: this.downSwimPortId,
  221. attorenyPickupIdcard: this.form1.attorenyPickupIdcard,
  222. attorneyContactTelephone: this.form1.attorneyContactTelephone,
  223. realForeignShipName:this.form1.realForeignShipName,
  224. batchId: this.batchIds,
  225. attorneyTime: sjTime(this.form1.attorneyTime),
  226. attorneyPdffile: this.form1.attorneyPdffile,
  227. noticeId: this.form1.noticeId,
  228. portId: this.portId,
  229. attorneyPickupContactPerson: this.form1.attorneyPickupContactPerson,
  230. userId: getCookie("userId"),
  231. // resultMemo: this.form1.resultMemo,
  232. };
  233. console.log(AmsshipDeliveryAttorney);
  234. //身份证校验
  235. function checkCardNo() {
  236. var value3 = AmsshipDeliveryAttorney.attorenyPickupIdcard;
  237. //验证是否为数字
  238. var patrn =
  239. /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
  240. if (patrn.exec(value3) == null || value3 == "") {
  241. return false;
  242. } else {
  243. return true;
  244. }
  245. }
  246. //判断是否为电话号码
  247. function isTelePhone() {
  248. var value2 = AmsshipDeliveryAttorney.attorneyContactTelephone;
  249. //验证是否为数字
  250. var patrn = /^1[3-9]\d{9}$/;
  251. // var patrn2 = /^(\d{3,4}-)?\d{7,8}$/;
  252. if (patrn.exec(value2) == null || value2 == "") {
  253. return false;
  254. } else {
  255. return true;
  256. }
  257. }
  258. var val2 = this.value2;
  259. var val3 = this.value3;
  260. if (
  261. typeof AmsshipDeliveryAttorney.portId =='undefined' || AmsshipDeliveryAttorney.portId==null||
  262. typeof AmsshipDeliveryAttorney.downSwimPortId =='undefined' || AmsshipDeliveryAttorney.downSwimPortId == null ||
  263. typeof AmsshipDeliveryAttorney.requesterGroupId =='undefined' || AmsshipDeliveryAttorney.requesterGroupId == null ||
  264. AmsshipDeliveryAttorney.attorenyPickupIdcard == null ||
  265. AmsshipDeliveryAttorney.attorneyContactTelephone == null ||
  266. AmsshipDeliveryAttorney.attorneyPickupContactPerson == null ||
  267. AmsshipDeliveryAttorney.realForeignShipName == null
  268. )
  269. this.$message.error("存在空值,请核实以后再提交");
  270. else if (!isTelePhone(val2))
  271. this.$message.warning("联系电话格式不正确");
  272. else if (!checkCardNo(val3))
  273. this.$message.warning("请输入正确的身份证格式");
  274. else{
  275. this.axios
  276. .post(
  277. "/api/v1/tms/insertshipDeliveryAttorney",
  278. AmsshipDeliveryAttorney
  279. )
  280. .then((res) => {
  281. if (res.data.code == 200) {
  282. this.$message({
  283. type: "success",
  284. message: "新增成功",
  285. });
  286. this.cancel();
  287. } else {
  288. this.$message({
  289. type: "warning",
  290. message: res.data.data,
  291. });
  292. }
  293. this.isLoading=false;
  294. });
  295. }
  296. this.isLoading=false;
  297. },
  298. // 取消
  299. cancel() {
  300. this.$router.go(-1);
  301. },
  302. },
  303. };
  304. </script>
  305. <style lang="scss">
  306. .shipTransport {
  307. .form {
  308. display: flex;
  309. .form_box {
  310. width: 320px;
  311. margin-left: 35%;
  312. margin-top: 30px;
  313. margin-right: 20px;
  314. .el-form {
  315. .preview-group {
  316. .el-form-item {
  317. .el-form-item__label {
  318. display: inline-block;
  319. width: 70px !important;
  320. }
  321. .el-form-item__content {
  322. .el-select {
  323. width: 250px;
  324. }
  325. .el-input {
  326. width: 250px;
  327. }
  328. }
  329. }
  330. }
  331. }
  332. }
  333. }
  334. .liulan {
  335. width: 120px;
  336. margin-top: 30px;
  337. .el-button {
  338. width: 100px !important;
  339. margin: auto;
  340. }
  341. .btn {
  342. margin-top: 0px;
  343. }
  344. .btn1 {
  345. margin-top: 13px;
  346. }
  347. .btn2 {
  348. margin-top: 67px;
  349. }
  350. }
  351. .button_box {
  352. margin-left: 45%;
  353. }
  354. }
  355. </style>