index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. <template>
  2. <view class="page-content expertsmodal">
  3. <view class="page-header expertsmodal-header">
  4. <u-tabs
  5. class="expertsmodal-tabs"
  6. name="cust_tabs_name"
  7. :list="tabsList"
  8. :current="currentTabs"
  9. height="80"
  10. item-width="256"
  11. gutter="50"
  12. bar-width="120"
  13. font-size="32"
  14. @change="handletabsChange"
  15. ></u-tabs>
  16. </view>
  17. <view class="page-main">
  18. <template v-if="currentTabs == 0">
  19. <view class="initiate-expertsmodal">
  20. <u-form
  21. :model="expertsModalForm"
  22. label-position="top"
  23. :label-style="custLabelStyle"
  24. ref="expertsModalFormRef"
  25. >
  26. <u-form-item
  27. label="真实姓名:"
  28. prop="matUser"
  29. :required="true"
  30. maxlength="20"
  31. class="initiate-formitem"
  32. >
  33. <u-input
  34. v-model="expertsModalForm.matUser"
  35. placeholder="请输入真实姓名"
  36. :placeholder-style="custPlaceholderStyle"
  37. />
  38. </u-form-item>
  39. <u-form-item label="手机号码:" prop="matPhone" :required="true" class="initiate-formitem">
  40. <u-input
  41. v-model="expertsModalForm.matPhone"
  42. placeholder="请输入手机号码"
  43. :placeholder-style="custPlaceholderStyle"
  44. />
  45. </u-form-item>
  46. <u-form-item
  47. label="咨询标题:"
  48. prop="matName"
  49. :required="true"
  50. maxlength="50"
  51. class="initiate-formitem"
  52. >
  53. <u-input
  54. v-model="expertsModalForm.matName"
  55. placeholder="请输入咨询标题"
  56. :placeholder-style="custPlaceholderStyle"
  57. />
  58. </u-form-item>
  59. <u-form-item
  60. label="咨询内容:"
  61. prop="matContent"
  62. :required="true"
  63. class="mt40 initiate-formitem"
  64. >
  65. <u-input
  66. v-model="expertsModalForm.matContent"
  67. type="textarea"
  68. maxlength="200"
  69. height="298"
  70. placeholder="请输入不少于10个字的描述"
  71. :placeholder-style="custPlaceholderStyle"
  72. @input="handleSumMatcontentNum"
  73. />
  74. <text class="formitem-summatcontentnum">{{ sumMatcontentNum }}/200</text>
  75. </u-form-item>
  76. </u-form>
  77. <view class="expertsmodalform-footer">
  78. <u-button
  79. type="primary"
  80. @click="handleExpertsModalformSubmit"
  81. class="complaint-submitbtn"
  82. >提交</u-button>
  83. </view>
  84. </view>
  85. </template>
  86. <template v-else-if="currentTabs == 1">
  87. <view class="history-expertsmodal">
  88. <scroll-view scroll-y="true" class="scroll-Y" @scrolltolower="handleScrolltolower">
  89. <view class="history-expertsmodal-listbody">
  90. <template v-if="hisExpertsModalObj.list_empty">
  91. <view class="history-expertsmodal-nodata">
  92. <text class="expertsmodal-nodata">暂无数据</text>
  93. </view>
  94. </template>
  95. <template>
  96. <u-row gutter="16" class="listbody-row">
  97. <u-col
  98. span="12"
  99. class="listbody-col"
  100. v-for="expertsModalItem in hisExpertsModalObj.expertsModalList"
  101. :key="expertsModalItem.plaId"
  102. @click="handleExpertsModalDetails(expertsModalItem)"
  103. >
  104. <view class="listbody-item">
  105. <view class="item-title">
  106. <text class="item-title-left">专家咨询</text>
  107. <text class="item-title-right">{{ expertsModalItem.plaInTime }}</text>
  108. </view>
  109. <view class="item-body">
  110. <text class="item-body-text">
  111. 真实姓名:{{ expertsModalItem.matUser }}
  112. <br />
  113. 手机号码:{{ expertsModalItem.matPhone ? expertsModalItem.matPhone.toString().replace(/^(.{3})(.*)(.{4})$/, '$1-$2-$3') : '' }}
  114. </text>
  115. <template v-if="expertsModalItem.matIsRe == 1">
  116. <text class="item-body-feedback">已反馈</text>
  117. </template>
  118. <template v-else>
  119. <text class="item-body-nofeedback">未反馈</text>
  120. </template>
  121. </view>
  122. </view>
  123. </u-col>
  124. </u-row>
  125. </template>
  126. <uni-load-more
  127. :status="hisExpertsModalObj.loadStatus"
  128. v-if="!hisExpertsModalObj.list_empty"
  129. ></uni-load-more>
  130. </view>
  131. </scroll-view>
  132. </view>
  133. </template>
  134. <template v-else></template>
  135. </view>
  136. </view>
  137. </template>
  138. <script>
  139. import {
  140. expertsModalAddData,
  141. expertsModalListData
  142. } from '@/agrcloud-api/expertsmodal';
  143. import uniLoadMore from "@/agrcloud-components/uni-load-more/uni-load-more"
  144. export default {
  145. name: 'expertsmodal',
  146. components: {
  147. uniLoadMore
  148. },
  149. data() {
  150. return {
  151. optionType: '',
  152. currentTabs: 0,
  153. tabsList: [{
  154. cust_tabs_name: '发起咨询'
  155. },
  156. {
  157. cust_tabs_name: '历史咨询'
  158. }
  159. ],
  160. expertsModalForm: {
  161. matUser: '',
  162. matPhone: '',
  163. matName: '',
  164. matContent: ''
  165. },
  166. expertsModalRules: {
  167. matUser: [{
  168. required: true,
  169. message: '请输入真实姓名',
  170. trigger: ['change', 'blur']
  171. }],
  172. matPhone: [{
  173. required: true,
  174. message: '请输入手机号码',
  175. trigger: ['change', 'blur']
  176. },
  177. {
  178. validator: (rule, value, callback) => {
  179. return this.$u.test.mobile(value);
  180. },
  181. message: '手机号码不正确',
  182. trigger: ['change', 'blur']
  183. }
  184. ],
  185. matName: [{
  186. required: true,
  187. message: '请输入咨询标题',
  188. trigger: ['change', 'blur']
  189. }],
  190. matContent: [{
  191. required: true,
  192. message: '请输入咨询内容',
  193. trigger: ['change', 'blur']
  194. },
  195. {
  196. min: 10,
  197. message: '咨询内容不少于10个字',
  198. trigger: ['change', 'blur']
  199. }
  200. ]
  201. },
  202. sumMatcontentNum: 0,
  203. custLabelStyle: {
  204. 'font-size': '30rpx',
  205. 'font-family': 'PingFangSC-Regular, PingFang SC',
  206. 'font-weight': '400',
  207. },
  208. custPlaceholderStyle: 'font-size: 34rpx;font-family: PingFangSC-Regular, PingFang SC;font-weight: 400;',
  209. hisExpertsModalObj: {
  210. loadStatus: 'more',
  211. list_empty: false,
  212. pageTotal: 0,
  213. pageCount: 0,
  214. pagination: {
  215. pageNum: 1,
  216. pageSize: 10
  217. },
  218. expertsModalList: []
  219. }
  220. };
  221. },
  222. onLoad(option) { },
  223. methods: {
  224. /** 切换页签 */
  225. handletabsChange(index) {
  226. if (index == 1) {
  227. if (!this.expertsModalForm.matUser) {
  228. this.currentTabs = 0;
  229. this.$msgbox('请输入真实姓名!', 'none');
  230. return;
  231. }
  232. if (!this.expertsModalForm.matPhone) {
  233. this.currentTabs = 0;
  234. this.$msgbox('请输入手机号码!', 'none');
  235. return;
  236. }
  237. this.hisExpertsModalObj.pagination.pageNum = 1;
  238. this.getExpertsModalListData();
  239. }
  240. this.currentTabs = index;
  241. },
  242. /** 获取历史咨询列表 */
  243. getExpertsModalListData() {
  244. this.hisExpertsModalObj = {
  245. ...this.hisExpertsModalObj,
  246. list_empty: false,
  247. loadStatus: 'loading',
  248. pageTotal: 0
  249. };
  250. // 请求获取列表数据
  251. expertsModalListData({
  252. ...this.hisExpertsModalObj.pagination,
  253. matUser: this.expertsModalForm.matUser,
  254. matPhone: this.expertsModalForm.matPhone
  255. }).then(res => {
  256. // 数据总条数
  257. this.hisExpertsModalObj.pageTotal = res.total || 0;
  258. // 如果列表为第一页,返回列表数据清空
  259. if (this.hisExpertsModalObj.pagination.pageNum == 1) {
  260. this.hisExpertsModalObj.expertsModalList = [];
  261. };
  262. // 处理返回结果
  263. if ((res.rows || []).length <= 0) { // 返回结果没有数据
  264. if ((this.hisExpertsModalObj.expertsModalList || []).length <= 0) {
  265. this.hisExpertsModalObj.loadStatus = 'noMores';
  266. this.hisExpertsModalObj.list_empty = true;
  267. } else {
  268. this.hisExpertsModalObj.loadStatus = 'noMores';
  269. }
  270. } else { //返回结果有数据
  271. //返回历史咨询列表存在
  272. this.hisExpertsModalObj.list_empty = false;
  273. // 获取列表数据分页数量
  274. this.hisExpertsModalObj.pageCount = Math.ceil((res.total || 0) / this.hisExpertsModalObj.pagination.pageSize);
  275. if ((res.total || 0) % this.hisExpertsModalObj.pagination.pageSize == 0) {
  276. this.hisExpertsModalObj.pageCount = Math.ceil((res.total || 0) / this.hisExpertsModalObj.pagination.pageSize);
  277. if (this.hisExpertsModalObj.pageCount == 1) {
  278. this.hisExpertsModalObj.pageCount--;
  279. }
  280. } else {
  281. this.hisExpertsModalObj.pageCount--;
  282. };
  283. // 处理页面状态
  284. if (this.hisExpertsModalObj.pageCount === 0) {
  285. this.hisExpertsModalObj.loadStatus = 'noMores'
  286. } else {
  287. this.hisExpertsModalObj.loadStatus = 'more'
  288. }
  289. // 组装返回数据
  290. this.hisExpertsModalObj.expertsModalList.push.apply(this.hisExpertsModalObj.expertsModalList, res.rows || []);
  291. uni.stopPullDownRefresh();
  292. }
  293. }).catch(err => {
  294. this.hisExpertsModalObj.loadStatus = 'noMores';
  295. });
  296. },
  297. handleExpertsModalformSubmit() {
  298. this.$refs.expertsModalFormRef && this.$refs.expertsModalFormRef.validate(valid => {
  299. if (valid) {
  300. expertsModalAddData(this.expertsModalForm).then(
  301. res => {
  302. this.$msgbox('操作成功!', 'success');
  303. this.expertsModalForm = {
  304. ...this.expertsModalForm,
  305. matName: '',
  306. matContent: ''
  307. };
  308. uni.navigateTo({
  309. url: '/pages/results/index'
  310. });
  311. }
  312. );
  313. }
  314. });
  315. },
  316. handleScrolltolower() {
  317. this.hisExpertsModalObj.loadStatus = 'loading'
  318. if (this.hisExpertsModalObj.pagination.pageNum - 1 >= this.hisExpertsModalObj.pageCount) {
  319. this.hisExpertsModalObj.loadStatus = 'noMores';
  320. return
  321. } else {
  322. this.hisExpertsModalObj.pagination.pageNum++;
  323. this.getExpertsModalListData();
  324. }
  325. },
  326. handleSumMatcontentNum() {
  327. this.sumMatcontentNum = this.expertsModalForm.matContent.length;
  328. if (this.sumMatcontentNum == 200) {
  329. this.$msgbox('最多只能输入240个字!', 'none');
  330. }
  331. },
  332. handleExpertsModalDetails(param) {
  333. this.$store.dispatch("SetExpertsDetails", param).then(() => {
  334. uni.navigateTo({
  335. url: '/pages/experts/modal/details'
  336. });
  337. }).catch(() => {
  338. this.$msgbox('访问数据异常!', 'none');
  339. });
  340. }
  341. },
  342. onReady() {
  343. this.$refs.expertsModalFormRef && this.$refs.expertsModalFormRef.setRules(this.expertsModalRules);
  344. }
  345. }
  346. </script>
  347. <style lang="scss" scoped>
  348. .expertsmodal {
  349. padding: 0;
  350. &-header {
  351. width: 100%;
  352. border-top: 2rpx solid #eeeeee;
  353. border-bottom: 2rpx solid #eeeeee;
  354. }
  355. .expertsmodal-tabs {
  356. height: 87rpx;
  357. display: flex;
  358. flex-direction: column;
  359. align-items: center;
  360. justify-content: center;
  361. }
  362. .initiate-expertsmodal {
  363. .initiate-formitem {
  364. padding-left: 24rpx;
  365. background: #ffffff;
  366. .formitem-summatcontentnum {
  367. position: absolute;
  368. bottom: 0;
  369. right: 0;
  370. }
  371. }
  372. }
  373. .expertsmodalform-footer {
  374. padding: 40rpx 32rpx;
  375. .complaint-submitbtn {
  376. height: 88rpx;
  377. }
  378. }
  379. .history-expertsmodal {
  380. .scroll-Y {
  381. height: calc(
  382. 100vh - 88rpx - 100rpx - env(safe-area-inset-bottom) -
  383. var(--status-bar-height)
  384. );
  385. }
  386. &-listbody {
  387. .history-expertsmodal-nodata {
  388. text-align: center;
  389. margin-top: 20rpx;
  390. .expertsmodal-nodata {
  391. font-size: 30rpx;
  392. color: #777777;
  393. }
  394. }
  395. .listbody-row {
  396. .listbody-col {
  397. padding: 24rpx 0 0 0 !important;
  398. .listbody-item {
  399. background: #ffffff;
  400. height: 196rpx;
  401. width: 100%;
  402. .item-title {
  403. padding-top: 24rpx;
  404. .item-title-left {
  405. float: left;
  406. height: 48rpx;
  407. font-size: 34rpx;
  408. font-family: PingFangSC-Medium, PingFang SC;
  409. font-weight: 500;
  410. color: #333333;
  411. line-height: 48rpx;
  412. padding-left: 24rpx;
  413. }
  414. .item-title-right {
  415. float: right;
  416. height: 48rpx;
  417. font-size: 30rpx;
  418. font-family: PingFangSC-Regular, PingFang SC;
  419. font-weight: 400;
  420. color: #999999;
  421. line-height: 48rpx;
  422. padding-right: 24rpx;
  423. }
  424. }
  425. .item-body {
  426. clear: both;
  427. padding: 16rpx 0 0 24rpx;
  428. .item-body-text {
  429. height: 84rpx;
  430. font-size: 30rpx;
  431. font-family: PingFangSC-Regular, PingFang SC;
  432. font-weight: 400;
  433. color: #666666;
  434. line-height: 42rpx;
  435. }
  436. .item-body-nofeedback {
  437. float: right;
  438. padding-right: 24rpx;
  439. height: 42rpx;
  440. font-size: 30rpx;
  441. font-family: PingFangSC-Medium, PingFang SC;
  442. font-weight: 500;
  443. color: #fd4779;
  444. line-height: 42rpx;
  445. }
  446. .item-body-feedback {
  447. float: right;
  448. padding-right: 24rpx;
  449. height: 42rpx;
  450. font-size: 30rpx;
  451. font-family: PingFangSC-Medium, PingFang SC;
  452. font-weight: 500;
  453. color: #48a79e;
  454. line-height: 42rpx;
  455. }
  456. }
  457. }
  458. }
  459. }
  460. }
  461. }
  462. }
  463. </style>