index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <view>
  3. <z-navbar title="处理咨询" back>
  4. <view slot="right" @click="submit">保存</view>
  5. </z-navbar>
  6. <w-picker mode="date" startYear="2000" endYear="2100" v-model="info.callbackDate" :current="true" fields="day"
  7. @confirm="onConfirm($event)" @cancel="onCancel" :disabled-after="false" ref="date"></w-picker>
  8. <z-card class="mt-30 ptb-10">
  9. <z-form :model="info" :rules="rules" ref="info">
  10. <z-form-item :bgcolor="switchAlert?'#eee':'white'" :labelStyle="{color:switchAlert?'#999':'#333'}" height="100rpx"
  11. label="客户姓名" prop="customName" showline dynamic :required="!switchAlert">
  12. <z-input v-model="info.customName" placeholder="点击填写" v-if="!switchAlert"></z-input>
  13. <z-text v-model="info.customName" textColor="#999" v-else placeholder=""></z-text>
  14. </z-form-item>
  15. <z-form-item :bgcolor="switchAlert?'#eee':'white'" :labelStyle="{color:switchAlert?'#999':'#333'}" height="100rpx"
  16. label="跟进状态" prop="followState" showline dynamic :required="!switchAlert">
  17. <follow-state v-model="info.followState" placeholder="请选择" v-if="!switchAlert" @change="changeFollowState"></follow-state>
  18. <z-text v-model="info.followStateText" textColor="#999" v-else placeholder=""></z-text>
  19. </z-form-item>
  20. <z-form-item :bgcolor="switchAlert?'#eee':'white'" :labelStyle="{color:switchAlert?'#999':'#333'}" height="100rpx"
  21. label="意向场地" prop="wantHouse" showline dynamic :required="!switchAlert">
  22. <want-house multiple title="选择意向场地" @checkedDetail="checkedWantHouseDetail" v-model="info.wantHouse" placeholder="选择意向场地"
  23. v-if="!switchAlert"></want-house>
  24. <z-text v-model="info.wantHouseText" textColor="#999" v-else placeholder=""></z-text>
  25. </z-form-item>
  26. <z-form-item :bgcolor="switchAlert?'#eee':'white'" :labelStyle="{color:switchAlert?'#999':'#333'}" height="100rpx"
  27. label="意向度" prop="wantLevelCode" showline dynamic :required="!switchAlert">
  28. <want-level v-model="info.wantLevelCode" placeholder="请选择意向度" v-if="!switchAlert" @change="changeWantLevelCode"></want-level>
  29. <z-text v-model="info.wantLevelCodeText" textColor="#999" v-else placeholder=""></z-text>
  30. </z-form-item>
  31. <z-form-item height="100rpx" label="关闭提醒" showline>
  32. <switch :checked="switchAlert" @change="changeSwitchAlert" />
  33. </z-form-item>
  34. <z-form-item height="100rpx" v-show="!switchAlert" label="下次提醒日期" dynamic prop="callbackDate" showline arrow
  35. :required="!switchAlert">
  36. <z-text v-model="info.callbackDate" placeholder="请选择下次提醒时间" @click="chooseDate"></z-text>
  37. </z-form-item>
  38. <z-form-item :bgcolor="switchAlert?'#eee':'white'" :labelStyle="{color:switchAlert?'#999':'#333'}" label="备注信息"
  39. prop="remark" labelPos="top" dynamic :required="!switchAlert">
  40. <textarea class="textarea" :disabled="switchAlert" v-model="info.remark" placeholder="请输入备注信息" maxlength="512"
  41. auto-height></textarea>
  42. </z-form-item>
  43. </z-form>
  44. </z-card>
  45. <u-toast ref="uToast"></u-toast>
  46. </view>
  47. </template>
  48. <script>
  49. import wantHouse from '../../component/wantHouse/wantHouse.vue';
  50. import followState from '../../component/followState/followState.vue';
  51. import wantLevel from '../../component/wantLevel/wantLevel.vue';
  52. export default {
  53. components: {
  54. wantHouse,
  55. followState,
  56. wantLevel
  57. },
  58. data() {
  59. var validateAlertDate = (rule, value, callback) => {
  60. if (new Date(this.info.callbackDate).getTime() > new Date(this.wantDate).getTime())
  61. return {
  62. state: false,
  63. message: '提醒日期不能大于意向日期' + this.wantDate
  64. };
  65. else if (new Date(this.info.callbackDate).getTime() < new Date(this.$Date.getDayDate().date).getTime()) {
  66. return {
  67. state: false,
  68. message: '设置的提醒日期不能小于当前日期'
  69. }
  70. } else
  71. return true;
  72. };
  73. return {
  74. info: {
  75. customName: '',
  76. followState: '',
  77. wantHouse: '',
  78. callbackDate: '',
  79. wantLevelCode: '',
  80. remark: ''
  81. },
  82. wantHouseDetail: [],
  83. rules: {
  84. customName: [{
  85. message: ''
  86. }],
  87. followState: [{
  88. message: ''
  89. }],
  90. wantHouse: [{
  91. message: ''
  92. }],
  93. wantLevelCode: [{
  94. message: ''
  95. }],
  96. callbackDate: [{
  97. validator: validateAlertDate
  98. }],
  99. remark: [{
  100. message: ''
  101. }]
  102. },
  103. id: '',
  104. switchAlert: false,
  105. callbackDate: '',
  106. wantDate: ''
  107. };
  108. },
  109. onLoad(option) {
  110. console.log(option)
  111. this.wantDate = option.wantDate;
  112. this.id = option.id;
  113. this.getData(option.id);
  114. },
  115. methods: {
  116. getData(id) {
  117. this.$axios.post('app/preUserAskRecord/askHandleById', {
  118. "userAskId": id
  119. }).then(res => {
  120. console.log(res.data)
  121. var info = res.data.list[0] || {}
  122. var wantHouse = [],
  123. wantHouse2 = [];
  124. for (var i = 0, len = info.wantHouse.length; i < len; i++) {
  125. if (info.wantHouse[i]) {
  126. wantHouse.push(info.wantHouse[i].houseId)
  127. wantHouse2.push({
  128. houseId: info.wantHouse[i].houseId,
  129. houseName: info.wantHouse[i].houseName
  130. })
  131. }
  132. }
  133. this.info = {
  134. customName: res.data.customName,
  135. followState: !info.followState||info.followState=='01' ? '02':info.followState,
  136. wantLevelCode: info.wantLevelCode ? info.wantLevelCode : '',
  137. callbackDate: info.callbackDate ? info.callbackDate : '',
  138. wantHouse: wantHouse,
  139. }
  140. console.log(this.info)
  141. this.callbackDate = info.callbackDate;
  142. this.wantHouseDetail = wantHouse2;
  143. }).catch(err => {
  144. this.$refs.uToast.error(err.msg);
  145. })
  146. },
  147. changeFollowState(data) {
  148. this.info.followStateText = data.dicName;
  149. },
  150. changeWantLevelCode(data) {
  151. this.info.wantLevelCodeText = data.dicName;
  152. },
  153. chooseDate() {
  154. this.$refs.date.show();
  155. },
  156. onConfirm(e) {
  157. console.log(e)
  158. this.$set(this.info, 'callbackDate', e.value)
  159. },
  160. onCancel() {
  161. console.log(this.$refs.date.value, this.$refs.date.pickVal)
  162. },
  163. changeSwitchAlert(e) {
  164. this.switchAlert = e.detail.value;
  165. if (this.switchAlert) {
  166. this.$set(this.info, 'callbackDate', '')
  167. } else {
  168. this.$set(this.info, 'callbackDate', this.callbackDate)
  169. }
  170. },
  171. checkedWantHouseDetail(data) {
  172. console.log(data)
  173. var wantHouse = [];
  174. var wantHouseText = '';
  175. for (var i = 0, len = data.length; i < len; i++) {
  176. wantHouse.push({
  177. houseId: data[i].id,
  178. houseName: data[i].houseName
  179. })
  180. wantHouseText += data[i].houseName + '、';
  181. }
  182. if (wantHouseText.length > 0) {
  183. wantHouseText = wantHouseText.substring(0, wantHouseText.length - 1);
  184. }
  185. console.log(wantHouse)
  186. this.wantHouseDetail = wantHouse;
  187. this.info.wantHouseText = wantHouseText;
  188. },
  189. submit() {
  190. console.log(this.info)
  191. this.$refs.info.validate(val => {
  192. console.log(val)
  193. if (val) {
  194. var info = this.info;
  195. this.$axios.post('app/preUserAskRecord/saveHandle', {
  196. storeId: uni.getStorageSync('storeId'), //this.$root.getStorage('storeId')
  197. userAskId: this.id,
  198. followState: this.switchAlert ? '' : info.followState, //后台未定义
  199. wantLevelCode: this.switchAlert ? '' : info.wantLevelCode,
  200. callbackDate: this.switchAlert ? '' : info.callbackDate,
  201. wantHouse: this.switchAlert ? [] : this.wantHouseDetail,
  202. remark: this.switchAlert ? '' : info.remark
  203. }).then(res => {
  204. // if(this.switchAlert){
  205. // uni.navigateTo({
  206. // delta: 2
  207. // })
  208. // }else{
  209. uni.navigateBack({
  210. delta: 1
  211. });
  212. // }
  213. }).catch(err => {
  214. this.$refs.uToast.error(err.msg);
  215. })
  216. } else {
  217. this.$refs.uToast.error('表单填写有误');
  218. }
  219. })
  220. var info = this.info;
  221. }
  222. }
  223. }
  224. </script>
  225. <style scoped lang="scss">
  226. .textarea {
  227. font-size: 28rpx;
  228. min-height: 180rpx;
  229. padding-bottom: 20rpx;
  230. width: 100%;
  231. }
  232. </style>