allowWriteAgainSummary.vue 31 KB

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