componVisitSummary.vue 32 KB

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