myrecordedit.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  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="recordEstateActionName">
  6. <u-input type="select" inputAlign="right" :select-open="actionSelectShow" v-model="form.recordEstateActionName" placeholder="请选择跟进方式" @click="actionSelectShow = 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="remind" required>
  12. <u-input placeholder="请输入" v-model="form.remind" 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="actionSelectShow" @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. actionSelectShow: 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. remind: '',
  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. remind: [
  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.action = userInfo2.record_estate_action || ''
  113. let list = dictObj.record_estate_action || []
  114. let groupTypeSelectList = []
  115. list.forEach(item => {
  116. if (item.val == userInfo2.record_estate_action) {
  117. this.form.recordEstateActionName = 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.action = val.value;
  136. this.form.recordEstateActionName = 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. let 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. if (valid) {
  212. // 验证成功
  213. let apiStr = 'apiprivaterecordadd'
  214. let params = {
  215. record_remark: that.form.record_remark,
  216. estate_id: that.form.estate_id,
  217. estate_name: that.form.estate_name,
  218. action: that.form.action,
  219. remind: that.form.remind,
  220. customer_id: that.customer_id
  221. }
  222. if (that.imgArr) params.record_img = that.imgArr.join(',')
  223. if (that.isEdit) {
  224. apiStr = 'apiprivaterecordedit'
  225. params.id = that.form.id
  226. }
  227. uni.api.cust[apiStr](params).then(res => {
  228. if (that.isEdit) {
  229. uni.$msgConfirm('编辑成功', () => {
  230. uni.reLaunch({
  231. url: '/pages/cust/my'
  232. })
  233. }, () => {
  234. uni.reLaunch({
  235. url: '/pages/cust/my'
  236. })
  237. })
  238. } else {
  239. uni.$msgConfirm('添加跟进记录成功,是否前往列表?', () => {
  240. uni.navigateBack()
  241. }, () => {
  242. that.imgArr = []
  243. that.form = {
  244. record_remark: null,
  245. }
  246. })
  247. }
  248. })
  249. } else {
  250. console.log('验证失败');
  251. }
  252. });
  253. },
  254. }
  255. };
  256. </script>
  257. <style lang="scss">
  258. .page {
  259. padding: 20rpx;
  260. background-color: #ffffff;
  261. }
  262. .form {
  263. border-radius: 10rpx;
  264. padding: 0 40rpx;
  265. }
  266. .popup-body {
  267. .tips-title {
  268. font-size: $u-p;
  269. margin-bottom: 20rpx;
  270. }
  271. .tips-content {
  272. font-size: $u-p2;
  273. color: $u-tips-color;
  274. margin-bottom: 60rpx;
  275. }
  276. }
  277. .id_card {
  278. color: #606266;
  279. width: 100%;
  280. height: 350rpx;
  281. display: flex;
  282. flex-direction: column;
  283. align-items: center;
  284. justify-content: center;
  285. background-color: #f4f5f6;
  286. font-size: $u-p2;
  287. }
  288. .footer {
  289. position: absolute;
  290. text-align: center;
  291. bottom: 40rpx;
  292. font-size: $u-p2;
  293. .agreement {
  294. color: $u-type-error;
  295. }
  296. }
  297. .slot-content {
  298. font-size: 28rpx;
  299. color: $u-content-color;
  300. padding: 20rpx;
  301. }
  302. .scoped-more-img {
  303. padding-top: 30rpx;
  304. .si-op {
  305. display: inline-block;
  306. vertical-align: middle;
  307. width: 150rpx;
  308. height: 150rpx;
  309. margin-right: 30rpx;
  310. margin-bottom: 30rpx;
  311. position: relative;
  312. border: 1PX solid #f2f2f2;
  313. .img {
  314. width: 150rpx;
  315. height: 150rpx;
  316. }
  317. .i {
  318. position: absolute;
  319. top: -20rpx;
  320. right: -20rpx;
  321. width: 40rpx;
  322. height: 40rpx;
  323. z-index: 9;
  324. }
  325. }
  326. }
  327. .scoped-estate-popup {
  328. height: 100%;
  329. padding-bottom: 100rpx;
  330. .popup-body {
  331. box-sizing: border-box;
  332. border-bottom: 1PX solid #dcdcdc;
  333. }
  334. }
  335. .scoped-estate-list {
  336. .sel-item {
  337. display: flex;
  338. border-bottom: 1PX solid #dcdcdc;
  339. padding: 20rpx;
  340. &.cur {
  341. background: #369af7;
  342. border-radius: 10rpx;
  343. overflow: hidden;
  344. .img {
  345. opacity: .6;
  346. }
  347. .p1 {
  348. color: #fff;
  349. }
  350. .p3 {
  351. color: #fff;
  352. }
  353. }
  354. }
  355. .sel-left {
  356. width: 180rpx;
  357. border-radius: 10rpx;
  358. .img {
  359. width: 180rpx;
  360. height: 120rpx;
  361. border-radius: 10rpx;
  362. }
  363. }
  364. .sel-right {
  365. // width: 450rpx;
  366. margin-left: 20rpx;
  367. .p1 {
  368. font-size: 30rpx;
  369. font-weight: bold;
  370. margin-bottom: 10rpx;
  371. }
  372. .p2 {
  373. margin-bottom: 10rpx;
  374. }
  375. .p3 {
  376. color: #369af7;
  377. font-size: 24rpx;
  378. font-weight: bold;
  379. }
  380. }
  381. }
  382. .scoped-popup-header-input {
  383. position: fixed;
  384. width: 90%;
  385. display: flex;
  386. border-bottom: 1PX solid #dcdcdc;
  387. .input {
  388. flex: 1;
  389. padding-left: 20rpx;
  390. height: 80rpx;
  391. .u-input__input {
  392. height: 80rpx;
  393. }
  394. }
  395. .b {
  396. width: 200rpx;
  397. height: 80rpx;
  398. line-height: 80rpx;
  399. background: #2d8cf0;
  400. color: #fff;
  401. text-align: center;
  402. margin-left: 20rpx;
  403. }
  404. }
  405. </style>