addVisit.vue 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004
  1. <template>
  2. <div class="addVisit">
  3. <m-header v-if="statusList.headerStatus" :name="name" />
  4. <van-cell-group>
  5. <van-field
  6. label="回访老师"
  7. v-model="teacherName"
  8. readonly
  9. input-align="right"
  10. placeholder="请选择"
  11. />
  12. </van-cell-group>
  13. <van-cell-group>
  14. <van-field
  15. label="学员姓名"
  16. @click="onCheckStudent"
  17. v-model="studentName"
  18. readonly
  19. input-align="right"
  20. :is-link="id || userId || studentId ? false : true"
  21. placeholder="请选择"
  22. >
  23. <template #right-icon>
  24. <a
  25. v-if="studentPhone"
  26. @click.stop="() => {}"
  27. class="phone_section"
  28. :href="'tel:' + studentPhone"
  29. ><img
  30. src="../../assets/images/icon_phone.png"
  31. class="iconPhone"
  32. alt=""
  33. /></a>
  34. </template>
  35. </van-field>
  36. <van-field
  37. label="回访类型"
  38. @click="onChange('type')"
  39. v-model="form.type"
  40. readonly
  41. input-align="right"
  42. :is-link="id || userId ? false : true"
  43. placeholder="请选择"
  44. />
  45. <van-field
  46. label="回访目的"
  47. @click="onChange('purpose')"
  48. v-model="form.purpose"
  49. readonly
  50. input-align="right"
  51. :is-link="id || userId ? false : true"
  52. placeholder="请选择"
  53. />
  54. <van-field
  55. v-if="form.type == '小课回访'"
  56. label="家长反馈"
  57. @click="onChange('feedbackType')"
  58. v-model="form.feedbackTypeName"
  59. readonly
  60. input-align="right"
  61. :is-link="id ? false : true"
  62. placeholder="请选择"
  63. />
  64. <van-field
  65. v-if="form.type == '小课回访'&&(form.feedbackType == 'THINKING' ||
  66. form.feedbackType == 'LOST')"
  67. label="反馈详情"
  68. @click="onChange('feedbackTypeDesc')"
  69. v-model="form.feedbackTypeDescName"
  70. readonly
  71. input-align="right"
  72. :is-link="id ? false : true"
  73. placeholder="请选择"
  74. />
  75. <van-field
  76. label="问题状态"
  77. @click="onChange('probStatus')"
  78. v-model="form.probStatusName"
  79. readonly
  80. input-align="right"
  81. :is-link="id ? false : true"
  82. placeholder="请选择"
  83. />
  84. </van-cell-group>
  85. <van-cell-group>
  86. <div class="dot"></div>
  87. <van-field
  88. label="当前学生情况"
  89. class="textarea"
  90. :readonly="id ? true : false"
  91. v-model="form.overview"
  92. rows="2"
  93. autosize
  94. type="textarea"
  95. maxlength="50"
  96. placeholder="请输入留言"
  97. :show-word-limit="id ? false : true"
  98. />
  99. </van-cell-group>
  100. <van-cell-group>
  101. <div class="dot"></div>
  102. <van-field
  103. label="沟通后家长反馈"
  104. class="textarea"
  105. :readonly="id ? true : false"
  106. v-model="form.feedback"
  107. rows="2"
  108. autosize
  109. type="textarea"
  110. maxlength="50"
  111. placeholder="请输入留言"
  112. :show-word-limit="id ? false : true"
  113. />
  114. </van-cell-group>
  115. <van-cell-group>
  116. <van-field
  117. label="回访时间"
  118. class="visiTimer"
  119. v-model="form.visitTime"
  120. readonly
  121. @click="onEnListShow"
  122. input-align="right"
  123. :is-link="id ? false : true"
  124. placeholder="请选择"
  125. />
  126. </van-cell-group>
  127. <van-cell-group v-if="id&&uploader[0]&&uploader[0].url || !id">
  128. <div class="visiWrap">
  129. <p>回访图片</p>
  130. <!-- :before-delete="beforDelete" -->
  131. <van-uploader
  132. v-model="uploader"
  133. :before-read="beforeRead"
  134. :after-read="afterRead"
  135. :disabled="id ? true : false"
  136. :deletable="!id ? true : false"
  137. accept="image/*"
  138. multiple
  139. :max-count="5"
  140. />
  141. <p class="submit" v-if="!id">上传文件大小不能超过5MB且最多上传五张</p>
  142. </div>
  143. </van-cell-group>
  144. <div class="button-group" v-if="!id">
  145. <van-button type="primary" @click="onSubmit" round size="large"
  146. >确认</van-button
  147. >
  148. </div>
  149. <van-action-sheet
  150. v-model="visit.status"
  151. :actions="visit.data"
  152. cancel-text="取消"
  153. @cancel="visit.status = false"
  154. @select="onModeSelect"
  155. />
  156. <van-popup v-model="dataForm.status" position="bottom">
  157. <van-datetime-picker
  158. v-model="dataForm.currentDate"
  159. type="date"
  160. :min-date="dataForm.minDate"
  161. :max-date="dataForm.maxDate"
  162. :formatter="formatter"
  163. @cancel="dataForm.status = false"
  164. @confirm="onCurrentConfirm"
  165. />
  166. </van-popup>
  167. <!-- 选择上课学生 -->
  168. <van-popup
  169. v-model="statusList.studentStatus"
  170. :lock-scroll="true"
  171. position="bottom"
  172. :style="{ height: '180%' }"
  173. >
  174. <van-sticky>
  175. <van-search
  176. show-action
  177. shape="round"
  178. :left-icon="searchIcon"
  179. @search="onSearch"
  180. v-model="params.search"
  181. placeholder="请输入学生名或手机号"
  182. >
  183. <template #action>
  184. <div @click="onSearch">搜索</div>
  185. </template>
  186. </van-search>
  187. </van-sticky>
  188. <div class="paddingB80">
  189. <van-list
  190. v-model="loading"
  191. class="studentContainer"
  192. v-if="dataShow"
  193. key="data"
  194. :finished="finished"
  195. finished-text=""
  196. @load="getStudent"
  197. >
  198. <van-radio-group v-model="radioSelect">
  199. <van-cell-group>
  200. <van-cell
  201. v-for="(item, index) in dataList"
  202. :key="index"
  203. @click="onCheckboxSelect(item)"
  204. class="input-cell"
  205. :center="true"
  206. >
  207. <template slot="icon">
  208. <img
  209. class="logo"
  210. v-if="item.avatar"
  211. :src="item.avatar"
  212. alt=""
  213. />
  214. <img
  215. class="logo"
  216. v-else
  217. src="@/assets/images/icon_student.png"
  218. alt=""
  219. />
  220. </template>
  221. <template slot="title">
  222. <div class="studentName">
  223. {{ item.userName }}
  224. </div>
  225. </template>
  226. <template slot="label">
  227. <span>{{ desensitPhone(item.phone) }}</span>
  228. </template>
  229. <template slot="default">
  230. <van-radio :name="item.userId"></van-radio>
  231. </template>
  232. </van-cell>
  233. </van-cell-group>
  234. </van-radio-group>
  235. </van-list>
  236. <m-empty class="empty" v-else key="data" />
  237. </div>
  238. <div class="button-group-popup">
  239. <span class="btn" @click="onPopupCancel">取消</span>
  240. <span class="btn primary" @click="onPopupSubmit">确认选择</span>
  241. </div>
  242. </van-popup>
  243. </div>
  244. </template>
  245. <script>
  246. import MHeader from "@/components/MHeader";
  247. import { browser } from "@/common/common";
  248. import MEmpty from "@/components/MEmpty";
  249. import dayjs from "dayjs";
  250. import {
  251. queryStudentsWithTeacher,
  252. visitAdd,
  253. visitGetInfo,
  254. queryUserById,
  255. } from "@/api/teacher";
  256. import { queryUserInfo } from "@/api/app";
  257. import { policy } from "@/views/massMessage/api";
  258. import setLoading from "@/utils/loading";
  259. import axios from "axios";
  260. export default {
  261. name: "addVisit",
  262. components: {
  263. MHeader,
  264. MEmpty,
  265. },
  266. data() {
  267. const query = this.$route.query;
  268. return {
  269. id: query.id,
  270. name: query.name,
  271. userId: query.userId, // 如果有userId的时候说明是从评测详情进来的
  272. studentId: query.studentId, // 这个参数是从原生传过来的,单独做了处理
  273. beforeId: query.beforeId, // 如果有beforeId的时候说明是从待回访列表进来的
  274. inside: query.inside || 0,
  275. visitFlag: Number(query.visitFlag) || 0,
  276. uploader: [],
  277. dataForm: {
  278. // 时间下拉框
  279. status: false,
  280. minDate: new Date(2000, 0, 1),
  281. maxDate: new Date(),
  282. currentDate: new Date(),
  283. },
  284. statusList: {
  285. // 散状态集合
  286. headerStatus: true, // 头部是否展示
  287. studentStatus: false, // 上课学生状态
  288. },
  289. typeList: [
  290. { name: "课程推荐" },
  291. { name: "常规回访" },
  292. { name: "小课回访" },
  293. { name: "云教练" },
  294. { name: "其它" },
  295. ],
  296. visit: {
  297. status: false,
  298. type: null,
  299. data: [],
  300. },
  301. studentName: query.username || null,
  302. studentPhone: query.phone || null,
  303. teacherName: null,
  304. form: {
  305. teacherId: null,
  306. studentId: query.userId || query.studentId || query.beforeId || null,
  307. type: query.userId ? "云教练" : query.beforeId ? "常规回访" : null,
  308. purpose: query.userId
  309. ? "体验回访"
  310. : query.beforeId
  311. ? "教学内容未达标"
  312. : null,
  313. overview: "",
  314. feedback: "",
  315. visitTime:
  316. query.userId || query.id || query.beforeId
  317. ? dayjs().format("YYYY年MM月DD日")
  318. : null,
  319. visiterType: "TEACHER",
  320. feedbackTypeDesc: "",
  321. feedbackType: "",
  322. probStatus: "",
  323. },
  324. loading: false,
  325. finished: false,
  326. params: {
  327. search: null,
  328. page: 1,
  329. rows: 20,
  330. },
  331. dataShow: true, // 是否有数据
  332. radioSelect: null,
  333. radioSelectName: null,
  334. radioSelectPhone: null,
  335. clickStatus: false,
  336. dataList: [],
  337. searchIcon: require("@/assets/images/search.png"),
  338. ossUploadUrl: "https://ks3-cn-beijing.ksyuncs.com/daya",
  339. dataObj: {
  340. policy: "",
  341. signature: "",
  342. key: "",
  343. KSSAccessKeyId: "",
  344. acl: "public-read",
  345. name: "",
  346. },
  347. feedbackTypeList: [
  348. { name: "考虑中", value: "THINKING" },
  349. { name: "确认缴费待缴费", value: "PENDING_PAYMENT" },
  350. { name: "回访流失", value: "LOST" },
  351. { name: "暂停", value: "PAUSE" },
  352. { name: "其他", value: "OTHER" },
  353. { name: "在读", value: "NORMAL" },
  354. ],
  355. feedbackTypeDescList: [
  356. { name: "价格原因", value: "PRICE" },
  357. { name: "时间原因", value: "TIME" },
  358. { name: "教学不满意", value: "THINKING" },
  359. { name: "其他", value: "OTHER" },
  360. ],
  361. probStatusList: [
  362. { name: "已解决", value: 1 },
  363. { name: "待跟进", value: 0 },
  364. ],
  365. };
  366. },
  367. mounted() {
  368. let params = this.$route.query;
  369. if (params.Authorization) {
  370. localStorage.setItem("Authorization", decodeURI(params.Authorization));
  371. localStorage.setItem("userInfo", decodeURI(params.Authorization));
  372. }
  373. if (browser().android || browser().iPhone) {
  374. this.statusList.headerStatus = false;
  375. }
  376. document.title = this.name || "新增回访记录";
  377. this.__init();
  378. },
  379. methods: {
  380. async __init() {
  381. let res = await queryUserInfo();
  382. let result = res.data;
  383. if (res.status == 200) {
  384. this.teacherName = result.realName;
  385. this.form.teacherId = result.id;
  386. } else {
  387. this.$toast(res.msg);
  388. }
  389. if (this.id) {
  390. setLoading(true);
  391. let queryInfo = await visitGetInfo({ id: this.id });
  392. const queryResult = queryInfo.data;
  393. let form = this.form;
  394. setLoading(false);
  395. if (queryResult.code == 200) {
  396. let tempData = queryResult.data;
  397. this.studentName = tempData.studentName;
  398. form.studentId = tempData.studentId;
  399. form.type = tempData.type;
  400. form.purpose = tempData.purpose;
  401. form.overview = tempData.overview;
  402. form.feedback = tempData.feedback;
  403. form.visitTime = dayjs(tempData.visitTime).format("YYYY年MM月DD日");
  404. form.visiterType = tempData.visiterType;
  405. form.feedbackType = tempData.feedbackType;
  406. form.feedbackTypeDesc = tempData.feedbackTypeDesc;
  407. form.probStatus = tempData.probStatus;
  408. if(form.feedbackType){
  409. form.feedbackTypeName = ''
  410. this.feedbackTypeList.forEach(item=>{
  411. if(item.value == form.feedbackType){
  412. form.feedbackTypeName = item.name
  413. }
  414. })
  415. }
  416. if(form.feedbackTypeDesc){
  417. form.feedbackTypeDescName = ''
  418. this.feedbackTypeDescList.forEach(item=>{
  419. if(item.value == form.feedbackType){
  420. form.feedbackTypeDescName = item.name
  421. }
  422. })
  423. }
  424. if( form.probStatus){
  425. form.probStatusName = '已解决';
  426. }else{
  427. form.probStatusName = '待跟进';
  428. }
  429. /**
  430. * form.feedbackTypeDescName = null;
  431. form.feedbackTypeDesc = null;
  432. form.probStatus = null;
  433. form.probStatusName = null;
  434. form.feedbackTypeDescName = null;
  435. form.feedbackTypeDesc = null;
  436. */
  437. form.probStatus = tempData.probStatus
  438. let attrList = tempData.attachments.split(",");
  439. this.uploader = attrList.map((item) => {
  440. return { url: item };
  441. });
  442. // console.log(this.uploader);
  443. } else {
  444. this.$toast(res.msg);
  445. }
  446. }
  447. let userId = this.userId || this.studentId || this.beforeId;
  448. if (userId) {
  449. await queryUserById({ userId }).then((res) => {
  450. let result = res.data;
  451. this.studentPhone = result.phone;
  452. this.studentName = result.username;
  453. });
  454. }
  455. },
  456. async onSubmit() {
  457. let form = this.form;
  458. if (!form.studentId) {
  459. this.$toast("请选择学员");
  460. return;
  461. } else if (!form.type) {
  462. this.$toast("请选择回访类型");
  463. return;
  464. } else if (!form.purpose) {
  465. this.$toast("请选择回访目的");
  466. return;
  467. } else if (!form.overview) {
  468. this.$toast("请输入当前学生情况");
  469. return;
  470. } else if (!form.feedback ) {
  471. this.$toast("请输入沟通后家长反馈");
  472. return;
  473. } else if (!form.visitTime) {
  474. this.$toast("请选择回访时间");
  475. return;
  476. } else if (!form.feedbackTypeDesc && form.type == "小课回访") {
  477. this.$toast("请选择反馈详情");
  478. return;
  479. } else if (!form.feedbackType && form.type == "小课回访") {
  480. this.$toast("请选择家长反馈");
  481. return;
  482. } else if (!(form.probStatus+'')) {
  483. this.$toast("请选择问题状态");
  484. return;
  485. }
  486. if (this.clickStatus) {
  487. return;
  488. }
  489. this.clickStatus = true;
  490. setLoading(true);
  491. // let visitTime = this.form.visitTime.replace(/[^\d]/g,'/');
  492. // let someDate = new Date(visitTime)
  493. let visitTime = dayjs(this.dataForm.currentDate).format("YYYY-MM-DD");
  494. let attachmentsList = this.uploader.map((item) => {
  495. return item.url;
  496. });
  497. let params = {
  498. ...form,
  499. visitTime,
  500. attachments: attachmentsList.join(","),
  501. };
  502. // 待回访时要传的参数
  503. if (this.beforeId) {
  504. params.objectId = this.$route.query.objectId;
  505. }
  506. let res = await visitAdd({ ...params });
  507. let result = res.data;
  508. setLoading(false);
  509. if (result.code == 200) {
  510. this.$toast("添加成功");
  511. setTimeout(() => {
  512. if (this.inside) {
  513. this.onAppBack();
  514. } else if (this.userId) {
  515. let { visitFlag, ...query } = this.$route.query;
  516. visitFlag = 0;
  517. this.$router.replace({
  518. path: "/trainDetail",
  519. query: {
  520. ...query,
  521. visitFlag,
  522. },
  523. });
  524. } else if (this.beforeId) {
  525. let { ...query } = this.$route.query;
  526. this.$router.replace({
  527. path: "/visitList",
  528. query: {
  529. userId: this.beforeId,
  530. ...query,
  531. },
  532. });
  533. } else {
  534. this.$router.replace("visitList");
  535. }
  536. }, 800);
  537. } else {
  538. this.$toast(result.msg);
  539. this.clickStatus = false;
  540. return;
  541. }
  542. },
  543. onAppBack() {
  544. if (browser().android) {
  545. DAYA.postMessage(JSON.stringify({ api: "back" }));
  546. } else if (browser().iPhone) {
  547. window.webkit.messageHandlers.DAYA.postMessage(
  548. JSON.stringify({ api: "back" })
  549. );
  550. }
  551. },
  552. onCheckStudent() {
  553. if (this.id || this.userId || this.studentId || this.beforeId) {
  554. return;
  555. }
  556. this.statusList.studentStatus = true;
  557. },
  558. onChange(type) {
  559. if (this.id || this.userId || this.beforeId) {
  560. return;
  561. }
  562. let visit = this.visit;
  563. let form = this.form;
  564. if (type == "type") {
  565. visit.data = this.typeList;
  566. } else if (type == "purpose") {
  567. if (form.type == "其它") {
  568. visit.data = [{ name: "其它" }, { name: "会员续费" }];
  569. } else if (form.type == "课程推荐") {
  570. visit.data = [{ name: "新课推荐" }, { name: "续费提醒" }];
  571. } else if (form.type == "常规回访") {
  572. visit.data = [
  573. { name: "课后及作业回访" },
  574. { name: "练习及乐团表现" },
  575. { name: "考勤申诉" },
  576. { name: "异常请假回访" },
  577. ];
  578. } else if (form.type == "小课回访") {
  579. visit.data = [
  580. { name: "VIP课回访" },
  581. { name: "乐理课回访" },
  582. { name: "网管课回访" },
  583. ];
  584. } else if (form.type == "云教练") {
  585. visit.data = [{ name: "体验回访" }];
  586. } else {
  587. this.$toast("请选择回访类型");
  588. return;
  589. }
  590. } else if (type == "feedbackType") {
  591. visit.data = this.feedbackTypeList;
  592. } else if (type == "feedbackTypeDesc") {
  593. visit.data = this.feedbackTypeDescList;
  594. } else if (type == "probStatus") {
  595. visit.data = this.probStatusList;
  596. }
  597. visit.status = true;
  598. visit.type = type;
  599. },
  600. onSearch() {
  601. this.params.page = 1;
  602. this.dataList = [];
  603. this.dataShow = true;
  604. this.loading = true;
  605. this.finished = false;
  606. this.getStudent();
  607. },
  608. onCheckboxSelect(item) {
  609. this.radioSelect = item.userId;
  610. this.radioSelectName = item.userName;
  611. this.radioSelectPhone = item.phone;
  612. },
  613. onPopupCancel() {
  614. this.statusList.studentStatus = false;
  615. },
  616. onPopupSubmit() {
  617. this.form.studentId = this.radioSelect;
  618. this.studentName = this.radioSelectName;
  619. this.studentPhone = this.radioSelectPhone;
  620. this.statusList.studentStatus = false;
  621. },
  622. onCurrentConfirm(value) {
  623. if (value) {
  624. this.form.visitTime = dayjs(value).format("YYYY年MM月DD日");
  625. }
  626. this.dataForm.status = false;
  627. },
  628. onEnListShow() {
  629. // 从云教练统计来的,不许改时间,默认当前时间
  630. if (this.id || this.visitFlag) {
  631. return;
  632. }
  633. this.dataForm.status = true;
  634. },
  635. getStudent() {
  636. let params = this.params;
  637. queryStudentsWithTeacher(params).then((res) => {
  638. let result = res.data;
  639. this.loading = false;
  640. if (result.code == 200 && result.data) {
  641. params.page = result.data.pageNo;
  642. this.dataList = this.dataList.concat(result.data.rows);
  643. if (params.page >= result.data.totalPage) {
  644. this.finished = true;
  645. }
  646. this.params.page++;
  647. } else {
  648. this.finished = true;
  649. }
  650. // 判断是否有数据
  651. if (this.dataList.length <= 0) {
  652. this.dataShow = false;
  653. }
  654. });
  655. },
  656. onModeSelect(value) {
  657. let visit = this.visit;
  658. let form = this.form;
  659. if (visit.type == "type") {
  660. form.type = value.name;
  661. form.purpose = null;
  662. form.feedbackTypeDescName = null;
  663. form.feedbackTypeDesc = null;
  664. form.probStatus = null;
  665. form.probStatusName = null;
  666. form.feedbackTypeDescName = null;
  667. form.feedbackTypeDesc = null;
  668. } else if (visit.type == "purpose") {
  669. form.purpose = value.name;
  670. } else if (visit.type == "feedbackType") {
  671. form.feedbackType = value.value;
  672. form.feedbackTypeName = value.name;
  673. } else if (visit.type == "feedbackTypeDesc") {
  674. form.feedbackTypeDescName = value.name;
  675. form.feedbackTypeDesc = value.value;
  676. } else if (visit.type == "probStatus") {
  677. form.probStatus = value.value;
  678. form.probStatusName = value.name;
  679. }
  680. visit.status = false;
  681. },
  682. formatter(type, value) {
  683. if (type === "year") {
  684. return `${value}年`;
  685. } else if (type === "month") {
  686. return `${value}月`;
  687. } else if (type === "day") {
  688. return `${value}日`;
  689. }
  690. return value;
  691. },
  692. desensitPhone(phone) {
  693. // 手机号脱敏
  694. let first = phone.substr(0, 3);
  695. let last = phone.substr(-4);
  696. return first + "****" + last;
  697. },
  698. beforeRead(file) {
  699. if (file.length) {
  700. file.map((item) => {
  701. const isLt2M = item.size / 1000 / 1000 < 5;
  702. if (!isLt2M) {
  703. this.$toast("上传文件大小不能超过 5MB");
  704. return false;
  705. }
  706. });
  707. } else {
  708. const isLt2M = file.size / 1000 / 1000 < 5;
  709. if (!isLt2M) {
  710. this.$toast("上传文件大小不能超过 5MB");
  711. return false;
  712. }
  713. }
  714. return true;
  715. },
  716. async uploadFile(file) {
  717. // console.log("uploadFile", file);
  718. try {
  719. file.status = "uploading";
  720. file.message = "上传中...";
  721. let tempName = file.file.name || "";
  722. const fileName = tempName && tempName.replace(/ /gi, "_");
  723. let key = new Date().getTime() + fileName;
  724. let objTemp = {
  725. filename: fileName,
  726. bucketName: this.bucket_name,
  727. postData: {
  728. filename: fileName,
  729. acl: "public-read",
  730. key: key,
  731. unknowValueField: [],
  732. },
  733. };
  734. const res = await policy(objTemp);
  735. const obj = {
  736. policy: res.data.policy,
  737. signature: res.data.signature,
  738. key: key,
  739. KSSAccessKeyId: res.data.kssAccessKeyId,
  740. acl: "public-read",
  741. name: fileName,
  742. };
  743. let formData = new FormData();
  744. for (let key in obj) {
  745. formData.append(key, obj[key]);
  746. }
  747. formData.append("file", file.file);
  748. // console.log(formData);
  749. await axios({
  750. method: "post",
  751. url: this.ossUploadUrl,
  752. data: formData,
  753. });
  754. const uploadUrl = this.ossUploadUrl + "/" + key;
  755. file.url = uploadUrl;
  756. file.status = "done";
  757. } catch (e) {
  758. console.log(e);
  759. file.status = "failed";
  760. file.message = "上传失败";
  761. this.uploader = [];
  762. }
  763. },
  764. async afterRead(file) {
  765. // 上传头像
  766. const form = this.form;
  767. try {
  768. if (file && file.length) {
  769. file.forEach((item) => {
  770. this.uploadFile(item);
  771. });
  772. } else {
  773. this.uploadFile(file);
  774. }
  775. } catch (e) {
  776. console.log(e);
  777. return false;
  778. }
  779. // this.$toast.loading({
  780. // duration: 0,
  781. // forbidClick: true,
  782. // message: "上传中...",
  783. // });
  784. //
  785. // try {
  786. // file.status = "uploading";
  787. // file.message = "上传中...";
  788. // let formData = new FormData();
  789. // formData.append("file", file.file);
  790. // let res = await uploadFile(formData);
  791. // this.$toast.clear();
  792. // let result = res.data;
  793. // if (result.code == 200) {
  794. // file.status = "done";
  795. // form.fileName = file.file.name;
  796. // form.fileUrl = result.data.url;
  797. // form.messageType = this.onCheckFileType(file.file.type);
  798. // } else {
  799. // file.status = "failed";
  800. // file.message = "上传失败";
  801. // this.$toast(result.msg);
  802. // form.fileName = "";
  803. // form.fileUrl = "";
  804. // return false;
  805. // }
  806. // } catch (err) {
  807. // this.$toast.clear();
  808. // file.status = "failed";
  809. // file.message = "上传失败";
  810. // form.fileName = "";
  811. // form.fileUrl = "";
  812. // return false;
  813. // }
  814. },
  815. },
  816. };
  817. </script>
  818. <style lang='less' scoped>
  819. @import url("../../assets/commonLess/variable.less");
  820. /deep/.van-popup--bottom {
  821. border-radius: 0px 0px 0px 0px !important;
  822. overflow: auto !important;
  823. }
  824. .addVisit {
  825. min-height: 100vh;
  826. }
  827. .vip-title {
  828. padding: 0.06rem 0.14rem 0.04rem;
  829. font-size: 0.14rem;
  830. color: #808080;
  831. }
  832. /deep/.van-cell-group {
  833. margin-bottom: 0.1rem;
  834. }
  835. /deep/.van-cell {
  836. display: flex;
  837. align-items: center;
  838. font-size: 0.16rem;
  839. line-height: 0.28rem;
  840. }
  841. /deep/.van-field__label,
  842. /deep/.van-cell__value {
  843. flex: 1 auto;
  844. }
  845. /deep/.van-field__word-limit {
  846. margin-top: 0px;
  847. position: absolute;
  848. top: -0.2rem;
  849. right: 5px;
  850. font-size: 0.14rem;
  851. }
  852. /deep/.van-field__control:disabled {
  853. color: #6a6969;
  854. }
  855. .textarea {
  856. display: flex;
  857. flex-direction: column;
  858. align-items: inherit;
  859. padding: 0.1rem 0.21rem;
  860. /deep/.van-field__label {
  861. width: 100%;
  862. }
  863. // /deep/.van-field__value {
  864. // border: 1px solid #ccc;
  865. // }
  866. }
  867. .button-group {
  868. margin: 0.3rem 0.26rem 0.2rem;
  869. .van-button--primary {
  870. background: @mColor;
  871. border: 1px solid @mColor;
  872. font-size: 0.18rem;
  873. height: 0.5rem;
  874. }
  875. }
  876. .studentContainer {
  877. /deep/.van-cell__title {
  878. font-size: 0.14rem;
  879. color: @mFontColor;
  880. // flex: 1 auto;
  881. }
  882. .logo {
  883. width: 0.42rem;
  884. height: 0.42rem;
  885. margin-right: 0.12rem;
  886. border-radius: 100%;
  887. }
  888. .input-cell {
  889. padding: 0.2rem 0.16rem;
  890. .van-radio {
  891. justify-content: flex-end;
  892. }
  893. }
  894. /deep/.van-cell__value {
  895. height: 0.2rem;
  896. }
  897. /deep/.van-radio__icon .van-icon {
  898. border-color: #d3d3d3;
  899. }
  900. /deep/.van-radio__icon--checked {
  901. .van-icon {
  902. border-color: @mColor;
  903. background: @mColor;
  904. }
  905. }
  906. .van-tag {
  907. margin-left: 0.08rem;
  908. }
  909. }
  910. /deep/.van-field__right-icon,
  911. .phone_section {
  912. display: flex;
  913. }
  914. .iconPhone {
  915. width: 0.17rem;
  916. height: 0.21rem;
  917. }
  918. .paddingB80 {
  919. padding-bottom: 0.8rem;
  920. }
  921. .button-group-popup {
  922. position: fixed;
  923. bottom: 0;
  924. padding: 0.2rem 0;
  925. width: 100%;
  926. text-align: center;
  927. background-color: #ffffff;
  928. .btn {
  929. line-height: 0.5rem;
  930. display: inline-block;
  931. border: 1px solid @mColor;
  932. width: 1.65rem;
  933. border-radius: 0.4rem;
  934. color: @mColor;
  935. background: #fff;
  936. font-size: 0.18rem;
  937. &.primary {
  938. color: #fff;
  939. background: @mColor;
  940. }
  941. }
  942. .btn + .btn {
  943. margin-left: 0.1rem;
  944. }
  945. }
  946. .studentColor {
  947. color: @mColor;
  948. }
  949. .visiTimer {
  950. /deep/.van-field__control {
  951. color: #333333 !important;
  952. font-size: 0.16rem;
  953. }
  954. }
  955. .studentName {
  956. font-size: 0.16rem;
  957. color: #1a1a1a;
  958. line-height: 0.22rem;
  959. }
  960. .dot {
  961. width: 4px;
  962. height: 0.17rem;
  963. background: #01c1b5;
  964. border-radius: 3px;
  965. position: absolute;
  966. z-index: 200;
  967. top: 0.14rem;
  968. left: 0.12rem;
  969. }
  970. .van-icon-search {
  971. color: @mColor;
  972. }
  973. .visiWrap {
  974. padding: 10px 16px;
  975. p {
  976. font-size: 0.16rem;
  977. line-height: 0.28rem;
  978. color: #646566;
  979. margin-bottom: 0.1rem;
  980. }
  981. .submit {
  982. color: red;
  983. font-size: .12rem;
  984. }
  985. }
  986. </style>