myrecordedit.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. <template>
  2. <view class="page">
  3. <view class="form">
  4. <u-form :model="form" ref="uForm">
  5. <u-form-item label-width="150" label="意向方式" prop="groupTypeName">
  6. <u-input type="select" inputAlign="right" :select-open="groupTypeSelectShow" v-model="form.groupTypeName" placeholder="请选择身份" @click="groupTypeSelectShow = true"></u-input>
  7. </u-form-item>
  8. <u-form-item label-width="150" label="意向项目" prop="estate_name">
  9. <u-input type="select" :select-open="propertySelectShow" v-model="form.estate_name" inputAlign="right" placeholder="请选择推荐项目" @click="propertySelectShow = true"></u-input>
  10. </u-form-item>
  11. <u-form-item label-width="150" label="提醒时间" prop="cur_time" required>
  12. <u-input placeholder="请输入" v-model="form.cur_time" type="number" inputAlign="right"></u-input>
  13. <view style="color: #333" slot="right">天后提醒我</view>
  14. </u-form-item>
  15. <u-form-item label-width="150" label="备注信息" prop="record_remark" required label-position="top">
  16. <u-input :placeholder="remarkTips" v-model="form.record_remark" type="textarea"></u-input>
  17. </u-form-item>
  18. </u-form>
  19. <view class="scoped-more-img">
  20. <view class="si-op" v-for="(url, index) in imgArr" :key="index">
  21. <u-image :src="url" class="img" mode="heightFix" height="150rpx" @click="previewImageHandle(url)" ></u-image>
  22. <u-image src="/static/icon_g_close.png" class="i" height="40rpx" @click="delImg(index)"></u-image>
  23. </view>
  24. <view class="si-op" @click="addImg">
  25. <u-image src="/static/icon_upload_img.png" mode="heightFix" height="150rpx" class="img"></u-image>
  26. </view>
  27. </view>
  28. <u-gap height="60"></u-gap>
  29. <u-button type="primary" @click="submitHandle">提交</u-button>
  30. </view>
  31. <!-- utoast -->
  32. <u-toast ref="uToast" />
  33. <u-select mode="single-column" :list="groupTypeSelectList" v-model="groupTypeSelectShow" @confirm="groupTypeSelectConfirm"></u-select>
  34. <!-- modal -->
  35. <u-popup v-model="propertySelectShow" mode="center" width="90%" height="100%">
  36. <view class="bwin-popup scoped-estate-popup">
  37. <view class="scoped-popup-header-input">
  38. <u-input class="input" v-model="curEstateName" placeholder="没找到楼盘??点这输入关键字搜索"></u-input>
  39. <view class="b" @click="getEstateList">搜索</view>
  40. </view>
  41. <scroll-view :scroll-y="true" class="popup-body">
  42. <view class="scoped-estate-list">
  43. <view v-for="(item, index) in estateList" :class="form.estate_id == item.id ? 'sel-item cur' : 'sel-item'" @click="listItemHandle(item)" :key="index">
  44. <view class="sel-left">
  45. <image class="img" :src="item.pri_image" mode="aspectFill"></image>
  46. </view>
  47. <view class="sel-right">
  48. <view class="p1">{{item.estate_name}}</view>
  49. <view class="p2">
  50. <u-tag
  51. :text="areaTypeObj[item.area_type]"
  52. :type="'success'"
  53. size="mini"
  54. ></u-tag>
  55. </view>
  56. <view class="p3" v-if="userInfo2.auth_state == 1">带看需收集:{{ item.report_visit }}</view>
  57. <view class="p3" v-if="userInfo2.auth_state == 1">报备/带看保护期:{{ item.report_lock }}天/{{ item.lead_lock }}天</view>
  58. <!-- <view class="p3" v-if="userInfo2.auth_state == 1">预计奖励:{{ item.brokerage }}</view> -->
  59. </view>
  60. </view>
  61. </view>
  62. </scroll-view>
  63. <view class="popup-footer" style="position: fixed;bottom: 12rpx;">
  64. <u-button size="medium" @click="propertySelectShow = false">关闭</u-button>
  65. <u-button size="medium" type="primary" @click="propertySelectShow = false">确定</u-button>
  66. </view>
  67. </view>
  68. </u-popup>
  69. </view>
  70. </template>
  71. <script>
  72. import { arrToObj } from '@/utils'
  73. export default {
  74. data() {
  75. return {
  76. groupTypeSelectShow: false,
  77. groupTypeSelectList: [],
  78. estateList: [],
  79. areaTypeObj: {},
  80. userInfo2: {},
  81. curEstateName: '',
  82. propertySelectShow: false,
  83. imgArr: [],
  84. form: {
  85. estate_id: '',
  86. estate_name: '',
  87. cur_time: '',
  88. record_remark: null,
  89. },
  90. customer_id: null,
  91. rules: {
  92. record_remark: [
  93. {
  94. required: true,
  95. message: '备注不能为空',
  96. trigger: ['change']
  97. },
  98. ],
  99. cur_time: [
  100. { required: true, message: "提醒时间不能为空", trigger: ['blur', 'change'] }
  101. ],
  102. },
  103. remarkTips: '请输入',
  104. };
  105. },
  106. onLoad(data) {
  107. this.customer_id = data.id
  108. let userInfo2 = this.userInfo2 = uni.getStorageSync('MD_userInfo2')
  109. const dictObj = uni.getStorageSync('MD_dict')
  110. this.areaTypeObj = arrToObj(dictObj.area_type)
  111. this.getEstateList()
  112. this.form.group_type = userInfo2.group_type || '1'
  113. let list = dictObj.group_type || []
  114. let groupTypeSelectList = []
  115. list.forEach(item => {
  116. if (item.val == userInfo2.group_type) {
  117. this.form.groupTypeName = item.key
  118. }
  119. groupTypeSelectList.push({
  120. value: item.val,
  121. label: item.key,
  122. })
  123. })
  124. this.groupTypeSelectList = [...groupTypeSelectList]
  125. },
  126. created() {
  127. },
  128. // 必须要在onReady生命周期,因为onLoad生命周期组件可能尚未创建完毕
  129. onReady() {
  130. this.$refs.uForm.setRules(this.rules);
  131. },
  132. methods: {
  133. groupTypeSelectConfirm(e) {
  134. e.map((val, index) => {
  135. this.form.group_type = val.value;
  136. this.form.groupTypeName = val.label;
  137. });
  138. },
  139. getEstateList () {
  140. uni.api.estate.apiestatelist({page_size: 100, report_open: 1, estate_name: this.curEstateName}).then(res => {
  141. let list = res.list || []
  142. this.estateList = [...list]
  143. })
  144. },
  145. listItemHandle (val) {
  146. this.form.estate_id = val.estate_id;
  147. this.form.estate_name = val.estate_name;
  148. },
  149. addImg () {
  150. this.uploadComImg((arr) => {
  151. this.imgArr = [...this.imgArr, ...arr]
  152. this.imgArr = [...imgArr]
  153. }, 9)
  154. },
  155. uploadComImg (bc, count, moreStr) {
  156. const that = this
  157. uni.chooseImage({
  158. count: count ? count : 1, // 默认9
  159. sizeType: ['compressed'], // original
  160. sourceType: ['album', 'camera'],
  161. success: function (res) {
  162. const tempFilePaths = res.tempFilePaths
  163. if (tempFilePaths.length > 0) {
  164. let imgBcArr = []
  165. tempFilePaths.forEach((p, i) => {
  166. that.diyUploadFile(p, moreStr).then(url => {
  167. imgBcArr.push(url)
  168. if (bc && imgBcArr.length === tempFilePaths.length) {
  169. bc(imgBcArr)
  170. }
  171. })
  172. })
  173. }
  174. }
  175. })
  176. },
  177. diyUploadFile (filePath, moreStr) {
  178. return new Promise((resolve, reject) => {
  179. let token = uni.getStorageSync('MD_token')
  180. let url = uni.baseUrl + 'api/upload/cloud'
  181. // if (moreStr === 'noSign') url = uni.baseUrl + 'api/upload/cloud'
  182. uni.uploadFile({
  183. url,
  184. filePath,
  185. name: 'upload',
  186. formData: {
  187. 'token': token
  188. },
  189. success (res){
  190. const cData = JSON.parse(res.data)
  191. let curImg = cData.data.url || ''
  192. resolve(curImg)
  193. }
  194. })
  195. })
  196. },
  197. delImg (index) {
  198. let imgArr = [...this.imgArr]
  199. imgArr.splice(index, 1)
  200. this.imgArr = [...imgArr]
  201. },
  202. previewImageHandle (current, arr) {
  203. uni.previewImage({
  204. current,
  205. urls: this.imgArr
  206. })
  207. },
  208. submitHandle() {
  209. const that = this
  210. this.$refs.uForm.validate(valid => {
  211. console.log(valid)
  212. return
  213. if (valid) {
  214. // 验证成功
  215. let apiStr = 'apiprivaterecordadd'
  216. let params = {
  217. record_remark: that.form.record_remark,
  218. customer_id: that.customer_id
  219. }
  220. if (that.imgArr) params.record_img = that.imgArr.join(',')
  221. if (that.isEdit) {
  222. apiStr = 'apiprivaterecordedit'
  223. params.id = that.form.id
  224. }
  225. uni.api.cust[apiStr](params).then(res => {
  226. if (that.isEdit) {
  227. uni.$msgConfirm('编辑成功', () => {
  228. uni.reLaunch({
  229. url: '/pages/cust/my'
  230. })
  231. }, () => {
  232. uni.reLaunch({
  233. url: '/pages/cust/my'
  234. })
  235. })
  236. } else {
  237. uni.$msgConfirm('添加跟进记录成功,是否前往列表?', () => {
  238. uni.navigateBack()
  239. }, () => {
  240. this.form = {
  241. record_remark: null,
  242. }
  243. })
  244. }
  245. })
  246. } else {
  247. console.log('验证失败');
  248. }
  249. });
  250. },
  251. }
  252. };
  253. </script>
  254. <style lang="scss">
  255. .page {
  256. padding: 20rpx;
  257. background-color: #ffffff;
  258. }
  259. .form {
  260. border-radius: 10rpx;
  261. padding: 0 40rpx;
  262. }
  263. .popup-body {
  264. .tips-title {
  265. font-size: $u-p;
  266. margin-bottom: 20rpx;
  267. }
  268. .tips-content {
  269. font-size: $u-p2;
  270. color: $u-tips-color;
  271. margin-bottom: 60rpx;
  272. }
  273. }
  274. .id_card {
  275. color: #606266;
  276. width: 100%;
  277. height: 350rpx;
  278. display: flex;
  279. flex-direction: column;
  280. align-items: center;
  281. justify-content: center;
  282. background-color: #f4f5f6;
  283. font-size: $u-p2;
  284. }
  285. .footer {
  286. position: absolute;
  287. text-align: center;
  288. bottom: 40rpx;
  289. font-size: $u-p2;
  290. .agreement {
  291. color: $u-type-error;
  292. }
  293. }
  294. .slot-content {
  295. font-size: 28rpx;
  296. color: $u-content-color;
  297. padding: 20rpx;
  298. }
  299. .scoped-more-img {
  300. padding-top: 30rpx;
  301. .si-op {
  302. display: inline-block;
  303. vertical-align: middle;
  304. width: 150rpx;
  305. height: 150rpx;
  306. margin-right: 30rpx;
  307. margin-bottom: 30rpx;
  308. position: relative;
  309. border: 1PX solid #f2f2f2;
  310. .img {
  311. width: 150rpx;
  312. height: 150rpx;
  313. }
  314. .i {
  315. position: absolute;
  316. top: -20rpx;
  317. right: -20rpx;
  318. width: 40rpx;
  319. height: 40rpx;
  320. z-index: 9;
  321. }
  322. }
  323. }
  324. .scoped-estate-popup {
  325. height: 100%;
  326. padding-bottom: 100rpx;
  327. .popup-body {
  328. box-sizing: border-box;
  329. border-bottom: 1PX solid #dcdcdc;
  330. }
  331. }
  332. .scoped-estate-list {
  333. .sel-item {
  334. display: flex;
  335. border-bottom: 1PX solid #dcdcdc;
  336. padding: 20rpx;
  337. &.cur {
  338. background: #369af7;
  339. border-radius: 10rpx;
  340. overflow: hidden;
  341. .img {
  342. opacity: .6;
  343. }
  344. .p1 {
  345. color: #fff;
  346. }
  347. .p3 {
  348. color: #fff;
  349. }
  350. }
  351. }
  352. .sel-left {
  353. width: 180rpx;
  354. border-radius: 10rpx;
  355. .img {
  356. width: 180rpx;
  357. height: 120rpx;
  358. border-radius: 10rpx;
  359. }
  360. }
  361. .sel-right {
  362. // width: 450rpx;
  363. margin-left: 20rpx;
  364. .p1 {
  365. font-size: 30rpx;
  366. font-weight: bold;
  367. margin-bottom: 10rpx;
  368. }
  369. .p2 {
  370. margin-bottom: 10rpx;
  371. }
  372. .p3 {
  373. color: #369af7;
  374. font-size: 24rpx;
  375. font-weight: bold;
  376. }
  377. }
  378. }
  379. .scoped-popup-header-input {
  380. position: fixed;
  381. width: 90%;
  382. display: flex;
  383. border-bottom: 1PX solid #dcdcdc;
  384. .input {
  385. flex: 1;
  386. padding-left: 20rpx;
  387. height: 80rpx;
  388. .u-input__input {
  389. height: 80rpx;
  390. }
  391. }
  392. .b {
  393. width: 200rpx;
  394. height: 80rpx;
  395. line-height: 80rpx;
  396. background: #2d8cf0;
  397. color: #fff;
  398. text-align: center;
  399. margin-left: 20rpx;
  400. }
  401. }
  402. </style>