addCustomer.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <div>
  3. <el-form ref="form" v-loading="addLoading" :model="form" style="width: 100%;padding: 5px" :rules="rules">
  4. <el-row>
  5. <el-col style="padding-bottom: 10px">
  6. <span class="card_title">基本信息</span>
  7. <el-card shadow="always" style="padding: 15px 5px 5px 15px">
  8. <el-row>
  9. <el-col :span="3" class="col-txt"><span>小区-分期</span></el-col>
  10. <el-col :span="9" class="col-input">
  11. <el-form-item>
  12. <el-cascader
  13. ref="findids"
  14. v-model="form.findids"
  15. class="full"
  16. :append-to-body="false"
  17. :options="options"
  18. clearable
  19. @change="handleChange"
  20. />
  21. </el-form-item>
  22. </el-col>
  23. <el-col :span="3" class="col-txt"><span>选房日</span></el-col>
  24. <el-col :span="9" class="col-input">
  25. <el-form-item prop="">
  26. <el-date-picker
  27. v-model="form.roomSelectionDate"
  28. type="date"
  29. placeholder="年月日"
  30. value-format="yyyy-MM-dd"
  31. />
  32. </el-form-item>
  33. </el-col>
  34. </el-row>
  35. <el-row>
  36. <el-col :span="3" class="col-txt"><span>批次号</span></el-col>
  37. <el-col :span="9" class="col-input">
  38. <el-form-item prop="companyId">
  39. <el-input v-model="form.batchNumber" />
  40. </el-form-item>
  41. </el-col>
  42. <el-col :span="3" class="col-txt"><span>选房号</span></el-col>
  43. <el-col :span="9" class="col-input">
  44. <el-form-item prop="companyId">
  45. <el-input v-model="form.roomSelectionNumber" />
  46. </el-form-item>
  47. </el-col>
  48. </el-row>
  49. <el-row>
  50. <!-- 特殊表单 -->
  51. <div v-for="(item, index) in form.dynamicItem" :key="index">
  52. <el-row style="margin-top: 10px">
  53. <el-col :span="2" class="col-txt"><span>购房人{{ index + 1 }}</span></el-col>
  54. <el-col :span="4" class="col-input">
  55. <el-form-item :prop="'dynamicItem.' + index + '.name'">
  56. <el-input
  57. v-model="item.name"
  58. placeholder="请填写姓名"
  59. />
  60. </el-form-item>
  61. </el-col>
  62. <el-col :span="4" class="col-input">
  63. <el-form-item :prop="'dynamicItem.' + index + '.identityCard'">
  64. <el-input
  65. v-model="item.identityCard"
  66. placeholder="请填写身份证号"
  67. />
  68. </el-form-item>
  69. </el-col>
  70. <el-col :span="4" class="col-input">
  71. <el-form-item :prop="'dynamicItem.' + index + '.phone'">
  72. <el-input
  73. v-model="item.phone"
  74. placeholder="请填写手机号"
  75. />
  76. </el-form-item>
  77. </el-col>
  78. <el-col v-if="index !== 0" :span="6" class="col-input">
  79. <el-form-item :prop="'dynamicItem.' + index + '.relationship'">
  80. <el-select
  81. v-model="item.relationship"
  82. placeholder="与1的关系"
  83. filterable
  84. :popper-append-to-body="false"
  85. popper-class="statistic_base"
  86. >
  87. <el-option
  88. v-for="relationship in dc_data.RELATIONSHIP"
  89. :key="relationship.value"
  90. :label="relationship.label"
  91. :value="relationship.value"
  92. :popper-append-to-body="false"
  93. popper-class="statistic_base"
  94. />
  95. </el-select>
  96. </el-form-item>
  97. </el-col>
  98. <el-col :span="2" class="col-input">
  99. <el-button v-if="index !== 0" type="danger" size="mini" @click="deleteItem(item, index)">-</el-button>
  100. </el-col>
  101. </el-row>
  102. </div>
  103. </el-row>
  104. <el-row>
  105. <el-col :span="2" class="col-txt">
  106. <el-button size="small" type="text" @click="addItem">+继续添加</el-button>
  107. </el-col>
  108. </el-row>
  109. </el-card>
  110. </el-col>
  111. </el-row>
  112. </el-form>
  113. <div style="text-align: right">
  114. <el-button @click="cancel">取 消</el-button>
  115. <el-button type="primary" @click="confirmSubmit()">提 交</el-button>
  116. </div>
  117. </div>
  118. </template>
  119. <script>
  120. import Base from '@/views/base/base'
  121. import BaseData from '@/views/base/baseData'
  122. export default {
  123. name: 'AddCustomer',
  124. components: { },
  125. mixins: [Base, BaseData],
  126. data() {
  127. return {
  128. dc_key: ['RELATIONSHIP'],
  129. form: {
  130. dynamicItem: [
  131. {
  132. id: '',
  133. customerManagementId: '',
  134. name: '',
  135. identityCard: '',
  136. phone: '',
  137. relationship: ''
  138. }
  139. ]
  140. },
  141. rules: {
  142. },
  143. addLoading: false,
  144. options: []
  145. }
  146. },
  147. mounted() {
  148. this.getTreeSelectData()
  149. },
  150. methods: {
  151. initData(data) {
  152. this.initDict(this.dc_key).then(res => {
  153. this.getById(data.id)
  154. })
  155. },
  156. handleChange(value) {
  157. },
  158. getById(val) {
  159. this.baseRequest('getById', { id: val }).then(res => {
  160. this.form = res.data
  161. this.form.findids = [res.data.groupId, res.data.discId]
  162. this.form.dynamicItem = []
  163. const json = JSON.parse(res.data.buyerJson)
  164. if (json) {
  165. json.forEach(item => {
  166. const data = {
  167. name: item.name,
  168. identityCard: item.identityCard,
  169. phone: item.phone,
  170. relationship: item.relationship
  171. }
  172. this.form.dynamicItem.push(data)
  173. })
  174. }
  175. })
  176. },
  177. confirmSubmit: function() {
  178. const _this = this
  179. this.$refs.form.validate(valid => {
  180. if (valid) {
  181. let soaUrl = 'add'
  182. if (_this.form.id) {
  183. soaUrl = 'edit'
  184. }
  185. const extraData = {
  186. groupId: _this.form.findids[0],
  187. discId: _this.form.findids[1],
  188. buyerJson: JSON.stringify(_this.form.dynamicItem)
  189. }
  190. const postData = Object.assign({}, _this.form, extraData)
  191. console.log('postData', postData)
  192. this.baseRequest(soaUrl, postData).then(res => {
  193. if (res.data.code == '200') {
  194. _this.$message({
  195. message: '新增成功',
  196. type: 'success'
  197. })
  198. _this.cancel()
  199. } else {
  200. _this.$message({
  201. message: res.msg,
  202. type: 'warning'
  203. })
  204. }
  205. }).catch(err => {
  206. _this.$message({
  207. message: err,
  208. type: 'warning'
  209. })
  210. })
  211. } else {
  212. console.log('error submit!!')
  213. return false
  214. }
  215. })
  216. },
  217. cancel() {
  218. this.$emit('cancel')
  219. },
  220. getTreeSelectData: function() {
  221. this.baseInfoRequest('getTreeData3', {}).then((res) => {
  222. this.options = res.data.data
  223. }).catch(() => {
  224. })
  225. },
  226. addItem(length) {
  227. this.form.dynamicItem.push({
  228. id: '',
  229. customerManagementId: '',
  230. name: '',
  231. identityCard: '',
  232. phone: '',
  233. relationship: ''
  234. })
  235. },
  236. // 删除方法
  237. deleteItem(item, index) {
  238. this.form.dynamicItem.splice(index, 1)
  239. },
  240. baseRequest(opUrl, postData) {
  241. return this.$channel.globeRequest('CustomerManagementController', opUrl, postData, 'project')
  242. },
  243. baseInfoRequest: function(opUrl, postData) {
  244. return this.$channel.baseRequest('ParkInfoController', opUrl, postData, 'User')
  245. }
  246. }
  247. }
  248. </script>
  249. <style scoped>
  250. </style>