allowWriteAgainSummary.vue 31 KB

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