VisitSummaryAdd.vue 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226
  1. <template>
  2. <div class="bgcolor VisitSummaryAdd">
  3. <div class="navBarTOP">
  4. <van-nav-bar class="navBar" left-arrow :title="title" @click-left="onClickLeft" />
  5. </div>
  6. <div class="lineGrey"></div>
  7. <div class="lineGrey"></div>
  8. <div class="lineGrey"></div>
  9. <div class="lineGrey"></div>
  10. <div class="lineGrey"></div>
  11. <div class="lineGrey" style="height: 6px"></div>
  12. <div class="container" style="width: 94%; margin: 0px auto; border-radius: 6px">
  13. <!-- 活动扫码 -->
  14. <ActivityQRCode
  15. v-if="$route.query.qrCodeCheck == '1'"
  16. @onSubmit="onStorage"
  17. ref="ActivityQRCode"></ActivityQRCode>
  18. <van-form ref="tabstoreVal">
  19. <div v-for="(item, index) in collectionItemList" :key="index">
  20. <div v-if="item.answerType == 'sz'" class="formLabel z-cell">
  21. <van-cell>
  22. <template #title>
  23. <span v-if="item.isMust == 0" class="van-f-red">*</span>
  24. {{ 1 + index + '.' }}
  25. {{ item.customName }}
  26. </template>
  27. </van-cell>
  28. <van-field
  29. v-model="item.answerValue"
  30. :placeholder="item.remark"
  31. type="number"
  32. @input="numberFn(item, index)"></van-field>
  33. <!-- <p style="color: #444; font-size: 12px; margin: 0; padding: 10px 0; text-align: right">
  34. {{ item.remark }}
  35. </p> -->
  36. </div>
  37. <div v-if="item.answerType == 'rq'" class="formLabel z-cell">
  38. <van-cell>
  39. <template #title>
  40. <span v-if="item.isMust == 0" class="van-f-red">*</span>
  41. {{ 1 + index + '.' }}
  42. {{ item.customName }}
  43. </template>
  44. </van-cell>
  45. <van-field
  46. v-model="item.answerValue"
  47. clickable
  48. name="calendar"
  49. placeholder="点击选择日期"
  50. readonly
  51. @click="showCalendarClick(index)" />
  52. <p style="color: #444; font-size: 12px; margin: 0; padding: 10px 0; text-align: right">
  53. {{ item.remark }}
  54. </p>
  55. </div>
  56. <div v-if="item.answerType == 'zp'" class="formLabel z-cell">
  57. <van-cell>
  58. <template #title>
  59. <span v-if="item.isMust == 0" class="van-f-red">*</span>
  60. {{ 1 + index + '.' }}
  61. {{ item.customName }}
  62. </template>
  63. </van-cell>
  64. <van-row gutter="10" style="margin-bottom: 10px">
  65. <p style="margin-top: 0">
  66. <span style="font-size: 12px; color: #888">{{ item.remark }}</span>
  67. </p>
  68. <delete-upload-img :imgs="item.fileInfoList" :isDelete="false"></delete-upload-img>
  69. <upload-img
  70. :uploadid="uploadid2"
  71. @newimgarr="newimgarr1"
  72. imgText="上传照片"
  73. :indexImg="index"
  74. :customId="item.customId"
  75. :summaryId="item.summaryId"
  76. :item="item"
  77. @click="imgClick(item, index)"></upload-img>
  78. </van-row>
  79. </div>
  80. <div v-if="item.answerType == 'wb'" class="formLabel z-cell">
  81. <van-cell>
  82. <template #title>
  83. <span v-if="item.isMust == 0" class="van-f-red">*</span>
  84. {{ 1 + index + '.' }}
  85. {{ item.customName }}
  86. </template>
  87. </van-cell>
  88. <van-field
  89. v-model="item.answerValue"
  90. :formatter="formatter"
  91. autosize
  92. type="textarea"
  93. :placeholder="item.remark"></van-field>
  94. <!-- <p style="color: #444; font-size: 12px; margin: 0; padding: 10px 0; text-align: right">
  95. {{ item.remark }}
  96. </p> -->
  97. </div>
  98. <div v-if="item.answerType == 'gs'" class="formLabel z-cell" @click="regionClick(index)">
  99. <van-cell>
  100. <template #title>
  101. <span v-if="item.isMust == 0" class="van-f-red">*</span>
  102. {{ 1 + index + '.' }}
  103. {{ item.customName }}
  104. </template>
  105. </van-cell>
  106. <van-field
  107. readonly
  108. v-model="item.answerName"
  109. :formatter="formatter"
  110. :placeholder="item.customName"></van-field>
  111. <p style="color: #444; font-size: 12px; margin: 0; padding: 10px 0; text-align: right">
  112. {{ item.remark }}
  113. </p>
  114. </div>
  115. <div
  116. v-if="item.answerType == 'dq'"
  117. class="formLabel z-cell"
  118. @click="SalesRegionClick(index)">
  119. <van-cell>
  120. <template #title>
  121. <span v-if="item.isMust == 0" class="van-f-red">*</span>
  122. {{ 1 + index + '.' }}
  123. {{ item.customName }}
  124. </template>
  125. </van-cell>
  126. <van-field
  127. readonly
  128. v-model="item.answerName"
  129. :formatter="formatter"
  130. :placeholder="item.customName"></van-field>
  131. <p style="color: #444; font-size: 12px; margin: 0; padding: 10px 0; text-align: right">
  132. {{ item.remark }}
  133. </p>
  134. </div>
  135. <div
  136. v-if="item.answerType == 'xsb'"
  137. class="formLabel z-cell"
  138. @click="SalesDepartmentClick(index)">
  139. <van-cell>
  140. <template #title>
  141. <span v-if="item.isMust == 0" class="van-f-red">*</span>
  142. {{ 1 + index + '.' }}
  143. {{ item.customName }}
  144. </template>
  145. </van-cell>
  146. <van-field
  147. readonly
  148. v-model="item.answerName"
  149. :formatter="formatter"
  150. :placeholder="item.customName"></van-field>
  151. <p style="color: #444; font-size: 12px; margin: 0; padding: 10px 0; text-align: right">
  152. {{ item.remark }}
  153. </p>
  154. </div>
  155. <div v-if="item.answerType == 'duox'" class="formLabel z-cell">
  156. <van-cell>
  157. <template #title>
  158. <span v-if="item.isMust == 0" class="van-f-red">*</span>
  159. {{ 1 + index + '.' }}
  160. {{ item.customName }}
  161. </template>
  162. </van-cell>
  163. <z-checkbox
  164. :answerType="item.answerType"
  165. :checkboxval="item.answerValue"
  166. :collectionType="item.customOptionList"
  167. :textc="item.customId"
  168. :zCheckboxcolumns="item.customOptionList"
  169. @zSelectVal="zSelectVal"></z-checkbox>
  170. </div>
  171. <div v-if="item.answerType == 'dx'" class="formLabel z-cell">
  172. <van-cell>
  173. <template #title>
  174. <span v-if="item.isMust == 0" class="van-f-red">*</span>
  175. {{ 1 + index + '.' }}
  176. {{ item.customName }}
  177. </template>
  178. </van-cell>
  179. <z-radio
  180. :answerType="item.answerType"
  181. :collectionType="item.collectionType"
  182. :radio="item.answerValue"
  183. :textc="item.customId"
  184. :zRadiocolumns="item.customOptionList"
  185. @zSelectVal="zSelectVal"></z-radio>
  186. </div>
  187. <div v-if="item.answerType == 'jxs'" class="formLabel z-cell">
  188. <van-cell>
  189. <template #title>
  190. <span v-if="item.isMust == 0" class="van-f-red">*</span>
  191. {{ 1 + index + '.' }}
  192. {{ item.customName }}
  193. </template>
  194. </van-cell>
  195. <div class="jxsBox">
  196. <div class="jxsContent">
  197. <div class="item" v-for="(val, index) in item.chainList">
  198. <el-popover
  199. placement="bottom"
  200. trigger="click"
  201. :content="val.chainName + '(' + val.chainCode + ')'">
  202. <template slot="reference">
  203. <div class="selectItem">{{ val.chainName }} &nbsp; ({{ val.chainCode }})</div>
  204. <van-icon name="clear" size="16" @click="closeJXS(item, index)" />
  205. </template>
  206. </el-popover>
  207. </div>
  208. </div>
  209. <div class="addJXS"><van-icon name="add-o" size="24" @click="addJXS" /></div>
  210. <div class="tips">{{ item.remark }}</div>
  211. </div>
  212. </div>
  213. <br />
  214. </div>
  215. </van-form>
  216. </div>
  217. <br />
  218. <div class="tc" style="padding: 0 16px">
  219. <van-button class="submitBtn" block type="primary" @click="onStorage(null)">
  220. 暂存
  221. </van-button>
  222. <van-button class="submitBtn" block type="info" color="#0057ba" @click="onSubmit">
  223. 提交汇报
  224. </van-button>
  225. </div>
  226. <br />
  227. <van-calendar
  228. v-model="showCalendar"
  229. @confirm="onConfirm"
  230. color="#0057ba"
  231. :min-date="minDate"
  232. :max-date="maxDate"
  233. :show-confirm="false" />
  234. <van-popup v-model="RegionShow" capture position="bottom">
  235. <van-picker
  236. :columns="companyList"
  237. show-toolbar
  238. value-key="deptName"
  239. @cancel="RegionShow = false"
  240. @confirm="onregionConfirm" />
  241. </van-popup>
  242. <van-popup v-model="SalesRegionShow" capture position="bottom">
  243. <van-picker
  244. :columns="regionList"
  245. show-toolbar
  246. value-key="deptName"
  247. @cancel="SalesRegionShow = false"
  248. @confirm="onSalesRegionConfirm" />
  249. </van-popup>
  250. <van-popup v-model="SalesDepartmentShow" capture position="bottom">
  251. <van-picker
  252. :columns="deptList"
  253. show-toolbar
  254. value-key="deptName"
  255. @cancel="SalesDepartmentShow = false"
  256. @confirm="onSalesDepartmentConfirm" />
  257. </van-popup>
  258. <van-popup v-model="StartTimeShow" capture position="bottom">
  259. <van-datetime-picker
  260. v-model="strtcurrentDate"
  261. :max-date="strtmaxDate"
  262. :min-date="strtminDate"
  263. title="选择查找开始时间"
  264. type="date"
  265. @cancel="StartTimeShow = false"
  266. @confirm="onStartTimeConfirm" />
  267. </van-popup>
  268. <van-popup v-model="EndTimeShow" capture position="bottom">
  269. <van-datetime-picker
  270. v-model="endcurrentDate"
  271. :max-date="endmaxDate"
  272. :min-date="endminDate"
  273. title="选择查找结束时间"
  274. type="date"
  275. @cancel="EndTimeShow = false"
  276. @confirm="onEndTimeConfirm" />
  277. </van-popup>
  278. <!-- 经销商 -->
  279. <van-popup v-model="moreTypeShow" position="bottom">
  280. <van-row style="background-color: #f5f5f5">
  281. <van-col span="20">
  282. <van-field
  283. left-icon="search"
  284. style="margin-top: 2px; border-radius: 6px; overflow: hidden"
  285. v-model="agentValue"
  286. label=""
  287. placeholder="请输入关键词"
  288. clearable />
  289. </van-col>
  290. <van-col
  291. span="4"
  292. style="text-align: center; line-height: 48px"
  293. @click="getChainsList(agentValue)">
  294. <div style="background-color: #0057ba; color: #fff">搜索</div>
  295. </van-col>
  296. </van-row>
  297. <van-picker
  298. show-toolbar
  299. :columns="chainsData"
  300. value-key="chainName"
  301. @confirm="onConfirmChainsList"
  302. @cancel="moreTypeShow = false" />
  303. </van-popup>
  304. </div>
  305. </template>
  306. <script>
  307. import timeico from '@/assets/Icon/datatims.png';
  308. import {
  309. insertCustomAnswer,
  310. getSummaryDetailById,
  311. getDeptInfo,
  312. getSummaryMobileDeptInfo,
  313. getDeptsByUser,
  314. chainsList,
  315. temporarilyCustomAnswer,
  316. } from '@/api/index';
  317. import zRadio from '@/components/zRadio2';
  318. import zCheckbox from '@/components/zCheckbox2';
  319. // import uploadImg from "@/components/uo";
  320. import uploadImg from '@/components/uploadVTask';
  321. import deleteUploadImg from '@/components/deleteUploadImg2';
  322. import ActivityQRCode from './ActivityQRCode';
  323. export default {
  324. name: 'MyHistoricalWeekly',
  325. components: { zRadio, zCheckbox, uploadImg, deleteUploadImg, ActivityQRCode },
  326. data() {
  327. return {
  328. timeico: timeico,
  329. RegionShow: false,
  330. SalesRegionShow: false,
  331. SalesDepartmentShow: false,
  332. StaffShow: false,
  333. StartTimeShow: false,
  334. dateIndex: '',
  335. EndTimeShow: false,
  336. uploadid2: 'uploadid2',
  337. PhotoTypeList: [{ text: '009', value: '09' }],
  338. strtminDate: new Date(2022, 0, 1),
  339. endminDate: new Date(2022, 0, 1),
  340. minDate: new Date(2020, 0, 1),
  341. maxDate: new Date(2090, 0, 31),
  342. strtmaxDate: new Date(),
  343. endmaxDate: new Date(),
  344. strtcurrentDate: new Date(),
  345. endcurrentDate: new Date(),
  346. companyName: '全部公司',
  347. deptName: '全部销售部',
  348. regionName: '全部大区',
  349. userName: '全部',
  350. companyCode: '',
  351. deptCode: '',
  352. regionCode: '',
  353. userCode: '',
  354. companyList: [],
  355. title: '',
  356. deptList: [],
  357. regionList: [],
  358. userList: [],
  359. deptForm: { type: '', parentId: '' },
  360. list: [],
  361. loading: false,
  362. finished: true,
  363. showCalendar: false,
  364. formData: {
  365. type: '2', // 汇报类型或入口 1-下属业务员日报 2-下属销售部主管周报 3-下属大区主管半月报
  366. companyId: '', // 公司id,必传 Long类型
  367. regionId: '', // 大区id,必传 Long类型
  368. deptId: '', // 部门id,如果为周报或日报为必传 Long类型
  369. userId: '', // 业务员id,如果为日报为必传 Long类型
  370. startTime: '', // 开始时间,必传 格式:yyyy-MM-dd String类型
  371. endTime: '', // 结束时间,必传 格式:yyyy-MM-dd String类型
  372. pageNum: 1, // 当前页码 int类型
  373. pageSize: 10, // 当前每页条数 int类型
  374. },
  375. tableList: [],
  376. collectionItemList: [],
  377. collectionAnswerlisd: [],
  378. flagclick: true,
  379. index: '',
  380. activaFlag: true,
  381. moreTypeShow: false,
  382. agentValue: '',
  383. chainsData: [],
  384. chainName: '',
  385. chainCode: '',
  386. jxsList: [],
  387. userSummaryId: null,
  388. qrUuid: null,
  389. };
  390. },
  391. activated() {
  392. this.userSummaryId = null;
  393. this.qrUuid = null;
  394. },
  395. created() {
  396. this.activaFlag = true;
  397. // this.formData.startTime = this.GetPreMonthDay(this.parseTime(new Date(), '{y}-{m}-{d}'),2)
  398. this.formData.startTime = this.getThreeDaysAgo();
  399. // this.strtcurrentDate=new Date(this.GetPreMonthDay(this.parseTime(new Date(), '{y}-{m}-{d}'),2))
  400. this.strtcurrentDate = new Date(this.getThreeDaysAgo());
  401. this.formData.endTime = this.parseTime(new Date(), '{y}-{m}-{d}') + '';
  402. this.endminDate = new Date(this.GetPreMonthDay(this.parseTime(new Date(), '{y}-{m}-{d}'), 2));
  403. this.powerGrade = localStorage.getItem('powerGrade');
  404. this.title = this.$route.query.title;
  405. this.getReportInfo();
  406. this.regionCode = '';
  407. },
  408. watch: {
  409. $route(to, from) {
  410. if (to.path == '/VisitSummaryAdd') {
  411. this.title = this.$route.query.title;
  412. this.getReportInfo();
  413. this.regionCode = '';
  414. }
  415. },
  416. },
  417. methods: {
  418. showCalendarClick(val) {
  419. this.dateIndex = val;
  420. this.showCalendar = true;
  421. },
  422. formatDate(date) {
  423. var Month = date.getMonth() + 1;
  424. var Day = date.getDate();
  425. if (Month < 10) {
  426. Month = '0' + Month;
  427. }
  428. if (Day < 10) {
  429. Day = '0' + Day;
  430. }
  431. return `${date.getFullYear()}-${Month}-${Day}`;
  432. },
  433. onConfirm(date) {
  434. this.showCalendar = false;
  435. this.collectionItemList[this.dateIndex].answerValue = this.formatDate(date);
  436. },
  437. formatter(value) {
  438. return value.replace(
  439. /[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF][\u200D|\uFE0F]|[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF]|[0-9|*|#]\uFE0F\u20E3|[0-9|#]\u20E3|[\u203C-\u3299]\uFE0F\u200D|[\u203C-\u3299]\uFE0F|[\u2122-\u2B55]|\u303D|[\A9|\AE]\u3030|\uA9|\uAE|\u3030/gi,
  440. ''
  441. );
  442. },
  443. numberFn(val, index) {
  444. if (!/^[+-]?\d*\.{0,1}\d{0,1}$/.test(this.collectionItemList[index].answerValue)) {
  445. this.collectionItemList[index].answerValue = this.collectionItemList[
  446. index
  447. ].answerValue.replace(
  448. /\.\d{2,}$/,
  449. this.collectionItemList[index].answerValue.substr(
  450. this.collectionItemList[index].answerValue.indexOf('.'),
  451. 3
  452. )
  453. );
  454. }
  455. },
  456. zSelectVal(value) {
  457. var collectionAnswerlisd = this.collectionAnswerlisd;
  458. if (collectionAnswerlisd.length > 0) {
  459. var num = 0;
  460. for (var a = 0; a < collectionAnswerlisd.length; a++) {
  461. if (collectionAnswerlisd[a].id == value.id) {
  462. collectionAnswerlisd[a] = value;
  463. num = 0;
  464. } else {
  465. num = 1;
  466. }
  467. }
  468. if (num > 0) {
  469. collectionAnswerlisd.push(value);
  470. }
  471. } else {
  472. collectionAnswerlisd.push(value);
  473. }
  474. this.collectionAnswerlisd = collectionAnswerlisd;
  475. },
  476. imgClick(val, index) {
  477. this.collectionId = val.collectionId + '';
  478. this.indeximg = index;
  479. this.show = true;
  480. },
  481. newimgarr1() {
  482. this.$forceUpdate();
  483. // if (
  484. // this.collectionItemList[val.index].fileInfoList == null ||
  485. // this.collectionItemList[val.index].fileInfoList == undefined
  486. // ) {
  487. // this.collectionItemList[val.index].fileInfoList = [];
  488. // this.collectionItemList[val.index].fileIdList = [];
  489. // }
  490. // this.collectionItemList[val.index].fileInfoList.push(val);
  491. // this.collectionItemList[val.index].fileIdList.push(val.id);
  492. },
  493. dateFn(val) {
  494. return val.slice(0, 4) + '-' + val.slice(4, 6) + '-' + val.slice(6, 8);
  495. },
  496. onLoad() {},
  497. // 暂存 不校验答案是否必填
  498. onStorage(callback) {
  499. let ActivityQRCodeData = this.$refs.ActivityQRCode ? this.$refs.ActivityQRCode.activityForm : {} || {};
  500. this.setParams(() => {
  501. temporarilyCustomAnswer({
  502. userSummaryId: this.userSummaryId, // Long 用户总结id,如果为新增则不填,编辑则必填
  503. summaryId: this.$route.query.summaryId, //Long 主管任务id
  504. customItemList: this.collectionItemList, //List<Object> 答案列表
  505. ...ActivityQRCodeData, //任务名称、活动日期、签到时间
  506. getQrCode: callback ? true : false, //是否需要反馈二维码(是:任务名称、活动日期、签到时间必填)
  507. qrUuid: this.qrUuid || null,
  508. })
  509. .then((res) => {
  510. if (res.code == 200) {
  511. if (callback) {
  512. this.userSummaryId = res.data.userSummaryId ? res.data.userSummaryId : null;
  513. this.qrUuid = res.data.qrUuid ? res.data.qrUuid : null;
  514. // 回传二维码
  515. callback(res);
  516. } else {
  517. this.$router.go(-1);
  518. }
  519. } else {
  520. this.$toast(res.msg);
  521. }
  522. })
  523. .catch((err) => {
  524. this.$toast(err.msg);
  525. });
  526. });
  527. },
  528. onSubmit() {
  529. if (this.$route.query.qrCodeCheck == '1') {
  530. // 执行 ActivityQRCode from表单验证触发
  531. this.$refs.ActivityQRCode.$refs.tabstoreVal
  532. .validate()
  533. .then(() => {
  534. // 验证通过
  535. let ActivityQRCodeData = this.$refs.ActivityQRCode ? this.$refs.ActivityQRCode.activityForm : {} || {};
  536. this.onSubmitFun(ActivityQRCodeData);
  537. })
  538. .catch((errors) => {
  539. //验证失败
  540. window.scrollTo(0, 0);
  541. return;
  542. });
  543. } else {
  544. this.onSubmitFun();
  545. }
  546. },
  547. onSubmitFun(ActivityQRCodeData = {}) {
  548. this.setParams(() => {
  549. if (this.flagclick) {
  550. this.flagclick = false;
  551. this.timer = null;
  552. this.timer = setTimeout(() => {
  553. this.flagclick = true;
  554. }, 2000);
  555. insertCustomAnswer({
  556. userSummaryId: this.userSummaryId, // Long 用户总结id,如果为新增则不填,编辑则必填
  557. summaryId: this.$route.query.summaryId, //Long 主管任务id
  558. customItemList: this.collectionItemList, //List<Object> 答案列表
  559. ...ActivityQRCodeData,
  560. qrUuid: this.qrUuid || null,
  561. })
  562. .then((res) => {
  563. if (res.code == 200) {
  564. this.$router.go(-1);
  565. } else {
  566. this.$toast(res.msg);
  567. }
  568. })
  569. .catch((err) => {
  570. this.$toast(err.msg);
  571. });
  572. }
  573. });
  574. },
  575. setParams(callback) {
  576. for (var c = 0; c < this.collectionAnswerlisd.length; c++) {
  577. for (var b = 0; b < this.collectionItemList.length; b++) {
  578. if (this.collectionAnswerlisd[c].id == this.collectionItemList[b].customId) {
  579. this.collectionItemList[b].customOptionList = this.collectionAnswerlisd[c].value;
  580. }
  581. }
  582. }
  583. // // 照片
  584. let zpDataList = this.collectionItemList.find((item) => item.answerType == 'zp');
  585. if (zpDataList && zpDataList.fileInfoList) {
  586. let fileIdList = [];
  587. zpDataList.fileInfoList.forEach((item) => {
  588. fileIdList.push(item.id);
  589. });
  590. zpDataList.fileIdList = fileIdList;
  591. }
  592. // 经销商
  593. // let JXSSataList = this.collectionItemList.find((item) => item.answerType == 'jxs');
  594. // if (this.jxsList.length) {
  595. // let fileIdList = [];
  596. // this.jxsList.forEach((item) => {
  597. // fileIdList.push({
  598. // chainCode: item.chainCode,
  599. // chainName: item.chainName,
  600. // });
  601. // });
  602. // JXSSataList.chainList = fileIdList;
  603. // }
  604. callback && callback();
  605. },
  606. getReportInfo() {
  607. let loading1 = this.$toast.loading({
  608. duration: 0,
  609. message: '加载中...',
  610. forbidClick: true,
  611. });
  612. this.collectionItemList = [];
  613. this.collectionAnswerlisd = [];
  614. getSummaryDetailById({ summaryId: this.$route.query.summaryId }).then((res) => {
  615. loading1.clear();
  616. if (res.code == 200) {
  617. var collectionItemLists = res.data;
  618. for (var q = 0; q < collectionItemLists.length; q++) {
  619. collectionItemLists[q].answerName = undefined;
  620. // 公司
  621. if (
  622. (collectionItemLists[q].answerType == 'gs' ||
  623. collectionItemLists[q].answerType == 'dq' ||
  624. collectionItemLists[q].answerType == 'xsb') &&
  625. this.activaFlag
  626. ) {
  627. this.activaFlag = false;
  628. if (collectionItemLists[q].answerType == 'xsb') {
  629. this.getDeptsBy(collectionItemLists[q].answerValue);
  630. this.getDeptInfo(
  631. 'dept',
  632. collectionItemLists[q].answerType,
  633. collectionItemLists[q].answerValue
  634. );
  635. } else {
  636. this.getDeptInfo(
  637. 'dept',
  638. collectionItemLists[q].answerType,
  639. collectionItemLists[q].answerValue
  640. );
  641. }
  642. }
  643. // 单选
  644. if (
  645. collectionItemLists[q].answerType == 'dx' &&
  646. collectionItemLists[q].showHistory == '1'
  647. ) {
  648. let findCustom = collectionItemLists[q].customOptionList.find((item) => item.checked);
  649. if (findCustom) {
  650. collectionItemLists[q].answerValue = findCustom.customOptionId + '';
  651. }
  652. }
  653. // 多选
  654. if (
  655. collectionItemLists[q].answerType == 'duox' &&
  656. collectionItemLists[q].showHistory == '1'
  657. ) {
  658. let findCustom = [];
  659. collectionItemLists[q].customOptionList.forEach((item) => {
  660. if (item.checked) {
  661. findCustom.push(item.customOptionId + '');
  662. }
  663. });
  664. if (findCustom) {
  665. collectionItemLists[q].answerValue = findCustom.join(',');
  666. }
  667. }
  668. // 照片
  669. if (collectionItemLists[q].answerType == 'zp' && collectionItemLists[q].fileInfoList) {
  670. let fileIdList = [];
  671. collectionItemLists[q].fileInfoList.forEach((item) => {
  672. fileIdList.push(item.id);
  673. });
  674. collectionItemLists[q].fileIdList = fileIdList;
  675. }
  676. }
  677. this.collectionItemList = collectionItemLists;
  678. }
  679. });
  680. },
  681. getThreeDaysAgo() {
  682. let myDate = new Date();
  683. let lw = new Date(myDate - 1000 * 60 * 60 * 24 * 14); //最后一个数字30可改,30天的意思
  684. let lastY = lw.getFullYear();
  685. let lastM = lw.getMonth() + 1;
  686. let lastD = lw.getDate();
  687. let startData =
  688. lastY + '-' + (lastM < 10 ? '0' + lastM : lastM) + '-' + (lastD < 10 ? '0' + lastD : lastD); //三十天之前日期
  689. return startData;
  690. },
  691. GetPreMonthDay(date, monthNum, type) {
  692. var dateArr = date.split('-');
  693. var year = dateArr[0]; //获取当前日期的年份
  694. var month = dateArr[1]; //获取当前日期的月份
  695. var day = dateArr[2]; //获取当前日期的日
  696. var days = new Date(year, month, 0);
  697. days = days.getDate(); //获取当前日期中月的天数
  698. var year2 = year;
  699. var month2 = parseInt(month) - monthNum;
  700. if (month2 <= 0) {
  701. var absM = Math.abs(month2);
  702. year2 = parseInt(year2) - Math.ceil(absM / 12 == 0 ? 1 : parseInt(absM) / 12);
  703. month2 = 12 - (absM % 12);
  704. }
  705. var day2 = day;
  706. var days2 = new Date(year2, month2, 0);
  707. days2 = days2.getDate();
  708. if (day2 > days2) {
  709. day2 = days2;
  710. }
  711. if (month2 < 10) {
  712. month2 = '0' + month2;
  713. }
  714. var t2 = '';
  715. if (monthNum > 0) {
  716. t2 = year2 + '-' + month2 + '-01';
  717. } else {
  718. if (type == 'end') {
  719. var Months = new Date().getMonth() + 1;
  720. var days111 = new Date().getDate();
  721. if (Months < 10) {
  722. Months = '0' + Months;
  723. }
  724. if (days111 < 10) {
  725. days111 = '0' + days111;
  726. }
  727. if (parseInt(month2) >= new Date().getMonth() + 1) {
  728. t2 = year2 + '-' + Months + '-' + days111;
  729. } else {
  730. var daysd = this.getMonthDays(year2, month2);
  731. t2 = year2 + '-' + month2 + '-' + daysd;
  732. }
  733. } else {
  734. t2 = year2 + '-' + month2 + '-' + day2;
  735. }
  736. }
  737. return t2;
  738. },
  739. getMonthDays(year, month) {
  740. var stratDate = new Date(year, month - 1, 1),
  741. endData = new Date(year, month, 1);
  742. var days = (endData - stratDate) / (1000 * 60 * 60 * 24);
  743. return days;
  744. },
  745. getDeptInfo(type, grade, answerValue) {
  746. this.deptForm.type = type;
  747. if (grade == 'dq') {
  748. this.deptForm.parentId = this.companyCode;
  749. } else if (grade == 'xsb') {
  750. this.deptForm.parentId = this.regionCode;
  751. } else {
  752. this.deptForm.type = '';
  753. this.deptForm.parentId = '';
  754. }
  755. getSummaryMobileDeptInfo(this.deptForm).then((res) => {
  756. if (grade == 'dq') {
  757. if (res.data.region != null) {
  758. this.regionList = res.data.region;
  759. // for (var k = 0; k < this.collectionItemList.length; k++) {
  760. // if (this.collectionItemList[k].answerType == 'dq') {
  761. // this.collectionItemList[k].answerName = res.data.region[0].deptName;
  762. // this.collectionItemList[k].answerValue = res.data.region[0].deptCode;
  763. // }
  764. // }
  765. if (answerValue) {
  766. let findCompany = this.companyList.find((item) => item.deptCode == answerValue);
  767. this.onSalesRegionConfirm(findCompany);
  768. } else {
  769. this.onSalesRegionConfirm(this.regionList[0]);
  770. }
  771. }
  772. } else if (grade == 'xsb') {
  773. if (res.data.dept != null) {
  774. this.deptList = res.data.dept;
  775. if (answerValue) {
  776. let findCompany = this.regionList.find((item) => item.deptCode == answerValue);
  777. this.onSalesDepartmentConfirm(findCompany);
  778. } else {
  779. this.onSalesDepartmentConfirm(this.deptList[0]);
  780. }
  781. }
  782. } else if (grade == 'gs') {
  783. this.companyList = res.data.company;
  784. if (answerValue) {
  785. let findCompany = this.companyList.find((item) => item.deptCode == answerValue);
  786. this.onregionConfirm(findCompany);
  787. } else {
  788. this.onregionConfirm(this.companyList[0]);
  789. }
  790. if (res.data.dept != null) {
  791. this.deptList = res.data.dept;
  792. }
  793. if (res.data.region != null) {
  794. this.regionList = res.data.region;
  795. }
  796. }
  797. });
  798. },
  799. getDeptsBy(answerValue) {
  800. getDeptsByUser().then((res) => {
  801. if (res.data && res.code == 200) {
  802. let arr = [];
  803. res.data.forEach((val) => {
  804. arr.push({
  805. ancestors: val.ancestors || '',
  806. deptCode: val.deptCode || '',
  807. deptId: val.deptId || '',
  808. deptLevel: val.deptLevel || '',
  809. deptName: val.deptName || '',
  810. parentId: val.parentId || '',
  811. });
  812. });
  813. this.deptList = arr;
  814. if (answerValue) {
  815. let findCompany = this.regionList.find((item) => item.deptCode == answerValue);
  816. this.onSalesDepartmentConfirm(findCompany);
  817. } else {
  818. this.onSalesDepartmentConfirm(this.deptList[0]);
  819. }
  820. }
  821. });
  822. },
  823. dailyFn(row) {
  824. if (row.status != '0') {
  825. if (row.status == -1) {
  826. var dayTime = row.showDate;
  827. var times = new Date(
  828. dayTime.slice(0, 4) + '-' + dayTime.slice(4, 6) + '-' + dayTime.slice(6, 8)
  829. ).getTime();
  830. var time = new Date('2022-08-25').getTime();
  831. if (times < time) {
  832. this.$dialog.alert({
  833. title: '系统提示',
  834. message: '非常抱歉,8月25日前历史报告数据不存在',
  835. });
  836. } else {
  837. this.$router.push({
  838. path: '/weeklyHistoricalDetils',
  839. query: { reportId: row.id },
  840. });
  841. }
  842. } else {
  843. this.$router.push({
  844. path: '/weeklyHistoricalDetils',
  845. query: { reportId: row.id },
  846. });
  847. }
  848. }
  849. },
  850. onClickLeft() {
  851. this.$router.go(-1);
  852. },
  853. regionClick(val) {
  854. // if(this.powerGrade>4){
  855. this.index = val;
  856. this.RegionShow = true;
  857. // }
  858. },
  859. SalesRegionClick(val) {
  860. this.index = val;
  861. this.SalesRegionShow = true;
  862. },
  863. SalesDepartmentClick(val) {
  864. this.index = val;
  865. this.SalesDepartmentShow = true;
  866. },
  867. StaffClick() {
  868. this.StaffShow = true;
  869. },
  870. StartTimeClick() {
  871. this.StartTimeShow = true;
  872. },
  873. EndTimeClick() {
  874. this.EndTimeShow = true;
  875. },
  876. onSalesRegionConfirm(val) {
  877. this.SalesRegionShow = false;
  878. this.regionCode = val.deptId;
  879. // if (this.index !== '') {
  880. // this.collectionItemList[this.index].answerName = val.deptName;
  881. // this.collectionItemList[this.index].answerValue = val.deptCode;
  882. // for (var k1 = 0; k1 < this.collectionItemList.length; k1++) {
  883. // if (this.collectionItemList[k1].answerType == 'xsb' && val.deptId != '') {
  884. // this.getDeptInfo('dept', 'xsb');
  885. // }
  886. // }
  887. // } else {
  888. for (var k1 = 0; k1 < this.collectionItemList.length; k1++) {
  889. if (this.collectionItemList[k1].answerType == 'xsb') {
  890. this.collectionItemList[k1].answerName = '';
  891. this.collectionItemList[k1].answerValue = '';
  892. }
  893. if (this.collectionItemList[k1].answerType == 'dq') {
  894. this.collectionItemList[k1].answerName = val.deptName;
  895. this.collectionItemList[k1].answerValue = val.deptCode;
  896. }
  897. if (this.collectionItemList[k1].answerType == 'xsb' && val.deptId != '') {
  898. this.getDeptInfo('dept', 'xsb');
  899. }
  900. }
  901. // }
  902. // if (val.deptId != '') {
  903. // this.getDeptInfo('dept', 'xsb');
  904. // }
  905. },
  906. onregionConfirm(val) {
  907. this.RegionShow = false;
  908. this.companyCode = val.deptId;
  909. // if (this.index !== '') {
  910. // this.collectionItemList[this.index].answerName = val.deptName;
  911. // this.collectionItemList[this.index].answerValue = val.deptCode;
  912. // for (var k1 = 0; k1 < this.collectionItemList.length; k1++) {
  913. // if (this.collectionItemList[k1].answerType == 'dq') {
  914. // this.getDeptInfo('dept', 'dq');
  915. // }
  916. // }
  917. // } else {
  918. for (var k1 = 0; k1 < this.collectionItemList.length; k1++) {
  919. if (this.collectionItemList[k1].answerType == 'xsb') {
  920. this.collectionItemList[k1].answerName = '';
  921. this.collectionItemList[k1].answerValue = '';
  922. }
  923. if (this.collectionItemList[k1].answerType == 'xsb') {
  924. this.collectionItemList[k1].answerName = '';
  925. this.collectionItemList[k1].answerValue = '';
  926. }
  927. if (this.collectionItemList[k1].answerType == 'gs') {
  928. this.collectionItemList[k1].answerName = val.deptName;
  929. this.collectionItemList[k1].answerValue = val.deptCode;
  930. }
  931. if (this.collectionItemList[k1].answerType == 'dq') {
  932. this.getDeptInfo('dept', 'dq');
  933. }
  934. }
  935. // }
  936. },
  937. onSalesDepartmentConfirm(val) {
  938. this.SalesDepartmentShow = false;
  939. // if (this.index !== '') {
  940. // this.collectionItemList[this.index].answerName = val.deptName;
  941. // this.collectionItemList[this.index].answerValue = val.deptCode;
  942. // } else {
  943. for (var k1 = 0; k1 < this.collectionItemList.length; k1++) {
  944. if (this.collectionItemList[k1].answerType == 'xsb') {
  945. this.collectionItemList[k1].answerName = val.deptName;
  946. this.collectionItemList[k1].answerValue = val.deptCode;
  947. }
  948. }
  949. // }
  950. },
  951. onStartTimeConfirm(val) {
  952. this.formData.startTime = this.parseTime(new Date(val), '{y}-{m}-{d}') + '';
  953. this.StartTimeShow = false;
  954. this.endminDate = new Date(val);
  955. this.endmaxDate = new Date(this.GetPreMonthDay(this.formData.startTime, -2, 'end'));
  956. if (
  957. new Date(this.formData.startTime).getTime() > new Date(this.formData.endTime).getTime() ||
  958. new Date(this.endmaxDate).getTime() < new Date(this.formData.endTime).getTime()
  959. ) {
  960. this.formData.endTime = this.parseTime(new Date(val), '{y}-{m}-{d}') + '';
  961. this.endcurrentDate = this.GetPreMonthDay(this.formData.startTime, -2);
  962. }
  963. this.list = [];
  964. this.formData.pageNum = 1;
  965. },
  966. onEndTimeConfirm(val) {
  967. this.formData.endTime = this.parseTime(new Date(val), '{y}-{m}-{d}');
  968. this.strtmaxDate = new Date(val);
  969. if (new Date(this.formData.startTime).getTime() > new Date(this.formData.endTime).getTime()) {
  970. this.formData.startTime = this.formData.endTime;
  971. }
  972. this.list = [];
  973. this.formData.pageNum = 1;
  974. this.EndTimeShow = false;
  975. },
  976. // 添加经销商
  977. addJXS() {
  978. this.agentValue = '';
  979. this.moreTypeShow = true;
  980. this.getChainsList();
  981. },
  982. // 删除经销商
  983. closeJXS(item, index) {
  984. item.chainList.splice(index, 1);
  985. },
  986. getChainsList(value = '') {
  987. this.chainsData = [];
  988. chainsList({
  989. chainCode: '', // string 经销商编码
  990. chainName: value, // string 经销商名称
  991. limit: 100,
  992. })
  993. .then((res) => {
  994. if (res.code == 200 && res.rows) {
  995. this.chainsData = res.rows;
  996. } else {
  997. this.chainsData = [];
  998. }
  999. })
  1000. .catch(() => {
  1001. this.chainsData = [];
  1002. });
  1003. },
  1004. onConfirmChainsList(value) {
  1005. if (value && value.chainName != undefined) {
  1006. let JXSSataList = this.collectionItemList.find((item) => item.answerType == 'jxs');
  1007. if (!JXSSataList.chainList) {
  1008. JXSSataList.chainList = [];
  1009. }
  1010. let isFlag = JXSSataList.chainList.find((val) => val.chainCode == value.chainCode);
  1011. if (!isFlag) {
  1012. JXSSataList.chainList.push({
  1013. chainName: value.chainName,
  1014. chainCode: value.chainCode,
  1015. });
  1016. this.moreTypeShow = false;
  1017. } else {
  1018. this.$toast('当前经销商已添加,不能重复添加!');
  1019. }
  1020. }
  1021. },
  1022. },
  1023. };
  1024. </script>
  1025. <style scoped lang="scss">
  1026. .container {
  1027. // background-color: white;
  1028. }
  1029. .van-f-red {
  1030. color: red;
  1031. width: 8px;
  1032. display: inline-block;
  1033. line-height: 26px;
  1034. }
  1035. .formLabel {
  1036. margin: 0 16px;
  1037. border-bottom: 1px solid #f1f1f1;
  1038. }
  1039. .formLabel .van-cell {
  1040. padding: 10px 0;
  1041. }
  1042. .formLabel .van-cell::after {
  1043. border: 0;
  1044. }
  1045. .formLabel .van-field {
  1046. border: 1px solid #f1f1f1;
  1047. padding: 6px;
  1048. width: 100%;
  1049. border-radius: 4px;
  1050. overflow: hidden;
  1051. }
  1052. .formLabel .van-field__control {
  1053. padding: 0 10px;
  1054. }
  1055. .formLabel .formLabeltitle {
  1056. position: absolute;
  1057. top: 8px;
  1058. }
  1059. .lineGrey {
  1060. height: 10px;
  1061. width: 100%;
  1062. background: #f1f1f1;
  1063. }
  1064. .z-checkbox .van-radio {
  1065. padding: 6px 0;
  1066. }
  1067. .z-cell .van-cell__title {
  1068. font-size: 16px;
  1069. }
  1070. .VisitSummaryAdd {
  1071. .tc {
  1072. display: flex;
  1073. justify-content: space-between;
  1074. .submitBtn {
  1075. width: 45%;
  1076. border-radius: 20px;
  1077. }
  1078. }
  1079. .van-form {
  1080. background-color: white;
  1081. }
  1082. }
  1083. </style>
  1084. <style lang="scss">
  1085. .table-headermd {
  1086. font-size: 12px;
  1087. text-align: center;
  1088. position: initial;
  1089. width: 98% !important;
  1090. margin: 0 auto;
  1091. border-right: 0;
  1092. }
  1093. .table-headermd .el-table__header,
  1094. .table-headermd .el-table__body {
  1095. width: 100% !important;
  1096. }
  1097. /*.table-headermd col {width: 6.8rem;}*/
  1098. .table-headermd col:nth-child(4) {
  1099. width: 5.6rem;
  1100. }
  1101. .table-headermd col:nth-child(2),
  1102. .table-headermd col:nth-child(3) {
  1103. width: 4.6rem;
  1104. }
  1105. .table-headermd .van-cell {
  1106. padding: 0 4px;
  1107. height: 100%;
  1108. }
  1109. .table-headermd th.el-table__cell > .cell {
  1110. padding: 0 4px;
  1111. text-align: center;
  1112. }
  1113. .table-headermd th.el-table__cell:first-child > .cell {
  1114. text-align: left;
  1115. }
  1116. .table-headermd th.el-table__cell {
  1117. background-color: #1989fa;
  1118. color: #fff;
  1119. }
  1120. .table-headermd .el-table__cell {
  1121. padding: 4px 0;
  1122. }
  1123. .table-headermd.el-table .cell {
  1124. padding: 0;
  1125. }
  1126. .table-headermd .tipTitle {
  1127. overflow: hidden;
  1128. text-overflow: ellipsis;
  1129. display: -webkit-box;
  1130. -webkit-box-orient: vertical;
  1131. -webkit-line-clamp: 2;
  1132. }
  1133. .table-headermd::before {
  1134. height: 0;
  1135. }
  1136. .xing {
  1137. color: red;
  1138. padding-left: 4px;
  1139. }
  1140. .formLabel .van-radio__label,
  1141. .formLabel .van-checkbox__label {
  1142. font-size: 1.4rem;
  1143. }
  1144. .table-headermd .cell,
  1145. .el-table--border .el-table__cell:first-child .cell {
  1146. padding: 0 4px;
  1147. }
  1148. .van-dialog__confirm,
  1149. .van-dialog__confirm:active {
  1150. color: #1989fa;
  1151. }
  1152. .navBarTOP {
  1153. position: fixed;
  1154. width: 100%;
  1155. z-index: 2;
  1156. top: 0;
  1157. }
  1158. .isTableMust {
  1159. padding: 4px;
  1160. color: #999;
  1161. margin: 0;
  1162. margin-top: -10px;
  1163. }
  1164. .jxsBox {
  1165. .tips {
  1166. text-align: right;
  1167. }
  1168. }
  1169. .VisitSummaryAdd {
  1170. .jxsContent {
  1171. margin-bottom: 10px;
  1172. .item {
  1173. padding: 5px;
  1174. background: #e9e9e9;
  1175. margin: 5px 0;
  1176. .el-popover__reference-wrapper {
  1177. display: flex;
  1178. justify-content: space-between;
  1179. align-items: center;
  1180. }
  1181. .selectItem {
  1182. flex: 1;
  1183. white-space: nowrap;
  1184. overflow: hidden;
  1185. text-overflow: ellipsis;
  1186. font-size: 14px;
  1187. }
  1188. }
  1189. }
  1190. .linep .van-cell__title {
  1191. color: #646566;
  1192. font-weight: 500;
  1193. font-size: 14px;
  1194. }
  1195. }
  1196. </style>