addConsignee.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <!-- 添加收货客户信息 -->
  3. <div class="addConsignee">
  4. <PageTitle>返回</PageTitle>
  5. <div class="form-box" style="margin-right: 10rem">
  6. <dil-form :formId="367" v-model="form1" ref="from1"></dil-form>
  7. </div>
  8. <div class="f-box">
  9. <el-form :inline="true" class="demo-form-inline" label-width="80px">
  10. <el-form-item label="收货父级单位">
  11. <el-autocomplete
  12. class="inline-input"
  13. v-model="stateConsignee"
  14. :fetch-suggestions="querySearchConsignee"
  15. placeholder="请输入收货父级单位名称"
  16. :trigger-on-focus="false"
  17. @select="handleSelectConsignee"
  18. >
  19. <template slot-scope="{ item }">
  20. <div class="name">{{ item.consigneeCompanyName }}</div>
  21. </template>
  22. </el-autocomplete>
  23. </el-form-item>
  24. </el-form>
  25. </div>
  26. <div class="button-box">
  27. <el-button @click="cancel">取消</el-button>
  28. <el-button type="primary" @click="makeSure">确定</el-button>
  29. </div>
  30. </div>
  31. </template>
  32. <script>
  33. import PageTitle from '@/components/Page/Title'
  34. import { getCookie } from '@/utils/util.js'
  35. export default {
  36. components: { PageTitle },
  37. data() {
  38. return {
  39. form1: {},
  40. stateConsignee: null,
  41. restaurantsConsignee: null
  42. }
  43. },
  44. mounted() {},
  45. methods: {
  46. //收货单位弹出层
  47. handleSelectConsignee(item) {
  48. console.log(this.consigneeId)
  49. this.consigneeId = item.consigneeId
  50. item.consigneeCompanyName = this.consigneeCompanyName
  51. console.log(this.consigneeId)
  52. console.log('这是选中的收货单位')
  53. },
  54. //以下是发货单位边输边查搜索
  55. querySearchConsignee(queryString, cb) {
  56. this.axios
  57. .post('/api/v1/uc/getConsigneeByLike?index=' + queryString)
  58. .then(res => {
  59. if (res.data.code == '200') {
  60. console.log(res)
  61. var restaurantsConsignee = res.data.data
  62. var results = queryString
  63. ? restaurantsConsignee.filter(
  64. this.createFilterConsignee(queryString)
  65. )
  66. : restaurantsConsignee
  67. // 调用 callback 返回建议列表的数据
  68. console.log(results, 'results')
  69. cb(results)
  70. }
  71. })
  72. },
  73. createFilterConsignee(queryString) {
  74. return restaurantsConsignee => {
  75. return (
  76. restaurantsConsignee.value
  77. .toLowerCase()
  78. .indexOf(queryString.toLowerCase()) > -1
  79. )
  80. }
  81. },
  82. //以上是收货单位边输边查搜索
  83. makeSure() {
  84. console.log(this.form1)
  85. let RmsConsignee = {
  86. companyName: this.form1.companyName,
  87. consigneeAbbreviation: this.form1.consigneeAbbreviation,
  88. consigneeRegisteredAddress: this.form1.consigneeRegisteredAddress,
  89. consigneeReceiveAddress: this.form1.consigneeReceiveAddress,
  90. consigneeRegistrationTime: this.form1.consigneeRegistrationTime,
  91. consigneeContactName: this.form1.consigneeContactName,
  92. consigneeContactTel: this.form1.consigneeContactTel,
  93. consigneeFarId: this.consigneeId,
  94. userName: getCookie('loginName')
  95. }
  96. console.log('RmsConsignee', RmsConsignee)
  97. if (RmsConsignee.companyName == null) this.$message.error('存在空值!')
  98. else
  99. this.axios
  100. .post('/api/v1/rms/insertConsignee', RmsConsignee)
  101. .then(res => {
  102. console.log('res.data.code', res.data.code)
  103. if (res.data.code == 200) {
  104. this.$message({
  105. type: 'success',
  106. message: '新增成功!'
  107. })
  108. // this.$refs.table.refreshData();
  109. this.$router.go(-1)
  110. } else {
  111. this.$message.error('新增失败,可能有重复')
  112. }
  113. })
  114. },
  115. // 取消
  116. cancel() {
  117. this.$router.go(-1)
  118. }
  119. }
  120. }
  121. </script>
  122. <style lang="scss">
  123. .addConsignee {
  124. .f-box {
  125. margin-left: 36%;
  126. }
  127. .button-box {
  128. display: flex;
  129. justify-content: center;
  130. .el-button {
  131. width: 80px;
  132. margin-right: 10px;
  133. }
  134. }
  135. .form-box {
  136. width: 100%;
  137. margin-top: 30px;
  138. display: flex;
  139. justify-content: center;
  140. .el-form-item {
  141. display: flex;
  142. justify-content: center;
  143. .el-form-item__label {
  144. display: flex;
  145. align-items: center;
  146. }
  147. .el-form-item__content {
  148. .el-select {
  149. width: 250px;
  150. }
  151. .el-input {
  152. width: 250px;
  153. }
  154. }
  155. }
  156. }
  157. }
  158. </style>