VisitSummaryAdd.vue 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255
  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. <div class="tips">
  298. <div><van-icon name="warning-o" />默认显示前100条,请输入关键词查询</div>
  299. </div>
  300. <van-picker
  301. show-toolbar
  302. :columns="chainsData"
  303. value-key="chainName"
  304. @confirm="onConfirmChainsList"
  305. @cancel="moreTypeShow = false" />
  306. </van-popup>
  307. </div>
  308. </template>
  309. <script>
  310. import timeico from '@/assets/Icon/datatims.png';
  311. import {
  312. insertCustomAnswer,
  313. getSummaryDetailById,
  314. getDeptInfo,
  315. getSummaryMobileDeptInfo,
  316. getDeptsByUser,
  317. chainsList,
  318. temporarilyCustomAnswer,
  319. } from '@/api/index';
  320. import zRadio from '@/components/zRadio2';
  321. import zCheckbox from '@/components/zCheckbox2';
  322. // import uploadImg from "@/components/uo";
  323. import uploadImg from '@/components/uploadVTask';
  324. import deleteUploadImg from '@/components/deleteUploadImg2';
  325. import ActivityQRCode from './ActivityQRCode';
  326. export default {
  327. name: 'MyHistoricalWeekly',
  328. components: { zRadio, zCheckbox, uploadImg, deleteUploadImg, ActivityQRCode },
  329. data() {
  330. return {
  331. timeico: timeico,
  332. RegionShow: false,
  333. SalesRegionShow: false,
  334. SalesDepartmentShow: false,
  335. StaffShow: false,
  336. StartTimeShow: false,
  337. dateIndex: '',
  338. EndTimeShow: false,
  339. uploadid2: 'uploadid2',
  340. PhotoTypeList: [{ text: '009', value: '09' }],
  341. strtminDate: new Date(2022, 0, 1),
  342. endminDate: new Date(2022, 0, 1),
  343. minDate: new Date(2020, 0, 1),
  344. maxDate: new Date(2090, 0, 31),
  345. strtmaxDate: new Date(),
  346. endmaxDate: new Date(),
  347. strtcurrentDate: new Date(),
  348. endcurrentDate: new Date(),
  349. companyName: '全部公司',
  350. deptName: '全部销售部',
  351. regionName: '全部大区',
  352. userName: '全部',
  353. companyCode: '',
  354. deptCode: '',
  355. regionCode: '',
  356. userCode: '',
  357. companyList: [],
  358. title: '',
  359. deptList: [],
  360. regionList: [],
  361. userList: [],
  362. deptForm: { type: '', parentId: '' },
  363. list: [],
  364. loading: false,
  365. finished: true,
  366. showCalendar: false,
  367. formData: {
  368. type: '2', // 汇报类型或入口 1-下属业务员日报 2-下属销售部主管周报 3-下属大区主管半月报
  369. companyId: '', // 公司id,必传 Long类型
  370. regionId: '', // 大区id,必传 Long类型
  371. deptId: '', // 部门id,如果为周报或日报为必传 Long类型
  372. userId: '', // 业务员id,如果为日报为必传 Long类型
  373. startTime: '', // 开始时间,必传 格式:yyyy-MM-dd String类型
  374. endTime: '', // 结束时间,必传 格式:yyyy-MM-dd String类型
  375. pageNum: 1, // 当前页码 int类型
  376. pageSize: 10, // 当前每页条数 int类型
  377. },
  378. tableList: [],
  379. collectionItemList: [],
  380. collectionAnswerlisd: [],
  381. flagclick: true,
  382. index: '',
  383. activaFlag: true,
  384. moreTypeShow: false,
  385. agentValue: '',
  386. chainsData: [],
  387. chainName: '',
  388. chainCode: '',
  389. jxsList: [],
  390. userSummaryId: null,
  391. qrUuid: null,
  392. };
  393. },
  394. activated() {
  395. this.userSummaryId = null;
  396. this.qrUuid = null;
  397. },
  398. created() {
  399. this.activaFlag = true;
  400. // this.formData.startTime = this.GetPreMonthDay(this.parseTime(new Date(), '{y}-{m}-{d}'),2)
  401. this.formData.startTime = this.getThreeDaysAgo();
  402. // this.strtcurrentDate=new Date(this.GetPreMonthDay(this.parseTime(new Date(), '{y}-{m}-{d}'),2))
  403. this.strtcurrentDate = new Date(this.getThreeDaysAgo());
  404. this.formData.endTime = this.parseTime(new Date(), '{y}-{m}-{d}') + '';
  405. this.endminDate = new Date(this.GetPreMonthDay(this.parseTime(new Date(), '{y}-{m}-{d}'), 2));
  406. this.powerGrade = localStorage.getItem('powerGrade');
  407. this.title = this.$route.query.title;
  408. this.getReportInfo();
  409. this.regionCode = '';
  410. },
  411. watch: {
  412. $route(to, from) {
  413. if (to.path == '/VisitSummaryAdd') {
  414. this.title = this.$route.query.title;
  415. this.getReportInfo();
  416. this.regionCode = '';
  417. }
  418. },
  419. },
  420. methods: {
  421. showCalendarClick(val) {
  422. this.dateIndex = val;
  423. this.showCalendar = true;
  424. },
  425. formatDate(date) {
  426. var Month = date.getMonth() + 1;
  427. var Day = date.getDate();
  428. if (Month < 10) {
  429. Month = '0' + Month;
  430. }
  431. if (Day < 10) {
  432. Day = '0' + Day;
  433. }
  434. return `${date.getFullYear()}-${Month}-${Day}`;
  435. },
  436. onConfirm(date) {
  437. this.showCalendar = false;
  438. this.collectionItemList[this.dateIndex].answerValue = this.formatDate(date);
  439. },
  440. formatter(value) {
  441. return value.replace(
  442. /[\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,
  443. ''
  444. );
  445. },
  446. numberFn(val, index) {
  447. if (!/^[+-]?\d*\.{0,1}\d{0,1}$/.test(this.collectionItemList[index].answerValue)) {
  448. this.collectionItemList[index].answerValue = this.collectionItemList[
  449. index
  450. ].answerValue.replace(
  451. /\.\d{2,}$/,
  452. this.collectionItemList[index].answerValue.substr(
  453. this.collectionItemList[index].answerValue.indexOf('.'),
  454. 3
  455. )
  456. );
  457. }
  458. },
  459. zSelectVal(value) {
  460. var collectionAnswerlisd = this.collectionAnswerlisd;
  461. if (collectionAnswerlisd.length > 0) {
  462. var num = 0;
  463. for (var a = 0; a < collectionAnswerlisd.length; a++) {
  464. if (collectionAnswerlisd[a].id == value.id) {
  465. collectionAnswerlisd[a] = value;
  466. num = 0;
  467. } else {
  468. num = 1;
  469. }
  470. }
  471. if (num > 0) {
  472. collectionAnswerlisd.push(value);
  473. }
  474. } else {
  475. collectionAnswerlisd.push(value);
  476. }
  477. this.collectionAnswerlisd = collectionAnswerlisd;
  478. },
  479. imgClick(val, index) {
  480. this.collectionId = val.collectionId + '';
  481. this.indeximg = index;
  482. this.show = true;
  483. },
  484. newimgarr1() {
  485. this.$forceUpdate();
  486. // if (
  487. // this.collectionItemList[val.index].fileInfoList == null ||
  488. // this.collectionItemList[val.index].fileInfoList == undefined
  489. // ) {
  490. // this.collectionItemList[val.index].fileInfoList = [];
  491. // this.collectionItemList[val.index].fileIdList = [];
  492. // }
  493. // this.collectionItemList[val.index].fileInfoList.push(val);
  494. // this.collectionItemList[val.index].fileIdList.push(val.id);
  495. },
  496. dateFn(val) {
  497. return val.slice(0, 4) + '-' + val.slice(4, 6) + '-' + val.slice(6, 8);
  498. },
  499. onLoad() {},
  500. // 暂存 不校验答案是否必填
  501. onStorage(callback) {
  502. let ActivityQRCodeData = this.$refs.ActivityQRCode.activityForm || {};
  503. this.setParams(() => {
  504. temporarilyCustomAnswer({
  505. userSummaryId: this.userSummaryId, // Long 用户总结id,如果为新增则不填,编辑则必填
  506. summaryId: this.$route.query.summaryId, //Long 主管任务id
  507. customItemList: this.collectionItemList, //List<Object> 答案列表
  508. ...ActivityQRCodeData, //任务名称、活动日期、签到时间
  509. getQrCode: callback ? true : false, //是否需要反馈二维码(是:任务名称、活动日期、签到时间必填)
  510. qrUuid: this.qrUuid || null,
  511. })
  512. .then((res) => {
  513. if (res.code == 200) {
  514. if (callback) {
  515. this.userSummaryId = res.data.userSummaryId ? res.data.userSummaryId : null;
  516. this.qrUuid = res.data.qrUuid ? res.data.qrUuid : null;
  517. // 回传二维码
  518. callback(res);
  519. } else {
  520. this.$router.go(-1);
  521. }
  522. } else {
  523. this.$toast(res.msg);
  524. }
  525. })
  526. .catch((err) => {
  527. this.$toast(err.msg);
  528. });
  529. });
  530. },
  531. onSubmit() {
  532. if (this.$route.query.qrCodeCheck == '1') {
  533. // 执行 ActivityQRCode from表单验证触发
  534. this.$refs.ActivityQRCode.$refs.tabstoreVal
  535. .validate()
  536. .then(() => {
  537. // 验证通过
  538. let ActivityQRCodeData = this.$refs.ActivityQRCode.activityForm || {};
  539. this.onSubmitFun(ActivityQRCodeData);
  540. })
  541. .catch((errors) => {
  542. //验证失败
  543. window.scrollTo(0, 0);
  544. return;
  545. });
  546. } else {
  547. this.onSubmitFun();
  548. }
  549. },
  550. onSubmitFun(ActivityQRCodeData = {}) {
  551. this.setParams(() => {
  552. if (this.flagclick) {
  553. this.flagclick = false;
  554. this.timer = null;
  555. this.timer = setTimeout(() => {
  556. this.flagclick = true;
  557. }, 2000);
  558. insertCustomAnswer({
  559. userSummaryId: this.userSummaryId, // Long 用户总结id,如果为新增则不填,编辑则必填
  560. summaryId: this.$route.query.summaryId, //Long 主管任务id
  561. customItemList: this.collectionItemList, //List<Object> 答案列表
  562. ...ActivityQRCodeData,
  563. qrUuid: this.qrUuid || null,
  564. })
  565. .then((res) => {
  566. if (res.code == 200) {
  567. this.$router.go(-1);
  568. } else {
  569. this.$toast(res.msg);
  570. }
  571. })
  572. .catch((err) => {
  573. this.$toast(err.msg);
  574. });
  575. }
  576. });
  577. },
  578. setParams(callback) {
  579. for (var c = 0; c < this.collectionAnswerlisd.length; c++) {
  580. for (var b = 0; b < this.collectionItemList.length; b++) {
  581. if (this.collectionAnswerlisd[c].id == this.collectionItemList[b].customId) {
  582. this.collectionItemList[b].customOptionList = this.collectionAnswerlisd[c].value;
  583. }
  584. }
  585. }
  586. // // 照片
  587. let zpDataList = this.collectionItemList.find((item) => item.answerType == 'zp');
  588. if (zpDataList && zpDataList.fileInfoList) {
  589. let fileIdList = [];
  590. zpDataList.fileInfoList.forEach((item) => {
  591. fileIdList.push(item.id);
  592. });
  593. zpDataList.fileIdList = fileIdList;
  594. }
  595. // 经销商
  596. // let JXSSataList = this.collectionItemList.find((item) => item.answerType == 'jxs');
  597. // if (this.jxsList.length) {
  598. // let fileIdList = [];
  599. // this.jxsList.forEach((item) => {
  600. // fileIdList.push({
  601. // chainCode: item.chainCode,
  602. // chainName: item.chainName,
  603. // });
  604. // });
  605. // JXSSataList.chainList = fileIdList;
  606. // }
  607. callback && callback();
  608. },
  609. getReportInfo() {
  610. let loading1 = this.$toast.loading({
  611. duration: 0,
  612. message: '加载中...',
  613. forbidClick: true,
  614. });
  615. this.collectionItemList = [];
  616. this.collectionAnswerlisd = [];
  617. getSummaryDetailById({ summaryId: this.$route.query.summaryId }).then((res) => {
  618. loading1.clear();
  619. if (res.code == 200) {
  620. var collectionItemLists = res.data;
  621. for (var q = 0; q < collectionItemLists.length; q++) {
  622. collectionItemLists[q].answerName = undefined;
  623. // 公司
  624. if (
  625. (collectionItemLists[q].answerType == 'gs' ||
  626. collectionItemLists[q].answerType == 'dq' ||
  627. collectionItemLists[q].answerType == 'xsb') &&
  628. this.activaFlag
  629. ) {
  630. this.activaFlag = false;
  631. if (collectionItemLists[q].answerType == 'xsb') {
  632. this.getDeptsBy(collectionItemLists[q].answerValue);
  633. this.getDeptInfo(
  634. 'dept',
  635. collectionItemLists[q].answerType,
  636. collectionItemLists[q].answerValue
  637. );
  638. } else {
  639. this.getDeptInfo(
  640. 'dept',
  641. collectionItemLists[q].answerType,
  642. collectionItemLists[q].answerValue
  643. );
  644. }
  645. }
  646. // 单选
  647. if (
  648. collectionItemLists[q].answerType == 'dx' &&
  649. collectionItemLists[q].showHistory == '1'
  650. ) {
  651. let findCustom = collectionItemLists[q].customOptionList.find((item) => item.checked);
  652. if (findCustom) {
  653. collectionItemLists[q].answerValue = findCustom.customOptionId + '';
  654. }
  655. }
  656. // 多选
  657. if (
  658. collectionItemLists[q].answerType == 'duox' &&
  659. collectionItemLists[q].showHistory == '1'
  660. ) {
  661. let findCustom = [];
  662. collectionItemLists[q].customOptionList.forEach((item) => {
  663. if (item.checked) {
  664. findCustom.push(item.customOptionId + '');
  665. }
  666. });
  667. if (findCustom) {
  668. collectionItemLists[q].answerValue = findCustom.join(',');
  669. }
  670. }
  671. // 照片
  672. if (collectionItemLists[q].answerType == 'zp' && collectionItemLists[q].fileInfoList) {
  673. let fileIdList = [];
  674. collectionItemLists[q].fileInfoList.forEach((item) => {
  675. fileIdList.push(item.id);
  676. });
  677. collectionItemLists[q].fileIdList = fileIdList;
  678. }
  679. }
  680. this.collectionItemList = collectionItemLists;
  681. }
  682. });
  683. },
  684. getThreeDaysAgo() {
  685. let myDate = new Date();
  686. let lw = new Date(myDate - 1000 * 60 * 60 * 24 * 14); //最后一个数字30可改,30天的意思
  687. let lastY = lw.getFullYear();
  688. let lastM = lw.getMonth() + 1;
  689. let lastD = lw.getDate();
  690. let startData =
  691. lastY + '-' + (lastM < 10 ? '0' + lastM : lastM) + '-' + (lastD < 10 ? '0' + lastD : lastD); //三十天之前日期
  692. return startData;
  693. },
  694. GetPreMonthDay(date, monthNum, type) {
  695. var dateArr = date.split('-');
  696. var year = dateArr[0]; //获取当前日期的年份
  697. var month = dateArr[1]; //获取当前日期的月份
  698. var day = dateArr[2]; //获取当前日期的日
  699. var days = new Date(year, month, 0);
  700. days = days.getDate(); //获取当前日期中月的天数
  701. var year2 = year;
  702. var month2 = parseInt(month) - monthNum;
  703. if (month2 <= 0) {
  704. var absM = Math.abs(month2);
  705. year2 = parseInt(year2) - Math.ceil(absM / 12 == 0 ? 1 : parseInt(absM) / 12);
  706. month2 = 12 - (absM % 12);
  707. }
  708. var day2 = day;
  709. var days2 = new Date(year2, month2, 0);
  710. days2 = days2.getDate();
  711. if (day2 > days2) {
  712. day2 = days2;
  713. }
  714. if (month2 < 10) {
  715. month2 = '0' + month2;
  716. }
  717. var t2 = '';
  718. if (monthNum > 0) {
  719. t2 = year2 + '-' + month2 + '-01';
  720. } else {
  721. if (type == 'end') {
  722. var Months = new Date().getMonth() + 1;
  723. var days111 = new Date().getDate();
  724. if (Months < 10) {
  725. Months = '0' + Months;
  726. }
  727. if (days111 < 10) {
  728. days111 = '0' + days111;
  729. }
  730. if (parseInt(month2) >= new Date().getMonth() + 1) {
  731. t2 = year2 + '-' + Months + '-' + days111;
  732. } else {
  733. var daysd = this.getMonthDays(year2, month2);
  734. t2 = year2 + '-' + month2 + '-' + daysd;
  735. }
  736. } else {
  737. t2 = year2 + '-' + month2 + '-' + day2;
  738. }
  739. }
  740. return t2;
  741. },
  742. getMonthDays(year, month) {
  743. var stratDate = new Date(year, month - 1, 1),
  744. endData = new Date(year, month, 1);
  745. var days = (endData - stratDate) / (1000 * 60 * 60 * 24);
  746. return days;
  747. },
  748. getDeptInfo(type, grade, answerValue) {
  749. this.deptForm.type = type;
  750. if (grade == 'dq') {
  751. this.deptForm.parentId = this.companyCode;
  752. } else if (grade == 'xsb') {
  753. this.deptForm.parentId = this.regionCode;
  754. } else {
  755. this.deptForm.type = '';
  756. this.deptForm.parentId = '';
  757. }
  758. getSummaryMobileDeptInfo(this.deptForm).then((res) => {
  759. if (grade == 'dq') {
  760. if (res.data.region != null) {
  761. this.regionList = res.data.region;
  762. // for (var k = 0; k < this.collectionItemList.length; k++) {
  763. // if (this.collectionItemList[k].answerType == 'dq') {
  764. // this.collectionItemList[k].answerName = res.data.region[0].deptName;
  765. // this.collectionItemList[k].answerValue = res.data.region[0].deptCode;
  766. // }
  767. // }
  768. if (answerValue) {
  769. let findCompany = this.companyList.find((item) => item.deptCode == answerValue);
  770. this.onSalesRegionConfirm(findCompany);
  771. } else {
  772. this.onSalesRegionConfirm(this.regionList[0]);
  773. }
  774. }
  775. } else if (grade == 'xsb') {
  776. if (res.data.dept != null) {
  777. this.deptList = res.data.dept;
  778. if (answerValue) {
  779. let findCompany = this.regionList.find((item) => item.deptCode == answerValue);
  780. this.onSalesDepartmentConfirm(findCompany);
  781. } else {
  782. this.onSalesDepartmentConfirm(this.deptList[0]);
  783. }
  784. }
  785. } else if (grade == 'gs') {
  786. this.companyList = res.data.company;
  787. if (answerValue) {
  788. let findCompany = this.companyList.find((item) => item.deptCode == answerValue);
  789. this.onregionConfirm(findCompany);
  790. } else {
  791. this.onregionConfirm(this.companyList[0]);
  792. }
  793. if (res.data.dept != null) {
  794. this.deptList = res.data.dept;
  795. }
  796. if (res.data.region != null) {
  797. this.regionList = res.data.region;
  798. }
  799. }
  800. });
  801. },
  802. getDeptsBy(answerValue) {
  803. getDeptsByUser().then((res) => {
  804. if (res.data && res.code == 200) {
  805. let arr = [];
  806. res.data.forEach((val) => {
  807. arr.push({
  808. ancestors: val.ancestors || '',
  809. deptCode: val.deptCode || '',
  810. deptId: val.deptId || '',
  811. deptLevel: val.deptLevel || '',
  812. deptName: val.deptName || '',
  813. parentId: val.parentId || '',
  814. });
  815. });
  816. this.deptList = arr;
  817. if (answerValue) {
  818. let findCompany = this.regionList.find((item) => item.deptCode == answerValue);
  819. this.onSalesDepartmentConfirm(findCompany);
  820. } else {
  821. this.onSalesDepartmentConfirm(this.deptList[0]);
  822. }
  823. }
  824. });
  825. },
  826. dailyFn(row) {
  827. if (row.status != '0') {
  828. if (row.status == -1) {
  829. var dayTime = row.showDate;
  830. var times = new Date(
  831. dayTime.slice(0, 4) + '-' + dayTime.slice(4, 6) + '-' + dayTime.slice(6, 8)
  832. ).getTime();
  833. var time = new Date('2022-08-25').getTime();
  834. if (times < time) {
  835. this.$dialog.alert({
  836. title: '系统提示',
  837. message: '非常抱歉,8月25日前历史报告数据不存在',
  838. });
  839. } else {
  840. this.$router.push({
  841. path: '/weeklyHistoricalDetils',
  842. query: { reportId: row.id },
  843. });
  844. }
  845. } else {
  846. this.$router.push({
  847. path: '/weeklyHistoricalDetils',
  848. query: { reportId: row.id },
  849. });
  850. }
  851. }
  852. },
  853. onClickLeft() {
  854. this.$router.go(-1);
  855. },
  856. regionClick(val) {
  857. // if(this.powerGrade>4){
  858. this.index = val;
  859. this.RegionShow = true;
  860. // }
  861. },
  862. SalesRegionClick(val) {
  863. this.index = val;
  864. this.SalesRegionShow = true;
  865. },
  866. SalesDepartmentClick(val) {
  867. this.index = val;
  868. this.SalesDepartmentShow = true;
  869. },
  870. StaffClick() {
  871. this.StaffShow = true;
  872. },
  873. StartTimeClick() {
  874. this.StartTimeShow = true;
  875. },
  876. EndTimeClick() {
  877. this.EndTimeShow = true;
  878. },
  879. onSalesRegionConfirm(val) {
  880. this.SalesRegionShow = false;
  881. this.regionCode = val.deptId;
  882. // if (this.index !== '') {
  883. // this.collectionItemList[this.index].answerName = val.deptName;
  884. // this.collectionItemList[this.index].answerValue = val.deptCode;
  885. // for (var k1 = 0; k1 < this.collectionItemList.length; k1++) {
  886. // if (this.collectionItemList[k1].answerType == 'xsb' && val.deptId != '') {
  887. // this.getDeptInfo('dept', 'xsb');
  888. // }
  889. // }
  890. // } else {
  891. for (var k1 = 0; k1 < this.collectionItemList.length; k1++) {
  892. if (this.collectionItemList[k1].answerType == 'xsb') {
  893. this.collectionItemList[k1].answerName = '';
  894. this.collectionItemList[k1].answerValue = '';
  895. }
  896. if (this.collectionItemList[k1].answerType == 'dq') {
  897. this.collectionItemList[k1].answerName = val.deptName;
  898. this.collectionItemList[k1].answerValue = val.deptCode;
  899. }
  900. if (this.collectionItemList[k1].answerType == 'xsb' && val.deptId != '') {
  901. this.getDeptInfo('dept', 'xsb');
  902. }
  903. }
  904. // }
  905. // if (val.deptId != '') {
  906. // this.getDeptInfo('dept', 'xsb');
  907. // }
  908. },
  909. onregionConfirm(val) {
  910. this.RegionShow = false;
  911. this.companyCode = val.deptId;
  912. // if (this.index !== '') {
  913. // this.collectionItemList[this.index].answerName = val.deptName;
  914. // this.collectionItemList[this.index].answerValue = val.deptCode;
  915. // for (var k1 = 0; k1 < this.collectionItemList.length; k1++) {
  916. // if (this.collectionItemList[k1].answerType == 'dq') {
  917. // this.getDeptInfo('dept', 'dq');
  918. // }
  919. // }
  920. // } else {
  921. for (var k1 = 0; k1 < this.collectionItemList.length; k1++) {
  922. if (this.collectionItemList[k1].answerType == 'xsb') {
  923. this.collectionItemList[k1].answerName = '';
  924. this.collectionItemList[k1].answerValue = '';
  925. }
  926. if (this.collectionItemList[k1].answerType == 'xsb') {
  927. this.collectionItemList[k1].answerName = '';
  928. this.collectionItemList[k1].answerValue = '';
  929. }
  930. if (this.collectionItemList[k1].answerType == 'gs') {
  931. this.collectionItemList[k1].answerName = val.deptName;
  932. this.collectionItemList[k1].answerValue = val.deptCode;
  933. }
  934. if (this.collectionItemList[k1].answerType == 'dq') {
  935. this.getDeptInfo('dept', 'dq');
  936. }
  937. }
  938. // }
  939. },
  940. onSalesDepartmentConfirm(val) {
  941. this.SalesDepartmentShow = false;
  942. // if (this.index !== '') {
  943. // this.collectionItemList[this.index].answerName = val.deptName;
  944. // this.collectionItemList[this.index].answerValue = val.deptCode;
  945. // } else {
  946. for (var k1 = 0; k1 < this.collectionItemList.length; k1++) {
  947. if (this.collectionItemList[k1].answerType == 'xsb') {
  948. this.collectionItemList[k1].answerName = val.deptName;
  949. this.collectionItemList[k1].answerValue = val.deptCode;
  950. }
  951. }
  952. // }
  953. },
  954. onStartTimeConfirm(val) {
  955. this.formData.startTime = this.parseTime(new Date(val), '{y}-{m}-{d}') + '';
  956. this.StartTimeShow = false;
  957. this.endminDate = new Date(val);
  958. this.endmaxDate = new Date(this.GetPreMonthDay(this.formData.startTime, -2, 'end'));
  959. if (
  960. new Date(this.formData.startTime).getTime() > new Date(this.formData.endTime).getTime() ||
  961. new Date(this.endmaxDate).getTime() < new Date(this.formData.endTime).getTime()
  962. ) {
  963. this.formData.endTime = this.parseTime(new Date(val), '{y}-{m}-{d}') + '';
  964. this.endcurrentDate = this.GetPreMonthDay(this.formData.startTime, -2);
  965. }
  966. this.list = [];
  967. this.formData.pageNum = 1;
  968. },
  969. onEndTimeConfirm(val) {
  970. this.formData.endTime = this.parseTime(new Date(val), '{y}-{m}-{d}');
  971. this.strtmaxDate = new Date(val);
  972. if (new Date(this.formData.startTime).getTime() > new Date(this.formData.endTime).getTime()) {
  973. this.formData.startTime = this.formData.endTime;
  974. }
  975. this.list = [];
  976. this.formData.pageNum = 1;
  977. this.EndTimeShow = false;
  978. },
  979. // 添加经销商
  980. addJXS() {
  981. this.agentValue = '';
  982. this.moreTypeShow = true;
  983. this.getChainsList();
  984. },
  985. // 删除经销商
  986. closeJXS(item, index) {
  987. item.chainList.splice(index, 1);
  988. },
  989. getChainsList(value = '') {
  990. this.chainsData = [];
  991. chainsList({
  992. chainCode: '', // string 经销商编码
  993. chainName: value, // string 经销商名称
  994. limit: 100,
  995. })
  996. .then((res) => {
  997. if (res.code == 200 && res.rows) {
  998. this.chainsData = res.rows;
  999. } else {
  1000. this.chainsData = [];
  1001. }
  1002. })
  1003. .catch(() => {
  1004. this.chainsData = [];
  1005. });
  1006. },
  1007. onConfirmChainsList(value) {
  1008. if (value && value.chainName != undefined) {
  1009. let JXSSataList = this.collectionItemList.find((item) => item.answerType == 'jxs');
  1010. if (!JXSSataList.chainList) {
  1011. JXSSataList.chainList = [];
  1012. }
  1013. let isFlag = JXSSataList.chainList.find((val) => val.chainCode == value.chainCode);
  1014. if (!isFlag) {
  1015. JXSSataList.chainList.push({
  1016. chainName: value.chainName,
  1017. chainCode: value.chainCode,
  1018. });
  1019. this.moreTypeShow = false;
  1020. } else {
  1021. this.$toast('当前经销商已添加,不能重复添加!');
  1022. }
  1023. }
  1024. },
  1025. },
  1026. };
  1027. </script>
  1028. <style scoped lang="scss">
  1029. .container {
  1030. // background-color: white;
  1031. }
  1032. .van-f-red {
  1033. color: red;
  1034. width: 8px;
  1035. display: inline-block;
  1036. line-height: 26px;
  1037. }
  1038. .formLabel {
  1039. margin: 0 16px;
  1040. border-bottom: 1px solid #f1f1f1;
  1041. }
  1042. .formLabel .van-cell {
  1043. padding: 10px 0;
  1044. }
  1045. .formLabel .van-cell::after {
  1046. border: 0;
  1047. }
  1048. .formLabel .van-field {
  1049. border: 1px solid #f1f1f1;
  1050. padding: 6px;
  1051. width: 100%;
  1052. border-radius: 4px;
  1053. overflow: hidden;
  1054. }
  1055. .formLabel .van-field__control {
  1056. padding: 0 10px;
  1057. }
  1058. .formLabel .formLabeltitle {
  1059. position: absolute;
  1060. top: 8px;
  1061. }
  1062. .lineGrey {
  1063. height: 10px;
  1064. width: 100%;
  1065. background: #f1f1f1;
  1066. }
  1067. .z-checkbox .van-radio {
  1068. padding: 6px 0;
  1069. }
  1070. .z-cell .van-cell__title {
  1071. font-size: 16px;
  1072. }
  1073. .VisitSummaryAdd {
  1074. .tc {
  1075. display: flex;
  1076. justify-content: space-between;
  1077. .submitBtn {
  1078. width: 45%;
  1079. border-radius: 20px;
  1080. }
  1081. }
  1082. .van-form {
  1083. background-color: white;
  1084. }
  1085. }
  1086. </style>
  1087. <style lang="scss">
  1088. .table-headermd {
  1089. font-size: 12px;
  1090. text-align: center;
  1091. position: initial;
  1092. width: 98% !important;
  1093. margin: 0 auto;
  1094. border-right: 0;
  1095. }
  1096. .table-headermd .el-table__header,
  1097. .table-headermd .el-table__body {
  1098. width: 100% !important;
  1099. }
  1100. /*.table-headermd col {width: 6.8rem;}*/
  1101. .table-headermd col:nth-child(4) {
  1102. width: 5.6rem;
  1103. }
  1104. .table-headermd col:nth-child(2),
  1105. .table-headermd col:nth-child(3) {
  1106. width: 4.6rem;
  1107. }
  1108. .table-headermd .van-cell {
  1109. padding: 0 4px;
  1110. height: 100%;
  1111. }
  1112. .table-headermd th.el-table__cell > .cell {
  1113. padding: 0 4px;
  1114. text-align: center;
  1115. }
  1116. .table-headermd th.el-table__cell:first-child > .cell {
  1117. text-align: left;
  1118. }
  1119. .table-headermd th.el-table__cell {
  1120. background-color: #1989fa;
  1121. color: #fff;
  1122. }
  1123. .table-headermd .el-table__cell {
  1124. padding: 4px 0;
  1125. }
  1126. .table-headermd.el-table .cell {
  1127. padding: 0;
  1128. }
  1129. .table-headermd .tipTitle {
  1130. overflow: hidden;
  1131. text-overflow: ellipsis;
  1132. display: -webkit-box;
  1133. -webkit-box-orient: vertical;
  1134. -webkit-line-clamp: 2;
  1135. }
  1136. .table-headermd::before {
  1137. height: 0;
  1138. }
  1139. .xing {
  1140. color: red;
  1141. padding-left: 4px;
  1142. }
  1143. .formLabel .van-radio__label,
  1144. .formLabel .van-checkbox__label {
  1145. font-size: 1.4rem;
  1146. }
  1147. .table-headermd .cell,
  1148. .el-table--border .el-table__cell:first-child .cell {
  1149. padding: 0 4px;
  1150. }
  1151. .van-dialog__confirm,
  1152. .van-dialog__confirm:active {
  1153. color: #1989fa;
  1154. }
  1155. .navBarTOP {
  1156. position: fixed;
  1157. width: 100%;
  1158. z-index: 2;
  1159. top: 0;
  1160. }
  1161. .isTableMust {
  1162. padding: 4px;
  1163. color: #999;
  1164. margin: 0;
  1165. margin-top: -10px;
  1166. }
  1167. .jxsBox {
  1168. .tips {
  1169. text-align: right;
  1170. }
  1171. }
  1172. .VisitSummaryAdd {
  1173. .jxsContent {
  1174. margin-bottom: 10px;
  1175. .item {
  1176. padding: 5px;
  1177. background: #e9e9e9;
  1178. margin: 5px 0;
  1179. .el-popover__reference-wrapper {
  1180. display: flex;
  1181. justify-content: space-between;
  1182. align-items: center;
  1183. }
  1184. .selectItem {
  1185. flex: 1;
  1186. white-space: nowrap;
  1187. overflow: hidden;
  1188. text-overflow: ellipsis;
  1189. font-size: 14px;
  1190. }
  1191. }
  1192. }
  1193. .linep .van-cell__title {
  1194. color: #646566;
  1195. font-weight: 500;
  1196. font-size: 14px;
  1197. }
  1198. }
  1199. .VisitSummaryAdd {
  1200. .van-popup {
  1201. .tips {
  1202. width: 100%;
  1203. height: 40px;
  1204. display: flex;
  1205. align-items: center;
  1206. justify-content: center;
  1207. position: absolute;
  1208. top: 100px;
  1209. z-index: 999999;
  1210. div {
  1211. width: 80%;
  1212. height: 100%;
  1213. display: flex;
  1214. align-items: center;
  1215. justify-content: center;
  1216. text-align: center;
  1217. font-size: 15px;
  1218. background: rgba(225, 236, 250, 0.8);
  1219. border-radius: 6px;
  1220. color: #575656;
  1221. }
  1222. }
  1223. }
  1224. }
  1225. </style>