componVisitSummary.vue 38 KB

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